diff --git a/node_modules/cli-table2/.npmignore b/node_modules/cli-table2/.npmignore deleted file mode 100644 index 3a3558960bd..00000000000 --- a/node_modules/cli-table2/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules/ -.idea/ -coverage/ -JasmineAdapter-1.1.2.js -jasmine-1.1.0.js \ No newline at end of file diff --git a/node_modules/cli-table2/.travis.yml b/node_modules/cli-table2/.travis.yml deleted file mode 100644 index 9466d5e0b88..00000000000 --- a/node_modules/cli-table2/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - "0.10" - - "0.11" -after_script: - - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js \ No newline at end of file diff --git a/node_modules/cli-table2/README.md b/node_modules/cli-table2/README.md deleted file mode 100644 index f0352a194d8..00000000000 --- a/node_modules/cli-table2/README.md +++ /dev/null @@ -1,215 +0,0 @@ -CLI Table 2 [![npm version](https://badge.fury.io/js/cli-table2.svg)](http://badge.fury.io/js/cli-table2) [![Build Status](https://travis-ci.org/jamestalmage/cli-table2.svg?branch=master)](https://travis-ci.org/jamestalmage/cli-table2) [![Coverage Status](https://coveralls.io/repos/jamestalmage/cli-table2/badge.png?branch=master)](https://coveralls.io/r/jamestalmage/cli-table2?branch=master) -=========== - -This utility allows you to render unicode-aided tables on the command line from -your node.js scripts. Based on (and api compatible with) the original [cli-table](https://github.com/Automattic/cli-table), -`cli-table2` is nearly a complete rewrite to accommodate column and row spanning. -It passes the entire original cli-table test suite, and should be a drop in -replacement for nearly all users. - -![Screenshot](http://i.imgur.com/sYq4T.png) - -## Features not in the original cli-table - -- Ability to make cells span columns and/or rows. -- Ability to set custom styles per cell (border characters/colors, padding, etc). -- Vertical alignment (top, bottom, center). -- Automatic word wrapping. -- More robust truncation of cell text that contains ansi color characters. -- Better handling of text color that spans multiple lines. -- API compatible with the original cli-table. -- Exhaustive test suite including the entire original cli-table test suite. -- Lots of examples auto-generated from the tests ([basic](https://github.com/jamestalmage/cli-table2/blob/master/basic-usage.md), [advanced](https://github.com/jamestalmage/cli-table2/blob/master/advanced-usage.md)). - -## Features - -- Customizable characters that constitute the table. -- Color/background styling in the header through - [colors.js](http://github.com/marak/colors.js) -- Column width customization -- Text truncation based on predefined widths -- Text alignment (left, right, center) -- Padding (left, right) -- Easy-to-use API - -## Installation - -```bash -npm install cli-table2 -``` - -## How to use - -A portion of the unit test suite is used to generate examples: -- [basic-usage](https://github.com/jamestalmage/cli-table2/blob/master/basic-usage.md) - covers basic uses. -- [advanced](https://github.com/jamestalmage/cli-table2/blob/master/advanced-usage.md) - covers using the new column and row span features. - -This package is api compatible with the original [cli-table](https://github.com/Automattic/cli-table). -So all the original documentation still applies (copied below). - -### Horizontal Tables -```javascript -var Table = require('cli-table2'); - -// instantiate -var table = new Table({ - head: ['TH 1 label', 'TH 2 label'] - , colWidths: [100, 200] -}); - -// table is an Array, so you can `push`, `unshift`, `splice` and friends -table.push( - ['First value', 'Second value'] - , ['First value', 'Second value'] -); - -console.log(table.toString()); -``` - -### Vertical Tables -```javascript -var Table = require('cli-table2'); -var table = new Table(); - -table.push( - { 'Some key': 'Some value' } - , { 'Another key': 'Another value' } -); - -console.log(table.toString()); -``` -### Cross Tables -Cross tables are very similar to vertical tables, with two key differences: - -1. They require a `head` setting when instantiated that has an empty string as the first header -2. The individual rows take the general form of { "Header": ["Row", "Values"] } - -```javascript -var Table = require('cli-table2'); -var table = new Table({ head: ["", "Top Header 1", "Top Header 2"] }); - -table.push( - { 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] } - , { 'Left Header 2': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] } -); - -console.log(table.toString()); -``` - -### Custom styles -The ```chars``` property controls how the table is drawn: -```javascript -var table = new Table({ - chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗' - , 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝' - , 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼' - , 'right': '║' , 'right-mid': '╢' , 'middle': '│' } -}); - -table.push( - ['foo', 'bar', 'baz'] - , ['frob', 'bar', 'quuz'] -); - -console.log(table.toString()); -// Outputs: -// -//╔══════╤═════╤══════╗ -//║ foo │ bar │ baz ║ -//╟──────┼─────┼──────╢ -//║ frob │ bar │ quuz ║ -//╚══════╧═════╧══════╝ -``` - -Empty decoration lines will be skipped, to avoid vertical separator rows just -set the 'mid', 'left-mid', 'mid-mid', 'right-mid' to the empty string: -```javascript -var table = new Table({ chars: {'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': ''} }); -table.push( - ['foo', 'bar', 'baz'] - , ['frobnicate', 'bar', 'quuz'] -); - -console.log(table.toString()); -// Outputs: (note the lack of the horizontal line between rows) -//┌────────────┬─────┬──────┐ -//│ foo │ bar │ baz │ -//│ frobnicate │ bar │ quuz │ -//└────────────┴─────┴──────┘ -``` - -By setting all chars to empty with the exception of 'middle' being set to a -single space and by setting padding to zero, it's possible to get the most -compact layout with no decorations: -```javascript -var table = new Table({ - chars: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '' - , 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '' - , 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '' - , 'right': '' , 'right-mid': '' , 'middle': ' ' }, - style: { 'padding-left': 0, 'padding-right': 0 } -}); - -table.push( - ['foo', 'bar', 'baz'] - , ['frobnicate', 'bar', 'quuz'] -); - -console.log(table.toString()); -// Outputs: -//foo bar baz -//frobnicate bar quuz -``` - -## Build Targets - -Clone the repository and run `npm install` to install all its submodules, then run one of the following commands: - -###### Run the tests with coverage reports. -```bash -$ gulp coverage -``` - -###### Run the tests every time a file changes. -```bash -$ gulp watch-test -``` - -###### Run the examples and print the output to the command line. -```bash -$ gulp example -``` - -Other build targets are available, check `gulpfile.js` for a comprehensive list. - -## Credits - -- James Talmage - author <james.talmage@jrtechnical.com> ([jamestalmage](http://github.com/jamestalmage)) -- Guillermo Rauch - author of the original cli-table <guillermo@learnboost.com> ([Guille](http://github.com/guille)) - -## License - -(The MIT License) - -Copyright (c) 2014 James Talmage <james.talmage@jrtechnical.com> - -Original cli-table code/documentation: Copyright (c) 2010 LearnBoost <dev@learnboost.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/cli-table2/advanced-usage.md b/node_modules/cli-table2/advanced-usage.md deleted file mode 100644 index 71810500ed1..00000000000 --- a/node_modules/cli-table2/advanced-usage.md +++ /dev/null @@ -1,247 +0,0 @@ -##### use colSpan to span columns - (colSpan above normal cell) - ┌───────────────┐ - │ greetings │ - ├───────────────┤ - │ greetings │ - ├───────┬───────┤ - │ hello │ howdy │ - └───────┴───────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'greetings'}], - [{colSpan:2,content:'greetings'}], - ['hello','howdy'] - ); - -``` - - -##### use colSpan to span columns - (colSpan below normal cell) - ┌───────┬───────┐ - │ hello │ howdy │ - ├───────┴───────┤ - │ greetings │ - ├───────────────┤ - │ greetings │ - └───────────────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - ['hello','howdy'], - [{colSpan:2,content:'greetings'}], - [{colSpan:2,content:'greetings'}] - ); - -``` - - -##### use rowSpan to span rows - (rowSpan on the left side) - ┌───────────┬───────────┬───────┐ - │ greetings │ │ hello │ - │ │ greetings ├───────┤ - │ │ │ howdy │ - └───────────┴───────────┴───────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'center'},'hello'], - ['howdy'] - ); - -``` - - -##### use rowSpan to span rows - (rowSpan on the right side) - ┌───────┬───────────┬───────────┐ - │ hello │ greetings │ │ - ├───────┤ │ │ - │ howdy │ │ greetings │ - └───────┴───────────┴───────────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - ['hello',{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'bottom'}], - ['howdy'] - ); - -``` - - -##### mix rowSpan and colSpan together for complex table layouts - ┌───────┬─────┬────┐ - │ hello │ sup │ hi │ - ├───────┤ │ │ - │ howdy │ │ │ - ├───┬───┼──┬──┤ │ - │ o │ k │ │ │ │ - └───┴───┴──┴──┴────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{content:'hello',colSpan:2},{rowSpan:2, colSpan:2,content:'sup'},{rowSpan:3,content:'hi'}], - [{content:'howdy',colSpan:2}], - ['o','k','',''] - ); - -``` - - -##### multi-line content will flow across rows in rowSpan cells - ┌───────┬───────────┬───────────┐ - │ hello │ greetings │ greetings │ - ├───────┤ friends │ friends │ - │ howdy │ │ │ - └───────┴───────────┴───────────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - ['hello',{rowSpan:2,content:'greetings\nfriends'},{rowSpan:2,content:'greetings\nfriends'}], - ['howdy'] - ); - -``` - - -##### multi-line content will flow across rows in rowSpan cells - (complex layout) - ┌───────┬─────┬────┐ - │ hello │ sup │ hi │ - ├───────┤ man │ yo │ - │ howdy │ hey │ │ - ├───┬───┼──┬──┤ │ - │ o │ k │ │ │ │ - └───┴───┴──┴──┴────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{content:'hello',colSpan:2},{rowSpan:2, colSpan:2,content:'sup\nman\nhey'},{rowSpan:3,content:'hi\nyo'}], - [{content:'howdy',colSpan:2}], - ['o','k','',''] - ); - -``` - - -##### rowSpan cells can have a staggered layout - ┌───┬───┐ - │ a │ b │ - │ ├───┤ - │ │ c │ - ├───┤ │ - │ d │ │ - └───┴───┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{content:'a',rowSpan:2},'b'], - [{content:'c',rowSpan:2}], - ['d'] - ); - -``` - - -##### the layout manager automatically create empty cells to fill in the table - ┌───┬───┬──┐ - │ a │ b │ │ - │ ├───┤ │ - │ │ │ │ - │ ├───┴──┤ - │ │ c │ - ├───┤ │ - │ │ │ - └───┴──────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - //notice we only create 3 cells here, but the table ends up having 6. - table.push( - [{content:'a',rowSpan:3,colSpan:2},'b'], - [], - [{content:'c',rowSpan:2,colSpan:2}], - [] - ); -``` - - -##### use table `rowHeights` option to fix row height. The truncation symbol will be shown on the last line. - ┌───────┐ - │ hello │ - │ hi… │ - └───────┘ -```javascript - var table = new Table({rowHeights:[2],style:{head:[],border:[]}}); - - table.push(['hello\nhi\nsup']); - -``` - - -##### if `colWidths` is not specified, the layout manager will automatically widen rows to fit the content - ┌─────────────┐ - │ hello there │ - ├──────┬──────┤ - │ hi │ hi │ - └──────┴──────┘ -```javascript - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'hello there'}], - ['hi', 'hi'] - ); - -``` - - -##### you can specify a column width for only the first row, other rows will be automatically widened to fit content - ┌─────────────┐ - │ hello there │ - ├────┬────────┤ - │ hi │ hi │ - └────┴────────┘ -```javascript - var table = new Table({colWidths:[4],style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'hello there'}], - ['hi',{hAlign:'center',content:'hi'}] - ); - -``` - - -##### a column with a null column width will be automatically widened to fit content - ┌─────────────┐ - │ hello there │ - ├────────┬────┤ - │ hi │ hi │ - └────────┴────┘ -```javascript - var table = new Table({colWidths:[null, 4],style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'hello there'}], - [{hAlign:'right',content:'hi'}, 'hi'] - ); - -``` - - -##### feel free to use colors in your content strings, column widths will be calculated correctly -![table image](https://cdn.rawgit.com/jamestalmage/cli-table2/c806c2636df97f73c732b41aa913cf78d4ac0d39/examples/screenshots/truncation-with-colors.png) -```javascript - var table = new Table({colWidths:[5],style:{head:[],border:[]}}); - - table.push([colors.red('hello')]); - -``` - diff --git a/node_modules/cli-table2/basic-usage.md b/node_modules/cli-table2/basic-usage.md deleted file mode 100644 index 6b566493a22..00000000000 --- a/node_modules/cli-table2/basic-usage.md +++ /dev/null @@ -1,146 +0,0 @@ -##### Basic Usage -![table image](https://cdn.rawgit.com/jamestalmage/cli-table2/c806c2636df97f73c732b41aa913cf78d4ac0d39/examples/screenshots/basic-usage-with-colors.png) -```javascript - // By default, headers will be red, and borders will be grey - var table = new Table({head:['a','b']}); - - table.push(['c','d']); - -``` - - -##### Basic Usage - disable colors - (used often in the examples and tests) - ┌──────┬─────────────────────┬─────────────────────────┬─────────────────┐ - │ Rel │ Change │ By │ When │ - ├──────┼─────────────────────┼─────────────────────────┼─────────────────┤ - │ v0.1 │ Testing something … │ rauchg@gmail.com │ 7 minutes ago │ - ├──────┼─────────────────────┼─────────────────────────┼─────────────────┤ - │ v0.1 │ Testing something … │ rauchg@gmail.com │ 8 minutes ago │ - └──────┴─────────────────────┴─────────────────────────┴─────────────────┘ -```javascript - // For most of these examples, and most of the unit tests we disable colors. - // It makes unit tests easier to write/understand, and allows these pages to - // display the examples as text instead of screen shots. - var table = new Table({ - head: ['Rel', 'Change', 'By', 'When'] - , style: { - head: [] //disable colors in header cells - , border: [] //disable colors for the border - } - , colWidths: [6, 21, 25, 17] //set the widths of each column (optional) - }); - - table.push( - ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago'] - , ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago'] - ); - -``` - - -##### Create vertical tables by adding objects a that specify key-value pairs - ┌────┬──────────────────────┐ - │v0.1│Testing something cool│ - ├────┼──────────────────────┤ - │v0.1│Testing something cool│ - └────┴──────────────────────┘ -```javascript - var table = new Table({ style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); - - table.push( - {'v0.1': 'Testing something cool'} - , {'v0.1': 'Testing something cool'} - ); - -``` - - -##### Cross tables are similar to vertical tables, but include an empty string for the first header - ┌────────┬────────┬──────────────────────┐ - │ │Header 1│Header 2 │ - ├────────┼────────┼──────────────────────┤ - │Header 3│v0.1 │Testing something cool│ - ├────────┼────────┼──────────────────────┤ - │Header 4│v0.1 │Testing something cool│ - └────────┴────────┴──────────────────────┘ -```javascript - var table = new Table({ head: ["", "Header 1", "Header 2"], style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); // clear styles to prevent color output - - table.push( - {"Header 3": ['v0.1', 'Testing something cool'] } - , {"Header 4": ['v0.1', 'Testing something cool'] } - ); - -``` - - -##### Stylize the table with custom border characters - ╔══════╤═════╤══════╗ - ║ foo │ bar │ baz ║ - ╟──────┼─────┼──────╢ - ║ frob │ bar │ quuz ║ - ╚══════╧═════╧══════╝ -```javascript - var table = new Table({ - chars: { - 'top': '═' - , 'top-mid': '╤' - , 'top-left': '╔' - , 'top-right': '╗' - , 'bottom': '═' - , 'bottom-mid': '╧' - , 'bottom-left': '╚' - , 'bottom-right': '╝' - , 'left': '║' - , 'left-mid': '╟' - , 'right': '║' - , 'right-mid': '╢' - }, - style: { - head: [] - , border: [] - } - }); - - table.push( - ['foo', 'bar', 'baz'] - , ['frob', 'bar', 'quuz'] - ); - -``` - - -##### Use ansi colors (i.e. colors.js) to style text within the cells at will, even across multiple lines -![table image](https://cdn.rawgit.com/jamestalmage/cli-table2/c806c2636df97f73c732b41aa913cf78d4ac0d39/examples/screenshots/multi-line-colors.png) -```javascript - var table = new Table({style:{border:[],header:[]}}); - - table.push([ - colors.red('Hello\nhow\nare\nyou?'), - colors.blue('I\nam\nfine\nthanks!') - ]); - -``` - - -##### Set `wordWrap` to true to make lines of text wrap instead of being truncated - ┌───────┬─────────┐ - │ Hello │ I am │ - │ how │ fine │ - │ are │ thanks! │ - │ you? │ │ - └───────┴─────────┘ -```javascript - var table = new Table({ - style:{border:[],header:[]}, - colWidths:[7,9], - wordWrap:true - }); - - table.push([ - 'Hello how are you?', - 'I am fine thanks!' - ]); - -``` - diff --git a/node_modules/cli-table2/examples/basic-usage-examples.js b/node_modules/cli-table2/examples/basic-usage-examples.js deleted file mode 100644 index 0542b17d365..00000000000 --- a/node_modules/cli-table2/examples/basic-usage-examples.js +++ /dev/null @@ -1,222 +0,0 @@ -var Table = require('../src/table'); -var colors = require('colors/safe'); - -module.exports = function(runTest) { - - function it(name, fn) { - var result = fn(); - runTest(name, result[0], result[1], result[2]); - } - - it('Basic Usage',function(){ - function makeTable(){ - // By default, headers will be red, and borders will be grey - var table = new Table({head:['a','b']}); - - table.push(['c','d']); - - return table; - } - - var expected = [ - colors.gray('┌───') + colors.gray('┬───┐') - , colors.gray('│') + colors.red(' a ') + colors.gray('│') + colors.red(' b ') + colors.gray('│') - , colors.gray('├───') + colors.gray('┼───┤') - , colors.gray('│') + (' c ') + colors.gray('│') + (' d ') + colors.gray('│') - , colors.gray('└───') + colors.gray('┴───┘') - ]; - - return [makeTable,expected,'basic-usage-with-colors']; - }); - - it('Basic Usage - disable colors - (used often in the examples and tests)', function (){ - function makeTable(){ - // For most of these examples, and most of the unit tests we disable colors. - // It makes unit tests easier to write/understand, and allows these pages to - // display the examples as text instead of screen shots. - var table = new Table({ - head: ['Rel', 'Change', 'By', 'When'] - , style: { - head: [] //disable colors in header cells - , border: [] //disable colors for the border - } - , colWidths: [6, 21, 25, 17] //set the widths of each column (optional) - }); - - table.push( - ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago'] - , ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago'] - ); - - return table; - } - - var expected = [ - '┌──────┬─────────────────────┬─────────────────────────┬─────────────────┐' - , '│ Rel │ Change │ By │ When │' - , '├──────┼─────────────────────┼─────────────────────────┼─────────────────┤' - , '│ v0.1 │ Testing something … │ rauchg@gmail.com │ 7 minutes ago │' - , '├──────┼─────────────────────┼─────────────────────────┼─────────────────┤' - , '│ v0.1 │ Testing something … │ rauchg@gmail.com │ 8 minutes ago │' - , '└──────┴─────────────────────┴─────────────────────────┴─────────────────┘' - ]; - - return [makeTable,expected]; - }); - - it('Create vertical tables by adding objects a that specify key-value pairs', function() { - function makeTable(){ - var table = new Table({ style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); - - table.push( - {'v0.1': 'Testing something cool'} - , {'v0.1': 'Testing something cool'} - ); - - return table; - } - - var expected = [ - '┌────┬──────────────────────┐' - , '│v0.1│Testing something cool│' - , '├────┼──────────────────────┤' - , '│v0.1│Testing something cool│' - , '└────┴──────────────────────┘' - ]; - - return [makeTable,expected]; - }); - - it('Cross tables are similar to vertical tables, but include an empty string for the first header', function() { - function makeTable(){ - var table = new Table({ head: ["", "Header 1", "Header 2"], style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); // clear styles to prevent color output - - table.push( - {"Header 3": ['v0.1', 'Testing something cool'] } - , {"Header 4": ['v0.1', 'Testing something cool'] } - ); - - return table; - } - - var expected = [ - '┌────────┬────────┬──────────────────────┐' - , '│ │Header 1│Header 2 │' - , '├────────┼────────┼──────────────────────┤' - , '│Header 3│v0.1 │Testing something cool│' - , '├────────┼────────┼──────────────────────┤' - , '│Header 4│v0.1 │Testing something cool│' - , '└────────┴────────┴──────────────────────┘' - ]; - - return [makeTable,expected]; - }); - - it('Stylize the table with custom border characters', function (){ - function makeTable(){ - var table = new Table({ - chars: { - 'top': '═' - , 'top-mid': '╤' - , 'top-left': '╔' - , 'top-right': '╗' - , 'bottom': '═' - , 'bottom-mid': '╧' - , 'bottom-left': '╚' - , 'bottom-right': '╝' - , 'left': '║' - , 'left-mid': '╟' - , 'right': '║' - , 'right-mid': '╢' - }, - style: { - head: [] - , border: [] - } - }); - - table.push( - ['foo', 'bar', 'baz'] - , ['frob', 'bar', 'quuz'] - ); - - return table; - } - - var expected = [ - '╔══════╤═════╤══════╗' - , '║ foo │ bar │ baz ║' - , '╟──────┼─────┼──────╢' - , '║ frob │ bar │ quuz ║' - , '╚══════╧═════╧══════╝' - ]; - - return [makeTable,expected]; - }); - - it('Use ansi colors (i.e. colors.js) to style text within the cells at will, even across multiple lines',function(){ - function makeTable(){ - var table = new Table({style:{border:[],header:[]}}); - - table.push([ - colors.red('Hello\nhow\nare\nyou?'), - colors.blue('I\nam\nfine\nthanks!') - ]); - - return table; - } - - var expected = [ - '┌───────┬─────────┐' - , '│ ' + colors.red('Hello') + ' │ ' + colors.blue('I') + ' │' - , '│ ' + colors.red('how') + ' │ ' + colors.blue('am') + ' │' - , '│ ' + colors.red('are') + ' │ ' + colors.blue('fine') + ' │' - , '│ ' + colors.red('you?') + ' │ ' + colors.blue('thanks!') + ' │' - , '└───────┴─────────┘' - ]; - - return [makeTable,expected,'multi-line-colors']; - }); - - it('Set `wordWrap` to true to make lines of text wrap instead of being truncated',function(){ - function makeTable(){ - var table = new Table({ - style:{border:[],header:[]}, - colWidths:[7,9], - wordWrap:true - }); - - table.push([ - 'Hello how are you?', - 'I am fine thanks!' - ]); - - return table; - } - - var expected = [ - '┌───────┬─────────┐' - , '│ Hello │ I am │' - , '│ how │ fine │' - , '│ are │ thanks! │' - , '│ you? │ │' - , '└───────┴─────────┘' - ]; - - return [makeTable,expected]; - }); -}; - -/* Expectation - ready to be copy/pasted and filled in. DO NOT DELETE THIS - - - var expected = [ - '┌──┬───┬──┬──┐' - , '│ │ │ │ │' - , '├──┼───┼──┼──┤' - , '│ │ … │ │ │' - , '├──┼───┼──┼──┤' - , '│ │ … │ │ │' - , '└──┴───┴──┴──┘' - ]; - */ \ No newline at end of file diff --git a/node_modules/cli-table2/examples/col-and-row-span-examples.js b/node_modules/cli-table2/examples/col-and-row-span-examples.js deleted file mode 100644 index 9cd6c1ad08b..00000000000 --- a/node_modules/cli-table2/examples/col-and-row-span-examples.js +++ /dev/null @@ -1,358 +0,0 @@ -var Table = require('../src/table'); -var colors = require('colors/safe'); - -module.exports = function(runTest) { - - function it(name,fn) { - var result = fn(); - runTest(name,result[0],result[1],result[2]); - } - - it('use colSpan to span columns - (colSpan above normal cell)',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'greetings'}], - [{colSpan:2,content:'greetings'}], - ['hello','howdy'] - ); - - return table; - } - - var expected = [ - '┌───────────────┐' - , '│ greetings │' - , '├───────────────┤' - , '│ greetings │' - , '├───────┬───────┤' - , '│ hello │ howdy │' - , '└───────┴───────┘' - ]; - - return [makeTable,expected]; - }); - - it('use colSpan to span columns - (colSpan below normal cell)',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - ['hello','howdy'], - [{colSpan:2,content:'greetings'}], - [{colSpan:2,content:'greetings'}] - ); - - return table; - } - - var expected = [ - '┌───────┬───────┐' - , '│ hello │ howdy │' - , '├───────┴───────┤' - , '│ greetings │' - , '├───────────────┤' - , '│ greetings │' - , '└───────────────┘' - ]; - - return [makeTable,expected]; - }); - - it('use rowSpan to span rows - (rowSpan on the left side)',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'center'},'hello'], - ['howdy'] - ); - - return table; - } - - var expected = [ - '┌───────────┬───────────┬───────┐' - , '│ greetings │ │ hello │' - , '│ │ greetings ├───────┤' - , '│ │ │ howdy │' - , '└───────────┴───────────┴───────┘' - ]; - - return [makeTable,expected]; - }); - - - it('use rowSpan to span rows - (rowSpan on the right side)',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - ['hello',{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'bottom'}], - ['howdy'] - ); - - return table; - } - - var expected = [ - '┌───────┬───────────┬───────────┐' - , '│ hello │ greetings │ │' - , '├───────┤ │ │' - , '│ howdy │ │ greetings │' - , '└───────┴───────────┴───────────┘' - ]; - - return[makeTable,expected]; - }); - - it('mix rowSpan and colSpan together for complex table layouts',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{content:'hello',colSpan:2},{rowSpan:2, colSpan:2,content:'sup'},{rowSpan:3,content:'hi'}], - [{content:'howdy',colSpan:2}], - ['o','k','',''] - ); - - return table; - } - - var expected = [ - '┌───────┬─────┬────┐' - , '│ hello │ sup │ hi │' - , '├───────┤ │ │' - , '│ howdy │ │ │' - , '├───┬───┼──┬──┤ │' - , '│ o │ k │ │ │ │' - , '└───┴───┴──┴──┴────┘' - ]; - - return [makeTable,expected]; - }); - - it('multi-line content will flow across rows in rowSpan cells',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - ['hello',{rowSpan:2,content:'greetings\nfriends'},{rowSpan:2,content:'greetings\nfriends'}], - ['howdy'] - ); - - return table; - } - - var expected = [ - '┌───────┬───────────┬───────────┐' - , '│ hello │ greetings │ greetings │' - , '├───────┤ friends │ friends │' - , '│ howdy │ │ │' - , '└───────┴───────────┴───────────┘' - ]; - - return [makeTable, expected]; - }); - - it('multi-line content will flow across rows in rowSpan cells - (complex layout)',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{content:'hello',colSpan:2},{rowSpan:2, colSpan:2,content:'sup\nman\nhey'},{rowSpan:3,content:'hi\nyo'}], - [{content:'howdy',colSpan:2}], - ['o','k','',''] - ); - - return table; - } - - var expected = [ - '┌───────┬─────┬────┐' - , '│ hello │ sup │ hi │' - , '├───────┤ man │ yo │' - , '│ howdy │ hey │ │' - , '├───┬───┼──┬──┤ │' - , '│ o │ k │ │ │ │' - , '└───┴───┴──┴──┴────┘' - ]; - - return [makeTable,expected]; - }); - - it('rowSpan cells can have a staggered layout',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{content:'a',rowSpan:2},'b'], - [{content:'c',rowSpan:2}], - ['d'] - ); - - return table; - } - - var expected = [ - '┌───┬───┐' - , '│ a │ b │' - , '│ ├───┤' - , '│ │ c │' - , '├───┤ │' - , '│ d │ │' - , '└───┴───┘' - ]; - - return [makeTable,expected]; - }); - - it('the layout manager automatically create empty cells to fill in the table',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - //notice we only create 3 cells here, but the table ends up having 6. - table.push( - [{content:'a',rowSpan:3,colSpan:2},'b'], - [], - [{content:'c',rowSpan:2,colSpan:2}], - [] - ); - return table; - } - - var expected = [ - '┌───┬───┬──┐' - , '│ a │ b │ │' // top-right and bottom-left cells are automatically created to fill the empty space - , '│ ├───┤ │' - , '│ │ │ │' - , '│ ├───┴──┤' - , '│ │ c │' - , '├───┤ │' - , '│ │ │' - , '└───┴──────┘' - ]; - - return [makeTable,expected]; - }); - - it('use table `rowHeights` option to fix row height. The truncation symbol will be shown on the last line.',function(){ - function makeTable(){ - var table = new Table({rowHeights:[2],style:{head:[],border:[]}}); - - table.push(['hello\nhi\nsup']); - - return table; - } - - var expected = [ - '┌───────┐' - , '│ hello │' - , '│ hi… │' - , '└───────┘' - ]; - - return [makeTable,expected]; - }); - - it('if `colWidths` is not specified, the layout manager will automatically widen rows to fit the content',function(){ - function makeTable(){ - var table = new Table({style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'hello there'}], - ['hi', 'hi'] - ); - - return table; - } - - var expected = [ - '┌─────────────┐' - , '│ hello there │' - , '├──────┬──────┤' - , '│ hi │ hi │' - , '└──────┴──────┘' - ]; - - return [makeTable,expected]; - }); - - it('you can specify a column width for only the first row, other rows will be automatically widened to fit content',function(){ - function makeTable(){ - var table = new Table({colWidths:[4],style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'hello there'}], - ['hi',{hAlign:'center',content:'hi'}] - ); - - return table; - } - - var expected = [ - '┌─────────────┐' - , '│ hello there │' - , '├────┬────────┤' - , '│ hi │ hi │' - , '└────┴────────┘' - ]; - - return [makeTable, expected]; - }); - - it('a column with a null column width will be automatically widened to fit content',function(){ - function makeTable(){ - var table = new Table({colWidths:[null, 4],style:{head:[],border:[]}}); - - table.push( - [{colSpan:2,content:'hello there'}], - [{hAlign:'right',content:'hi'}, 'hi'] - ); - - return table; - } - - var expected = [ - '┌─────────────┐' - , '│ hello there │' - , '├────────┬────┤' - , '│ hi │ hi │' - , '└────────┴────┘' - ]; - - return [makeTable,expected]; - }); - - it('feel free to use colors in your content strings, column widths will be calculated correctly',function(){ - function makeTable(){ - var table = new Table({colWidths:[5],style:{head:[],border:[]}}); - - table.push([colors.red('hello')]); - - return table; - } - - var expected = [ - '┌─────┐' - , '│ ' + colors.red('he') + '… │' - , '└─────┘' - ]; - - return [makeTable,expected,'truncation-with-colors']; - }); -}; - -/* - - var expected = [ - '┌──┬───┬──┬──┐' - , '│ │ │ │ │' - , '├──┼───┼──┼──┤' - , '│ │ … │ │ │' - , '├──┼───┼──┼──┤' - , '│ │ … │ │ │' - , '└──┴───┴──┴──┘' - ]; - */ \ No newline at end of file diff --git a/node_modules/cli-table2/examples/screenshots/basic-usage-with-colors.png b/node_modules/cli-table2/examples/screenshots/basic-usage-with-colors.png deleted file mode 100644 index 88399fca009..00000000000 Binary files a/node_modules/cli-table2/examples/screenshots/basic-usage-with-colors.png and /dev/null differ diff --git a/node_modules/cli-table2/examples/screenshots/multi-line-colors.png b/node_modules/cli-table2/examples/screenshots/multi-line-colors.png deleted file mode 100644 index 36f6f34f8de..00000000000 Binary files a/node_modules/cli-table2/examples/screenshots/multi-line-colors.png and /dev/null differ diff --git a/node_modules/cli-table2/examples/screenshots/truncation-with-colors.png b/node_modules/cli-table2/examples/screenshots/truncation-with-colors.png deleted file mode 100644 index d14b9d2fe17..00000000000 Binary files a/node_modules/cli-table2/examples/screenshots/truncation-with-colors.png and /dev/null differ diff --git a/node_modules/cli-table2/gulpfile.js b/node_modules/cli-table2/gulpfile.js deleted file mode 100644 index 53496260683..00000000000 --- a/node_modules/cli-table2/gulpfile.js +++ /dev/null @@ -1,73 +0,0 @@ -var gulp = require('gulp'); -var gutil = require('gulp-util'); -var mocha = require('gulp-mocha'); -var istanbul = require('gulp-istanbul'); -var printExample = require('./lib/print-example'); -var _ = require('lodash'); - -gulp.task('test',mochaTask); -gulp.task('coverage',coverage()); -gulp.task('coverage-api',coverage({grep:'@api'})); - -gulp.task('watch-test',function(){ - gulp.watch(['test/**','src/**','examples/**'],['test']); - mochaTask(); -}); - -gulp.task('example',function(){ - printExample.logExample(require('./examples/basic-usage-examples')); - printExample.logExample(require('./examples/col-and-row-span-examples')); -}); - -/** - * Do NOT run this in the same commit when you are adding images. - * Commit the images, then run this. - */ -gulp.task('example-md',['example-md-basic','example-md-advanced']); -gulp.task('example-md-basic',function(cb){ - printExample.mdExample(require('./examples/basic-usage-examples'),'basic-usage.md',cb); -}); -gulp.task('example-md-advanced',function(cb){ - printExample.mdExample(require('./examples/col-and-row-span-examples'),'advanced-usage.md',cb); -}); - -function coverage(opts){ - opts = opts || {}; - - function coverageTask(cb){ - gulp.src(['src/*.js']) - .pipe(istanbul()) // Covering files - .pipe(istanbul.hookRequire()) // Force `require` to return covered files - .on('error', logMochaError) - .on('finish', function () { - gulp.src(['test/*.js']) - .pipe(mocha(opts)) - .on('error',function(err){ - logMochaError(err); - if(cb) cb(err); - }) - .pipe(istanbul.writeReports()) // Creating the reports after tests run - .on('end', function(){ - if(cb) cb(); - }); - }); - } - - return coverageTask; -} - -function mochaTask(){ - return gulp.src(['test/*.js'],{read:false}) - .pipe(mocha({ - growl:true - })) - .on('error',logMochaError); -} - -function logMochaError(err){ - if(err && err.message){ - gutil.log(err.message); - } else { - gutil.log.apply(gutil,arguments); - } -} \ No newline at end of file diff --git a/node_modules/cli-table2/index.js b/node_modules/cli-table2/index.js deleted file mode 100644 index b49d920dd3e..00000000000 --- a/node_modules/cli-table2/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./src/table'); \ No newline at end of file diff --git a/node_modules/cli-table2/lib/print-example.js b/node_modules/cli-table2/lib/print-example.js deleted file mode 100644 index ae23609cb2d..00000000000 --- a/node_modules/cli-table2/lib/print-example.js +++ /dev/null @@ -1,123 +0,0 @@ -var chai = require('chai'); -var expect = chai.expect; -var colors = require('colors/safe'); -var _ = require('lodash'); -var fs = require('fs'); -var git = require('git-rev'); - -function logExample(fn){ - runPrintingExample(fn, - function logName(name){ - console.log(colors.gray('========= ') + name + colors.gray(' ================')); - }, - console.log, //logTable - console.log, //logCode - console.log, //logSeparator - identity //screenShot - ) -} - -function mdExample(fn,file,cb){ - git.long(function(commitHash){ - var buffer = []; - - runPrintingExample(fn, - function logName(name){ - buffer.push('##### ' + name); - }, - function logTable(table){ - //md files won't render color strings properly. - table = stripColors(table); - - // indent table so is displayed preformatted text - table = ' ' + (table.split('\n').join('\n ')); - - buffer.push(table); - }, - function logCode(code){ - buffer.push('```javascript'); - buffer.push(stripColors(code)); - buffer.push('```'); - }, - function logSeparator(sep){ - buffer.push(stripColors(sep)); - }, - function logScreenShot(image){ - buffer.push('![table image](https://cdn.rawgit.com/jamestalmage/cli-table2/' - + commitHash + '/examples/screenshots/' + image + '.png)'); - } - ); - - fs.writeFileSync(file,buffer.join('\n')); - - if(cb){cb();} - }); -} - -/** - * Actually runs the tests and verifies the functions create the expected output. - * @param name of the test suite, used in the mocha.describe call. - * @param fn a function which creates the test suite. - */ -function runTest(name,fn){ - function testExample(name,fn,expected){ - it(name,function(){ - expect(fn().toString()).to.equal(expected.join('\n')); - }); - } - - describe(name,function () { - fn(testExample,identity); - }); -} - -/** - * Common execution for runs that print output (either to console or to a Markdown file); - * @param fn - a function containing the tests/demos. - * @param logName - callback to print the name of this test to the console or file. - * @param logTable - callback to print the output of the table to the console or file. - * @param logCode - callback to print the output of the table to the console or file. - * @param logSeparator - callback to print extra whitespace between demos. - * @param logScreenShot - write out a link to the screenShot image. - */ -function runPrintingExample(fn,logName,logTable,logCode,logSeparator,logScreenShot){ - - /** - * Called by every test/demo - * @param name - the name of this test. - * @param makeTable - a function which builds the table under test. Also, The contents of this function will be printed. - * @param expected - The expected result. - * @param screenshot - If present, there is an image containing a screenshot of the output - */ - function printExample(name,makeTable,expected,screenshot){ - var code = makeTable.toString().split('\n').slice(1,-2).join('\n'); - - logName(name); - if(screenshot && logScreenShot){ - logScreenShot(screenshot); - } - else { - logTable(makeTable().toString()); - } - logCode(code); - logSeparator('\n'); - } - - fn(printExample); -} - -// removes all the color characters from a string -function stripColors(str){ - return str.split( /\u001b\[(?:\d*;){0,5}\d*m/g).join(''); -} - -// returns the first arg - used as snapshot function -function identity(str){ - return str; -} - -module.exports = { - mdExample:mdExample, - logExample:logExample, - runTest:runTest -}; \ No newline at end of file diff --git a/node_modules/cli-table2/node_modules/string-width/index.js b/node_modules/cli-table2/node_modules/string-width/index.js deleted file mode 100644 index b9bec62440a..00000000000 --- a/node_modules/cli-table2/node_modules/string-width/index.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; -var stripAnsi = require('strip-ansi'); -var codePointAt = require('code-point-at'); -var isFullwidthCodePoint = require('is-fullwidth-code-point'); - -// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345 -module.exports = function (str) { - if (typeof str !== 'string' || str.length === 0) { - return 0; - } - - var width = 0; - - str = stripAnsi(str); - - for (var i = 0; i < str.length; i++) { - var code = codePointAt(str, i); - - // ignore control characters - if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) { - continue; - } - - // surrogates - if (code >= 0x10000) { - i++; - } - - if (isFullwidthCodePoint(code)) { - width += 2; - } else { - width++; - } - } - - return width; -}; diff --git a/node_modules/cli-table2/node_modules/string-width/license b/node_modules/cli-table2/node_modules/string-width/license deleted file mode 100644 index 654d0bfe943..00000000000 --- a/node_modules/cli-table2/node_modules/string-width/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/cli-table2/node_modules/string-width/package.json b/node_modules/cli-table2/node_modules/string-width/package.json deleted file mode 100644 index 154c4856be1..00000000000 --- a/node_modules/cli-table2/node_modules/string-width/package.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "_from": "string-width@^1.0.1", - "_id": "string-width@1.0.2", - "_inBundle": false, - "_integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "_location": "/cli-table2/string-width", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "string-width@^1.0.1", - "name": "string-width", - "escapedName": "string-width", - "rawSpec": "^1.0.1", - "saveSpec": null, - "fetchSpec": "^1.0.1" - }, - "_requiredBy": [ - "/cli-table2" - ], - "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "_shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", - "_spec": "string-width@^1.0.1", - "_where": "/Users/rebecca/code/npm/node_modules/cli-table2", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/string-width/issues" - }, - "bundleDependencies": false, - "dependencies": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - }, - "deprecated": false, - "description": "Get the visual width of a string - the number of columns required to display it", - "devDependencies": { - "ava": "*", - "xo": "*" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "homepage": "https://github.com/sindresorhus/string-width#readme", - "keywords": [ - "string", - "str", - "character", - "char", - "unicode", - "width", - "visual", - "column", - "columns", - "fullwidth", - "full-width", - "full", - "ansi", - "escape", - "codes", - "cli", - "command-line", - "terminal", - "console", - "cjk", - "chinese", - "japanese", - "korean", - "fixed-width" - ], - "license": "MIT", - "name": "string-width", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/string-width.git" - }, - "scripts": { - "test": "xo && ava" - }, - "version": "1.0.2" -} diff --git a/node_modules/cli-table2/node_modules/string-width/readme.md b/node_modules/cli-table2/node_modules/string-width/readme.md deleted file mode 100644 index 1ab42c93580..00000000000 --- a/node_modules/cli-table2/node_modules/string-width/readme.md +++ /dev/null @@ -1,42 +0,0 @@ -# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width) - -> Get the visual width of a string - the number of columns required to display it - -Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. - -Useful to be able to measure the actual width of command-line output. - - -## Install - -``` -$ npm install --save string-width -``` - - -## Usage - -```js -const stringWidth = require('string-width'); - -stringWidth('古'); -//=> 2 - -stringWidth('\u001b[1m古\u001b[22m'); -//=> 2 - -stringWidth('a'); -//=> 1 -``` - - -## Related - -- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module -- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string -- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/cli-table2/package.json b/node_modules/cli-table2/package.json deleted file mode 100644 index c502a45cdd9..00000000000 --- a/node_modules/cli-table2/package.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "_args": [ - [ - "cli-table2@0.2.0", - "/Users/rebecca/code/npm" - ] - ], - "_from": "cli-table2@0.2.0", - "_id": "cli-table2@0.2.0", - "_inBundle": false, - "_integrity": "sha1-LR738hig54biFFQFYtS9F3/jLZc=", - "_location": "/cli-table2", - "_phantomChildren": { - "code-point-at": "1.1.0", - "number-is-nan": "1.0.1" - }, - "_requested": { - "type": "version", - "registry": true, - "raw": "cli-table2@0.2.0", - "name": "cli-table2", - "escapedName": "cli-table2", - "rawSpec": "0.2.0", - "saveSpec": null, - "fetchSpec": "0.2.0" - }, - "_requiredBy": [ - "/", - "/npm-audit-report" - ], - "_resolved": "https://registry.npmjs.org/cli-table2/-/cli-table2-0.2.0.tgz", - "_spec": "0.2.0", - "_where": "/Users/rebecca/code/npm", - "author": { - "name": "James Talmage" - }, - "bugs": { - "url": "https://github.com/jamestalmage/cli-table2/issues" - }, - "dependencies": { - "colors": "^1.1.2", - "lodash": "^3.10.1", - "string-width": "^1.0.1" - }, - "description": "Pretty unicode tables for the command line. Based on the original cli-table.", - "devDependencies": { - "ansi-256-colors": "^1.1.0", - "chai": "^3.4.1", - "cli-table": "^0.3.1", - "coveralls": "^2.11.4", - "git-rev": "^0.2.1", - "growl": "^1.8.1", - "gulp": "^3.9.0", - "gulp-istanbul": "^0.10.3", - "gulp-mocha": "^2.2.0", - "gulp-util": "^3.0.7", - "sinon": "^1.17.2", - "sinon-chai": "^2.8.0" - }, - "directories": { - "test": "test" - }, - "homepage": "https://github.com/jamestalmage/cli-table2", - "keywords": [ - "node", - "command", - "line", - "cli", - "table", - "tables", - "tabular", - "unicode", - "colors", - "grid" - ], - "license": "MIT", - "main": "index.js", - "name": "cli-table2", - "optionalDependencies": { - "colors": "^1.1.2" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/jamestalmage/cli-table2.git" - }, - "scripts": { - "test": "gulp coverage" - }, - "version": "0.2.0" -} diff --git a/node_modules/cli-table2/src/cell.js b/node_modules/cli-table2/src/cell.js deleted file mode 100644 index 1281b979b19..00000000000 --- a/node_modules/cli-table2/src/cell.js +++ /dev/null @@ -1,364 +0,0 @@ -var _ = require('lodash'); -var utils = require('./utils'); - -/** - * A representation of a cell within the table. - * Implementations must have `init` and `draw` methods, - * as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties. - * @param options - * @constructor - */ -function Cell(options){ - this.setOptions(options); -} - -Cell.prototype.setOptions = function(options){ - if(_.isString(options) || _.isNumber(options) || _.isBoolean(options)){ - options = {content:''+options}; - } - options = options || {}; - this.options = options; - var content = options.content; - if (_.isString(content) || _.isNumber(content) || _.isBoolean(content)) { - this.content = String(content); - } else if (!content) { - this.content = ''; - } else { - throw new Error('Content needs to be a primitive, got: ' + (typeof content)); - } - this.colSpan = options.colSpan || 1; - this.rowSpan = options.rowSpan || 1; -}; - -Cell.prototype.mergeTableOptions = function(tableOptions,cells){ - this.cells = cells; - - var optionsChars = this.options.chars || {}; - var tableChars = tableOptions.chars; - var chars = this.chars = {}; - _.forEach(CHAR_NAMES,function(name){ - setOption(optionsChars,tableChars,name,chars); - }); - - this.truncate = this.options.truncate || tableOptions.truncate; - - var style = this.options.style = this.options.style || {}; - var tableStyle = tableOptions.style; - setOption(style, tableStyle, 'padding-left', this); - setOption(style, tableStyle, 'padding-right', this); - this.head = style.head || tableStyle.head; - this.border = style.border || tableStyle.border; - - var fixedWidth = tableOptions.colWidths[this.x]; - if(tableOptions.wordWrap && fixedWidth){ - fixedWidth -= this.paddingLeft + this.paddingRight; - this.lines = utils.colorizeLines(utils.wordWrap(fixedWidth,this.content)); - } - else { - this.lines = utils.colorizeLines(this.content.split('\n')); - } - - this.desiredWidth = utils.strlen(this.content) + this.paddingLeft + this.paddingRight; - this.desiredHeight = this.lines.length; -}; - -/** - * Each cell will have it's `x` and `y` values set by the `layout-manager` prior to - * `init` being called; - * @type {Number} - */ - -Cell.prototype.x = null; -Cell.prototype.y = null; - -/** - * Initializes the Cells data structure. - * - * @param tableOptions - A fully populated set of tableOptions. - * In addition to the standard default values, tableOptions must have fully populated the - * `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number - * of columns or rows (respectively) in this table, and each array item must be a Number. - * - */ -Cell.prototype.init = function(tableOptions){ - var x = this.x; - var y = this.y; - this.widths = tableOptions.colWidths.slice(x, x + this.colSpan); - this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan); - this.width = _.reduce(this.widths,sumPlusOne); - this.height = _.reduce(this.heights,sumPlusOne); - - this.hAlign = this.options.hAlign || tableOptions.colAligns[x]; - this.vAlign = this.options.vAlign || tableOptions.rowAligns[y]; - - this.drawRight = x + this.colSpan == tableOptions.colWidths.length; -}; - -/** - * Draws the given line of the cell. - * This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`. - * @param lineNum - can be `top`, `bottom` or a numerical line number. - * @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how - * many rows below it's being called from. Otherwise it's undefined. - * @returns {String} The representation of this line. - */ -Cell.prototype.draw = function(lineNum,spanningCell){ - if(lineNum == 'top') return this.drawTop(this.drawRight); - if(lineNum == 'bottom') return this.drawBottom(this.drawRight); - var padLen = Math.max(this.height - this.lines.length, 0); - var padTop; - switch (this.vAlign){ - case 'center': - padTop = Math.ceil(padLen / 2); - break; - case 'bottom': - padTop = padLen; - break; - default : - padTop = 0; - } - if( (lineNum < padTop) || (lineNum >= (padTop + this.lines.length))){ - return this.drawEmpty(this.drawRight,spanningCell); - } - var forceTruncation = (this.lines.length > this.height) && (lineNum + 1 >= this.height); - return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation,spanningCell); -}; - -/** - * Renders the top line of the cell. - * @param drawRight - true if this method should render the right edge of the cell. - * @returns {String} - */ -Cell.prototype.drawTop = function(drawRight){ - var content = []; - if(this.cells){ //TODO: cells should always exist - some tests don't fill it in though - _.forEach(this.widths,function(width,index){ - content.push(this._topLeftChar(index)); - content.push( - utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'],width) - ); - },this); - } - else { - content.push(this._topLeftChar(0)); - content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'],this.width)); - } - if(drawRight){ - content.push(this.chars[this.y == 0 ? 'topRight' : 'rightMid']); - } - return this.wrapWithStyleColors('border',content.join('')); -}; - -Cell.prototype._topLeftChar = function(offset){ - var x = this.x+offset; - var leftChar; - if(this.y == 0){ - leftChar = x == 0 ? 'topLeft' : (offset == 0 ? 'topMid' : 'top'); - } else { - if(x == 0){ - leftChar = 'leftMid'; - } - else { - leftChar = offset == 0 ? 'midMid' : 'bottomMid'; - if(this.cells){ //TODO: cells should always exist - some tests don't fill it in though - var spanAbove = this.cells[this.y-1][x] instanceof Cell.ColSpanCell; - if(spanAbove){ - leftChar = offset == 0 ? 'topMid' : 'mid'; - } - if(offset == 0){ - var i = 1; - while(this.cells[this.y][x-i] instanceof Cell.ColSpanCell){ - i++; - } - if(this.cells[this.y][x-i] instanceof Cell.RowSpanCell){ - leftChar = 'leftMid'; - } - } - } - } - } - return this.chars[leftChar]; -}; - -Cell.prototype.wrapWithStyleColors = function(styleProperty,content){ - if(this[styleProperty] && this[styleProperty].length){ - try { - var colors = require('colors/safe'); - for(var i = this[styleProperty].length - 1; i >= 0; i--){ - colors = colors[this[styleProperty][i]]; - } - return colors(content); - } catch (e) { - return content; - } - } - else { - return content; - } -}; - -/** - * Renders a line of text. - * @param lineNum - Which line of text to render. This is not necessarily the line within the cell. - * There may be top-padding above the first line of text. - * @param drawRight - true if this method should render the right edge of the cell. - * @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even - * if the text fits. This is used when the cell is vertically truncated. If `false` the text should - * only include the truncation symbol if the text will not fit horizontally within the cell width. - * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined. - * @returns {String} - */ -Cell.prototype.drawLine = function(lineNum,drawRight,forceTruncationSymbol,spanningCell){ - var left = this.chars[this.x == 0 ? 'left' : 'middle']; - if(this.x && spanningCell && this.cells){ - var cellLeft = this.cells[this.y+spanningCell][this.x-1]; - while(cellLeft instanceof ColSpanCell){ - cellLeft = this.cells[cellLeft.y][cellLeft.x-1]; - } - if(!(cellLeft instanceof RowSpanCell)){ - left = this.chars['rightMid']; - } - } - var leftPadding = utils.repeat(' ', this.paddingLeft); - var right = (drawRight ? this.chars['right'] : ''); - var rightPadding = utils.repeat(' ', this.paddingRight); - var line = this.lines[lineNum]; - var len = this.width - (this.paddingLeft + this.paddingRight); - if(forceTruncationSymbol) line += this.truncate || '…'; - var content = utils.truncate(line,len,this.truncate); - content = utils.pad(content, len, ' ', this.hAlign); - content = leftPadding + content + rightPadding; - return this.stylizeLine(left,content,right); -}; - -Cell.prototype.stylizeLine = function(left,content,right){ - left = this.wrapWithStyleColors('border',left); - right = this.wrapWithStyleColors('border',right); - if(this.y === 0){ - content = this.wrapWithStyleColors('head',content); - } - return left + content + right; -}; - -/** - * Renders the bottom line of the cell. - * @param drawRight - true if this method should render the right edge of the cell. - * @returns {String} - */ -Cell.prototype.drawBottom = function(drawRight){ - var left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid']; - var content = utils.repeat(this.chars.bottom,this.width); - var right = drawRight ? this.chars['bottomRight'] : ''; - return this.wrapWithStyleColors('border',left + content + right); -}; - -/** - * Renders a blank line of text within the cell. Used for top and/or bottom padding. - * @param drawRight - true if this method should render the right edge of the cell. - * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined. - * @returns {String} - */ -Cell.prototype.drawEmpty = function(drawRight,spanningCell){ - var left = this.chars[this.x == 0 ? 'left' : 'middle']; - if(this.x && spanningCell && this.cells){ - var cellLeft = this.cells[this.y+spanningCell][this.x-1]; - while(cellLeft instanceof ColSpanCell){ - cellLeft = this.cells[cellLeft.y][cellLeft.x-1]; - } - if(!(cellLeft instanceof RowSpanCell)){ - left = this.chars['rightMid']; - } - } - var right = (drawRight ? this.chars['right'] : ''); - var content = utils.repeat(' ',this.width); - return this.stylizeLine(left , content , right); -}; - -/** - * A Cell that doesn't do anything. It just draws empty lines. - * Used as a placeholder in column spanning. - * @constructor - */ -function ColSpanCell(){} - -ColSpanCell.prototype.draw = function(){ - return ''; -}; - -ColSpanCell.prototype.init = function(tableOptions){}; - - -/** - * A placeholder Cell for a Cell that spans multiple rows. - * It delegates rendering to the original cell, but adds the appropriate offset. - * @param originalCell - * @constructor - */ -function RowSpanCell(originalCell){ - this.originalCell = originalCell; -} - -RowSpanCell.prototype.init = function(tableOptions){ - var y = this.y; - var originalY = this.originalCell.y; - this.cellOffset = y - originalY; - this.offset = findDimension(tableOptions.rowHeights,originalY,this.cellOffset); -}; - -RowSpanCell.prototype.draw = function(lineNum){ - if(lineNum == 'top'){ - return this.originalCell.draw(this.offset,this.cellOffset); - } - if(lineNum == 'bottom'){ - return this.originalCell.draw('bottom'); - } - return this.originalCell.draw(this.offset + 1 + lineNum); -}; - -ColSpanCell.prototype.mergeTableOptions = -RowSpanCell.prototype.mergeTableOptions = function(){}; - -// HELPER FUNCTIONS -function setOption(objA,objB,nameB,targetObj){ - var nameA = nameB.split('-'); - if(nameA.length > 1) { - nameA[1] = nameA[1].charAt(0).toUpperCase() + nameA[1].substr(1); - nameA = nameA.join(''); - targetObj[nameA] = objA[nameA] || objA[nameB] || objB[nameA] || objB[nameB]; - } - else { - targetObj[nameB] = objA[nameB] || objB[nameB]; - } -} - -function findDimension(dimensionTable, startingIndex, span){ - var ret = dimensionTable[startingIndex]; - for(var i = 1; i < span; i++){ - ret += 1 + dimensionTable[startingIndex + i]; - } - return ret; -} - -function sumPlusOne(a,b){ - return a+b+1; -} - -var CHAR_NAMES = [ 'top' - , 'top-mid' - , 'top-left' - , 'top-right' - , 'bottom' - , 'bottom-mid' - , 'bottom-left' - , 'bottom-right' - , 'left' - , 'left-mid' - , 'mid' - , 'mid-mid' - , 'right' - , 'right-mid' - , 'middle' -]; -module.exports = Cell; -module.exports.ColSpanCell = ColSpanCell; -module.exports.RowSpanCell = RowSpanCell; \ No newline at end of file diff --git a/node_modules/cli-table2/src/layout-manager.js b/node_modules/cli-table2/src/layout-manager.js deleted file mode 100644 index c17ce34cbec..00000000000 --- a/node_modules/cli-table2/src/layout-manager.js +++ /dev/null @@ -1,235 +0,0 @@ -var _ = require('lodash'); -var Cell = require('./cell'); -var RowSpanCell = Cell.RowSpanCell; -var ColSpanCell = Cell.ColSpanCell; - -(function(){ - function layoutTable(table){ - _.forEach(table,function(row,rowIndex){ - _.forEach(row,function(cell,columnIndex){ - cell.y = rowIndex; - cell.x = columnIndex; - for(var y = rowIndex; y >= 0; y--){ - var row2 = table[y]; - var xMax = (y === rowIndex) ? columnIndex : row2.length; - for(var x = 0; x < xMax; x++){ - var cell2 = row2[x]; - while(cellsConflict(cell,cell2)){ - cell.x++; - } - } - } - }); - }); - } - - function maxWidth(table) { - var mw = 0; - _.forEach(table, function (row) { - _.forEach(row, function (cell) { - mw = Math.max(mw,cell.x + (cell.colSpan || 1)); - }); - }); - return mw; - } - - function maxHeight(table){ - return table.length; - } - - function cellsConflict(cell1,cell2){ - var yMin1 = cell1.y; - var yMax1 = cell1.y - 1 + (cell1.rowSpan || 1); - var yMin2 = cell2.y; - var yMax2 = cell2.y - 1 + (cell2.rowSpan || 1); - var yConflict = !(yMin1 > yMax2 || yMin2 > yMax1); - - var xMin1= cell1.x; - var xMax1 = cell1.x - 1 + (cell1.colSpan || 1); - var xMin2= cell2.x; - var xMax2 = cell2.x - 1 + (cell2.colSpan || 1); - var xConflict = !(xMin1 > xMax2 || xMin2 > xMax1); - - return yConflict && xConflict; - } - - function conflictExists(rows,x,y){ - var i_max = Math.min(rows.length-1,y); - var cell = {x:x,y:y}; - for(var i = 0; i <= i_max; i++){ - var row = rows[i]; - for(var j = 0; j < row.length; j++){ - if(cellsConflict(cell,row[j])){ - return true; - } - } - } - return false; - } - - function allBlank(rows,y,xMin,xMax){ - for(var x = xMin; x < xMax; x++){ - if(conflictExists(rows,x,y)){ - return false; - } - } - return true; - } - - function addRowSpanCells(table){ - _.forEach(table,function(row,rowIndex){ - _.forEach(row,function(cell){ - for(var i = 1; i < cell.rowSpan; i++){ - var rowSpanCell = new RowSpanCell(cell); - rowSpanCell.x = cell.x; - rowSpanCell.y = cell.y + i; - rowSpanCell.colSpan = cell.colSpan; - insertCell(rowSpanCell,table[rowIndex+i]); - } - }); - }); - } - - function addColSpanCells(cellRows){ - for(var rowIndex = cellRows.length-1; rowIndex >= 0; rowIndex--) { - var cellColumns = cellRows[rowIndex]; - for (var columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) { - var cell = cellColumns[columnIndex]; - for (var k = 1; k < cell.colSpan; k++) { - var colSpanCell = new ColSpanCell(); - colSpanCell.x = cell.x + k; - colSpanCell.y = cell.y; - cellColumns.splice(columnIndex + 1, 0, colSpanCell); - } - } - } - } - - function insertCell(cell,row){ - var x = 0; - while(x < row.length && (row[x].x < cell.x)) { - x++; - } - row.splice(x,0,cell); - } - - function fillInTable(table){ - var h_max = maxHeight(table); - var w_max = maxWidth(table); - for(var y = 0; y < h_max; y++){ - for(var x = 0; x < w_max; x++){ - if(!conflictExists(table,x,y)){ - var opts = {x:x,y:y,colSpan:1,rowSpan:1}; - x++; - while(x < w_max && !conflictExists(table,x,y)){ - opts.colSpan++; - x++; - } - var y2 = y + 1; - while(y2 < h_max && allBlank(table,y2,opts.x,opts.x+opts.colSpan)){ - opts.rowSpan++; - y2++; - } - - var cell = new Cell(opts); - cell.x = opts.x; - cell.y = opts.y; - insertCell(cell,table[y]); - } - } - } - } - - function generateCells(rows){ - return _.map(rows,function(row){ - if(!_.isArray(row)){ - var key = Object.keys(row)[0]; - row = row[key]; - if(_.isArray(row)){ - row = row.slice(); - row.unshift(key); - } - else { - row = [key,row]; - } - } - return _.map(row,function(cell){ - return new Cell(cell); - }); - }); - } - - function makeTableLayout(rows){ - var cellRows = generateCells(rows); - layoutTable(cellRows); - fillInTable(cellRows); - addRowSpanCells(cellRows); - addColSpanCells(cellRows); - return cellRows; - } - - module.exports = { - makeTableLayout: makeTableLayout, - layoutTable: layoutTable, - addRowSpanCells: addRowSpanCells, - maxWidth:maxWidth, - fillInTable:fillInTable, - computeWidths:makeComputeWidths('colSpan','desiredWidth','x',1), - computeHeights:makeComputeWidths('rowSpan','desiredHeight','y',1) - }; -})(); - -function makeComputeWidths(colSpan,desiredWidth,x,forcedMin){ - return function(vals,table){ - var result = []; - var spanners = []; - _.forEach(table,function(row){ - _.forEach(row,function(cell){ - if((cell[colSpan] || 1) > 1){ - spanners.push(cell); - } - else { - result[cell[x]] = Math.max(result[cell[x]] || 0, cell[desiredWidth] || 0, forcedMin); - } - }); - }); - - _.forEach(vals,function(val,index){ - if(_.isNumber(val)){ - result[index] = val; - } - }); - - //_.forEach(spanners,function(cell){ - for(var k = spanners.length - 1; k >=0; k--){ - var cell = spanners[k]; - var span = cell[colSpan]; - var col = cell[x]; - var existingWidth = result[col]; - var editableCols = _.isNumber(vals[col]) ? 0 : 1; - for(var i = 1; i < span; i ++){ - existingWidth += 1 + result[col + i]; - if(!_.isNumber(vals[col + i])){ - editableCols++; - } - } - if(cell[desiredWidth] > existingWidth){ - i = 0; - while(editableCols > 0 && cell[desiredWidth] > existingWidth){ - if(!_.isNumber(vals[col+i])){ - var dif = Math.round( (cell[desiredWidth] - existingWidth) / editableCols ); - existingWidth += dif; - result[col + i] += dif; - editableCols--; - } - i++; - } - } - } - - _.extend(vals,result); - for(var j = 0; j < vals.length; j++){ - vals[j] = Math.max(forcedMin, vals[j] || 0); - } - }; -} diff --git a/node_modules/cli-table2/src/table.js b/node_modules/cli-table2/src/table.js deleted file mode 100644 index 09af0d7e6ba..00000000000 --- a/node_modules/cli-table2/src/table.js +++ /dev/null @@ -1,78 +0,0 @@ - -var utils = require('./utils'); -var tableLayout = require('./layout-manager'); -var _ = require('lodash'); - -function Table(options){ - this.options = utils.mergeOptions(options); -} - -Table.prototype.__proto__ = Array.prototype; - -Table.prototype.toString = function(){ - var array = this; - var headersPresent = this.options.head && this.options.head.length; - if(headersPresent){ - array = [this.options.head]; - if(this.length){ - array.push.apply(array,this); - } - } - else { - this.options.style.head=[]; - } - - var cells = tableLayout.makeTableLayout(array); - - _.forEach(cells,function(row){ - _.forEach(row,function(cell){ - cell.mergeTableOptions(this.options,cells); - },this); - },this); - - tableLayout.computeWidths(this.options.colWidths,cells); - tableLayout.computeHeights(this.options.rowHeights,cells); - - _.forEach(cells,function(row,rowIndex){ - _.forEach(row,function(cell,cellIndex){ - cell.init(this.options); - },this); - },this); - - var result = []; - - for(var rowIndex = 0; rowIndex < cells.length; rowIndex++){ - var row = cells[rowIndex]; - var heightOfRow = this.options.rowHeights[rowIndex]; - - if(rowIndex === 0 || !this.options.style.compact || (rowIndex == 1 && headersPresent)){ - doDraw(row,'top',result); - } - - for(var lineNum = 0; lineNum < heightOfRow; lineNum++){ - doDraw(row,lineNum,result); - } - - if(rowIndex + 1 == cells.length){ - doDraw(row,'bottom',result); - } - } - - return result.join('\n'); -}; - -function doDraw(row,lineNum,result){ - var line = []; - _.forEach(row,function(cell){ - line.push(cell.draw(lineNum)); - }); - var str = line.join(''); - if(str.length) result.push(str); -} - -Table.prototype.__defineGetter__('width', function (){ - var str = this.toString().split("\n"); - return str[0].length; -}); - -module.exports = Table; \ No newline at end of file diff --git a/node_modules/cli-table2/src/utils.js b/node_modules/cli-table2/src/utils.js deleted file mode 100644 index 9dae6e53aa4..00000000000 --- a/node_modules/cli-table2/src/utils.js +++ /dev/null @@ -1,304 +0,0 @@ -var _ = require('lodash'); -var stringWidth = require('string-width'); - -function codeRegex(capture){ - return capture ? /\u001b\[((?:\d*;){0,5}\d*)m/g : /\u001b\[(?:\d*;){0,5}\d*m/g -} - -function strlen(str){ - var code = codeRegex(); - var stripped = ("" + str).replace(code,''); - var split = stripped.split("\n"); - return split.reduce(function (memo, s) { return (stringWidth(s) > memo) ? stringWidth(s) : memo }, 0); -} - -function repeat(str,times){ - return Array(times + 1).join(str); -} - -function pad(str, len, pad, dir) { - var length = strlen(str); - if (len + 1 >= length) { - var padlen = len - length; - switch (dir) { - case 'right': - str = repeat(pad, padlen) + str; - break; - - case 'center': - var right = Math.ceil((padlen) / 2); - var left = padlen - right; - str = repeat(pad, left) + str + repeat(pad, right); - break; - - default : - str = str + repeat(pad,padlen); - break; - } - } - return str; -} - -var codeCache = {}; - -function addToCodeCache(name,on,off){ - on = '\u001b[' + on + 'm'; - off = '\u001b[' + off + 'm'; - codeCache[on] = {set:name,to:true}; - codeCache[off] = {set:name,to:false}; - codeCache[name] = {on:on,off:off}; -} - -//https://github.com/Marak/colors.js/blob/master/lib/styles.js -addToCodeCache('bold', 1, 22); -addToCodeCache('italics', 3, 23); -addToCodeCache('underline', 4, 24); -addToCodeCache('inverse', 7, 27); -addToCodeCache('strikethrough', 9, 29); - - -function updateState(state, controlChars){ - var controlCode = controlChars[1] ? parseInt(controlChars[1].split(';')[0]) : 0; - if ( (controlCode >= 30 && controlCode <= 39) - || (controlCode >= 90 && controlCode <= 97) - ) { - state.lastForegroundAdded = controlChars[0]; - return; - } - if ( (controlCode >= 40 && controlCode <= 49) - || (controlCode >= 100 && controlCode <= 107) - ) { - state.lastBackgroundAdded = controlChars[0]; - return; - } - if (controlCode === 0) { - for (var i in state) { - /* istanbul ignore else */ - if (state.hasOwnProperty(i)) { - delete state[i]; - } - } - return; - } - var info = codeCache[controlChars[0]]; - if (info) { - state[info.set] = info.to; - } -} - -function readState(line){ - var code = codeRegex(true); - var controlChars = code.exec(line); - var state = {}; - while(controlChars !== null){ - updateState(state, controlChars); - controlChars = code.exec(line); - } - return state; -} - -function unwindState(state,ret){ - var lastBackgroundAdded = state.lastBackgroundAdded; - var lastForegroundAdded = state.lastForegroundAdded; - - delete state.lastBackgroundAdded; - delete state.lastForegroundAdded; - - _.forEach(state,function(value,key){ - if(value){ - ret += codeCache[key].off; - } - }); - - if(lastBackgroundAdded && (lastBackgroundAdded != '\u001b[49m')){ - ret += '\u001b[49m'; - } - if(lastForegroundAdded && (lastForegroundAdded != '\u001b[39m')){ - ret += '\u001b[39m'; - } - - return ret; -} - -function rewindState(state,ret){ - var lastBackgroundAdded = state.lastBackgroundAdded; - var lastForegroundAdded = state.lastForegroundAdded; - - delete state.lastBackgroundAdded; - delete state.lastForegroundAdded; - - _.forEach(state,function(value,key){ - if(value){ - ret = codeCache[key].on + ret; - } - }); - - if(lastBackgroundAdded && (lastBackgroundAdded != '\u001b[49m')){ - ret = lastBackgroundAdded + ret; - } - if(lastForegroundAdded && (lastForegroundAdded != '\u001b[39m')){ - ret = lastForegroundAdded + ret; - } - - return ret; -} - -function truncateWidth(str, desiredLength){ - if (str.length === strlen(str)) { - return str.substr(0, desiredLength); - } - - while (strlen(str) > desiredLength){ - str = str.slice(0, -1); - } - - return str; -} - -function truncateWidthWithAnsi(str, desiredLength){ - var code = codeRegex(true); - var split = str.split(codeRegex()); - var splitIndex = 0; - var retLen = 0; - var ret = ''; - var myArray; - var state = {}; - - while(retLen < desiredLength){ - myArray = code.exec(str); - var toAdd = split[splitIndex]; - splitIndex++; - if (retLen + strlen(toAdd) > desiredLength){ - toAdd = truncateWidth(toAdd, desiredLength - retLen); - } - ret += toAdd; - retLen += strlen(toAdd); - - if(retLen < desiredLength){ - if (!myArray) { break; } // full-width chars may cause a whitespace which cannot be filled - ret += myArray[0]; - updateState(state,myArray); - } - } - - return unwindState(state,ret); -} - -function truncate(str, desiredLength, truncateChar){ - truncateChar = truncateChar || '…'; - var lengthOfStr = strlen(str); - if(lengthOfStr <= desiredLength){ - return str; - } - desiredLength -= strlen(truncateChar); - - ret = truncateWidthWithAnsi(str, desiredLength); - - return ret + truncateChar; -} - - -function defaultOptions(){ - return{ - chars: { - 'top': '─' - , 'top-mid': '┬' - , 'top-left': '┌' - , 'top-right': '┐' - , 'bottom': '─' - , 'bottom-mid': '┴' - , 'bottom-left': '└' - , 'bottom-right': '┘' - , 'left': '│' - , 'left-mid': '├' - , 'mid': '─' - , 'mid-mid': '┼' - , 'right': '│' - , 'right-mid': '┤' - , 'middle': '│' - } - , truncate: '…' - , colWidths: [] - , rowHeights: [] - , colAligns: [] - , rowAligns: [] - , style: { - 'padding-left': 1 - , 'padding-right': 1 - , head: ['red'] - , border: ['grey'] - , compact : false - } - , head: [] - }; -} - -function mergeOptions(options,defaults){ - options = options || {}; - defaults = defaults || defaultOptions(); - var ret = _.extend({}, defaults, options); - ret.chars = _.extend({}, defaults.chars, options.chars); - ret.style = _.extend({}, defaults.style, options.style); - return ret; -} - -function wordWrap(maxLength,input){ - var lines = []; - var split = input.split(/(\s+)/g); - var line = []; - var lineLength = 0; - var whitespace; - for (var i = 0; i < split.length; i += 2) { - var word = split[i]; - var newLength = lineLength + strlen(word); - if (lineLength > 0 && whitespace) { - newLength += whitespace.length; - } - if(newLength > maxLength){ - if(lineLength !== 0){ - lines.push(line.join('')); - } - line = [word]; - lineLength = strlen(word); - } else { - line.push(whitespace || '', word); - lineLength = newLength; - } - whitespace = split[i+1]; - } - if(lineLength){ - lines.push(line.join('')); - } - return lines; -} - -function multiLineWordWrap(maxLength, input){ - var output = []; - input = input.split('\n'); - for(var i = 0; i < input.length; i++){ - output.push.apply(output,wordWrap(maxLength,input[i])); - } - return output; -} - -function colorizeLines(input){ - var state = {}; - var output = []; - for(var i = 0; i < input.length; i++){ - var line = rewindState(state,input[i]) ; - state = readState(line); - var temp = _.extend({},state); - output.push(unwindState(temp,line)); - } - return output; -} - -module.exports = { - strlen:strlen, - repeat:repeat, - pad:pad, - truncate:truncate, - mergeOptions:mergeOptions, - wordWrap:multiLineWordWrap, - colorizeLines:colorizeLines -}; diff --git a/node_modules/cli-table2/test/cell-test.js b/node_modules/cli-table2/test/cell-test.js deleted file mode 100644 index 6e2ddd796ed..00000000000 --- a/node_modules/cli-table2/test/cell-test.js +++ /dev/null @@ -1,936 +0,0 @@ -describe('Cell',function(){ - var chai = require('chai'); - var expect = chai.expect; - var sinon = require('sinon'); - var sinonChai = require("sinon-chai"); - chai.use(sinonChai); - - var colors = require('colors'); - var Cell = require('../src/cell'); - var RowSpanCell = Cell.RowSpanCell; - var ColSpanCell = Cell.ColSpanCell; - var mergeOptions = require('../src/utils').mergeOptions; - - function defaultOptions(){ - //overwrite coloring of head and border by default for easier testing. - return mergeOptions({style:{head:[],border:[]}}); - } - - function defaultChars(){ - return { - 'top': '─' - , 'topMid': '┬' - , 'topLeft': '┌' - , 'topRight': '┐' - , 'bottom': '─' - , 'bottomMid': '┴' - , 'bottomLeft': '└' - , 'bottomRight': '┘' - , 'left': '│' - , 'leftMid': '├' - , 'mid': '─' - , 'midMid': '┼' - , 'right': '│' - , 'rightMid': '┤' - , 'middle': '│' - }; - } - - describe('constructor',function(){ - it('colSpan and rowSpan default to 1',function(){ - var cell = new Cell(); - expect(cell.colSpan).to.equal(1); - expect(cell.rowSpan).to.equal(1); - }); - - it('colSpan and rowSpan can be set via constructor',function(){ - var cell = new Cell({rowSpan:2,colSpan:3}); - expect(cell.rowSpan).to.equal(2); - expect(cell.colSpan).to.equal(3); - }); - - it('content can be set as a string',function(){ - var cell = new Cell('hello\nworld'); - expect(cell.content).to.equal('hello\nworld'); - }); - - it('content can be set as a options property',function(){ - var cell = new Cell({content:'hello\nworld'}); - expect(cell.content).to.equal('hello\nworld'); - }); - - it('default content is an empty string',function(){ - var cell = new Cell(); - expect(cell.content).to.equal(''); - }); - - it('new Cell(null) will have empty string content',function(){ - var cell = new Cell(null); - expect(cell.content).to.equal(''); - }); - - it('new Cell({content: null}) will have empty string content',function(){ - var cell = new Cell({content: null}); - expect(cell.content).to.equal(''); - }); - - it('new Cell(0) will have "0" as content',function(){ - var cell = new Cell(0); - expect(cell.content).to.equal('0'); - }); - - it('new Cell({content: 0}) will have "0" as content',function(){ - var cell = new Cell({content: 0}); - expect(cell.content).to.equal('0'); - }); - - it('new Cell(false) will have "false" as content',function(){ - var cell = new Cell(false); - expect(cell.content).to.equal('false'); - }); - - it('new Cell({content: false}) will have "false" as content',function(){ - var cell = new Cell({content: false}); - expect(cell.content).to.equal('false'); - }); - }); - - describe('mergeTableOptions',function(){ - describe('chars',function(){ - it('unset chars take on value of table',function(){ - var cell = new Cell(); - var tableOptions = defaultOptions(); - cell.mergeTableOptions(tableOptions); - expect(cell.chars).to.eql(defaultChars()); - }); - - it('set chars override the value of table',function(){ - var cell = new Cell({chars:{bottomRight:'='}}); - cell.mergeTableOptions(defaultOptions()); - var chars = defaultChars(); - chars.bottomRight = '='; - expect(cell.chars).to.eql(chars); - }); - - it('hyphenated names will be converted to camel-case',function(){ - var cell = new Cell({chars:{'bottom-left':'='}}); - cell.mergeTableOptions(defaultOptions()); - var chars = defaultChars(); - chars.bottomLeft = '='; - expect(cell.chars).to.eql(chars); - }); - }); - - describe('truncate',function(){ - it('if unset takes on value of table',function(){ - var cell = new Cell(); - cell.mergeTableOptions(defaultOptions()); - expect(cell.truncate).to.equal('…'); - }); - - it('if set overrides value of table',function(){ - var cell = new Cell({truncate:'...'}); - cell.mergeTableOptions(defaultOptions()); - expect(cell.truncate).to.equal('...'); - }); - }); - - describe('style.padding-left', function () { - it('if unset will be copied from tableOptions.style', function () { - var cell = new Cell(); - cell.mergeTableOptions(defaultOptions()); - expect(cell.paddingLeft).to.equal(1); - - cell = new Cell(); - var tableOptions = defaultOptions(); - tableOptions.style['padding-left'] = 2; - cell.mergeTableOptions(tableOptions); - expect(cell.paddingLeft).to.equal(2); - - cell = new Cell(); - tableOptions = defaultOptions(); - tableOptions.style.paddingLeft = 3; - cell.mergeTableOptions(tableOptions); - expect(cell.paddingLeft).to.equal(3); - }); - - it('if set will override tableOptions.style', function () { - var cell = new Cell({style:{'padding-left':2}}); - cell.mergeTableOptions(defaultOptions()); - expect(cell.paddingLeft).to.equal(2); - - cell = new Cell({style:{paddingLeft:3}}); - cell.mergeTableOptions(defaultOptions()); - expect(cell.paddingLeft).to.equal(3); - }); - }); - - describe('style.padding-right', function () { - it('if unset will be copied from tableOptions.style', function () { - var cell = new Cell(); - cell.mergeTableOptions(defaultOptions()); - expect(cell.paddingRight).to.equal(1); - - cell = new Cell(); - var tableOptions = defaultOptions(); - tableOptions.style['padding-right'] = 2; - cell.mergeTableOptions(tableOptions); - expect(cell.paddingRight).to.equal(2); - - cell = new Cell(); - tableOptions = defaultOptions(); - tableOptions.style.paddingRight = 3; - cell.mergeTableOptions(tableOptions); - expect(cell.paddingRight).to.equal(3); - }); - - it('if set will override tableOptions.style', function () { - var cell = new Cell({style:{'padding-right':2}}); - cell.mergeTableOptions(defaultOptions()); - expect(cell.paddingRight).to.equal(2); - - cell = new Cell({style:{paddingRight:3}}); - cell.mergeTableOptions(defaultOptions()); - expect(cell.paddingRight).to.equal(3); - }); - }); - - describe('desiredWidth',function(){ - it('content(hello) padding(1,1) == 7',function(){ - var cell = new Cell('hello'); - cell.mergeTableOptions(defaultOptions()); - expect(cell.desiredWidth).to.equal(7); - }); - - it('content(hi) padding(1,2) == 5',function(){ - var cell = new Cell({content:'hi',style:{paddingRight:2}}); - var tableOptions = defaultOptions(); - cell.mergeTableOptions(tableOptions); - expect(cell.desiredWidth).to.equal(5); - }); - - it('content(hi) padding(3,2) == 7',function(){ - var cell = new Cell({content:'hi',style:{paddingLeft:3,paddingRight:2}}); - var tableOptions = defaultOptions(); - cell.mergeTableOptions(tableOptions); - expect(cell.desiredWidth).to.equal(7); - }); - }); - - describe('desiredHeight',function(){ - it('1 lines of text',function(){ - var cell = new Cell('hi'); - cell.mergeTableOptions(defaultOptions()); - expect(cell.desiredHeight).to.equal(1); - }); - - it('2 lines of text',function(){ - var cell = new Cell('hi\nbye'); - cell.mergeTableOptions(defaultOptions()); - expect(cell.desiredHeight).to.equal(2); - }); - - it('2 lines of text',function(){ - var cell = new Cell('hi\nbye\nyo'); - cell.mergeTableOptions(defaultOptions()); - expect(cell.desiredHeight).to.equal(3); - }); - }); - }); - - describe('init',function(){ - describe('hAlign',function(){ - it('if unset takes colAlign value from tableOptions',function(){ - var tableOptions = defaultOptions(); - tableOptions.colAligns = ['left','right','both']; - var cell = new Cell(); - cell.x = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.hAlign).to.equal('left'); - cell = new Cell(); - cell.x = 1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.hAlign).to.equal('right'); - cell = new Cell(); - cell.mergeTableOptions(tableOptions); - cell.x=2; - cell.init(tableOptions); - expect(cell.hAlign).to.equal('both'); - }); - - it('if set overrides tableOptions',function(){ - var tableOptions = defaultOptions(); - tableOptions.colAligns = ['left','right','both']; - var cell = new Cell({hAlign:'right'}); - cell.x = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.hAlign).to.equal('right'); - cell = new Cell({hAlign:'left'}); - cell.x = 1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.hAlign).to.equal('left'); - cell = new Cell({hAlign:'right'}); - cell.x = 2; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.hAlign).to.equal('right'); - }); - }); - - describe('vAlign',function(){ - it('if unset takes rowAlign value from tableOptions',function(){ - var tableOptions = defaultOptions(); - tableOptions.rowAligns = ['top','bottom','center']; - var cell = new Cell(); - cell.y=0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.vAlign).to.equal('top'); - cell = new Cell(); - cell.y = 1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.vAlign).to.equal('bottom'); - cell = new Cell(); - cell.y = 2; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.vAlign).to.equal('center'); - }); - - it('if set overrides tableOptions',function(){ - var tableOptions = defaultOptions(); - tableOptions.rowAligns = ['top','bottom','center']; - - var cell = new Cell({vAlign:'bottom'}); - cell.y = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.vAlign).to.equal('bottom'); - - cell = new Cell({vAlign:'top'}); - cell.y = 1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.vAlign).to.equal('top'); - - cell = new Cell({vAlign:'center'}); - cell.y = 2; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.vAlign).to.equal('center'); - }); - }); - - describe('width', function(){ - it('will match colWidth of x',function(){ - var tableOptions = defaultOptions(); - tableOptions.colWidths = [5,10,15]; - - var cell = new Cell(); - cell.x = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.width).to.equal(5); - - cell = new Cell(); - cell.x = 1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.width).to.equal(10); - - cell = new Cell(); - cell.x = 2; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.width).to.equal(15); - }); - - it('will add colWidths if colSpan > 1',function(){ - var tableOptions = defaultOptions(); - tableOptions.colWidths = [5,10,15]; - - var cell = new Cell({colSpan:2}); - cell.x=0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.width).to.equal(16); - - cell = new Cell({colSpan:2}); - cell.x=1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.width).to.equal(26); - - cell = new Cell({colSpan:3}); - cell.x=0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.width).to.equal(32); - }); - }); - - describe('height', function(){ - it('will match rowHeight of x',function(){ - var tableOptions = defaultOptions(); - tableOptions.rowHeights = [5,10,15]; - - var cell = new Cell(); - cell.y=0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.height).to.equal(5); - - cell = new Cell(); - cell.y=1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.height).to.equal(10); - - cell = new Cell(); - cell.y=2; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.height).to.equal(15); - }); - - it('will add rowHeights if rowSpan > 1',function(){ - var tableOptions = defaultOptions(); - tableOptions.rowHeights = [5,10,15]; - - var cell = new Cell({rowSpan:2}); - cell.y = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.height).to.equal(16); - - cell = new Cell({rowSpan:2}); - cell.y = 1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.height).to.equal(26); - - cell = new Cell({rowSpan:3}); - cell.y = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.height).to.equal(32); - }); - }); - - describe('drawRight', function(){ - var tableOptions; - - beforeEach(function(){ - tableOptions = defaultOptions(); - tableOptions.colWidths = [20,20,20]; - }); - - it('col 1 of 3, with default colspan',function(){ - var cell = new Cell(); - cell.x = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.drawRight).to.equal(false); - }); - - it('col 2 of 3, with default colspan',function(){ - var cell = new Cell(); - cell.x = 1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.drawRight).to.equal(false); - }); - - it('col 3 of 3, with default colspan',function(){ - var cell = new Cell(); - cell.x = 2; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.drawRight).to.equal(true); - }); - - it('col 3 of 4, with default colspan',function(){ - var cell = new Cell(); - cell.x = 2; - tableOptions.colWidths = [20,20,20,20]; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.drawRight).to.equal(false); - }); - - it('col 2 of 3, with colspan of 2',function(){ - var cell = new Cell({colSpan:2}); - cell.x=1; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.drawRight).to.equal(true); - }); - - it('col 1 of 3, with colspan of 3',function(){ - var cell = new Cell({colSpan:3}); - cell.x = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.drawRight).to.equal(true); - }); - - it('col 1 of 3, with colspan of 2',function(){ - var cell = new Cell({colSpan:2}); - cell.x = 0; - cell.mergeTableOptions(tableOptions); - cell.init(tableOptions); - expect(cell.drawRight).to.equal(false); - }); - }); - }); - - describe('drawLine', function(){ - var cell; - - beforeEach(function () { - cell = new Cell(); - - //manually init - cell.chars = defaultChars(); - cell.paddingLeft = cell.paddingRight = 1; - cell.width = 7; - cell.height = 3; - cell.hAlign = 'center'; - cell.vAlign = 'center'; - cell.chars.left = 'L'; - cell.chars.right = 'R'; - cell.chars.middle = 'M'; - cell.content = 'hello\nhowdy\ngoodnight'; - cell.lines = cell.content.split('\n'); - cell.x = cell.y = 0; - }); - - describe('top line',function(){ - it('will draw the top left corner when x=0,y=0',function(){ - cell.x = cell.y = 0; - expect(cell.draw('top')).to.equal('┌───────'); - cell.drawRight = true; - expect(cell.draw('top')).to.equal('┌───────┐'); - }); - - it('will draw the top mid corner when x=1,y=0',function(){ - cell.x = 1; - cell.y = 0; - expect(cell.draw('top')).to.equal('┬───────'); - cell.drawRight = true; - expect(cell.draw('top')).to.equal('┬───────┐'); - }); - - it('will draw the left mid corner when x=0,y=1',function(){ - cell.x = 0; - cell.y = 1; - expect(cell.draw('top')).to.equal('├───────'); - cell.drawRight = true; - expect(cell.draw('top')).to.equal('├───────┤'); - }); - - it('will draw the mid mid corner when x=1,y=1',function(){ - cell.x = 1; - cell.y = 1; - expect(cell.draw('top')).to.equal('┼───────'); - cell.drawRight = true; - expect(cell.draw('top')).to.equal('┼───────┤'); - }); - - it('will draw in the color specified by border style',function(){ - cell.border = ['gray']; - expect(cell.draw('top')).to.equal(colors.gray('┌───────')) - }); - }); - - describe('bottom line',function(){ - it('will draw the bottom left corner if x=0',function(){ - cell.x = 0; - cell.y = 1; - expect(cell.draw('bottom')).to.equal('└───────'); - cell.drawRight = true; - expect(cell.draw('bottom')).to.equal('└───────┘'); - }); - - it('will draw the bottom left corner if x=1',function(){ - cell.x = 1; - cell.y = 1; - expect(cell.draw('bottom')).to.equal('┴───────'); - cell.drawRight = true; - expect(cell.draw('bottom')).to.equal('┴───────┘'); - }); - - it('will draw in the color specified by border style',function(){ - cell.border = ['gray']; - expect(cell.draw('bottom')).to.equal(colors.gray('└───────')) - }); - }); - - describe('drawBottom',function(){ - it('draws an empty line',function(){ - expect(cell.drawEmpty()).to.equal('L '); - expect(cell.drawEmpty(true)).to.equal('L R'); - }); - - it('draws an empty line',function(){ - cell.border = ['gray']; - cell.head = ['red']; - expect(cell.drawEmpty()).to.equal(colors.gray('L') + colors.red(' ')); - expect(cell.drawEmpty(true)).to.equal(colors.gray('L') + colors.red(' ') + colors.gray('R')); - }); - }); - - describe('first line of text',function(){ - beforeEach(function () { - cell.width = 9; - }); - - it('will draw left side if x=0',function(){ - cell.x = 0; - expect(cell.draw(0)).to.equal('L hello '); - cell.drawRight = true; - expect(cell.draw(0)).to.equal('L hello R'); - }); - - it('will draw mid side if x=1',function(){ - cell.x = 1; - expect(cell.draw(0)).to.equal('M hello '); - cell.drawRight = true; - expect(cell.draw(0)).to.equal('M hello R'); - }); - - it('will align left',function(){ - cell.x = 1; - cell.hAlign = 'left'; - expect(cell.draw(0)).to.equal('M hello '); - cell.drawRight = true; - expect(cell.draw(0)).to.equal('M hello R'); - }); - - it('will align right',function(){ - cell.x = 1; - cell.hAlign = 'right'; - expect(cell.draw(0)).to.equal('M hello '); - cell.drawRight = true; - expect(cell.draw(0)).to.equal('M hello R'); - }); - - it('left and right will be drawn in color of border style',function(){ - cell.border = ['gray']; - cell.x = 0; - expect(cell.draw(0)).to.equal(colors.gray('L') + ' hello '); - cell.drawRight = true; - expect(cell.draw(0)).to.equal(colors.gray('L') + ' hello ' + colors.gray('R')); - }); - - it('text will be drawn in color of head style if y == 0',function(){ - cell.head = ['red']; - cell.x = cell.y = 0; - expect(cell.draw(0)).to.equal('L' + colors.red(' hello ')); - cell.drawRight = true; - expect(cell.draw(0)).to.equal('L' + colors.red(' hello ') + 'R'); - }); - - it('text will NOT be drawn in color of head style if y == 1',function(){ - cell.head = ['red']; - cell.x = cell.y = 1; - expect(cell.draw(0)).to.equal('M hello '); - cell.drawRight = true; - expect(cell.draw(0)).to.equal('M hello R'); - }); - - it('head and border colors together',function(){ - cell.border = ['gray']; - cell.head = ['red']; - cell.x = cell.y = 0; - expect(cell.draw(0)).to.equal(colors.gray('L') + colors.red(' hello ')); - cell.drawRight = true; - expect(cell.draw(0)).to.equal(colors.gray('L') + colors.red(' hello ') + colors.gray('R')); - }); - }); - - describe('second line of text',function(){ - beforeEach(function () { - cell.width = 9; - }); - - it('will draw left side if x=0',function(){ - cell.x = 0; - expect(cell.draw(1)).to.equal('L howdy '); - cell.drawRight = true; - expect(cell.draw(1)).to.equal('L howdy R'); - }); - - it('will draw mid side if x=1',function(){ - cell.x = 1; - expect(cell.draw(1)).to.equal('M howdy '); - cell.drawRight = true; - expect(cell.draw(1)).to.equal('M howdy R'); - }); - - it('will align left',function(){ - cell.x = 1; - cell.hAlign = 'left'; - expect(cell.draw(1)).to.equal('M howdy '); - cell.drawRight = true; - expect(cell.draw(1)).to.equal('M howdy R'); - }); - - it('will align right',function(){ - cell.x = 1; - cell.hAlign = 'right'; - expect(cell.draw(1)).to.equal('M howdy '); - cell.drawRight = true; - expect(cell.draw(1)).to.equal('M howdy R'); - }); - }); - - describe('truncated line of text',function(){ - beforeEach(function () { - cell.width = 9; - }); - - it('will draw left side if x=0',function(){ - cell.x = 0; - expect(cell.draw(2)).to.equal('L goodni… '); - cell.drawRight = true; - expect(cell.draw(2)).to.equal('L goodni… R'); - }); - - it('will draw mid side if x=1',function(){ - cell.x = 1; - expect(cell.draw(2)).to.equal('M goodni… '); - cell.drawRight = true; - expect(cell.draw(2)).to.equal('M goodni… R'); - }); - - it('will not change when aligned left',function(){ - cell.x = 1; - cell.hAlign = 'left'; - expect(cell.draw(2)).to.equal('M goodni… '); - cell.drawRight = true; - expect(cell.draw(2)).to.equal('M goodni… R'); - }); - - it('will not change when aligned right',function(){ - cell.x = 1; - cell.hAlign = 'right'; - expect(cell.draw(2)).to.equal('M goodni… '); - cell.drawRight = true; - expect(cell.draw(2)).to.equal('M goodni… R'); - }); - }); - - describe('vAlign',function(){ - beforeEach(function () { - cell.height = '5'; - }); - - it('center',function(){ - cell.vAlign = 'center'; - expect(cell.draw(0)).to.equal('L '); - expect(cell.draw(1)).to.equal('L hello '); - expect(cell.draw(2)).to.equal('L howdy '); - expect(cell.draw(3)).to.equal('L good… '); - expect(cell.draw(4)).to.equal('L '); - - cell.drawRight = true; - expect(cell.draw(0)).to.equal('L R'); - expect(cell.draw(1)).to.equal('L hello R'); - expect(cell.draw(2)).to.equal('L howdy R'); - expect(cell.draw(3)).to.equal('L good… R'); - expect(cell.draw(4)).to.equal('L R'); - - cell.x = 1; - cell.drawRight = false; - expect(cell.draw(0)).to.equal('M '); - expect(cell.draw(1)).to.equal('M hello '); - expect(cell.draw(2)).to.equal('M howdy '); - expect(cell.draw(3)).to.equal('M good… '); - expect(cell.draw(4)).to.equal('M '); - }); - - it('top',function(){ - cell.vAlign = 'top'; - expect(cell.draw(0)).to.equal('L hello '); - expect(cell.draw(1)).to.equal('L howdy '); - expect(cell.draw(2)).to.equal('L good… '); - expect(cell.draw(3)).to.equal('L '); - expect(cell.draw(4)).to.equal('L '); - - cell.vAlign = null; //top is the default - cell.drawRight = true; - expect(cell.draw(0)).to.equal('L hello R'); - expect(cell.draw(1)).to.equal('L howdy R'); - expect(cell.draw(2)).to.equal('L good… R'); - expect(cell.draw(3)).to.equal('L R'); - expect(cell.draw(4)).to.equal('L R'); - - cell.x = 1; - cell.drawRight = false; - expect(cell.draw(0)).to.equal('M hello '); - expect(cell.draw(1)).to.equal('M howdy '); - expect(cell.draw(2)).to.equal('M good… '); - expect(cell.draw(3)).to.equal('M '); - expect(cell.draw(4)).to.equal('M '); - }); - - it('center',function(){ - cell.vAlign = 'bottom'; - expect(cell.draw(0)).to.equal('L '); - expect(cell.draw(1)).to.equal('L '); - expect(cell.draw(2)).to.equal('L hello '); - expect(cell.draw(3)).to.equal('L howdy '); - expect(cell.draw(4)).to.equal('L good… '); - - cell.drawRight = true; - expect(cell.draw(0)).to.equal('L R'); - expect(cell.draw(1)).to.equal('L R'); - expect(cell.draw(2)).to.equal('L hello R'); - expect(cell.draw(3)).to.equal('L howdy R'); - expect(cell.draw(4)).to.equal('L good… R'); - - cell.x = 1; - cell.drawRight = false; - expect(cell.draw(0)).to.equal('M '); - expect(cell.draw(1)).to.equal('M '); - expect(cell.draw(2)).to.equal('M hello '); - expect(cell.draw(3)).to.equal('M howdy '); - expect(cell.draw(4)).to.equal('M good… '); - }); - }); - - it('vertically truncated will show truncation on last visible line',function(){ - cell.height = 2; - expect(cell.draw(0)).to.equal('L hello '); - expect(cell.draw(1)).to.equal('L howd… '); - }); - - it("won't vertically truncate if the lines just fit",function(){ - cell.height = 2; - cell.content = "hello\nhowdy"; - cell.lines = cell.content.split("\n"); - expect(cell.draw(0)).to.equal('L hello '); - expect(cell.draw(1)).to.equal('L howdy '); - }); - - it("will vertically truncate even if last line is short",function(){ - cell.height = 2; - cell.content = "hello\nhi\nhowdy"; - cell.lines = cell.content.split("\n"); - expect(cell.draw(0)).to.equal('L hello '); - expect(cell.draw(1)).to.equal('L hi… '); - }); - - it("allows custom truncation",function(){ - cell.height = 2; - cell.truncate = '...'; - cell.content = "hello\nhi\nhowdy"; - cell.lines = cell.content.split("\n"); - expect(cell.draw(0)).to.equal('L hello '); - expect(cell.draw(1)).to.equal('L hi... '); - - cell.content = "hello\nhowdy\nhi"; - cell.lines = cell.content.split("\n"); - expect(cell.draw(0)).to.equal('L hello '); - expect(cell.draw(1)).to.equal('L ho... '); - }); - }); - - describe("ColSpanCell",function(){ - it('has an init function',function(){ - expect(new ColSpanCell()).to.respondTo('init'); - new ColSpanCell().init(); // nothing happens. - }); - - it('draw returns an empty string',function(){ - expect(new ColSpanCell().draw('top')).to.equal(''); - expect(new ColSpanCell().draw('bottom')).to.equal(''); - expect(new ColSpanCell().draw(1)).to.equal(''); - }); - }); - - describe("RowSpanCell",function(){ - var original, tableOptions; - - beforeEach(function () { - original = { - rowSpan:3, - y:0, - draw:sinon.spy() - }; - tableOptions = { - rowHeights:[2,3,4,5] - } - }); - - it('drawing top of the next row',function(){ - var spanner = new RowSpanCell(original); - spanner.x = 0; - spanner.y = 1; - spanner.init(tableOptions); - spanner.draw('top'); - expect(original.draw).to.have.been.calledOnce.and.calledWith(2); - }); - - it('drawing line 0 of the next row',function(){ - var spanner = new RowSpanCell(original); - spanner.x = 0; - spanner.y = 1; - spanner.init(tableOptions); - spanner.draw(0); - expect(original.draw).to.have.been.calledOnce.and.calledWith(3); - }); - - it('drawing line 1 of the next row',function(){ - var spanner = new RowSpanCell(original); - spanner.x = 0; - spanner.y = 1; - spanner.init(tableOptions); - spanner.draw(1); - expect(original.draw).to.have.been.calledOnce.and.calledWith(4); - }); - - it('drawing top of two rows below',function(){ - var spanner = new RowSpanCell(original); - spanner.x = 0; - spanner.y = 2; - spanner.init(tableOptions); - spanner.draw('top'); - expect(original.draw).to.have.been.calledOnce.and.calledWith(6); - }); - - it('drawing line 0 of two rows below',function(){ - var spanner = new RowSpanCell(original); - spanner.x = 0; - spanner.y = 2; - spanner.init(tableOptions); - spanner.draw(0); - expect(original.draw).to.have.been.calledOnce.and.calledWith(7); - }); - - it('drawing line 1 of two rows below',function(){ - var spanner = new RowSpanCell(original); - spanner.x = 0; - spanner.y = 2; - spanner.init(tableOptions); - spanner.draw(1); - expect(original.draw).to.have.been.calledOnce.and.calledWith(8); - }); - - it('drawing bottom',function(){ - var spanner = new RowSpanCell(original); - spanner.x = 0; - spanner.y = 1; - spanner.init(tableOptions); - spanner.draw('bottom'); - expect(original.draw).to.have.been.calledOnce.and.calledWith('bottom'); - }); - }); -}); - diff --git a/node_modules/cli-table2/test/example-tests.js b/node_modules/cli-table2/test/example-tests.js deleted file mode 100644 index e3ea2a78348..00000000000 --- a/node_modules/cli-table2/test/example-tests.js +++ /dev/null @@ -1,6 +0,0 @@ -var printExamples = require('../lib/print-example'); -var examples = require('../examples/col-and-row-span-examples'); -var usage = require('../examples/basic-usage-examples'); - -printExamples.runTest('@api Usage',usage); -printExamples.runTest('@api Table (examples)',examples); \ No newline at end of file diff --git a/node_modules/cli-table2/test/layout-manager-test.js b/node_modules/cli-table2/test/layout-manager-test.js deleted file mode 100644 index 362f348e0ed..00000000000 --- a/node_modules/cli-table2/test/layout-manager-test.js +++ /dev/null @@ -1,163 +0,0 @@ -describe('layout-manager',function(){ - var chai = require('chai'); - var expect = chai.expect; - - var layoutManager = require('../src/layout-manager'); - var layoutTable = layoutManager.layoutTable; - var addRowSpanCells = layoutManager.addRowSpanCells; - var maxWidth = layoutManager.maxWidth; - var Cell = require('../src/cell'); - var RowSpanCell = Cell.RowSpanCell; - - describe('layoutTable',function(){ - it('sets x and y',function(){ - var table = [ - [{},{}], - [{},{}] - ]; - - layoutTable(table); - - expect(table).to.eql([ - [{x:0,y:0},{x:1,y:0}], - [{x:0,y:1},{x:1,y:1}] - ]); - - var w = maxWidth(table); - expect(w).to.equal(2); - }); - - it('colSpan will push x values to the right',function(){ - var table = [ - [{colSpan:2},{}], - [{},{colSpan:2}] - ]; - - layoutTable(table); - - expect(table).to.eql([ - [{x:0,y:0,colSpan:2},{x:2,y:0}], - [{x:0,y:1},{x:1,y:1,colSpan:2}] - ]); - - expect(maxWidth(table)).to.equal(3); - }); - - it('rowSpan will push x values on cells below',function(){ - var table = [ - [{rowSpan:2},{}], - [{}] - ]; - - layoutTable(table); - - expect(table).to.eql([ - [{x:0,y:0,rowSpan:2},{x:1,y:0}], - [{x:1,y:1}] - ]); - - expect(maxWidth(table)).to.equal(2); - }); - - it('colSpan and rowSpan together',function(){ - var table = [ - [{rowSpan:2,colSpan:2},{}], - [{}] - ]; - - layoutTable(table); - - expect(table).to.eql([ - [{x:0,y:0,rowSpan:2,colSpan:2},{x:2,y:0}], - [{x:2,y:1}] - ]); - - expect(maxWidth(table)).to.equal(3); - }); - - it('complex layout',function(){ - - var table = [ - [{c:'a'},{c:'b'}, {c:'c',rowSpan:3,colSpan:2}, {c:'d'}], - [{c:'e',rowSpan:2,colSpan:2}, {c:'f'}], - [ {c:'g'}] - ]; - - layoutTable(table); - - expect(table).to.eql([ - [{c:'a',y:0,x:0}, {c:'b',y:0,x:1}, {c:'c',y:0,x:2,rowSpan:3,colSpan:2}, {c:'d',y:0,x:4}], - [{c:'e',rowSpan:2,colSpan:2,y:1,x:0}, {c:'f',y:1,x:4}], - [{c:'g',y:2,x:4}] - ]); - - }); - - it('maxWidth of single element',function(){ - var table = [[{}]]; - layoutTable(table) - expect(maxWidth(table)).to.equal(1); - }); - }); - - describe('addRowSpanCells',function(){ - it('will insert a rowSpan cell - beginning of line',function(){ - var table = [ - [{x:0,y:0,rowSpan:2},{x:1,y:0}], - [{x:1,y:1}] - ]; - - addRowSpanCells(table); - - expect(table[0]).to.eql([{x:0,y:0,rowSpan:2},{x:1,y:0}]); - expect(table[1].length).to.equal(2); - expect(table[1][0]).to.be.instanceOf(RowSpanCell); - expect(table[1][1]).to.eql({x:1,y:1}); - }); - - it('will insert a rowSpan cell - end of line',function(){ - var table = [ - [{x:0,y:0},{x:1,y:0,rowSpan:2}], - [{x:0,y:1}] - ]; - - addRowSpanCells(table); - - expect(table[0]).to.eql([{x:0,y:0},{rowSpan:2,x:1,y:0}]); - expect(table[1].length).to.equal(2); - expect(table[1][0]).to.eql({x:0,y:1}); - expect(table[1][1]).to.be.instanceOf(RowSpanCell); - }); - - it('will insert a rowSpan cell - middle of line',function(){ - var table = [ - [{x:0,y:0},{x:1,y:0,rowSpan:2},{x:2,y:0}], - [{x:0,y:1},{x:2,y:1}] - ]; - - addRowSpanCells(table); - - expect(table[0]).to.eql([{x:0,y:0},{rowSpan:2,x:1,y:0},{x:2,y:0}]); - expect(table[1].length).to.equal(3); - expect(table[1][0]).to.eql({x:0,y:1}); - expect(table[1][1]).to.be.instanceOf(RowSpanCell); - expect(table[1][2]).to.eql({x:2,y:1}); - }); - - it('will insert a rowSpan cell - multiple on the same line',function(){ - var table = [ - [{x:0,y:0},{x:1,y:0,rowSpan:2},{x:2,y:0,rowSpan:2},{x:3,y:0}], - [{x:0,y:1},{x:3,y:1}] - ]; - - addRowSpanCells(table); - - expect(table[0]).to.eql([{x:0,y:0},{rowSpan:2,x:1,y:0},{rowSpan:2,x:2,y:0},{x:3,y:0}]); - expect(table[1].length).to.equal(4); - expect(table[1][0]).to.eql({x:0,y:1}); - expect(table[1][1]).to.be.instanceOf(RowSpanCell); - expect(table[1][2]).to.be.instanceOf(RowSpanCell); - expect(table[1][3]).to.eql({x:3,y:1}); - }); - }); -}); \ No newline at end of file diff --git a/node_modules/cli-table2/test/original-cli-table-index-tests.js b/node_modules/cli-table2/test/original-cli-table-index-tests.js deleted file mode 100644 index 78362671b19..00000000000 --- a/node_modules/cli-table2/test/original-cli-table-index-tests.js +++ /dev/null @@ -1,294 +0,0 @@ -describe('@api original-cli-table index tests',function(){ - var Table = require('../src/table'); - var chai = require('chai'); - var expect = chai.expect; - - it('test complete table', function (){ - var table = new Table({ - head: ['Rel', 'Change', 'By', 'When'] - , style: { - 'padding-left': 1 - , 'padding-right': 1 - , head: [] - , border: [] - } - , colWidths: [6, 21, 25, 17] - }); - - table.push( - ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago'] - , ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago'] - ); - - var expected = [ - '┌──────┬─────────────────────┬─────────────────────────┬─────────────────┐' - , '│ Rel │ Change │ By │ When │' - , '├──────┼─────────────────────┼─────────────────────────┼─────────────────┤' - , '│ v0.1 │ Testing something … │ rauchg@gmail.com │ 7 minutes ago │' - , '├──────┼─────────────────────┼─────────────────────────┼─────────────────┤' - , '│ v0.1 │ Testing something … │ rauchg@gmail.com │ 8 minutes ago │' - , '└──────┴─────────────────────┴─────────────────────────┴─────────────────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - //expect(table.render()).should.eql(expected.join("\n")); - }); - - it('test width property', function (){ - var table = new Table({ - head: ['Cool'], - style: { - head: [], - border: [] - } - }); - - expect(table.width).to.equal(8); - }); - - it('test vertical table output', function() { - var table = new Table({ style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); // clear styles to prevent color output - - table.push( - {'v0.1': 'Testing something cool'} - , {'v0.1': 'Testing something cool'} - ); - - var expected = [ - '┌────┬──────────────────────┐' - , '│v0.1│Testing something cool│' - , '├────┼──────────────────────┤' - , '│v0.1│Testing something cool│' - , '└────┴──────────────────────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test cross table output', function() { - var table = new Table({ head: ["", "Header 1", "Header 2"], style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); // clear styles to prevent color output - - table.push( - {"Header 3": ['v0.1', 'Testing something cool'] } - , {"Header 4": ['v0.1', 'Testing something cool'] } - ); - - var expected = [ - '┌────────┬────────┬──────────────────────┐' - , '│ │Header 1│Header 2 │' - , '├────────┼────────┼──────────────────────┤' - , '│Header 3│v0.1 │Testing something cool│' - , '├────────┼────────┼──────────────────────┤' - , '│Header 4│v0.1 │Testing something cool│' - , '└────────┴────────┴──────────────────────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test table colors', function(){ - var table = new Table({ - head: ['Rel', 'By'], - style: {head: ['red'], border: ['grey']} - }); - - /*var off = '' - , red = '' - , orange = '' - , grey = ''*/ - var off = '\u001b[39m' - , red = '\u001b[31m' - , orange = '\u001b[38;5;221m' - , grey = '\u001b[90m' - - , c256s = orange + 'v0.1' + off; - - table.push( - [c256s, 'rauchg@gmail.com'] - ); - - // The expectation from the original cli-table is commented out below. - // The output from cli-table2 will still look the same, but the border color is - // toggled off and back on at the border of each cell. - - /*var expected = [ - grey + '┌──────┬──────────────────┐' + off - , grey + '│' + off + red + ' Rel ' + off + grey + '│' + off + red + ' By ' + off + grey + '│' + off - , grey + '├──────┼──────────────────┤' + off - , grey + '│' + off + ' ' + c256s + ' ' + grey + '│' + off + ' rauchg@gmail.com ' + grey + '│' + off - , grey + '└──────┴──────────────────┘' + off - ];*/ - - var expected = [ - grey + '┌──────'+off+grey+'┬──────────────────┐' + off - , grey + '│' + off + red + ' Rel ' + off + grey + '│' + off + red + ' By ' + off + grey + '│' + off - , grey + '├──────'+off+grey+'┼──────────────────┤' + off - , grey + '│' + off + ' ' + c256s + ' ' + grey + '│' + off + ' rauchg@gmail.com ' + grey + '│' + off - , grey + '└──────'+off+grey+'┴──────────────────┘' + off - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test custom chars', function (){ - var table = new Table({ - chars: { - 'top': '═' - , 'top-mid': '╤' - , 'top-left': '╔' - , 'top-right': '╗' - , 'bottom': '═' - , 'bottom-mid': '╧' - , 'bottom-left': '╚' - , 'bottom-right': '╝' - , 'left': '║' - , 'left-mid': '╟' - , 'right': '║' - , 'right-mid': '╢' - }, - style: { - head: [] - , border: [] - } - }); - - table.push( - ['foo', 'bar', 'baz'] - , ['frob', 'bar', 'quuz'] - ); - - var expected = [ - '╔══════╤═════╤══════╗' - , '║ foo │ bar │ baz ║' - , '╟──────┼─────┼──────╢' - , '║ frob │ bar │ quuz ║' - , '╚══════╧═════╧══════╝' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test compact shortand', function (){ - var table = new Table({ - style: { - head: [] - , border: [] - , compact : true - } - }); - - table.push( - ['foo', 'bar', 'baz'] - , ['frob', 'bar', 'quuz'] - ); - - var expected = [ - '┌──────┬─────┬──────┐' - , '│ foo │ bar │ baz │' - , '│ frob │ bar │ quuz │' - , '└──────┴─────┴──────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test compact empty mid line', function (){ - var table = new Table({ - chars: { - 'mid': '' - , 'left-mid': '' - , 'mid-mid': '' - , 'right-mid': '' - }, - style: { - head: [] - , border: [] - } - }); - - table.push( - ['foo', 'bar', 'baz'] - , ['frob', 'bar', 'quuz'] - ); - - var expected = [ - '┌──────┬─────┬──────┐' - , '│ foo │ bar │ baz │' - , '│ frob │ bar │ quuz │' - , '└──────┴─────┴──────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test decoration lines disabled', function (){ - var table = new Table({ - chars: { - 'top': '' - , 'top-mid': '' - , 'top-left': '' - , 'top-right': '' - , 'bottom': '' - , 'bottom-mid': '' - , 'bottom-left': '' - , 'bottom-right': '' - , 'left': '' - , 'left-mid': '' - , 'mid': '' - , 'mid-mid': '' - , 'right': '' - , 'right-mid': '' - , 'middle': ' ' // a single space - }, - style: { - head: [] - , border: [] - , 'padding-left': 0 - , 'padding-right': 0 - } - }); - - table.push( - ['foo', 'bar', 'baz'] - , ['frobnicate', 'bar', 'quuz'] - ); - - var expected = [ - 'foo bar baz ' - , 'frobnicate bar quuz' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test with null/undefined as values or column names', function (){ - var table = new Table({ - style: { - head: [] - , border: [] - } - }); - - table.push( - [null, undefined, 0] - ); - - // This is the expectation from the original cli-table. - // The empty columns have widths based on the strings `null` and `undefined` - // That does not make sense to me, so I am deviating from the original behavior here. - - /*var expected = [ - '┌──────┬───────────┬───┐' - , '│ │ │ 0 │' - , '└──────┴───────────┴───┘' - ]; */ - - var expected = [ - '┌──┬──┬───┐' - , '│ │ │ 0 │' - , '└──┴──┴───┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); -}); diff --git a/node_modules/cli-table2/test/original-cli-table-newlines-test.js b/node_modules/cli-table2/test/original-cli-table-newlines-test.js deleted file mode 100644 index 5fd092ee67f..00000000000 --- a/node_modules/cli-table2/test/original-cli-table-newlines-test.js +++ /dev/null @@ -1,86 +0,0 @@ -describe('@api original-cli-table newline tests',function(){ - var Table = require('../src/table'); - var chai = require('chai'); - var expect = chai.expect; - - it('test table with newlines in headers', function() { - var table = new Table({ - head: ['Test', "1\n2\n3"] - , style: { - 'padding-left': 1 - , 'padding-right': 1 - , head: [] - , border: [] - } - }); - - var expected = [ - '┌──────┬───┐' - , '│ Test │ 1 │' - , '│ │ 2 │' - , '│ │ 3 │' - , '└──────┴───┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test column width is accurately reflected when newlines are present', function() { - var table = new Table({ head: ['Test\nWidth'], style: {head:[], border:[]} }); - expect(table.width).to.equal(9); - }); - - it('test newlines in body cells', function() { - var table = new Table({style: {head:[], border:[]}}); - - table.push(["something\nwith\nnewlines"]); - - var expected = [ - '┌───────────┐' - , '│ something │' - , '│ with │' - , '│ newlines │' - , '└───────────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test newlines in vertical cell header and body', function() { - var table = new Table({ style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); - - table.push( - {'v\n0.1': 'Testing\nsomething cool'} - ); - - var expected = [ - '┌───┬──────────────┐' - , '│v │Testing │' - , '│0.1│something cool│' - , '└───┴──────────────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - - it('test newlines in cross table header and body', function() { - var table = new Table({ head: ["", "Header\n1"], style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); - - table.push({ "Header\n2": ['Testing\nsomething\ncool'] }); - - var expected = [ - '┌──────┬─────────┐' - , '│ │Header │' - , '│ │1 │' - , '├──────┼─────────┤' - , '│Header│Testing │' - , '│2 │something│' - , '│ │cool │' - , '└──────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); - -}); - diff --git a/node_modules/cli-table2/test/table-layout-test.js b/node_modules/cli-table2/test/table-layout-test.js deleted file mode 100644 index cebe1674655..00000000000 --- a/node_modules/cli-table2/test/table-layout-test.js +++ /dev/null @@ -1,466 +0,0 @@ -describe('tableLayout', function () { - var Cell = require('../src/cell'); - var layoutManager = require('../src/layout-manager'); - var layoutTable = layoutManager.layoutTable; - var makeTableLayout = layoutManager.makeTableLayout; - var addRowSpanCells = layoutManager.addRowSpanCells; - var maxWidth = layoutManager.maxWidth; - var fillInTable = layoutManager.fillInTable; - var computeWidths = layoutManager.computeWidths; - var computeHeights = layoutManager.computeHeights; - var chai = require('chai'); - var expect = chai.expect; - var _ = require('lodash'); - - it('simple 2x2 layout',function(){ - var actual = makeTableLayout([ - ['hello','goodbye'], - ['hola','adios'] - ]); - - var expected = [ - ['hello','goodbye'], - ['hola','adios'] - ]; - - checkLayout(actual,expected); - }); - - it('cross table',function(){ - var actual = makeTableLayout([ - {'1.0':['yes','no']}, - {'2.0':['hello','goodbye']} - ]); - - var expected = [ - ['1.0','yes','no'], - ['2.0','hello','goodbye'] - ]; - - checkLayout(actual,expected); - }); - - it('vertical table',function(){ - var actual = makeTableLayout([ - {'1.0':'yes'}, - {'2.0':'hello'} - ]); - - var expected = [ - ['1.0','yes'], - ['2.0','hello'] - ]; - - checkLayout(actual,expected); - }); - - it('colSpan adds RowSpanCells to the right',function(){ - var actual = makeTableLayout([ - [{content:'hello',colSpan:2}], - ['hola','adios'] - ]); - - var expected = [ - [{content:'hello',colSpan:2},null], - ['hola','adios'] - ]; - - checkLayout(actual,expected); - }); - - it('rowSpan adds RowSpanCell below',function(){ - var actual = makeTableLayout([ - [{content:'hello',rowSpan:2},'goodbye'], - ['adios'] - ]); - - var expected = [ - ['hello' , 'goodbye'], - [{spannerFor:[0,0]} , 'adios'] - ]; - - checkLayout(actual,expected); - }); - - it('rowSpan and cellSpan together',function(){ - var actual = makeTableLayout([ - [{content:'hello',rowSpan:2,colSpan:2},'goodbye'], - ['adios'] - ]); - - var expected = [ - ['hello' , null, 'goodbye'], - [{spannerFor:[0,0]} , null, 'adios'] - ]; - - checkLayout(actual,expected); - }); - - it('complex layout',function(){ - var actual = makeTableLayout([ - [{content:'hello',rowSpan:2,colSpan:2},{content:'yo',rowSpan:2,colSpan:2},'goodbye'], - ['adios'] - ]); - - var expected = [ - ['hello' , null, 'yo' , null, 'goodbye'], - [{spannerFor:[0,0]} , null, {spannerFor:[0,2]} , null, 'adios'] - ]; - - checkLayout(actual,expected); - }); - - it('complex layout2',function(){ - var actual = makeTableLayout([ - ['a','b', {content:'c',rowSpan:3,colSpan:2},'d'], - [{content:'e',rowSpan:2,colSpan:2}, 'f'], - ['g'] - ]); - - var expected = [ - ['a', 'b', 'c', null, 'd'], - ['e', null, {spannerFor:[0,2]}, null, 'f'], - [{spannerFor:[1,0]}, null, {spannerFor:[0,2]}, null, 'g'] - ]; - - checkLayout(actual,expected); - }); - - it('stairstep spans',function(){ - var actual = makeTableLayout([ - [{content:'',rowSpan:2},''], - [{content:'',rowSpan:2}], - [''] - ]); - - var expected = [ - [{content:'',rowSpan:2}, ''], - [{spannerFor:[0,0]},{content:'',rowSpan:2}], - ['',{spannerFor:[1,1]}] - ]; - - checkLayout(actual,expected); - }); - - describe('fillInTable',function(){ - function mc(opts,y,x){ - var cell = new Cell(opts); - cell.x = x; - cell.y = y; - return cell; - } - - it('will blank out individual cells',function(){ - var cells = [ - [mc('a',0,1)], - [mc('b',1,0)] - ]; - fillInTable(cells); - - checkLayout(cells,[ - ['', 'a'], - ['b', ''] - ]); - }); - - it('will autospan to the right',function(){ - var cells = [ - [], - [mc('a',1,1)] - ]; - fillInTable(cells); - - checkLayout(cells,[ - [{content:'',colSpan:2}, null], - ['', 'a'] - ]); - }); - - it('will autospan down',function(){ - var cells = [ - [ mc('a',0,1)], - [] - ]; - fillInTable(cells); - addRowSpanCells(cells); - - checkLayout(cells,[ - [{content:'',rowSpan:2}, 'a'], - [{spannerFor:[0,0]}, ''] - ]); - }); - - it('will autospan right and down',function(){ - var cells = [ - [ mc('a',0,2)], - [], - [ mc('b',2,1)] - ]; - fillInTable(cells); - addRowSpanCells(cells); - - checkLayout(cells,[ - [{content:'',colSpan:2, rowSpan:2}, null, 'a'], - [{spannerFor:[0,0]}, null, {content:'', colSpan:1, rowSpan:2}], - ['','b',{spannerFor:[1,2]}] - ]); - }); - }); - - describe('computeWidths',function() { - function mc(y,x,desiredWidth, colSpan) { - return {x:x,y:y,desiredWidth:desiredWidth,colSpan:colSpan}; - } - - it('finds the maximum desired width of each column', function () { - var widths = []; - var cells = [ - [mc(0,0,7), mc(0,1,3), mc(0,2,5)], - [mc(1,0,8), mc(1,1,5), mc(1,2,2)], - [mc(2,0,6), mc(2,1,9), mc(2,2,1)] - ]; - - computeWidths(widths, cells); - - expect(widths).to.eql([8, 9, 5]); - }); - - it('won\'t touch hard coded values', function () { - var widths = [null, 3]; - var cells = [ - [mc(0,0,7), mc(0,1,3), mc(0,2,5)], - [mc(1,0,8), mc(1,1,5), mc(1,2,2)], - [mc(2,0,6), mc(2,1,9), mc(2,2,1)] - ]; - - computeWidths(widths, cells); - - expect(widths).to.eql([8, 3, 5]); - }); - - it('assumes undefined desiredWidth is 1', function () { - var widths = []; - var cells = [[{x:0,y:0}], [{x:0,y:1}], [{x:0,y:2}]]; - computeWidths(widths, cells); - expect(widths).to.eql([1]) - }); - - it('takes into account colSpan and wont over expand', function () { - var widths = []; - var cells = [ - [mc(0,0,10, 2), mc(0,2,5)], - [mc(1,0,5), mc(1,1,5), mc(1,2,2)], - [mc(2,0,4), mc(2,1,2), mc(2,2,1)] - ]; - computeWidths(widths, cells); - expect(widths).to.eql([5, 5, 5]); - }); - - it('will expand rows involved in colSpan in a balanced way', function () { - var widths = []; - var cells = [ - [mc(0,0,13,2), mc(0,2,5)], - [mc(1,0,5), mc(1,1,5), mc(1,2,2)], - [mc(2,0,4), mc(2,1,2), mc(2,2,1)] - ]; - computeWidths(widths, cells); - expect(widths).to.eql([6, 6, 5]); - }); - - it('expands across 3 cols', function () { - var widths = []; - var cells = [ - [mc(0,0,25,3) ], - [mc(1,0,5), mc(1,1,5), mc(1,2,2) ], - [mc(2,0,4), mc(2,1,2), mc(2,2,1) ] - ]; - computeWidths(widths, cells); - expect(widths).to.eql([9, 9, 5]); - }); - - it('multiple spans in same table', function () { - var widths = []; - var cells = [ - [mc(0,0,25,3) ], - [mc(1,0,30,3) ], - [mc(2,0,4), mc(2,1,2), mc(2,2,1) ] - ]; - computeWidths(widths, cells); - expect(widths).to.eql([11, 9, 8]); - }); - - it('spans will only edit uneditable tables',function(){ - var widths = [null, 3]; - var cells = [ - [mc(0,0,20,3) ], - [mc(1,0,4), mc(1,1,20), mc(1,2,5) ] - ]; - computeWidths(widths, cells); - expect(widths).to.eql([7,3,8]) - }); - - it('spans will only edit uneditable tables - first column uneditable',function(){ - var widths = [3]; - var cells = [ - [mc(0,0,20,3) ], - [mc(1,0,4), mc(1,1,3), mc(1,2,5) ] - ]; - computeWidths(widths, cells); - expect(widths).to.eql([3,7,8]) - }); - }); - - describe('computeHeights',function(){ - function mc(y,x,desiredHeight,colSpan){ - return {x:x,y:y,desiredHeight:desiredHeight,rowSpan:colSpan}; - } - - it('finds the maximum desired height of each row',function(){ - var heights = []; - var cells = [ - [mc(0,0,7), mc(0,1,3), mc(0,2,5) ], - [mc(1,0,8), mc(1,1,5), mc(1,2,2) ], - [mc(2,0,6), mc(2,1,9), mc(2,2,1) ] - ]; - - computeHeights(heights,cells); - - expect(heights).to.eql([7,8,9]); - }); - - it('won\'t touch hard coded values',function(){ - var heights = [null,3]; - var cells = [ - [mc(0,0,7), mc(0,1,3), mc(0,2,5)], - [mc(1,0,8), mc(1,1,5), mc(1,2,2)], - [mc(2,0,6), mc(2,1,9), mc(2,2,1)] - ]; - - computeHeights(heights,cells); - - expect(heights).to.eql([7,3,9]); - }); - - it('assumes undefined desiredHeight is 1',function(){ - var heights = []; - var cells = [[{x:0,y:0},{x:1,y:0},{x:2,y:0}]]; - computeHeights(heights,cells); - expect(heights).to.eql([1]) - }); - - it('takes into account rowSpan and wont over expand',function(){ - var heights = []; - var cells = [ - [mc(0,0,10,2), mc(0,1,5), mc(0,2,2)], - [ mc(1,1,5), mc(1,2,2)], - [mc(2,0,4), mc(2,1,2), mc(2,2,1)] - ]; - computeHeights(heights,cells); - expect(heights).to.eql([5,5,4]); - }); - - it('will expand rows involved in rowSpan in a balanced way',function(){ - var heights = []; - var cells = [ - [mc(0,0,13,2), mc(0,1,5), mc(0,2,5)], - [ mc(1,1,5), mc(1,2,2)], - [mc(2,0,4), mc(2,1,2), mc(2,2,1)] - ]; - computeHeights(heights,cells); - expect(heights).to.eql([6,6,4]); - }); - - it('expands across 3 rows',function(){ - var heights = []; - var cells = [ - [mc(0,0,25,3), mc(0,1,5), mc(0,2,4)], - [ mc(1,1,5), mc(1,2,2)], - [ mc(2,1,2), mc(2,2,1)] - ]; - computeHeights(heights,cells); - expect(heights).to.eql([9,9,5]); - }); - - it('multiple spans in same table',function(){ - var heights = []; - var cells = [ - [mc(0,0,25,3), mc(0,1,30,3), mc(0,2,4)], - [ mc(1,2,2)], - [ mc(2,2,1)] - ]; - computeHeights(heights,cells); - expect(heights).to.eql([11,9,8]); - }); - }); - - /** - * Provides a shorthand for validating a table of cells. - * To pass, both arrays must have the same dimensions, and each cell in `actualRows` must - * satisfy the shorthand assertion of the corresponding location in `expectedRows`. - * - * Available Expectations Can Be: - * - * * A `String` - Must be a normal cell with contents equal to the String value. - * * `null` - Must be a RowSpanCell - * - * Or an `Object` with any of the following properties (multiple properties allowed): - * * rowSpan:Number - Must be a normal cell with the given rowSpan. - * * colSpan:Number - Must be a normal cell with the given colSpan. - * * content:String - Must be a normal cell with the given content. - * * spannerFor:[row,col] - Must be a RowSpanCell delegating to the cell at the given coordinates. - * - * @param actualRows - the table of cells under test. - * @param expectedRows - a table of shorthand assertions. - */ - - function checkLayout(actualTable,expectedTable){ - _.forEach(expectedTable,function(expectedRow,y){ - _.forEach(expectedRow,function(expectedCell,x){ - if(expectedCell !== null){ - var actualCell = findCell(actualTable,x,y); - checkExpectation(actualCell,expectedCell,x,y,actualTable); - } - }); - }); - } - - function findCell(table,x,y){ - for(var i = 0; i < table.length; i++){ - var row = table[i]; - for(var j = 0; j < row.length; j++){ - var cell = row[j]; - if(cell.x === x && cell.y === y){ - return cell; - } - } - } - } - - function checkExpectation(actualCell,expectedCell,x,y,actualTable){ - if(_.isString(expectedCell)){ - expectedCell = {content:expectedCell}; - } - var address = '(' + y + ',' + x + ')'; - if(expectedCell.hasOwnProperty('content')){ - expect(actualCell, address).to.be.instanceOf(Cell); - expect(actualCell.content,'content of ' + address).to.equal(expectedCell.content); - } - if(expectedCell.hasOwnProperty('rowSpan')){ - expect(actualCell, address).to.be.instanceOf(Cell); - expect(actualCell.rowSpan, 'rowSpan of ' + address).to.equal(expectedCell.rowSpan); - } - if(expectedCell.hasOwnProperty('colSpan')){ - expect(actualCell, address).to.be.instanceOf(Cell); - expect(actualCell.colSpan, 'colSpan of ' + address).to.equal(expectedCell.colSpan); - } - if(expectedCell.hasOwnProperty('spannerFor')){ - expect(actualCell, address).to.be.instanceOf(Cell.RowSpanCell); - expect(actualCell.originalCell,address + 'originalCell should be a cell').to.be.instanceOf(Cell); - expect(actualCell.originalCell,address + 'originalCell not right').to.equal(findCell(actualTable, - expectedCell.spannerFor[1], - expectedCell.spannerFor[0] - )); - //TODO: retest here x,y coords - } - } -}); \ No newline at end of file diff --git a/node_modules/cli-table2/test/table-test.js b/node_modules/cli-table2/test/table-test.js deleted file mode 100644 index 4bc3e055d93..00000000000 --- a/node_modules/cli-table2/test/table-test.js +++ /dev/null @@ -1,87 +0,0 @@ -describe('@api Table ',function(){ - var chai = require('chai'); - var expect = chai.expect; - var Table = require('..'); - var colors = require('colors/safe'); - - it('wordWrap with colored text',function(){ - var table = new Table({style:{border:[],head:[]},wordWrap:true,colWidths:[7,9]}); - - table.push([colors.red('Hello how are you?'),colors.blue('I am fine thanks!')]); - - var expected = [ - '┌───────┬─────────┐' - , '│ ' + colors.red('Hello') + ' │ ' + colors.blue('I am') + ' │' - , '│ ' + colors.red('how') + ' │ ' + colors.blue('fine') + ' │' - , '│ ' + colors.red('are') + ' │ ' + colors.blue('thanks!') + ' │' - , '│ ' + colors.red('you?') + ' │ │' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('allows numbers as `content` property of cells defined using object notation', function() { - var table = new Table({style:{border:[],head:[]}}); - - table.push([{content: 12}]); - - var expected = [ - '┌────┐' - , '│ 12 │' - , '└────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('throws if content is not a string or number', function() { - var table = new Table({style:{border:[],head:[]}}); - - expect(function() { - table.push([{content: {a:'b'}}]); - table.toString(); - }).to.throw(); - - }); - - it('works with CJK values', function () { - var table = new Table({style: {border:[],head:[]}, colWidths: [5, 10, 5]}); - - table.push( - ['foobar', 'English test', 'baz'] - , ['foobar', '中文测试', 'baz'] - , ['foobar', '日本語テスト', 'baz'] - , ['foobar', '한국어테스트', 'baz'] - ); - - var expected = [ - '┌─────┬──────────┬─────┐' - , '│ fo… │ English… │ baz │' - , '├─────┼──────────┼─────┤' - , '│ fo… │ 中文测试 │ baz │' - , '├─────┼──────────┼─────┤' - , '│ fo… │ 日本語… │ baz │' - , '├─────┼──────────┼─────┤' - , '│ fo… │ 한국어… │ baz │' - , '└─────┴──────────┴─────┘' - ]; - - expect(table.toString()).to.equal(expected.join("\n")); - }); -}); - - -/* - - var expected = [ - '┌──┬───┬──┬──┐' - , '│ │ │ │ │' - , '├──┼───┼──┼──┤' - , '│ │ … │ │ │' - , '├──┼───┼──┼──┤' - , '│ │ … │ │ │' - , '└──┴───┴──┴──┘' - ]; - - */ diff --git a/node_modules/cli-table2/test/utils-test.js b/node_modules/cli-table2/test/utils-test.js deleted file mode 100644 index f876b87e631..00000000000 --- a/node_modules/cli-table2/test/utils-test.js +++ /dev/null @@ -1,414 +0,0 @@ -describe('utils',function(){ - var colors = require('colors/safe'); - var chai = require('chai'); - var utils = require('../src/utils'); - var expect = chai.expect; - - var strlen = utils.strlen; - var repeat = utils.repeat; - var pad = utils.pad; - var truncate = utils.truncate; - var mergeOptions = utils.mergeOptions; - var wordWrap = utils.wordWrap; - - - describe('strlen',function(){ - it('length of "hello" is 5',function(){ - expect(strlen('hello')).to.equal(5); - }); - - it('length of "hi" is 2',function(){ - expect(strlen('hi')).to.equal(2); - }); - - it('length of "hello" in red is 5',function(){ - expect(strlen(colors.red('hello'))).to.equal(5); - }); - - it('length of "hello" in zebra is 5',function(){ - expect(strlen(colors.zebra('hello'))).to.equal(5); - }); - - it('length of "hello\\nhi\\nheynow" is 6',function(){ - expect(strlen('hello\nhi\nheynow')).to.equal(6); - }); - - it('length of "中文字符" is 8',function(){ - expect(strlen('中文字符')).to.equal(8); - }); - - it('length of "日本語の文字" is 12',function(){ - expect(strlen('日本語の文字')).to.equal(12); - }); - - it('length of "한글" is 4',function(){ - expect(strlen('한글')).to.equal(4); - }); - }); - - describe('repeat',function(){ - it('"-" x 3',function(){ - expect(repeat('-',3)).to.equal('---'); - }); - - it('"-" x 4',function(){ - expect(repeat('-',4)).to.equal('----'); - }); - - it('"=" x 4',function(){ - expect(repeat('=',4)).to.equal('===='); - }); - }); - - describe('pad',function(){ - it("pad('hello',6,' ', right) == ' hello'", function () { - expect(pad('hello',6,' ','right')).to.equal(' hello'); - }); - - it("pad('hello',7,' ', left) == 'hello '", function () { - expect(pad('hello',7,' ','left')).to.equal('hello '); - }); - - it("pad('hello',8,' ', center) == ' hello '", function () { - expect(pad('hello',8,' ','center')).to.equal(' hello '); - }); - - it("pad('hello',9,' ', center) == ' hello '", function () { - expect(pad('hello',9,' ','center')).to.equal(' hello '); - }); - - it("pad('yo',4,' ', center) == ' yo '", function () { - expect(pad('yo',4,' ','center')).to.equal(' yo '); - }); - - it('pad red(hello)', function(){ - expect(pad(colors.red('hello'),7,' ','right')).to.equal(' ' + colors.red('hello')); - }); - - it("pad('hello', 2, ' ', right) == 'hello'", function(){ - expect(pad('hello', 2, ' ', 'right')).to.equal('hello'); - }); - }); - - describe('truncate',function(){ - it('truncate("hello", 5) === "hello"',function(){ - expect(truncate('hello',5)).to.equal('hello'); - }); - - it('truncate("hello sir", 7, "…") == "hello …"',function(){ - expect(truncate('hello sir', 7, '…')).to.equal('hello …'); - }); - - it('truncate("hello sir", 6, "…") == "hello…"',function(){ - expect(truncate('hello sir', 6, '…')).to.equal('hello…'); - }); - - it('truncate("goodnight moon", 8, "…") == "goodnig…"',function(){ - expect(truncate('goodnight moon', 8, '…')).to.equal('goodnig…'); - }); - - it('truncate(colors.zebra("goodnight moon"), 15, "…") == colors.zebra("goodnight moon")',function(){ - var original = colors.zebra('goodnight moon'); - expect(truncate(original, 15, '…')).to.equal(original); - }); - - it('truncate(colors.zebra("goodnight moon"), 8, "…") == colors.zebra("goodnig") + "…"',function(){ - var original = colors.zebra('goodnight moon'); - var expected = colors.zebra('goodnig') + '…'; - expect(truncate(original, 8, '…')).to.equal(expected); - }); - - it('truncate(colors.zebra("goodnight moon"), 9, "…") == colors.zebra("goodnig") + "…"',function(){ - var original = colors.zebra('goodnight moon'); - var expected = colors.zebra('goodnigh') + '…'; - expect(truncate(original, 9, '…')).to.equal(expected); - }); - - it('red(hello) + green(world) truncated to 9 chars',function(){ - var original = colors.red('hello') + colors.green(' world'); - var expected = colors.red('hello') + colors.green(' wo') + '…'; - expect(truncate(original, 9)).to.equal(expected); - }); - - it('red-on-green(hello) + green-on-red(world) truncated to 9 chars',function(){ - var original = colors.red.bgGreen('hello') + colors.green.bgRed(' world'); - var expected = colors.red.bgGreen('hello') + colors.green.bgRed(' wo') + '…'; - expect(truncate(original,9)).to.equal(expected); - }); - - it('red-on-green(hello) + green-on-red(world) truncated to 10 chars - using inverse',function(){ - var original = colors.red.bgGreen('hello' + colors.inverse(' world')); - var expected = colors.red.bgGreen('hello' + colors.inverse(' wor')) + '…'; - expect(truncate(original,10)).to.equal(expected); - }); - - it('red-on-green( zebra (hello world) ) truncated to 11 chars',function(){ - var original = colors.red.bgGreen(colors.zebra('hello world')); - var expected = colors.red.bgGreen(colors.zebra('hello world')); - expect(truncate(original,11)).to.equal(expected); - }); - - it('red-on-green( zebra (hello world) ) truncated to 10 chars',function(){ - var original = colors.red.bgGreen(colors.zebra('hello world')); - var expected = colors.red.bgGreen(colors.zebra('hello wor')) + '…'; - expect(truncate(original,10)).to.equal(expected); - }); - - it('handles reset code', function() { - var original = '\x1b[31mhello\x1b[0m world'; - var expected = '\x1b[31mhello\x1b[0m wor…'; - expect(truncate(original,10)).to.equal(expected); - }); - - it('handles reset code (EMPTY VERSION)', function() { - var original = '\x1b[31mhello\x1b[0m world'; - var expected = '\x1b[31mhello\x1b[0m wor…'; - expect(truncate(original,10)).to.equal(expected); - }); - - it('truncateWidth("漢字テスト", 15) === "漢字テスト"',function(){ - expect(truncate('漢字テスト',15)).to.equal('漢字テスト'); - }); - - it('truncateWidth("漢字テスト", 6) === "漢字…"',function(){ - expect(truncate('漢字テスト',6)).to.equal('漢字…'); - }); - - it('truncateWidth("漢字テスト", 5) === "漢字…"',function(){ - expect(truncate('漢字テスト',5)).to.equal('漢字…'); - }); - - it('truncateWidth("漢字testてすと", 12) === "漢字testて…"',function(){ - expect(truncate('漢字testてすと',12)).to.equal('漢字testて…'); - }); - - it('handles color code with CJK chars',function(){ - var original = '漢字\x1b[31m漢字\x1b[0m漢字'; - var expected = '漢字\x1b[31m漢字\x1b[0m漢…'; - expect(truncate(original,11)).to.equal(expected); - }); - }); - - function defaultOptions(){ - return { - chars: { - 'top': '─' - , 'top-mid': '┬' - , 'top-left': '┌' - , 'top-right': '┐' - , 'bottom': '─' - , 'bottom-mid': '┴' - , 'bottom-left': '└' - , 'bottom-right': '┘' - , 'left': '│' - , 'left-mid': '├' - , 'mid': '─' - , 'mid-mid': '┼' - , 'right': '│' - , 'right-mid': '┤' - , 'middle': '│' - } - , truncate: '…' - , colWidths: [] - , rowHeights: [] - , colAligns: [] - , rowAligns: [] - , style: { - 'padding-left': 1 - , 'padding-right': 1 - , head: ['red'] - , border: ['grey'] - , compact : false - } - , head: [] - }; - } - - describe('mergeOptions',function(){ - it('allows you to override chars',function(){ - expect(mergeOptions()).to.eql(defaultOptions()); - }); - - it('chars will be merged deeply',function(){ - var expected = defaultOptions(); - expected.chars.left = 'L'; - expect(mergeOptions({chars:{left:'L'}})).to.eql(expected); - }); - - it('style will be merged deeply',function(){ - var expected = defaultOptions(); - expected.style['padding-left'] = 2; - expect(mergeOptions({style:{'padding-left':2}})).to.eql(expected); - }); - - it('head will be overwritten',function(){ - var expected = defaultOptions(); - expected.style.head = []; - //we can't use lodash's `merge()` in implementation because it would deeply copy array. - expect(mergeOptions({style:{'head':[]}})).to.eql(expected); - }); - - it('border will be overwritten',function(){ - var expected = defaultOptions(); - expected.style.border = []; - //we can't use lodash's `merge()` in implementation because it would deeply copy array. - expect(mergeOptions({style:{'border':[]}})).to.eql(expected); - }); - }); - - describe('wordWrap',function(){ - it('length',function(){ - var input = 'Hello, how are you today? I am fine, thank you!'; - - var expected = 'Hello, how\nare you\ntoday? I\nam fine,\nthank you!'; - - expect(wordWrap(10,input).join('\n')).to.equal(expected); - }); - - it('length with colors',function(){ - var input = colors.red('Hello, how are') + colors.blue(' you today? I') + colors.green(' am fine, thank you!'); - - var expected = colors.red('Hello, how\nare') + colors.blue(' you\ntoday? I') + colors.green('\nam fine,\nthank you!'); - - expect(wordWrap(10,input).join('\n')).to.equal(expected); - }); - - it('will not create an empty last line',function(){ - var input = 'Hello Hello '; - - var expected = 'Hello\nHello'; - - expect(wordWrap(5,input).join('\n')).to.equal(expected); - }); - - it('will handle color reset code',function(){ - var input = '\x1b[31mHello\x1b[0m Hello '; - - var expected = '\x1b[31mHello\x1b[0m\nHello'; - - expect(wordWrap(5,input).join('\n')).to.equal(expected); - }); - - it('will handle color reset code (EMPTY version)',function(){ - var input = '\x1b[31mHello\x1b[m Hello '; - - var expected = '\x1b[31mHello\x1b[m\nHello'; - - expect(wordWrap(5,input).join('\n')).to.equal(expected); - }); - - it('words longer than limit will not create extra newlines',function(){ - var input = 'disestablishment is a multiplicity someotherlongword'; - - var expected = 'disestablishment\nis a\nmultiplicity\nsomeotherlongword'; - - expect(wordWrap(7,input).join('\n')).to.equal(expected); - }); - - it('multiple line input',function(){ - var input = 'a\nb\nc d e d b duck\nm\nn\nr'; - var expected = ['a', 'b', 'c d', 'e d', 'b', 'duck', 'm', 'n', 'r']; - - expect(wordWrap(4,input)).to.eql(expected); - }); - - it('will not start a line with whitespace', function(){ - var input = 'ab cd ef gh ij kl'; - var expected = ['ab cd','ef gh', 'ij kl']; - expect(wordWrap(7, input)).to.eql(expected); - }); - - it('wraps CJK chars', function(){ - var input = '漢字 漢\n字 漢字'; - var expected = ['漢字 漢','字 漢字']; - expect(wordWrap(7, input)).to.eql(expected); - }); - - it('wraps CJK chars with colors', function(){ - var input = '\x1b[31m漢字\x1b[0m\n 漢字'; - var expected = ['\x1b[31m漢字\x1b[0m', ' 漢字']; - expect(wordWrap(5, input)).to.eql(expected); - }); - }); - - describe('colorizeLines',function(){ - it('foreground colors continue on each line',function(){ - var input = colors.red('Hello\nHi').split('\n'); - - expect(utils.colorizeLines(input)).to.eql([ - colors.red('Hello'), - colors.red('Hi') - ]); - }); - - it('foreground colors continue on each line',function(){ - var input = colors.bgRed('Hello\nHi').split('\n'); - - expect(utils.colorizeLines(input)).to.eql([ - colors.bgRed('Hello'), - colors.bgRed('Hi') - ]); - }); - - it('styles will continue on each line',function(){ - var input = colors.underline('Hello\nHi').split('\n'); - - expect(utils.colorizeLines(input)).to.eql([ - colors.underline('Hello'), - colors.underline('Hi') - ]); - }); - - it('styles that end before the break will not be applied to the next line',function(){ - var input = (colors.underline('Hello') +'\nHi').split('\n'); - - expect(utils.colorizeLines(input)).to.eql([ - colors.underline('Hello'), - 'Hi' - ]); - }); - - it('the reset code can be used to drop styles', function() { - var input = '\x1b[31mHello\x1b[0m\nHi'.split('\n'); - expect(utils.colorizeLines(input)).to.eql([ - "\x1b[31mHello\x1b[0m", - "Hi" - ]); - }); - - it('handles aixterm 16-color foreground', function() { - var input = '\x1b[90mHello\nHi\x1b[0m'.split('\n'); - expect(utils.colorizeLines(input)).to.eql([ - '\x1b[90mHello\x1b[39m', - '\x1b[90mHi\x1b[0m' - ]); - }); - - it('handles aixterm 16-color background', function() { - var input = '\x1b[100mHello\nHi\x1b[m\nHowdy'.split('\n'); - expect(utils.colorizeLines(input)).to.eql([ - '\x1b[100mHello\x1b[49m', - '\x1b[100mHi\x1b[m', - 'Howdy' - ]); - }); - - it('handles aixterm 256-color foreground', function() { - var input ='\x1b[48;5;8mHello\nHi\x1b[0m\nHowdy'.split('\n'); - expect(utils.colorizeLines(input)).to.eql([ - '\x1b[48;5;8mHello\x1b[49m', - '\x1b[48;5;8mHi\x1b[0m', - 'Howdy' - ]); - }); - - it('handles CJK chars',function(){ - var input = colors.red('漢字\nテスト').split('\n'); - - expect(utils.colorizeLines(input)).to.eql([ - colors.red('漢字'), - colors.red('テスト') - ]); - }); - }); -}); \ No newline at end of file diff --git a/node_modules/cli-table2/test/verify-legacy-compatibility-test.js b/node_modules/cli-table2/test/verify-legacy-compatibility-test.js deleted file mode 100644 index 5cd4703477e..00000000000 --- a/node_modules/cli-table2/test/verify-legacy-compatibility-test.js +++ /dev/null @@ -1,158 +0,0 @@ -(function(){ - describe('verify original cli-table behavior',function(){ - commonTests(require('cli-table')); - }); - - describe('@api cli-table2 matches verified behavior',function(){ - commonTests(require('../src/table')); - }); - - function commonTests(Table){ - var chai = require('chai'); - var expect = chai.expect; - var colors = require('colors/safe'); - - it('empty table has a width of 0',function(){ - var table = new Table(); - expect(table.width).to.equal(0); - expect(table.toString()).to.equal(''); - }); - - it('header text will be colored according to style',function(){ - var table = new Table({head:['hello','goodbye'],style:{border:[],head:['red','bgWhite']}}); - - var expected = [ - '┌───────┬─────────┐' - , '│' + colors.bgWhite.red(' hello ') +'│' + colors.bgWhite.red(' goodbye ') + '│' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('tables with one row of data will not be treated as headers',function(){ - var table = new Table({style:{border:[],head:['red']}}); - - table.push(['hello','goodbye']); - - var expected = [ - '┌───────┬─────────┐' - , '│ hello │ goodbye │' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('table with headers and data headers',function(){ - var table = new Table({head:['hello','goodbye'],style:{border:[],head:['red']}}); - - table.push(['hola','adios']); - - var expected = [ - '┌───────┬─────────┐' - , '│' + colors.red(' hello ') +'│' + colors.red(' goodbye ') + '│' - , '├───────┼─────────┤' - , '│ hola │ adios │' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('compact shorthand',function(){ - var table = new Table({style:{compact:true,border:[],head:['red']}}); - - table.push(['hello','goodbye'],['hola','adios']); - - var expected = [ - '┌───────┬─────────┐' - , '│ hello │ goodbye │' - , '│ hola │ adios │' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('compact shorthand - headers are still rendered with separator',function(){ - var table = new Table({head:['hello','goodbye'],style:{compact:true,border:[],head:[]}}); - - table.push(['hola','adios'],['hi','bye']); - - var expected = [ - '┌───────┬─────────┐' - , '│ hello │ goodbye │' - , '├───────┼─────────┤' - , '│ hola │ adios │' - , '│ hi │ bye │' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('compact longhand - headers are not rendered with separator',function(){ - var table = new Table({ - chars: { - 'mid': '' - , 'left-mid': '' - , 'mid-mid': '' - , 'right-mid': '' - }, - head:['hello','goodbye'], - style:{border:[],head:[]}} - ); - - table.push(['hola','adios'],['hi','bye']); - - var expected = [ - '┌───────┬─────────┐' - , '│ hello │ goodbye │' - , '│ hola │ adios │' - , '│ hi │ bye │' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('compact longhand',function(){ - var table = new Table({ - chars: { - 'mid': '' - , 'left-mid': '' - , 'mid-mid': '' - , 'right-mid': '' - }, - style:{border:[],head:['red']} - }); - - table.push(['hello','goodbye'],['hola','adios']); - - var expected = [ - '┌───────┬─────────┐' - , '│ hello │ goodbye │' - , '│ hola │ adios │' - , '└───────┴─────────┘' - ]; - - expect(table.toString()).to.equal(expected.join('\n')); - }); - - it('objects with multiple properties in a cross-table',function(){ - var table = new Table({style:{border:[],head:[]}}); - - table.push( - {'a':['b'], c:['d']} // value of property 'c' will be discarded - ); - - var expected = [ - '┌───┬───┐' - , '│ a │ b │' - , '└───┴───┘' - ]; - expect(table.toString()).to.equal(expected.join('\n')); - }); - } -})(); \ No newline at end of file diff --git a/node_modules/lodash/LICENSE b/node_modules/lodash/LICENSE deleted file mode 100644 index 9cd87e5dcef..00000000000 --- a/node_modules/lodash/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright 2012-2015 The Dojo Foundation -Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, -DocumentCloud and Investigative Reporters & Editors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/lodash/README.md b/node_modules/lodash/README.md deleted file mode 100644 index fd98e5c9895..00000000000 --- a/node_modules/lodash/README.md +++ /dev/null @@ -1,121 +0,0 @@ -# lodash v3.10.1 - -The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) modules. - -Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli): -```bash -$ lodash modularize modern exports=node -o ./ -$ lodash modern -d -o ./index.js -``` - -## Installation - -Using npm: - -```bash -$ {sudo -H} npm i -g npm -$ npm i --save lodash -``` - -In Node.js/io.js: - -```js -// load the modern build -var _ = require('lodash'); -// or a method category -var array = require('lodash/array'); -// or a method (great for smaller builds with browserify/webpack) -var chunk = require('lodash/array/chunk'); -``` - -See the [package source](https://github.com/lodash/lodash/tree/3.10.1-npm) for more details. - -**Note:**
-Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.
-Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash by default. - -## Module formats - -lodash is also available in a variety of other builds & module formats. - - * npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds - * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.10.1-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.10.1-amd) builds - * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.10.1-es) build - -## Further Reading - - * [API Documentation](https://lodash.com/docs) - * [Build Differences](https://github.com/lodash/lodash/wiki/Build-Differences) - * [Changelog](https://github.com/lodash/lodash/wiki/Changelog) - * [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap) - * [More Resources](https://github.com/lodash/lodash/wiki/Resources) - -## Features - - * ~100% [code coverage](https://coveralls.io/r/lodash) - * Follows [semantic versioning](http://semver.org/) for releases - * [Lazily evaluated](http://filimanjaro.com/blog/2014/introducing-lazy-evaluation/) chaining - * [_(…)](https://lodash.com/docs#_) supports implicit chaining - * [_.ary](https://lodash.com/docs#ary) & [_.rearg](https://lodash.com/docs#rearg) to change function argument limits & order - * [_.at](https://lodash.com/docs#at) for cherry-picking collection values - * [_.attempt](https://lodash.com/docs#attempt) to execute functions which may error without a try-catch - * [_.before](https://lodash.com/docs#before) to complement [_.after](https://lodash.com/docs#after) - * [_.bindKey](https://lodash.com/docs#bindKey) for binding [*“lazy”*](http://michaux.ca/articles/lazy-function-definition-pattern) defined methods - * [_.chunk](https://lodash.com/docs#chunk) for splitting an array into chunks of a given size - * [_.clone](https://lodash.com/docs#clone) supports shallow cloning of `Date` & `RegExp` objects - * [_.cloneDeep](https://lodash.com/docs#cloneDeep) for deep cloning arrays & objects - * [_.curry](https://lodash.com/docs#curry) & [_.curryRight](https://lodash.com/docs#curryRight) for creating [curried](http://hughfdjackson.com/javascript/why-curry-helps/) functions - * [_.debounce](https://lodash.com/docs#debounce) & [_.throttle](https://lodash.com/docs#throttle) are cancelable & accept options for more control - * [_.defaultsDeep](https://lodash.com/docs#defaultsDeep) for recursively assigning default properties - * [_.fill](https://lodash.com/docs#fill) to fill arrays with values - * [_.findKey](https://lodash.com/docs#findKey) for finding keys - * [_.flow](https://lodash.com/docs#flow) to complement [_.flowRight](https://lodash.com/docs#flowRight) (a.k.a `_.compose`) - * [_.forEach](https://lodash.com/docs#forEach) supports exiting early - * [_.forIn](https://lodash.com/docs#forIn) for iterating all enumerable properties - * [_.forOwn](https://lodash.com/docs#forOwn) for iterating own properties - * [_.get](https://lodash.com/docs#get) & [_.set](https://lodash.com/docs#set) for deep property getting & setting - * [_.gt](https://lodash.com/docs#gt), [_.gte](https://lodash.com/docs#gte), [_.lt](https://lodash.com/docs#lt), & [_.lte](https://lodash.com/docs#lte) relational methods - * [_.inRange](https://lodash.com/docs#inRange) for checking whether a number is within a given range - * [_.isNative](https://lodash.com/docs#isNative) to check for native functions - * [_.isPlainObject](https://lodash.com/docs#isPlainObject) & [_.toPlainObject](https://lodash.com/docs#toPlainObject) to check for & convert to `Object` objects - * [_.isTypedArray](https://lodash.com/docs#isTypedArray) to check for typed arrays - * [_.mapKeys](https://lodash.com/docs#mapKeys) for mapping keys to an object - * [_.matches](https://lodash.com/docs#matches) supports deep object comparisons - * [_.matchesProperty](https://lodash.com/docs#matchesProperty) to complement [_.matches](https://lodash.com/docs#matches) & [_.property](https://lodash.com/docs#property) - * [_.merge](https://lodash.com/docs#merge) for a deep [_.extend](https://lodash.com/docs#extend) - * [_.method](https://lodash.com/docs#method) & [_.methodOf](https://lodash.com/docs#methodOf) to create functions that invoke methods - * [_.modArgs](https://lodash.com/docs#modArgs) for more advanced functional composition - * [_.parseInt](https://lodash.com/docs#parseInt) for consistent cross-environment behavior - * [_.pull](https://lodash.com/docs#pull), [_.pullAt](https://lodash.com/docs#pullAt), & [_.remove](https://lodash.com/docs#remove) for mutating arrays - * [_.random](https://lodash.com/docs#random) supports returning floating-point numbers - * [_.restParam](https://lodash.com/docs#restParam) & [_.spread](https://lodash.com/docs#spread) for applying rest parameters & spreading arguments to functions - * [_.runInContext](https://lodash.com/docs#runInContext) for collisionless mixins & easier mocking - * [_.slice](https://lodash.com/docs#slice) for creating subsets of array-like values - * [_.sortByAll](https://lodash.com/docs#sortByAll) & [_.sortByOrder](https://lodash.com/docs#sortByOrder) for sorting by multiple properties & orders - * [_.support](https://lodash.com/docs#support) for flagging environment features - * [_.template](https://lodash.com/docs#template) supports [*“imports”*](https://lodash.com/docs#templateSettings-imports) options & [ES template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components) - * [_.transform](https://lodash.com/docs#transform) as a powerful alternative to [_.reduce](https://lodash.com/docs#reduce) for transforming objects - * [_.unzipWith](https://lodash.com/docs#unzipWith) & [_.zipWith](https://lodash.com/docs#zipWith) to specify how grouped values should be combined - * [_.valuesIn](https://lodash.com/docs#valuesIn) for getting values of all enumerable properties - * [_.xor](https://lodash.com/docs#xor) to complement [_.difference](https://lodash.com/docs#difference), [_.intersection](https://lodash.com/docs#intersection), & [_.union](https://lodash.com/docs#union) - * [_.add](https://lodash.com/docs#add), [_.round](https://lodash.com/docs#round), [_.sum](https://lodash.com/docs#sum), & - [more](https://lodash.com/docs "_.ceil & _.floor") math methods - * [_.bind](https://lodash.com/docs#bind), [_.curry](https://lodash.com/docs#curry), [_.partial](https://lodash.com/docs#partial), & - [more](https://lodash.com/docs "_.bindKey, _.curryRight, _.partialRight") support customizable argument placeholders - * [_.capitalize](https://lodash.com/docs#capitalize), [_.trim](https://lodash.com/docs#trim), & - [more](https://lodash.com/docs "_.camelCase, _.deburr, _.endsWith, _.escapeRegExp, _.kebabCase, _.pad, _.padLeft, _.padRight, _.repeat, _.snakeCase, _.startCase, _.startsWith, _.trimLeft, _.trimRight, _.trunc, _.words") string methods - * [_.clone](https://lodash.com/docs#clone), [_.isEqual](https://lodash.com/docs#isEqual), & - [more](https://lodash.com/docs "_.assign, _.cloneDeep, _.merge") accept customizer callbacks - * [_.dropWhile](https://lodash.com/docs#dropWhile), [_.takeWhile](https://lodash.com/docs#takeWhile), & - [more](https://lodash.com/docs "_.drop, _.dropRight, _.dropRightWhile, _.take, _.takeRight, _.takeRightWhile") to complement [_.first](https://lodash.com/docs#first), [_.initial](https://lodash.com/docs#initial), [_.last](https://lodash.com/docs#last), & [_.rest](https://lodash.com/docs#rest) - * [_.findLast](https://lodash.com/docs#findLast), [_.findLastKey](https://lodash.com/docs#findLastKey), & - [more](https://lodash.com/docs "_.curryRight, _.dropRight, _.dropRightWhile, _.flowRight, _.forEachRight, _.forInRight, _.forOwnRight, _.padRight, partialRight, _.takeRight, _.trimRight, _.takeRightWhile") right-associative methods - * [_.includes](https://lodash.com/docs#includes), [_.toArray](https://lodash.com/docs#toArray), & - [more](https://lodash.com/docs "_.at, _.countBy, _.every, _.filter, _.find, _.findLast, _.findWhere, _.forEach, _.forEachRight, _.groupBy, _.indexBy, _.invoke, _.map, _.max, _.min, _.partition, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.size, _.some, _.sortBy, _.sortByAll, _.sortByOrder, _.sum, _.where") accept strings - * [_#commit](https://lodash.com/docs#prototype-commit) & [_#plant](https://lodash.com/docs#prototype-plant) for working with chain sequences - * [_#thru](https://lodash.com/docs#thru) to pass values thru a chain sequence - -## Support - -Tested in Chrome 43-44, Firefox 38-39, IE 6-11, MS Edge, Safari 5-8, ChakraNode 0.12.2, io.js 2.5.0, Node.js 0.8.28, 0.10.40, & 0.12.7, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7.6. -Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing. diff --git a/node_modules/lodash/array.js b/node_modules/lodash/array.js deleted file mode 100644 index e5121fa52ec..00000000000 --- a/node_modules/lodash/array.js +++ /dev/null @@ -1,44 +0,0 @@ -module.exports = { - 'chunk': require('./array/chunk'), - 'compact': require('./array/compact'), - 'difference': require('./array/difference'), - 'drop': require('./array/drop'), - 'dropRight': require('./array/dropRight'), - 'dropRightWhile': require('./array/dropRightWhile'), - 'dropWhile': require('./array/dropWhile'), - 'fill': require('./array/fill'), - 'findIndex': require('./array/findIndex'), - 'findLastIndex': require('./array/findLastIndex'), - 'first': require('./array/first'), - 'flatten': require('./array/flatten'), - 'flattenDeep': require('./array/flattenDeep'), - 'head': require('./array/head'), - 'indexOf': require('./array/indexOf'), - 'initial': require('./array/initial'), - 'intersection': require('./array/intersection'), - 'last': require('./array/last'), - 'lastIndexOf': require('./array/lastIndexOf'), - 'object': require('./array/object'), - 'pull': require('./array/pull'), - 'pullAt': require('./array/pullAt'), - 'remove': require('./array/remove'), - 'rest': require('./array/rest'), - 'slice': require('./array/slice'), - 'sortedIndex': require('./array/sortedIndex'), - 'sortedLastIndex': require('./array/sortedLastIndex'), - 'tail': require('./array/tail'), - 'take': require('./array/take'), - 'takeRight': require('./array/takeRight'), - 'takeRightWhile': require('./array/takeRightWhile'), - 'takeWhile': require('./array/takeWhile'), - 'union': require('./array/union'), - 'uniq': require('./array/uniq'), - 'unique': require('./array/unique'), - 'unzip': require('./array/unzip'), - 'unzipWith': require('./array/unzipWith'), - 'without': require('./array/without'), - 'xor': require('./array/xor'), - 'zip': require('./array/zip'), - 'zipObject': require('./array/zipObject'), - 'zipWith': require('./array/zipWith') -}; diff --git a/node_modules/lodash/array/chunk.js b/node_modules/lodash/array/chunk.js deleted file mode 100644 index c8be1fb02da..00000000000 --- a/node_modules/lodash/array/chunk.js +++ /dev/null @@ -1,46 +0,0 @@ -var baseSlice = require('../internal/baseSlice'), - isIterateeCall = require('../internal/isIterateeCall'); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeCeil = Math.ceil, - nativeFloor = Math.floor, - nativeMax = Math.max; - -/** - * Creates an array of elements split into groups the length of `size`. - * If `collection` can't be split evenly, the final chunk will be the remaining - * elements. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to process. - * @param {number} [size=1] The length of each chunk. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the new array containing chunks. - * @example - * - * _.chunk(['a', 'b', 'c', 'd'], 2); - * // => [['a', 'b'], ['c', 'd']] - * - * _.chunk(['a', 'b', 'c', 'd'], 3); - * // => [['a', 'b', 'c'], ['d']] - */ -function chunk(array, size, guard) { - if (guard ? isIterateeCall(array, size, guard) : size == null) { - size = 1; - } else { - size = nativeMax(nativeFloor(size) || 1, 1); - } - var index = 0, - length = array ? array.length : 0, - resIndex = -1, - result = Array(nativeCeil(length / size)); - - while (index < length) { - result[++resIndex] = baseSlice(array, index, (index += size)); - } - return result; -} - -module.exports = chunk; diff --git a/node_modules/lodash/array/compact.js b/node_modules/lodash/array/compact.js deleted file mode 100644 index 1dc1c55e8f1..00000000000 --- a/node_modules/lodash/array/compact.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are falsey. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to compact. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.compact([0, 1, false, 2, '', 3]); - * // => [1, 2, 3] - */ -function compact(array) { - var index = -1, - length = array ? array.length : 0, - resIndex = -1, - result = []; - - while (++index < length) { - var value = array[index]; - if (value) { - result[++resIndex] = value; - } - } - return result; -} - -module.exports = compact; diff --git a/node_modules/lodash/array/difference.js b/node_modules/lodash/array/difference.js deleted file mode 100644 index 128932a146d..00000000000 --- a/node_modules/lodash/array/difference.js +++ /dev/null @@ -1,29 +0,0 @@ -var baseDifference = require('../internal/baseDifference'), - baseFlatten = require('../internal/baseFlatten'), - isArrayLike = require('../internal/isArrayLike'), - isObjectLike = require('../internal/isObjectLike'), - restParam = require('../function/restParam'); - -/** - * Creates an array of unique `array` values not included in the other - * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The arrays of values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.difference([1, 2, 3], [4, 2]); - * // => [1, 3] - */ -var difference = restParam(function(array, values) { - return (isObjectLike(array) && isArrayLike(array)) - ? baseDifference(array, baseFlatten(values, false, true)) - : []; -}); - -module.exports = difference; diff --git a/node_modules/lodash/array/drop.js b/node_modules/lodash/array/drop.js deleted file mode 100644 index 039a0b5fdcd..00000000000 --- a/node_modules/lodash/array/drop.js +++ /dev/null @@ -1,39 +0,0 @@ -var baseSlice = require('../internal/baseSlice'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Creates a slice of `array` with `n` elements dropped from the beginning. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.drop([1, 2, 3]); - * // => [2, 3] - * - * _.drop([1, 2, 3], 2); - * // => [3] - * - * _.drop([1, 2, 3], 5); - * // => [] - * - * _.drop([1, 2, 3], 0); - * // => [1, 2, 3] - */ -function drop(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - return baseSlice(array, n < 0 ? 0 : n); -} - -module.exports = drop; diff --git a/node_modules/lodash/array/dropRight.js b/node_modules/lodash/array/dropRight.js deleted file mode 100644 index 14b5eb6f0a1..00000000000 --- a/node_modules/lodash/array/dropRight.js +++ /dev/null @@ -1,40 +0,0 @@ -var baseSlice = require('../internal/baseSlice'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Creates a slice of `array` with `n` elements dropped from the end. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropRight([1, 2, 3]); - * // => [1, 2] - * - * _.dropRight([1, 2, 3], 2); - * // => [1] - * - * _.dropRight([1, 2, 3], 5); - * // => [] - * - * _.dropRight([1, 2, 3], 0); - * // => [1, 2, 3] - */ -function dropRight(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - n = length - (+n || 0); - return baseSlice(array, 0, n < 0 ? 0 : n); -} - -module.exports = dropRight; diff --git a/node_modules/lodash/array/dropRightWhile.js b/node_modules/lodash/array/dropRightWhile.js deleted file mode 100644 index be158bd5fa9..00000000000 --- a/node_modules/lodash/array/dropRightWhile.js +++ /dev/null @@ -1,59 +0,0 @@ -var baseCallback = require('../internal/baseCallback'), - baseWhile = require('../internal/baseWhile'); - -/** - * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until `predicate` returns falsey. The predicate is - * bound to `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that match the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropRightWhile([1, 2, 3], function(n) { - * return n > 1; - * }); - * // => [1] - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); - * // => ['barney', 'fred'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.dropRightWhile(users, 'active', false), 'user'); - * // => ['barney'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.dropRightWhile(users, 'active'), 'user'); - * // => ['barney', 'fred', 'pebbles'] - */ -function dropRightWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, baseCallback(predicate, thisArg, 3), true, true) - : []; -} - -module.exports = dropRightWhile; diff --git a/node_modules/lodash/array/dropWhile.js b/node_modules/lodash/array/dropWhile.js deleted file mode 100644 index d9eabae9fac..00000000000 --- a/node_modules/lodash/array/dropWhile.js +++ /dev/null @@ -1,59 +0,0 @@ -var baseCallback = require('../internal/baseCallback'), - baseWhile = require('../internal/baseWhile'); - -/** - * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until `predicate` returns falsey. The predicate is - * bound to `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropWhile([1, 2, 3], function(n) { - * return n < 3; - * }); - * // => [3] - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user'); - * // => ['fred', 'pebbles'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.dropWhile(users, 'active', false), 'user'); - * // => ['pebbles'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.dropWhile(users, 'active'), 'user'); - * // => ['barney', 'fred', 'pebbles'] - */ -function dropWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, baseCallback(predicate, thisArg, 3), true) - : []; -} - -module.exports = dropWhile; diff --git a/node_modules/lodash/array/fill.js b/node_modules/lodash/array/fill.js deleted file mode 100644 index 2c8f6da71d0..00000000000 --- a/node_modules/lodash/array/fill.js +++ /dev/null @@ -1,44 +0,0 @@ -var baseFill = require('../internal/baseFill'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Fills elements of `array` with `value` from `start` up to, but not - * including, `end`. - * - * **Note:** This method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3]; - * - * _.fill(array, 'a'); - * console.log(array); - * // => ['a', 'a', 'a'] - * - * _.fill(Array(3), 2); - * // => [2, 2, 2] - * - * _.fill([4, 6, 8], '*', 1, 2); - * // => [4, '*', 8] - */ -function fill(array, value, start, end) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { - start = 0; - end = length; - } - return baseFill(array, value, start, end); -} - -module.exports = fill; diff --git a/node_modules/lodash/array/findIndex.js b/node_modules/lodash/array/findIndex.js deleted file mode 100644 index 2a6b8e14bac..00000000000 --- a/node_modules/lodash/array/findIndex.js +++ /dev/null @@ -1,53 +0,0 @@ -var createFindIndex = require('../internal/createFindIndex'); - -/** - * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for instead of the element itself. - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.findIndex(users, function(chr) { - * return chr.user == 'barney'; - * }); - * // => 0 - * - * // using the `_.matches` callback shorthand - * _.findIndex(users, { 'user': 'fred', 'active': false }); - * // => 1 - * - * // using the `_.matchesProperty` callback shorthand - * _.findIndex(users, 'active', false); - * // => 0 - * - * // using the `_.property` callback shorthand - * _.findIndex(users, 'active'); - * // => 2 - */ -var findIndex = createFindIndex(); - -module.exports = findIndex; diff --git a/node_modules/lodash/array/findLastIndex.js b/node_modules/lodash/array/findLastIndex.js deleted file mode 100644 index d6d8eca6df7..00000000000 --- a/node_modules/lodash/array/findLastIndex.js +++ /dev/null @@ -1,53 +0,0 @@ -var createFindIndex = require('../internal/createFindIndex'); - -/** - * This method is like `_.findIndex` except that it iterates over elements - * of `collection` from right to left. - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.findLastIndex(users, function(chr) { - * return chr.user == 'pebbles'; - * }); - * // => 2 - * - * // using the `_.matches` callback shorthand - * _.findLastIndex(users, { 'user': 'barney', 'active': true }); - * // => 0 - * - * // using the `_.matchesProperty` callback shorthand - * _.findLastIndex(users, 'active', false); - * // => 2 - * - * // using the `_.property` callback shorthand - * _.findLastIndex(users, 'active'); - * // => 0 - */ -var findLastIndex = createFindIndex(true); - -module.exports = findLastIndex; diff --git a/node_modules/lodash/array/first.js b/node_modules/lodash/array/first.js deleted file mode 100644 index b3b9c79c7bb..00000000000 --- a/node_modules/lodash/array/first.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Gets the first element of `array`. - * - * @static - * @memberOf _ - * @alias head - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the first element of `array`. - * @example - * - * _.first([1, 2, 3]); - * // => 1 - * - * _.first([]); - * // => undefined - */ -function first(array) { - return array ? array[0] : undefined; -} - -module.exports = first; diff --git a/node_modules/lodash/array/flatten.js b/node_modules/lodash/array/flatten.js deleted file mode 100644 index dc2eff86867..00000000000 --- a/node_modules/lodash/array/flatten.js +++ /dev/null @@ -1,32 +0,0 @@ -var baseFlatten = require('../internal/baseFlatten'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Flattens a nested array. If `isDeep` is `true` the array is recursively - * flattened, otherwise it's only flattened a single level. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to flatten. - * @param {boolean} [isDeep] Specify a deep flatten. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flatten([1, [2, 3, [4]]]); - * // => [1, 2, 3, [4]] - * - * // using `isDeep` - * _.flatten([1, [2, 3, [4]]], true); - * // => [1, 2, 3, 4] - */ -function flatten(array, isDeep, guard) { - var length = array ? array.length : 0; - if (guard && isIterateeCall(array, isDeep, guard)) { - isDeep = false; - } - return length ? baseFlatten(array, isDeep) : []; -} - -module.exports = flatten; diff --git a/node_modules/lodash/array/flattenDeep.js b/node_modules/lodash/array/flattenDeep.js deleted file mode 100644 index 9f775febe2a..00000000000 --- a/node_modules/lodash/array/flattenDeep.js +++ /dev/null @@ -1,21 +0,0 @@ -var baseFlatten = require('../internal/baseFlatten'); - -/** - * Recursively flattens a nested array. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to recursively flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flattenDeep([1, [2, 3, [4]]]); - * // => [1, 2, 3, 4] - */ -function flattenDeep(array) { - var length = array ? array.length : 0; - return length ? baseFlatten(array, true) : []; -} - -module.exports = flattenDeep; diff --git a/node_modules/lodash/array/head.js b/node_modules/lodash/array/head.js deleted file mode 100644 index 1961b08c7eb..00000000000 --- a/node_modules/lodash/array/head.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./first'); diff --git a/node_modules/lodash/array/indexOf.js b/node_modules/lodash/array/indexOf.js deleted file mode 100644 index 4cfc6823199..00000000000 --- a/node_modules/lodash/array/indexOf.js +++ /dev/null @@ -1,53 +0,0 @@ -var baseIndexOf = require('../internal/baseIndexOf'), - binaryIndex = require('../internal/binaryIndex'); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the offset - * from the end of `array`. If `array` is sorted providing `true` for `fromIndex` - * performs a faster binary search. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {boolean|number} [fromIndex=0] The index to search from or `true` - * to perform a binary search on a sorted array. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.indexOf([1, 2, 1, 2], 2); - * // => 1 - * - * // using `fromIndex` - * _.indexOf([1, 2, 1, 2], 2, 2); - * // => 3 - * - * // performing a binary search - * _.indexOf([1, 1, 2, 2], 2, true); - * // => 2 - */ -function indexOf(array, value, fromIndex) { - var length = array ? array.length : 0; - if (!length) { - return -1; - } - if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; - } else if (fromIndex) { - var index = binaryIndex(array, value); - if (index < length && - (value === value ? (value === array[index]) : (array[index] !== array[index]))) { - return index; - } - return -1; - } - return baseIndexOf(array, value, fromIndex || 0); -} - -module.exports = indexOf; diff --git a/node_modules/lodash/array/initial.js b/node_modules/lodash/array/initial.js deleted file mode 100644 index 59b7a7d96df..00000000000 --- a/node_modules/lodash/array/initial.js +++ /dev/null @@ -1,20 +0,0 @@ -var dropRight = require('./dropRight'); - -/** - * Gets all but the last element of `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.initial([1, 2, 3]); - * // => [1, 2] - */ -function initial(array) { - return dropRight(array, 1); -} - -module.exports = initial; diff --git a/node_modules/lodash/array/intersection.js b/node_modules/lodash/array/intersection.js deleted file mode 100644 index f218432cfb4..00000000000 --- a/node_modules/lodash/array/intersection.js +++ /dev/null @@ -1,58 +0,0 @@ -var baseIndexOf = require('../internal/baseIndexOf'), - cacheIndexOf = require('../internal/cacheIndexOf'), - createCache = require('../internal/createCache'), - isArrayLike = require('../internal/isArrayLike'), - restParam = require('../function/restParam'); - -/** - * Creates an array of unique values that are included in all of the provided - * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of shared values. - * @example - * _.intersection([1, 2], [4, 2], [2, 1]); - * // => [2] - */ -var intersection = restParam(function(arrays) { - var othLength = arrays.length, - othIndex = othLength, - caches = Array(length), - indexOf = baseIndexOf, - isCommon = true, - result = []; - - while (othIndex--) { - var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; - caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null; - } - var array = arrays[0], - index = -1, - length = array ? array.length : 0, - seen = caches[0]; - - outer: - while (++index < length) { - value = array[index]; - if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { - var othIndex = othLength; - while (--othIndex) { - var cache = caches[othIndex]; - if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { - continue outer; - } - } - if (seen) { - seen.push(value); - } - result.push(value); - } - } - return result; -}); - -module.exports = intersection; diff --git a/node_modules/lodash/array/last.js b/node_modules/lodash/array/last.js deleted file mode 100644 index 299af3146ca..00000000000 --- a/node_modules/lodash/array/last.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Gets the last element of `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - */ -function last(array) { - var length = array ? array.length : 0; - return length ? array[length - 1] : undefined; -} - -module.exports = last; diff --git a/node_modules/lodash/array/lastIndexOf.js b/node_modules/lodash/array/lastIndexOf.js deleted file mode 100644 index 02b806269bd..00000000000 --- a/node_modules/lodash/array/lastIndexOf.js +++ /dev/null @@ -1,60 +0,0 @@ -var binaryIndex = require('../internal/binaryIndex'), - indexOfNaN = require('../internal/indexOfNaN'); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max, - nativeMin = Math.min; - -/** - * This method is like `_.indexOf` except that it iterates over elements of - * `array` from right to left. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {boolean|number} [fromIndex=array.length-1] The index to search from - * or `true` to perform a binary search on a sorted array. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.lastIndexOf([1, 2, 1, 2], 2); - * // => 3 - * - * // using `fromIndex` - * _.lastIndexOf([1, 2, 1, 2], 2, 2); - * // => 1 - * - * // performing a binary search - * _.lastIndexOf([1, 1, 2, 2], 2, true); - * // => 3 - */ -function lastIndexOf(array, value, fromIndex) { - var length = array ? array.length : 0; - if (!length) { - return -1; - } - var index = length; - if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; - } else if (fromIndex) { - index = binaryIndex(array, value, true) - 1; - var other = array[index]; - if (value === value ? (value === other) : (other !== other)) { - return index; - } - return -1; - } - if (value !== value) { - return indexOfNaN(array, index, true); - } - while (index--) { - if (array[index] === value) { - return index; - } - } - return -1; -} - -module.exports = lastIndexOf; diff --git a/node_modules/lodash/array/object.js b/node_modules/lodash/array/object.js deleted file mode 100644 index f4a34531b13..00000000000 --- a/node_modules/lodash/array/object.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./zipObject'); diff --git a/node_modules/lodash/array/pull.js b/node_modules/lodash/array/pull.js deleted file mode 100644 index 7bcbb4a63cb..00000000000 --- a/node_modules/lodash/array/pull.js +++ /dev/null @@ -1,52 +0,0 @@ -var baseIndexOf = require('../internal/baseIndexOf'); - -/** Used for native method references. */ -var arrayProto = Array.prototype; - -/** Native method references. */ -var splice = arrayProto.splice; - -/** - * Removes all provided values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `_.without`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {...*} [values] The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3, 1, 2, 3]; - * - * _.pull(array, 2, 3); - * console.log(array); - * // => [1, 1] - */ -function pull() { - var args = arguments, - array = args[0]; - - if (!(array && array.length)) { - return array; - } - var index = 0, - indexOf = baseIndexOf, - length = args.length; - - while (++index < length) { - var fromIndex = 0, - value = args[index]; - - while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { - splice.call(array, fromIndex, 1); - } - } - return array; -} - -module.exports = pull; diff --git a/node_modules/lodash/array/pullAt.js b/node_modules/lodash/array/pullAt.js deleted file mode 100644 index 4ca2476f0e1..00000000000 --- a/node_modules/lodash/array/pullAt.js +++ /dev/null @@ -1,40 +0,0 @@ -var baseAt = require('../internal/baseAt'), - baseCompareAscending = require('../internal/baseCompareAscending'), - baseFlatten = require('../internal/baseFlatten'), - basePullAt = require('../internal/basePullAt'), - restParam = require('../function/restParam'); - -/** - * Removes elements from `array` corresponding to the given indexes and returns - * an array of the removed elements. Indexes may be specified as an array of - * indexes or as individual arguments. - * - * **Note:** Unlike `_.at`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {...(number|number[])} [indexes] The indexes of elements to remove, - * specified as individual indexes or arrays of indexes. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = [5, 10, 15, 20]; - * var evens = _.pullAt(array, 1, 3); - * - * console.log(array); - * // => [5, 15] - * - * console.log(evens); - * // => [10, 20] - */ -var pullAt = restParam(function(array, indexes) { - indexes = baseFlatten(indexes); - - var result = baseAt(array, indexes); - basePullAt(array, indexes.sort(baseCompareAscending)); - return result; -}); - -module.exports = pullAt; diff --git a/node_modules/lodash/array/remove.js b/node_modules/lodash/array/remove.js deleted file mode 100644 index 0cf979bda0b..00000000000 --- a/node_modules/lodash/array/remove.js +++ /dev/null @@ -1,64 +0,0 @@ -var baseCallback = require('../internal/baseCallback'), - basePullAt = require('../internal/basePullAt'); - -/** - * Removes all elements from `array` that `predicate` returns truthy for - * and returns an array of the removed elements. The predicate is bound to - * `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * **Note:** Unlike `_.filter`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(n) { - * return n % 2 == 0; - * }); - * - * console.log(array); - * // => [1, 3] - * - * console.log(evens); - * // => [2, 4] - */ -function remove(array, predicate, thisArg) { - var result = []; - if (!(array && array.length)) { - return result; - } - var index = -1, - indexes = [], - length = array.length; - - predicate = baseCallback(predicate, thisArg, 3); - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result.push(value); - indexes.push(index); - } - } - basePullAt(array, indexes); - return result; -} - -module.exports = remove; diff --git a/node_modules/lodash/array/rest.js b/node_modules/lodash/array/rest.js deleted file mode 100644 index 9bfb734f1fb..00000000000 --- a/node_modules/lodash/array/rest.js +++ /dev/null @@ -1,21 +0,0 @@ -var drop = require('./drop'); - -/** - * Gets all but the first element of `array`. - * - * @static - * @memberOf _ - * @alias tail - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.rest([1, 2, 3]); - * // => [2, 3] - */ -function rest(array) { - return drop(array, 1); -} - -module.exports = rest; diff --git a/node_modules/lodash/array/slice.js b/node_modules/lodash/array/slice.js deleted file mode 100644 index 48ef1a1a280..00000000000 --- a/node_modules/lodash/array/slice.js +++ /dev/null @@ -1,30 +0,0 @@ -var baseSlice = require('../internal/baseSlice'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Creates a slice of `array` from `start` up to, but not including, `end`. - * - * **Note:** This method is used instead of `Array#slice` to support node - * lists in IE < 9 and to ensure dense arrays are returned. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ -function slice(array, start, end) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { - start = 0; - end = length; - } - return baseSlice(array, start, end); -} - -module.exports = slice; diff --git a/node_modules/lodash/array/sortedIndex.js b/node_modules/lodash/array/sortedIndex.js deleted file mode 100644 index 6903bca4370..00000000000 --- a/node_modules/lodash/array/sortedIndex.js +++ /dev/null @@ -1,53 +0,0 @@ -var createSortedIndex = require('../internal/createSortedIndex'); - -/** - * Uses a binary search to determine the lowest index at which `value` should - * be inserted into `array` in order to maintain its sort order. If an iteratee - * function is provided it's invoked for `value` and each element of `array` - * to compute their sort ranking. The iteratee is bound to `thisArg` and - * invoked with one argument; (value). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedIndex([30, 50], 40); - * // => 1 - * - * _.sortedIndex([4, 4, 5, 5], 5); - * // => 2 - * - * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; - * - * // using an iteratee function - * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { - * return this.data[word]; - * }, dict); - * // => 1 - * - * // using the `_.property` callback shorthand - * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); - * // => 1 - */ -var sortedIndex = createSortedIndex(); - -module.exports = sortedIndex; diff --git a/node_modules/lodash/array/sortedLastIndex.js b/node_modules/lodash/array/sortedLastIndex.js deleted file mode 100644 index 81a4a8689e8..00000000000 --- a/node_modules/lodash/array/sortedLastIndex.js +++ /dev/null @@ -1,25 +0,0 @@ -var createSortedIndex = require('../internal/createSortedIndex'); - -/** - * This method is like `_.sortedIndex` except that it returns the highest - * index at which `value` should be inserted into `array` in order to - * maintain its sort order. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedLastIndex([4, 4, 5, 5], 5); - * // => 4 - */ -var sortedLastIndex = createSortedIndex(true); - -module.exports = sortedLastIndex; diff --git a/node_modules/lodash/array/tail.js b/node_modules/lodash/array/tail.js deleted file mode 100644 index c5dfe779d6f..00000000000 --- a/node_modules/lodash/array/tail.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./rest'); diff --git a/node_modules/lodash/array/take.js b/node_modules/lodash/array/take.js deleted file mode 100644 index 875917a7466..00000000000 --- a/node_modules/lodash/array/take.js +++ /dev/null @@ -1,39 +0,0 @@ -var baseSlice = require('../internal/baseSlice'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Creates a slice of `array` with `n` elements taken from the beginning. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.take([1, 2, 3]); - * // => [1] - * - * _.take([1, 2, 3], 2); - * // => [1, 2] - * - * _.take([1, 2, 3], 5); - * // => [1, 2, 3] - * - * _.take([1, 2, 3], 0); - * // => [] - */ -function take(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - return baseSlice(array, 0, n < 0 ? 0 : n); -} - -module.exports = take; diff --git a/node_modules/lodash/array/takeRight.js b/node_modules/lodash/array/takeRight.js deleted file mode 100644 index 6e89c874801..00000000000 --- a/node_modules/lodash/array/takeRight.js +++ /dev/null @@ -1,40 +0,0 @@ -var baseSlice = require('../internal/baseSlice'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Creates a slice of `array` with `n` elements taken from the end. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeRight([1, 2, 3]); - * // => [3] - * - * _.takeRight([1, 2, 3], 2); - * // => [2, 3] - * - * _.takeRight([1, 2, 3], 5); - * // => [1, 2, 3] - * - * _.takeRight([1, 2, 3], 0); - * // => [] - */ -function takeRight(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - n = length - (+n || 0); - return baseSlice(array, n < 0 ? 0 : n); -} - -module.exports = takeRight; diff --git a/node_modules/lodash/array/takeRightWhile.js b/node_modules/lodash/array/takeRightWhile.js deleted file mode 100644 index 5464d13b7fa..00000000000 --- a/node_modules/lodash/array/takeRightWhile.js +++ /dev/null @@ -1,59 +0,0 @@ -var baseCallback = require('../internal/baseCallback'), - baseWhile = require('../internal/baseWhile'); - -/** - * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is bound to `thisArg` - * and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeRightWhile([1, 2, 3], function(n) { - * return n > 1; - * }); - * // => [2, 3] - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); - * // => ['pebbles'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.takeRightWhile(users, 'active', false), 'user'); - * // => ['fred', 'pebbles'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.takeRightWhile(users, 'active'), 'user'); - * // => [] - */ -function takeRightWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, baseCallback(predicate, thisArg, 3), false, true) - : []; -} - -module.exports = takeRightWhile; diff --git a/node_modules/lodash/array/takeWhile.js b/node_modules/lodash/array/takeWhile.js deleted file mode 100644 index f7e28a1d423..00000000000 --- a/node_modules/lodash/array/takeWhile.js +++ /dev/null @@ -1,59 +0,0 @@ -var baseCallback = require('../internal/baseCallback'), - baseWhile = require('../internal/baseWhile'); - -/** - * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until `predicate` returns falsey. The predicate is bound to - * `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeWhile([1, 2, 3], function(n) { - * return n < 3; - * }); - * // => [1, 2] - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false}, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user'); - * // => ['barney'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.takeWhile(users, 'active', false), 'user'); - * // => ['barney', 'fred'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.takeWhile(users, 'active'), 'user'); - * // => [] - */ -function takeWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, baseCallback(predicate, thisArg, 3)) - : []; -} - -module.exports = takeWhile; diff --git a/node_modules/lodash/array/union.js b/node_modules/lodash/array/union.js deleted file mode 100644 index 53cefe432d4..00000000000 --- a/node_modules/lodash/array/union.js +++ /dev/null @@ -1,24 +0,0 @@ -var baseFlatten = require('../internal/baseFlatten'), - baseUniq = require('../internal/baseUniq'), - restParam = require('../function/restParam'); - -/** - * Creates an array of unique values, in order, from all of the provided arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of combined values. - * @example - * - * _.union([1, 2], [4, 2], [2, 1]); - * // => [1, 2, 4] - */ -var union = restParam(function(arrays) { - return baseUniq(baseFlatten(arrays, false, true)); -}); - -module.exports = union; diff --git a/node_modules/lodash/array/uniq.js b/node_modules/lodash/array/uniq.js deleted file mode 100644 index ae937efdf53..00000000000 --- a/node_modules/lodash/array/uniq.js +++ /dev/null @@ -1,71 +0,0 @@ -var baseCallback = require('../internal/baseCallback'), - baseUniq = require('../internal/baseUniq'), - isIterateeCall = require('../internal/isIterateeCall'), - sortedUniq = require('../internal/sortedUniq'); - -/** - * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurence of each element - * is kept. Providing `true` for `isSorted` performs a faster search algorithm - * for sorted arrays. If an iteratee function is provided it's invoked for - * each element in the array to generate the criterion by which uniqueness - * is computed. The `iteratee` is bound to `thisArg` and invoked with three - * arguments: (value, index, array). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias unique - * @category Array - * @param {Array} array The array to inspect. - * @param {boolean} [isSorted] Specify the array is sorted. - * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new duplicate-value-free array. - * @example - * - * _.uniq([2, 1, 2]); - * // => [2, 1] - * - * // using `isSorted` - * _.uniq([1, 1, 2], true); - * // => [1, 2] - * - * // using an iteratee function - * _.uniq([1, 2.5, 1.5, 2], function(n) { - * return this.floor(n); - * }, Math); - * // => [1, 2.5] - * - * // using the `_.property` callback shorthand - * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] - */ -function uniq(array, isSorted, iteratee, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (isSorted != null && typeof isSorted != 'boolean') { - thisArg = iteratee; - iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; - isSorted = false; - } - iteratee = iteratee == null ? iteratee : baseCallback(iteratee, thisArg, 3); - return (isSorted) - ? sortedUniq(array, iteratee) - : baseUniq(array, iteratee); -} - -module.exports = uniq; diff --git a/node_modules/lodash/array/unique.js b/node_modules/lodash/array/unique.js deleted file mode 100644 index 396de1b8046..00000000000 --- a/node_modules/lodash/array/unique.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./uniq'); diff --git a/node_modules/lodash/array/unzip.js b/node_modules/lodash/array/unzip.js deleted file mode 100644 index 0a539fa6315..00000000000 --- a/node_modules/lodash/array/unzip.js +++ /dev/null @@ -1,47 +0,0 @@ -var arrayFilter = require('../internal/arrayFilter'), - arrayMap = require('../internal/arrayMap'), - baseProperty = require('../internal/baseProperty'), - isArrayLike = require('../internal/isArrayLike'); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * This method is like `_.zip` except that it accepts an array of grouped - * elements and creates an array regrouping the elements to their pre-zip - * configuration. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array of grouped elements to process. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]); - * // => [['fred', 30, true], ['barney', 40, false]] - * - * _.unzip(zipped); - * // => [['fred', 'barney'], [30, 40], [true, false]] - */ -function unzip(array) { - if (!(array && array.length)) { - return []; - } - var index = -1, - length = 0; - - array = arrayFilter(array, function(group) { - if (isArrayLike(group)) { - length = nativeMax(group.length, length); - return true; - } - }); - var result = Array(length); - while (++index < length) { - result[index] = arrayMap(array, baseProperty(index)); - } - return result; -} - -module.exports = unzip; diff --git a/node_modules/lodash/array/unzipWith.js b/node_modules/lodash/array/unzipWith.js deleted file mode 100644 index 324a2b1db28..00000000000 --- a/node_modules/lodash/array/unzipWith.js +++ /dev/null @@ -1,41 +0,0 @@ -var arrayMap = require('../internal/arrayMap'), - arrayReduce = require('../internal/arrayReduce'), - bindCallback = require('../internal/bindCallback'), - unzip = require('./unzip'); - -/** - * This method is like `_.unzip` except that it accepts an iteratee to specify - * how regrouped values should be combined. The `iteratee` is bound to `thisArg` - * and invoked with four arguments: (accumulator, value, index, group). - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array of grouped elements to process. - * @param {Function} [iteratee] The function to combine regrouped values. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip([1, 2], [10, 20], [100, 200]); - * // => [[1, 10, 100], [2, 20, 200]] - * - * _.unzipWith(zipped, _.add); - * // => [3, 30, 300] - */ -function unzipWith(array, iteratee, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - var result = unzip(array); - if (iteratee == null) { - return result; - } - iteratee = bindCallback(iteratee, thisArg, 4); - return arrayMap(result, function(group) { - return arrayReduce(group, iteratee, undefined, true); - }); -} - -module.exports = unzipWith; diff --git a/node_modules/lodash/array/without.js b/node_modules/lodash/array/without.js deleted file mode 100644 index 2ac3d1176ee..00000000000 --- a/node_modules/lodash/array/without.js +++ /dev/null @@ -1,27 +0,0 @@ -var baseDifference = require('../internal/baseDifference'), - isArrayLike = require('../internal/isArrayLike'), - restParam = require('../function/restParam'); - -/** - * Creates an array excluding all provided values using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to filter. - * @param {...*} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.without([1, 2, 1, 3], 1, 2); - * // => [3] - */ -var without = restParam(function(array, values) { - return isArrayLike(array) - ? baseDifference(array, values) - : []; -}); - -module.exports = without; diff --git a/node_modules/lodash/array/xor.js b/node_modules/lodash/array/xor.js deleted file mode 100644 index 04ef32aefd9..00000000000 --- a/node_modules/lodash/array/xor.js +++ /dev/null @@ -1,35 +0,0 @@ -var arrayPush = require('../internal/arrayPush'), - baseDifference = require('../internal/baseDifference'), - baseUniq = require('../internal/baseUniq'), - isArrayLike = require('../internal/isArrayLike'); - -/** - * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) - * of the provided arrays. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of values. - * @example - * - * _.xor([1, 2], [4, 2]); - * // => [1, 4] - */ -function xor() { - var index = -1, - length = arguments.length; - - while (++index < length) { - var array = arguments[index]; - if (isArrayLike(array)) { - var result = result - ? arrayPush(baseDifference(result, array), baseDifference(array, result)) - : array; - } - } - return result ? baseUniq(result) : []; -} - -module.exports = xor; diff --git a/node_modules/lodash/array/zip.js b/node_modules/lodash/array/zip.js deleted file mode 100644 index 53a6f699121..00000000000 --- a/node_modules/lodash/array/zip.js +++ /dev/null @@ -1,21 +0,0 @@ -var restParam = require('../function/restParam'), - unzip = require('./unzip'); - -/** - * Creates an array of grouped elements, the first of which contains the first - * elements of the given arrays, the second of which contains the second elements - * of the given arrays, and so on. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @returns {Array} Returns the new array of grouped elements. - * @example - * - * _.zip(['fred', 'barney'], [30, 40], [true, false]); - * // => [['fred', 30, true], ['barney', 40, false]] - */ -var zip = restParam(unzip); - -module.exports = zip; diff --git a/node_modules/lodash/array/zipObject.js b/node_modules/lodash/array/zipObject.js deleted file mode 100644 index dec7a211b74..00000000000 --- a/node_modules/lodash/array/zipObject.js +++ /dev/null @@ -1,43 +0,0 @@ -var isArray = require('../lang/isArray'); - -/** - * The inverse of `_.pairs`; this method returns an object composed from arrays - * of property names and values. Provide either a single two dimensional array, - * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names - * and one of corresponding values. - * - * @static - * @memberOf _ - * @alias object - * @category Array - * @param {Array} props The property names. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @example - * - * _.zipObject([['fred', 30], ['barney', 40]]); - * // => { 'fred': 30, 'barney': 40 } - * - * _.zipObject(['fred', 'barney'], [30, 40]); - * // => { 'fred': 30, 'barney': 40 } - */ -function zipObject(props, values) { - var index = -1, - length = props ? props.length : 0, - result = {}; - - if (length && !values && !isArray(props[0])) { - values = []; - } - while (++index < length) { - var key = props[index]; - if (values) { - result[key] = values[index]; - } else if (key) { - result[key[0]] = key[1]; - } - } - return result; -} - -module.exports = zipObject; diff --git a/node_modules/lodash/array/zipWith.js b/node_modules/lodash/array/zipWith.js deleted file mode 100644 index ad103742cd1..00000000000 --- a/node_modules/lodash/array/zipWith.js +++ /dev/null @@ -1,36 +0,0 @@ -var restParam = require('../function/restParam'), - unzipWith = require('./unzipWith'); - -/** - * This method is like `_.zip` except that it accepts an iteratee to specify - * how grouped values should be combined. The `iteratee` is bound to `thisArg` - * and invoked with four arguments: (accumulator, value, index, group). - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @param {Function} [iteratee] The function to combine grouped values. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new array of grouped elements. - * @example - * - * _.zipWith([1, 2], [10, 20], [100, 200], _.add); - * // => [111, 222] - */ -var zipWith = restParam(function(arrays) { - var length = arrays.length, - iteratee = length > 2 ? arrays[length - 2] : undefined, - thisArg = length > 1 ? arrays[length - 1] : undefined; - - if (length > 2 && typeof iteratee == 'function') { - length -= 2; - } else { - iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined; - thisArg = undefined; - } - arrays.length = length; - return unzipWith(arrays, iteratee, thisArg); -}); - -module.exports = zipWith; diff --git a/node_modules/lodash/chain.js b/node_modules/lodash/chain.js deleted file mode 100644 index 6439627f3d9..00000000000 --- a/node_modules/lodash/chain.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - 'chain': require('./chain/chain'), - 'commit': require('./chain/commit'), - 'concat': require('./chain/concat'), - 'lodash': require('./chain/lodash'), - 'plant': require('./chain/plant'), - 'reverse': require('./chain/reverse'), - 'run': require('./chain/run'), - 'tap': require('./chain/tap'), - 'thru': require('./chain/thru'), - 'toJSON': require('./chain/toJSON'), - 'toString': require('./chain/toString'), - 'value': require('./chain/value'), - 'valueOf': require('./chain/valueOf'), - 'wrapperChain': require('./chain/wrapperChain') -}; diff --git a/node_modules/lodash/chain/chain.js b/node_modules/lodash/chain/chain.js deleted file mode 100644 index 453ba1eb5e8..00000000000 --- a/node_modules/lodash/chain/chain.js +++ /dev/null @@ -1,35 +0,0 @@ -var lodash = require('./lodash'); - -/** - * Creates a `lodash` object that wraps `value` with explicit method - * chaining enabled. - * - * @static - * @memberOf _ - * @category Chain - * @param {*} value The value to wrap. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'pebbles', 'age': 1 } - * ]; - * - * var youngest = _.chain(users) - * .sortBy('age') - * .map(function(chr) { - * return chr.user + ' is ' + chr.age; - * }) - * .first() - * .value(); - * // => 'pebbles is 1' - */ -function chain(value) { - var result = lodash(value); - result.__chain__ = true; - return result; -} - -module.exports = chain; diff --git a/node_modules/lodash/chain/commit.js b/node_modules/lodash/chain/commit.js deleted file mode 100644 index c732d1bf913..00000000000 --- a/node_modules/lodash/chain/commit.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperCommit'); diff --git a/node_modules/lodash/chain/concat.js b/node_modules/lodash/chain/concat.js deleted file mode 100644 index 90607d1ee10..00000000000 --- a/node_modules/lodash/chain/concat.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperConcat'); diff --git a/node_modules/lodash/chain/lodash.js b/node_modules/lodash/chain/lodash.js deleted file mode 100644 index 1c3467efeec..00000000000 --- a/node_modules/lodash/chain/lodash.js +++ /dev/null @@ -1,125 +0,0 @@ -var LazyWrapper = require('../internal/LazyWrapper'), - LodashWrapper = require('../internal/LodashWrapper'), - baseLodash = require('../internal/baseLodash'), - isArray = require('../lang/isArray'), - isObjectLike = require('../internal/isObjectLike'), - wrapperClone = require('../internal/wrapperClone'); - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Creates a `lodash` object which wraps `value` to enable implicit chaining. - * Methods that operate on and return arrays, collections, and functions can - * be chained together. Methods that retrieve a single value or may return a - * primitive value will automatically end the chain returning the unwrapped - * value. Explicit chaining may be enabled using `_.chain`. The execution of - * chained methods is lazy, that is, execution is deferred until `_#value` - * is implicitly or explicitly called. - * - * Lazy evaluation allows several methods to support shortcut fusion. Shortcut - * fusion is an optimization strategy which merge iteratee calls; this can help - * to avoid the creation of intermediate data structures and greatly reduce the - * number of iteratee executions. - * - * Chaining is supported in custom builds as long as the `_#value` method is - * directly or indirectly included in the build. - * - * In addition to lodash methods, wrappers have `Array` and `String` methods. - * - * The wrapper `Array` methods are: - * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, - * `splice`, and `unshift` - * - * The wrapper `String` methods are: - * `replace` and `split` - * - * The wrapper methods that support shortcut fusion are: - * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, - * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, - * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, - * and `where` - * - * The chainable wrapper methods are: - * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, - * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, - * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, - * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`, - * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, - * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, - * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, - * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, - * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`, - * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, - * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, - * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`, - * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, - * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`, - * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, - * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`, - * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith` - * - * The wrapper methods that are **not** chainable by default are: - * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`, - * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, - * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, - * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`, - * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, - * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, - * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, - * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, - * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, - * `unescape`, `uniqueId`, `value`, and `words` - * - * The wrapper method `sample` will return a wrapped value when `n` is provided, - * otherwise an unwrapped value is returned. - * - * @name _ - * @constructor - * @category Chain - * @param {*} value The value to wrap in a `lodash` instance. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var wrapped = _([1, 2, 3]); - * - * // returns an unwrapped value - * wrapped.reduce(function(total, n) { - * return total + n; - * }); - * // => 6 - * - * // returns a wrapped value - * var squares = wrapped.map(function(n) { - * return n * n; - * }); - * - * _.isArray(squares); - * // => false - * - * _.isArray(squares.value()); - * // => true - */ -function lodash(value) { - if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { - if (value instanceof LodashWrapper) { - return value; - } - if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) { - return wrapperClone(value); - } - } - return new LodashWrapper(value); -} - -// Ensure wrappers are instances of `baseLodash`. -lodash.prototype = baseLodash.prototype; - -module.exports = lodash; diff --git a/node_modules/lodash/chain/plant.js b/node_modules/lodash/chain/plant.js deleted file mode 100644 index 04099f23865..00000000000 --- a/node_modules/lodash/chain/plant.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperPlant'); diff --git a/node_modules/lodash/chain/reverse.js b/node_modules/lodash/chain/reverse.js deleted file mode 100644 index f72a64a19b9..00000000000 --- a/node_modules/lodash/chain/reverse.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperReverse'); diff --git a/node_modules/lodash/chain/run.js b/node_modules/lodash/chain/run.js deleted file mode 100644 index 5e751a2c32e..00000000000 --- a/node_modules/lodash/chain/run.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperValue'); diff --git a/node_modules/lodash/chain/tap.js b/node_modules/lodash/chain/tap.js deleted file mode 100644 index 3d0257ecfde..00000000000 --- a/node_modules/lodash/chain/tap.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This method invokes `interceptor` and returns `value`. The interceptor is - * bound to `thisArg` and invoked with one argument; (value). The purpose of - * this method is to "tap into" a method chain in order to perform operations - * on intermediate results within the chain. - * - * @static - * @memberOf _ - * @category Chain - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @param {*} [thisArg] The `this` binding of `interceptor`. - * @returns {*} Returns `value`. - * @example - * - * _([1, 2, 3]) - * .tap(function(array) { - * array.pop(); - * }) - * .reverse() - * .value(); - * // => [2, 1] - */ -function tap(value, interceptor, thisArg) { - interceptor.call(thisArg, value); - return value; -} - -module.exports = tap; diff --git a/node_modules/lodash/chain/thru.js b/node_modules/lodash/chain/thru.js deleted file mode 100644 index a7157803769..00000000000 --- a/node_modules/lodash/chain/thru.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This method is like `_.tap` except that it returns the result of `interceptor`. - * - * @static - * @memberOf _ - * @category Chain - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @param {*} [thisArg] The `this` binding of `interceptor`. - * @returns {*} Returns the result of `interceptor`. - * @example - * - * _(' abc ') - * .chain() - * .trim() - * .thru(function(value) { - * return [value]; - * }) - * .value(); - * // => ['abc'] - */ -function thru(value, interceptor, thisArg) { - return interceptor.call(thisArg, value); -} - -module.exports = thru; diff --git a/node_modules/lodash/chain/toJSON.js b/node_modules/lodash/chain/toJSON.js deleted file mode 100644 index 5e751a2c32e..00000000000 --- a/node_modules/lodash/chain/toJSON.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperValue'); diff --git a/node_modules/lodash/chain/toString.js b/node_modules/lodash/chain/toString.js deleted file mode 100644 index c7bcbf9a543..00000000000 --- a/node_modules/lodash/chain/toString.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperToString'); diff --git a/node_modules/lodash/chain/value.js b/node_modules/lodash/chain/value.js deleted file mode 100644 index 5e751a2c32e..00000000000 --- a/node_modules/lodash/chain/value.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperValue'); diff --git a/node_modules/lodash/chain/valueOf.js b/node_modules/lodash/chain/valueOf.js deleted file mode 100644 index 5e751a2c32e..00000000000 --- a/node_modules/lodash/chain/valueOf.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./wrapperValue'); diff --git a/node_modules/lodash/chain/wrapperChain.js b/node_modules/lodash/chain/wrapperChain.js deleted file mode 100644 index 38234819ba0..00000000000 --- a/node_modules/lodash/chain/wrapperChain.js +++ /dev/null @@ -1,32 +0,0 @@ -var chain = require('./chain'); - -/** - * Enables explicit method chaining on the wrapper object. - * - * @name chain - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * // without explicit chaining - * _(users).first(); - * // => { 'user': 'barney', 'age': 36 } - * - * // with explicit chaining - * _(users).chain() - * .first() - * .pick('user') - * .value(); - * // => { 'user': 'barney' } - */ -function wrapperChain() { - return chain(this); -} - -module.exports = wrapperChain; diff --git a/node_modules/lodash/chain/wrapperCommit.js b/node_modules/lodash/chain/wrapperCommit.js deleted file mode 100644 index c3d289804bd..00000000000 --- a/node_modules/lodash/chain/wrapperCommit.js +++ /dev/null @@ -1,32 +0,0 @@ -var LodashWrapper = require('../internal/LodashWrapper'); - -/** - * Executes the chained sequence and returns the wrapped result. - * - * @name commit - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2]; - * var wrapped = _(array).push(3); - * - * console.log(array); - * // => [1, 2] - * - * wrapped = wrapped.commit(); - * console.log(array); - * // => [1, 2, 3] - * - * wrapped.last(); - * // => 3 - * - * console.log(array); - * // => [1, 2, 3] - */ -function wrapperCommit() { - return new LodashWrapper(this.value(), this.__chain__); -} - -module.exports = wrapperCommit; diff --git a/node_modules/lodash/chain/wrapperConcat.js b/node_modules/lodash/chain/wrapperConcat.js deleted file mode 100644 index 799156cd836..00000000000 --- a/node_modules/lodash/chain/wrapperConcat.js +++ /dev/null @@ -1,34 +0,0 @@ -var arrayConcat = require('../internal/arrayConcat'), - baseFlatten = require('../internal/baseFlatten'), - isArray = require('../lang/isArray'), - restParam = require('../function/restParam'), - toObject = require('../internal/toObject'); - -/** - * Creates a new array joining a wrapped array with any additional arrays - * and/or values. - * - * @name concat - * @memberOf _ - * @category Chain - * @param {...*} [values] The values to concatenate. - * @returns {Array} Returns the new concatenated array. - * @example - * - * var array = [1]; - * var wrapped = _(array).concat(2, [3], [[4]]); - * - * console.log(wrapped.value()); - * // => [1, 2, 3, [4]] - * - * console.log(array); - * // => [1] - */ -var wrapperConcat = restParam(function(values) { - values = baseFlatten(values); - return this.thru(function(array) { - return arrayConcat(isArray(array) ? array : [toObject(array)], values); - }); -}); - -module.exports = wrapperConcat; diff --git a/node_modules/lodash/chain/wrapperPlant.js b/node_modules/lodash/chain/wrapperPlant.js deleted file mode 100644 index 234fe41fec4..00000000000 --- a/node_modules/lodash/chain/wrapperPlant.js +++ /dev/null @@ -1,45 +0,0 @@ -var baseLodash = require('../internal/baseLodash'), - wrapperClone = require('../internal/wrapperClone'); - -/** - * Creates a clone of the chained sequence planting `value` as the wrapped value. - * - * @name plant - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2]; - * var wrapped = _(array).map(function(value) { - * return Math.pow(value, 2); - * }); - * - * var other = [3, 4]; - * var otherWrapped = wrapped.plant(other); - * - * otherWrapped.value(); - * // => [9, 16] - * - * wrapped.value(); - * // => [1, 4] - */ -function wrapperPlant(value) { - var result, - parent = this; - - while (parent instanceof baseLodash) { - var clone = wrapperClone(parent); - if (result) { - previous.__wrapped__ = clone; - } else { - result = clone; - } - var previous = clone; - parent = parent.__wrapped__; - } - previous.__wrapped__ = value; - return result; -} - -module.exports = wrapperPlant; diff --git a/node_modules/lodash/chain/wrapperReverse.js b/node_modules/lodash/chain/wrapperReverse.js deleted file mode 100644 index 6ba546de4ee..00000000000 --- a/node_modules/lodash/chain/wrapperReverse.js +++ /dev/null @@ -1,43 +0,0 @@ -var LazyWrapper = require('../internal/LazyWrapper'), - LodashWrapper = require('../internal/LodashWrapper'), - thru = require('./thru'); - -/** - * Reverses the wrapped array so the first element becomes the last, the - * second element becomes the second to last, and so on. - * - * **Note:** This method mutates the wrapped array. - * - * @name reverse - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new reversed `lodash` wrapper instance. - * @example - * - * var array = [1, 2, 3]; - * - * _(array).reverse().value() - * // => [3, 2, 1] - * - * console.log(array); - * // => [3, 2, 1] - */ -function wrapperReverse() { - var value = this.__wrapped__; - - var interceptor = function(value) { - return value.reverse(); - }; - if (value instanceof LazyWrapper) { - var wrapped = value; - if (this.__actions__.length) { - wrapped = new LazyWrapper(this); - } - wrapped = wrapped.reverse(); - wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); - return new LodashWrapper(wrapped, this.__chain__); - } - return this.thru(interceptor); -} - -module.exports = wrapperReverse; diff --git a/node_modules/lodash/chain/wrapperToString.js b/node_modules/lodash/chain/wrapperToString.js deleted file mode 100644 index db975a5a354..00000000000 --- a/node_modules/lodash/chain/wrapperToString.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Produces the result of coercing the unwrapped value to a string. - * - * @name toString - * @memberOf _ - * @category Chain - * @returns {string} Returns the coerced string value. - * @example - * - * _([1, 2, 3]).toString(); - * // => '1,2,3' - */ -function wrapperToString() { - return (this.value() + ''); -} - -module.exports = wrapperToString; diff --git a/node_modules/lodash/chain/wrapperValue.js b/node_modules/lodash/chain/wrapperValue.js deleted file mode 100644 index 2734e41c4a9..00000000000 --- a/node_modules/lodash/chain/wrapperValue.js +++ /dev/null @@ -1,20 +0,0 @@ -var baseWrapperValue = require('../internal/baseWrapperValue'); - -/** - * Executes the chained sequence to extract the unwrapped value. - * - * @name value - * @memberOf _ - * @alias run, toJSON, valueOf - * @category Chain - * @returns {*} Returns the resolved unwrapped value. - * @example - * - * _([1, 2, 3]).value(); - * // => [1, 2, 3] - */ -function wrapperValue() { - return baseWrapperValue(this.__wrapped__, this.__actions__); -} - -module.exports = wrapperValue; diff --git a/node_modules/lodash/collection.js b/node_modules/lodash/collection.js deleted file mode 100644 index 03388571c31..00000000000 --- a/node_modules/lodash/collection.js +++ /dev/null @@ -1,44 +0,0 @@ -module.exports = { - 'all': require('./collection/all'), - 'any': require('./collection/any'), - 'at': require('./collection/at'), - 'collect': require('./collection/collect'), - 'contains': require('./collection/contains'), - 'countBy': require('./collection/countBy'), - 'detect': require('./collection/detect'), - 'each': require('./collection/each'), - 'eachRight': require('./collection/eachRight'), - 'every': require('./collection/every'), - 'filter': require('./collection/filter'), - 'find': require('./collection/find'), - 'findLast': require('./collection/findLast'), - 'findWhere': require('./collection/findWhere'), - 'foldl': require('./collection/foldl'), - 'foldr': require('./collection/foldr'), - 'forEach': require('./collection/forEach'), - 'forEachRight': require('./collection/forEachRight'), - 'groupBy': require('./collection/groupBy'), - 'include': require('./collection/include'), - 'includes': require('./collection/includes'), - 'indexBy': require('./collection/indexBy'), - 'inject': require('./collection/inject'), - 'invoke': require('./collection/invoke'), - 'map': require('./collection/map'), - 'max': require('./math/max'), - 'min': require('./math/min'), - 'partition': require('./collection/partition'), - 'pluck': require('./collection/pluck'), - 'reduce': require('./collection/reduce'), - 'reduceRight': require('./collection/reduceRight'), - 'reject': require('./collection/reject'), - 'sample': require('./collection/sample'), - 'select': require('./collection/select'), - 'shuffle': require('./collection/shuffle'), - 'size': require('./collection/size'), - 'some': require('./collection/some'), - 'sortBy': require('./collection/sortBy'), - 'sortByAll': require('./collection/sortByAll'), - 'sortByOrder': require('./collection/sortByOrder'), - 'sum': require('./math/sum'), - 'where': require('./collection/where') -}; diff --git a/node_modules/lodash/collection/all.js b/node_modules/lodash/collection/all.js deleted file mode 100644 index d0839f77ed7..00000000000 --- a/node_modules/lodash/collection/all.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./every'); diff --git a/node_modules/lodash/collection/any.js b/node_modules/lodash/collection/any.js deleted file mode 100644 index 900ac25e836..00000000000 --- a/node_modules/lodash/collection/any.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./some'); diff --git a/node_modules/lodash/collection/at.js b/node_modules/lodash/collection/at.js deleted file mode 100644 index 29236e577df..00000000000 --- a/node_modules/lodash/collection/at.js +++ /dev/null @@ -1,29 +0,0 @@ -var baseAt = require('../internal/baseAt'), - baseFlatten = require('../internal/baseFlatten'), - restParam = require('../function/restParam'); - -/** - * Creates an array of elements corresponding to the given keys, or indexes, - * of `collection`. Keys may be specified as individual arguments or as arrays - * of keys. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {...(number|number[]|string|string[])} [props] The property names - * or indexes of elements to pick, specified individually or in arrays. - * @returns {Array} Returns the new array of picked elements. - * @example - * - * _.at(['a', 'b', 'c'], [0, 2]); - * // => ['a', 'c'] - * - * _.at(['barney', 'fred', 'pebbles'], 0, 2); - * // => ['barney', 'pebbles'] - */ -var at = restParam(function(collection, props) { - return baseAt(collection, baseFlatten(props)); -}); - -module.exports = at; diff --git a/node_modules/lodash/collection/collect.js b/node_modules/lodash/collection/collect.js deleted file mode 100644 index 0d1e1abfaf9..00000000000 --- a/node_modules/lodash/collection/collect.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./map'); diff --git a/node_modules/lodash/collection/contains.js b/node_modules/lodash/collection/contains.js deleted file mode 100644 index 594722af59a..00000000000 --- a/node_modules/lodash/collection/contains.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./includes'); diff --git a/node_modules/lodash/collection/countBy.js b/node_modules/lodash/collection/countBy.js deleted file mode 100644 index e97dbb749d1..00000000000 --- a/node_modules/lodash/collection/countBy.js +++ /dev/null @@ -1,54 +0,0 @@ -var createAggregator = require('../internal/createAggregator'); - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding value - * of each key is the number of times the key was returned by `iteratee`. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.countBy([4.3, 6.1, 6.4], function(n) { - * return Math.floor(n); - * }); - * // => { '4': 1, '6': 2 } - * - * _.countBy([4.3, 6.1, 6.4], function(n) { - * return this.floor(n); - * }, Math); - * // => { '4': 1, '6': 2 } - * - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } - */ -var countBy = createAggregator(function(result, value, key) { - hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1); -}); - -module.exports = countBy; diff --git a/node_modules/lodash/collection/detect.js b/node_modules/lodash/collection/detect.js deleted file mode 100644 index 2fb6303efb4..00000000000 --- a/node_modules/lodash/collection/detect.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./find'); diff --git a/node_modules/lodash/collection/each.js b/node_modules/lodash/collection/each.js deleted file mode 100644 index 8800f42046e..00000000000 --- a/node_modules/lodash/collection/each.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./forEach'); diff --git a/node_modules/lodash/collection/eachRight.js b/node_modules/lodash/collection/eachRight.js deleted file mode 100644 index 3252b2aba32..00000000000 --- a/node_modules/lodash/collection/eachRight.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./forEachRight'); diff --git a/node_modules/lodash/collection/every.js b/node_modules/lodash/collection/every.js deleted file mode 100644 index 5a2d0f5dd44..00000000000 --- a/node_modules/lodash/collection/every.js +++ /dev/null @@ -1,66 +0,0 @@ -var arrayEvery = require('../internal/arrayEvery'), - baseCallback = require('../internal/baseCallback'), - baseEvery = require('../internal/baseEvery'), - isArray = require('../lang/isArray'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Checks if `predicate` returns truthy for **all** elements of `collection`. - * The predicate is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias all - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes'], Boolean); - * // => false - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.every(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // using the `_.matchesProperty` callback shorthand - * _.every(users, 'active', false); - * // => true - * - * // using the `_.property` callback shorthand - * _.every(users, 'active'); - * // => false - */ -function every(collection, predicate, thisArg) { - var func = isArray(collection) ? arrayEvery : baseEvery; - if (thisArg && isIterateeCall(collection, predicate, thisArg)) { - predicate = undefined; - } - if (typeof predicate != 'function' || thisArg !== undefined) { - predicate = baseCallback(predicate, thisArg, 3); - } - return func(collection, predicate); -} - -module.exports = every; diff --git a/node_modules/lodash/collection/filter.js b/node_modules/lodash/collection/filter.js deleted file mode 100644 index 7620aa76195..00000000000 --- a/node_modules/lodash/collection/filter.js +++ /dev/null @@ -1,61 +0,0 @@ -var arrayFilter = require('../internal/arrayFilter'), - baseCallback = require('../internal/baseCallback'), - baseFilter = require('../internal/baseFilter'), - isArray = require('../lang/isArray'); - -/** - * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is bound to `thisArg` and - * invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias select - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the new filtered array. - * @example - * - * _.filter([4, 5, 6], function(n) { - * return n % 2 == 0; - * }); - * // => [4, 6] - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); - * // => ['barney'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.filter(users, 'active', false), 'user'); - * // => ['fred'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.filter(users, 'active'), 'user'); - * // => ['barney'] - */ -function filter(collection, predicate, thisArg) { - var func = isArray(collection) ? arrayFilter : baseFilter; - predicate = baseCallback(predicate, thisArg, 3); - return func(collection, predicate); -} - -module.exports = filter; diff --git a/node_modules/lodash/collection/find.js b/node_modules/lodash/collection/find.js deleted file mode 100644 index 7358cfe86cb..00000000000 --- a/node_modules/lodash/collection/find.js +++ /dev/null @@ -1,56 +0,0 @@ -var baseEach = require('../internal/baseEach'), - createFind = require('../internal/createFind'); - -/** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is bound to `thisArg` and - * invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias detect - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ]; - * - * _.result(_.find(users, function(chr) { - * return chr.age < 40; - * }), 'user'); - * // => 'barney' - * - * // using the `_.matches` callback shorthand - * _.result(_.find(users, { 'age': 1, 'active': true }), 'user'); - * // => 'pebbles' - * - * // using the `_.matchesProperty` callback shorthand - * _.result(_.find(users, 'active', false), 'user'); - * // => 'fred' - * - * // using the `_.property` callback shorthand - * _.result(_.find(users, 'active'), 'user'); - * // => 'barney' - */ -var find = createFind(baseEach); - -module.exports = find; diff --git a/node_modules/lodash/collection/findLast.js b/node_modules/lodash/collection/findLast.js deleted file mode 100644 index 75dbadca240..00000000000 --- a/node_modules/lodash/collection/findLast.js +++ /dev/null @@ -1,25 +0,0 @@ -var baseEachRight = require('../internal/baseEachRight'), - createFind = require('../internal/createFind'); - -/** - * This method is like `_.find` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * _.findLast([1, 2, 3, 4], function(n) { - * return n % 2 == 1; - * }); - * // => 3 - */ -var findLast = createFind(baseEachRight, true); - -module.exports = findLast; diff --git a/node_modules/lodash/collection/findWhere.js b/node_modules/lodash/collection/findWhere.js deleted file mode 100644 index 2d620655ed4..00000000000 --- a/node_modules/lodash/collection/findWhere.js +++ /dev/null @@ -1,37 +0,0 @@ -var baseMatches = require('../internal/baseMatches'), - find = require('./find'); - -/** - * Performs a deep comparison between each element in `collection` and the - * source object, returning the first element that has equivalent property - * values. - * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own, not inherited, enumerable properties. For comparing a single - * own or inherited property value see `_.matchesProperty`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Object} source The object of property values to match. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user'); - * // => 'barney' - * - * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); - * // => 'fred' - */ -function findWhere(collection, source) { - return find(collection, baseMatches(source)); -} - -module.exports = findWhere; diff --git a/node_modules/lodash/collection/foldl.js b/node_modules/lodash/collection/foldl.js deleted file mode 100644 index 26f53cf7b26..00000000000 --- a/node_modules/lodash/collection/foldl.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./reduce'); diff --git a/node_modules/lodash/collection/foldr.js b/node_modules/lodash/collection/foldr.js deleted file mode 100644 index 8fb199eda60..00000000000 --- a/node_modules/lodash/collection/foldr.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./reduceRight'); diff --git a/node_modules/lodash/collection/forEach.js b/node_modules/lodash/collection/forEach.js deleted file mode 100644 index 05a8e2140eb..00000000000 --- a/node_modules/lodash/collection/forEach.js +++ /dev/null @@ -1,37 +0,0 @@ -var arrayEach = require('../internal/arrayEach'), - baseEach = require('../internal/baseEach'), - createForEach = require('../internal/createForEach'); - -/** - * Iterates over elements of `collection` invoking `iteratee` for each element. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). Iteratee functions may exit iteration early - * by explicitly returning `false`. - * - * **Note:** As with other "Collections" methods, objects with a "length" property - * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` - * may be used for object iteration. - * - * @static - * @memberOf _ - * @alias each - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2]).forEach(function(n) { - * console.log(n); - * }).value(); - * // => logs each value from left to right and returns the array - * - * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { - * console.log(n, key); - * }); - * // => logs each value-key pair and returns the object (iteration order is not guaranteed) - */ -var forEach = createForEach(arrayEach, baseEach); - -module.exports = forEach; diff --git a/node_modules/lodash/collection/forEachRight.js b/node_modules/lodash/collection/forEachRight.js deleted file mode 100644 index 34997110024..00000000000 --- a/node_modules/lodash/collection/forEachRight.js +++ /dev/null @@ -1,26 +0,0 @@ -var arrayEachRight = require('../internal/arrayEachRight'), - baseEachRight = require('../internal/baseEachRight'), - createForEach = require('../internal/createForEach'); - -/** - * This method is like `_.forEach` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @alias eachRight - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2]).forEachRight(function(n) { - * console.log(n); - * }).value(); - * // => logs each value from right to left and returns the array - */ -var forEachRight = createForEach(arrayEachRight, baseEachRight); - -module.exports = forEachRight; diff --git a/node_modules/lodash/collection/groupBy.js b/node_modules/lodash/collection/groupBy.js deleted file mode 100644 index a925c894a0d..00000000000 --- a/node_modules/lodash/collection/groupBy.js +++ /dev/null @@ -1,59 +0,0 @@ -var createAggregator = require('../internal/createAggregator'); - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding value - * of each key is an array of the elements responsible for generating the key. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.groupBy([4.2, 6.1, 6.4], function(n) { - * return Math.floor(n); - * }); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * _.groupBy([4.2, 6.1, 6.4], function(n) { - * return this.floor(n); - * }, Math); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * // using the `_.property` callback shorthand - * _.groupBy(['one', 'two', 'three'], 'length'); - * // => { '3': ['one', 'two'], '5': ['three'] } - */ -var groupBy = createAggregator(function(result, value, key) { - if (hasOwnProperty.call(result, key)) { - result[key].push(value); - } else { - result[key] = [value]; - } -}); - -module.exports = groupBy; diff --git a/node_modules/lodash/collection/include.js b/node_modules/lodash/collection/include.js deleted file mode 100644 index 594722af59a..00000000000 --- a/node_modules/lodash/collection/include.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./includes'); diff --git a/node_modules/lodash/collection/includes.js b/node_modules/lodash/collection/includes.js deleted file mode 100644 index 329486a530f..00000000000 --- a/node_modules/lodash/collection/includes.js +++ /dev/null @@ -1,57 +0,0 @@ -var baseIndexOf = require('../internal/baseIndexOf'), - getLength = require('../internal/getLength'), - isArray = require('../lang/isArray'), - isIterateeCall = require('../internal/isIterateeCall'), - isLength = require('../internal/isLength'), - isString = require('../lang/isString'), - values = require('../object/values'); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * Checks if `target` is in `collection` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the offset - * from the end of `collection`. - * - * @static - * @memberOf _ - * @alias contains, include - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {*} target The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. - * @returns {boolean} Returns `true` if a matching element is found, else `false`. - * @example - * - * _.includes([1, 2, 3], 1); - * // => true - * - * _.includes([1, 2, 3], 1, 2); - * // => false - * - * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); - * // => true - * - * _.includes('pebbles', 'eb'); - * // => true - */ -function includes(collection, target, fromIndex, guard) { - var length = collection ? getLength(collection) : 0; - if (!isLength(length)) { - collection = values(collection); - length = collection.length; - } - if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) { - fromIndex = 0; - } else { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); - } - return (typeof collection == 'string' || !isArray(collection) && isString(collection)) - ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) - : (!!length && baseIndexOf(collection, target, fromIndex) > -1); -} - -module.exports = includes; diff --git a/node_modules/lodash/collection/indexBy.js b/node_modules/lodash/collection/indexBy.js deleted file mode 100644 index 34a941e7290..00000000000 --- a/node_modules/lodash/collection/indexBy.js +++ /dev/null @@ -1,53 +0,0 @@ -var createAggregator = require('../internal/createAggregator'); - -/** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding value - * of each key is the last element responsible for generating the key. The - * iteratee function is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * var keyData = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ]; - * - * _.indexBy(keyData, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(keyData, function(object) { - * return String.fromCharCode(object.code); - * }); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(keyData, function(object) { - * return this.fromCharCode(object.code); - * }, String); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - */ -var indexBy = createAggregator(function(result, value, key) { - result[key] = value; -}); - -module.exports = indexBy; diff --git a/node_modules/lodash/collection/inject.js b/node_modules/lodash/collection/inject.js deleted file mode 100644 index 26f53cf7b26..00000000000 --- a/node_modules/lodash/collection/inject.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./reduce'); diff --git a/node_modules/lodash/collection/invoke.js b/node_modules/lodash/collection/invoke.js deleted file mode 100644 index 6e717219573..00000000000 --- a/node_modules/lodash/collection/invoke.js +++ /dev/null @@ -1,42 +0,0 @@ -var baseEach = require('../internal/baseEach'), - invokePath = require('../internal/invokePath'), - isArrayLike = require('../internal/isArrayLike'), - isKey = require('../internal/isKey'), - restParam = require('../function/restParam'); - -/** - * Invokes the method at `path` of each element in `collection`, returning - * an array of the results of each invoked method. Any additional arguments - * are provided to each invoked method. If `methodName` is a function it's - * invoked for, and `this` bound to, each element in `collection`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|string} path The path of the method to invoke or - * the function invoked per iteration. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {Array} Returns the array of results. - * @example - * - * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); - * // => [[1, 5, 7], [1, 2, 3]] - * - * _.invoke([123, 456], String.prototype.split, ''); - * // => [['1', '2', '3'], ['4', '5', '6']] - */ -var invoke = restParam(function(collection, path, args) { - var index = -1, - isFunc = typeof path == 'function', - isProp = isKey(path), - result = isArrayLike(collection) ? Array(collection.length) : []; - - baseEach(collection, function(value) { - var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined); - result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); - }); - return result; -}); - -module.exports = invoke; diff --git a/node_modules/lodash/collection/map.js b/node_modules/lodash/collection/map.js deleted file mode 100644 index 5381110df12..00000000000 --- a/node_modules/lodash/collection/map.js +++ /dev/null @@ -1,68 +0,0 @@ -var arrayMap = require('../internal/arrayMap'), - baseCallback = require('../internal/baseCallback'), - baseMap = require('../internal/baseMap'), - isArray = require('../lang/isArray'); - -/** - * Creates an array of values by running each element in `collection` through - * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three - * arguments: (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. - * - * The guarded methods are: - * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, - * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, - * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, - * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, - * `sum`, `uniq`, and `words` - * - * @static - * @memberOf _ - * @alias collect - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new mapped array. - * @example - * - * function timesThree(n) { - * return n * 3; - * } - * - * _.map([1, 2], timesThree); - * // => [3, 6] - * - * _.map({ 'a': 1, 'b': 2 }, timesThree); - * // => [3, 6] (iteration order is not guaranteed) - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; - * - * // using the `_.property` callback shorthand - * _.map(users, 'user'); - * // => ['barney', 'fred'] - */ -function map(collection, iteratee, thisArg) { - var func = isArray(collection) ? arrayMap : baseMap; - iteratee = baseCallback(iteratee, thisArg, 3); - return func(collection, iteratee); -} - -module.exports = map; diff --git a/node_modules/lodash/collection/max.js b/node_modules/lodash/collection/max.js deleted file mode 100644 index bb1d213c33b..00000000000 --- a/node_modules/lodash/collection/max.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../math/max'); diff --git a/node_modules/lodash/collection/min.js b/node_modules/lodash/collection/min.js deleted file mode 100644 index eef13d02b8a..00000000000 --- a/node_modules/lodash/collection/min.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../math/min'); diff --git a/node_modules/lodash/collection/partition.js b/node_modules/lodash/collection/partition.js deleted file mode 100644 index ee35f27d930..00000000000 --- a/node_modules/lodash/collection/partition.js +++ /dev/null @@ -1,66 +0,0 @@ -var createAggregator = require('../internal/createAggregator'); - -/** - * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, while the second of which - * contains elements `predicate` returns falsey for. The predicate is bound - * to `thisArg` and invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the array of grouped elements. - * @example - * - * _.partition([1, 2, 3], function(n) { - * return n % 2; - * }); - * // => [[1, 3], [2]] - * - * _.partition([1.2, 2.3, 3.4], function(n) { - * return this.floor(n) % 2; - * }, Math); - * // => [[1.2, 3.4], [2.3]] - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } - * ]; - * - * var mapper = function(array) { - * return _.pluck(array, 'user'); - * }; - * - * // using the `_.matches` callback shorthand - * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); - * // => [['pebbles'], ['barney', 'fred']] - * - * // using the `_.matchesProperty` callback shorthand - * _.map(_.partition(users, 'active', false), mapper); - * // => [['barney', 'pebbles'], ['fred']] - * - * // using the `_.property` callback shorthand - * _.map(_.partition(users, 'active'), mapper); - * // => [['fred'], ['barney', 'pebbles']] - */ -var partition = createAggregator(function(result, value, key) { - result[key ? 0 : 1].push(value); -}, function() { return [[], []]; }); - -module.exports = partition; diff --git a/node_modules/lodash/collection/pluck.js b/node_modules/lodash/collection/pluck.js deleted file mode 100644 index 5ee1ec84eec..00000000000 --- a/node_modules/lodash/collection/pluck.js +++ /dev/null @@ -1,31 +0,0 @@ -var map = require('./map'), - property = require('../utility/property'); - -/** - * Gets the property value of `path` from all elements in `collection`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|string} path The path of the property to pluck. - * @returns {Array} Returns the property values. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * _.pluck(users, 'user'); - * // => ['barney', 'fred'] - * - * var userIndex = _.indexBy(users, 'user'); - * _.pluck(userIndex, 'age'); - * // => [36, 40] (iteration order is not guaranteed) - */ -function pluck(collection, path) { - return map(collection, property(path)); -} - -module.exports = pluck; diff --git a/node_modules/lodash/collection/reduce.js b/node_modules/lodash/collection/reduce.js deleted file mode 100644 index 5d5e8c91691..00000000000 --- a/node_modules/lodash/collection/reduce.js +++ /dev/null @@ -1,44 +0,0 @@ -var arrayReduce = require('../internal/arrayReduce'), - baseEach = require('../internal/baseEach'), - createReduce = require('../internal/createReduce'); - -/** - * Reduces `collection` to a value which is the accumulated result of running - * each element in `collection` through `iteratee`, where each successive - * invocation is supplied the return value of the previous. If `accumulator` - * is not provided the first element of `collection` is used as the initial - * value. The `iteratee` is bound to `thisArg` and invoked with four arguments: - * (accumulator, value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.reduce`, `_.reduceRight`, and `_.transform`. - * - * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`, - * and `sortByOrder` - * - * @static - * @memberOf _ - * @alias foldl, inject - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the accumulated value. - * @example - * - * _.reduce([1, 2], function(total, n) { - * return total + n; - * }); - * // => 3 - * - * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { - * result[key] = n * 3; - * return result; - * }, {}); - * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) - */ -var reduce = createReduce(arrayReduce, baseEach); - -module.exports = reduce; diff --git a/node_modules/lodash/collection/reduceRight.js b/node_modules/lodash/collection/reduceRight.js deleted file mode 100644 index 5a5753b9c21..00000000000 --- a/node_modules/lodash/collection/reduceRight.js +++ /dev/null @@ -1,29 +0,0 @@ -var arrayReduceRight = require('../internal/arrayReduceRight'), - baseEachRight = require('../internal/baseEachRight'), - createReduce = require('../internal/createReduce'); - -/** - * This method is like `_.reduce` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @alias foldr - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the accumulated value. - * @example - * - * var array = [[0, 1], [2, 3], [4, 5]]; - * - * _.reduceRight(array, function(flattened, other) { - * return flattened.concat(other); - * }, []); - * // => [4, 5, 2, 3, 0, 1] - */ -var reduceRight = createReduce(arrayReduceRight, baseEachRight); - -module.exports = reduceRight; diff --git a/node_modules/lodash/collection/reject.js b/node_modules/lodash/collection/reject.js deleted file mode 100644 index 55924539b52..00000000000 --- a/node_modules/lodash/collection/reject.js +++ /dev/null @@ -1,50 +0,0 @@ -var arrayFilter = require('../internal/arrayFilter'), - baseCallback = require('../internal/baseCallback'), - baseFilter = require('../internal/baseFilter'), - isArray = require('../lang/isArray'); - -/** - * The opposite of `_.filter`; this method returns the elements of `collection` - * that `predicate` does **not** return truthy for. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the new filtered array. - * @example - * - * _.reject([1, 2, 3, 4], function(n) { - * return n % 2 == 0; - * }); - * // => [1, 3] - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user'); - * // => ['barney'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.reject(users, 'active', false), 'user'); - * // => ['fred'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.reject(users, 'active'), 'user'); - * // => ['barney'] - */ -function reject(collection, predicate, thisArg) { - var func = isArray(collection) ? arrayFilter : baseFilter; - predicate = baseCallback(predicate, thisArg, 3); - return func(collection, function(value, index, collection) { - return !predicate(value, index, collection); - }); -} - -module.exports = reject; diff --git a/node_modules/lodash/collection/sample.js b/node_modules/lodash/collection/sample.js deleted file mode 100644 index 8e015330162..00000000000 --- a/node_modules/lodash/collection/sample.js +++ /dev/null @@ -1,50 +0,0 @@ -var baseRandom = require('../internal/baseRandom'), - isIterateeCall = require('../internal/isIterateeCall'), - toArray = require('../lang/toArray'), - toIterable = require('../internal/toIterable'); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMin = Math.min; - -/** - * Gets a random element or `n` random elements from a collection. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to sample. - * @param {number} [n] The number of elements to sample. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {*} Returns the random sample(s). - * @example - * - * _.sample([1, 2, 3, 4]); - * // => 2 - * - * _.sample([1, 2, 3, 4], 2); - * // => [3, 1] - */ -function sample(collection, n, guard) { - if (guard ? isIterateeCall(collection, n, guard) : n == null) { - collection = toIterable(collection); - var length = collection.length; - return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; - } - var index = -1, - result = toArray(collection), - length = result.length, - lastIndex = length - 1; - - n = nativeMin(n < 0 ? 0 : (+n || 0), length); - while (++index < n) { - var rand = baseRandom(index, lastIndex), - value = result[rand]; - - result[rand] = result[index]; - result[index] = value; - } - result.length = n; - return result; -} - -module.exports = sample; diff --git a/node_modules/lodash/collection/select.js b/node_modules/lodash/collection/select.js deleted file mode 100644 index ade80f6fbae..00000000000 --- a/node_modules/lodash/collection/select.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./filter'); diff --git a/node_modules/lodash/collection/shuffle.js b/node_modules/lodash/collection/shuffle.js deleted file mode 100644 index 949689c5fc7..00000000000 --- a/node_modules/lodash/collection/shuffle.js +++ /dev/null @@ -1,24 +0,0 @@ -var sample = require('./sample'); - -/** Used as references for `-Infinity` and `Infinity`. */ -var POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - -/** - * Creates an array of shuffled values, using a version of the - * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. - * @example - * - * _.shuffle([1, 2, 3, 4]); - * // => [4, 1, 3, 2] - */ -function shuffle(collection) { - return sample(collection, POSITIVE_INFINITY); -} - -module.exports = shuffle; diff --git a/node_modules/lodash/collection/size.js b/node_modules/lodash/collection/size.js deleted file mode 100644 index 78dcf4ce9be..00000000000 --- a/node_modules/lodash/collection/size.js +++ /dev/null @@ -1,30 +0,0 @@ -var getLength = require('../internal/getLength'), - isLength = require('../internal/isLength'), - keys = require('../object/keys'); - -/** - * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable properties for objects. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns the size of `collection`. - * @example - * - * _.size([1, 2, 3]); - * // => 3 - * - * _.size({ 'a': 1, 'b': 2 }); - * // => 2 - * - * _.size('pebbles'); - * // => 7 - */ -function size(collection) { - var length = collection ? getLength(collection) : 0; - return isLength(length) ? length : keys(collection).length; -} - -module.exports = size; diff --git a/node_modules/lodash/collection/some.js b/node_modules/lodash/collection/some.js deleted file mode 100644 index d0b09a47469..00000000000 --- a/node_modules/lodash/collection/some.js +++ /dev/null @@ -1,67 +0,0 @@ -var arraySome = require('../internal/arraySome'), - baseCallback = require('../internal/baseCallback'), - baseSome = require('../internal/baseSome'), - isArray = require('../lang/isArray'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Checks if `predicate` returns truthy for **any** element of `collection`. - * The function returns as soon as it finds a passing value and does not iterate - * over the entire collection. The predicate is bound to `thisArg` and invoked - * with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias any - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - * @example - * - * _.some([null, 0, 'yes', false], Boolean); - * // => true - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.some(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // using the `_.matchesProperty` callback shorthand - * _.some(users, 'active', false); - * // => true - * - * // using the `_.property` callback shorthand - * _.some(users, 'active'); - * // => true - */ -function some(collection, predicate, thisArg) { - var func = isArray(collection) ? arraySome : baseSome; - if (thisArg && isIterateeCall(collection, predicate, thisArg)) { - predicate = undefined; - } - if (typeof predicate != 'function' || thisArg !== undefined) { - predicate = baseCallback(predicate, thisArg, 3); - } - return func(collection, predicate); -} - -module.exports = some; diff --git a/node_modules/lodash/collection/sortBy.js b/node_modules/lodash/collection/sortBy.js deleted file mode 100644 index 4401c777f40..00000000000 --- a/node_modules/lodash/collection/sortBy.js +++ /dev/null @@ -1,71 +0,0 @@ -var baseCallback = require('../internal/baseCallback'), - baseMap = require('../internal/baseMap'), - baseSortBy = require('../internal/baseSortBy'), - compareAscending = require('../internal/compareAscending'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through `iteratee`. This method performs - * a stable sort, that is, it preserves the original sort order of equal elements. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new sorted array. - * @example - * - * _.sortBy([1, 2, 3], function(n) { - * return Math.sin(n); - * }); - * // => [3, 1, 2] - * - * _.sortBy([1, 2, 3], function(n) { - * return this.sin(n); - * }, Math); - * // => [3, 1, 2] - * - * var users = [ - * { 'user': 'fred' }, - * { 'user': 'pebbles' }, - * { 'user': 'barney' } - * ]; - * - * // using the `_.property` callback shorthand - * _.pluck(_.sortBy(users, 'user'), 'user'); - * // => ['barney', 'fred', 'pebbles'] - */ -function sortBy(collection, iteratee, thisArg) { - if (collection == null) { - return []; - } - if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { - iteratee = undefined; - } - var index = -1; - iteratee = baseCallback(iteratee, thisArg, 3); - - var result = baseMap(collection, function(value, key, collection) { - return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value }; - }); - return baseSortBy(result, compareAscending); -} - -module.exports = sortBy; diff --git a/node_modules/lodash/collection/sortByAll.js b/node_modules/lodash/collection/sortByAll.js deleted file mode 100644 index 4766c209855..00000000000 --- a/node_modules/lodash/collection/sortByAll.js +++ /dev/null @@ -1,52 +0,0 @@ -var baseFlatten = require('../internal/baseFlatten'), - baseSortByOrder = require('../internal/baseSortByOrder'), - isIterateeCall = require('../internal/isIterateeCall'), - restParam = require('../function/restParam'); - -/** - * This method is like `_.sortBy` except that it can sort by multiple iteratees - * or property names. - * - * If a property name is provided for an iteratee the created `_.property` - * style callback returns the property value of the given element. - * - * If an object is provided for an iteratee the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {...(Function|Function[]|Object|Object[]|string|string[])} iteratees - * The iteratees to sort by, specified as individual values or arrays of values. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 42 }, - * { 'user': 'barney', 'age': 34 } - * ]; - * - * _.map(_.sortByAll(users, ['user', 'age']), _.values); - * // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] - * - * _.map(_.sortByAll(users, 'user', function(chr) { - * return Math.floor(chr.age / 10); - * }), _.values); - * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - */ -var sortByAll = restParam(function(collection, iteratees) { - if (collection == null) { - return []; - } - var guard = iteratees[2]; - if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) { - iteratees.length = 1; - } - return baseSortByOrder(collection, baseFlatten(iteratees), []); -}); - -module.exports = sortByAll; diff --git a/node_modules/lodash/collection/sortByOrder.js b/node_modules/lodash/collection/sortByOrder.js deleted file mode 100644 index 8b4fc196877..00000000000 --- a/node_modules/lodash/collection/sortByOrder.js +++ /dev/null @@ -1,55 +0,0 @@ -var baseSortByOrder = require('../internal/baseSortByOrder'), - isArray = require('../lang/isArray'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** - * This method is like `_.sortByAll` except that it allows specifying the - * sort orders of the iteratees to sort by. If `orders` is unspecified, all - * values are sorted in ascending order. Otherwise, a value is sorted in - * ascending order if its corresponding order is "asc", and descending if "desc". - * - * If a property name is provided for an iteratee the created `_.property` - * style callback returns the property value of the given element. - * - * If an object is provided for an iteratee the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {boolean[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 42 }, - * { 'user': 'barney', 'age': 36 } - * ]; - * - * // sort by `user` in ascending order and by `age` in descending order - * _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values); - * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - */ -function sortByOrder(collection, iteratees, orders, guard) { - if (collection == null) { - return []; - } - if (guard && isIterateeCall(iteratees, orders, guard)) { - orders = undefined; - } - if (!isArray(iteratees)) { - iteratees = iteratees == null ? [] : [iteratees]; - } - if (!isArray(orders)) { - orders = orders == null ? [] : [orders]; - } - return baseSortByOrder(collection, iteratees, orders); -} - -module.exports = sortByOrder; diff --git a/node_modules/lodash/collection/sum.js b/node_modules/lodash/collection/sum.js deleted file mode 100644 index a2e93808ae8..00000000000 --- a/node_modules/lodash/collection/sum.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../math/sum'); diff --git a/node_modules/lodash/collection/where.js b/node_modules/lodash/collection/where.js deleted file mode 100644 index f603bf8ce49..00000000000 --- a/node_modules/lodash/collection/where.js +++ /dev/null @@ -1,37 +0,0 @@ -var baseMatches = require('../internal/baseMatches'), - filter = require('./filter'); - -/** - * Performs a deep comparison between each element in `collection` and the - * source object, returning an array of all elements that have equivalent - * property values. - * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own, not inherited, enumerable properties. For comparing a single - * own or inherited property value see `_.matchesProperty`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Object} source The object of property values to match. - * @returns {Array} Returns the new filtered array. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, - * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } - * ]; - * - * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); - * // => ['barney'] - * - * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); - * // => ['fred'] - */ -function where(collection, source) { - return filter(collection, baseMatches(source)); -} - -module.exports = where; diff --git a/node_modules/lodash/date.js b/node_modules/lodash/date.js deleted file mode 100644 index 195366e7776..00000000000 --- a/node_modules/lodash/date.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - 'now': require('./date/now') -}; diff --git a/node_modules/lodash/date/now.js b/node_modules/lodash/date/now.js deleted file mode 100644 index ffe3060e5b9..00000000000 --- a/node_modules/lodash/date/now.js +++ /dev/null @@ -1,24 +0,0 @@ -var getNative = require('../internal/getNative'); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeNow = getNative(Date, 'now'); - -/** - * Gets the number of milliseconds that have elapsed since the Unix epoch - * (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @category Date - * @example - * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => logs the number of milliseconds it took for the deferred function to be invoked - */ -var now = nativeNow || function() { - return new Date().getTime(); -}; - -module.exports = now; diff --git a/node_modules/lodash/function.js b/node_modules/lodash/function.js deleted file mode 100644 index 71f8ebeb27d..00000000000 --- a/node_modules/lodash/function.js +++ /dev/null @@ -1,28 +0,0 @@ -module.exports = { - 'after': require('./function/after'), - 'ary': require('./function/ary'), - 'backflow': require('./function/backflow'), - 'before': require('./function/before'), - 'bind': require('./function/bind'), - 'bindAll': require('./function/bindAll'), - 'bindKey': require('./function/bindKey'), - 'compose': require('./function/compose'), - 'curry': require('./function/curry'), - 'curryRight': require('./function/curryRight'), - 'debounce': require('./function/debounce'), - 'defer': require('./function/defer'), - 'delay': require('./function/delay'), - 'flow': require('./function/flow'), - 'flowRight': require('./function/flowRight'), - 'memoize': require('./function/memoize'), - 'modArgs': require('./function/modArgs'), - 'negate': require('./function/negate'), - 'once': require('./function/once'), - 'partial': require('./function/partial'), - 'partialRight': require('./function/partialRight'), - 'rearg': require('./function/rearg'), - 'restParam': require('./function/restParam'), - 'spread': require('./function/spread'), - 'throttle': require('./function/throttle'), - 'wrap': require('./function/wrap') -}; diff --git a/node_modules/lodash/function/after.js b/node_modules/lodash/function/after.js deleted file mode 100644 index 96a51fdbcf7..00000000000 --- a/node_modules/lodash/function/after.js +++ /dev/null @@ -1,48 +0,0 @@ -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeIsFinite = global.isFinite; - -/** - * The opposite of `_.before`; this method creates a function that invokes - * `func` once it's called `n` or more times. - * - * @static - * @memberOf _ - * @category Function - * @param {number} n The number of calls before `func` is invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var saves = ['profile', 'settings']; - * - * var done = _.after(saves.length, function() { - * console.log('done saving!'); - * }); - * - * _.forEach(saves, function(type) { - * asyncSave({ 'type': type, 'complete': done }); - * }); - * // => logs 'done saving!' after the two async saves have completed - */ -function after(n, func) { - if (typeof func != 'function') { - if (typeof n == 'function') { - var temp = n; - n = func; - func = temp; - } else { - throw new TypeError(FUNC_ERROR_TEXT); - } - } - n = nativeIsFinite(n = +n) ? n : 0; - return function() { - if (--n < 1) { - return func.apply(this, arguments); - } - }; -} - -module.exports = after; diff --git a/node_modules/lodash/function/ary.js b/node_modules/lodash/function/ary.js deleted file mode 100644 index 53a6913e3f1..00000000000 --- a/node_modules/lodash/function/ary.js +++ /dev/null @@ -1,34 +0,0 @@ -var createWrapper = require('../internal/createWrapper'), - isIterateeCall = require('../internal/isIterateeCall'); - -/** Used to compose bitmasks for wrapper metadata. */ -var ARY_FLAG = 128; - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * Creates a function that accepts up to `n` arguments ignoring any - * additional arguments. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to cap arguments for. - * @param {number} [n=func.length] The arity cap. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new function. - * @example - * - * _.map(['6', '8', '10'], _.ary(parseInt, 1)); - * // => [6, 8, 10] - */ -function ary(func, n, guard) { - if (guard && isIterateeCall(func, n, guard)) { - n = undefined; - } - n = (func && n == null) ? func.length : nativeMax(+n || 0, 0); - return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); -} - -module.exports = ary; diff --git a/node_modules/lodash/function/backflow.js b/node_modules/lodash/function/backflow.js deleted file mode 100644 index 1954e942397..00000000000 --- a/node_modules/lodash/function/backflow.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./flowRight'); diff --git a/node_modules/lodash/function/before.js b/node_modules/lodash/function/before.js deleted file mode 100644 index 3d942168255..00000000000 --- a/node_modules/lodash/function/before.js +++ /dev/null @@ -1,42 +0,0 @@ -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** - * Creates a function that invokes `func`, with the `this` binding and arguments - * of the created function, while it's called less than `n` times. Subsequent - * calls to the created function return the result of the last `func` invocation. - * - * @static - * @memberOf _ - * @category Function - * @param {number} n The number of calls at which `func` is no longer invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * jQuery('#add').on('click', _.before(5, addContactToList)); - * // => allows adding up to 4 contacts to the list - */ -function before(n, func) { - var result; - if (typeof func != 'function') { - if (typeof n == 'function') { - var temp = n; - n = func; - func = temp; - } else { - throw new TypeError(FUNC_ERROR_TEXT); - } - } - return function() { - if (--n > 0) { - result = func.apply(this, arguments); - } - if (n <= 1) { - func = undefined; - } - return result; - }; -} - -module.exports = before; diff --git a/node_modules/lodash/function/bind.js b/node_modules/lodash/function/bind.js deleted file mode 100644 index 0de126ae359..00000000000 --- a/node_modules/lodash/function/bind.js +++ /dev/null @@ -1,56 +0,0 @@ -var createWrapper = require('../internal/createWrapper'), - replaceHolders = require('../internal/replaceHolders'), - restParam = require('./restParam'); - -/** Used to compose bitmasks for wrapper metadata. */ -var BIND_FLAG = 1, - PARTIAL_FLAG = 32; - -/** - * Creates a function that invokes `func` with the `this` binding of `thisArg` - * and prepends any additional `_.bind` arguments to those provided to the - * bound function. - * - * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for partially applied arguments. - * - * **Note:** Unlike native `Function#bind` this method does not set the "length" - * property of bound functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var greet = function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * }; - * - * var object = { 'user': 'fred' }; - * - * var bound = _.bind(greet, object, 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * // using placeholders - * var bound = _.bind(greet, object, _, '!'); - * bound('hi'); - * // => 'hi fred!' - */ -var bind = restParam(function(func, thisArg, partials) { - var bitmask = BIND_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, bind.placeholder); - bitmask |= PARTIAL_FLAG; - } - return createWrapper(func, bitmask, thisArg, partials, holders); -}); - -// Assign default placeholders. -bind.placeholder = {}; - -module.exports = bind; diff --git a/node_modules/lodash/function/bindAll.js b/node_modules/lodash/function/bindAll.js deleted file mode 100644 index a09e9485248..00000000000 --- a/node_modules/lodash/function/bindAll.js +++ /dev/null @@ -1,50 +0,0 @@ -var baseFlatten = require('../internal/baseFlatten'), - createWrapper = require('../internal/createWrapper'), - functions = require('../object/functions'), - restParam = require('./restParam'); - -/** Used to compose bitmasks for wrapper metadata. */ -var BIND_FLAG = 1; - -/** - * Binds methods of an object to the object itself, overwriting the existing - * method. Method names may be specified as individual arguments or as arrays - * of method names. If no method names are provided all enumerable function - * properties, own and inherited, of `object` are bound. - * - * **Note:** This method does not set the "length" property of bound functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Object} object The object to bind and assign the bound methods to. - * @param {...(string|string[])} [methodNames] The object method names to bind, - * specified as individual method names or arrays of method names. - * @returns {Object} Returns `object`. - * @example - * - * var view = { - * 'label': 'docs', - * 'onClick': function() { - * console.log('clicked ' + this.label); - * } - * }; - * - * _.bindAll(view); - * jQuery('#docs').on('click', view.onClick); - * // => logs 'clicked docs' when the element is clicked - */ -var bindAll = restParam(function(object, methodNames) { - methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); - - var index = -1, - length = methodNames.length; - - while (++index < length) { - var key = methodNames[index]; - object[key] = createWrapper(object[key], BIND_FLAG, object); - } - return object; -}); - -module.exports = bindAll; diff --git a/node_modules/lodash/function/bindKey.js b/node_modules/lodash/function/bindKey.js deleted file mode 100644 index b787fe70227..00000000000 --- a/node_modules/lodash/function/bindKey.js +++ /dev/null @@ -1,66 +0,0 @@ -var createWrapper = require('../internal/createWrapper'), - replaceHolders = require('../internal/replaceHolders'), - restParam = require('./restParam'); - -/** Used to compose bitmasks for wrapper metadata. */ -var BIND_FLAG = 1, - BIND_KEY_FLAG = 2, - PARTIAL_FLAG = 32; - -/** - * Creates a function that invokes the method at `object[key]` and prepends - * any additional `_.bindKey` arguments to those provided to the bound function. - * - * This method differs from `_.bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. - * See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) - * for more details. - * - * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * @static - * @memberOf _ - * @category Function - * @param {Object} object The object the method belongs to. - * @param {string} key The key of the method. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var object = { - * 'user': 'fred', - * 'greet': function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * }; - * - * var bound = _.bindKey(object, 'greet', 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * object.greet = function(greeting, punctuation) { - * return greeting + 'ya ' + this.user + punctuation; - * }; - * - * bound('!'); - * // => 'hiya fred!' - * - * // using placeholders - * var bound = _.bindKey(object, 'greet', _, '!'); - * bound('hi'); - * // => 'hiya fred!' - */ -var bindKey = restParam(function(object, key, partials) { - var bitmask = BIND_FLAG | BIND_KEY_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, bindKey.placeholder); - bitmask |= PARTIAL_FLAG; - } - return createWrapper(key, bitmask, object, partials, holders); -}); - -// Assign default placeholders. -bindKey.placeholder = {}; - -module.exports = bindKey; diff --git a/node_modules/lodash/function/compose.js b/node_modules/lodash/function/compose.js deleted file mode 100644 index 1954e942397..00000000000 --- a/node_modules/lodash/function/compose.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./flowRight'); diff --git a/node_modules/lodash/function/curry.js b/node_modules/lodash/function/curry.js deleted file mode 100644 index b7db3fdad8a..00000000000 --- a/node_modules/lodash/function/curry.js +++ /dev/null @@ -1,51 +0,0 @@ -var createCurry = require('../internal/createCurry'); - -/** Used to compose bitmasks for wrapper metadata. */ -var CURRY_FLAG = 8; - -/** - * Creates a function that accepts one or more arguments of `func` that when - * called either invokes `func` returning its result, if all `func` arguments - * have been provided, or returns a function that accepts one or more of the - * remaining `func` arguments, and so on. The arity of `func` may be specified - * if `func.length` is not sufficient. - * - * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for provided arguments. - * - * **Note:** This method does not set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curry(abc); - * - * curried(1)(2)(3); - * // => [1, 2, 3] - * - * curried(1, 2)(3); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] - * - * // using placeholders - * curried(1)(_, 3)(2); - * // => [1, 2, 3] - */ -var curry = createCurry(CURRY_FLAG); - -// Assign default placeholders. -curry.placeholder = {}; - -module.exports = curry; diff --git a/node_modules/lodash/function/curryRight.js b/node_modules/lodash/function/curryRight.js deleted file mode 100644 index 11c540393b3..00000000000 --- a/node_modules/lodash/function/curryRight.js +++ /dev/null @@ -1,48 +0,0 @@ -var createCurry = require('../internal/createCurry'); - -/** Used to compose bitmasks for wrapper metadata. */ -var CURRY_RIGHT_FLAG = 16; - -/** - * This method is like `_.curry` except that arguments are applied to `func` - * in the manner of `_.partialRight` instead of `_.partial`. - * - * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for provided arguments. - * - * **Note:** This method does not set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curryRight(abc); - * - * curried(3)(2)(1); - * // => [1, 2, 3] - * - * curried(2, 3)(1); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] - * - * // using placeholders - * curried(3)(1, _)(2); - * // => [1, 2, 3] - */ -var curryRight = createCurry(CURRY_RIGHT_FLAG); - -// Assign default placeholders. -curryRight.placeholder = {}; - -module.exports = curryRight; diff --git a/node_modules/lodash/function/debounce.js b/node_modules/lodash/function/debounce.js deleted file mode 100644 index 163af90f38a..00000000000 --- a/node_modules/lodash/function/debounce.js +++ /dev/null @@ -1,181 +0,0 @@ -var isObject = require('../lang/isObject'), - now = require('../date/now'); - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * Creates a debounced function that delays invoking `func` until after `wait` - * milliseconds have elapsed since the last time the debounced function was - * invoked. The debounced function comes with a `cancel` method to cancel - * delayed invocations. Provide an options object to indicate that `func` - * should be invoked on the leading and/or trailing edge of the `wait` timeout. - * Subsequent calls to the debounced function return the result of the last - * `func` invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked - * on the trailing edge of the timeout only if the the debounced function is - * invoked more than once during the `wait` timeout. - * - * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) - * for details over the differences between `_.debounce` and `_.throttle`. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to debounce. - * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=false] Specify invoking on the leading - * edge of the timeout. - * @param {number} [options.maxWait] The maximum time `func` is allowed to be - * delayed before it's invoked. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example - * - * // avoid costly calculations while the window size is in flux - * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); - * - * // invoke `sendMail` when the click event is fired, debouncing subsequent calls - * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * })); - * - * // ensure `batchLog` is invoked once after 1 second of debounced calls - * var source = new EventSource('/stream'); - * jQuery(source).on('message', _.debounce(batchLog, 250, { - * 'maxWait': 1000 - * })); - * - * // cancel a debounced call - * var todoChanges = _.debounce(batchLog, 1000); - * Object.observe(models.todo, todoChanges); - * - * Object.observe(models, function(changes) { - * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) { - * todoChanges.cancel(); - * } - * }, ['delete']); - * - * // ...at some point `models.todo` is changed - * models.todo.completed = true; - * - * // ...before 1 second has passed `models.todo` is deleted - * // which cancels the debounced `todoChanges` call - * delete models.todo; - */ -function debounce(func, wait, options) { - var args, - maxTimeoutId, - result, - stamp, - thisArg, - timeoutId, - trailingCall, - lastCalled = 0, - maxWait = false, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - wait = wait < 0 ? 0 : (+wait || 0); - if (options === true) { - var leading = true; - trailing = false; - } else if (isObject(options)) { - leading = !!options.leading; - maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait); - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - - function cancel() { - if (timeoutId) { - clearTimeout(timeoutId); - } - if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - } - lastCalled = 0; - maxTimeoutId = timeoutId = trailingCall = undefined; - } - - function complete(isCalled, id) { - if (id) { - clearTimeout(id); - } - maxTimeoutId = timeoutId = trailingCall = undefined; - if (isCalled) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = undefined; - } - } - } - - function delayed() { - var remaining = wait - (now() - stamp); - if (remaining <= 0 || remaining > wait) { - complete(trailingCall, maxTimeoutId); - } else { - timeoutId = setTimeout(delayed, remaining); - } - } - - function maxDelayed() { - complete(trailing, timeoutId); - } - - function debounced() { - args = arguments; - stamp = now(); - thisArg = this; - trailingCall = trailing && (timeoutId || !leading); - - if (maxWait === false) { - var leadingCall = leading && !timeoutId; - } else { - if (!maxTimeoutId && !leading) { - lastCalled = stamp; - } - var remaining = maxWait - (stamp - lastCalled), - isCalled = remaining <= 0 || remaining > maxWait; - - if (isCalled) { - if (maxTimeoutId) { - maxTimeoutId = clearTimeout(maxTimeoutId); - } - lastCalled = stamp; - result = func.apply(thisArg, args); - } - else if (!maxTimeoutId) { - maxTimeoutId = setTimeout(maxDelayed, remaining); - } - } - if (isCalled && timeoutId) { - timeoutId = clearTimeout(timeoutId); - } - else if (!timeoutId && wait !== maxWait) { - timeoutId = setTimeout(delayed, wait); - } - if (leadingCall) { - isCalled = true; - result = func.apply(thisArg, args); - } - if (isCalled && !timeoutId && !maxTimeoutId) { - args = thisArg = undefined; - } - return result; - } - debounced.cancel = cancel; - return debounced; -} - -module.exports = debounce; diff --git a/node_modules/lodash/function/defer.js b/node_modules/lodash/function/defer.js deleted file mode 100644 index 3accbf9b109..00000000000 --- a/node_modules/lodash/function/defer.js +++ /dev/null @@ -1,25 +0,0 @@ -var baseDelay = require('../internal/baseDelay'), - restParam = require('./restParam'); - -/** - * Defers invoking the `func` until the current call stack has cleared. Any - * additional arguments are provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to defer. - * @param {...*} [args] The arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.defer(function(text) { - * console.log(text); - * }, 'deferred'); - * // logs 'deferred' after one or more milliseconds - */ -var defer = restParam(function(func, args) { - return baseDelay(func, 1, args); -}); - -module.exports = defer; diff --git a/node_modules/lodash/function/delay.js b/node_modules/lodash/function/delay.js deleted file mode 100644 index d5eef27a9f3..00000000000 --- a/node_modules/lodash/function/delay.js +++ /dev/null @@ -1,26 +0,0 @@ -var baseDelay = require('../internal/baseDelay'), - restParam = require('./restParam'); - -/** - * Invokes `func` after `wait` milliseconds. Any additional arguments are - * provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {...*} [args] The arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.delay(function(text) { - * console.log(text); - * }, 1000, 'later'); - * // => logs 'later' after one second - */ -var delay = restParam(function(func, wait, args) { - return baseDelay(func, wait, args); -}); - -module.exports = delay; diff --git a/node_modules/lodash/function/flow.js b/node_modules/lodash/function/flow.js deleted file mode 100644 index a435a3d878f..00000000000 --- a/node_modules/lodash/function/flow.js +++ /dev/null @@ -1,25 +0,0 @@ -var createFlow = require('../internal/createFlow'); - -/** - * Creates a function that returns the result of invoking the provided - * functions with the `this` binding of the created function, where each - * successive invocation is supplied the return value of the previous. - * - * @static - * @memberOf _ - * @category Function - * @param {...Function} [funcs] Functions to invoke. - * @returns {Function} Returns the new function. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var addSquare = _.flow(_.add, square); - * addSquare(1, 2); - * // => 9 - */ -var flow = createFlow(); - -module.exports = flow; diff --git a/node_modules/lodash/function/flowRight.js b/node_modules/lodash/function/flowRight.js deleted file mode 100644 index 23b9d76b58e..00000000000 --- a/node_modules/lodash/function/flowRight.js +++ /dev/null @@ -1,25 +0,0 @@ -var createFlow = require('../internal/createFlow'); - -/** - * This method is like `_.flow` except that it creates a function that - * invokes the provided functions from right to left. - * - * @static - * @memberOf _ - * @alias backflow, compose - * @category Function - * @param {...Function} [funcs] Functions to invoke. - * @returns {Function} Returns the new function. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var addSquare = _.flowRight(square, _.add); - * addSquare(1, 2); - * // => 9 - */ -var flowRight = createFlow(true); - -module.exports = flowRight; diff --git a/node_modules/lodash/function/memoize.js b/node_modules/lodash/function/memoize.js deleted file mode 100644 index f3b8d699209..00000000000 --- a/node_modules/lodash/function/memoize.js +++ /dev/null @@ -1,80 +0,0 @@ -var MapCache = require('../internal/MapCache'); - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is coerced to a string and used as the - * cache key. The `func` is invoked with the `this` binding of the memoized - * function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) - * method interface of `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoizing function. - * @example - * - * var upperCase = _.memoize(function(string) { - * return string.toUpperCase(); - * }); - * - * upperCase('fred'); - * // => 'FRED' - * - * // modifying the result cache - * upperCase.cache.set('fred', 'BARNEY'); - * upperCase('fred'); - * // => 'BARNEY' - * - * // replacing `_.memoize.Cache` - * var object = { 'user': 'fred' }; - * var other = { 'user': 'barney' }; - * var identity = _.memoize(_.identity); - * - * identity(object); - * // => { 'user': 'fred' } - * identity(other); - * // => { 'user': 'fred' } - * - * _.memoize.Cache = WeakMap; - * var identity = _.memoize(_.identity); - * - * identity(object); - * // => { 'user': 'fred' } - * identity(other); - * // => { 'user': 'barney' } - */ -function memoize(func, resolver) { - if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; - - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result); - return result; - }; - memoized.cache = new memoize.Cache; - return memoized; -} - -// Assign cache to `_.memoize`. -memoize.Cache = MapCache; - -module.exports = memoize; diff --git a/node_modules/lodash/function/modArgs.js b/node_modules/lodash/function/modArgs.js deleted file mode 100644 index 49b9b5e6828..00000000000 --- a/node_modules/lodash/function/modArgs.js +++ /dev/null @@ -1,58 +0,0 @@ -var arrayEvery = require('../internal/arrayEvery'), - baseFlatten = require('../internal/baseFlatten'), - baseIsFunction = require('../internal/baseIsFunction'), - restParam = require('./restParam'); - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMin = Math.min; - -/** - * Creates a function that runs each argument through a corresponding - * transform function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms] The functions to transform - * arguments, specified as individual functions or arrays of functions. - * @returns {Function} Returns the new function. - * @example - * - * function doubled(n) { - * return n * 2; - * } - * - * function square(n) { - * return n * n; - * } - * - * var modded = _.modArgs(function(x, y) { - * return [x, y]; - * }, square, doubled); - * - * modded(1, 2); - * // => [1, 4] - * - * modded(5, 10); - * // => [25, 20] - */ -var modArgs = restParam(function(func, transforms) { - transforms = baseFlatten(transforms); - if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var length = transforms.length; - return restParam(function(args) { - var index = nativeMin(args.length, length); - while (index--) { - args[index] = transforms[index](args[index]); - } - return func.apply(this, args); - }); -}); - -module.exports = modArgs; diff --git a/node_modules/lodash/function/negate.js b/node_modules/lodash/function/negate.js deleted file mode 100644 index 82479390ad7..00000000000 --- a/node_modules/lodash/function/negate.js +++ /dev/null @@ -1,32 +0,0 @@ -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** - * Creates a function that negates the result of the predicate `func`. The - * `func` predicate is invoked with the `this` binding and arguments of the - * created function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} predicate The predicate to negate. - * @returns {Function} Returns the new function. - * @example - * - * function isEven(n) { - * return n % 2 == 0; - * } - * - * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); - * // => [1, 3, 5] - */ -function negate(predicate) { - if (typeof predicate != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - return !predicate.apply(this, arguments); - }; -} - -module.exports = negate; diff --git a/node_modules/lodash/function/once.js b/node_modules/lodash/function/once.js deleted file mode 100644 index 0b5bd853cb4..00000000000 --- a/node_modules/lodash/function/once.js +++ /dev/null @@ -1,24 +0,0 @@ -var before = require('./before'); - -/** - * Creates a function that is restricted to invoking `func` once. Repeat calls - * to the function return the value of the first call. The `func` is invoked - * with the `this` binding and arguments of the created function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var initialize = _.once(createApplication); - * initialize(); - * initialize(); - * // `initialize` invokes `createApplication` once - */ -function once(func) { - return before(2, func); -} - -module.exports = once; diff --git a/node_modules/lodash/function/partial.js b/node_modules/lodash/function/partial.js deleted file mode 100644 index fb1d04fb6c5..00000000000 --- a/node_modules/lodash/function/partial.js +++ /dev/null @@ -1,43 +0,0 @@ -var createPartial = require('../internal/createPartial'); - -/** Used to compose bitmasks for wrapper metadata. */ -var PARTIAL_FLAG = 32; - -/** - * Creates a function that invokes `func` with `partial` arguments prepended - * to those provided to the new function. This method is like `_.bind` except - * it does **not** alter the `this` binding. - * - * The `_.partial.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method does not set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var greet = function(greeting, name) { - * return greeting + ' ' + name; - * }; - * - * var sayHelloTo = _.partial(greet, 'hello'); - * sayHelloTo('fred'); - * // => 'hello fred' - * - * // using placeholders - * var greetFred = _.partial(greet, _, 'fred'); - * greetFred('hi'); - * // => 'hi fred' - */ -var partial = createPartial(PARTIAL_FLAG); - -// Assign default placeholders. -partial.placeholder = {}; - -module.exports = partial; diff --git a/node_modules/lodash/function/partialRight.js b/node_modules/lodash/function/partialRight.js deleted file mode 100644 index 634e6a4c40c..00000000000 --- a/node_modules/lodash/function/partialRight.js +++ /dev/null @@ -1,42 +0,0 @@ -var createPartial = require('../internal/createPartial'); - -/** Used to compose bitmasks for wrapper metadata. */ -var PARTIAL_RIGHT_FLAG = 64; - -/** - * This method is like `_.partial` except that partially applied arguments - * are appended to those provided to the new function. - * - * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method does not set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var greet = function(greeting, name) { - * return greeting + ' ' + name; - * }; - * - * var greetFred = _.partialRight(greet, 'fred'); - * greetFred('hi'); - * // => 'hi fred' - * - * // using placeholders - * var sayHelloTo = _.partialRight(greet, 'hello', _); - * sayHelloTo('fred'); - * // => 'hello fred' - */ -var partialRight = createPartial(PARTIAL_RIGHT_FLAG); - -// Assign default placeholders. -partialRight.placeholder = {}; - -module.exports = partialRight; diff --git a/node_modules/lodash/function/rearg.js b/node_modules/lodash/function/rearg.js deleted file mode 100644 index f2bd9c41ec2..00000000000 --- a/node_modules/lodash/function/rearg.js +++ /dev/null @@ -1,40 +0,0 @@ -var baseFlatten = require('../internal/baseFlatten'), - createWrapper = require('../internal/createWrapper'), - restParam = require('./restParam'); - -/** Used to compose bitmasks for wrapper metadata. */ -var REARG_FLAG = 256; - -/** - * Creates a function that invokes `func` with arguments arranged according - * to the specified indexes where the argument value at the first index is - * provided as the first argument, the argument value at the second index is - * provided as the second argument, and so on. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to rearrange arguments for. - * @param {...(number|number[])} indexes The arranged argument indexes, - * specified as individual indexes or arrays of indexes. - * @returns {Function} Returns the new function. - * @example - * - * var rearged = _.rearg(function(a, b, c) { - * return [a, b, c]; - * }, 2, 0, 1); - * - * rearged('b', 'c', 'a') - * // => ['a', 'b', 'c'] - * - * var map = _.rearg(_.map, [1, 0]); - * map(function(n) { - * return n * 3; - * }, [1, 2, 3]); - * // => [3, 6, 9] - */ -var rearg = restParam(function(func, indexes) { - return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); -}); - -module.exports = rearg; diff --git a/node_modules/lodash/function/restParam.js b/node_modules/lodash/function/restParam.js deleted file mode 100644 index 8852286dd5b..00000000000 --- a/node_modules/lodash/function/restParam.js +++ /dev/null @@ -1,58 +0,0 @@ -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as an array. - * - * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters). - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.restParam(function(what, names) { - * return what + ' ' + _.initial(names).join(', ') + - * (_.size(names) > 1 ? ', & ' : '') + _.last(names); - * }); - * - * say('hello', 'fred', 'barney', 'pebbles'); - * // => 'hello fred, barney, & pebbles' - */ -function restParam(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - rest = Array(length); - - while (++index < length) { - rest[index] = args[start + index]; - } - switch (start) { - case 0: return func.call(this, rest); - case 1: return func.call(this, args[0], rest); - case 2: return func.call(this, args[0], args[1], rest); - } - var otherArgs = Array(start + 1); - index = -1; - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = rest; - return func.apply(this, otherArgs); - }; -} - -module.exports = restParam; diff --git a/node_modules/lodash/function/spread.js b/node_modules/lodash/function/spread.js deleted file mode 100644 index 780f5042ad5..00000000000 --- a/node_modules/lodash/function/spread.js +++ /dev/null @@ -1,44 +0,0 @@ -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** - * Creates a function that invokes `func` with the `this` binding of the created - * function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3). - * - * **Note:** This method is based on the [spread operator](https://developer.mozilla.org/Web/JavaScript/Reference/Operators/Spread_operator). - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to spread arguments over. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.spread(function(who, what) { - * return who + ' says ' + what; - * }); - * - * say(['fred', 'hello']); - * // => 'fred says hello' - * - * // with a Promise - * var numbers = Promise.all([ - * Promise.resolve(40), - * Promise.resolve(36) - * ]); - * - * numbers.then(_.spread(function(x, y) { - * return x + y; - * })); - * // => a Promise of 76 - */ -function spread(func) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function(array) { - return func.apply(this, array); - }; -} - -module.exports = spread; diff --git a/node_modules/lodash/function/throttle.js b/node_modules/lodash/function/throttle.js deleted file mode 100644 index 1dd00eab758..00000000000 --- a/node_modules/lodash/function/throttle.js +++ /dev/null @@ -1,62 +0,0 @@ -var debounce = require('./debounce'), - isObject = require('../lang/isObject'); - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** - * Creates a throttled function that only invokes `func` at most once per - * every `wait` milliseconds. The throttled function comes with a `cancel` - * method to cancel delayed invocations. Provide an options object to indicate - * that `func` should be invoked on the leading and/or trailing edge of the - * `wait` timeout. Subsequent calls to the throttled function return the - * result of the last `func` call. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked - * on the trailing edge of the timeout only if the the throttled function is - * invoked more than once during the `wait` timeout. - * - * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) - * for details over the differences between `_.throttle` and `_.debounce`. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to throttle. - * @param {number} [wait=0] The number of milliseconds to throttle invocations to. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=true] Specify invoking on the leading - * edge of the timeout. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. - * @returns {Function} Returns the new throttled function. - * @example - * - * // avoid excessively updating the position while scrolling - * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); - * - * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); - * - * // cancel a trailing throttled call - * jQuery(window).on('popstate', throttled.cancel); - */ -function throttle(func, wait, options) { - var leading = true, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (options === false) { - leading = false; - } else if (isObject(options)) { - leading = 'leading' in options ? !!options.leading : leading; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing }); -} - -module.exports = throttle; diff --git a/node_modules/lodash/function/wrap.js b/node_modules/lodash/function/wrap.js deleted file mode 100644 index 6a33c5ec6f1..00000000000 --- a/node_modules/lodash/function/wrap.js +++ /dev/null @@ -1,33 +0,0 @@ -var createWrapper = require('../internal/createWrapper'), - identity = require('../utility/identity'); - -/** Used to compose bitmasks for wrapper metadata. */ -var PARTIAL_FLAG = 32; - -/** - * Creates a function that provides `value` to the wrapper function as its - * first argument. Any additional arguments provided to the function are - * appended to those provided to the wrapper function. The wrapper is invoked - * with the `this` binding of the created function. - * - * @static - * @memberOf _ - * @category Function - * @param {*} value The value to wrap. - * @param {Function} wrapper The wrapper function. - * @returns {Function} Returns the new function. - * @example - * - * var p = _.wrap(_.escape, function(func, text) { - * return '

' + func(text) + '

'; - * }); - * - * p('fred, barney, & pebbles'); - * // => '

fred, barney, & pebbles

' - */ -function wrap(value, wrapper) { - wrapper = wrapper == null ? identity : wrapper; - return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []); -} - -module.exports = wrap; diff --git a/node_modules/lodash/index.js b/node_modules/lodash/index.js deleted file mode 100644 index 5f17319b9bb..00000000000 --- a/node_modules/lodash/index.js +++ /dev/null @@ -1,12351 +0,0 @@ -/** - * @license - * lodash 3.10.1 (Custom Build) - * Build: `lodash modern -d -o ./index.js` - * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ -;(function() { - - /** Used as a safe reference for `undefined` in pre-ES5 environments. */ - var undefined; - - /** Used as the semantic version number. */ - var VERSION = '3.10.1'; - - /** Used to compose bitmasks for wrapper metadata. */ - var BIND_FLAG = 1, - BIND_KEY_FLAG = 2, - CURRY_BOUND_FLAG = 4, - CURRY_FLAG = 8, - CURRY_RIGHT_FLAG = 16, - PARTIAL_FLAG = 32, - PARTIAL_RIGHT_FLAG = 64, - ARY_FLAG = 128, - REARG_FLAG = 256; - - /** Used as default options for `_.trunc`. */ - var DEFAULT_TRUNC_LENGTH = 30, - DEFAULT_TRUNC_OMISSION = '...'; - - /** Used to detect when a function becomes hot. */ - var HOT_COUNT = 150, - HOT_SPAN = 16; - - /** Used as the size to enable large array optimizations. */ - var LARGE_ARRAY_SIZE = 200; - - /** Used to indicate the type of lazy iteratees. */ - var LAZY_FILTER_FLAG = 1, - LAZY_MAP_FLAG = 2; - - /** Used as the `TypeError` message for "Functions" methods. */ - var FUNC_ERROR_TEXT = 'Expected a function'; - - /** Used as the internal argument placeholder. */ - var PLACEHOLDER = '__lodash_placeholder__'; - - /** `Object#toString` result references. */ - var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - weakMapTag = '[object WeakMap]'; - - var arrayBufferTag = '[object ArrayBuffer]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - - /** Used to match empty string literals in compiled template source. */ - var reEmptyStringLeading = /\b__p \+= '';/g, - reEmptyStringMiddle = /\b(__p \+=) '' \+/g, - reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - - /** Used to match HTML entities and HTML characters. */ - var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, - reUnescapedHtml = /[&<>"'`]/g, - reHasEscapedHtml = RegExp(reEscapedHtml.source), - reHasUnescapedHtml = RegExp(reUnescapedHtml.source); - - /** Used to match template delimiters. */ - var reEscape = /<%-([\s\S]+?)%>/g, - reEvaluate = /<%([\s\S]+?)%>/g, - reInterpolate = /<%=([\s\S]+?)%>/g; - - /** Used to match property names within property paths. */ - var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; - - /** - * Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns) - * and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern). - */ - var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g, - reHasRegExpChars = RegExp(reRegExpChars.source); - - /** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */ - var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g; - - /** Used to match backslashes in property paths. */ - var reEscapeChar = /\\(\\)?/g; - - /** Used to match [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). */ - var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - - /** Used to match `RegExp` flags from their coerced string values. */ - var reFlags = /\w*$/; - - /** Used to detect hexadecimal string values. */ - var reHasHexPrefix = /^0[xX]/; - - /** Used to detect host constructors (Safari > 5). */ - var reIsHostCtor = /^\[object .+?Constructor\]$/; - - /** Used to detect unsigned integer values. */ - var reIsUint = /^\d+$/; - - /** Used to match latin-1 supplementary letters (excluding mathematical operators). */ - var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; - - /** Used to ensure capturing order of template delimiters. */ - var reNoMatch = /($^)/; - - /** Used to match unescaped characters in compiled string literals. */ - var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - - /** Used to match words to create compound words. */ - var reWords = (function() { - var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', - lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; - - return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); - }()); - - /** Used to assign default `context` object properties. */ - var contextProps = [ - 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array', - 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', - 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'isFinite', - 'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', - 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap' - ]; - - /** Used to make template sourceURLs easier to identify. */ - var templateCounter = -1; - - /** Used to identify `toStringTag` values of typed arrays. */ - var typedArrayTags = {}; - typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = - typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = - typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = - typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = - typedArrayTags[uint32Tag] = true; - typedArrayTags[argsTag] = typedArrayTags[arrayTag] = - typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = - typedArrayTags[dateTag] = typedArrayTags[errorTag] = - typedArrayTags[funcTag] = typedArrayTags[mapTag] = - typedArrayTags[numberTag] = typedArrayTags[objectTag] = - typedArrayTags[regexpTag] = typedArrayTags[setTag] = - typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - - /** Used to identify `toStringTag` values supported by `_.clone`. */ - var cloneableTags = {}; - cloneableTags[argsTag] = cloneableTags[arrayTag] = - cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = - cloneableTags[dateTag] = cloneableTags[float32Tag] = - cloneableTags[float64Tag] = cloneableTags[int8Tag] = - cloneableTags[int16Tag] = cloneableTags[int32Tag] = - cloneableTags[numberTag] = cloneableTags[objectTag] = - cloneableTags[regexpTag] = cloneableTags[stringTag] = - cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = - cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; - cloneableTags[errorTag] = cloneableTags[funcTag] = - cloneableTags[mapTag] = cloneableTags[setTag] = - cloneableTags[weakMapTag] = false; - - /** Used to map latin-1 supplementary letters to basic latin letters. */ - var deburredLetters = { - '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', - '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', - '\xc7': 'C', '\xe7': 'c', - '\xd0': 'D', '\xf0': 'd', - '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', - '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', - '\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', - '\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', - '\xd1': 'N', '\xf1': 'n', - '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', - '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', - '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', - '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', - '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', - '\xc6': 'Ae', '\xe6': 'ae', - '\xde': 'Th', '\xfe': 'th', - '\xdf': 'ss' - }; - - /** Used to map characters to HTML entities. */ - var htmlEscapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '`': '`' - }; - - /** Used to map HTML entities to characters. */ - var htmlUnescapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - ''': "'", - '`': '`' - }; - - /** Used to determine if values are of the language type `Object`. */ - var objectTypes = { - 'function': true, - 'object': true - }; - - /** Used to escape characters for inclusion in compiled regexes. */ - var regexpEscapes = { - '0': 'x30', '1': 'x31', '2': 'x32', '3': 'x33', '4': 'x34', - '5': 'x35', '6': 'x36', '7': 'x37', '8': 'x38', '9': 'x39', - 'A': 'x41', 'B': 'x42', 'C': 'x43', 'D': 'x44', 'E': 'x45', 'F': 'x46', - 'a': 'x61', 'b': 'x62', 'c': 'x63', 'd': 'x64', 'e': 'x65', 'f': 'x66', - 'n': 'x6e', 'r': 'x72', 't': 'x74', 'u': 'x75', 'v': 'x76', 'x': 'x78' - }; - - /** Used to escape characters for inclusion in compiled string literals. */ - var stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - /** Detect free variable `exports`. */ - var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - - /** Detect free variable `module`. */ - var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - - /** Detect free variable `global` from Node.js. */ - var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global; - - /** Detect free variable `self`. */ - var freeSelf = objectTypes[typeof self] && self && self.Object && self; - - /** Detect free variable `window`. */ - var freeWindow = objectTypes[typeof window] && window && window.Object && window; - - /** Detect the popular CommonJS extension `module.exports`. */ - var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; - - /** - * Used as a reference to the global object. - * - * The `this` value is used if it's the global object to avoid Greasemonkey's - * restricted `window` object, otherwise the `window` object is used. - */ - var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; - - /*--------------------------------------------------------------------------*/ - - /** - * The base implementation of `compareAscending` which compares values and - * sorts them in ascending order without guaranteeing a stable sort. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {number} Returns the sort order indicator for `value`. - */ - function baseCompareAscending(value, other) { - if (value !== other) { - var valIsNull = value === null, - valIsUndef = value === undefined, - valIsReflexive = value === value; - - var othIsNull = other === null, - othIsUndef = other === undefined, - othIsReflexive = other === other; - - if ((value > other && !othIsNull) || !valIsReflexive || - (valIsNull && !othIsUndef && othIsReflexive) || - (valIsUndef && othIsReflexive)) { - return 1; - } - if ((value < other && !valIsNull) || !othIsReflexive || - (othIsNull && !valIsUndef && valIsReflexive) || - (othIsUndef && valIsReflexive)) { - return -1; - } - } - return 0; - } - - /** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to search. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseFindIndex(array, predicate, fromRight) { - var length = array.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; - } - - /** - * The base implementation of `_.indexOf` without support for binary searches. - * - * @private - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseIndexOf(array, value, fromIndex) { - if (value !== value) { - return indexOfNaN(array, fromIndex); - } - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; - } - - /** - * The base implementation of `_.isFunction` without support for environments - * with incorrect `typeof` results. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - */ - function baseIsFunction(value) { - // Avoid a Chakra JIT bug in compatibility modes of IE 11. - // See https://github.com/jashkenas/underscore/issues/1621 for more details. - return typeof value == 'function' || false; - } - - /** - * Converts `value` to a string if it's not one. An empty string is returned - * for `null` or `undefined` values. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ - function baseToString(value) { - return value == null ? '' : (value + ''); - } - - /** - * Used by `_.trim` and `_.trimLeft` to get the index of the first character - * of `string` that is not found in `chars`. - * - * @private - * @param {string} string The string to inspect. - * @param {string} chars The characters to find. - * @returns {number} Returns the index of the first character not found in `chars`. - */ - function charsLeftIndex(string, chars) { - var index = -1, - length = string.length; - - while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} - return index; - } - - /** - * Used by `_.trim` and `_.trimRight` to get the index of the last character - * of `string` that is not found in `chars`. - * - * @private - * @param {string} string The string to inspect. - * @param {string} chars The characters to find. - * @returns {number} Returns the index of the last character not found in `chars`. - */ - function charsRightIndex(string, chars) { - var index = string.length; - - while (index-- && chars.indexOf(string.charAt(index)) > -1) {} - return index; - } - - /** - * Used by `_.sortBy` to compare transformed elements of a collection and stable - * sort them in ascending order. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @returns {number} Returns the sort order indicator for `object`. - */ - function compareAscending(object, other) { - return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index); - } - - /** - * Used by `_.sortByOrder` to compare multiple properties of a value to another - * and stable sort them. - * - * If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise, - * a value is sorted in ascending order if its corresponding order is "asc", and - * descending if "desc". - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {boolean[]} orders The order to sort by for each property. - * @returns {number} Returns the sort order indicator for `object`. - */ - function compareMultiple(object, other, orders) { - var index = -1, - objCriteria = object.criteria, - othCriteria = other.criteria, - length = objCriteria.length, - ordersLength = orders.length; - - while (++index < length) { - var result = baseCompareAscending(objCriteria[index], othCriteria[index]); - if (result) { - if (index >= ordersLength) { - return result; - } - var order = orders[index]; - return result * ((order === 'asc' || order === true) ? 1 : -1); - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to provide the same value for - // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 - // for more details. - // - // This also ensures a stable sort in V8 and other engines. - // See https://code.google.com/p/v8/issues/detail?id=90 for more details. - return object.index - other.index; - } - - /** - * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. - * - * @private - * @param {string} letter The matched letter to deburr. - * @returns {string} Returns the deburred letter. - */ - function deburrLetter(letter) { - return deburredLetters[letter]; - } - - /** - * Used by `_.escape` to convert characters to HTML entities. - * - * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeHtmlChar(chr) { - return htmlEscapes[chr]; - } - - /** - * Used by `_.escapeRegExp` to escape characters for inclusion in compiled regexes. - * - * @private - * @param {string} chr The matched character to escape. - * @param {string} leadingChar The capture group for a leading character. - * @param {string} whitespaceChar The capture group for a whitespace character. - * @returns {string} Returns the escaped character. - */ - function escapeRegExpChar(chr, leadingChar, whitespaceChar) { - if (leadingChar) { - chr = regexpEscapes[chr]; - } else if (whitespaceChar) { - chr = stringEscapes[chr]; - } - return '\\' + chr; - } - - /** - * Used by `_.template` to escape characters for inclusion in compiled string literals. - * - * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeStringChar(chr) { - return '\\' + stringEscapes[chr]; - } - - /** - * Gets the index at which the first occurrence of `NaN` is found in `array`. - * - * @private - * @param {Array} array The array to search. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched `NaN`, else `-1`. - */ - function indexOfNaN(array, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 0 : -1); - - while ((fromRight ? index-- : ++index < length)) { - var other = array[index]; - if (other !== other) { - return index; - } - } - return -1; - } - - /** - * Checks if `value` is object-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - */ - function isObjectLike(value) { - return !!value && typeof value == 'object'; - } - - /** - * Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a - * character code is whitespace. - * - * @private - * @param {number} charCode The character code to inspect. - * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`. - */ - function isSpace(charCode) { - return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 || - (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279))); - } - - /** - * Replaces all `placeholder` elements in `array` with an internal placeholder - * and returns an array of their indexes. - * - * @private - * @param {Array} array The array to modify. - * @param {*} placeholder The placeholder to replace. - * @returns {Array} Returns the new array of placeholder indexes. - */ - function replaceHolders(array, placeholder) { - var index = -1, - length = array.length, - resIndex = -1, - result = []; - - while (++index < length) { - if (array[index] === placeholder) { - array[index] = PLACEHOLDER; - result[++resIndex] = index; - } - } - return result; - } - - /** - * An implementation of `_.uniq` optimized for sorted arrays without support - * for callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The function invoked per iteration. - * @returns {Array} Returns the new duplicate-value-free array. - */ - function sortedUniq(array, iteratee) { - var seen, - index = -1, - length = array.length, - resIndex = -1, - result = []; - - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value, index, array) : value; - - if (!index || seen !== computed) { - seen = computed; - result[++resIndex] = value; - } - } - return result; - } - - /** - * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace - * character of `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the index of the first non-whitespace character. - */ - function trimmedLeftIndex(string) { - var index = -1, - length = string.length; - - while (++index < length && isSpace(string.charCodeAt(index))) {} - return index; - } - - /** - * Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace - * character of `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the index of the last non-whitespace character. - */ - function trimmedRightIndex(string) { - var index = string.length; - - while (index-- && isSpace(string.charCodeAt(index))) {} - return index; - } - - /** - * Used by `_.unescape` to convert HTML entities to characters. - * - * @private - * @param {string} chr The matched character to unescape. - * @returns {string} Returns the unescaped character. - */ - function unescapeHtmlChar(chr) { - return htmlUnescapes[chr]; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Create a new pristine `lodash` function using the given `context` object. - * - * @static - * @memberOf _ - * @category Utility - * @param {Object} [context=root] The context object. - * @returns {Function} Returns a new `lodash` function. - * @example - * - * _.mixin({ 'foo': _.constant('foo') }); - * - * var lodash = _.runInContext(); - * lodash.mixin({ 'bar': lodash.constant('bar') }); - * - * _.isFunction(_.foo); - * // => true - * _.isFunction(_.bar); - * // => false - * - * lodash.isFunction(lodash.foo); - * // => false - * lodash.isFunction(lodash.bar); - * // => true - * - * // using `context` to mock `Date#getTime` use in `_.now` - * var mock = _.runInContext({ - * 'Date': function() { - * return { 'getTime': getTimeMock }; - * } - * }); - * - * // or creating a suped-up `defer` in Node.js - * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; - */ - function runInContext(context) { - // Avoid issues with some ES3 environments that attempt to use values, named - // after built-in constructors like `Object`, for the creation of literals. - // ES5 clears this up by stating that literals must use built-in constructors. - // See https://es5.github.io/#x11.1.5 for more details. - context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; - - /** Native constructor references. */ - var Array = context.Array, - Date = context.Date, - Error = context.Error, - Function = context.Function, - Math = context.Math, - Number = context.Number, - Object = context.Object, - RegExp = context.RegExp, - String = context.String, - TypeError = context.TypeError; - - /** Used for native method references. */ - var arrayProto = Array.prototype, - objectProto = Object.prototype, - stringProto = String.prototype; - - /** Used to resolve the decompiled source of functions. */ - var fnToString = Function.prototype.toString; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; - - /** Used to generate unique IDs. */ - var idCounter = 0; - - /** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ - var objToString = objectProto.toString; - - /** Used to restore the original `_` reference in `_.noConflict`. */ - var oldDash = root._; - - /** Used to detect if a method is native. */ - var reIsNative = RegExp('^' + - fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' - ); - - /** Native method references. */ - var ArrayBuffer = context.ArrayBuffer, - clearTimeout = context.clearTimeout, - parseFloat = context.parseFloat, - pow = Math.pow, - propertyIsEnumerable = objectProto.propertyIsEnumerable, - Set = getNative(context, 'Set'), - setTimeout = context.setTimeout, - splice = arrayProto.splice, - Uint8Array = context.Uint8Array, - WeakMap = getNative(context, 'WeakMap'); - - /* Native method references for those with the same name as other `lodash` methods. */ - var nativeCeil = Math.ceil, - nativeCreate = getNative(Object, 'create'), - nativeFloor = Math.floor, - nativeIsArray = getNative(Array, 'isArray'), - nativeIsFinite = context.isFinite, - nativeKeys = getNative(Object, 'keys'), - nativeMax = Math.max, - nativeMin = Math.min, - nativeNow = getNative(Date, 'now'), - nativeParseInt = context.parseInt, - nativeRandom = Math.random; - - /** Used as references for `-Infinity` and `Infinity`. */ - var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, - POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - - /** Used as references for the maximum length and index of an array. */ - var MAX_ARRAY_LENGTH = 4294967295, - MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, - HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; - - /** - * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) - * of an array-like value. - */ - var MAX_SAFE_INTEGER = 9007199254740991; - - /** Used to store function metadata. */ - var metaMap = WeakMap && new WeakMap; - - /** Used to lookup unminified function names. */ - var realNames = {}; - - /*------------------------------------------------------------------------*/ - - /** - * Creates a `lodash` object which wraps `value` to enable implicit chaining. - * Methods that operate on and return arrays, collections, and functions can - * be chained together. Methods that retrieve a single value or may return a - * primitive value will automatically end the chain returning the unwrapped - * value. Explicit chaining may be enabled using `_.chain`. The execution of - * chained methods is lazy, that is, execution is deferred until `_#value` - * is implicitly or explicitly called. - * - * Lazy evaluation allows several methods to support shortcut fusion. Shortcut - * fusion is an optimization strategy which merge iteratee calls; this can help - * to avoid the creation of intermediate data structures and greatly reduce the - * number of iteratee executions. - * - * Chaining is supported in custom builds as long as the `_#value` method is - * directly or indirectly included in the build. - * - * In addition to lodash methods, wrappers have `Array` and `String` methods. - * - * The wrapper `Array` methods are: - * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, - * `splice`, and `unshift` - * - * The wrapper `String` methods are: - * `replace` and `split` - * - * The wrapper methods that support shortcut fusion are: - * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, - * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, - * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, - * and `where` - * - * The chainable wrapper methods are: - * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, - * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, - * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, - * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`, - * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, - * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, - * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, - * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, - * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`, - * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, - * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, - * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`, - * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, - * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`, - * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, - * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`, - * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith` - * - * The wrapper methods that are **not** chainable by default are: - * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`, - * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, - * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, - * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`, - * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, - * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, - * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, - * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, - * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, - * `unescape`, `uniqueId`, `value`, and `words` - * - * The wrapper method `sample` will return a wrapped value when `n` is provided, - * otherwise an unwrapped value is returned. - * - * @name _ - * @constructor - * @category Chain - * @param {*} value The value to wrap in a `lodash` instance. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var wrapped = _([1, 2, 3]); - * - * // returns an unwrapped value - * wrapped.reduce(function(total, n) { - * return total + n; - * }); - * // => 6 - * - * // returns a wrapped value - * var squares = wrapped.map(function(n) { - * return n * n; - * }); - * - * _.isArray(squares); - * // => false - * - * _.isArray(squares.value()); - * // => true - */ - function lodash(value) { - if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { - if (value instanceof LodashWrapper) { - return value; - } - if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) { - return wrapperClone(value); - } - } - return new LodashWrapper(value); - } - - /** - * The function whose prototype all chaining wrappers inherit from. - * - * @private - */ - function baseLodash() { - // No operation performed. - } - - /** - * The base constructor for creating `lodash` wrapper objects. - * - * @private - * @param {*} value The value to wrap. - * @param {boolean} [chainAll] Enable chaining for all wrapper methods. - * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value. - */ - function LodashWrapper(value, chainAll, actions) { - this.__wrapped__ = value; - this.__actions__ = actions || []; - this.__chain__ = !!chainAll; - } - - /** - * An object environment feature flags. - * - * @static - * @memberOf _ - * @type Object - */ - var support = lodash.support = {}; - - /** - * By default, the template delimiters used by lodash are like those in - * embedded Ruby (ERB). Change the following template settings to use - * alternative delimiters. - * - * @static - * @memberOf _ - * @type Object - */ - lodash.templateSettings = { - - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'escape': reEscape, - - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'evaluate': reEvaluate, - - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'interpolate': reInterpolate, - - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type string - */ - 'variable': '', - - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type Object - */ - 'imports': { - - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type Function - */ - '_': lodash - } - }; - - /*------------------------------------------------------------------------*/ - - /** - * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. - * - * @private - * @param {*} value The value to wrap. - */ - function LazyWrapper(value) { - this.__wrapped__ = value; - this.__actions__ = []; - this.__dir__ = 1; - this.__filtered__ = false; - this.__iteratees__ = []; - this.__takeCount__ = POSITIVE_INFINITY; - this.__views__ = []; - } - - /** - * Creates a clone of the lazy wrapper object. - * - * @private - * @name clone - * @memberOf LazyWrapper - * @returns {Object} Returns the cloned `LazyWrapper` object. - */ - function lazyClone() { - var result = new LazyWrapper(this.__wrapped__); - result.__actions__ = arrayCopy(this.__actions__); - result.__dir__ = this.__dir__; - result.__filtered__ = this.__filtered__; - result.__iteratees__ = arrayCopy(this.__iteratees__); - result.__takeCount__ = this.__takeCount__; - result.__views__ = arrayCopy(this.__views__); - return result; - } - - /** - * Reverses the direction of lazy iteration. - * - * @private - * @name reverse - * @memberOf LazyWrapper - * @returns {Object} Returns the new reversed `LazyWrapper` object. - */ - function lazyReverse() { - if (this.__filtered__) { - var result = new LazyWrapper(this); - result.__dir__ = -1; - result.__filtered__ = true; - } else { - result = this.clone(); - result.__dir__ *= -1; - } - return result; - } - - /** - * Extracts the unwrapped value from its lazy wrapper. - * - * @private - * @name value - * @memberOf LazyWrapper - * @returns {*} Returns the unwrapped value. - */ - function lazyValue() { - var array = this.__wrapped__.value(), - dir = this.__dir__, - isArr = isArray(array), - isRight = dir < 0, - arrLength = isArr ? array.length : 0, - view = getView(0, arrLength, this.__views__), - start = view.start, - end = view.end, - length = end - start, - index = isRight ? end : (start - 1), - iteratees = this.__iteratees__, - iterLength = iteratees.length, - resIndex = 0, - takeCount = nativeMin(length, this.__takeCount__); - - if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) { - return baseWrapperValue((isRight && isArr) ? array.reverse() : array, this.__actions__); - } - var result = []; - - outer: - while (length-- && resIndex < takeCount) { - index += dir; - - var iterIndex = -1, - value = array[index]; - - while (++iterIndex < iterLength) { - var data = iteratees[iterIndex], - iteratee = data.iteratee, - type = data.type, - computed = iteratee(value); - - if (type == LAZY_MAP_FLAG) { - value = computed; - } else if (!computed) { - if (type == LAZY_FILTER_FLAG) { - continue outer; - } else { - break outer; - } - } - } - result[resIndex++] = value; - } - return result; - } - - /*------------------------------------------------------------------------*/ - - /** - * Creates a cache object to store key/value pairs. - * - * @private - * @static - * @name Cache - * @memberOf _.memoize - */ - function MapCache() { - this.__data__ = {}; - } - - /** - * Removes `key` and its value from the cache. - * - * @private - * @name delete - * @memberOf _.memoize.Cache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed successfully, else `false`. - */ - function mapDelete(key) { - return this.has(key) && delete this.__data__[key]; - } - - /** - * Gets the cached value for `key`. - * - * @private - * @name get - * @memberOf _.memoize.Cache - * @param {string} key The key of the value to get. - * @returns {*} Returns the cached value. - */ - function mapGet(key) { - return key == '__proto__' ? undefined : this.__data__[key]; - } - - /** - * Checks if a cached value for `key` exists. - * - * @private - * @name has - * @memberOf _.memoize.Cache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function mapHas(key) { - return key != '__proto__' && hasOwnProperty.call(this.__data__, key); - } - - /** - * Sets `value` to `key` of the cache. - * - * @private - * @name set - * @memberOf _.memoize.Cache - * @param {string} key The key of the value to cache. - * @param {*} value The value to cache. - * @returns {Object} Returns the cache object. - */ - function mapSet(key, value) { - if (key != '__proto__') { - this.__data__[key] = value; - } - return this; - } - - /*------------------------------------------------------------------------*/ - - /** - * - * Creates a cache object to store unique values. - * - * @private - * @param {Array} [values] The values to cache. - */ - function SetCache(values) { - var length = values ? values.length : 0; - - this.data = { 'hash': nativeCreate(null), 'set': new Set }; - while (length--) { - this.push(values[length]); - } - } - - /** - * Checks if `value` is in `cache` mimicking the return signature of - * `_.indexOf` by returning `0` if the value is found, else `-1`. - * - * @private - * @param {Object} cache The cache to search. - * @param {*} value The value to search for. - * @returns {number} Returns `0` if `value` is found, else `-1`. - */ - function cacheIndexOf(cache, value) { - var data = cache.data, - result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value]; - - return result ? 0 : -1; - } - - /** - * Adds `value` to the cache. - * - * @private - * @name push - * @memberOf SetCache - * @param {*} value The value to cache. - */ - function cachePush(value) { - var data = this.data; - if (typeof value == 'string' || isObject(value)) { - data.set.add(value); - } else { - data.hash[value] = true; - } - } - - /*------------------------------------------------------------------------*/ - - /** - * Creates a new array joining `array` with `other`. - * - * @private - * @param {Array} array The array to join. - * @param {Array} other The other array to join. - * @returns {Array} Returns the new concatenated array. - */ - function arrayConcat(array, other) { - var index = -1, - length = array.length, - othIndex = -1, - othLength = other.length, - result = Array(length + othLength); - - while (++index < length) { - result[index] = array[index]; - } - while (++othIndex < othLength) { - result[index++] = other[othIndex]; - } - return result; - } - - /** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ - function arrayCopy(source, array) { - var index = -1, - length = source.length; - - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; - } - - /** - * A specialized version of `_.forEach` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ - function arrayEach(array, iteratee) { - var index = -1, - length = array.length; - - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } - } - return array; - } - - /** - * A specialized version of `_.forEachRight` for arrays without support for - * callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ - function arrayEachRight(array, iteratee) { - var length = array.length; - - while (length--) { - if (iteratee(array[length], length, array) === false) { - break; - } - } - return array; - } - - /** - * A specialized version of `_.every` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - */ - function arrayEvery(array, predicate) { - var index = -1, - length = array.length; - - while (++index < length) { - if (!predicate(array[index], index, array)) { - return false; - } - } - return true; - } - - /** - * A specialized version of `baseExtremum` for arrays which invokes `iteratee` - * with one argument: (value). - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} comparator The function used to compare values. - * @param {*} exValue The initial extremum value. - * @returns {*} Returns the extremum value. - */ - function arrayExtremum(array, iteratee, comparator, exValue) { - var index = -1, - length = array.length, - computed = exValue, - result = computed; - - while (++index < length) { - var value = array[index], - current = +iteratee(value); - - if (comparator(current, computed)) { - computed = current; - result = value; - } - } - return result; - } - - /** - * A specialized version of `_.filter` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ - function arrayFilter(array, predicate) { - var index = -1, - length = array.length, - resIndex = -1, - result = []; - - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result[++resIndex] = value; - } - } - return result; - } - - /** - * A specialized version of `_.map` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ - function arrayMap(array, iteratee) { - var index = -1, - length = array.length, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; - } - - /** - * Appends the elements of `values` to `array`. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to append. - * @returns {Array} Returns `array`. - */ - function arrayPush(array, values) { - var index = -1, - length = values.length, - offset = array.length; - - while (++index < length) { - array[offset + index] = values[index]; - } - return array; - } - - /** - * A specialized version of `_.reduce` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray] Specify using the first element of `array` - * as the initial value. - * @returns {*} Returns the accumulated value. - */ - function arrayReduce(array, iteratee, accumulator, initFromArray) { - var index = -1, - length = array.length; - - if (initFromArray && length) { - accumulator = array[++index]; - } - while (++index < length) { - accumulator = iteratee(accumulator, array[index], index, array); - } - return accumulator; - } - - /** - * A specialized version of `_.reduceRight` for arrays without support for - * callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray] Specify using the last element of `array` - * as the initial value. - * @returns {*} Returns the accumulated value. - */ - function arrayReduceRight(array, iteratee, accumulator, initFromArray) { - var length = array.length; - if (initFromArray && length) { - accumulator = array[--length]; - } - while (length--) { - accumulator = iteratee(accumulator, array[length], length, array); - } - return accumulator; - } - - /** - * A specialized version of `_.some` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ - function arraySome(array, predicate) { - var index = -1, - length = array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; - } - - /** - * A specialized version of `_.sum` for arrays without support for callback - * shorthands and `this` binding.. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the sum. - */ - function arraySum(array, iteratee) { - var length = array.length, - result = 0; - - while (length--) { - result += +iteratee(array[length]) || 0; - } - return result; - } - - /** - * Used by `_.defaults` to customize its `_.assign` use. - * - * @private - * @param {*} objectValue The destination object property value. - * @param {*} sourceValue The source object property value. - * @returns {*} Returns the value to assign to the destination object. - */ - function assignDefaults(objectValue, sourceValue) { - return objectValue === undefined ? sourceValue : objectValue; - } - - /** - * Used by `_.template` to customize its `_.assign` use. - * - * **Note:** This function is like `assignDefaults` except that it ignores - * inherited property values when checking if a property is `undefined`. - * - * @private - * @param {*} objectValue The destination object property value. - * @param {*} sourceValue The source object property value. - * @param {string} key The key associated with the object and source values. - * @param {Object} object The destination object. - * @returns {*} Returns the value to assign to the destination object. - */ - function assignOwnDefaults(objectValue, sourceValue, key, object) { - return (objectValue === undefined || !hasOwnProperty.call(object, key)) - ? sourceValue - : objectValue; - } - - /** - * A specialized version of `_.assign` for customizing assigned values without - * support for argument juggling, multiple sources, and `this` binding `customizer` - * functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {Function} customizer The function to customize assigned values. - * @returns {Object} Returns `object`. - */ - function assignWith(object, source, customizer) { - var index = -1, - props = keys(source), - length = props.length; - - while (++index < length) { - var key = props[index], - value = object[key], - result = customizer(value, source[key], key, object, source); - - if ((result === result ? (result !== value) : (value === value)) || - (value === undefined && !(key in object))) { - object[key] = result; - } - } - return object; - } - - /** - * The base implementation of `_.assign` without support for argument juggling, - * multiple sources, and `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ - function baseAssign(object, source) { - return source == null - ? object - : baseCopy(source, keys(source), object); - } - - /** - * The base implementation of `_.at` without support for string collections - * and individual key arguments. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {number[]|string[]} props The property names or indexes of elements to pick. - * @returns {Array} Returns the new array of picked elements. - */ - function baseAt(collection, props) { - var index = -1, - isNil = collection == null, - isArr = !isNil && isArrayLike(collection), - length = isArr ? collection.length : 0, - propsLength = props.length, - result = Array(propsLength); - - while(++index < propsLength) { - var key = props[index]; - if (isArr) { - result[index] = isIndex(key, length) ? collection[key] : undefined; - } else { - result[index] = isNil ? undefined : collection[key]; - } - } - return result; - } - - /** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. - * @param {Object} [object={}] The object to copy properties to. - * @returns {Object} Returns `object`. - */ - function baseCopy(source, props, object) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - object[key] = source[key]; - } - return object; - } - - /** - * The base implementation of `_.callback` which supports specifying the - * number of arguments to provide to `func`. - * - * @private - * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [argCount] The number of arguments to provide to `func`. - * @returns {Function} Returns the callback. - */ - function baseCallback(func, thisArg, argCount) { - var type = typeof func; - if (type == 'function') { - return thisArg === undefined - ? func - : bindCallback(func, thisArg, argCount); - } - if (func == null) { - return identity; - } - if (type == 'object') { - return baseMatches(func); - } - return thisArg === undefined - ? property(func) - : baseMatchesProperty(func, thisArg); - } - - /** - * The base implementation of `_.clone` without support for argument juggling - * and `this` binding `customizer` functions. - * - * @private - * @param {*} value The value to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @param {Function} [customizer] The function to customize cloning values. - * @param {string} [key] The key of `value`. - * @param {Object} [object] The object `value` belongs to. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates clones with source counterparts. - * @returns {*} Returns the cloned value. - */ - function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { - var result; - if (customizer) { - result = object ? customizer(value, key, object) : customizer(value); - } - if (result !== undefined) { - return result; - } - if (!isObject(value)) { - return value; - } - var isArr = isArray(value); - if (isArr) { - result = initCloneArray(value); - if (!isDeep) { - return arrayCopy(value, result); - } - } else { - var tag = objToString.call(value), - isFunc = tag == funcTag; - - if (tag == objectTag || tag == argsTag || (isFunc && !object)) { - result = initCloneObject(isFunc ? {} : value); - if (!isDeep) { - return baseAssign(result, value); - } - } else { - return cloneableTags[tag] - ? initCloneByTag(value, tag, isDeep) - : (object ? value : {}); - } - } - // Check for circular references and return its corresponding clone. - stackA || (stackA = []); - stackB || (stackB = []); - - var length = stackA.length; - while (length--) { - if (stackA[length] == value) { - return stackB[length]; - } - } - // Add the source value to the stack of traversed objects and associate it with its clone. - stackA.push(value); - stackB.push(result); - - // Recursively populate clone (susceptible to call stack limits). - (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { - result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); - }); - return result; - } - - /** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} prototype The object to inherit from. - * @returns {Object} Returns the new object. - */ - var baseCreate = (function() { - function object() {} - return function(prototype) { - if (isObject(prototype)) { - object.prototype = prototype; - var result = new object; - object.prototype = undefined; - } - return result || {}; - }; - }()); - - /** - * The base implementation of `_.delay` and `_.defer` which accepts an index - * of where to slice the arguments to provide to `func`. - * - * @private - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {Object} args The arguments provide to `func`. - * @returns {number} Returns the timer id. - */ - function baseDelay(func, wait, args) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return setTimeout(function() { func.apply(undefined, args); }, wait); - } - - /** - * The base implementation of `_.difference` which accepts a single array - * of values to exclude. - * - * @private - * @param {Array} array The array to inspect. - * @param {Array} values The values to exclude. - * @returns {Array} Returns the new array of filtered values. - */ - function baseDifference(array, values) { - var length = array ? array.length : 0, - result = []; - - if (!length) { - return result; - } - var index = -1, - indexOf = getIndexOf(), - isCommon = indexOf == baseIndexOf, - cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null, - valuesLength = values.length; - - if (cache) { - indexOf = cacheIndexOf; - isCommon = false; - values = cache; - } - outer: - while (++index < length) { - var value = array[index]; - - if (isCommon && value === value) { - var valuesIndex = valuesLength; - while (valuesIndex--) { - if (values[valuesIndex] === value) { - continue outer; - } - } - result.push(value); - } - else if (indexOf(values, value, 0) < 0) { - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.forEach` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object|string} Returns `collection`. - */ - var baseEach = createBaseEach(baseForOwn); - - /** - * The base implementation of `_.forEachRight` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object|string} Returns `collection`. - */ - var baseEachRight = createBaseEach(baseForOwnRight, true); - - /** - * The base implementation of `_.every` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false` - */ - function baseEvery(collection, predicate) { - var result = true; - baseEach(collection, function(value, index, collection) { - result = !!predicate(value, index, collection); - return result; - }); - return result; - } - - /** - * Gets the extremum value of `collection` invoking `iteratee` for each value - * in `collection` to generate the criterion by which the value is ranked. - * The `iteratee` is invoked with three arguments: (value, index|key, collection). - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} comparator The function used to compare values. - * @param {*} exValue The initial extremum value. - * @returns {*} Returns the extremum value. - */ - function baseExtremum(collection, iteratee, comparator, exValue) { - var computed = exValue, - result = computed; - - baseEach(collection, function(value, index, collection) { - var current = +iteratee(value, index, collection); - if (comparator(current, computed) || (current === exValue && current === result)) { - computed = current; - result = value; - } - }); - return result; - } - - /** - * The base implementation of `_.fill` without an iteratee call guard. - * - * @private - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. - */ - function baseFill(array, value, start, end) { - var length = array.length; - - start = start == null ? 0 : (+start || 0); - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = (end === undefined || end > length) ? length : (+end || 0); - if (end < 0) { - end += length; - } - length = start > end ? 0 : (end >>> 0); - start >>>= 0; - - while (start < length) { - array[start++] = value; - } - return array; - } - - /** - * The base implementation of `_.filter` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ - function baseFilter(collection, predicate) { - var result = []; - baseEach(collection, function(value, index, collection) { - if (predicate(value, index, collection)) { - result.push(value); - } - }); - return result; - } - - /** - * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`, - * without support for callback shorthands and `this` binding, which iterates - * over `collection` using the provided `eachFunc`. - * - * @private - * @param {Array|Object|string} collection The collection to search. - * @param {Function} predicate The function invoked per iteration. - * @param {Function} eachFunc The function to iterate over `collection`. - * @param {boolean} [retKey] Specify returning the key of the found element - * instead of the element itself. - * @returns {*} Returns the found element or its key, else `undefined`. - */ - function baseFind(collection, predicate, eachFunc, retKey) { - var result; - eachFunc(collection, function(value, key, collection) { - if (predicate(value, key, collection)) { - result = retKey ? key : value; - return false; - } - }); - return result; - } - - /** - * The base implementation of `_.flatten` with added support for restricting - * flattening and specifying the start index. - * - * @private - * @param {Array} array The array to flatten. - * @param {boolean} [isDeep] Specify a deep flatten. - * @param {boolean} [isStrict] Restrict flattening to arrays-like objects. - * @param {Array} [result=[]] The initial result value. - * @returns {Array} Returns the new flattened array. - */ - function baseFlatten(array, isDeep, isStrict, result) { - result || (result = []); - - var index = -1, - length = array.length; - - while (++index < length) { - var value = array[index]; - if (isObjectLike(value) && isArrayLike(value) && - (isStrict || isArray(value) || isArguments(value))) { - if (isDeep) { - // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, isDeep, isStrict, result); - } else { - arrayPush(result, value); - } - } else if (!isStrict) { - result[result.length] = value; - } - } - return result; - } - - /** - * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` invoking `iteratee` for - * each property. Iteratee functions may exit iteration early by explicitly - * returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ - var baseFor = createBaseFor(); - - /** - * This function is like `baseFor` except that it iterates over properties - * in the opposite order. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ - var baseForRight = createBaseFor(true); - - /** - * The base implementation of `_.forIn` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForIn(object, iteratee) { - return baseFor(object, iteratee, keysIn); - } - - /** - * The base implementation of `_.forOwn` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForOwn(object, iteratee) { - return baseFor(object, iteratee, keys); - } - - /** - * The base implementation of `_.forOwnRight` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForOwnRight(object, iteratee) { - return baseForRight(object, iteratee, keys); - } - - /** - * The base implementation of `_.functions` which creates an array of - * `object` function property names filtered from those provided. - * - * @private - * @param {Object} object The object to inspect. - * @param {Array} props The property names to filter. - * @returns {Array} Returns the new array of filtered property names. - */ - function baseFunctions(object, props) { - var index = -1, - length = props.length, - resIndex = -1, - result = []; - - while (++index < length) { - var key = props[index]; - if (isFunction(object[key])) { - result[++resIndex] = key; - } - } - return result; - } - - /** - * The base implementation of `get` without support for string paths - * and default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array} path The path of the property to get. - * @param {string} [pathKey] The key representation of path. - * @returns {*} Returns the resolved value. - */ - function baseGet(object, path, pathKey) { - if (object == null) { - return; - } - if (pathKey !== undefined && pathKey in toObject(object)) { - path = [pathKey]; - } - var index = 0, - length = path.length; - - while (object != null && index < length) { - object = object[path[index++]]; - } - return (index && index == length) ? object : undefined; - } - - /** - * The base implementation of `_.isEqual` without support for `this` binding - * `customizer` functions. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA] Tracks traversed `value` objects. - * @param {Array} [stackB] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); - } - - /** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparing objects. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA=[]] Tracks traversed `value` objects. - * @param {Array} [stackB=[]] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = arrayTag, - othTag = arrayTag; - - if (!objIsArr) { - objTag = objToString.call(object); - if (objTag == argsTag) { - objTag = objectTag; - } else if (objTag != objectTag) { - objIsArr = isTypedArray(object); - } - } - if (!othIsArr) { - othTag = objToString.call(other); - if (othTag == argsTag) { - othTag = objectTag; - } else if (othTag != objectTag) { - othIsArr = isTypedArray(other); - } - } - var objIsObj = objTag == objectTag, - othIsObj = othTag == objectTag, - isSameTag = objTag == othTag; - - if (isSameTag && !(objIsArr || objIsObj)) { - return equalByTag(object, other, objTag); - } - if (!isLoose) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); - } - } - if (!isSameTag) { - return false; - } - // Assume cyclic values are equal. - // For more information on detecting circular references see https://es5.github.io/#JO. - stackA || (stackA = []); - stackB || (stackB = []); - - var length = stackA.length; - while (length--) { - if (stackA[length] == object) { - return stackB[length] == other; - } - } - // Add `object` and `other` to the stack of traversed objects. - stackA.push(object); - stackB.push(other); - - var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); - - stackA.pop(); - stackB.pop(); - - return result; - } - - /** - * The base implementation of `_.isMatch` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Object} object The object to inspect. - * @param {Array} matchData The propery names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparing objects. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ - function baseIsMatch(object, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; - - if (object == null) { - return !length; - } - object = toObject(object); - while (index--) { - var data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; - - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var result = customizer ? customizer(objValue, srcValue, key) : undefined; - if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { - return false; - } - } - } - return true; - } - - /** - * The base implementation of `_.map` without support for callback shorthands - * and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ - function baseMap(collection, iteratee) { - var index = -1, - result = isArrayLike(collection) ? Array(collection.length) : []; - - baseEach(collection, function(value, key, collection) { - result[++index] = iteratee(value, key, collection); - }); - return result; - } - - /** - * The base implementation of `_.matches` which does not clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new function. - */ - function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - var key = matchData[0][0], - value = matchData[0][1]; - - return function(object) { - if (object == null) { - return false; - } - return object[key] === value && (value !== undefined || (key in toObject(object))); - }; - } - return function(object) { - return baseIsMatch(object, matchData); - }; - } - - /** - * The base implementation of `_.matchesProperty` which does not clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to compare. - * @returns {Function} Returns the new function. - */ - function baseMatchesProperty(path, srcValue) { - var isArr = isArray(path), - isCommon = isKey(path) && isStrictComparable(srcValue), - pathKey = (path + ''); - - path = toPath(path); - return function(object) { - if (object == null) { - return false; - } - var key = pathKey; - object = toObject(object); - if ((isArr || !isCommon) && !(key in object)) { - object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); - if (object == null) { - return false; - } - key = last(path); - object = toObject(object); - } - return object[key] === srcValue - ? (srcValue !== undefined || (key in object)) - : baseIsEqual(srcValue, object[key], undefined, true); - }; - } - - /** - * The base implementation of `_.merge` without support for argument juggling, - * multiple sources, and `this` binding `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {Function} [customizer] The function to customize merged values. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates values with source counterparts. - * @returns {Object} Returns `object`. - */ - function baseMerge(object, source, customizer, stackA, stackB) { - if (!isObject(object)) { - return object; - } - var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), - props = isSrcArr ? undefined : keys(source); - - arrayEach(props || source, function(srcValue, key) { - if (props) { - key = srcValue; - srcValue = source[key]; - } - if (isObjectLike(srcValue)) { - stackA || (stackA = []); - stackB || (stackB = []); - baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB); - } - else { - var value = object[key], - result = customizer ? customizer(value, srcValue, key, object, source) : undefined, - isCommon = result === undefined; - - if (isCommon) { - result = srcValue; - } - if ((result !== undefined || (isSrcArr && !(key in object))) && - (isCommon || (result === result ? (result !== value) : (value === value)))) { - object[key] = result; - } - } - }); - return object; - } - - /** - * A specialized version of `baseMerge` for arrays and objects which performs - * deep merges and tracks traversed objects enabling objects with circular - * references to be merged. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {string} key The key of the value to merge. - * @param {Function} mergeFunc The function to merge values. - * @param {Function} [customizer] The function to customize merged values. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates values with source counterparts. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) { - var length = stackA.length, - srcValue = source[key]; - - while (length--) { - if (stackA[length] == srcValue) { - object[key] = stackB[length]; - return; - } - } - var value = object[key], - result = customizer ? customizer(value, srcValue, key, object, source) : undefined, - isCommon = result === undefined; - - if (isCommon) { - result = srcValue; - if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) { - result = isArray(value) - ? value - : (isArrayLike(value) ? arrayCopy(value) : []); - } - else if (isPlainObject(srcValue) || isArguments(srcValue)) { - result = isArguments(value) - ? toPlainObject(value) - : (isPlainObject(value) ? value : {}); - } - else { - isCommon = false; - } - } - // Add the source value to the stack of traversed objects and associate - // it with its merged value. - stackA.push(srcValue); - stackB.push(result); - - if (isCommon) { - // Recursively merge objects and arrays (susceptible to call stack limits). - object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB); - } else if (result === result ? (result !== value) : (value === value)) { - object[key] = result; - } - } - - /** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new function. - */ - function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; - } - - /** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new function. - */ - function basePropertyDeep(path) { - var pathKey = (path + ''); - path = toPath(path); - return function(object) { - return baseGet(object, path, pathKey); - }; - } - - /** - * The base implementation of `_.pullAt` without support for individual - * index arguments and capturing the removed elements. - * - * @private - * @param {Array} array The array to modify. - * @param {number[]} indexes The indexes of elements to remove. - * @returns {Array} Returns `array`. - */ - function basePullAt(array, indexes) { - var length = array ? indexes.length : 0; - while (length--) { - var index = indexes[length]; - if (index != previous && isIndex(index)) { - var previous = index; - splice.call(array, index, 1); - } - } - return array; - } - - /** - * The base implementation of `_.random` without support for argument juggling - * and returning floating-point numbers. - * - * @private - * @param {number} min The minimum possible value. - * @param {number} max The maximum possible value. - * @returns {number} Returns the random number. - */ - function baseRandom(min, max) { - return min + nativeFloor(nativeRandom() * (max - min + 1)); - } - - /** - * The base implementation of `_.reduce` and `_.reduceRight` without support - * for callback shorthands and `this` binding, which iterates over `collection` - * using the provided `eachFunc`. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} accumulator The initial value. - * @param {boolean} initFromCollection Specify using the first or last element - * of `collection` as the initial value. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the accumulated value. - */ - function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { - eachFunc(collection, function(value, index, collection) { - accumulator = initFromCollection - ? (initFromCollection = false, value) - : iteratee(accumulator, value, index, collection); - }); - return accumulator; - } - - /** - * The base implementation of `setData` without support for hot loop detection. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ - var baseSetData = !metaMap ? identity : function(func, data) { - metaMap.set(func, data); - return func; - }; - - /** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ - function baseSlice(array, start, end) { - var index = -1, - length = array.length; - - start = start == null ? 0 : (+start || 0); - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = (end === undefined || end > length) ? length : (+end || 0); - if (end < 0) { - end += length; - } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; - - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; - } - - /** - * The base implementation of `_.some` without support for callback shorthands - * and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ - function baseSome(collection, predicate) { - var result; - - baseEach(collection, function(value, index, collection) { - result = predicate(value, index, collection); - return !result; - }); - return !!result; - } - - /** - * The base implementation of `_.sortBy` which uses `comparer` to define - * the sort order of `array` and replaces criteria objects with their - * corresponding values. - * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. - */ - function baseSortBy(array, comparer) { - var length = array.length; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; - } - - /** - * The base implementation of `_.sortByOrder` without param guards. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {boolean[]} orders The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. - */ - function baseSortByOrder(collection, iteratees, orders) { - var callback = getCallback(), - index = -1; - - iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); }); - - var result = baseMap(collection, function(value) { - var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); }); - return { 'criteria': criteria, 'index': ++index, 'value': value }; - }); - - return baseSortBy(result, function(object, other) { - return compareMultiple(object, other, orders); - }); - } - - /** - * The base implementation of `_.sum` without support for callback shorthands - * and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the sum. - */ - function baseSum(collection, iteratee) { - var result = 0; - baseEach(collection, function(value, index, collection) { - result += +iteratee(value, index, collection) || 0; - }); - return result; - } - - /** - * The base implementation of `_.uniq` without support for callback shorthands - * and `this` binding. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The function invoked per iteration. - * @returns {Array} Returns the new duplicate-value-free array. - */ - function baseUniq(array, iteratee) { - var index = -1, - indexOf = getIndexOf(), - length = array.length, - isCommon = indexOf == baseIndexOf, - isLarge = isCommon && length >= LARGE_ARRAY_SIZE, - seen = isLarge ? createCache() : null, - result = []; - - if (seen) { - indexOf = cacheIndexOf; - isCommon = false; - } else { - isLarge = false; - seen = iteratee ? [] : result; - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value, index, array) : value; - - if (isCommon && value === value) { - var seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed) { - continue outer; - } - } - if (iteratee) { - seen.push(computed); - } - result.push(value); - } - else if (indexOf(seen, computed, 0) < 0) { - if (iteratee || isLarge) { - seen.push(computed); - } - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.values` and `_.valuesIn` which creates an - * array of `object` property values corresponding to the property names - * of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the array of property values. - */ - function baseValues(object, props) { - var index = -1, - length = props.length, - result = Array(length); - - while (++index < length) { - result[index] = object[props[index]]; - } - return result; - } - - /** - * The base implementation of `_.dropRightWhile`, `_.dropWhile`, `_.takeRightWhile`, - * and `_.takeWhile` without support for callback shorthands and `this` binding. - * - * @private - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [isDrop] Specify dropping elements instead of taking them. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the slice of `array`. - */ - function baseWhile(array, predicate, isDrop, fromRight) { - var length = array.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {} - return isDrop - ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) - : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); - } - - /** - * The base implementation of `wrapperValue` which returns the result of - * performing a sequence of actions on the unwrapped `value`, where each - * successive action is supplied the return value of the previous. - * - * @private - * @param {*} value The unwrapped value. - * @param {Array} actions Actions to peform to resolve the unwrapped value. - * @returns {*} Returns the resolved value. - */ - function baseWrapperValue(value, actions) { - var result = value; - if (result instanceof LazyWrapper) { - result = result.value(); - } - var index = -1, - length = actions.length; - - while (++index < length) { - var action = actions[index]; - result = action.func.apply(action.thisArg, arrayPush([result], action.args)); - } - return result; - } - - /** - * Performs a binary search of `array` to determine the index at which `value` - * should be inserted into `array` in order to maintain its sort order. - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function binaryIndex(array, value, retHighest) { - var low = 0, - high = array ? array.length : low; - - if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { - while (low < high) { - var mid = (low + high) >>> 1, - computed = array[mid]; - - if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) { - low = mid + 1; - } else { - high = mid; - } - } - return high; - } - return binaryIndexBy(array, value, identity, retHighest); - } - - /** - * This function is like `binaryIndex` except that it invokes `iteratee` for - * `value` and each element of `array` to compute their sort ranking. The - * iteratee is invoked with one argument; (value). - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The function invoked per iteration. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function binaryIndexBy(array, value, iteratee, retHighest) { - value = iteratee(value); - - var low = 0, - high = array ? array.length : 0, - valIsNaN = value !== value, - valIsNull = value === null, - valIsUndef = value === undefined; - - while (low < high) { - var mid = nativeFloor((low + high) / 2), - computed = iteratee(array[mid]), - isDef = computed !== undefined, - isReflexive = computed === computed; - - if (valIsNaN) { - var setLow = isReflexive || retHighest; - } else if (valIsNull) { - setLow = isReflexive && isDef && (retHighest || computed != null); - } else if (valIsUndef) { - setLow = isReflexive && (retHighest || isDef); - } else if (computed == null) { - setLow = false; - } else { - setLow = retHighest ? (computed <= value) : (computed < value); - } - if (setLow) { - low = mid + 1; - } else { - high = mid; - } - } - return nativeMin(high, MAX_ARRAY_INDEX); - } - - /** - * A specialized version of `baseCallback` which only supports `this` binding - * and specifying the number of arguments to provide to `func`. - * - * @private - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {number} [argCount] The number of arguments to provide to `func`. - * @returns {Function} Returns the callback. - */ - function bindCallback(func, thisArg, argCount) { - if (typeof func != 'function') { - return identity; - } - if (thisArg === undefined) { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - case 5: return function(value, other, key, object, source) { - return func.call(thisArg, value, other, key, object, source); - }; - } - return function() { - return func.apply(thisArg, arguments); - }; - } - - /** - * Creates a clone of the given array buffer. - * - * @private - * @param {ArrayBuffer} buffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. - */ - function bufferClone(buffer) { - var result = new ArrayBuffer(buffer.byteLength), - view = new Uint8Array(result); - - view.set(new Uint8Array(buffer)); - return result; - } - - /** - * Creates an array that is the composition of partially applied arguments, - * placeholders, and provided arguments into a single array of arguments. - * - * @private - * @param {Array|Object} args The provided arguments. - * @param {Array} partials The arguments to prepend to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @returns {Array} Returns the new array of composed arguments. - */ - function composeArgs(args, partials, holders) { - var holdersLength = holders.length, - argsIndex = -1, - argsLength = nativeMax(args.length - holdersLength, 0), - leftIndex = -1, - leftLength = partials.length, - result = Array(leftLength + argsLength); - - while (++leftIndex < leftLength) { - result[leftIndex] = partials[leftIndex]; - } - while (++argsIndex < holdersLength) { - result[holders[argsIndex]] = args[argsIndex]; - } - while (argsLength--) { - result[leftIndex++] = args[argsIndex++]; - } - return result; - } - - /** - * This function is like `composeArgs` except that the arguments composition - * is tailored for `_.partialRight`. - * - * @private - * @param {Array|Object} args The provided arguments. - * @param {Array} partials The arguments to append to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @returns {Array} Returns the new array of composed arguments. - */ - function composeArgsRight(args, partials, holders) { - var holdersIndex = -1, - holdersLength = holders.length, - argsIndex = -1, - argsLength = nativeMax(args.length - holdersLength, 0), - rightIndex = -1, - rightLength = partials.length, - result = Array(argsLength + rightLength); - - while (++argsIndex < argsLength) { - result[argsIndex] = args[argsIndex]; - } - var offset = argsIndex; - while (++rightIndex < rightLength) { - result[offset + rightIndex] = partials[rightIndex]; - } - while (++holdersIndex < holdersLength) { - result[offset + holders[holdersIndex]] = args[argsIndex++]; - } - return result; - } - - /** - * Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function. - * - * @private - * @param {Function} setter The function to set keys and values of the accumulator object. - * @param {Function} [initializer] The function to initialize the accumulator object. - * @returns {Function} Returns the new aggregator function. - */ - function createAggregator(setter, initializer) { - return function(collection, iteratee, thisArg) { - var result = initializer ? initializer() : {}; - iteratee = getCallback(iteratee, thisArg, 3); - - if (isArray(collection)) { - var index = -1, - length = collection.length; - - while (++index < length) { - var value = collection[index]; - setter(result, value, iteratee(value, index, collection), collection); - } - } else { - baseEach(collection, function(value, key, collection) { - setter(result, value, iteratee(value, key, collection), collection); - }); - } - return result; - }; - } - - /** - * Creates a `_.assign`, `_.defaults`, or `_.merge` function. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ - function createAssigner(assigner) { - return restParam(function(object, sources) { - var index = -1, - length = object == null ? 0 : sources.length, - customizer = length > 2 ? sources[length - 2] : undefined, - guard = length > 2 ? sources[2] : undefined, - thisArg = length > 1 ? sources[length - 1] : undefined; - - if (typeof customizer == 'function') { - customizer = bindCallback(customizer, thisArg, 5); - length -= 2; - } else { - customizer = typeof thisArg == 'function' ? thisArg : undefined; - length -= (customizer ? 1 : 0); - } - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, customizer); - } - } - return object; - }); - } - - /** - * Creates a `baseEach` or `baseEachRight` function. - * - * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ - function createBaseEach(eachFunc, fromRight) { - return function(collection, iteratee) { - var length = collection ? getLength(collection) : 0; - if (!isLength(length)) { - return eachFunc(collection, iteratee); - } - var index = fromRight ? length : -1, - iterable = toObject(collection); - - while ((fromRight ? index-- : ++index < length)) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - }; - } - - /** - * Creates a base function for `_.forIn` or `_.forInRight`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ - function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var iterable = toObject(object), - props = keysFunc(object), - length = props.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length)) { - var key = props[index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - }; - } - - /** - * Creates a function that wraps `func` and invokes it with the `this` - * binding of `thisArg`. - * - * @private - * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. - * @returns {Function} Returns the new bound function. - */ - function createBindWrapper(func, thisArg) { - var Ctor = createCtorWrapper(func); - - function wrapper() { - var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return fn.apply(thisArg, arguments); - } - return wrapper; - } - - /** - * Creates a `Set` cache object to optimize linear searches of large arrays. - * - * @private - * @param {Array} [values] The values to cache. - * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`. - */ - function createCache(values) { - return (nativeCreate && Set) ? new SetCache(values) : null; - } - - /** - * Creates a function that produces compound words out of the words in a - * given string. - * - * @private - * @param {Function} callback The function to combine each word. - * @returns {Function} Returns the new compounder function. - */ - function createCompounder(callback) { - return function(string) { - var index = -1, - array = words(deburr(string)), - length = array.length, - result = ''; - - while (++index < length) { - result = callback(result, array[index], index); - } - return result; - }; - } - - /** - * Creates a function that produces an instance of `Ctor` regardless of - * whether it was invoked as part of a `new` expression or by `call` or `apply`. - * - * @private - * @param {Function} Ctor The constructor to wrap. - * @returns {Function} Returns the new wrapped function. - */ - function createCtorWrapper(Ctor) { - return function() { - // Use a `switch` statement to work with class constructors. - // See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist - // for more details. - var args = arguments; - switch (args.length) { - case 0: return new Ctor; - case 1: return new Ctor(args[0]); - case 2: return new Ctor(args[0], args[1]); - case 3: return new Ctor(args[0], args[1], args[2]); - case 4: return new Ctor(args[0], args[1], args[2], args[3]); - case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); - case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); - case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - } - var thisBinding = baseCreate(Ctor.prototype), - result = Ctor.apply(thisBinding, args); - - // Mimic the constructor's `return` behavior. - // See https://es5.github.io/#x13.2.2 for more details. - return isObject(result) ? result : thisBinding; - }; - } - - /** - * Creates a `_.curry` or `_.curryRight` function. - * - * @private - * @param {boolean} flag The curry bit flag. - * @returns {Function} Returns the new curry function. - */ - function createCurry(flag) { - function curryFunc(func, arity, guard) { - if (guard && isIterateeCall(func, arity, guard)) { - arity = undefined; - } - var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity); - result.placeholder = curryFunc.placeholder; - return result; - } - return curryFunc; - } - - /** - * Creates a `_.defaults` or `_.defaultsDeep` function. - * - * @private - * @param {Function} assigner The function to assign values. - * @param {Function} customizer The function to customize assigned values. - * @returns {Function} Returns the new defaults function. - */ - function createDefaults(assigner, customizer) { - return restParam(function(args) { - var object = args[0]; - if (object == null) { - return object; - } - args.push(customizer); - return assigner.apply(undefined, args); - }); - } - - /** - * Creates a `_.max` or `_.min` function. - * - * @private - * @param {Function} comparator The function used to compare values. - * @param {*} exValue The initial extremum value. - * @returns {Function} Returns the new extremum function. - */ - function createExtremum(comparator, exValue) { - return function(collection, iteratee, thisArg) { - if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { - iteratee = undefined; - } - iteratee = getCallback(iteratee, thisArg, 3); - if (iteratee.length == 1) { - collection = isArray(collection) ? collection : toIterable(collection); - var result = arrayExtremum(collection, iteratee, comparator, exValue); - if (!(collection.length && result === exValue)) { - return result; - } - } - return baseExtremum(collection, iteratee, comparator, exValue); - }; - } - - /** - * Creates a `_.find` or `_.findLast` function. - * - * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new find function. - */ - function createFind(eachFunc, fromRight) { - return function(collection, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - if (isArray(collection)) { - var index = baseFindIndex(collection, predicate, fromRight); - return index > -1 ? collection[index] : undefined; - } - return baseFind(collection, predicate, eachFunc); - }; - } - - /** - * Creates a `_.findIndex` or `_.findLastIndex` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new find function. - */ - function createFindIndex(fromRight) { - return function(array, predicate, thisArg) { - if (!(array && array.length)) { - return -1; - } - predicate = getCallback(predicate, thisArg, 3); - return baseFindIndex(array, predicate, fromRight); - }; - } - - /** - * Creates a `_.findKey` or `_.findLastKey` function. - * - * @private - * @param {Function} objectFunc The function to iterate over an object. - * @returns {Function} Returns the new find function. - */ - function createFindKey(objectFunc) { - return function(object, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return baseFind(object, predicate, objectFunc, true); - }; - } - - /** - * Creates a `_.flow` or `_.flowRight` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new flow function. - */ - function createFlow(fromRight) { - return function() { - var wrapper, - length = arguments.length, - index = fromRight ? length : -1, - leftIndex = 0, - funcs = Array(length); - - while ((fromRight ? index-- : ++index < length)) { - var func = funcs[leftIndex++] = arguments[index]; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') { - wrapper = new LodashWrapper([], true); - } - } - index = wrapper ? -1 : length; - while (++index < length) { - func = funcs[index]; - - var funcName = getFuncName(func), - data = funcName == 'wrapper' ? getData(func) : undefined; - - if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { - wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); - } else { - wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func); - } - } - return function() { - var args = arguments, - value = args[0]; - - if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { - return wrapper.plant(value).value(); - } - var index = 0, - result = length ? funcs[index].apply(this, args) : value; - - while (++index < length) { - result = funcs[index].call(this, result); - } - return result; - }; - }; - } - - /** - * Creates a function for `_.forEach` or `_.forEachRight`. - * - * @private - * @param {Function} arrayFunc The function to iterate over an array. - * @param {Function} eachFunc The function to iterate over a collection. - * @returns {Function} Returns the new each function. - */ - function createForEach(arrayFunc, eachFunc) { - return function(collection, iteratee, thisArg) { - return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection)) - ? arrayFunc(collection, iteratee) - : eachFunc(collection, bindCallback(iteratee, thisArg, 3)); - }; - } - - /** - * Creates a function for `_.forIn` or `_.forInRight`. - * - * @private - * @param {Function} objectFunc The function to iterate over an object. - * @returns {Function} Returns the new each function. - */ - function createForIn(objectFunc) { - return function(object, iteratee, thisArg) { - if (typeof iteratee != 'function' || thisArg !== undefined) { - iteratee = bindCallback(iteratee, thisArg, 3); - } - return objectFunc(object, iteratee, keysIn); - }; - } - - /** - * Creates a function for `_.forOwn` or `_.forOwnRight`. - * - * @private - * @param {Function} objectFunc The function to iterate over an object. - * @returns {Function} Returns the new each function. - */ - function createForOwn(objectFunc) { - return function(object, iteratee, thisArg) { - if (typeof iteratee != 'function' || thisArg !== undefined) { - iteratee = bindCallback(iteratee, thisArg, 3); - } - return objectFunc(object, iteratee); - }; - } - - /** - * Creates a function for `_.mapKeys` or `_.mapValues`. - * - * @private - * @param {boolean} [isMapKeys] Specify mapping keys instead of values. - * @returns {Function} Returns the new map function. - */ - function createObjectMapper(isMapKeys) { - return function(object, iteratee, thisArg) { - var result = {}; - iteratee = getCallback(iteratee, thisArg, 3); - - baseForOwn(object, function(value, key, object) { - var mapped = iteratee(value, key, object); - key = isMapKeys ? mapped : key; - value = isMapKeys ? value : mapped; - result[key] = value; - }); - return result; - }; - } - - /** - * Creates a function for `_.padLeft` or `_.padRight`. - * - * @private - * @param {boolean} [fromRight] Specify padding from the right. - * @returns {Function} Returns the new pad function. - */ - function createPadDir(fromRight) { - return function(string, length, chars) { - string = baseToString(string); - return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string); - }; - } - - /** - * Creates a `_.partial` or `_.partialRight` function. - * - * @private - * @param {boolean} flag The partial bit flag. - * @returns {Function} Returns the new partial function. - */ - function createPartial(flag) { - var partialFunc = restParam(function(func, partials) { - var holders = replaceHolders(partials, partialFunc.placeholder); - return createWrapper(func, flag, undefined, partials, holders); - }); - return partialFunc; - } - - /** - * Creates a function for `_.reduce` or `_.reduceRight`. - * - * @private - * @param {Function} arrayFunc The function to iterate over an array. - * @param {Function} eachFunc The function to iterate over a collection. - * @returns {Function} Returns the new each function. - */ - function createReduce(arrayFunc, eachFunc) { - return function(collection, iteratee, accumulator, thisArg) { - var initFromArray = arguments.length < 3; - return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection)) - ? arrayFunc(collection, iteratee, accumulator, initFromArray) - : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc); - }; - } - - /** - * Creates a function that wraps `func` and invokes it with optional `this` - * binding of, partial application, and currying. - * - * @private - * @param {Function|string} func The function or method name to reference. - * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to the new function. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [partialsRight] The arguments to append to those provided to the new function. - * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { - var isAry = bitmask & ARY_FLAG, - isBind = bitmask & BIND_FLAG, - isBindKey = bitmask & BIND_KEY_FLAG, - isCurry = bitmask & CURRY_FLAG, - isCurryBound = bitmask & CURRY_BOUND_FLAG, - isCurryRight = bitmask & CURRY_RIGHT_FLAG, - Ctor = isBindKey ? undefined : createCtorWrapper(func); - - function wrapper() { - // Avoid `arguments` object use disqualifying optimizations by - // converting it to an array before providing it to other functions. - var length = arguments.length, - index = length, - args = Array(length); - - while (index--) { - args[index] = arguments[index]; - } - if (partials) { - args = composeArgs(args, partials, holders); - } - if (partialsRight) { - args = composeArgsRight(args, partialsRight, holdersRight); - } - if (isCurry || isCurryRight) { - var placeholder = wrapper.placeholder, - argsHolders = replaceHolders(args, placeholder); - - length -= argsHolders.length; - if (length < arity) { - var newArgPos = argPos ? arrayCopy(argPos) : undefined, - newArity = nativeMax(arity - length, 0), - newsHolders = isCurry ? argsHolders : undefined, - newHoldersRight = isCurry ? undefined : argsHolders, - newPartials = isCurry ? args : undefined, - newPartialsRight = isCurry ? undefined : args; - - bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); - bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); - - if (!isCurryBound) { - bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); - } - var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity], - result = createHybridWrapper.apply(undefined, newData); - - if (isLaziable(func)) { - setData(result, newData); - } - result.placeholder = placeholder; - return result; - } - } - var thisBinding = isBind ? thisArg : this, - fn = isBindKey ? thisBinding[func] : func; - - if (argPos) { - args = reorder(args, argPos); - } - if (isAry && ary < args.length) { - args.length = ary; - } - if (this && this !== root && this instanceof wrapper) { - fn = Ctor || createCtorWrapper(func); - } - return fn.apply(thisBinding, args); - } - return wrapper; - } - - /** - * Creates the padding required for `string` based on the given `length`. - * The `chars` string is truncated if the number of characters exceeds `length`. - * - * @private - * @param {string} string The string to create padding for. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the pad for `string`. - */ - function createPadding(string, length, chars) { - var strLength = string.length; - length = +length; - - if (strLength >= length || !nativeIsFinite(length)) { - return ''; - } - var padLength = length - strLength; - chars = chars == null ? ' ' : (chars + ''); - return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength); - } - - /** - * Creates a function that wraps `func` and invokes it with the optional `this` - * binding of `thisArg` and the `partials` prepended to those provided to - * the wrapper. - * - * @private - * @param {Function} func The function to partially apply arguments to. - * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} partials The arguments to prepend to those provided to the new function. - * @returns {Function} Returns the new bound function. - */ - function createPartialWrapper(func, bitmask, thisArg, partials) { - var isBind = bitmask & BIND_FLAG, - Ctor = createCtorWrapper(func); - - function wrapper() { - // Avoid `arguments` object use disqualifying optimizations by - // converting it to an array before providing it `func`. - var argsIndex = -1, - argsLength = arguments.length, - leftIndex = -1, - leftLength = partials.length, - args = Array(leftLength + argsLength); - - while (++leftIndex < leftLength) { - args[leftIndex] = partials[leftIndex]; - } - while (argsLength--) { - args[leftIndex++] = arguments[++argsIndex]; - } - var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return fn.apply(isBind ? thisArg : this, args); - } - return wrapper; - } - - /** - * Creates a `_.ceil`, `_.floor`, or `_.round` function. - * - * @private - * @param {string} methodName The name of the `Math` method to use when rounding. - * @returns {Function} Returns the new round function. - */ - function createRound(methodName) { - var func = Math[methodName]; - return function(number, precision) { - precision = precision === undefined ? 0 : (+precision || 0); - if (precision) { - precision = pow(10, precision); - return func(number * precision) / precision; - } - return func(number); - }; - } - - /** - * Creates a `_.sortedIndex` or `_.sortedLastIndex` function. - * - * @private - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {Function} Returns the new index function. - */ - function createSortedIndex(retHighest) { - return function(array, value, iteratee, thisArg) { - var callback = getCallback(iteratee); - return (iteratee == null && callback === baseCallback) - ? binaryIndex(array, value, retHighest) - : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest); - }; - } - - /** - * Creates a function that either curries or invokes `func` with optional - * `this` binding and partially applied arguments. - * - * @private - * @param {Function|string} func The function or method name to reference. - * @param {number} bitmask The bitmask of flags. - * The bitmask may be composed of the following flags: - * 1 - `_.bind` - * 2 - `_.bindKey` - * 4 - `_.curry` or `_.curryRight` of a bound function - * 8 - `_.curry` - * 16 - `_.curryRight` - * 32 - `_.partial` - * 64 - `_.partialRight` - * 128 - `_.rearg` - * 256 - `_.ary` - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to be partially applied. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { - var isBindKey = bitmask & BIND_KEY_FLAG; - if (!isBindKey && typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - var length = partials ? partials.length : 0; - if (!length) { - bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); - partials = holders = undefined; - } - length -= (holders ? holders.length : 0); - if (bitmask & PARTIAL_RIGHT_FLAG) { - var partialsRight = partials, - holdersRight = holders; - - partials = holders = undefined; - } - var data = isBindKey ? undefined : getData(func), - newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; - - if (data) { - mergeData(newData, data); - bitmask = newData[1]; - arity = newData[9]; - } - newData[9] = arity == null - ? (isBindKey ? 0 : func.length) - : (nativeMax(arity - length, 0) || 0); - - if (bitmask == BIND_FLAG) { - var result = createBindWrapper(newData[0], newData[2]); - } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { - result = createPartialWrapper.apply(undefined, newData); - } else { - result = createHybridWrapper.apply(undefined, newData); - } - var setter = data ? baseSetData : setData; - return setter(result, newData); - } - - /** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparing arrays. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA] Tracks traversed `value` objects. - * @param {Array} [stackB] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ - function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { - var index = -1, - arrLength = array.length, - othLength = other.length; - - if (arrLength != othLength && !(isLoose && othLength > arrLength)) { - return false; - } - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index], - result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; - - if (result !== undefined) { - if (result) { - continue; - } - return false; - } - // Recursively compare arrays (susceptible to call stack limits). - if (isLoose) { - if (!arraySome(other, function(othValue) { - return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); - })) { - return false; - } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { - return false; - } - } - return true; - } - - /** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function equalByTag(object, other, tag) { - switch (tag) { - case boolTag: - case dateTag: - // Coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. - return +object == +other; - - case errorTag: - return object.name == other.name && object.message == other.message; - - case numberTag: - // Treat `NaN` vs. `NaN` as equal. - return (object != +object) - ? other != +other - : object == +other; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings primitives and string - // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. - return object == (other + ''); - } - return false; - } - - /** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA] Tracks traversed `value` objects. - * @param {Array} [stackB] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { - var objProps = keys(object), - objLength = objProps.length, - othProps = keys(other), - othLength = othProps.length; - - if (objLength != othLength && !isLoose) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - var skipCtor = isLoose; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key], - result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; - - // Recursively compare objects (susceptible to call stack limits). - if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { - return false; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (!skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; - - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - return false; - } - } - return true; - } - - /** - * Gets the appropriate "callback" function. If the `_.callback` method is - * customized this function returns the custom method, otherwise it returns - * the `baseCallback` function. If arguments are provided the chosen function - * is invoked with them and its result is returned. - * - * @private - * @returns {Function} Returns the chosen function or its result. - */ - function getCallback(func, thisArg, argCount) { - var result = lodash.callback || callback; - result = result === callback ? baseCallback : result; - return argCount ? result(func, thisArg, argCount) : result; - } - - /** - * Gets metadata for `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {*} Returns the metadata for `func`. - */ - var getData = !metaMap ? noop : function(func) { - return metaMap.get(func); - }; - - /** - * Gets the name of `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {string} Returns the function name. - */ - function getFuncName(func) { - var result = func.name, - array = realNames[result], - length = array ? array.length : 0; - - while (length--) { - var data = array[length], - otherFunc = data.func; - if (otherFunc == null || otherFunc == func) { - return data.name; - } - } - return result; - } - - /** - * Gets the appropriate "indexOf" function. If the `_.indexOf` method is - * customized this function returns the custom method, otherwise it returns - * the `baseIndexOf` function. If arguments are provided the chosen function - * is invoked with them and its result is returned. - * - * @private - * @returns {Function|number} Returns the chosen function or its result. - */ - function getIndexOf(collection, target, fromIndex) { - var result = lodash.indexOf || indexOf; - result = result === indexOf ? baseIndexOf : result; - return collection ? result(collection, target, fromIndex) : result; - } - - /** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ - var getLength = baseProperty('length'); - - /** - * Gets the propery names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ - function getMatchData(object) { - var result = pairs(object), - length = result.length; - - while (length--) { - result[length][2] = isStrictComparable(result[length][1]); - } - return result; - } - - /** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ - function getNative(object, key) { - var value = object == null ? undefined : object[key]; - return isNative(value) ? value : undefined; - } - - /** - * Gets the view, applying any `transforms` to the `start` and `end` positions. - * - * @private - * @param {number} start The start of the view. - * @param {number} end The end of the view. - * @param {Array} transforms The transformations to apply to the view. - * @returns {Object} Returns an object containing the `start` and `end` - * positions of the view. - */ - function getView(start, end, transforms) { - var index = -1, - length = transforms.length; - - while (++index < length) { - var data = transforms[index], - size = data.size; - - switch (data.type) { - case 'drop': start += size; break; - case 'dropRight': end -= size; break; - case 'take': end = nativeMin(end, start + size); break; - case 'takeRight': start = nativeMax(start, end - size); break; - } - } - return { 'start': start, 'end': end }; - } - - /** - * Initializes an array clone. - * - * @private - * @param {Array} array The array to clone. - * @returns {Array} Returns the initialized clone. - */ - function initCloneArray(array) { - var length = array.length, - result = new array.constructor(length); - - // Add array properties assigned by `RegExp#exec`. - if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { - result.index = array.index; - result.input = array.input; - } - return result; - } - - /** - * Initializes an object clone. - * - * @private - * @param {Object} object The object to clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneObject(object) { - var Ctor = object.constructor; - if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) { - Ctor = Object; - } - return new Ctor; - } - - /** - * Initializes an object clone based on its `toStringTag`. - * - * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to clone. - * @param {string} tag The `toStringTag` of the object to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneByTag(object, tag, isDeep) { - var Ctor = object.constructor; - switch (tag) { - case arrayBufferTag: - return bufferClone(object); - - case boolTag: - case dateTag: - return new Ctor(+object); - - case float32Tag: case float64Tag: - case int8Tag: case int16Tag: case int32Tag: - case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: - var buffer = object.buffer; - return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); - - case numberTag: - case stringTag: - return new Ctor(object); - - case regexpTag: - var result = new Ctor(object.source, reFlags.exec(object)); - result.lastIndex = object.lastIndex; - } - return result; - } - - /** - * Invokes the method at `path` on `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {Array} args The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - */ - function invokePath(object, path, args) { - if (object != null && !isKey(path, object)) { - path = toPath(path); - object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); - path = last(path); - } - var func = object == null ? object : object[path]; - return func == null ? undefined : func.apply(object, args); - } - - /** - * Checks if `value` is array-like. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - */ - function isArrayLike(value) { - return value != null && isLength(getLength(value)); - } - - /** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ - function isIndex(value, length) { - value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; - length = length == null ? MAX_SAFE_INTEGER : length; - return value > -1 && value % 1 == 0 && value < length; - } - - /** - * Checks if the provided arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. - */ - function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object)) { - var other = object[index]; - return value === value ? (value === other) : (other !== other); - } - return false; - } - - /** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ - function isKey(value, object) { - var type = typeof value; - if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') { - return true; - } - if (isArray(value)) { - return false; - } - var result = !reIsDeepProp.test(value); - return result || (object != null && value in toObject(object)); - } - - /** - * Checks if `func` has a lazy counterpart. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`. - */ - function isLaziable(func) { - var funcName = getFuncName(func); - if (!(funcName in LazyWrapper.prototype)) { - return false; - } - var other = lodash[funcName]; - if (func === other) { - return true; - } - var data = getData(other); - return !!data && func === data[0]; - } - - /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ - function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - - /** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ - function isStrictComparable(value) { - return value === value && !isObject(value); - } - - /** - * Merges the function metadata of `source` into `data`. - * - * Merging metadata reduces the number of wrappers required to invoke a function. - * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` - * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg` - * augment function arguments, making the order in which they are executed important, - * preventing the merging of metadata. However, we make an exception for a safe - * common case where curried functions have `_.ary` and or `_.rearg` applied. - * - * @private - * @param {Array} data The destination metadata. - * @param {Array} source The source metadata. - * @returns {Array} Returns `data`. - */ - function mergeData(data, source) { - var bitmask = data[1], - srcBitmask = source[1], - newBitmask = bitmask | srcBitmask, - isCommon = newBitmask < ARY_FLAG; - - var isCombo = - (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) || - (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) || - (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG); - - // Exit early if metadata can't be merged. - if (!(isCommon || isCombo)) { - return data; - } - // Use source `thisArg` if available. - if (srcBitmask & BIND_FLAG) { - data[2] = source[2]; - // Set when currying a bound function. - newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; - } - // Compose partial arguments. - var value = source[3]; - if (value) { - var partials = data[3]; - data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value); - data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]); - } - // Compose partial right arguments. - value = source[5]; - if (value) { - partials = data[5]; - data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value); - data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]); - } - // Use source `argPos` if available. - value = source[7]; - if (value) { - data[7] = arrayCopy(value); - } - // Use source `ary` if it's smaller. - if (srcBitmask & ARY_FLAG) { - data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); - } - // Use source `arity` if one is not provided. - if (data[9] == null) { - data[9] = source[9]; - } - // Use source `func` and merge bitmasks. - data[0] = source[0]; - data[1] = newBitmask; - - return data; - } - - /** - * Used by `_.defaultsDeep` to customize its `_.merge` use. - * - * @private - * @param {*} objectValue The destination object property value. - * @param {*} sourceValue The source object property value. - * @returns {*} Returns the value to assign to the destination object. - */ - function mergeDefaults(objectValue, sourceValue) { - return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults); - } - - /** - * A specialized version of `_.pick` which picks `object` properties specified - * by `props`. - * - * @private - * @param {Object} object The source object. - * @param {string[]} props The property names to pick. - * @returns {Object} Returns the new object. - */ - function pickByArray(object, props) { - object = toObject(object); - - var index = -1, - length = props.length, - result = {}; - - while (++index < length) { - var key = props[index]; - if (key in object) { - result[key] = object[key]; - } - } - return result; - } - - /** - * A specialized version of `_.pick` which picks `object` properties `predicate` - * returns truthy for. - * - * @private - * @param {Object} object The source object. - * @param {Function} predicate The function invoked per iteration. - * @returns {Object} Returns the new object. - */ - function pickByCallback(object, predicate) { - var result = {}; - baseForIn(object, function(value, key, object) { - if (predicate(value, key, object)) { - result[key] = value; - } - }); - return result; - } - - /** - * Reorder `array` according to the specified indexes where the element at - * the first index is assigned as the first element, the element at - * the second index is assigned as the second element, and so on. - * - * @private - * @param {Array} array The array to reorder. - * @param {Array} indexes The arranged array indexes. - * @returns {Array} Returns `array`. - */ - function reorder(array, indexes) { - var arrLength = array.length, - length = nativeMin(indexes.length, arrLength), - oldArray = arrayCopy(array); - - while (length--) { - var index = indexes[length]; - array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; - } - return array; - } - - /** - * Sets metadata for `func`. - * - * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity function - * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070) - * for more details. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ - var setData = (function() { - var count = 0, - lastCalled = 0; - - return function(key, value) { - var stamp = now(), - remaining = HOT_SPAN - (stamp - lastCalled); - - lastCalled = stamp; - if (remaining > 0) { - if (++count >= HOT_COUNT) { - return key; - } - } else { - count = 0; - } - return baseSetData(key, value); - }; - }()); - - /** - * A fallback implementation of `Object.keys` which creates an array of the - * own enumerable property names of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - function shimKeys(object) { - var props = keysIn(object), - propsLength = props.length, - length = propsLength && object.length; - - var allowIndexes = !!length && isLength(length) && - (isArray(object) || isArguments(object)); - - var index = -1, - result = []; - - while (++index < propsLength) { - var key = props[index]; - if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { - result.push(key); - } - } - return result; - } - - /** - * Converts `value` to an array-like object if it's not one. - * - * @private - * @param {*} value The value to process. - * @returns {Array|Object} Returns the array-like object. - */ - function toIterable(value) { - if (value == null) { - return []; - } - if (!isArrayLike(value)) { - return values(value); - } - return isObject(value) ? value : Object(value); - } - - /** - * Converts `value` to an object if it's not one. - * - * @private - * @param {*} value The value to process. - * @returns {Object} Returns the object. - */ - function toObject(value) { - return isObject(value) ? value : Object(value); - } - - /** - * Converts `value` to property path array if it's not one. - * - * @private - * @param {*} value The value to process. - * @returns {Array} Returns the property path array. - */ - function toPath(value) { - if (isArray(value)) { - return value; - } - var result = []; - baseToString(value).replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; - } - - /** - * Creates a clone of `wrapper`. - * - * @private - * @param {Object} wrapper The wrapper to clone. - * @returns {Object} Returns the cloned wrapper. - */ - function wrapperClone(wrapper) { - return wrapper instanceof LazyWrapper - ? wrapper.clone() - : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__)); - } - - /*------------------------------------------------------------------------*/ - - /** - * Creates an array of elements split into groups the length of `size`. - * If `collection` can't be split evenly, the final chunk will be the remaining - * elements. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to process. - * @param {number} [size=1] The length of each chunk. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the new array containing chunks. - * @example - * - * _.chunk(['a', 'b', 'c', 'd'], 2); - * // => [['a', 'b'], ['c', 'd']] - * - * _.chunk(['a', 'b', 'c', 'd'], 3); - * // => [['a', 'b', 'c'], ['d']] - */ - function chunk(array, size, guard) { - if (guard ? isIterateeCall(array, size, guard) : size == null) { - size = 1; - } else { - size = nativeMax(nativeFloor(size) || 1, 1); - } - var index = 0, - length = array ? array.length : 0, - resIndex = -1, - result = Array(nativeCeil(length / size)); - - while (index < length) { - result[++resIndex] = baseSlice(array, index, (index += size)); - } - return result; - } - - /** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are falsey. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to compact. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.compact([0, 1, false, 2, '', 3]); - * // => [1, 2, 3] - */ - function compact(array) { - var index = -1, - length = array ? array.length : 0, - resIndex = -1, - result = []; - - while (++index < length) { - var value = array[index]; - if (value) { - result[++resIndex] = value; - } - } - return result; - } - - /** - * Creates an array of unique `array` values not included in the other - * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The arrays of values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.difference([1, 2, 3], [4, 2]); - * // => [1, 3] - */ - var difference = restParam(function(array, values) { - return (isObjectLike(array) && isArrayLike(array)) - ? baseDifference(array, baseFlatten(values, false, true)) - : []; - }); - - /** - * Creates a slice of `array` with `n` elements dropped from the beginning. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.drop([1, 2, 3]); - * // => [2, 3] - * - * _.drop([1, 2, 3], 2); - * // => [3] - * - * _.drop([1, 2, 3], 5); - * // => [] - * - * _.drop([1, 2, 3], 0); - * // => [1, 2, 3] - */ - function drop(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - return baseSlice(array, n < 0 ? 0 : n); - } - - /** - * Creates a slice of `array` with `n` elements dropped from the end. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropRight([1, 2, 3]); - * // => [1, 2] - * - * _.dropRight([1, 2, 3], 2); - * // => [1] - * - * _.dropRight([1, 2, 3], 5); - * // => [] - * - * _.dropRight([1, 2, 3], 0); - * // => [1, 2, 3] - */ - function dropRight(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - n = length - (+n || 0); - return baseSlice(array, 0, n < 0 ? 0 : n); - } - - /** - * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until `predicate` returns falsey. The predicate is - * bound to `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that match the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropRightWhile([1, 2, 3], function(n) { - * return n > 1; - * }); - * // => [1] - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); - * // => ['barney', 'fred'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.dropRightWhile(users, 'active', false), 'user'); - * // => ['barney'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.dropRightWhile(users, 'active'), 'user'); - * // => ['barney', 'fred', 'pebbles'] - */ - function dropRightWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true) - : []; - } - - /** - * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until `predicate` returns falsey. The predicate is - * bound to `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropWhile([1, 2, 3], function(n) { - * return n < 3; - * }); - * // => [3] - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user'); - * // => ['fred', 'pebbles'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.dropWhile(users, 'active', false), 'user'); - * // => ['pebbles'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.dropWhile(users, 'active'), 'user'); - * // => ['barney', 'fred', 'pebbles'] - */ - function dropWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3), true) - : []; - } - - /** - * Fills elements of `array` with `value` from `start` up to, but not - * including, `end`. - * - * **Note:** This method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3]; - * - * _.fill(array, 'a'); - * console.log(array); - * // => ['a', 'a', 'a'] - * - * _.fill(Array(3), 2); - * // => [2, 2, 2] - * - * _.fill([4, 6, 8], '*', 1, 2); - * // => [4, '*', 8] - */ - function fill(array, value, start, end) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { - start = 0; - end = length; - } - return baseFill(array, value, start, end); - } - - /** - * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for instead of the element itself. - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.findIndex(users, function(chr) { - * return chr.user == 'barney'; - * }); - * // => 0 - * - * // using the `_.matches` callback shorthand - * _.findIndex(users, { 'user': 'fred', 'active': false }); - * // => 1 - * - * // using the `_.matchesProperty` callback shorthand - * _.findIndex(users, 'active', false); - * // => 0 - * - * // using the `_.property` callback shorthand - * _.findIndex(users, 'active'); - * // => 2 - */ - var findIndex = createFindIndex(); - - /** - * This method is like `_.findIndex` except that it iterates over elements - * of `collection` from right to left. - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.findLastIndex(users, function(chr) { - * return chr.user == 'pebbles'; - * }); - * // => 2 - * - * // using the `_.matches` callback shorthand - * _.findLastIndex(users, { 'user': 'barney', 'active': true }); - * // => 0 - * - * // using the `_.matchesProperty` callback shorthand - * _.findLastIndex(users, 'active', false); - * // => 2 - * - * // using the `_.property` callback shorthand - * _.findLastIndex(users, 'active'); - * // => 0 - */ - var findLastIndex = createFindIndex(true); - - /** - * Gets the first element of `array`. - * - * @static - * @memberOf _ - * @alias head - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the first element of `array`. - * @example - * - * _.first([1, 2, 3]); - * // => 1 - * - * _.first([]); - * // => undefined - */ - function first(array) { - return array ? array[0] : undefined; - } - - /** - * Flattens a nested array. If `isDeep` is `true` the array is recursively - * flattened, otherwise it is only flattened a single level. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to flatten. - * @param {boolean} [isDeep] Specify a deep flatten. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flatten([1, [2, 3, [4]]]); - * // => [1, 2, 3, [4]] - * - * // using `isDeep` - * _.flatten([1, [2, 3, [4]]], true); - * // => [1, 2, 3, 4] - */ - function flatten(array, isDeep, guard) { - var length = array ? array.length : 0; - if (guard && isIterateeCall(array, isDeep, guard)) { - isDeep = false; - } - return length ? baseFlatten(array, isDeep) : []; - } - - /** - * Recursively flattens a nested array. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to recursively flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flattenDeep([1, [2, 3, [4]]]); - * // => [1, 2, 3, 4] - */ - function flattenDeep(array) { - var length = array ? array.length : 0; - return length ? baseFlatten(array, true) : []; - } - - /** - * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it is used as the offset - * from the end of `array`. If `array` is sorted providing `true` for `fromIndex` - * performs a faster binary search. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {boolean|number} [fromIndex=0] The index to search from or `true` - * to perform a binary search on a sorted array. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.indexOf([1, 2, 1, 2], 2); - * // => 1 - * - * // using `fromIndex` - * _.indexOf([1, 2, 1, 2], 2, 2); - * // => 3 - * - * // performing a binary search - * _.indexOf([1, 1, 2, 2], 2, true); - * // => 2 - */ - function indexOf(array, value, fromIndex) { - var length = array ? array.length : 0; - if (!length) { - return -1; - } - if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; - } else if (fromIndex) { - var index = binaryIndex(array, value); - if (index < length && - (value === value ? (value === array[index]) : (array[index] !== array[index]))) { - return index; - } - return -1; - } - return baseIndexOf(array, value, fromIndex || 0); - } - - /** - * Gets all but the last element of `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.initial([1, 2, 3]); - * // => [1, 2] - */ - function initial(array) { - return dropRight(array, 1); - } - - /** - * Creates an array of unique values that are included in all of the provided - * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of shared values. - * @example - * _.intersection([1, 2], [4, 2], [2, 1]); - * // => [2] - */ - var intersection = restParam(function(arrays) { - var othLength = arrays.length, - othIndex = othLength, - caches = Array(length), - indexOf = getIndexOf(), - isCommon = indexOf == baseIndexOf, - result = []; - - while (othIndex--) { - var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; - caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null; - } - var array = arrays[0], - index = -1, - length = array ? array.length : 0, - seen = caches[0]; - - outer: - while (++index < length) { - value = array[index]; - if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { - var othIndex = othLength; - while (--othIndex) { - var cache = caches[othIndex]; - if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { - continue outer; - } - } - if (seen) { - seen.push(value); - } - result.push(value); - } - } - return result; - }); - - /** - * Gets the last element of `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - */ - function last(array) { - var length = array ? array.length : 0; - return length ? array[length - 1] : undefined; - } - - /** - * This method is like `_.indexOf` except that it iterates over elements of - * `array` from right to left. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {boolean|number} [fromIndex=array.length-1] The index to search from - * or `true` to perform a binary search on a sorted array. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.lastIndexOf([1, 2, 1, 2], 2); - * // => 3 - * - * // using `fromIndex` - * _.lastIndexOf([1, 2, 1, 2], 2, 2); - * // => 1 - * - * // performing a binary search - * _.lastIndexOf([1, 1, 2, 2], 2, true); - * // => 3 - */ - function lastIndexOf(array, value, fromIndex) { - var length = array ? array.length : 0; - if (!length) { - return -1; - } - var index = length; - if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; - } else if (fromIndex) { - index = binaryIndex(array, value, true) - 1; - var other = array[index]; - if (value === value ? (value === other) : (other !== other)) { - return index; - } - return -1; - } - if (value !== value) { - return indexOfNaN(array, index, true); - } - while (index--) { - if (array[index] === value) { - return index; - } - } - return -1; - } - - /** - * Removes all provided values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `_.without`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {...*} [values] The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3, 1, 2, 3]; - * - * _.pull(array, 2, 3); - * console.log(array); - * // => [1, 1] - */ - function pull() { - var args = arguments, - array = args[0]; - - if (!(array && array.length)) { - return array; - } - var index = 0, - indexOf = getIndexOf(), - length = args.length; - - while (++index < length) { - var fromIndex = 0, - value = args[index]; - - while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { - splice.call(array, fromIndex, 1); - } - } - return array; - } - - /** - * Removes elements from `array` corresponding to the given indexes and returns - * an array of the removed elements. Indexes may be specified as an array of - * indexes or as individual arguments. - * - * **Note:** Unlike `_.at`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {...(number|number[])} [indexes] The indexes of elements to remove, - * specified as individual indexes or arrays of indexes. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = [5, 10, 15, 20]; - * var evens = _.pullAt(array, 1, 3); - * - * console.log(array); - * // => [5, 15] - * - * console.log(evens); - * // => [10, 20] - */ - var pullAt = restParam(function(array, indexes) { - indexes = baseFlatten(indexes); - - var result = baseAt(array, indexes); - basePullAt(array, indexes.sort(baseCompareAscending)); - return result; - }); - - /** - * Removes all elements from `array` that `predicate` returns truthy for - * and returns an array of the removed elements. The predicate is bound to - * `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * **Note:** Unlike `_.filter`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(n) { - * return n % 2 == 0; - * }); - * - * console.log(array); - * // => [1, 3] - * - * console.log(evens); - * // => [2, 4] - */ - function remove(array, predicate, thisArg) { - var result = []; - if (!(array && array.length)) { - return result; - } - var index = -1, - indexes = [], - length = array.length; - - predicate = getCallback(predicate, thisArg, 3); - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result.push(value); - indexes.push(index); - } - } - basePullAt(array, indexes); - return result; - } - - /** - * Gets all but the first element of `array`. - * - * @static - * @memberOf _ - * @alias tail - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.rest([1, 2, 3]); - * // => [2, 3] - */ - function rest(array) { - return drop(array, 1); - } - - /** - * Creates a slice of `array` from `start` up to, but not including, `end`. - * - * **Note:** This method is used instead of `Array#slice` to support node - * lists in IE < 9 and to ensure dense arrays are returned. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ - function slice(array, start, end) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { - start = 0; - end = length; - } - return baseSlice(array, start, end); - } - - /** - * Uses a binary search to determine the lowest index at which `value` should - * be inserted into `array` in order to maintain its sort order. If an iteratee - * function is provided it is invoked for `value` and each element of `array` - * to compute their sort ranking. The iteratee is bound to `thisArg` and - * invoked with one argument; (value). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedIndex([30, 50], 40); - * // => 1 - * - * _.sortedIndex([4, 4, 5, 5], 5); - * // => 2 - * - * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; - * - * // using an iteratee function - * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { - * return this.data[word]; - * }, dict); - * // => 1 - * - * // using the `_.property` callback shorthand - * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); - * // => 1 - */ - var sortedIndex = createSortedIndex(); - - /** - * This method is like `_.sortedIndex` except that it returns the highest - * index at which `value` should be inserted into `array` in order to - * maintain its sort order. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedLastIndex([4, 4, 5, 5], 5); - * // => 4 - */ - var sortedLastIndex = createSortedIndex(true); - - /** - * Creates a slice of `array` with `n` elements taken from the beginning. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.take([1, 2, 3]); - * // => [1] - * - * _.take([1, 2, 3], 2); - * // => [1, 2] - * - * _.take([1, 2, 3], 5); - * // => [1, 2, 3] - * - * _.take([1, 2, 3], 0); - * // => [] - */ - function take(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - return baseSlice(array, 0, n < 0 ? 0 : n); - } - - /** - * Creates a slice of `array` with `n` elements taken from the end. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeRight([1, 2, 3]); - * // => [3] - * - * _.takeRight([1, 2, 3], 2); - * // => [2, 3] - * - * _.takeRight([1, 2, 3], 5); - * // => [1, 2, 3] - * - * _.takeRight([1, 2, 3], 0); - * // => [] - */ - function takeRight(array, n, guard) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (guard ? isIterateeCall(array, n, guard) : n == null) { - n = 1; - } - n = length - (+n || 0); - return baseSlice(array, n < 0 ? 0 : n); - } - - /** - * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is bound to `thisArg` - * and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeRightWhile([1, 2, 3], function(n) { - * return n > 1; - * }); - * // => [2, 3] - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); - * // => ['pebbles'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.takeRightWhile(users, 'active', false), 'user'); - * // => ['fred', 'pebbles'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.takeRightWhile(users, 'active'), 'user'); - * // => [] - */ - function takeRightWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true) - : []; - } - - /** - * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until `predicate` returns falsey. The predicate is bound to - * `thisArg` and invoked with three arguments: (value, index, array). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeWhile([1, 2, 3], function(n) { - * return n < 3; - * }); - * // => [1, 2] - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false}, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user'); - * // => ['barney'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.takeWhile(users, 'active', false), 'user'); - * // => ['barney', 'fred'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.takeWhile(users, 'active'), 'user'); - * // => [] - */ - function takeWhile(array, predicate, thisArg) { - return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3)) - : []; - } - - /** - * Creates an array of unique values, in order, from all of the provided arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of combined values. - * @example - * - * _.union([1, 2], [4, 2], [2, 1]); - * // => [1, 2, 4] - */ - var union = restParam(function(arrays) { - return baseUniq(baseFlatten(arrays, false, true)); - }); - - /** - * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurence of each element - * is kept. Providing `true` for `isSorted` performs a faster search algorithm - * for sorted arrays. If an iteratee function is provided it is invoked for - * each element in the array to generate the criterion by which uniqueness - * is computed. The `iteratee` is bound to `thisArg` and invoked with three - * arguments: (value, index, array). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias unique - * @category Array - * @param {Array} array The array to inspect. - * @param {boolean} [isSorted] Specify the array is sorted. - * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new duplicate-value-free array. - * @example - * - * _.uniq([2, 1, 2]); - * // => [2, 1] - * - * // using `isSorted` - * _.uniq([1, 1, 2], true); - * // => [1, 2] - * - * // using an iteratee function - * _.uniq([1, 2.5, 1.5, 2], function(n) { - * return this.floor(n); - * }, Math); - * // => [1, 2.5] - * - * // using the `_.property` callback shorthand - * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] - */ - function uniq(array, isSorted, iteratee, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - if (isSorted != null && typeof isSorted != 'boolean') { - thisArg = iteratee; - iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; - isSorted = false; - } - var callback = getCallback(); - if (!(iteratee == null && callback === baseCallback)) { - iteratee = callback(iteratee, thisArg, 3); - } - return (isSorted && getIndexOf() == baseIndexOf) - ? sortedUniq(array, iteratee) - : baseUniq(array, iteratee); - } - - /** - * This method is like `_.zip` except that it accepts an array of grouped - * elements and creates an array regrouping the elements to their pre-zip - * configuration. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array of grouped elements to process. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]); - * // => [['fred', 30, true], ['barney', 40, false]] - * - * _.unzip(zipped); - * // => [['fred', 'barney'], [30, 40], [true, false]] - */ - function unzip(array) { - if (!(array && array.length)) { - return []; - } - var index = -1, - length = 0; - - array = arrayFilter(array, function(group) { - if (isArrayLike(group)) { - length = nativeMax(group.length, length); - return true; - } - }); - var result = Array(length); - while (++index < length) { - result[index] = arrayMap(array, baseProperty(index)); - } - return result; - } - - /** - * This method is like `_.unzip` except that it accepts an iteratee to specify - * how regrouped values should be combined. The `iteratee` is bound to `thisArg` - * and invoked with four arguments: (accumulator, value, index, group). - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array of grouped elements to process. - * @param {Function} [iteratee] The function to combine regrouped values. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip([1, 2], [10, 20], [100, 200]); - * // => [[1, 10, 100], [2, 20, 200]] - * - * _.unzipWith(zipped, _.add); - * // => [3, 30, 300] - */ - function unzipWith(array, iteratee, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - var result = unzip(array); - if (iteratee == null) { - return result; - } - iteratee = bindCallback(iteratee, thisArg, 4); - return arrayMap(result, function(group) { - return arrayReduce(group, iteratee, undefined, true); - }); - } - - /** - * Creates an array excluding all provided values using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to filter. - * @param {...*} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.without([1, 2, 1, 3], 1, 2); - * // => [3] - */ - var without = restParam(function(array, values) { - return isArrayLike(array) - ? baseDifference(array, values) - : []; - }); - - /** - * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) - * of the provided arrays. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of values. - * @example - * - * _.xor([1, 2], [4, 2]); - * // => [1, 4] - */ - function xor() { - var index = -1, - length = arguments.length; - - while (++index < length) { - var array = arguments[index]; - if (isArrayLike(array)) { - var result = result - ? arrayPush(baseDifference(result, array), baseDifference(array, result)) - : array; - } - } - return result ? baseUniq(result) : []; - } - - /** - * Creates an array of grouped elements, the first of which contains the first - * elements of the given arrays, the second of which contains the second elements - * of the given arrays, and so on. - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @returns {Array} Returns the new array of grouped elements. - * @example - * - * _.zip(['fred', 'barney'], [30, 40], [true, false]); - * // => [['fred', 30, true], ['barney', 40, false]] - */ - var zip = restParam(unzip); - - /** - * The inverse of `_.pairs`; this method returns an object composed from arrays - * of property names and values. Provide either a single two dimensional array, - * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names - * and one of corresponding values. - * - * @static - * @memberOf _ - * @alias object - * @category Array - * @param {Array} props The property names. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @example - * - * _.zipObject([['fred', 30], ['barney', 40]]); - * // => { 'fred': 30, 'barney': 40 } - * - * _.zipObject(['fred', 'barney'], [30, 40]); - * // => { 'fred': 30, 'barney': 40 } - */ - function zipObject(props, values) { - var index = -1, - length = props ? props.length : 0, - result = {}; - - if (length && !values && !isArray(props[0])) { - values = []; - } - while (++index < length) { - var key = props[index]; - if (values) { - result[key] = values[index]; - } else if (key) { - result[key[0]] = key[1]; - } - } - return result; - } - - /** - * This method is like `_.zip` except that it accepts an iteratee to specify - * how grouped values should be combined. The `iteratee` is bound to `thisArg` - * and invoked with four arguments: (accumulator, value, index, group). - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @param {Function} [iteratee] The function to combine grouped values. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new array of grouped elements. - * @example - * - * _.zipWith([1, 2], [10, 20], [100, 200], _.add); - * // => [111, 222] - */ - var zipWith = restParam(function(arrays) { - var length = arrays.length, - iteratee = length > 2 ? arrays[length - 2] : undefined, - thisArg = length > 1 ? arrays[length - 1] : undefined; - - if (length > 2 && typeof iteratee == 'function') { - length -= 2; - } else { - iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined; - thisArg = undefined; - } - arrays.length = length; - return unzipWith(arrays, iteratee, thisArg); - }); - - /*------------------------------------------------------------------------*/ - - /** - * Creates a `lodash` object that wraps `value` with explicit method - * chaining enabled. - * - * @static - * @memberOf _ - * @category Chain - * @param {*} value The value to wrap. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'pebbles', 'age': 1 } - * ]; - * - * var youngest = _.chain(users) - * .sortBy('age') - * .map(function(chr) { - * return chr.user + ' is ' + chr.age; - * }) - * .first() - * .value(); - * // => 'pebbles is 1' - */ - function chain(value) { - var result = lodash(value); - result.__chain__ = true; - return result; - } - - /** - * This method invokes `interceptor` and returns `value`. The interceptor is - * bound to `thisArg` and invoked with one argument; (value). The purpose of - * this method is to "tap into" a method chain in order to perform operations - * on intermediate results within the chain. - * - * @static - * @memberOf _ - * @category Chain - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @param {*} [thisArg] The `this` binding of `interceptor`. - * @returns {*} Returns `value`. - * @example - * - * _([1, 2, 3]) - * .tap(function(array) { - * array.pop(); - * }) - * .reverse() - * .value(); - * // => [2, 1] - */ - function tap(value, interceptor, thisArg) { - interceptor.call(thisArg, value); - return value; - } - - /** - * This method is like `_.tap` except that it returns the result of `interceptor`. - * - * @static - * @memberOf _ - * @category Chain - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @param {*} [thisArg] The `this` binding of `interceptor`. - * @returns {*} Returns the result of `interceptor`. - * @example - * - * _(' abc ') - * .chain() - * .trim() - * .thru(function(value) { - * return [value]; - * }) - * .value(); - * // => ['abc'] - */ - function thru(value, interceptor, thisArg) { - return interceptor.call(thisArg, value); - } - - /** - * Enables explicit method chaining on the wrapper object. - * - * @name chain - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * // without explicit chaining - * _(users).first(); - * // => { 'user': 'barney', 'age': 36 } - * - * // with explicit chaining - * _(users).chain() - * .first() - * .pick('user') - * .value(); - * // => { 'user': 'barney' } - */ - function wrapperChain() { - return chain(this); - } - - /** - * Executes the chained sequence and returns the wrapped result. - * - * @name commit - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2]; - * var wrapped = _(array).push(3); - * - * console.log(array); - * // => [1, 2] - * - * wrapped = wrapped.commit(); - * console.log(array); - * // => [1, 2, 3] - * - * wrapped.last(); - * // => 3 - * - * console.log(array); - * // => [1, 2, 3] - */ - function wrapperCommit() { - return new LodashWrapper(this.value(), this.__chain__); - } - - /** - * Creates a new array joining a wrapped array with any additional arrays - * and/or values. - * - * @name concat - * @memberOf _ - * @category Chain - * @param {...*} [values] The values to concatenate. - * @returns {Array} Returns the new concatenated array. - * @example - * - * var array = [1]; - * var wrapped = _(array).concat(2, [3], [[4]]); - * - * console.log(wrapped.value()); - * // => [1, 2, 3, [4]] - * - * console.log(array); - * // => [1] - */ - var wrapperConcat = restParam(function(values) { - values = baseFlatten(values); - return this.thru(function(array) { - return arrayConcat(isArray(array) ? array : [toObject(array)], values); - }); - }); - - /** - * Creates a clone of the chained sequence planting `value` as the wrapped value. - * - * @name plant - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2]; - * var wrapped = _(array).map(function(value) { - * return Math.pow(value, 2); - * }); - * - * var other = [3, 4]; - * var otherWrapped = wrapped.plant(other); - * - * otherWrapped.value(); - * // => [9, 16] - * - * wrapped.value(); - * // => [1, 4] - */ - function wrapperPlant(value) { - var result, - parent = this; - - while (parent instanceof baseLodash) { - var clone = wrapperClone(parent); - if (result) { - previous.__wrapped__ = clone; - } else { - result = clone; - } - var previous = clone; - parent = parent.__wrapped__; - } - previous.__wrapped__ = value; - return result; - } - - /** - * Reverses the wrapped array so the first element becomes the last, the - * second element becomes the second to last, and so on. - * - * **Note:** This method mutates the wrapped array. - * - * @name reverse - * @memberOf _ - * @category Chain - * @returns {Object} Returns the new reversed `lodash` wrapper instance. - * @example - * - * var array = [1, 2, 3]; - * - * _(array).reverse().value() - * // => [3, 2, 1] - * - * console.log(array); - * // => [3, 2, 1] - */ - function wrapperReverse() { - var value = this.__wrapped__; - - var interceptor = function(value) { - return (wrapped && wrapped.__dir__ < 0) ? value : value.reverse(); - }; - if (value instanceof LazyWrapper) { - var wrapped = value; - if (this.__actions__.length) { - wrapped = new LazyWrapper(this); - } - wrapped = wrapped.reverse(); - wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); - return new LodashWrapper(wrapped, this.__chain__); - } - return this.thru(interceptor); - } - - /** - * Produces the result of coercing the unwrapped value to a string. - * - * @name toString - * @memberOf _ - * @category Chain - * @returns {string} Returns the coerced string value. - * @example - * - * _([1, 2, 3]).toString(); - * // => '1,2,3' - */ - function wrapperToString() { - return (this.value() + ''); - } - - /** - * Executes the chained sequence to extract the unwrapped value. - * - * @name value - * @memberOf _ - * @alias run, toJSON, valueOf - * @category Chain - * @returns {*} Returns the resolved unwrapped value. - * @example - * - * _([1, 2, 3]).value(); - * // => [1, 2, 3] - */ - function wrapperValue() { - return baseWrapperValue(this.__wrapped__, this.__actions__); - } - - /*------------------------------------------------------------------------*/ - - /** - * Creates an array of elements corresponding to the given keys, or indexes, - * of `collection`. Keys may be specified as individual arguments or as arrays - * of keys. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {...(number|number[]|string|string[])} [props] The property names - * or indexes of elements to pick, specified individually or in arrays. - * @returns {Array} Returns the new array of picked elements. - * @example - * - * _.at(['a', 'b', 'c'], [0, 2]); - * // => ['a', 'c'] - * - * _.at(['barney', 'fred', 'pebbles'], 0, 2); - * // => ['barney', 'pebbles'] - */ - var at = restParam(function(collection, props) { - return baseAt(collection, baseFlatten(props)); - }); - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding value - * of each key is the number of times the key was returned by `iteratee`. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.countBy([4.3, 6.1, 6.4], function(n) { - * return Math.floor(n); - * }); - * // => { '4': 1, '6': 2 } - * - * _.countBy([4.3, 6.1, 6.4], function(n) { - * return this.floor(n); - * }, Math); - * // => { '4': 1, '6': 2 } - * - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } - */ - var countBy = createAggregator(function(result, value, key) { - hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1); - }); - - /** - * Checks if `predicate` returns truthy for **all** elements of `collection`. - * The predicate is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias all - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes'], Boolean); - * // => false - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.every(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // using the `_.matchesProperty` callback shorthand - * _.every(users, 'active', false); - * // => true - * - * // using the `_.property` callback shorthand - * _.every(users, 'active'); - * // => false - */ - function every(collection, predicate, thisArg) { - var func = isArray(collection) ? arrayEvery : baseEvery; - if (thisArg && isIterateeCall(collection, predicate, thisArg)) { - predicate = undefined; - } - if (typeof predicate != 'function' || thisArg !== undefined) { - predicate = getCallback(predicate, thisArg, 3); - } - return func(collection, predicate); - } - - /** - * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is bound to `thisArg` and - * invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias select - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the new filtered array. - * @example - * - * _.filter([4, 5, 6], function(n) { - * return n % 2 == 0; - * }); - * // => [4, 6] - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); - * // => ['barney'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.filter(users, 'active', false), 'user'); - * // => ['fred'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.filter(users, 'active'), 'user'); - * // => ['barney'] - */ - function filter(collection, predicate, thisArg) { - var func = isArray(collection) ? arrayFilter : baseFilter; - predicate = getCallback(predicate, thisArg, 3); - return func(collection, predicate); - } - - /** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is bound to `thisArg` and - * invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias detect - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ]; - * - * _.result(_.find(users, function(chr) { - * return chr.age < 40; - * }), 'user'); - * // => 'barney' - * - * // using the `_.matches` callback shorthand - * _.result(_.find(users, { 'age': 1, 'active': true }), 'user'); - * // => 'pebbles' - * - * // using the `_.matchesProperty` callback shorthand - * _.result(_.find(users, 'active', false), 'user'); - * // => 'fred' - * - * // using the `_.property` callback shorthand - * _.result(_.find(users, 'active'), 'user'); - * // => 'barney' - */ - var find = createFind(baseEach); - - /** - * This method is like `_.find` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * _.findLast([1, 2, 3, 4], function(n) { - * return n % 2 == 1; - * }); - * // => 3 - */ - var findLast = createFind(baseEachRight, true); - - /** - * Performs a deep comparison between each element in `collection` and the - * source object, returning the first element that has equivalent property - * values. - * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own, not inherited, enumerable properties. For comparing a single - * own or inherited property value see `_.matchesProperty`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Object} source The object of property values to match. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user'); - * // => 'barney' - * - * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); - * // => 'fred' - */ - function findWhere(collection, source) { - return find(collection, baseMatches(source)); - } - - /** - * Iterates over elements of `collection` invoking `iteratee` for each element. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). Iteratee functions may exit iteration early - * by explicitly returning `false`. - * - * **Note:** As with other "Collections" methods, objects with a "length" property - * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` - * may be used for object iteration. - * - * @static - * @memberOf _ - * @alias each - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2]).forEach(function(n) { - * console.log(n); - * }).value(); - * // => logs each value from left to right and returns the array - * - * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { - * console.log(n, key); - * }); - * // => logs each value-key pair and returns the object (iteration order is not guaranteed) - */ - var forEach = createForEach(arrayEach, baseEach); - - /** - * This method is like `_.forEach` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @alias eachRight - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2]).forEachRight(function(n) { - * console.log(n); - * }).value(); - * // => logs each value from right to left and returns the array - */ - var forEachRight = createForEach(arrayEachRight, baseEachRight); - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding value - * of each key is an array of the elements responsible for generating the key. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.groupBy([4.2, 6.1, 6.4], function(n) { - * return Math.floor(n); - * }); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * _.groupBy([4.2, 6.1, 6.4], function(n) { - * return this.floor(n); - * }, Math); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * // using the `_.property` callback shorthand - * _.groupBy(['one', 'two', 'three'], 'length'); - * // => { '3': ['one', 'two'], '5': ['three'] } - */ - var groupBy = createAggregator(function(result, value, key) { - if (hasOwnProperty.call(result, key)) { - result[key].push(value); - } else { - result[key] = [value]; - } - }); - - /** - * Checks if `value` is in `collection` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it is used as the offset - * from the end of `collection`. - * - * @static - * @memberOf _ - * @alias contains, include - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {*} target The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. - * @returns {boolean} Returns `true` if a matching element is found, else `false`. - * @example - * - * _.includes([1, 2, 3], 1); - * // => true - * - * _.includes([1, 2, 3], 1, 2); - * // => false - * - * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); - * // => true - * - * _.includes('pebbles', 'eb'); - * // => true - */ - function includes(collection, target, fromIndex, guard) { - var length = collection ? getLength(collection) : 0; - if (!isLength(length)) { - collection = values(collection); - length = collection.length; - } - if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) { - fromIndex = 0; - } else { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); - } - return (typeof collection == 'string' || !isArray(collection) && isString(collection)) - ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) - : (!!length && getIndexOf(collection, target, fromIndex) > -1); - } - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iteratee`. The corresponding value - * of each key is the last element responsible for generating the key. The - * iteratee function is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * var keyData = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ]; - * - * _.indexBy(keyData, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(keyData, function(object) { - * return String.fromCharCode(object.code); - * }); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(keyData, function(object) { - * return this.fromCharCode(object.code); - * }, String); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - */ - var indexBy = createAggregator(function(result, value, key) { - result[key] = value; - }); - - /** - * Invokes the method at `path` of each element in `collection`, returning - * an array of the results of each invoked method. Any additional arguments - * are provided to each invoked method. If `methodName` is a function it is - * invoked for, and `this` bound to, each element in `collection`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|string} path The path of the method to invoke or - * the function invoked per iteration. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {Array} Returns the array of results. - * @example - * - * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); - * // => [[1, 5, 7], [1, 2, 3]] - * - * _.invoke([123, 456], String.prototype.split, ''); - * // => [['1', '2', '3'], ['4', '5', '6']] - */ - var invoke = restParam(function(collection, path, args) { - var index = -1, - isFunc = typeof path == 'function', - isProp = isKey(path), - result = isArrayLike(collection) ? Array(collection.length) : []; - - baseEach(collection, function(value) { - var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined); - result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); - }); - return result; - }); - - /** - * Creates an array of values by running each element in `collection` through - * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three - * arguments: (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. - * - * The guarded methods are: - * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, - * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, - * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, - * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, - * `sum`, `uniq`, and `words` - * - * @static - * @memberOf _ - * @alias collect - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new mapped array. - * @example - * - * function timesThree(n) { - * return n * 3; - * } - * - * _.map([1, 2], timesThree); - * // => [3, 6] - * - * _.map({ 'a': 1, 'b': 2 }, timesThree); - * // => [3, 6] (iteration order is not guaranteed) - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; - * - * // using the `_.property` callback shorthand - * _.map(users, 'user'); - * // => ['barney', 'fred'] - */ - function map(collection, iteratee, thisArg) { - var func = isArray(collection) ? arrayMap : baseMap; - iteratee = getCallback(iteratee, thisArg, 3); - return func(collection, iteratee); - } - - /** - * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, while the second of which - * contains elements `predicate` returns falsey for. The predicate is bound - * to `thisArg` and invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the array of grouped elements. - * @example - * - * _.partition([1, 2, 3], function(n) { - * return n % 2; - * }); - * // => [[1, 3], [2]] - * - * _.partition([1.2, 2.3, 3.4], function(n) { - * return this.floor(n) % 2; - * }, Math); - * // => [[1.2, 3.4], [2.3]] - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } - * ]; - * - * var mapper = function(array) { - * return _.pluck(array, 'user'); - * }; - * - * // using the `_.matches` callback shorthand - * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); - * // => [['pebbles'], ['barney', 'fred']] - * - * // using the `_.matchesProperty` callback shorthand - * _.map(_.partition(users, 'active', false), mapper); - * // => [['barney', 'pebbles'], ['fred']] - * - * // using the `_.property` callback shorthand - * _.map(_.partition(users, 'active'), mapper); - * // => [['fred'], ['barney', 'pebbles']] - */ - var partition = createAggregator(function(result, value, key) { - result[key ? 0 : 1].push(value); - }, function() { return [[], []]; }); - - /** - * Gets the property value of `path` from all elements in `collection`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|string} path The path of the property to pluck. - * @returns {Array} Returns the property values. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * _.pluck(users, 'user'); - * // => ['barney', 'fred'] - * - * var userIndex = _.indexBy(users, 'user'); - * _.pluck(userIndex, 'age'); - * // => [36, 40] (iteration order is not guaranteed) - */ - function pluck(collection, path) { - return map(collection, property(path)); - } - - /** - * Reduces `collection` to a value which is the accumulated result of running - * each element in `collection` through `iteratee`, where each successive - * invocation is supplied the return value of the previous. If `accumulator` - * is not provided the first element of `collection` is used as the initial - * value. The `iteratee` is bound to `thisArg` and invoked with four arguments: - * (accumulator, value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.reduce`, `_.reduceRight`, and `_.transform`. - * - * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`, - * and `sortByOrder` - * - * @static - * @memberOf _ - * @alias foldl, inject - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the accumulated value. - * @example - * - * _.reduce([1, 2], function(total, n) { - * return total + n; - * }); - * // => 3 - * - * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { - * result[key] = n * 3; - * return result; - * }, {}); - * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) - */ - var reduce = createReduce(arrayReduce, baseEach); - - /** - * This method is like `_.reduce` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @alias foldr - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the accumulated value. - * @example - * - * var array = [[0, 1], [2, 3], [4, 5]]; - * - * _.reduceRight(array, function(flattened, other) { - * return flattened.concat(other); - * }, []); - * // => [4, 5, 2, 3, 0, 1] - */ - var reduceRight = createReduce(arrayReduceRight, baseEachRight); - - /** - * The opposite of `_.filter`; this method returns the elements of `collection` - * that `predicate` does **not** return truthy for. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Array} Returns the new filtered array. - * @example - * - * _.reject([1, 2, 3, 4], function(n) { - * return n % 2 == 0; - * }); - * // => [1, 3] - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true } - * ]; - * - * // using the `_.matches` callback shorthand - * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user'); - * // => ['barney'] - * - * // using the `_.matchesProperty` callback shorthand - * _.pluck(_.reject(users, 'active', false), 'user'); - * // => ['fred'] - * - * // using the `_.property` callback shorthand - * _.pluck(_.reject(users, 'active'), 'user'); - * // => ['barney'] - */ - function reject(collection, predicate, thisArg) { - var func = isArray(collection) ? arrayFilter : baseFilter; - predicate = getCallback(predicate, thisArg, 3); - return func(collection, function(value, index, collection) { - return !predicate(value, index, collection); - }); - } - - /** - * Gets a random element or `n` random elements from a collection. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to sample. - * @param {number} [n] The number of elements to sample. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {*} Returns the random sample(s). - * @example - * - * _.sample([1, 2, 3, 4]); - * // => 2 - * - * _.sample([1, 2, 3, 4], 2); - * // => [3, 1] - */ - function sample(collection, n, guard) { - if (guard ? isIterateeCall(collection, n, guard) : n == null) { - collection = toIterable(collection); - var length = collection.length; - return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; - } - var index = -1, - result = toArray(collection), - length = result.length, - lastIndex = length - 1; - - n = nativeMin(n < 0 ? 0 : (+n || 0), length); - while (++index < n) { - var rand = baseRandom(index, lastIndex), - value = result[rand]; - - result[rand] = result[index]; - result[index] = value; - } - result.length = n; - return result; - } - - /** - * Creates an array of shuffled values, using a version of the - * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. - * @example - * - * _.shuffle([1, 2, 3, 4]); - * // => [4, 1, 3, 2] - */ - function shuffle(collection) { - return sample(collection, POSITIVE_INFINITY); - } - - /** - * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable properties for objects. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns the size of `collection`. - * @example - * - * _.size([1, 2, 3]); - * // => 3 - * - * _.size({ 'a': 1, 'b': 2 }); - * // => 2 - * - * _.size('pebbles'); - * // => 7 - */ - function size(collection) { - var length = collection ? getLength(collection) : 0; - return isLength(length) ? length : keys(collection).length; - } - - /** - * Checks if `predicate` returns truthy for **any** element of `collection`. - * The function returns as soon as it finds a passing value and does not iterate - * over the entire collection. The predicate is bound to `thisArg` and invoked - * with three arguments: (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias any - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - * @example - * - * _.some([null, 0, 'yes', false], Boolean); - * // => true - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.some(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // using the `_.matchesProperty` callback shorthand - * _.some(users, 'active', false); - * // => true - * - * // using the `_.property` callback shorthand - * _.some(users, 'active'); - * // => true - */ - function some(collection, predicate, thisArg) { - var func = isArray(collection) ? arraySome : baseSome; - if (thisArg && isIterateeCall(collection, predicate, thisArg)) { - predicate = undefined; - } - if (typeof predicate != 'function' || thisArg !== undefined) { - predicate = getCallback(predicate, thisArg, 3); - } - return func(collection, predicate); - } - - /** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through `iteratee`. This method performs - * a stable sort, that is, it preserves the original sort order of equal elements. - * The `iteratee` is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Array} Returns the new sorted array. - * @example - * - * _.sortBy([1, 2, 3], function(n) { - * return Math.sin(n); - * }); - * // => [3, 1, 2] - * - * _.sortBy([1, 2, 3], function(n) { - * return this.sin(n); - * }, Math); - * // => [3, 1, 2] - * - * var users = [ - * { 'user': 'fred' }, - * { 'user': 'pebbles' }, - * { 'user': 'barney' } - * ]; - * - * // using the `_.property` callback shorthand - * _.pluck(_.sortBy(users, 'user'), 'user'); - * // => ['barney', 'fred', 'pebbles'] - */ - function sortBy(collection, iteratee, thisArg) { - if (collection == null) { - return []; - } - if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { - iteratee = undefined; - } - var index = -1; - iteratee = getCallback(iteratee, thisArg, 3); - - var result = baseMap(collection, function(value, key, collection) { - return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value }; - }); - return baseSortBy(result, compareAscending); - } - - /** - * This method is like `_.sortBy` except that it can sort by multiple iteratees - * or property names. - * - * If a property name is provided for an iteratee the created `_.property` - * style callback returns the property value of the given element. - * - * If an object is provided for an iteratee the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {...(Function|Function[]|Object|Object[]|string|string[])} iteratees - * The iteratees to sort by, specified as individual values or arrays of values. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 42 }, - * { 'user': 'barney', 'age': 34 } - * ]; - * - * _.map(_.sortByAll(users, ['user', 'age']), _.values); - * // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] - * - * _.map(_.sortByAll(users, 'user', function(chr) { - * return Math.floor(chr.age / 10); - * }), _.values); - * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - */ - var sortByAll = restParam(function(collection, iteratees) { - if (collection == null) { - return []; - } - var guard = iteratees[2]; - if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) { - iteratees.length = 1; - } - return baseSortByOrder(collection, baseFlatten(iteratees), []); - }); - - /** - * This method is like `_.sortByAll` except that it allows specifying the - * sort orders of the iteratees to sort by. If `orders` is unspecified, all - * values are sorted in ascending order. Otherwise, a value is sorted in - * ascending order if its corresponding order is "asc", and descending if "desc". - * - * If a property name is provided for an iteratee the created `_.property` - * style callback returns the property value of the given element. - * - * If an object is provided for an iteratee the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {boolean[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 42 }, - * { 'user': 'barney', 'age': 36 } - * ]; - * - * // sort by `user` in ascending order and by `age` in descending order - * _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values); - * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - */ - function sortByOrder(collection, iteratees, orders, guard) { - if (collection == null) { - return []; - } - if (guard && isIterateeCall(iteratees, orders, guard)) { - orders = undefined; - } - if (!isArray(iteratees)) { - iteratees = iteratees == null ? [] : [iteratees]; - } - if (!isArray(orders)) { - orders = orders == null ? [] : [orders]; - } - return baseSortByOrder(collection, iteratees, orders); - } - - /** - * Performs a deep comparison between each element in `collection` and the - * source object, returning an array of all elements that have equivalent - * property values. - * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own, not inherited, enumerable properties. For comparing a single - * own or inherited property value see `_.matchesProperty`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {Object} source The object of property values to match. - * @returns {Array} Returns the new filtered array. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, - * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } - * ]; - * - * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); - * // => ['barney'] - * - * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); - * // => ['fred'] - */ - function where(collection, source) { - return filter(collection, baseMatches(source)); - } - - /*------------------------------------------------------------------------*/ - - /** - * Gets the number of milliseconds that have elapsed since the Unix epoch - * (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @category Date - * @example - * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => logs the number of milliseconds it took for the deferred function to be invoked - */ - var now = nativeNow || function() { - return new Date().getTime(); - }; - - /*------------------------------------------------------------------------*/ - - /** - * The opposite of `_.before`; this method creates a function that invokes - * `func` once it is called `n` or more times. - * - * @static - * @memberOf _ - * @category Function - * @param {number} n The number of calls before `func` is invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var saves = ['profile', 'settings']; - * - * var done = _.after(saves.length, function() { - * console.log('done saving!'); - * }); - * - * _.forEach(saves, function(type) { - * asyncSave({ 'type': type, 'complete': done }); - * }); - * // => logs 'done saving!' after the two async saves have completed - */ - function after(n, func) { - if (typeof func != 'function') { - if (typeof n == 'function') { - var temp = n; - n = func; - func = temp; - } else { - throw new TypeError(FUNC_ERROR_TEXT); - } - } - n = nativeIsFinite(n = +n) ? n : 0; - return function() { - if (--n < 1) { - return func.apply(this, arguments); - } - }; - } - - /** - * Creates a function that accepts up to `n` arguments ignoring any - * additional arguments. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to cap arguments for. - * @param {number} [n=func.length] The arity cap. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new function. - * @example - * - * _.map(['6', '8', '10'], _.ary(parseInt, 1)); - * // => [6, 8, 10] - */ - function ary(func, n, guard) { - if (guard && isIterateeCall(func, n, guard)) { - n = undefined; - } - n = (func && n == null) ? func.length : nativeMax(+n || 0, 0); - return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); - } - - /** - * Creates a function that invokes `func`, with the `this` binding and arguments - * of the created function, while it is called less than `n` times. Subsequent - * calls to the created function return the result of the last `func` invocation. - * - * @static - * @memberOf _ - * @category Function - * @param {number} n The number of calls at which `func` is no longer invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * jQuery('#add').on('click', _.before(5, addContactToList)); - * // => allows adding up to 4 contacts to the list - */ - function before(n, func) { - var result; - if (typeof func != 'function') { - if (typeof n == 'function') { - var temp = n; - n = func; - func = temp; - } else { - throw new TypeError(FUNC_ERROR_TEXT); - } - } - return function() { - if (--n > 0) { - result = func.apply(this, arguments); - } - if (n <= 1) { - func = undefined; - } - return result; - }; - } - - /** - * Creates a function that invokes `func` with the `this` binding of `thisArg` - * and prepends any additional `_.bind` arguments to those provided to the - * bound function. - * - * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for partially applied arguments. - * - * **Note:** Unlike native `Function#bind` this method does not set the "length" - * property of bound functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var greet = function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * }; - * - * var object = { 'user': 'fred' }; - * - * var bound = _.bind(greet, object, 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * // using placeholders - * var bound = _.bind(greet, object, _, '!'); - * bound('hi'); - * // => 'hi fred!' - */ - var bind = restParam(function(func, thisArg, partials) { - var bitmask = BIND_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, bind.placeholder); - bitmask |= PARTIAL_FLAG; - } - return createWrapper(func, bitmask, thisArg, partials, holders); - }); - - /** - * Binds methods of an object to the object itself, overwriting the existing - * method. Method names may be specified as individual arguments or as arrays - * of method names. If no method names are provided all enumerable function - * properties, own and inherited, of `object` are bound. - * - * **Note:** This method does not set the "length" property of bound functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Object} object The object to bind and assign the bound methods to. - * @param {...(string|string[])} [methodNames] The object method names to bind, - * specified as individual method names or arrays of method names. - * @returns {Object} Returns `object`. - * @example - * - * var view = { - * 'label': 'docs', - * 'onClick': function() { - * console.log('clicked ' + this.label); - * } - * }; - * - * _.bindAll(view); - * jQuery('#docs').on('click', view.onClick); - * // => logs 'clicked docs' when the element is clicked - */ - var bindAll = restParam(function(object, methodNames) { - methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); - - var index = -1, - length = methodNames.length; - - while (++index < length) { - var key = methodNames[index]; - object[key] = createWrapper(object[key], BIND_FLAG, object); - } - return object; - }); - - /** - * Creates a function that invokes the method at `object[key]` and prepends - * any additional `_.bindKey` arguments to those provided to the bound function. - * - * This method differs from `_.bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. - * See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) - * for more details. - * - * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * @static - * @memberOf _ - * @category Function - * @param {Object} object The object the method belongs to. - * @param {string} key The key of the method. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var object = { - * 'user': 'fred', - * 'greet': function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * }; - * - * var bound = _.bindKey(object, 'greet', 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * object.greet = function(greeting, punctuation) { - * return greeting + 'ya ' + this.user + punctuation; - * }; - * - * bound('!'); - * // => 'hiya fred!' - * - * // using placeholders - * var bound = _.bindKey(object, 'greet', _, '!'); - * bound('hi'); - * // => 'hiya fred!' - */ - var bindKey = restParam(function(object, key, partials) { - var bitmask = BIND_FLAG | BIND_KEY_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, bindKey.placeholder); - bitmask |= PARTIAL_FLAG; - } - return createWrapper(key, bitmask, object, partials, holders); - }); - - /** - * Creates a function that accepts one or more arguments of `func` that when - * called either invokes `func` returning its result, if all `func` arguments - * have been provided, or returns a function that accepts one or more of the - * remaining `func` arguments, and so on. The arity of `func` may be specified - * if `func.length` is not sufficient. - * - * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for provided arguments. - * - * **Note:** This method does not set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curry(abc); - * - * curried(1)(2)(3); - * // => [1, 2, 3] - * - * curried(1, 2)(3); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] - * - * // using placeholders - * curried(1)(_, 3)(2); - * // => [1, 2, 3] - */ - var curry = createCurry(CURRY_FLAG); - - /** - * This method is like `_.curry` except that arguments are applied to `func` - * in the manner of `_.partialRight` instead of `_.partial`. - * - * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for provided arguments. - * - * **Note:** This method does not set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curryRight(abc); - * - * curried(3)(2)(1); - * // => [1, 2, 3] - * - * curried(2, 3)(1); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] - * - * // using placeholders - * curried(3)(1, _)(2); - * // => [1, 2, 3] - */ - var curryRight = createCurry(CURRY_RIGHT_FLAG); - - /** - * Creates a debounced function that delays invoking `func` until after `wait` - * milliseconds have elapsed since the last time the debounced function was - * invoked. The debounced function comes with a `cancel` method to cancel - * delayed invocations. Provide an options object to indicate that `func` - * should be invoked on the leading and/or trailing edge of the `wait` timeout. - * Subsequent calls to the debounced function return the result of the last - * `func` invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked - * on the trailing edge of the timeout only if the the debounced function is - * invoked more than once during the `wait` timeout. - * - * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) - * for details over the differences between `_.debounce` and `_.throttle`. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to debounce. - * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=false] Specify invoking on the leading - * edge of the timeout. - * @param {number} [options.maxWait] The maximum time `func` is allowed to be - * delayed before it is invoked. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example - * - * // avoid costly calculations while the window size is in flux - * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); - * - * // invoke `sendMail` when the click event is fired, debouncing subsequent calls - * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * })); - * - * // ensure `batchLog` is invoked once after 1 second of debounced calls - * var source = new EventSource('/stream'); - * jQuery(source).on('message', _.debounce(batchLog, 250, { - * 'maxWait': 1000 - * })); - * - * // cancel a debounced call - * var todoChanges = _.debounce(batchLog, 1000); - * Object.observe(models.todo, todoChanges); - * - * Object.observe(models, function(changes) { - * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) { - * todoChanges.cancel(); - * } - * }, ['delete']); - * - * // ...at some point `models.todo` is changed - * models.todo.completed = true; - * - * // ...before 1 second has passed `models.todo` is deleted - * // which cancels the debounced `todoChanges` call - * delete models.todo; - */ - function debounce(func, wait, options) { - var args, - maxTimeoutId, - result, - stamp, - thisArg, - timeoutId, - trailingCall, - lastCalled = 0, - maxWait = false, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - wait = wait < 0 ? 0 : (+wait || 0); - if (options === true) { - var leading = true; - trailing = false; - } else if (isObject(options)) { - leading = !!options.leading; - maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait); - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - - function cancel() { - if (timeoutId) { - clearTimeout(timeoutId); - } - if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - } - lastCalled = 0; - maxTimeoutId = timeoutId = trailingCall = undefined; - } - - function complete(isCalled, id) { - if (id) { - clearTimeout(id); - } - maxTimeoutId = timeoutId = trailingCall = undefined; - if (isCalled) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = undefined; - } - } - } - - function delayed() { - var remaining = wait - (now() - stamp); - if (remaining <= 0 || remaining > wait) { - complete(trailingCall, maxTimeoutId); - } else { - timeoutId = setTimeout(delayed, remaining); - } - } - - function maxDelayed() { - complete(trailing, timeoutId); - } - - function debounced() { - args = arguments; - stamp = now(); - thisArg = this; - trailingCall = trailing && (timeoutId || !leading); - - if (maxWait === false) { - var leadingCall = leading && !timeoutId; - } else { - if (!maxTimeoutId && !leading) { - lastCalled = stamp; - } - var remaining = maxWait - (stamp - lastCalled), - isCalled = remaining <= 0 || remaining > maxWait; - - if (isCalled) { - if (maxTimeoutId) { - maxTimeoutId = clearTimeout(maxTimeoutId); - } - lastCalled = stamp; - result = func.apply(thisArg, args); - } - else if (!maxTimeoutId) { - maxTimeoutId = setTimeout(maxDelayed, remaining); - } - } - if (isCalled && timeoutId) { - timeoutId = clearTimeout(timeoutId); - } - else if (!timeoutId && wait !== maxWait) { - timeoutId = setTimeout(delayed, wait); - } - if (leadingCall) { - isCalled = true; - result = func.apply(thisArg, args); - } - if (isCalled && !timeoutId && !maxTimeoutId) { - args = thisArg = undefined; - } - return result; - } - debounced.cancel = cancel; - return debounced; - } - - /** - * Defers invoking the `func` until the current call stack has cleared. Any - * additional arguments are provided to `func` when it is invoked. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to defer. - * @param {...*} [args] The arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.defer(function(text) { - * console.log(text); - * }, 'deferred'); - * // logs 'deferred' after one or more milliseconds - */ - var defer = restParam(function(func, args) { - return baseDelay(func, 1, args); - }); - - /** - * Invokes `func` after `wait` milliseconds. Any additional arguments are - * provided to `func` when it is invoked. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {...*} [args] The arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.delay(function(text) { - * console.log(text); - * }, 1000, 'later'); - * // => logs 'later' after one second - */ - var delay = restParam(function(func, wait, args) { - return baseDelay(func, wait, args); - }); - - /** - * Creates a function that returns the result of invoking the provided - * functions with the `this` binding of the created function, where each - * successive invocation is supplied the return value of the previous. - * - * @static - * @memberOf _ - * @category Function - * @param {...Function} [funcs] Functions to invoke. - * @returns {Function} Returns the new function. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var addSquare = _.flow(_.add, square); - * addSquare(1, 2); - * // => 9 - */ - var flow = createFlow(); - - /** - * This method is like `_.flow` except that it creates a function that - * invokes the provided functions from right to left. - * - * @static - * @memberOf _ - * @alias backflow, compose - * @category Function - * @param {...Function} [funcs] Functions to invoke. - * @returns {Function} Returns the new function. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var addSquare = _.flowRight(square, _.add); - * addSquare(1, 2); - * // => 9 - */ - var flowRight = createFlow(true); - - /** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is coerced to a string and used as the - * cache key. The `func` is invoked with the `this` binding of the memoized - * function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) - * method interface of `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoizing function. - * @example - * - * var upperCase = _.memoize(function(string) { - * return string.toUpperCase(); - * }); - * - * upperCase('fred'); - * // => 'FRED' - * - * // modifying the result cache - * upperCase.cache.set('fred', 'BARNEY'); - * upperCase('fred'); - * // => 'BARNEY' - * - * // replacing `_.memoize.Cache` - * var object = { 'user': 'fred' }; - * var other = { 'user': 'barney' }; - * var identity = _.memoize(_.identity); - * - * identity(object); - * // => { 'user': 'fred' } - * identity(other); - * // => { 'user': 'fred' } - * - * _.memoize.Cache = WeakMap; - * var identity = _.memoize(_.identity); - * - * identity(object); - * // => { 'user': 'fred' } - * identity(other); - * // => { 'user': 'barney' } - */ - function memoize(func, resolver) { - if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; - - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result); - return result; - }; - memoized.cache = new memoize.Cache; - return memoized; - } - - /** - * Creates a function that runs each argument through a corresponding - * transform function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms] The functions to transform - * arguments, specified as individual functions or arrays of functions. - * @returns {Function} Returns the new function. - * @example - * - * function doubled(n) { - * return n * 2; - * } - * - * function square(n) { - * return n * n; - * } - * - * var modded = _.modArgs(function(x, y) { - * return [x, y]; - * }, square, doubled); - * - * modded(1, 2); - * // => [1, 4] - * - * modded(5, 10); - * // => [25, 20] - */ - var modArgs = restParam(function(func, transforms) { - transforms = baseFlatten(transforms); - if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var length = transforms.length; - return restParam(function(args) { - var index = nativeMin(args.length, length); - while (index--) { - args[index] = transforms[index](args[index]); - } - return func.apply(this, args); - }); - }); - - /** - * Creates a function that negates the result of the predicate `func`. The - * `func` predicate is invoked with the `this` binding and arguments of the - * created function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} predicate The predicate to negate. - * @returns {Function} Returns the new function. - * @example - * - * function isEven(n) { - * return n % 2 == 0; - * } - * - * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); - * // => [1, 3, 5] - */ - function negate(predicate) { - if (typeof predicate != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - return !predicate.apply(this, arguments); - }; - } - - /** - * Creates a function that is restricted to invoking `func` once. Repeat calls - * to the function return the value of the first call. The `func` is invoked - * with the `this` binding and arguments of the created function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var initialize = _.once(createApplication); - * initialize(); - * initialize(); - * // `initialize` invokes `createApplication` once - */ - function once(func) { - return before(2, func); - } - - /** - * Creates a function that invokes `func` with `partial` arguments prepended - * to those provided to the new function. This method is like `_.bind` except - * it does **not** alter the `this` binding. - * - * The `_.partial.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method does not set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var greet = function(greeting, name) { - * return greeting + ' ' + name; - * }; - * - * var sayHelloTo = _.partial(greet, 'hello'); - * sayHelloTo('fred'); - * // => 'hello fred' - * - * // using placeholders - * var greetFred = _.partial(greet, _, 'fred'); - * greetFred('hi'); - * // => 'hi fred' - */ - var partial = createPartial(PARTIAL_FLAG); - - /** - * This method is like `_.partial` except that partially applied arguments - * are appended to those provided to the new function. - * - * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method does not set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var greet = function(greeting, name) { - * return greeting + ' ' + name; - * }; - * - * var greetFred = _.partialRight(greet, 'fred'); - * greetFred('hi'); - * // => 'hi fred' - * - * // using placeholders - * var sayHelloTo = _.partialRight(greet, 'hello', _); - * sayHelloTo('fred'); - * // => 'hello fred' - */ - var partialRight = createPartial(PARTIAL_RIGHT_FLAG); - - /** - * Creates a function that invokes `func` with arguments arranged according - * to the specified indexes where the argument value at the first index is - * provided as the first argument, the argument value at the second index is - * provided as the second argument, and so on. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to rearrange arguments for. - * @param {...(number|number[])} indexes The arranged argument indexes, - * specified as individual indexes or arrays of indexes. - * @returns {Function} Returns the new function. - * @example - * - * var rearged = _.rearg(function(a, b, c) { - * return [a, b, c]; - * }, 2, 0, 1); - * - * rearged('b', 'c', 'a') - * // => ['a', 'b', 'c'] - * - * var map = _.rearg(_.map, [1, 0]); - * map(function(n) { - * return n * 3; - * }, [1, 2, 3]); - * // => [3, 6, 9] - */ - var rearg = restParam(function(func, indexes) { - return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); - }); - - /** - * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as an array. - * - * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.restParam(function(what, names) { - * return what + ' ' + _.initial(names).join(', ') + - * (_.size(names) > 1 ? ', & ' : '') + _.last(names); - * }); - * - * say('hello', 'fred', 'barney', 'pebbles'); - * // => 'hello fred, barney, & pebbles' - */ - function restParam(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - rest = Array(length); - - while (++index < length) { - rest[index] = args[start + index]; - } - switch (start) { - case 0: return func.call(this, rest); - case 1: return func.call(this, args[0], rest); - case 2: return func.call(this, args[0], args[1], rest); - } - var otherArgs = Array(start + 1); - index = -1; - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = rest; - return func.apply(this, otherArgs); - }; - } - - /** - * Creates a function that invokes `func` with the `this` binding of the created - * function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3). - * - * **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator). - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to spread arguments over. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.spread(function(who, what) { - * return who + ' says ' + what; - * }); - * - * say(['fred', 'hello']); - * // => 'fred says hello' - * - * // with a Promise - * var numbers = Promise.all([ - * Promise.resolve(40), - * Promise.resolve(36) - * ]); - * - * numbers.then(_.spread(function(x, y) { - * return x + y; - * })); - * // => a Promise of 76 - */ - function spread(func) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function(array) { - return func.apply(this, array); - }; - } - - /** - * Creates a throttled function that only invokes `func` at most once per - * every `wait` milliseconds. The throttled function comes with a `cancel` - * method to cancel delayed invocations. Provide an options object to indicate - * that `func` should be invoked on the leading and/or trailing edge of the - * `wait` timeout. Subsequent calls to the throttled function return the - * result of the last `func` call. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked - * on the trailing edge of the timeout only if the the throttled function is - * invoked more than once during the `wait` timeout. - * - * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) - * for details over the differences between `_.throttle` and `_.debounce`. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to throttle. - * @param {number} [wait=0] The number of milliseconds to throttle invocations to. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=true] Specify invoking on the leading - * edge of the timeout. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. - * @returns {Function} Returns the new throttled function. - * @example - * - * // avoid excessively updating the position while scrolling - * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); - * - * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); - * - * // cancel a trailing throttled call - * jQuery(window).on('popstate', throttled.cancel); - */ - function throttle(func, wait, options) { - var leading = true, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (options === false) { - leading = false; - } else if (isObject(options)) { - leading = 'leading' in options ? !!options.leading : leading; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing }); - } - - /** - * Creates a function that provides `value` to the wrapper function as its - * first argument. Any additional arguments provided to the function are - * appended to those provided to the wrapper function. The wrapper is invoked - * with the `this` binding of the created function. - * - * @static - * @memberOf _ - * @category Function - * @param {*} value The value to wrap. - * @param {Function} wrapper The wrapper function. - * @returns {Function} Returns the new function. - * @example - * - * var p = _.wrap(_.escape, function(func, text) { - * return '

' + func(text) + '

'; - * }); - * - * p('fred, barney, & pebbles'); - * // => '

fred, barney, & pebbles

' - */ - function wrap(value, wrapper) { - wrapper = wrapper == null ? identity : wrapper; - return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []); - } - - /*------------------------------------------------------------------------*/ - - /** - * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, - * otherwise they are assigned by reference. If `customizer` is provided it is - * invoked to produce the cloned values. If `customizer` returns `undefined` - * cloning is handled by the method instead. The `customizer` is bound to - * `thisArg` and invoked with two argument; (value [, index|key, object]). - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). - * The enumerable properties of `arguments` objects and objects created by - * constructors other than `Object` are cloned to plain `Object` objects. An - * empty object is returned for uncloneable values such as functions, DOM nodes, - * Maps, Sets, and WeakMaps. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @param {Function} [customizer] The function to customize cloning values. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {*} Returns the cloned value. - * @example - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; - * - * var shallow = _.clone(users); - * shallow[0] === users[0]; - * // => true - * - * var deep = _.clone(users, true); - * deep[0] === users[0]; - * // => false - * - * // using a customizer callback - * var el = _.clone(document.body, function(value) { - * if (_.isElement(value)) { - * return value.cloneNode(false); - * } - * }); - * - * el === document.body - * // => false - * el.nodeName - * // => BODY - * el.childNodes.length; - * // => 0 - */ - function clone(value, isDeep, customizer, thisArg) { - if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) { - isDeep = false; - } - else if (typeof isDeep == 'function') { - thisArg = customizer; - customizer = isDeep; - isDeep = false; - } - return typeof customizer == 'function' - ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1)) - : baseClone(value, isDeep); - } - - /** - * Creates a deep clone of `value`. If `customizer` is provided it is invoked - * to produce the cloned values. If `customizer` returns `undefined` cloning - * is handled by the method instead. The `customizer` is bound to `thisArg` - * and invoked with two argument; (value [, index|key, object]). - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). - * The enumerable properties of `arguments` objects and objects created by - * constructors other than `Object` are cloned to plain `Object` objects. An - * empty object is returned for uncloneable values such as functions, DOM nodes, - * Maps, Sets, and WeakMaps. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to deep clone. - * @param {Function} [customizer] The function to customize cloning values. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {*} Returns the deep cloned value. - * @example - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; - * - * var deep = _.cloneDeep(users); - * deep[0] === users[0]; - * // => false - * - * // using a customizer callback - * var el = _.cloneDeep(document.body, function(value) { - * if (_.isElement(value)) { - * return value.cloneNode(true); - * } - * }); - * - * el === document.body - * // => false - * el.nodeName - * // => BODY - * el.childNodes.length; - * // => 20 - */ - function cloneDeep(value, customizer, thisArg) { - return typeof customizer == 'function' - ? baseClone(value, true, bindCallback(customizer, thisArg, 1)) - : baseClone(value, true); - } - - /** - * Checks if `value` is greater than `other`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`. - * @example - * - * _.gt(3, 1); - * // => true - * - * _.gt(3, 3); - * // => false - * - * _.gt(1, 3); - * // => false - */ - function gt(value, other) { - return value > other; - } - - /** - * Checks if `value` is greater than or equal to `other`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`. - * @example - * - * _.gte(3, 1); - * // => true - * - * _.gte(3, 3); - * // => true - * - * _.gte(1, 3); - * // => false - */ - function gte(value, other) { - return value >= other; - } - - /** - * Checks if `value` is classified as an `arguments` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ - function isArguments(value) { - return isObjectLike(value) && isArrayLike(value) && - hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); - } - - /** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(function() { return arguments; }()); - * // => false - */ - var isArray = nativeIsArray || function(value) { - return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; - }; - - /** - * Checks if `value` is classified as a boolean primitive or object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isBoolean(false); - * // => true - * - * _.isBoolean(null); - * // => false - */ - function isBoolean(value) { - return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag); - } - - /** - * Checks if `value` is classified as a `Date` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isDate(new Date); - * // => true - * - * _.isDate('Mon April 23 2012'); - * // => false - */ - function isDate(value) { - return isObjectLike(value) && objToString.call(value) == dateTag; - } - - /** - * Checks if `value` is a DOM element. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. - * @example - * - * _.isElement(document.body); - * // => true - * - * _.isElement(''); - * // => false - */ - function isElement(value) { - return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); - } - - /** - * Checks if `value` is empty. A value is considered empty unless it is an - * `arguments` object, array, string, or jQuery-like collection with a length - * greater than `0` or an object with own enumerable properties. - * - * @static - * @memberOf _ - * @category Lang - * @param {Array|Object|string} value The value to inspect. - * @returns {boolean} Returns `true` if `value` is empty, else `false`. - * @example - * - * _.isEmpty(null); - * // => true - * - * _.isEmpty(true); - * // => true - * - * _.isEmpty(1); - * // => true - * - * _.isEmpty([1, 2, 3]); - * // => false - * - * _.isEmpty({ 'a': 1 }); - * // => false - */ - function isEmpty(value) { - if (value == null) { - return true; - } - if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || - (isObjectLike(value) && isFunction(value.splice)))) { - return !value.length; - } - return !keys(value).length; - } - - /** - * Performs a deep comparison between two values to determine if they are - * equivalent. If `customizer` is provided it is invoked to compare values. - * If `customizer` returns `undefined` comparisons are handled by the method - * instead. The `customizer` is bound to `thisArg` and invoked with three - * arguments: (value, other [, index|key]). - * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own, not inherited, enumerable properties. Functions and DOM nodes - * are **not** supported. Provide a customizer function to extend support - * for comparing other values. - * - * @static - * @memberOf _ - * @alias eq - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize value comparisons. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'user': 'fred' }; - * var other = { 'user': 'fred' }; - * - * object == other; - * // => false - * - * _.isEqual(object, other); - * // => true - * - * // using a customizer callback - * var array = ['hello', 'goodbye']; - * var other = ['hi', 'goodbye']; - * - * _.isEqual(array, other, function(value, other) { - * if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { - * return true; - * } - * }); - * // => true - */ - function isEqual(value, other, customizer, thisArg) { - customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; - var result = customizer ? customizer(value, other) : undefined; - return result === undefined ? baseIsEqual(value, other, customizer) : !!result; - } - - /** - * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, - * `SyntaxError`, `TypeError`, or `URIError` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. - * @example - * - * _.isError(new Error); - * // => true - * - * _.isError(Error); - * // => false - */ - function isError(value) { - return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag; - } - - /** - * Checks if `value` is a finite primitive number. - * - * **Note:** This method is based on [`Number.isFinite`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite). - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. - * @example - * - * _.isFinite(10); - * // => true - * - * _.isFinite('10'); - * // => false - * - * _.isFinite(true); - * // => false - * - * _.isFinite(Object(10)); - * // => false - * - * _.isFinite(Infinity); - * // => false - */ - function isFinite(value) { - return typeof value == 'number' && nativeIsFinite(value); - } - - /** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ - function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in older versions of Chrome and Safari which return 'function' for regexes - // and Safari 8 equivalents which return 'object' for typed array constructors. - return isObject(value) && objToString.call(value) == funcTag; - } - - /** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ - function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); - } - - /** - * Performs a deep comparison between `object` and `source` to determine if - * `object` contains equivalent property values. If `customizer` is provided - * it is invoked to compare values. If `customizer` returns `undefined` - * comparisons are handled by the method instead. The `customizer` is bound - * to `thisArg` and invoked with three arguments: (value, other, index|key). - * - * **Note:** This method supports comparing properties of arrays, booleans, - * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions - * and DOM nodes are **not** supported. Provide a customizer function to extend - * support for comparing other values. - * - * @static - * @memberOf _ - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Function} [customizer] The function to customize value comparisons. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * var object = { 'user': 'fred', 'age': 40 }; - * - * _.isMatch(object, { 'age': 40 }); - * // => true - * - * _.isMatch(object, { 'age': 36 }); - * // => false - * - * // using a customizer callback - * var object = { 'greeting': 'hello' }; - * var source = { 'greeting': 'hi' }; - * - * _.isMatch(object, source, function(value, other) { - * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; - * }); - * // => true - */ - function isMatch(object, source, customizer, thisArg) { - customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; - return baseIsMatch(object, getMatchData(source), customizer); - } - - /** - * Checks if `value` is `NaN`. - * - * **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4) - * which returns `true` for `undefined` and other non-numeric values. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - * @example - * - * _.isNaN(NaN); - * // => true - * - * _.isNaN(new Number(NaN)); - * // => true - * - * isNaN(undefined); - * // => true - * - * _.isNaN(undefined); - * // => false - */ - function isNaN(value) { - // An `NaN` primitive is the only value that is not equal to itself. - // Perform the `toStringTag` check first to avoid errors with some host objects in IE. - return isNumber(value) && value != +value; - } - - /** - * Checks if `value` is a native function. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ - function isNative(value) { - if (value == null) { - return false; - } - if (isFunction(value)) { - return reIsNative.test(fnToString.call(value)); - } - return isObjectLike(value) && reIsHostCtor.test(value); - } - - /** - * Checks if `value` is `null`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `null`, else `false`. - * @example - * - * _.isNull(null); - * // => true - * - * _.isNull(void 0); - * // => false - */ - function isNull(value) { - return value === null; - } - - /** - * Checks if `value` is classified as a `Number` primitive or object. - * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified - * as numbers, use the `_.isFinite` method. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isNumber(8.4); - * // => true - * - * _.isNumber(NaN); - * // => true - * - * _.isNumber('8.4'); - * // => false - */ - function isNumber(value) { - return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag); - } - - /** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * **Note:** This method assumes objects created by the `Object` constructor - * have no inherited enumerable properties. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * _.isPlainObject(new Foo); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - * - * _.isPlainObject(Object.create(null)); - * // => true - */ - function isPlainObject(value) { - var Ctor; - - // Exit early for non `Object` objects. - if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) || - (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) { - return false; - } - // IE < 9 iterates inherited properties before own properties. If the first - // iterated property is an object's own property then there are no inherited - // enumerable properties. - var result; - // In most environments an object's own properties are iterated before - // its inherited properties. If the last iterated property is an object's - // own property then there are no inherited enumerable properties. - baseForIn(value, function(subValue, key) { - result = key; - }); - return result === undefined || hasOwnProperty.call(value, result); - } - - /** - * Checks if `value` is classified as a `RegExp` object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isRegExp(/abc/); - * // => true - * - * _.isRegExp('/abc/'); - * // => false - */ - function isRegExp(value) { - return isObject(value) && objToString.call(value) == regexpTag; - } - - /** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ - function isString(value) { - return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag); - } - - /** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ - function isTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; - } - - /** - * Checks if `value` is `undefined`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. - * @example - * - * _.isUndefined(void 0); - * // => true - * - * _.isUndefined(null); - * // => false - */ - function isUndefined(value) { - return value === undefined; - } - - /** - * Checks if `value` is less than `other`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`. - * @example - * - * _.lt(1, 3); - * // => true - * - * _.lt(3, 3); - * // => false - * - * _.lt(3, 1); - * // => false - */ - function lt(value, other) { - return value < other; - } - - /** - * Checks if `value` is less than or equal to `other`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than or equal to `other`, else `false`. - * @example - * - * _.lte(1, 3); - * // => true - * - * _.lte(3, 3); - * // => true - * - * _.lte(3, 1); - * // => false - */ - function lte(value, other) { - return value <= other; - } - - /** - * Converts `value` to an array. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {Array} Returns the converted array. - * @example - * - * (function() { - * return _.toArray(arguments).slice(1); - * }(1, 2, 3)); - * // => [2, 3] - */ - function toArray(value) { - var length = value ? getLength(value) : 0; - if (!isLength(length)) { - return values(value); - } - if (!length) { - return []; - } - return arrayCopy(value); - } - - /** - * Converts `value` to a plain object flattening inherited enumerable - * properties of `value` to own properties of the plain object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {Object} Returns the converted plain object. - * @example - * - * function Foo() { - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.assign({ 'a': 1 }, new Foo); - * // => { 'a': 1, 'b': 2 } - * - * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); - * // => { 'a': 1, 'b': 2, 'c': 3 } - */ - function toPlainObject(value) { - return baseCopy(value, keysIn(value)); - } - - /*------------------------------------------------------------------------*/ - - /** - * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `undefined` into the destination object. Subsequent sources - * overwrite property assignments of previous sources. If `customizer` is - * provided it is invoked to produce the merged values of the destination and - * source properties. If `customizer` returns `undefined` merging is handled - * by the method instead. The `customizer` is bound to `thisArg` and invoked - * with five arguments: (objectValue, sourceValue, key, object, source). - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {Object} Returns `object`. - * @example - * - * var users = { - * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }] - * }; - * - * var ages = { - * 'data': [{ 'age': 36 }, { 'age': 40 }] - * }; - * - * _.merge(users, ages); - * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } - * - * // using a customizer callback - * var object = { - * 'fruits': ['apple'], - * 'vegetables': ['beet'] - * }; - * - * var other = { - * 'fruits': ['banana'], - * 'vegetables': ['carrot'] - * }; - * - * _.merge(object, other, function(a, b) { - * if (_.isArray(a)) { - * return a.concat(b); - * } - * }); - * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } - */ - var merge = createAssigner(baseMerge); - - /** - * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources overwrite property assignments of previous sources. - * If `customizer` is provided it is invoked to produce the assigned values. - * The `customizer` is bound to `thisArg` and invoked with five arguments: - * (objectValue, sourceValue, key, object, source). - * - * **Note:** This method mutates `object` and is based on - * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). - * - * @static - * @memberOf _ - * @alias extend - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {Object} Returns `object`. - * @example - * - * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); - * // => { 'user': 'fred', 'age': 40 } - * - * // using a customizer callback - * var defaults = _.partialRight(_.assign, function(value, other) { - * return _.isUndefined(value) ? other : value; - * }); - * - * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); - * // => { 'user': 'barney', 'age': 36 } - */ - var assign = createAssigner(function(object, source, customizer) { - return customizer - ? assignWith(object, source, customizer) - : baseAssign(object, source); - }); - - /** - * Creates an object that inherits from the given `prototype` object. If a - * `properties` object is provided its own enumerable properties are assigned - * to the created object. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { - * 'constructor': Circle - * }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true - * - * circle instanceof Shape; - * // => true - */ - function create(prototype, properties, guard) { - var result = baseCreate(prototype); - if (guard && isIterateeCall(prototype, properties, guard)) { - properties = undefined; - } - return properties ? baseAssign(result, properties) : result; - } - - /** - * Assigns own enumerable properties of source object(s) to the destination - * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional values of the same property are ignored. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); - * // => { 'user': 'barney', 'age': 36 } - */ - var defaults = createDefaults(assign, assignDefaults); - - /** - * This method is like `_.defaults` except that it recursively assigns - * default properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } }); - * // => { 'user': { 'name': 'barney', 'age': 36 } } - * - */ - var defaultsDeep = createDefaults(merge, mergeDefaults); - - /** - * This method is like `_.find` except that it returns the key of the first - * element `predicate` returns truthy for instead of the element itself. - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {string|undefined} Returns the key of the matched element, else `undefined`. - * @example - * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * }; - * - * _.findKey(users, function(chr) { - * return chr.age < 40; - * }); - * // => 'barney' (iteration order is not guaranteed) - * - * // using the `_.matches` callback shorthand - * _.findKey(users, { 'age': 1, 'active': true }); - * // => 'pebbles' - * - * // using the `_.matchesProperty` callback shorthand - * _.findKey(users, 'active', false); - * // => 'fred' - * - * // using the `_.property` callback shorthand - * _.findKey(users, 'active'); - * // => 'barney' - */ - var findKey = createFindKey(baseForOwn); - - /** - * This method is like `_.findKey` except that it iterates over elements of - * a collection in the opposite order. - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {string|undefined} Returns the key of the matched element, else `undefined`. - * @example - * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * }; - * - * _.findLastKey(users, function(chr) { - * return chr.age < 40; - * }); - * // => returns `pebbles` assuming `_.findKey` returns `barney` - * - * // using the `_.matches` callback shorthand - * _.findLastKey(users, { 'age': 36, 'active': true }); - * // => 'barney' - * - * // using the `_.matchesProperty` callback shorthand - * _.findLastKey(users, 'active', false); - * // => 'fred' - * - * // using the `_.property` callback shorthand - * _.findLastKey(users, 'active'); - * // => 'pebbles' - */ - var findLastKey = createFindKey(baseForOwnRight); - - /** - * Iterates over own and inherited enumerable properties of an object invoking - * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked - * with three arguments: (value, key, object). Iteratee functions may exit - * iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns `object`. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forIn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => logs 'a', 'b', and 'c' (iteration order is not guaranteed) - */ - var forIn = createForIn(baseFor); - - /** - * This method is like `_.forIn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns `object`. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forInRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c' - */ - var forInRight = createForIn(baseForRight); - - /** - * Iterates over own enumerable properties of an object invoking `iteratee` - * for each property. The `iteratee` is bound to `thisArg` and invoked with - * three arguments: (value, key, object). Iteratee functions may exit iteration - * early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns `object`. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forOwn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => logs 'a' and 'b' (iteration order is not guaranteed) - */ - var forOwn = createForOwn(baseForOwn); - - /** - * This method is like `_.forOwn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns `object`. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forOwnRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' - */ - var forOwnRight = createForOwn(baseForOwnRight); - - /** - * Creates an array of function property names from all enumerable properties, - * own and inherited, of `object`. - * - * @static - * @memberOf _ - * @alias methods - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the new array of property names. - * @example - * - * _.functions(_); - * // => ['after', 'ary', 'assign', ...] - */ - function functions(object) { - return baseFunctions(object, keysIn(object)); - } - - /** - * Gets the property value at `path` of `object`. If the resolved value is - * `undefined` the `defaultValue` is used in its place. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 - * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' - */ - function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, toPath(path), path + ''); - return result === undefined ? defaultValue : result; - } - - /** - * Checks if `path` is a direct property. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` is a direct property, else `false`. - * @example - * - * var object = { 'a': { 'b': { 'c': 3 } } }; - * - * _.has(object, 'a'); - * // => true - * - * _.has(object, 'a.b.c'); - * // => true - * - * _.has(object, ['a', 'b', 'c']); - * // => true - */ - function has(object, path) { - if (object == null) { - return false; - } - var result = hasOwnProperty.call(object, path); - if (!result && !isKey(path)) { - path = toPath(path); - object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); - if (object == null) { - return false; - } - path = last(path); - result = hasOwnProperty.call(object, path); - } - return result || (isLength(object.length) && isIndex(path, object.length) && - (isArray(object) || isArguments(object))); - } - - /** - * Creates an object composed of the inverted keys and values of `object`. - * If `object` contains duplicate values, subsequent values overwrite property - * assignments of previous values unless `multiValue` is `true`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to invert. - * @param {boolean} [multiValue] Allow multiple values per key. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Object} Returns the new inverted object. - * @example - * - * var object = { 'a': 1, 'b': 2, 'c': 1 }; - * - * _.invert(object); - * // => { '1': 'c', '2': 'b' } - * - * // with `multiValue` - * _.invert(object, true); - * // => { '1': ['a', 'c'], '2': ['b'] } - */ - function invert(object, multiValue, guard) { - if (guard && isIterateeCall(object, multiValue, guard)) { - multiValue = undefined; - } - var index = -1, - props = keys(object), - length = props.length, - result = {}; - - while (++index < length) { - var key = props[index], - value = object[key]; - - if (multiValue) { - if (hasOwnProperty.call(result, value)) { - result[value].push(key); - } else { - result[value] = [key]; - } - } - else { - result[value] = key; - } - } - return result; - } - - /** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) - * for more details. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ - var keys = !nativeKeys ? shimKeys : function(object) { - var Ctor = object == null ? undefined : object.constructor; - if ((typeof Ctor == 'function' && Ctor.prototype === object) || - (typeof object != 'function' && isArrayLike(object))) { - return shimKeys(object); - } - return isObject(object) ? nativeKeys(object) : []; - }; - - /** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ - function keysIn(object) { - if (object == null) { - return []; - } - if (!isObject(object)) { - object = Object(object); - } - var length = object.length; - length = (length && isLength(length) && - (isArray(object) || isArguments(object)) && length) || 0; - - var Ctor = object.constructor, - index = -1, - isProto = typeof Ctor == 'function' && Ctor.prototype === object, - result = Array(length), - skipIndexes = length > 0; - - while (++index < length) { - result[index] = (index + ''); - } - for (var key in object) { - if (!(skipIndexes && isIndex(key, length)) && - !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; - } - - /** - * The opposite of `_.mapValues`; this method creates an object with the - * same values as `object` and keys generated by running each own enumerable - * property of `object` through `iteratee`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the new mapped object. - * @example - * - * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { - * return key + value; - * }); - * // => { 'a1': 1, 'b2': 2 } - */ - var mapKeys = createObjectMapper(true); - - /** - * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through `iteratee`. The - * iteratee function is bound to `thisArg` and invoked with three arguments: - * (value, key, object). - * - * If a property name is provided for `iteratee` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `iteratee` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {Object} Returns the new mapped object. - * @example - * - * _.mapValues({ 'a': 1, 'b': 2 }, function(n) { - * return n * 3; - * }); - * // => { 'a': 3, 'b': 6 } - * - * var users = { - * 'fred': { 'user': 'fred', 'age': 40 }, - * 'pebbles': { 'user': 'pebbles', 'age': 1 } - * }; - * - * // using the `_.property` callback shorthand - * _.mapValues(users, 'age'); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) - */ - var mapValues = createObjectMapper(); - - /** - * The opposite of `_.pick`; this method creates an object composed of the - * own and inherited enumerable properties of `object` that are not omitted. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {Function|...(string|string[])} [predicate] The function invoked per - * iteration or property names to omit, specified as individual property - * names or arrays of property names. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'user': 'fred', 'age': 40 }; - * - * _.omit(object, 'age'); - * // => { 'user': 'fred' } - * - * _.omit(object, _.isNumber); - * // => { 'user': 'fred' } - */ - var omit = restParam(function(object, props) { - if (object == null) { - return {}; - } - if (typeof props[0] != 'function') { - var props = arrayMap(baseFlatten(props), String); - return pickByArray(object, baseDifference(keysIn(object), props)); - } - var predicate = bindCallback(props[0], props[1], 3); - return pickByCallback(object, function(value, key, object) { - return !predicate(value, key, object); - }); - }); - - /** - * Creates a two dimensional array of the key-value pairs for `object`, - * e.g. `[[key1, value1], [key2, value2]]`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the new array of key-value pairs. - * @example - * - * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) - */ - function pairs(object) { - object = toObject(object); - - var index = -1, - props = keys(object), - length = props.length, - result = Array(length); - - while (++index < length) { - var key = props[index]; - result[index] = [key, object[key]]; - } - return result; - } - - /** - * Creates an object composed of the picked `object` properties. Property - * names may be specified as individual arguments or as arrays of property - * names. If `predicate` is provided it is invoked for each property of `object` - * picking the properties `predicate` returns truthy for. The predicate is - * bound to `thisArg` and invoked with three arguments: (value, key, object). - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {Function|...(string|string[])} [predicate] The function invoked per - * iteration or property names to pick, specified as individual property - * names or arrays of property names. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'user': 'fred', 'age': 40 }; - * - * _.pick(object, 'user'); - * // => { 'user': 'fred' } - * - * _.pick(object, _.isString); - * // => { 'user': 'fred' } - */ - var pick = restParam(function(object, props) { - if (object == null) { - return {}; - } - return typeof props[0] == 'function' - ? pickByCallback(object, bindCallback(props[0], props[1], 3)) - : pickByArray(object, baseFlatten(props)); - }); - - /** - * This method is like `_.get` except that if the resolved value is a function - * it is invoked with the `this` binding of its parent object and its result - * is returned. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; - * - * _.result(object, 'a[0].b.c1'); - * // => 3 - * - * _.result(object, 'a[0].b.c2'); - * // => 4 - * - * _.result(object, 'a.b.c', 'default'); - * // => 'default' - * - * _.result(object, 'a.b.c', _.constant('default')); - * // => 'default' - */ - function result(object, path, defaultValue) { - var result = object == null ? undefined : object[path]; - if (result === undefined) { - if (object != null && !isKey(path, object)) { - path = toPath(path); - object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); - result = object == null ? undefined : object[last(path)]; - } - result = result === undefined ? defaultValue : result; - } - return isFunction(result) ? result.call(object) : result; - } - - /** - * Sets the property value of `path` on `object`. If a portion of `path` - * does not exist it is created. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to augment. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @returns {Object} Returns `object`. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.set(object, 'a[0].b.c', 4); - * console.log(object.a[0].b.c); - * // => 4 - * - * _.set(object, 'x[0].y.z', 5); - * console.log(object.x[0].y.z); - * // => 5 - */ - function set(object, path, value) { - if (object == null) { - return object; - } - var pathKey = (path + ''); - path = (object[pathKey] != null || isKey(path, object)) ? [pathKey] : toPath(path); - - var index = -1, - length = path.length, - lastIndex = length - 1, - nested = object; - - while (nested != null && ++index < length) { - var key = path[index]; - if (isObject(nested)) { - if (index == lastIndex) { - nested[key] = value; - } else if (nested[key] == null) { - nested[key] = isIndex(path[index + 1]) ? [] : {}; - } - } - nested = nested[key]; - } - return object; - } - - /** - * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own enumerable - * properties through `iteratee`, with each invocation potentially mutating - * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked - * with four arguments: (accumulator, value, key, object). Iteratee functions - * may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @category Object - * @param {Array|Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the accumulated value. - * @example - * - * _.transform([2, 3, 4], function(result, n) { - * result.push(n *= n); - * return n % 2 == 0; - * }); - * // => [4, 9] - * - * _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { - * result[key] = n * 3; - * }); - * // => { 'a': 3, 'b': 6 } - */ - function transform(object, iteratee, accumulator, thisArg) { - var isArr = isArray(object) || isTypedArray(object); - iteratee = getCallback(iteratee, thisArg, 4); - - if (accumulator == null) { - if (isArr || isObject(object)) { - var Ctor = object.constructor; - if (isArr) { - accumulator = isArray(object) ? new Ctor : []; - } else { - accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); - } - } else { - accumulator = {}; - } - } - (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iteratee(accumulator, value, index, object); - }); - return accumulator; - } - - /** - * Creates an array of the own enumerable property values of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.values(new Foo); - * // => [1, 2] (iteration order is not guaranteed) - * - * _.values('hi'); - * // => ['h', 'i'] - */ - function values(object) { - return baseValues(object, keys(object)); - } - - /** - * Creates an array of the own and inherited enumerable property values - * of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.valuesIn(new Foo); - * // => [1, 2, 3] (iteration order is not guaranteed) - */ - function valuesIn(object) { - return baseValues(object, keysIn(object)); - } - - /*------------------------------------------------------------------------*/ - - /** - * Checks if `n` is between `start` and up to but not including, `end`. If - * `end` is not specified it is set to `start` with `start` then set to `0`. - * - * @static - * @memberOf _ - * @category Number - * @param {number} n The number to check. - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `n` is in the range, else `false`. - * @example - * - * _.inRange(3, 2, 4); - * // => true - * - * _.inRange(4, 8); - * // => true - * - * _.inRange(4, 2); - * // => false - * - * _.inRange(2, 2); - * // => false - * - * _.inRange(1.2, 2); - * // => true - * - * _.inRange(5.2, 4); - * // => false - */ - function inRange(value, start, end) { - start = +start || 0; - if (end === undefined) { - end = start; - start = 0; - } else { - end = +end || 0; - } - return value >= nativeMin(start, end) && value < nativeMax(start, end); - } - - /** - * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number is returned. - * If `floating` is `true`, or either `min` or `max` are floats, a floating-point - * number is returned instead of an integer. - * - * @static - * @memberOf _ - * @category Number - * @param {number} [min=0] The minimum possible value. - * @param {number} [max=1] The maximum possible value. - * @param {boolean} [floating] Specify returning a floating-point number. - * @returns {number} Returns the random number. - * @example - * - * _.random(0, 5); - * // => an integer between 0 and 5 - * - * _.random(5); - * // => also an integer between 0 and 5 - * - * _.random(5, true); - * // => a floating-point number between 0 and 5 - * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 - */ - function random(min, max, floating) { - if (floating && isIterateeCall(min, max, floating)) { - max = floating = undefined; - } - var noMin = min == null, - noMax = max == null; - - if (floating == null) { - if (noMax && typeof min == 'boolean') { - floating = min; - min = 1; - } - else if (typeof max == 'boolean') { - floating = max; - noMax = true; - } - } - if (noMin && noMax) { - max = 1; - noMax = false; - } - min = +min || 0; - if (noMax) { - max = min; - min = 0; - } else { - max = +max || 0; - } - if (floating || min % 1 || max % 1) { - var rand = nativeRandom(); - return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max); - } - return baseRandom(min, max); - } - - /*------------------------------------------------------------------------*/ - - /** - * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the camel cased string. - * @example - * - * _.camelCase('Foo Bar'); - * // => 'fooBar' - * - * _.camelCase('--foo-bar'); - * // => 'fooBar' - * - * _.camelCase('__foo_bar__'); - * // => 'fooBar' - */ - var camelCase = createCompounder(function(result, word, index) { - word = word.toLowerCase(); - return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word); - }); - - /** - * Capitalizes the first character of `string`. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to capitalize. - * @returns {string} Returns the capitalized string. - * @example - * - * _.capitalize('fred'); - * // => 'Fred' - */ - function capitalize(string) { - string = baseToString(string); - return string && (string.charAt(0).toUpperCase() + string.slice(1)); - } - - /** - * Deburrs `string` by converting [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * to basic latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to deburr. - * @returns {string} Returns the deburred string. - * @example - * - * _.deburr('déjà vu'); - * // => 'deja vu' - */ - function deburr(string) { - string = baseToString(string); - return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, ''); - } - - /** - * Checks if `string` ends with the given target string. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to search. - * @param {string} [target] The string to search for. - * @param {number} [position=string.length] The position to search from. - * @returns {boolean} Returns `true` if `string` ends with `target`, else `false`. - * @example - * - * _.endsWith('abc', 'c'); - * // => true - * - * _.endsWith('abc', 'b'); - * // => false - * - * _.endsWith('abc', 'b', 2); - * // => true - */ - function endsWith(string, target, position) { - string = baseToString(string); - target = (target + ''); - - var length = string.length; - position = position === undefined - ? length - : nativeMin(position < 0 ? 0 : (+position || 0), length); - - position -= target.length; - return position >= 0 && string.indexOf(target, position) == position; - } - - /** - * Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to - * their corresponding HTML entities. - * - * **Note:** No other characters are escaped. To escape additional characters - * use a third-party library like [_he_](https://mths.be/he). - * - * Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. - * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. - * - * Backticks are escaped because in Internet Explorer < 9, they can break out - * of attribute values or HTML comments. See [#59](https://html5sec.org/#59), - * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and - * [#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/) - * for more details. - * - * When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping) - * to reduce XSS vectors. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @example - * - * _.escape('fred, barney, & pebbles'); - * // => 'fred, barney, & pebbles' - */ - function escape(string) { - // Reset `lastIndex` because in IE < 9 `String#replace` does not. - string = baseToString(string); - return (string && reHasUnescapedHtml.test(string)) - ? string.replace(reUnescapedHtml, escapeHtmlChar) - : string; - } - - /** - * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?", - * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @example - * - * _.escapeRegExp('[lodash](https://lodash.com/)'); - * // => '\[lodash\]\(https:\/\/lodash\.com\/\)' - */ - function escapeRegExp(string) { - string = baseToString(string); - return (string && reHasRegExpChars.test(string)) - ? string.replace(reRegExpChars, escapeRegExpChar) - : (string || '(?:)'); - } - - /** - * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the kebab cased string. - * @example - * - * _.kebabCase('Foo Bar'); - * // => 'foo-bar' - * - * _.kebabCase('fooBar'); - * // => 'foo-bar' - * - * _.kebabCase('__foo_bar__'); - * // => 'foo-bar' - */ - var kebabCase = createCompounder(function(result, word, index) { - return result + (index ? '-' : '') + word.toLowerCase(); - }); - - /** - * Pads `string` on the left and right sides if it's shorter than `length`. - * Padding characters are truncated if they can't be evenly divided by `length`. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * _.pad('abc', 8); - * // => ' abc ' - * - * _.pad('abc', 8, '_-'); - * // => '_-abc_-_' - * - * _.pad('abc', 3); - * // => 'abc' - */ - function pad(string, length, chars) { - string = baseToString(string); - length = +length; - - var strLength = string.length; - if (strLength >= length || !nativeIsFinite(length)) { - return string; - } - var mid = (length - strLength) / 2, - leftLength = nativeFloor(mid), - rightLength = nativeCeil(mid); - - chars = createPadding('', rightLength, chars); - return chars.slice(0, leftLength) + string + chars; - } - - /** - * Pads `string` on the left side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * _.padLeft('abc', 6); - * // => ' abc' - * - * _.padLeft('abc', 6, '_-'); - * // => '_-_abc' - * - * _.padLeft('abc', 3); - * // => 'abc' - */ - var padLeft = createPadDir(); - - /** - * Pads `string` on the right side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * _.padRight('abc', 6); - * // => 'abc ' - * - * _.padRight('abc', 6, '_-'); - * // => 'abc_-_' - * - * _.padRight('abc', 3); - * // => 'abc' - */ - var padRight = createPadDir(true); - - /** - * Converts `string` to an integer of the specified radix. If `radix` is - * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, - * in which case a `radix` of `16` is used. - * - * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E) - * of `parseInt`. - * - * @static - * @memberOf _ - * @category String - * @param {string} string The string to convert. - * @param {number} [radix] The radix to interpret `value` by. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {number} Returns the converted integer. - * @example - * - * _.parseInt('08'); - * // => 8 - * - * _.map(['6', '08', '10'], _.parseInt); - * // => [6, 8, 10] - */ - function parseInt(string, radix, guard) { - // Firefox < 21 and Opera < 15 follow ES3 for `parseInt`. - // Chrome fails to trim leading whitespace characters. - // See https://code.google.com/p/v8/issues/detail?id=3109 for more details. - if (guard ? isIterateeCall(string, radix, guard) : radix == null) { - radix = 0; - } else if (radix) { - radix = +radix; - } - string = trim(string); - return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); - } - - /** - * Repeats the given string `n` times. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to repeat. - * @param {number} [n=0] The number of times to repeat the string. - * @returns {string} Returns the repeated string. - * @example - * - * _.repeat('*', 3); - * // => '***' - * - * _.repeat('abc', 2); - * // => 'abcabc' - * - * _.repeat('abc', 0); - * // => '' - */ - function repeat(string, n) { - var result = ''; - string = baseToString(string); - n = +n; - if (n < 1 || !string || !nativeIsFinite(n)) { - return result; - } - // Leverage the exponentiation by squaring algorithm for a faster repeat. - // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. - do { - if (n % 2) { - result += string; - } - n = nativeFloor(n / 2); - string += string; - } while (n); - - return result; - } - - /** - * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the snake cased string. - * @example - * - * _.snakeCase('Foo Bar'); - * // => 'foo_bar' - * - * _.snakeCase('fooBar'); - * // => 'foo_bar' - * - * _.snakeCase('--foo-bar'); - * // => 'foo_bar' - */ - var snakeCase = createCompounder(function(result, word, index) { - return result + (index ? '_' : '') + word.toLowerCase(); - }); - - /** - * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the start cased string. - * @example - * - * _.startCase('--foo-bar'); - * // => 'Foo Bar' - * - * _.startCase('fooBar'); - * // => 'Foo Bar' - * - * _.startCase('__foo_bar__'); - * // => 'Foo Bar' - */ - var startCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1)); - }); - - /** - * Checks if `string` starts with the given target string. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to search. - * @param {string} [target] The string to search for. - * @param {number} [position=0] The position to search from. - * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`. - * @example - * - * _.startsWith('abc', 'a'); - * // => true - * - * _.startsWith('abc', 'b'); - * // => false - * - * _.startsWith('abc', 'b', 1); - * // => true - */ - function startsWith(string, target, position) { - string = baseToString(string); - position = position == null - ? 0 - : nativeMin(position < 0 ? 0 : (+position || 0), string.length); - - return string.lastIndexOf(target, position) == position; - } - - /** - * Creates a compiled template function that can interpolate data properties - * in "interpolate" delimiters, HTML-escape interpolated data properties in - * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data - * properties may be accessed as free variables in the template. If a setting - * object is provided it takes precedence over `_.templateSettings` values. - * - * **Note:** In the development build `_.template` utilizes - * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for easier debugging. - * - * For more information on precompiling templates see - * [lodash's custom builds documentation](https://lodash.com/custom-builds). - * - * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The template string. - * @param {Object} [options] The options object. - * @param {RegExp} [options.escape] The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate] The "evaluate" delimiter. - * @param {Object} [options.imports] An object to import into the template as free variables. - * @param {RegExp} [options.interpolate] The "interpolate" delimiter. - * @param {string} [options.sourceURL] The sourceURL of the template's compiled source. - * @param {string} [options.variable] The data object variable name. - * @param- {Object} [otherOptions] Enables the legacy `options` param signature. - * @returns {Function} Returns the compiled template function. - * @example - * - * // using the "interpolate" delimiter to create a compiled template - * var compiled = _.template('hello <%= user %>!'); - * compiled({ 'user': 'fred' }); - * // => 'hello fred!' - * - * // using the HTML "escape" delimiter to escape data property values - * var compiled = _.template('<%- value %>'); - * compiled({ 'value': '