diff --git a/.travis.yml b/.travis.yml index c2a8df8fa1..e239d632a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ before_install: - "git clone --depth=10 --branch=master git://github.com/lodash/lodash-cli.git ./node_modules/lodash-cli && mkdir $_/node_modules && cd $_ && ln -s ../../../ ./lodash-compat && cd ../ && npm i && cd ../../" - "node ./node_modules/lodash-cli/bin/lodash $BUILD -o ./lodash.$BUILD.js" script: - - "[ $ISTANBUL == false ] || (cp ./lodash.$BUILD.js ./lodash.js && node ./node_modules/istanbul/lib/cli.js cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./lodash.js)" + - "[ $ISTANBUL == false ] || (cp ./lodash.$BUILD.js ./lodash.js && sed -i'' 's|constant\\.name == '\\''constant'\\''|false|' $_ && node ./node_modules/istanbul/lib/cli.js cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./lodash.js)" - "[ $ISTANBUL == false ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || (cat ./coverage/lcov.info | coveralls)" - "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || cd ./test" - "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || $BIN $OPTION ./test.js ../lodash.$BUILD.js" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cca489a1f6..df0e4aa42c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,9 @@ Please make sure to [search the issue tracker](https://github.com/lodash/lodash/ Include updated unit tests in the `test` directory as part of your pull request. Don’t worry about regenerating the documentation, lodash.js, or lodash.min.js. -You can run the tests from the command line via `node test/test`, or open `test/index.html` in a web browser. +Before running the unit tests you’ll need to install, `npm i`, [development dependencies](https://docs.npmjs.com/files/package.json#devdependencies). +Run unit tests from the command-line via `node test/test`, or open `test/index.html` in a web browser. + The `test/run-test.sh` script attempts to run the tests in [Rhino](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino), [RingoJS](http://ringojs.org/), [PhantomJS](http://phantomjs.org/), & [Node](http://nodejs.org/), before running them in your default browser. The [Backbone](http://backbonejs.org/) & [Underscore](http://underscorejs.org/) test suites are included as well. diff --git a/README.md b/README.md index 44b2991699..6b050248dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash v3.5.0 +# lodash v3.6.0 The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) with packages for [Bower](http://bower.io/), [Component](http://component.github.io/), & [Volo](http://volojs.org/). @@ -16,8 +16,8 @@ $ lodash modern -o ./lodash.js 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.5.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.5.0-amd) builds - * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.5.0-es) build + * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.6.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.6.0-amd) builds + * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.6.0-es) build ## Further Reading diff --git a/bower.json b/bower.json index a80fea5e94..f8ceaf0e1f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "3.5.0", + "version": "3.6.0", "main": "lodash.js", "ignore": [ ".*", diff --git a/component.json b/component.json index 5cb835828f..2400e8ef1a 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "lodash", "repo": "lodash/lodash", - "version": "3.5.0", + "version": "3.6.0", "description": "The modern build of lodash.", "license": "MIT", "main": "lodash.js", diff --git a/doc/README.md b/doc/README.md index 7f287b1afb..401dbae54f 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# lodash v3.5.0 +# lodash v3.6.0 @@ -126,9 +126,9 @@ * `_.ary` * `_.backflow` -> `flowRight` * `_.before` -* `_.bind` +* `_.bind` * `_.bindAll` -* `_.bindKey` +* `_.bindKey` * `_.compose` -> `flowRight` * `_.curry` * `_.curryRight` @@ -140,9 +140,10 @@ * `_.memoize` * `_.negate` * `_.once` -* `_.partial` -* `_.partialRight` +* `_.partial` +* `_.partialRight` * `_.rearg` +* `_.restParam` * `_.spread` * `_.throttle` * `_.wrap` @@ -186,7 +187,7 @@ * `_.add` * `_.max` * `_.min` -* `_.sum` +* `_.sum` @@ -322,7 +323,7 @@ ### `_.chunk(array, [size=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4300 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4536 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm package") 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 @@ -350,7 +351,7 @@ _.chunk(['a', 'b', 'c', 'd'], 3); ### `_.compact(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4331 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.compact "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4567 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.compact "See the npm package") Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are falsey. @@ -373,7 +374,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4366 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4602 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the npm package") Creates an array excluding all values of the provided arrays using `SameValueZero` for equality comparisons. @@ -403,7 +404,7 @@ _.difference([1, 2, 3], [4, 2]); ### `_.drop(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4404 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.drop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4632 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.drop "See the npm package") Creates a slice of `array` with `n` elements dropped from the beginning. @@ -435,7 +436,7 @@ _.drop([1, 2, 3], 0); ### `_.dropRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4439 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4667 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropright "See the npm package") Creates a slice of `array` with `n` elements dropped from the end. @@ -467,11 +468,11 @@ _.dropRight([1, 2, 3], 0); ### `_.dropRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4500 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4728 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm package") 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). +bound to `thisArg` and invoked with three arguments: (value, index, array).

If a property name is provided for `predicate` the created `_.property` @@ -527,11 +528,11 @@ _.pluck(_.dropRightWhile(users, 'active'), 'user'); ### `_.dropWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4559 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4783 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") 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). +bound to `thisArg` and invoked with three arguments: (value, index, array).

If a property name is provided for `predicate` the created `_.property` @@ -587,7 +588,7 @@ _.pluck(_.dropWhile(users, 'active'), 'user'); ### `_.fill(array, value, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4585 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4817 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm package") Fills elements of `array` with `value` from `start` up to, but not including, `end`. @@ -604,6 +605,20 @@ including, `end`. #### Returns *(Array)*: Returns `array`. +#### Example +```js +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] +``` * * * @@ -611,10 +626,10 @@ including, `end`. ### `_.findIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4645 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4877 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findindex "See the npm package") This method is like `_.find` except that it returns the index of the first -element `predicate` returns truthy for, instead of the element itself. +element `predicate` returns truthy for instead of the element itself.

If a property name is provided for `predicate` the created `_.property` @@ -670,7 +685,7 @@ _.findIndex(users, 'active'); ### `_.findLastIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4706 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4927 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See the npm package") This method is like `_.findIndex` except that it iterates over elements of `collection` from right to left. @@ -729,10 +744,13 @@ _.findLastIndex(users, 'active'); ### `_.first(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4734 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.first "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4946 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.first "See the npm package") Gets the first element of `array`. +#### Aliases +*_.head* + #### Arguments 1. `array` *(Array)*: The array to query. @@ -754,7 +772,7 @@ _.first([]); ### `_.flatten(array, [isDeep])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4758 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4970 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") Flattens a nested array. If `isDeep` is `true` the array is recursively flattened, otherwise it is only flattened a single level. @@ -769,11 +787,11 @@ flattened, otherwise it is only flattened a single level. #### Example ```js _.flatten([1, [2, 3, [4]]]); -// => [1, 2, 3, [4]]; +// => [1, 2, 3, [4]] // using `isDeep` _.flatten([1, [2, 3, [4]]], true); -// => [1, 2, 3, 4]; +// => [1, 2, 3, 4] ``` * * * @@ -782,7 +800,7 @@ _.flatten([1, [2, 3, [4]]], true); ### `_.flattenDeep(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4779 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L4991 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") Recursively flattens a nested array. @@ -795,7 +813,7 @@ Recursively flattens a nested array. #### Example ```js _.flattenDeep([1, [2, 3, [4]]]); -// => [1, 2, 3, 4]; +// => [1, 2, 3, 4] ``` * * * @@ -804,7 +822,7 @@ _.flattenDeep([1, [2, 3, [4]]]); ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4816 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5028 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexof "See the npm package") Gets the index at which the first occurrence of `value` is found in `array` using `SameValueZero` for equality comparisons. If `fromIndex` is negative, @@ -845,7 +863,7 @@ _.indexOf([1, 1, 2, 2], 2, true); ### `_.initial(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4848 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5060 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") Gets all but the last element of `array`. @@ -867,7 +885,7 @@ _.initial([1, 2, 3]); ### `_.intersection([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4870 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5082 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the npm package") Creates an array of unique values in all provided arrays using `SameValueZero` for equality comparisons. @@ -896,7 +914,7 @@ _.intersection([1, 2], [4, 2], [2, 1]); ### `_.last(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4925 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5137 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") Gets the last element of `array`. @@ -918,7 +936,7 @@ _.last([1, 2, 3]); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L4955 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5167 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the npm package") This method is like `_.indexOf` except that it iterates over elements of `array` from right to left. @@ -951,7 +969,7 @@ _.lastIndexOf([1, 1, 2, 2], 2, true); ### `_.pull(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5006 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5218 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") Removes all provided values from `array` using `SameValueZero` for equality comparisons. @@ -987,7 +1005,7 @@ console.log(array); ### `_.pullAt(array, [indexes])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5053 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5265 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm package") 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 @@ -1021,11 +1039,11 @@ console.log(evens); ### `_.remove(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5096 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5322 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm package") 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). +`thisArg` and invoked with three arguments: (value, index, array).

If a property name is provided for `predicate` the created `_.property` @@ -1072,10 +1090,13 @@ console.log(evens); ### `_.rest(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5127 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5353 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") Gets all but the first element of `array`. +#### Aliases +*_.tail* + #### Arguments 1. `array` *(Array)*: The array to query. @@ -1094,7 +1115,7 @@ _.rest([1, 2, 3]); ### `_.slice(array, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5145 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.slice "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5371 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.slice "See the npm package") Creates a slice of `array` from `start` up to, but not including, `end`.
@@ -1117,7 +1138,7 @@ lists in IE < 9 and to ensure dense arrays are returned. ### `_.sortedIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5205 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5431 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the npm package") 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 @@ -1126,7 +1147,7 @@ to compute their sort ranking. The iteratee is bound to `thisArg` and invoked with one argument; (value).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -1135,7 +1156,7 @@ 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 +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`. @@ -1176,7 +1197,7 @@ _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); ### `_.sortedLastIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5232 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5453 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindex "See the npm package") This method is like `_.sortedIndex` except that it returns the highest index at which `value` should be inserted into `array` in order to @@ -1204,7 +1225,7 @@ _.sortedLastIndex([4, 4, 5, 5], 5); ### `_.take(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5263 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.take "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5479 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.take "See the npm package") Creates a slice of `array` with `n` elements taken from the beginning. @@ -1236,7 +1257,7 @@ _.take([1, 2, 3], 0); ### `_.takeRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5298 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takeright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5514 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takeright "See the npm package") Creates a slice of `array` with `n` elements taken from the end. @@ -1268,11 +1289,11 @@ _.takeRight([1, 2, 3], 0); ### `_.takeRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5359 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5575 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package") 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). +and invoked with three arguments: (value, index, array).

If a property name is provided for `predicate` the created `_.property` @@ -1328,11 +1349,11 @@ _.pluck(_.takeRightWhile(users, 'active'), 'user'); ### `_.takeWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5418 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5630 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the npm package") 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). +`thisArg` and invoked with three arguments: (value, index, array).

If a property name is provided for `predicate` the created `_.property` @@ -1388,7 +1409,7 @@ _.pluck(_.takeWhile(users, 'active'), 'user'); ### `_.union([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5448 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5655 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm package") Creates an array of unique values, in order, of the provided arrays using `SameValueZero` for equality comparisons. @@ -1417,17 +1438,17 @@ _.union([1, 2], [4, 2], [2, 1]); ### `_.uniq(array, [isSorted], [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5504 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5711 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm package") Creates a duplicate-value-free version of an array using `SameValueZero` for equality comparisons. Providing `true` for `isSorted` performs a faster search algorithm for sorted arrays. If an iteratee function is provided it is invoked for each value 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). +with three arguments: (value, index, array).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -1436,7 +1457,7 @@ 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 +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`.
@@ -1446,6 +1467,9 @@ e.g. `===`, except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) for more details. +#### Aliases +*_.unique* + #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `[isSorted]` *(boolean)*: Specify the array is sorted. @@ -1481,7 +1505,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unzip(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5541 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5748 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzip "See the npm package") 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` @@ -1508,7 +1532,7 @@ _.unzip(zipped); ### `_.without(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5572 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5779 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") Creates an array excluding all provided values using `SameValueZero` for equality comparisons. @@ -1538,7 +1562,7 @@ _.without([1, 2, 1, 3], 1, 2); ### `_.xor([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5591 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5800 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm package") Creates an array that is the symmetric difference of the provided arrays. See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for @@ -1562,7 +1586,7 @@ _.xor([1, 2], [4, 2]); ### `_.zip([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5621 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5830 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zip "See the npm package") 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 @@ -1586,11 +1610,15 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]); ### `_.zipObject(props, [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5648 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5853 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") + +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. -Creates 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. +#### Aliases +*_.object* #### Arguments 1. `props` *(Array)*: The property names. @@ -1601,6 +1629,9 @@ or two arrays, one of property names and one of corresponding values. #### Example ```js +_.zipObject([['fred', 30], ['barney', 40]]); +// => { 'fred': 30, 'barney': 40 } + _.zipObject(['fred', 'barney'], [30, 40]); // => { 'fred': 30, 'barney': 40 } ``` @@ -1617,7 +1648,7 @@ _.zipObject(['fred', 'barney'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L962 "View in source") [Ⓣ][1] Creates a `lodash` object which wraps `value` to enable implicit chaining. Methods that operate on and return arrays, collections, and functions can @@ -1728,7 +1759,7 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5695 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5900 "View in source") [Ⓣ][1] Creates a `lodash` object that wraps `value` with explicit method chaining enabled. @@ -1763,7 +1794,7 @@ var youngest = _.chain(users) ### `_.tap(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5929 "View in source") [Ⓣ][1] This method invokes `interceptor` and returns `value`. The interceptor is bound to `thisArg` and invoked with one argument; (value). The purpose of @@ -1795,7 +1826,7 @@ _([1, 2, 3]) ### `_.thru(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5749 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5955 "View in source") [Ⓣ][1] This method is like `_.tap` except that it returns the result of `interceptor`. @@ -1809,13 +1840,14 @@ This method is like `_.tap` except that it returns the result of `interceptor`. #### Example ```js -_([1, 2, 3]) - .last() +_(' abc ') + .chain() + .trim() .thru(function(value) { return [value]; }) .value(); -// => [3] +// => ['abc'] ``` * * * @@ -1824,7 +1856,7 @@ _([1, 2, 3]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5778 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L5984 "View in source") [Ⓣ][1] Enables explicit method chaining on the wrapper object. @@ -1856,7 +1888,7 @@ _(users).chain() ### `_.prototype.commit()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5807 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6013 "View in source") [Ⓣ][1] Executes the chained sequence and returns the wrapped result. @@ -1888,7 +1920,7 @@ console.log(array); ### `_.prototype.plant()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5834 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6040 "View in source") [Ⓣ][1] Creates a clone of the chained sequence planting `value` as the wrapped value. @@ -1918,7 +1950,7 @@ wrapper.value(); ### `_.prototype.reverse()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5872 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6078 "View in source") [Ⓣ][1] Reverses the wrapped array so the first element becomes the last, the second element becomes the second to last, and so on. @@ -1946,7 +1978,7 @@ console.log(array); ### `_.prototype.toString()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5897 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6103 "View in source") [Ⓣ][1] Produces the result of coercing the unwrapped value to a string. @@ -1965,10 +1997,13 @@ _([1, 2, 3]).toString(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5914 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6120 "View in source") [Ⓣ][1] Executes the chained sequence to extract the unwrapped value. +#### Aliases +*_.prototype.run, _.prototype.toJSON, _.prototype.valueOf* + #### Returns *(*)*: Returns the resolved unwrapped value. @@ -1990,7 +2025,7 @@ _([1, 2, 3]).value(); ### `_.at(collection, [props])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5940 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.at "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6146 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.at "See the npm package") Creates an array of elements corresponding to the given keys, or indexes, of `collection`. Keys may be specified as individual arguments or as arrays @@ -2008,8 +2043,8 @@ of keys. _.at(['a', 'b', 'c'], [0, 2]); // => ['a', 'c'] -_.at(['fred', 'barney', 'pebbles'], 0, 2); -// => ['fred', 'pebbles'] +_.at(['barney', 'fred', 'pebbles'], 0, 2); +// => ['barney', 'pebbles'] ``` * * * @@ -2018,16 +2053,16 @@ _.at(['fred', 'barney', 'pebbles'], 0, 2); ### `_.countBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L5989 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6195 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm package") 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; +The `iteratee` is bound to `thisArg` and invoked with three arguments:
(value, index|key, collection).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -2036,7 +2071,7 @@ 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 +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`. @@ -2070,10 +2105,10 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6041 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6247 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm package") Checks if `predicate` returns truthy for **all** elements of `collection`. -The predicate is bound to `thisArg` and invoked with three arguments; +The predicate is bound to `thisArg` and invoked with three arguments:
(value, index|key, collection).

@@ -2090,6 +2125,9 @@ 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`. +#### Aliases +*_.all* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. @@ -2128,11 +2166,11 @@ _.every(users, 'active'); ### `_.filter(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6098 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6307 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm package") 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). +invoked with three arguments: (value, index|key, collection).

If a property name is provided for `predicate` the created `_.property` @@ -2148,6 +2186,9 @@ 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`. +#### Aliases +*_.select* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. @@ -2187,11 +2228,11 @@ _.pluck(_.filter(users, 'active'), 'user'); ### `_.find(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6154 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6363 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm package") 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). +invoked with three arguments: (value, index|key, collection).

If a property name is provided for `predicate` the created `_.property` @@ -2207,6 +2248,9 @@ 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`. +#### Aliases +*_.detect* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. @@ -2247,7 +2291,7 @@ _.result(_.find(users, 'active'), 'user'); ### `_.findLast(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6182 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6384 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm package") This method is like `_.find` except that it iterates over elements of `collection` from right to left. @@ -2274,7 +2318,7 @@ _.findLast([1, 2, 3, 4], function(n) { ### `_.findWhere(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6216 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findwhere "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6415 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findwhere "See the npm package") Performs a deep comparison between each element in `collection` and the source object, returning the first element that has equivalent property @@ -2313,10 +2357,10 @@ _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); ### `_.forEach(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6250 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6449 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm package") Iterates over elements of `collection` invoking `iteratee` for each element. -The `iteratee` is bound to `thisArg` and invoked with three arguments; +The `iteratee` is bound to `thisArg` and invoked with three arguments:
(value, index|key, collection). Iterator functions may exit iteration early by explicitly returning `false`.
@@ -2325,6 +2369,9 @@ by explicitly returning `false`. are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` may be used for object iteration. +#### Aliases +*_.each* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. @@ -2352,11 +2399,14 @@ _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { ### `_.forEachRight(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6275 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6470 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the npm package") This method is like `_.forEach` except that it iterates over elements of `collection` from right to left. +#### Aliases +*_.eachRight* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. @@ -2369,7 +2419,7 @@ This method is like `_.forEach` except that it iterates over elements of ```js _([1, 2]).forEachRight(function(n) { console.log(n); -}).join(','); +}).value(); // => logs each value from right to left and returns the array ``` * * * @@ -2379,16 +2429,16 @@ _([1, 2]).forEachRight(function(n) { ### `_.groupBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6323 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6514 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm package") 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; +The `iteratee` is bound to `thisArg` and invoked with three arguments:
(value, index|key, collection).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -2397,7 +2447,7 @@ 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 +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`. @@ -2432,7 +2482,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.includes(collection, target, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6363 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6555 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") Checks if `value` is in `collection` using `SameValueZero` for equality comparisons. If `fromIndex` is negative, it is used as the offset from @@ -2444,6 +2494,9 @@ e.g. `===`, except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) for more details. +#### Aliases +*_.contains, _.include* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. 2. `target` *(*)*: The value to search for. @@ -2473,16 +2526,16 @@ _.includes('pebbles', 'eb'); ### `_.indexBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6428 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6620 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexby "See the npm package") 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; +iteratee function is bound to `thisArg` and invoked with three arguments:
(value, index|key, collection).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -2491,7 +2544,7 @@ 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 +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`. @@ -2530,7 +2583,7 @@ _.indexBy(keyData, function(object) { ### `_.invoke(collection, methodName, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6454 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6646 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "See the npm package") Invokes the method named by `methodName` on each element in `collection`, returning an array of the results of each invoked method. Any additional @@ -2560,14 +2613,14 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6514 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6715 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm package") 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). +arguments: (value, index|key, collection).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -2576,7 +2629,7 @@ 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 +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`.
@@ -2587,9 +2640,12 @@ Many lodash methods are guarded to work as interatees for methods like
The guarded methods are:
`ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`, -`dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`, -`sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`, -`trunc`, `random`, `range`, `sample`, `uniq`, and `words` +`dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, +`slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, +`trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words` + +#### Aliases +*_.collect* #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. @@ -2627,12 +2683,12 @@ _.map(users, 'user'); ### `_.partition(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6579 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6780 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") 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). +to `thisArg` and invoked with three arguments: (value, index|key, collection).

If a property name is provided for `predicate` the created `_.property` @@ -2697,7 +2753,7 @@ _.map(_.partition(users, 'active'), mapper); ### `_.pluck(collection, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6606 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pluck "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6807 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pluck "See the npm package") Gets the value of `key` from all elements in `collection`. @@ -2729,13 +2785,13 @@ _.pluck(userIndex, 'age'); ### `_.reduce(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6646 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6847 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm package") 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; +value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
(accumulator, value, index|key, collection).

@@ -2744,7 +2800,10 @@ Many lodash methods are guarded to work as interatees for methods like

The guarded methods are:
-`assign`, `defaults`, `merge`, and `sortAllBy` +`assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder` + +#### Aliases +*_.foldl, _.inject* #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. @@ -2775,11 +2834,14 @@ _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { ### `_.reduceRight(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6673 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6871 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the npm package") This method is like `_.reduce` except that it iterates over elements of `collection` from right to left. +#### Aliases +*_.foldr* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. @@ -2805,7 +2867,7 @@ _.reduceRight(array, function(flattened, other) { ### `_.reject(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6725 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6920 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reject "See the npm package") The opposite of `_.filter`; this method returns the elements of `collection` that `predicate` does **not** return truthy for. @@ -2863,7 +2925,7 @@ _.pluck(_.reject(users, 'active'), 'user'); ### `_.sample(collection, [n])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6751 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6946 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") Gets a random element or `n` random elements from a collection. @@ -2889,7 +2951,7 @@ _.sample([1, 2, 3, 4], 2); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6777 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.shuffle "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L6972 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.shuffle "See the npm package") Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle) @@ -2913,7 +2975,7 @@ _.shuffle([1, 2, 3, 4]); ### `_.size(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6814 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.size "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7009 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.size "See the npm package") Gets the size of `collection` by returning its length for array-like values or the number of own enumerable properties for objects. @@ -2942,12 +3004,12 @@ _.size('pebbles'); ### `_.some(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6868 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7063 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm package") 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). +with three arguments: (value, index|key, collection).

If a property name is provided for `predicate` the created `_.property` @@ -2963,6 +3025,9 @@ 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`. +#### Aliases +*_.any* + #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. @@ -3001,16 +3066,16 @@ _.some(users, 'active'); ### `_.sortBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6925 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7123 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortby "See the npm package") 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; +The `iteratee` is bound to `thisArg` and invoked with three arguments:
(value, index|key, collection).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -3019,7 +3084,7 @@ 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 +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`. @@ -3060,7 +3125,7 @@ _.pluck(_.sortBy(users, 'user'), 'user'); ### `_.sortByAll(collection, props)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L6966 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyall "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7164 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyall "See the npm package") This method is like `_.sortBy` except that it sorts by property names instead of an iteratee function. @@ -3091,7 +3156,7 @@ _.map(_.sortByAll(users, ['user', 'age']), _.values); ### `_.sortByOrder(collection, props, orders)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7006 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyorder "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7211 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyorder "See the npm package") This method is like `_.sortByAll` except that it allows specifying the sort orders of the property names to sort by. A truthy value in `orders` @@ -3126,7 +3191,7 @@ _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values); ### `_.where(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7051 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.where "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7256 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.where "See the npm package") Performs a deep comparison between each element in `collection` and the source object, returning an array of all elements that have equivalent @@ -3171,7 +3236,7 @@ _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); ### `_.now` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7071 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7276 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") Gets the number of milliseconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC). @@ -3196,7 +3261,7 @@ _.defer(function(stamp) { ### `_.after(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7100 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.after "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7305 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.after "See the npm package") The opposite of `_.before`; this method creates a function that invokes `func` once it is called `n` or more times. @@ -3228,7 +3293,7 @@ _.forEach(saves, function(type) { ### `_.ary(func, [n=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7134 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ary "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7339 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ary "See the npm package") Creates a function that accepts up to `n` arguments ignoring any additional arguments. @@ -3252,7 +3317,7 @@ _.map(['6', '8', '10'], _.ary(parseInt, 1)); ### `_.before(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7158 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.before "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7363 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.before "See the npm package") 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 @@ -3276,8 +3341,8 @@ jQuery('#add').on('click', _.before(5, addContactToList)); -### `_.bind(func, thisArg, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7214 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bind "See the npm package") +### `_.bind(func, thisArg, [partials])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7419 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bind "See the npm package") Creates a function that invokes `func` with the `this` binding of `thisArg` and prepends any additional `_.bind` arguments to those provided to the @@ -3294,7 +3359,7 @@ property of bound functions. #### Arguments 1. `func` *(Function)*: The function to bind. 2. `thisArg` *(*)*: The `this` binding of `func`. -3. `[args]` *(...*)*: The arguments to be partially applied. +3. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns *(Function)*: Returns the new bound function. @@ -3323,7 +3388,7 @@ bound('hi'); ### `_.bindAll(object, [methodNames])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7253 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindall "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7456 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindall "See the npm package") Binds methods of an object to the object itself, overwriting the existing method. Method names may be specified as individual arguments or as arrays @@ -3359,8 +3424,8 @@ jQuery('#docs').on('click', view.onClick); -### `_.bindKey(object, key, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7305 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindkey "See the npm package") +### `_.bindKey(object, key, [partials])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7513 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindkey "See the npm package") Creates a function that invokes the method at `object[key]` and prepends any additional `_.bindKey` arguments to those provided to the bound function. @@ -3378,7 +3443,7 @@ builds, may be used as a placeholder for partially applied arguments. #### Arguments 1. `object` *(Object)*: The object the method belongs to. 2. `key` *(string)*: The key of the method. -3. `[args]` *(...*)*: The arguments to be partially applied. +3. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns *(Function)*: Returns the new bound function. @@ -3415,7 +3480,7 @@ bound('hi'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7356 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7562 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") Creates a function that accepts one or more arguments of `func` that when called either invokes `func` returning its result, if all `func` arguments @@ -3465,7 +3530,7 @@ curried(1)(_, 3)(2); ### `_.curryRight(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7402 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curryright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7601 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curryright "See the npm package") This method is like `_.curry` except that arguments are applied to `func` in the manner of `_.partialRight` instead of `_.partial`. @@ -3512,7 +3577,7 @@ curried(3)(1, _)(2); ### `_.debounce(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7473 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7665 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the npm package") Creates a function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time it was invoked. The created function comes @@ -3582,7 +3647,7 @@ delete models.todo; ### `_.defer(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7604 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defer "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7796 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defer "See the npm package") Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to `func` when it is invoked. @@ -3608,7 +3673,7 @@ _.defer(function(text) { ### `_.delay(func, wait, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7626 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.delay "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7818 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.delay "See the npm package") Invokes `func` after `wait` milliseconds. Any additional arguments are provided to `func` when it is invoked. @@ -3635,7 +3700,7 @@ _.delay(function(text) { ### `_.flow([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7650 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flow "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7842 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flow "See the npm package") Creates a function that returns the result of invoking the provided functions with the `this` binding of the created function, where each @@ -3664,11 +3729,14 @@ addSquare(1, 2); ### `_.flowRight([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7672 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flowright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7864 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flowright "See the npm package") This method is like `_.flow` except that it creates a function that invokes the provided functions from right to left. +#### Aliases +*_.backflow, _.compose* + #### Arguments 1. `[funcs]` *(...Function)*: Functions to invoke. @@ -3692,7 +3760,7 @@ addSquare(1, 2); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7727 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.memoize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7919 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.memoize "See the npm package") 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 @@ -3755,7 +3823,7 @@ identity(other); ### `_.negate(predicate)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7766 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.negate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7958 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.negate "See the npm package") Creates a function that negates the result of the predicate `func`. The `func` predicate is invoked with the `this` binding and arguments of the @@ -3783,11 +3851,11 @@ _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); ### `_.once(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7792 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L7984 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm package") 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 of the created function. +with the `this` binding and arguments of the created function. #### Arguments 1. `func` *(Function)*: The function to restrict. @@ -3808,8 +3876,8 @@ initialize(); -### `_.partial(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7828 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partial "See the npm package") +### `_.partial(func, [partials])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8020 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partial "See the npm package") Creates a function that invokes `func` with `partial` arguments prepended to those provided to the new function. This method is like `_.bind` except @@ -3825,7 +3893,7 @@ applied functions. #### Arguments 1. `func` *(Function)*: The function to partially apply arguments to. -2. `[args]` *(...*)*: The arguments to be partially applied. +2. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns *(Function)*: Returns the new partially applied function. @@ -3851,8 +3919,8 @@ greetFred('hi'); -### `_.partialRight(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7866 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partialright "See the npm package") +### `_.partialRight(func, [partials])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8053 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partialright "See the npm package") This method is like `_.partial` except that partially applied arguments are appended to those provided to the new function. @@ -3867,7 +3935,7 @@ applied functions. #### Arguments 1. `func` *(Function)*: The function to partially apply arguments to. -2. `[args]` *(...*)*: The arguments to be partially applied. +2. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns *(Function)*: Returns the new partially applied function. @@ -3894,7 +3962,7 @@ sayHelloTo('fred'); ### `_.rearg(func, indexes)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7901 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rearg "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8083 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rearg "See the npm package") Creates a function that invokes `func` with arguments arranged according to the specified indexes where the argument value at the first index is @@ -3929,27 +3997,65 @@ map(function(n) { -### `_.spread(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7936 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.spread "See the npm package") +### `_.restParam(func, [start=func.length-1])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8111 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.restparam "See the npm package") Creates a function that invokes `func` with the `this` binding of the -created function and the array of arguments provided to the created -function much like [Function#apply](http://es5.github.io/#x15.3.4.3). +created function and arguments from `start` and beyond provided as an array. +
+
+**Note:** This method is based on the ES6 rest parameter. See the +[MDN Wiki](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) +for more details. + +#### Arguments +1. `func` *(Function)*: The function to apply a rest parameter to. +2. `[start=func.length-1]` *(number)*: The start position of the rest parameter. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +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' +``` +* * * + + + + + +### `_.spread(func)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8173 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.spread "See the npm package") + +Creates a function that invokes `func` with the `this` binding of the created +function and an array of arguments much like [Function#apply](http://es5.github.io/#x15.3.4.3). +
+
+**Note:** This method is based on the ES6 spread operator. See the +[MDN Wiki](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator) +for more details. #### Arguments 1. `func` *(Function)*: The function to spread arguments over. #### Returns -*(*)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js -var spread = _.spread(function(who, what) { +var say = _.spread(function(who, what) { return who + ' says ' + what; }); -spread(['Fred', 'hello']); -// => 'Fred says hello' +say(['fred', 'hello']); +// => 'fred says hello' // with a Promise var numbers = Promise.all([ @@ -3969,7 +4075,7 @@ numbers.then(_.spread(function(x, y) { ### `_.throttle(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L7984 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8221 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the npm package") Creates a function that only invokes `func` at most once per every `wait` milliseconds. The created function comes with a `cancel` method to cancel @@ -4017,7 +4123,7 @@ jQuery(window).on('popstate', throttled.cancel); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8024 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.wrap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8261 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.wrap "See the npm package") Creates a function that provides `value` to the wrapper function as its first argument. Any additional arguments provided to the function are @@ -4053,7 +4159,7 @@ p('fred, barney, & pebbles'); ### `_.clone(value, [isDeep], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8082 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8319 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") 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 @@ -4114,7 +4220,7 @@ el.childNodes.length; ### `_.cloneDeep(value, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8140 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8377 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") Creates a deep clone of `value`. If `customizer` is provided it is invoked to produce the cloned values. If `customizer` returns `undefined` cloning @@ -4169,7 +4275,7 @@ el.childNodes.length; ### `_.isArguments(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8161 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8398 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") Checks if `value` is classified as an `arguments` object. @@ -4194,7 +4300,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8190 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8427 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") Checks if `value` is classified as an `Array` object. @@ -4219,7 +4325,7 @@ _.isArray(function() { return arguments; }()); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8210 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isboolean "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8447 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isboolean "See the npm package") Checks if `value` is classified as a boolean primitive or object. @@ -4244,7 +4350,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8230 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8467 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") Checks if `value` is classified as a `Date` object. @@ -4269,7 +4375,7 @@ _.isDate('Mon April 23 2012'); ### `_.isElement(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8250 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8487 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") Checks if `value` is a DOM element. @@ -4294,7 +4400,7 @@ _.isElement(''); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8288 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8525 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") 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 @@ -4330,13 +4436,13 @@ _.isEmpty({ 'a': 1 }); ### `_.isEqual(value, other, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8343 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8580 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm package") 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]). +arguments: (value, other [, index|key]).

**Note:** This method supports comparing arrays, booleans, `Date` objects, @@ -4383,7 +4489,7 @@ _.isEqual(array, other, function(value, other) { ### `_.isError(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8369 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iserror "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8606 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iserror "See the npm package") Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, `SyntaxError`, `TypeError`, or `URIError` object. @@ -4409,7 +4515,7 @@ _.isError(Error); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8402 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8639 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") Checks if `value` is a finite primitive number.
@@ -4448,7 +4554,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8422 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8659 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") Checks if `value` is classified as a `Function` object. @@ -4473,13 +4579,13 @@ _.isFunction(/abc/); ### `_.isMatch(object, source, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8497 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8734 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") 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). +to `thisArg` and invoked with three arguments: (value, other, index|key).

**Note:** This method supports comparing properties of arrays, booleans, @@ -4522,7 +4628,7 @@ _.isMatch(object, source, function(value, other) { ### `_.isNaN(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8546 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8789 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") Checks if `value` is `NaN`.
@@ -4558,7 +4664,7 @@ _.isNaN(undefined); ### `_.isNative(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8568 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8811 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") Checks if `value` is a native function. @@ -4583,7 +4689,7 @@ _.isNative(_); ### `_.isNull(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8595 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8837 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") Checks if `value` is `null`. @@ -4608,7 +4714,7 @@ _.isNull(void 0); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8621 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnumber "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8863 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnumber "See the npm package") Checks if `value` is classified as a `Number` primitive or object.
@@ -4640,7 +4746,7 @@ _.isNumber('8.4'); ### `_.isObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8451 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8688 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the npm package") Checks if `value` is the language type of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) @@ -4672,7 +4778,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8655 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8897 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isplainobject "See the npm package") Checks if `value` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`. @@ -4712,7 +4818,7 @@ _.isPlainObject(Object.create(null)); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8683 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8925 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") Checks if `value` is classified as a `RegExp` object. @@ -4737,7 +4843,7 @@ _.isRegExp('/abc/'); ### `_.isString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8703 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isstring "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8945 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isstring "See the npm package") Checks if `value` is classified as a `String` primitive or object. @@ -4762,7 +4868,7 @@ _.isString(1); ### `_.isTypedArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8723 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8965 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") Checks if `value` is classified as a typed array. @@ -4787,7 +4893,7 @@ _.isTypedArray([]); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8743 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L8985 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") Checks if `value` is `undefined`. @@ -4812,7 +4918,7 @@ _.isUndefined(null); ### `_.toArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8762 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9004 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") Converts `value` to an array. @@ -4836,7 +4942,7 @@ Converts `value` to an array. ### `_.toPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8798 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9040 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toplainobject "See the npm package") Converts `value` to a plain object flattening inherited enumerable properties of `value` to own properties of the plain object. @@ -4874,7 +4980,7 @@ _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); ### `_.add(augend, addend)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11190 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11394 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm package") Adds two numbers. @@ -4897,16 +5003,16 @@ _.add(6, 4); ### `_.max(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11241 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11445 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm package") Gets the maximum value of `collection`. If `collection` is empty or falsey `-Infinity` is returned. If an iteratee function is provided it is invoked for each value in `collection` to generate the criterion by which the value is ranked. The `iteratee` is bound to `thisArg` and invoked with three -arguments; (value, index, collection). +arguments: (value, index, collection).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -4915,7 +5021,7 @@ 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 +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`. @@ -4943,11 +5049,11 @@ var users = [ _.max(users, function(chr) { return chr.age; }); -// => { 'user': 'fred', 'age': 40 }; +// => { 'user': 'fred', 'age': 40 } // using the `_.property` callback shorthand _.max(users, 'age'); -// => { 'user': 'fred', 'age': 40 }; +// => { 'user': 'fred', 'age': 40 } ``` * * * @@ -4956,16 +5062,16 @@ _.max(users, 'age'); ### `_.min(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11290 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.min "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11494 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.min "See the npm package") Gets the minimum value of `collection`. If `collection` is empty or falsey `Infinity` is returned. If an iteratee function is provided it is invoked for each value in `collection` to generate the criterion by which the value is ranked. The `iteratee` is bound to `thisArg` and invoked with three -arguments; (value, index, collection). +arguments: (value, index, collection).

-If a property name is provided for `predicate` the created `_.property` +If a property name is provided for `iteratee` the created `_.property` style callback returns the property value of the given element.

@@ -4974,7 +5080,7 @@ 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 +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`. @@ -5002,11 +5108,11 @@ var users = [ _.min(users, function(chr) { return chr.age; }); -// => { 'user': 'barney', 'age': 36 }; +// => { 'user': 'barney', 'age': 36 } // using the `_.property` callback shorthand _.min(users, 'age'); -// => { 'user': 'barney', 'age': 36 }; +// => { 'user': 'barney', 'age': 36 } ``` * * * @@ -5014,24 +5120,40 @@ _.min(users, 'age'); -### `_.sum(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11308 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sum "See the npm package") +### `_.sum(collection, [iteratee], [thisArg])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11528 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sum "See the npm package") Gets the sum of the values in `collection`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to iterate over. +2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. +3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(number)*: Returns the sum. #### Example ```js -_.sum([4, 6, 2]); -// => 12 +_.sum([4, 6]); +// => 10 + +_.sum({ 'a': 4, 'b': 6 }); +// => 10 + +var objects = [ + { 'n': 4 }, + { 'n': 6 } +]; + +_.sum(objects, function(object) { + return object.n; +}); +// => 10 -_.sum({ 'a': 4, 'b': 6, 'c': 2 }); -// => 12 +// using the `_.property` callback shorthand +_.sum(objects, 'n'); +// => 10 ``` * * * @@ -5046,7 +5168,7 @@ _.sum({ 'a': 4, 'b': 6, 'c': 2 }); ### `_.inRange(n, [start=0], end)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9728 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.inrange "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9948 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.inrange "See the npm package") 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`. @@ -5086,7 +5208,7 @@ _.inRange(5.2, 4); ### `_.random([min=0], [max=1], [floating])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9766 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9986 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") 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. @@ -5128,14 +5250,17 @@ _.random(1.2, 5.2); ### `_.assign(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8833 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9075 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") 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; +The `customizer` is bound to `thisArg` and invoked with five arguments:
(objectValue, sourceValue, key, object, source). +#### Aliases +*_.extend* + #### Arguments 1. `object` *(Object)*: The destination object. 2. `[sources]` *(...Object)*: The source objects. @@ -5165,7 +5290,7 @@ defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.create(prototype, [properties])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8869 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9111 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") Creates an object that inherits from the given `prototype` object. If a `properties` object is provided its own enumerable properties are assigned @@ -5207,7 +5332,7 @@ circle instanceof Shape; ### `_.defaults(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8893 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9135 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a @@ -5232,10 +5357,10 @@ _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.findKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L8950 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9192 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findkey "See the npm package") -This method is like `_.findIndex` except that it returns the key of the -first element `predicate` returns truthy for, instead of the element itself. +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` @@ -5291,7 +5416,7 @@ _.findKey(users, 'active'); ### `_.findLastKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9003 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9242 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastkey "See the npm package") This method is like `_.findKey` except that it iterates over elements of a collection in the opposite order. @@ -5350,11 +5475,11 @@ _.findLastKey(users, 'active'); ### `_.forIn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9035 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9271 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forin "See the npm package") 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). Iterator functions may exit +with three arguments: (value, key, object). Iterator functions may exit iteration early by explicitly returning `false`. #### Arguments @@ -5386,7 +5511,7 @@ _.forIn(new Foo, function(value, key) { ### `_.forInRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9067 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forinright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9298 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forinright "See the npm package") This method is like `_.forIn` except that it iterates over properties of `object` in the opposite order. @@ -5420,11 +5545,11 @@ _.forInRight(new Foo, function(value, key) { ### `_.forOwn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9099 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forown "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9327 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forown "See the npm package") 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). Iterator functions may exit iteration +three arguments: (value, key, object). Iterator functions may exit iteration early by explicitly returning `false`. #### Arguments @@ -5456,7 +5581,7 @@ _.forOwn(new Foo, function(value, key) { ### `_.forOwnRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9131 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forownright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9354 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forownright "See the npm package") This method is like `_.forOwn` except that it iterates over properties of `object` in the opposite order. @@ -5490,11 +5615,14 @@ _.forOwnRight(new Foo, function(value, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9151 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9371 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") Creates an array of function property names from all enumerable properties, own and inherited, of `object`. +#### Aliases +*_.methods* + #### Arguments 1. `object` *(Object)*: The object to inspect. @@ -5513,7 +5641,7 @@ _.functions(_); ### `_.has(object, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9172 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9392 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") Checks if `key` exists as a direct property of `object` instead of an inherited property. @@ -5539,7 +5667,7 @@ _.has(object, 'b'); ### `_.invert(object, [multiValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9199 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invert "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9419 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invert "See the npm package") Creates an object composed of the inverted keys and values of `object`. If `object` contains duplicate values, subsequent values overwrite property @@ -5570,7 +5698,7 @@ _.invert(object, true); ### `_.keys(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9253 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keys "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9473 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keys "See the npm package") Creates an array of the own enumerable property names of `object`.
@@ -5607,7 +5735,7 @@ _.keys('hi'); ### `_.keysIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9287 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keysin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9507 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keysin "See the npm package") Creates an array of the own and inherited enumerable property names of `object`.
@@ -5639,11 +5767,11 @@ _.keysIn(new Foo); ### `_.mapValues(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9386 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapvalues "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9606 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapvalues "See the npm package") 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; +iteratee function is bound to `thisArg` and invoked with three arguments:
(value, key, object).

@@ -5691,7 +5819,7 @@ _.mapValues(users, 'age'); ### `_.merge(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9444 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9664 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined` into the destination object. Subsequent sources @@ -5699,7 +5827,7 @@ 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). +with five arguments: (objectValue, sourceValue, key, object, source). #### Arguments 1. `object` *(Object)*: The destination object. @@ -5748,14 +5876,14 @@ _.merge(object, other, function(a, b) { ### `_.omit(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9474 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omit "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9694 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omit "See the npm package") The opposite of `_.pick`; this method creates an object composed of the own and inherited enumerable properties of `object` that are not omitted. 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` omitting the properties `predicate` returns truthy for. The -predicate is bound to `thisArg` and invoked with three arguments; +predicate is bound to `thisArg` and invoked with three arguments:
(value, key, object). #### Arguments @@ -5783,7 +5911,7 @@ _.omit(object, _.isNumber); ### `_.pairs(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9502 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pairs "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9722 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pairs "See the npm package") Creates a two dimensional array of the key-value pairs for `object`, e.g. `[[key1, value1], [key2, value2]]`. @@ -5806,13 +5934,13 @@ _.pairs({ 'barney': 36, 'fred': 40 }); ### `_.pick(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9541 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9761 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") 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). +bound to `thisArg` and invoked with three arguments: (value, key, object). #### Arguments 1. `object` *(Object)*: The source object. @@ -5839,7 +5967,7 @@ _.pick(object, _.isString); ### `_.result(object, key, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9580 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.result "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9800 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.result "See the npm package") Resolves the value of property `key` on `object`. If the value of `key` is a function it is invoked with the `this` binding of `object` and its result @@ -5877,13 +6005,13 @@ _.result(object, 'status', _.constant('busy')); ### `_.transform(object, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9617 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.transform "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9837 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.transform "See the npm package") 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). Iterator functions +with four arguments: (accumulator, value, key, object). Iterator functions may exit iteration early by explicitly returning `false`. #### Arguments @@ -5915,7 +6043,7 @@ _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9664 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.values "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9884 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.values "See the npm package") Creates an array of the own enumerable property values of `object`.
@@ -5950,7 +6078,7 @@ _.values('hi'); ### `_.valuesIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9691 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.valuesin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L9911 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.valuesin "See the npm package") Creates an array of the own and inherited enumerable property values of `object`. @@ -5989,7 +6117,7 @@ _.valuesIn(new Foo); ### `_.camelCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9823 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.camelcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10043 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.camelcase "See the npm package") Converts `string` to camel case. See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details. @@ -6018,7 +6146,7 @@ _.camelCase('__foo_bar__'); ### `_.capitalize([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9841 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10061 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") Capitalizes the first character of `string`. @@ -6040,7 +6168,7 @@ _.capitalize('fred'); ### `_.deburr([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9861 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.deburr "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10081 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.deburr "See the npm package") Deburrs `string` by converting latin-1 supplementary letters to basic latin letters. See [Wikipedia](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) @@ -6064,7 +6192,7 @@ _.deburr('déjà vu'); ### `_.endsWith([string=''], [target], [position=string.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9887 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10107 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") Checks if `string` ends with the given target string. @@ -6094,7 +6222,7 @@ _.endsWith('abc', 'b', 2); ### `_.escape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9932 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10152 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to their corresponding HTML entities. @@ -6139,10 +6267,10 @@ _.escape('fred, barney, & pebbles'); ### `_.escapeRegExp([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9954 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10174 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") -Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", -"+", "(", ")", "[", "]", "{" and "}" in `string`. +Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?", +"*", "+", "(", ")", "[", "]", "{" and "}" in `string`. #### Arguments 1. `[string='']` *(string)*: The string to escape. @@ -6153,7 +6281,7 @@ Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", #### Example ```js _.escapeRegExp('[lodash](https://lodash.com/)'); -// => '\[lodash\]\(https://lodash\.com/\)' +// => '\[lodash\]\(https:\/\/lodash\.com\/\)' ``` * * * @@ -6162,7 +6290,7 @@ _.escapeRegExp('[lodash](https://lodash.com/)'); ### `_.kebabCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L9982 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10202 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") Converts `string` to kebab case. See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for @@ -6192,11 +6320,10 @@ _.kebabCase('__foo_bar__'); ### `_.pad([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10009 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pad "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10228 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pad "See the npm package") -Pads `string` on the left and right sides if it is shorter then the given -padding length. The `chars` string may be truncated if the number of padding -characters can't be evenly divided by the padding length. +Pads `string` on the left and right sides if it is shorter than `length`. +Padding characters are truncated if they can't be evenly divided by `length`. #### Arguments 1. `[string='']` *(string)*: The string to pad. @@ -6224,11 +6351,10 @@ _.pad('abc', 3); ### `_.padLeft([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10048 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padleft "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10266 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padleft "See the npm package") -Pads `string` on the left side if it is shorter then the given padding -length. The `chars` string may be truncated if the number of padding -characters exceeds the padding length. +Pads `string` on the left side if it is shorter than `length`. Padding +characters are truncated if they exceed `length`. #### Arguments 1. `[string='']` *(string)*: The string to pad. @@ -6256,11 +6382,10 @@ _.padLeft('abc', 3); ### `_.padRight([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10076 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10290 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padright "See the npm package") -Pads `string` on the right side if it is shorter then the given padding -length. The `chars` string may be truncated if the number of padding -characters exceeds the padding length. +Pads `string` on the right side if it is shorter than `length`. Padding +characters are truncated if they exceed `length`. #### Arguments 1. `[string='']` *(string)*: The string to pad. @@ -6288,7 +6413,7 @@ _.padRight('abc', 3); ### `_.parseInt(string, [radix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10104 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.parseint "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10315 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.parseint "See the npm package") 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, @@ -6320,7 +6445,7 @@ _.map(['6', '08', '10'], _.parseInt); ### `_.repeat([string=''], [n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10146 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10357 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") Repeats the given string `n` times. @@ -6349,7 +6474,7 @@ _.repeat('abc', 0); ### `_.snakeCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10186 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.snakecase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10397 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.snakecase "See the npm package") Converts `string` to snake case. See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details. @@ -6378,7 +6503,7 @@ _.snakeCase('--foo-bar'); ### `_.startCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10211 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10422 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startcase "See the npm package") Converts `string` to start case. See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage) @@ -6408,7 +6533,7 @@ _.startCase('__foo_bar__'); ### `_.startsWith([string=''], [target], [position=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10236 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10447 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") Checks if `string` starts with the given target string. @@ -6438,7 +6563,7 @@ _.startsWith('abc', 'b', 1); ### `_.template([string=''], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10341 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.template "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10552 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.template "See the npm package") Creates a compiled template function that can interpolate data properties in "interpolate" delimiters, HTML-escape interpolated data properties in @@ -6545,7 +6670,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.trim([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10468 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trim "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10679 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trim "See the npm package") Removes leading and trailing whitespace or specified characters from `string`. @@ -6565,7 +6690,7 @@ _.trim('-_-abc-_-', '_-'); // => 'abc' _.map([' foo ', ' bar '], _.trim); -// => ['foo', 'bar] +// => ['foo', 'bar'] ``` * * * @@ -6574,7 +6699,7 @@ _.map([' foo ', ' bar '], _.trim); ### `_.trimLeft([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10499 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimleft "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10710 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimleft "See the npm package") Removes leading whitespace or specified characters from `string`. @@ -6600,7 +6725,7 @@ _.trimLeft('-_-abc-_-', '_-'); ### `_.trimRight([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10529 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10740 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimright "See the npm package") Removes trailing whitespace or specified characters from `string`. @@ -6626,7 +6751,7 @@ _.trimRight('-_-abc-_-', '_-'); ### `_.trunc([string=''], [options], [options.length=30], [options.omission='...'], [options.separator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10581 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trunc "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10792 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trunc "See the npm package") Truncates `string` if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the omission @@ -6660,7 +6785,7 @@ _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); -//=> 'hi-diddly-ho there...' +// => 'hi-diddly-ho there...' _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' @@ -6674,7 +6799,7 @@ _.trunc('hi-diddly-ho there, neighborino', { ### `_.unescape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10651 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unescape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10862 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unescape "See the npm package") The inverse of `_.escape`; this method converts the HTML entities `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their @@ -6702,7 +6827,7 @@ _.unescape('fred, barney, & pebbles'); ### `_.words([string=''], [pattern])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10676 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10887 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") Splits `string` into an array of its words. @@ -6734,13 +6859,13 @@ _.words('fred, barney, & pebbles', /[^, ]+/g); ### `_.attempt(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10706 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.attempt "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10917 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.attempt "See the npm package") Attempts to invoke `func`, returning either the result or the caught error object. Any additional arguments are provided to `func` when it is invoked. #### Arguments -1. `func` *(*)*: The function to attempt. +1. `func` *(Function)*: The function to attempt. #### Returns *(*)*: Returns the `func` result or error object. @@ -6763,7 +6888,7 @@ if (_.isError(elements)) { ### `_.callback([func=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10759 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.callback "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10963 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.callback "See the npm package") Creates a function that invokes `func` with the `this` binding of `thisArg` and arguments of the created function. If `func` is a property name the @@ -6771,6 +6896,9 @@ created callback returns the property value for a given element. If `func` is an object the created callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`. +#### Aliases +*_.iteratee* + #### Arguments 1. `[func=_.identity]` *(*)*: The value to convert to a callback. 2. `[thisArg]` *(*)*: The `this` binding of `func`. @@ -6808,7 +6936,7 @@ _.filter(users, 'age__gt36'); ### `_.constant(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10784 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L10988 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") Creates a function that returns `value`. @@ -6833,7 +6961,7 @@ getter() === object; ### `_.identity(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10805 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11009 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") This method returns the first argument provided to it. @@ -6857,7 +6985,7 @@ _.identity(object) === object; ### `_.matches(source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10834 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11038 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") Creates a function which performs a deep comparison between a given object and `source`, returning `true` if the given object has equivalent property @@ -6892,7 +7020,7 @@ _.filter(users, _.matches({ 'age': 40, 'active': false })); ### `_.matchesProperty(key, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10863 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11066 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") Creates a function which compares the property value of `key` on a given object to `value`. @@ -6913,12 +7041,11 @@ their own, not inherited, enumerable properties. ```js var users = [ { 'user': 'barney' }, - { 'user': 'fred' }, - { 'user': 'pebbles' } + { 'user': 'fred' } ]; _.find(users, _.matchesProperty('user', 'fred')); -// => { 'user': 'fred', 'age': 40 } +// => { 'user': 'fred' } ``` * * * @@ -6927,11 +7054,15 @@ _.find(users, _.matchesProperty('user', 'fred')); ### `_.mixin([object=this], source, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10903 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mixin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11109 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mixin "See the npm package") Adds all own enumerable function properties of a source object to the destination object. If `object` is a function then methods are added to its prototype as well. +
+
+**Note:** Use `_.runInContext` to create a pristine `lodash` function +for mixins to avoid conflicts caused by modifying the original. #### Arguments 1. `[object=this]` *(Function|Object)*: object The destination object. @@ -6950,7 +7081,7 @@ function vowels(string) { }); } -// use `_.runInContext` to avoid potential conflicts (esp. in Node.js) +// use `_.runInContext` to avoid conflicts (esp. in Node.js) var _ = require('lodash').runInContext(); _.mixin({ 'vowels': vowels }); @@ -6971,7 +7102,7 @@ _('fred').vowels(); ### `_.noConflict()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10970 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noconflict "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11174 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noconflict "See the npm package") Reverts the `_` variable to its previous value and returns a reference to the `lodash` function. @@ -6990,7 +7121,7 @@ var lodash = _.noConflict(); ### `_.noop()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L10989 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11193 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") A no-operation function which returns `undefined` regardless of the arguments it receives. @@ -7009,7 +7140,7 @@ _.noop(object) === undefined; ### `_.property(key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11016 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.property "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11220 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.property "See the npm package") Creates a function which returns the property value of `key` on a given object. @@ -7029,7 +7160,7 @@ var users = [ var getName = _.property('user'); _.map(users, getName); -// => ['fred', barney'] +// => ['fred', 'barney'] _.pluck(_.sortBy(users, getName), 'user'); // => ['barney', 'fred'] @@ -7041,9 +7172,9 @@ _.pluck(_.sortBy(users, getName), 'user'); ### `_.propertyOf(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11039 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.propertyof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11243 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.propertyof "See the npm package") -The inverse of `_.property`; this method creates a function which returns +The opposite of `_.property`; this method creates a function which returns the property value of a given key on `object`. #### Arguments @@ -7069,7 +7200,7 @@ _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11078 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.range "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11282 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.range "See the npm package") Creates an array of numbers (positive and/or negative) progressing from `start` up to, but not including, `end`. If `end` is not specified it is @@ -7111,7 +7242,7 @@ _.range(0); ### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L693 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.runincontext "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L719 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.runincontext "See the npm package") Create a new pristine `lodash` function using the given `context` object. @@ -7123,19 +7254,19 @@ Create a new pristine `lodash` function using the given `context` object. #### Example ```js -_.mixin({ 'add': function(a, b) { return a + b; } }); +_.mixin({ 'foo': _.constant('foo') }); var lodash = _.runInContext(); -lodash.mixin({ 'sub': function(a, b) { return a - b; } }); +lodash.mixin({ 'bar': lodash.constant('bar') }); -_.isFunction(_.add); +_.isFunction(_.foo); // => true -_.isFunction(_.sub); +_.isFunction(_.bar); // => false -lodash.isFunction(lodash.add); +lodash.isFunction(lodash.foo); // => false -lodash.isFunction(lodash.sub); +lodash.isFunction(lodash.bar); // => true // using `context` to mock `Date#getTime` use in `_.now` @@ -7155,7 +7286,7 @@ var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; ### `_.times(n, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11131 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11335 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") Invokes the iteratee function `n` times, returning an array of the results of each invocation. The `iteratee` is bound to `thisArg` and invoked with @@ -7191,7 +7322,7 @@ _.times(3, function(n) { ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11169 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11373 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") Generates a unique ID. If `prefix` is provided the ID is appended to it. @@ -7222,7 +7353,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1186 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1215 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -7239,7 +7370,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L11590 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L11814 "View in source") [Ⓣ][1] (string): The semantic version number. @@ -7250,7 +7381,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L975 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.support "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1004 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.support "See the npm package") (Object): An object environment feature flags. @@ -7261,7 +7392,7 @@ A reference to the `lodash` function. ### `_.support.argsTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L992 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1021 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of `arguments` objects is resolvable (all but Firefox < 4, IE < 9). @@ -7273,7 +7404,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1001 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1030 "View in source") [Ⓣ][1] (boolean): Detect if `name` or `message` properties of `Error.prototype` are enumerable by default (IE < 9, Safari < 5.1). @@ -7285,7 +7416,7 @@ enumerable by default (IE < 9, Safari < 5.1). ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1015 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1044 "View in source") [Ⓣ][1] (boolean): Detect if `prototype` properties are enumerable by default.
@@ -7302,7 +7433,7 @@ property to `true`. ### `_.support.funcDecomp` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1025 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1054 "View in source") [Ⓣ][1] (boolean): Detect if functions can be decompiled by `Function#toString` (all but Firefox OS certified apps, older Opera mobile browsers, and @@ -7315,7 +7446,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.funcNames` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1033 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1062 "View in source") [Ⓣ][1] (boolean): Detect if `Function#name` is supported (all but IE). @@ -7326,7 +7457,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nodeTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1041 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1070 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9). @@ -7337,7 +7468,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1091 "View in source") [Ⓣ][1] (boolean): Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -7353,7 +7484,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.nonEnumStrings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1079 "View in source") [Ⓣ][1] (boolean): Detect if string indexes are non-enumerable (IE < 9, RingoJS, Rhino, Narwhal). @@ -7365,7 +7496,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.ownLast` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1070 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1099 "View in source") [Ⓣ][1] (boolean): Detect if own properties are iterated after inherited properties (IE < 9). @@ -7376,7 +7507,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1085 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1114 "View in source") [Ⓣ][1] (boolean): Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -7395,7 +7526,7 @@ is buggy regardless of mode in IE < 9. ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1096 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1125 "View in source") [Ⓣ][1] (boolean): Detect lack of support for accessing string characters by index.
@@ -7410,7 +7541,7 @@ by index on string literals, not string objects. ### `_.templateSettings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1138 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.templatesettings "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1167 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.templatesettings "See the npm package") (Object): By default, the template delimiters used by lodash are like those in embedded Ruby (ERB). Change the following template settings to use @@ -7423,7 +7554,7 @@ alternative delimiters. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1175 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to be HTML-escaped. @@ -7434,7 +7565,7 @@ alternative delimiters. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1154 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1183 "View in source") [Ⓣ][1] (RegExp): Used to detect code to be evaluated. @@ -7445,7 +7576,7 @@ alternative delimiters. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1178 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1207 "View in source") [Ⓣ][1] (Object): Used to import variables into the compiled template. @@ -7456,7 +7587,7 @@ alternative delimiters. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1191 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to inject. @@ -7467,7 +7598,7 @@ alternative delimiters. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.5.0/lodash.src.js#L1170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.6.0/lodash.src.js#L1199 "View in source") [Ⓣ][1] (string): Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index c62ae05126..da29d9925a 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.5.0 (Custom Build) + * lodash 3.6.0 (Custom Build) * Build: `lodash modern -o ./lodash.js` * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.8.2 @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.5.0'; + var VERSION = '3.6.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -23,8 +23,8 @@ CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, - REARG_FLAG = 128, - ARY_FLAG = 256; + ARY_FLAG = 128, + REARG_FLAG = 256; /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, @@ -88,18 +88,18 @@ reInterpolate = /<%=([\s\S]+?)%>/g; /** - * Used to match ES template delimiters. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components) - * for more details. + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + */ + var reComboMarks = /[\u0300-\u036f\ufe20-\ufe23]/g; + + /** + * Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components). */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; - /** Used to detect named functions. */ - var reFuncName = /^\s*function[ \n\r\t]+\w/; - /** Used to detect hexadecimal string values. */ var reHexPrefix = /^0[xX]/; @@ -113,16 +113,13 @@ var reNoMatch = /($^)/; /** - * Used to match `RegExp` special characters. - * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) - * for more details. + * Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special). + * In addition to special characters the forward slash is escaped to allow for + * easier `eval` use and `Function` compilation. */ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, reHasRegExpChars = RegExp(reRegExpChars.source); - /** Used to detect functions containing a `this` reference. */ - var reThis = /\bthis\b/; - /** Used to match unescaped characters in compiled string literals. */ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; @@ -153,7 +150,7 @@ 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', - 'window', 'WinRTError' + 'window' ]; /** Used to make template sourceURLs easier to identify. */ @@ -262,8 +259,11 @@ /** Detect free variable `global` from Node.js. */ var freeGlobal = freeExports && freeModule && typeof 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; + var freeWindow = objectTypes[typeof window] && window && window.Object && window; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; @@ -274,7 +274,7 @@ * The `this` value is used if it is the global object to avoid Greasemonkey's * restricted `window` object, otherwise the `window` object is used. */ - var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this; + var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; /*--------------------------------------------------------------------------*/ @@ -302,6 +302,28 @@ 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. * @@ -488,7 +510,6 @@ /** * Gets the index at which the first occurrence of `NaN` is found in `array`. - * If `fromRight` is provided elements of `array` are iterated from right to left. * * @private * @param {Array} array The array to search. @@ -517,7 +538,7 @@ * @returns {boolean} Returns `true` if `value` is object-like, else `false`. */ function isObjectLike(value) { - return (value && typeof value == 'object') || false; + return !!value && typeof value == 'object'; } /** @@ -639,19 +660,19 @@ * @returns {Function} Returns a new `lodash` function. * @example * - * _.mixin({ 'add': function(a, b) { return a + b; } }); + * _.mixin({ 'foo': _.constant('foo') }); * * var lodash = _.runInContext(); - * lodash.mixin({ 'sub': function(a, b) { return a - b; } }); + * lodash.mixin({ 'bar': lodash.constant('bar') }); * - * _.isFunction(_.add); + * _.isFunction(_.foo); * // => true - * _.isFunction(_.sub); + * _.isFunction(_.bar); * // => false * - * lodash.isFunction(lodash.add); + * lodash.isFunction(lodash.foo); * // => false - * lodash.isFunction(lodash.sub); + * lodash.isFunction(lodash.bar); * // => true * * // using `context` to mock `Date#getTime` use in `_.now` @@ -704,9 +725,8 @@ var idCounter = 0; /** - * Used to resolve the `toStringTag` of values. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) - * for more details. + * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) + * of values. */ var objToString = objectProto.toString; @@ -771,15 +791,17 @@ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** - * Used as the maximum length of an array-like value. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) - * for more details. + * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) + * of an array-like value. */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; /** Used to store function metadata. */ var metaMap = WeakMap && new WeakMap; + /** Used to lookup unminified function names. */ + var realNames = {}; + /*------------------------------------------------------------------------*/ /** @@ -929,7 +951,7 @@ * @memberOf _.support * @type boolean */ - support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext); + support.funcDecomp = /\bthis\b/.test(function() { return this; }); /** * Detect if `Function#name` is supported (all but IE). @@ -1305,7 +1327,7 @@ /** * A specialized version of `_.forEach` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1326,7 +1348,7 @@ /** * A specialized version of `_.forEachRight` for arrays without support for - * callback shorthands or `this` binding. + * callback shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1346,7 +1368,7 @@ /** * A specialized version of `_.every` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1368,7 +1390,7 @@ /** * A specialized version of `_.filter` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1392,7 +1414,7 @@ /** * A specialized version of `_.map` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1454,7 +1476,7 @@ /** * A specialized version of `_.reduce` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1479,7 +1501,7 @@ /** * A specialized version of `_.reduceRight` for arrays without support for - * callback shorthands or `this` binding. + * callback shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1502,7 +1524,7 @@ /** * A specialized version of `_.some` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1522,6 +1544,23 @@ return false; } + /** + * A specialized version of `_.sum` for arrays without support for iteratees. + * + * @private + * @param {Array} array The array to iterate over. + * @returns {number} Returns the sum. + */ + function arraySum(array) { + var length = array.length, + result = 0; + + while (length--) { + result += +array[length] || 0; + } + return result; + } + /** * Used by `_.defaults` to customize its `_.assign` use. * @@ -1636,26 +1675,6 @@ return object; } - /** - * The base implementation of `_.bindAll` without support for individual - * method name arguments. - * - * @private - * @param {Object} object The object to bind and assign the bound methods to. - * @param {string[]} methodNames The object method names to bind. - * @returns {Object} Returns `object`. - */ - function baseBindAll(object, methodNames) { - var index = -1, - length = methodNames.length; - - while (++index < length) { - var key = methodNames[index]; - object[key] = createWrapper(object[key], BIND_FLAG, object); - } - return object; - } - /** * The base implementation of `_.callback` which supports specifying the * number of arguments to provide to `func`. @@ -1669,9 +1688,9 @@ function baseCallback(func, thisArg, argCount) { var type = typeof func; if (type == 'function') { - return (typeof thisArg != 'undefined' && isBindable(func)) - ? bindCallback(func, thisArg, argCount) - : func; + return typeof thisArg == 'undefined' + ? func + : bindCallback(func, thisArg, argCount); } if (func == null) { return identity; @@ -1778,14 +1797,14 @@ * @private * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. - * @param {Object} args The `arguments` object to slice and provide to `func`. + * @param {Object} args The arguments provide to `func`. * @returns {number} Returns the timer id. */ - function baseDelay(func, wait, args, fromIndex) { + function baseDelay(func, wait, args) { if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - return setTimeout(function() { func.apply(undefined, baseSlice(args, fromIndex)); }, wait); + return setTimeout(function() { func.apply(undefined, args); }, wait); } /** @@ -1844,21 +1863,7 @@ * @param {Function} iteratee The function invoked per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEach(collection, iteratee) { - var length = collection ? collection.length : 0; - if (!isLength(length)) { - return baseForOwn(collection, iteratee); - } - var index = -1, - iterable = toObject(collection); - - while (++index < length) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - } + var baseEach = createBaseEach(baseForOwn); /** * The base implementation of `_.forEachRight` without support for callback @@ -1869,23 +1874,11 @@ * @param {Function} iteratee The function invoked per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEachRight(collection, iteratee) { - var length = collection ? collection.length : 0; - if (!isLength(length)) { - return baseForOwnRight(collection, iteratee); - } - var iterable = toObject(collection); - while (length--) { - if (iteratee(iterable[length], length, iterable) === false) { - break; - } - } - return collection; - } + var baseEachRight = createBaseEach(baseForOwnRight, true); /** * The base implementation of `_.every` without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -1934,7 +1927,7 @@ /** * The base implementation of `_.filter` without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -1983,11 +1976,10 @@ * @param {Array} array The array to flatten. * @param {boolean} isDeep Specify a deep flatten. * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects. - * @param {number} fromIndex The index to start from. * @returns {Array} Returns the new flattened array. */ - function baseFlatten(array, isDeep, isStrict, fromIndex) { - var index = fromIndex - 1, + function baseFlatten(array, isDeep, isStrict) { + var index = -1, length = array.length, resIndex = -1, result = []; @@ -1998,7 +1990,7 @@ if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) { if (isDeep) { // Recursively flatten arrays (susceptible to call stack limits). - value = baseFlatten(value, isDeep, isStrict, 0); + value = baseFlatten(value, isDeep, isStrict); } var valIndex = -1, valLength = value.length; @@ -2026,20 +2018,7 @@ * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseFor(object, iteratee, keysFunc) { - var index = -1, - iterable = toObject(object), - props = keysFunc(object), - length = props.length; - - while (++index < length) { - var key = props[index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - } + var baseFor = createBaseFor(); /** * This function is like `baseFor` except that it iterates over properties @@ -2051,19 +2030,7 @@ * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseForRight(object, iteratee, keysFunc) { - var iterable = toObject(object), - props = keysFunc(object), - length = props.length; - - while (length--) { - var key = props[length]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - } + var baseForRight = createBaseFor(true); /** * The base implementation of `_.forIn` without support for callback @@ -2128,30 +2095,6 @@ return result; } - /** - * The base implementation of `_.invoke` which requires additional arguments - * to be provided as an array of arguments rather than individually. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|string} methodName The name of the method to invoke or - * the function invoked per iteration. - * @param {Array} [args] The arguments to invoke the method with. - * @returns {Array} Returns the array of results. - */ - function baseInvoke(collection, methodName, args) { - var index = -1, - isFunc = typeof methodName == 'function', - length = collection ? collection.length : 0, - result = isLength(length) ? Array(length) : []; - - baseEach(collection, function(value) { - var func = isFunc ? methodName : (value != null && value[methodName]); - result[++index] = func ? func.apply(value, args) : undefined; - }); - return result; - } - /** * The base implementation of `_.isEqual` without support for `this` binding * `customizer` functions. @@ -2160,12 +2103,12 @@ * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { // Exit early for identical values. if (value === other) { // Treat `+0` vs. `-0` as not equal. @@ -2180,7 +2123,7 @@ // Return `false` unless both values are `NaN`. return value !== value && other !== other; } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB); + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); } /** @@ -2193,12 +2136,12 @@ * @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} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { var objIsArr = isArray(object), othIsArr = isArray(other), objTag = arrayTag, @@ -2220,21 +2163,27 @@ othIsArr = isTypedArray(other); } } - var objIsObj = objTag == objectTag, - othIsObj = othTag == objectTag, + var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)), + othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)), isSameTag = objTag == othTag; if (isSameTag && !(objIsArr || objIsObj)) { return equalByTag(object, other, objTag); } - var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + if (isLoose) { + if (!isSameTag && !(objIsObj && othIsObj)) { + return false; + } + } else { + var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - if (valWrapped || othWrapped) { - return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB); - } - if (!isSameTag) { - return false; + if (valWrapped || othWrapped) { + return equalFunc(valWrapped ? object.value() : object, othWrapped ? 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. @@ -2251,7 +2200,7 @@ stackA.push(object); stackB.push(other); - var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isWhere, stackA, stackB); + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); stackA.pop(); stackB.pop(); @@ -2261,7 +2210,7 @@ /** * The base implementation of `_.isMatch` without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Object} object The object to inspect. @@ -2272,30 +2221,27 @@ * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ function baseIsMatch(object, props, values, strictCompareFlags, customizer) { - var length = props.length; - if (object == null) { - return !length; - } var index = -1, + length = props.length, noCustomizer = !customizer; while (++index < length) { if ((noCustomizer && strictCompareFlags[index]) ? values[index] !== object[props[index]] - : !hasOwnProperty.call(object, props[index]) + : !(props[index] in object) ) { return false; } } index = -1; while (++index < length) { - var key = props[index]; + var key = props[index], + objValue = object[key], + srcValue = values[index]; + if (noCustomizer && strictCompareFlags[index]) { - var result = hasOwnProperty.call(object, key); + var result = typeof objValue != 'undefined' || (key in object); } else { - var objValue = object[key], - srcValue = values[index]; - result = customizer ? customizer(objValue, srcValue, key) : undefined; if (typeof result == 'undefined') { result = baseIsEqual(srcValue, objValue, customizer, true); @@ -2310,7 +2256,7 @@ /** * The base implementation of `_.map` without support for callback shorthands - * or `this` binding. + * and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2336,13 +2282,17 @@ var props = keys(source), length = props.length; + if (!length) { + return constant(true); + } if (length == 1) { var key = props[0], value = source[key]; if (isStrictComparable(value)) { return function(object) { - return object != null && object[key] === value && hasOwnProperty.call(object, key); + return object != null && object[key] === value && + (typeof value != 'undefined' || (key in toObject(object))); }; } } @@ -2355,7 +2305,7 @@ strictCompareFlags[length] = isStrictComparable(value); } return function(object) { - return baseIsMatch(object, props, values, strictCompareFlags); + return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags); }; } @@ -2371,7 +2321,8 @@ function baseMatchesProperty(key, value) { if (isStrictComparable(value)) { return function(object) { - return object != null && object[key] === value; + return object != null && object[key] === value && + (typeof value != 'undefined' || (key in toObject(object))); }; } return function(object) { @@ -2451,7 +2402,7 @@ if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) { result = isArray(value) ? value - : (value ? arrayCopy(value) : []); + : ((value && value.length) ? arrayCopy(value) : []); } else if (isPlainObject(srcValue) || isArguments(srcValue)) { result = isArguments(value) @@ -2488,30 +2439,6 @@ }; } - /** - * The base implementation of `_.pullAt` without support for individual - * index arguments. - * - * @private - * @param {Array} array The array to modify. - * @param {number[]} indexes The indexes of elements to remove. - * @returns {Array} Returns the new array of removed elements. - */ - function basePullAt(array, indexes) { - var length = indexes.length, - result = baseAt(array, indexes); - - indexes.sort(baseCompareAscending); - while (length--) { - var index = parseFloat(indexes[length]); - if (index != previous && isIndex(index)) { - var previous = index; - splice.call(array, index, 1); - } - } - return result; - } - /** * The base implementation of `_.random` without support for argument juggling * and returning floating-point numbers. @@ -2527,7 +2454,7 @@ /** * The base implementation of `_.reduce` and `_.reduceRight` without support - * for callback shorthands or `this` binding, which iterates over `collection` + * for callback shorthands and `this` binding, which iterates over `collection` * using the provided `eachFunc`. * * @private @@ -2594,7 +2521,7 @@ /** * The base implementation of `_.some` without support for callback shorthands - * or `this` binding. + * and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2661,6 +2588,23 @@ }); } + /** + * 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. @@ -2734,6 +2678,27 @@ 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 @@ -2742,7 +2707,7 @@ * @private * @param {*} value The unwrapped value. * @param {Array} actions Actions to peform to resolve the unwrapped value. - * @returns {*} Returns the resolved unwrapped value. + * @returns {*} Returns the resolved value. */ function baseWrapperValue(value, actions) { var result = value; @@ -2769,8 +2734,7 @@ * @private * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {boolean} [retHighest] Specify returning the highest, instead - * of the lowest, index at which a value should be inserted into `array`. + * @param {boolean} [retHighest] Specify returning the highest qualified index. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ @@ -2803,8 +2767,7 @@ * @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, instead - * of the lowest, index at which a value should be inserted into `array`. + * @param {boolean} [retHighest] Specify returning the highest qualified index. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ @@ -2970,6 +2933,9 @@ * object composed from the results of running each element in the collection * through an iteratee. * + * **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`, + * and `_.partition`. + * * @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. @@ -3001,6 +2967,8 @@ * Creates a function that assigns properties of source object(s) to a given * destination object. * + * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`. + * * @private * @param {Function} assigner The function to assign values. * @returns {Function} Returns the new assigner function. @@ -3040,6 +3008,56 @@ }; } + /** + * 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 ? collection.length : 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`. @@ -3070,41 +3088,6 @@ return new SetCache(values); }; - /** - * Creates a function to compose other functions into a single function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new composer function. - */ - function createComposer(fromRight) { - return function() { - var length = arguments.length, - index = length, - fromIndex = fromRight ? (length - 1) : 0; - - if (!length) { - return function() { return arguments[0]; }; - } - var funcs = Array(length); - while (index--) { - funcs[index] = arguments[index]; - if (typeof funcs[index] != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - } - return function() { - var index = fromIndex, - result = funcs[index].apply(this, arguments); - - while ((fromRight ? index-- : ++index < length)) { - result = funcs[index].call(this, result); - } - return result; - }; - }; - } - /** * Creates a function that produces compound words out of the words in a * given string. @@ -3147,7 +3130,26 @@ } /** - * Creates a function that gets the extremum value of a collection. + * 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 = null; + } + var result = createWrapper(func, flag, null, null, null, null, null, arity); + result.placeholder = curryFunc.placeholder; + return result; + } + return curryFunc; + } + + /** + * Creates a `_.max` or `_.min` function. * * @private * @param {Function} arrayFunc The function to get the extremum value from an array. @@ -3179,6 +3181,204 @@ }; } + /** + * 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 length = arguments.length; + if (!length) { + return function() { return arguments[0]; }; + } + var wrapper, + 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); + } + var funcName = wrapper ? '' : getFuncName(func); + wrapper = funcName == 'wrapper' ? new LodashWrapper([]) : wrapper; + } + index = wrapper ? -1 : length; + while (++index < length) { + func = funcs[index]; + funcName = getFuncName(func); + + var data = funcName == 'wrapper' ? getData(func) : null; + if (data && isLaziable(data[0])) { + 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; + if (wrapper && args.length == 1 && isArray(args[0])) { + return wrapper.plant(args[0]).value(); + } + var index = 0, + result = funcs[index].apply(this, args); + + 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' && typeof 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' || typeof 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' || typeof thisArg != 'undefined') { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee); + }; + } + + /** + * 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 string && ((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, null, 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' && typeof 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. @@ -3242,7 +3442,12 @@ if (!isCurryBound) { bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); } - var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity); + 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; } @@ -3264,9 +3469,8 @@ } /** - * Creates the pad required for `string` based on the given padding length. - * The `chars` string may be truncated if the number of padding characters - * exceeds the padding length. + * 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. @@ -3274,7 +3478,7 @@ * @param {string} [chars=' '] The string used as padding. * @returns {string} Returns the pad for `string`. */ - function createPad(string, length, chars) { + function createPadding(string, length, chars) { var strLength = string.length; length = +length; @@ -3323,6 +3527,22 @@ return wrapper; } + /** + * 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 func = getCallback(iteratee); + return (func === baseCallback && iteratee == null) + ? binaryIndex(array, value, retHighest) + : binaryIndexBy(array, value, func(iteratee, thisArg, 1), retHighest); + }; + } + /** * Creates a function that either curries or invokes `func` with optional * `this` binding and partially applied arguments. @@ -3365,10 +3585,10 @@ partials = holders = null; } - var data = !isBindKey && getData(func), + var data = isBindKey ? null : getData(func), newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; - if (data && data !== true) { + if (data) { mergeData(newData, data); bitmask = newData[1]; arity = newData[9]; @@ -3397,18 +3617,18 @@ * @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} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { var index = -1, arrLength = array.length, othLength = other.length, result = true; - if (arrLength != othLength && !(isWhere && othLength > arrLength)) { + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { return false; } // Deep compare the contents, ignoring non-numeric properties. @@ -3418,23 +3638,23 @@ result = undefined; if (customizer) { - result = isWhere + result = isLoose ? customizer(othValue, arrValue, index) : customizer(arrValue, othValue, index); } if (typeof result == 'undefined') { // Recursively compare arrays (susceptible to call stack limits). - if (isWhere) { + if (isLoose) { var othIndex = othLength; while (othIndex--) { othValue = other[othIndex]; - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); if (result) { break; } } } else { - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); } } } @@ -3490,26 +3710,26 @@ * @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} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + 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 && !isWhere) { + if (objLength != othLength && !isLoose) { return false; } - var hasCtor, + var skipCtor = isLoose, index = -1; while (++index < objLength) { var key = objProps[index], - result = hasOwnProperty.call(other, key); + result = isLoose ? key in other : hasOwnProperty.call(other, key); if (result) { var objValue = object[key], @@ -3517,21 +3737,21 @@ result = undefined; if (customizer) { - result = isWhere + result = isLoose ? customizer(othValue, objValue, key) : customizer(objValue, othValue, key); } if (typeof result == 'undefined') { // Recursively compare objects (susceptible to call stack limits). - result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isWhere, stackA, stackB); + result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB); } } if (!result) { return false; } - hasCtor || (hasCtor = key == 'constructor'); + skipCtor || (skipCtor = key == 'constructor'); } - if (!hasCtor) { + if (!skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; @@ -3549,7 +3769,7 @@ /** * 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, collection). + * The `iteratee` is invoked with three arguments: (value, index, collection). * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -3600,6 +3820,37 @@ return metaMap.get(func); }; + /** + * Gets the name of `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. + */ + var getFuncName = (function() { + if (!support.funcNames) { + return constant(''); + } + if (constant.name == 'constant') { + return baseProperty('name'); + } + return function(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 @@ -3717,31 +3968,6 @@ return result; } - /** - * Checks if `func` is eligible for `this` binding. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is eligible, else `false`. - */ - function isBindable(func) { - var support = lodash.support, - result = !(support.funcNames ? func.name : support.funcDecomp); - - if (!result) { - var source = fnToString.call(func); - if (!support.funcNames) { - result = !reFuncName.test(source); - } - if (!result) { - // Check if `func` references the `this` keyword and store the result. - result = reThis.test(source) || isNative(func); - baseSetData(func, result); - } - } - return result; - } - /** * Checks if `value` is a valid array-like index. * @@ -3783,12 +4009,22 @@ return false; } + /** + * 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); + return !!funcName && func === lodash[funcName] && funcName in LazyWrapper.prototype; + } + /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is based on ES `ToLength`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) - * for more details. + * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). * * @private * @param {*} value The value to check. @@ -3828,22 +4064,13 @@ function mergeData(data, source) { var bitmask = data[1], srcBitmask = source[1], - newBitmask = bitmask | srcBitmask; - - var arityFlags = ARY_FLAG | REARG_FLAG, - bindFlags = BIND_FLAG | BIND_KEY_FLAG, - comboFlags = arityFlags | bindFlags | CURRY_BOUND_FLAG | CURRY_RIGHT_FLAG; + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < ARY_FLAG; - var isAry = bitmask & ARY_FLAG && !(srcBitmask & ARY_FLAG), - isRearg = bitmask & REARG_FLAG && !(srcBitmask & REARG_FLAG), - argPos = (isRearg ? data : source)[7], - ary = (isAry ? data : source)[8]; - - var isCommon = !(bitmask >= REARG_FLAG && srcBitmask > bindFlags) && - !(bitmask > bindFlags && srcBitmask >= REARG_FLAG); - - var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) && - (bitmask < REARG_FLAG || ((isRearg || isAry) && argPos.length <= ary)); + 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)) { @@ -4162,10 +4389,9 @@ * Creates an array excluding all values of the provided arrays using * `SameValueZero` for equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -4178,19 +4404,11 @@ * _.difference([1, 2, 3], [4, 2]); * // => [1, 3] */ - function difference() { - var args = arguments, - index = -1, - length = args.length; - - while (++index < length) { - var value = args[index]; - if (isArray(value) || isArguments(value)) { - break; - } - } - return baseDifference(value, baseFlatten(args, false, true, ++index)); - } + var difference = restParam(function(array, values) { + return (isArray(array) || isArguments(array)) + ? baseDifference(array, baseFlatten(values, false, true)) + : []; + }); /** * Creates a slice of `array` with `n` elements dropped from the beginning. @@ -4266,7 +4484,7 @@ /** * 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). + * 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. @@ -4313,19 +4531,15 @@ * // => ['barney', 'fred', 'pebbles'] */ function dropRightWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - predicate = getCallback(predicate, thisArg, 3); - while (length-- && predicate(array[length], length, array)) {} - return baseSlice(array, 0, length + 1); + 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). + * 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. @@ -4372,14 +4586,9 @@ * // => ['barney', 'fred', 'pebbles'] */ function dropWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - var index = -1; - predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) {} - return baseSlice(array, index); + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3), true) + : []; } /** @@ -4396,6 +4605,19 @@ * @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; @@ -4411,7 +4633,7 @@ /** * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for, instead of the element itself. + * 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. @@ -4457,18 +4679,7 @@ * _.findIndex(users, 'active'); * // => 2 */ - function findIndex(array, predicate, thisArg) { - var index = -1, - length = array ? array.length : 0; - - predicate = getCallback(predicate, thisArg, 3); - while (++index < length) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; - } + var findIndex = createFindIndex(); /** * This method is like `_.findIndex` except that it iterates over elements @@ -4518,16 +4729,7 @@ * _.findLastIndex(users, 'active'); * // => 0 */ - function findLastIndex(array, predicate, thisArg) { - var length = array ? array.length : 0; - predicate = getCallback(predicate, thisArg, 3); - while (length--) { - if (predicate(array[length], length, array)) { - return length; - } - } - return -1; - } + var findLastIndex = createFindIndex(true); /** * Gets the first element of `array`. @@ -4564,18 +4766,18 @@ * @example * * _.flatten([1, [2, 3, [4]]]); - * // => [1, 2, 3, [4]]; + * // => [1, 2, 3, [4]] * * // using `isDeep` * _.flatten([1, [2, 3, [4]]], true); - * // => [1, 2, 3, 4]; + * // => [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, false, 0) : []; + return length ? baseFlatten(array, isDeep) : []; } /** @@ -4589,11 +4791,11 @@ * @example * * _.flattenDeep([1, [2, 3, [4]]]); - * // => [1, 2, 3, 4]; + * // => [1, 2, 3, 4] */ function flattenDeep(array) { var length = array ? array.length : 0; - return length ? baseFlatten(array, true, false, 0) : []; + return length ? baseFlatten(array, true) : []; } /** @@ -4602,10 +4804,9 @@ * it is used as the offset from the end of `array`. If `array` is sorted * providing `true` for `fromIndex` performs a faster binary search. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -4668,10 +4869,9 @@ * Creates an array of unique values in all provided arrays using `SameValueZero` * for equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -4799,10 +4999,10 @@ * comparisons. * * **Notes:** - * - Unlike `_.without`, this method mutates `array`. - * - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`, - * except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * - Unlike `_.without`, this method mutates `array` + * - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except + * that `NaN` matches `NaN` * * @static * @memberOf _ @@ -4865,14 +5065,28 @@ * console.log(evens); * // => [10, 20] */ - function pullAt(array) { - return basePullAt(array || [], baseFlatten(arguments, false, false, 1)); - } + var pullAt = restParam(function(array, indexes) { + array || (array = []); + indexes = baseFlatten(indexes); + + var length = indexes.length, + result = baseAt(array, indexes); + + indexes.sort(baseCompareAscending); + while (length--) { + var index = parseFloat(indexes[length]); + if (index != previous && isIndex(index)) { + var previous = index; + splice.call(array, index, 1); + } + } + 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). + * `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. @@ -4976,14 +5190,14 @@ * to compute their sort ranking. The iteratee is bound to `thisArg` and * invoked with one argument; (value). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -5017,12 +5231,7 @@ * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); * // => 1 */ - function sortedIndex(array, value, iteratee, thisArg) { - var func = getCallback(iteratee); - return (func === baseCallback && iteratee == null) - ? binaryIndex(array, value) - : binaryIndexBy(array, value, func(iteratee, thisArg, 1)); - } + var sortedIndex = createSortedIndex(); /** * This method is like `_.sortedIndex` except that it returns the highest @@ -5044,12 +5253,7 @@ * _.sortedLastIndex([4, 4, 5, 5], 5); * // => 4 */ - function sortedLastIndex(array, value, iteratee, thisArg) { - var func = getCallback(iteratee); - return (func === baseCallback && iteratee == null) - ? binaryIndex(array, value, true) - : binaryIndexBy(array, value, func(iteratee, thisArg, 1), true); - } + var sortedLastIndex = createSortedIndex(true); /** * Creates a slice of `array` with `n` elements taken from the beginning. @@ -5125,7 +5329,7 @@ /** * 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). + * 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. @@ -5172,19 +5376,15 @@ * // => [] */ function takeRightWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - predicate = getCallback(predicate, thisArg, 3); - while (length-- && predicate(array[length], length, array)) {} - return baseSlice(array, length + 1); + 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). + * `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. @@ -5231,24 +5431,18 @@ * // => [] */ function takeWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - var index = -1; - predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) {} - return baseSlice(array, 0, index); + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3)) + : []; } /** * Creates an array of unique values, in order, of the provided arrays using * `SameValueZero` for equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -5260,9 +5454,9 @@ * _.union([1, 2], [4, 2], [2, 1]); * // => [1, 2, 4] */ - function union() { - return baseUniq(baseFlatten(arguments, false, true, 0)); - } + var union = restParam(function(arrays) { + return baseUniq(baseFlatten(arrays, false, true)); + }); /** * Creates a duplicate-value-free version of an array using `SameValueZero` @@ -5270,23 +5464,22 @@ * search algorithm for sorted arrays. If an iteratee function is provided it * is invoked for each value 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). + * with three arguments: (value, index, array). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -5368,10 +5561,9 @@ * Creates an array excluding all provided values using `SameValueZero` for * equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -5384,14 +5576,15 @@ * _.without([1, 2, 1, 3], 1, 2); * // => [3] */ - function without(array) { - return baseDifference(array, baseSlice(arguments, 1)); - } + var without = restParam(function(array, values) { + return (isArray(array) || isArguments(array)) + ? baseDifference(array, values) + : []; + }); /** - * Creates an array that is the symmetric difference of the provided arrays. - * See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for - * more details. + * Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * of the provided arrays. * * @static * @memberOf _ @@ -5433,20 +5626,13 @@ * _.zip(['fred', 'barney'], [30, 40], [true, false]); * // => [['fred', 30, true], ['barney', 40, false]] */ - function zip() { - var length = arguments.length, - array = Array(length); - - while (length--) { - array[length] = arguments[length]; - } - return unzip(array); - } + var zip = restParam(unzip); /** - * Creates 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. + * 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 _ @@ -5457,6 +5643,9 @@ * @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 } */ @@ -5553,13 +5742,14 @@ * @returns {*} Returns the result of `interceptor`. * @example * - * _([1, 2, 3]) - * .last() + * _(' abc ') + * .chain() + * .trim() * .thru(function(value) { * return [value]; * }) * .value(); - * // => [3] + * // => ['abc'] */ function thru(value, interceptor, thisArg) { return interceptor.call(thisArg, value); @@ -5749,32 +5939,32 @@ * _.at(['a', 'b', 'c'], [0, 2]); * // => ['a', 'c'] * - * _.at(['fred', 'barney', 'pebbles'], 0, 2); - * // => ['fred', 'pebbles'] + * _.at(['barney', 'fred', 'pebbles'], 0, 2); + * // => ['barney', 'pebbles'] */ - function at(collection) { + var at = restParam(function(collection, props) { var length = collection ? collection.length : 0; if (isLength(length)) { collection = toIterable(collection); } - return baseAt(collection, baseFlatten(arguments, false, false, 1)); - } + 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; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -5807,7 +5997,7 @@ /** * Checks if `predicate` returns truthy for **all** elements of `collection`. - * The predicate is bound to `thisArg` and invoked with three arguments; + * 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` @@ -5855,6 +6045,9 @@ */ function every(collection, predicate, thisArg) { var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = null; + } if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } @@ -5864,7 +6057,7 @@ /** * 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). + * 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. @@ -5919,7 +6112,7 @@ /** * 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). + * 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. @@ -5966,14 +6159,7 @@ * _.result(_.find(users, 'active'), 'user'); * // => 'barney' */ - function find(collection, predicate, thisArg) { - if (isArray(collection)) { - var index = findIndex(collection, predicate, thisArg); - return index > -1 ? collection[index] : undefined; - } - predicate = getCallback(predicate, thisArg, 3); - return baseFind(collection, predicate, baseEach); - } + var find = createFind(baseEach); /** * This method is like `_.find` except that it iterates over elements of @@ -5994,10 +6180,7 @@ * }); * // => 3 */ - function findLast(collection, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return baseFind(collection, predicate, baseEachRight); - } + var findLast = createFind(baseEachRight, true); /** * Performs a deep comparison between each element in `collection` and the @@ -6034,7 +6217,7 @@ /** * Iterates over elements of `collection` invoking `iteratee` for each element. - * The `iteratee` is bound to `thisArg` and invoked with three arguments; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). Iterator functions may exit iteration early * by explicitly returning `false`. * @@ -6062,11 +6245,7 @@ * }); * // => logs each value-key pair and returns the object (iteration order is not guaranteed) */ - function forEach(collection, iteratee, thisArg) { - return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEach(collection, iteratee) - : baseEach(collection, bindCallback(iteratee, thisArg, 3)); - } + var forEach = createForEach(arrayEach, baseEach); /** * This method is like `_.forEach` except that it iterates over elements of @@ -6084,30 +6263,26 @@ * * _([1, 2]).forEachRight(function(n) { * console.log(n); - * }).join(','); + * }).value(); * // => logs each value from right to left and returns the array */ - function forEachRight(collection, iteratee, thisArg) { - return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEachRight(collection, iteratee) - : baseEachRight(collection, bindCallback(iteratee, thisArg, 3)); - } + 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; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6148,10 +6323,9 @@ * comparisons. If `fromIndex` is negative, it is used as the offset from * the end of `collection`. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -6160,6 +6334,7 @@ * @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 * @@ -6175,7 +6350,7 @@ * _.includes('pebbles', 'eb'); * // => true */ - function includes(collection, target, fromIndex) { + function includes(collection, target, fromIndex, guard) { var length = collection ? collection.length : 0; if (!isLength(length)) { collection = values(collection); @@ -6184,10 +6359,10 @@ if (!length) { return false; } - if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); - } else { + 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) @@ -6198,17 +6373,17 @@ * 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; + * iteratee function is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6266,23 +6441,32 @@ * _.invoke([123, 456], String.prototype.split, ''); * // => [['1', '2', '3'], ['4', '5', '6']] */ - function invoke(collection, methodName) { - return baseInvoke(collection, methodName, baseSlice(arguments, 2)); - } + var invoke = restParam(function(collection, methodName, args) { + var index = -1, + isFunc = typeof methodName == 'function', + length = collection ? collection.length : 0, + result = isLength(length) ? Array(length) : []; + + baseEach(collection, function(value) { + var func = isFunc ? methodName : (value != null && value[methodName]); + result[++index] = func ? func.apply(value, args) : undefined; + }); + 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). + * arguments: (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6291,9 +6475,9 @@ * * The guarded methods are: * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`, - * `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`, - * `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`, - * `trunc`, `random`, `range`, `sample`, `uniq`, and `words` + * `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, + * `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, + * `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words` * * @static * @memberOf _ @@ -6336,7 +6520,7 @@ * 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). + * 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. @@ -6427,14 +6611,14 @@ * 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; + * 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 interatees for methods like * `_.reduce`, `_.reduceRight`, and `_.transform`. * * The guarded methods are: - * `assign`, `defaults`, `merge`, and `sortAllBy` + * `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder` * * @static * @memberOf _ @@ -6458,10 +6642,7 @@ * }, {}); * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) */ - function reduce(collection, iteratee, accumulator, thisArg) { - var func = isArray(collection) ? arrayReduce : baseReduce; - return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach); - } + var reduce = createReduce(arrayReduce, baseEach); /** * This method is like `_.reduce` except that it iterates over elements of @@ -6485,10 +6666,7 @@ * }, []); * // => [4, 5, 2, 3, 0, 1] */ - function reduceRight(collection, iteratee, accumulator, thisArg) { - var func = isArray(collection) ? arrayReduceRight : baseReduce; - return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); - } + var reduceRight = createReduce(arrayReduceRight, baseEachRight); /** * The opposite of `_.filter`; this method returns the elements of `collection` @@ -6575,9 +6753,8 @@ } /** - * Creates an array of shuffled values, using a version of the Fisher-Yates - * shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle) - * for more details. + * Creates an array of shuffled values, using a version of the + * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). * * @static * @memberOf _ @@ -6635,7 +6812,7 @@ * 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). + * 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. @@ -6682,6 +6859,9 @@ */ function some(collection, predicate, thisArg) { var func = isArray(collection) ? arraySome : baseSome; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = null; + } if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } @@ -6692,17 +6872,17 @@ * 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; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6778,17 +6958,24 @@ * _.map(_.sortByAll(users, ['user', 'age']), _.values); * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ - function sortByAll(collection) { + function sortByAll() { + var args = arguments, + collection = args[0], + guard = args[3], + index = 0, + length = args.length - 1; + if (collection == null) { return []; } - var args = arguments, - guard = args[3]; - + var props = Array(length); + while (index < length) { + props[index] = args[++index]; + } if (guard && isIterateeCall(args[1], args[2], guard)) { - args = [collection, args[1]]; + props = args[1]; } - return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []); + return baseSortByOrder(collection, baseFlatten(props), []); } /** @@ -7007,7 +7194,7 @@ * @category Function * @param {Function} func The function to bind. * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new bound function. * @example * @@ -7026,16 +7213,14 @@ * bound('hi'); * // => 'hi fred!' */ - function bind(func, thisArg) { + var bind = restParam(function(func, thisArg, partials) { var bitmask = BIND_FLAG; - if (arguments.length > 2) { - var partials = baseSlice(arguments, 2), - holders = replaceHolders(partials, bind.placeholder); - + 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 @@ -7065,13 +7250,18 @@ * jQuery('#docs').on('click', view.onClick); * // => logs 'clicked docs' when the element is clicked */ - function bindAll(object) { - return baseBindAll(object, - arguments.length > 1 - ? baseFlatten(arguments, false, false, 1) - : functions(object) - ); - } + 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 @@ -7090,7 +7280,7 @@ * @category Function * @param {Object} object The object the method belongs to. * @param {string} key The key of the method. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new bound function. * @example * @@ -7117,16 +7307,14 @@ * bound('hi'); * // => 'hiya fred!' */ - function bindKey(object, key) { + var bindKey = restParam(function(object, key, partials) { var bitmask = BIND_FLAG | BIND_KEY_FLAG; - if (arguments.length > 2) { - var partials = baseSlice(arguments, 2), - holders = replaceHolders(partials, bindKey.placeholder); - + 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 @@ -7168,14 +7356,7 @@ * curried(1)(_, 3)(2); * // => [1, 2, 3] */ - function curry(func, arity, guard) { - if (guard && isIterateeCall(func, arity, guard)) { - arity = null; - } - var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity); - result.placeholder = curry.placeholder; - return result; - } + var curry = createCurry(CURRY_FLAG); /** * This method is like `_.curry` except that arguments are applied to `func` @@ -7214,14 +7395,7 @@ * curried(3)(1, _)(2); * // => [1, 2, 3] */ - function curryRight(func, arity, guard) { - if (guard && isIterateeCall(func, arity, guard)) { - arity = null; - } - var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity); - result.placeholder = curryRight.placeholder; - return result; - } + var curryRight = createCurry(CURRY_RIGHT_FLAG); /** * Creates a function that delays invoking `func` until after `wait` milliseconds @@ -7416,9 +7590,9 @@ * }, 'deferred'); * // logs 'deferred' after one or more milliseconds */ - function defer(func) { - return baseDelay(func, 1, arguments, 1); - } + var defer = restParam(function(func, args) { + return baseDelay(func, 1, args); + }); /** * Invokes `func` after `wait` milliseconds. Any additional arguments are @@ -7438,9 +7612,9 @@ * }, 1000, 'later'); * // => logs 'later' after one second */ - function delay(func, wait) { - return baseDelay(func, wait, arguments, 2); - } + var delay = restParam(function(func, wait, args) { + return baseDelay(func, wait, args); + }); /** * Creates a function that returns the result of invoking the provided @@ -7462,7 +7636,7 @@ * addSquare(1, 2); * // => 9 */ - var flow = createComposer(); + var flow = createFlow(); /** * This method is like `_.flow` except that it creates a function that @@ -7484,7 +7658,7 @@ * addSquare(1, 2); * // => 9 */ - var flowRight = createComposer(true); + var flowRight = createFlow(true); /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -7496,10 +7670,8 @@ * * **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 ES `Map` method interface - * of `get`, `has`, and `set`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object) - * for more details. + * constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object) + * method interface of `get`, `has`, and `set`. * * @static * @memberOf _ @@ -7590,7 +7762,7 @@ /** * 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 of the created function. + * with the `this` binding and arguments of the created function. * * @static * @memberOf _ @@ -7623,7 +7795,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to partially apply arguments to. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new partially applied function. * @example * @@ -7640,12 +7812,7 @@ * greetFred('hi'); * // => 'hi fred' */ - function partial(func) { - var partials = baseSlice(arguments, 1), - holders = replaceHolders(partials, partial.placeholder); - - return createWrapper(func, PARTIAL_FLAG, null, partials, holders); - } + var partial = createPartial(PARTIAL_FLAG); /** * This method is like `_.partial` except that partially applied arguments @@ -7661,7 +7828,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to partially apply arguments to. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new partially applied function. * @example * @@ -7678,12 +7845,7 @@ * sayHelloTo('fred'); * // => 'hello fred' */ - function partialRight(func) { - var partials = baseSlice(arguments, 1), - holders = replaceHolders(partials, partialRight.placeholder); - - return createWrapper(func, PARTIAL_RIGHT_FLAG, null, partials, holders); - } + var partialRight = createPartial(PARTIAL_RIGHT_FLAG); /** * Creates a function that invokes `func` with arguments arranged according @@ -7713,29 +7875,80 @@ * }, [1, 2, 3]); * // => [3, 6, 9] */ - function rearg(func) { - var indexes = baseFlatten(arguments, false, false, 1); - return createWrapper(func, REARG_FLAG, null, null, null, indexes); - } + var rearg = restParam(function(func, indexes) { + return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes)); + }); /** * Creates a function that invokes `func` with the `this` binding of the - * created function and the array of arguments provided to the created - * function much like [Function#apply](http://es5.github.io/#x15.3.4.3). + * 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(typeof 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 {*} Returns the new function. + * @returns {Function} Returns the new function. * @example * - * var spread = _.spread(function(who, what) { + * var say = _.spread(function(who, what) { * return who + ' says ' + what; * }); * - * spread(['Fred', 'hello']); - * // => 'Fred says hello' + * say(['fred', 'hello']); + * // => 'fred says hello' * * // with a Promise * var numbers = Promise.all([ @@ -7850,12 +8063,12 @@ * 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. + * **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. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) - * for more details. + * Maps, Sets, and WeakMaps. * * @static * @memberOf _ @@ -7913,12 +8126,12 @@ * 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. + * **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. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) - * for more details. + * Maps, Sets, and WeakMaps. * * @static * @memberOf _ @@ -7975,7 +8188,7 @@ */ function isArguments(value) { var length = isObjectLike(value) ? value.length : undefined; - return (isLength(length) && objToString.call(value) == argsTag) || false; + return isLength(length) && objToString.call(value) == argsTag; } /** @@ -7995,7 +8208,7 @@ * // => false */ var isArray = nativeIsArray || function(value) { - return (isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag) || false; + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; }; /** @@ -8015,7 +8228,7 @@ * // => false */ function isBoolean(value) { - return (value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag) || false; + return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag); } /** @@ -8035,7 +8248,7 @@ * // => false */ function isDate(value) { - return (isObjectLike(value) && objToString.call(value) == dateTag) || false; + return isObjectLike(value) && objToString.call(value) == dateTag; } /** @@ -8055,13 +8268,13 @@ * // => false */ function isElement(value) { - return (value && value.nodeType === 1 && isObjectLike(value) && - (objToString.call(value).indexOf('Element') > -1)) || false; + return !!value && value.nodeType === 1 && isObjectLike(value) && + (objToString.call(value).indexOf('Element') > -1); } // Fallback for environments without DOM support. if (!support.dom) { isElement = function(value) { - return (value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value)) || false; + return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); }; } @@ -8109,7 +8322,7 @@ * 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]). + * arguments: (value, other [, index|key]). * * **Note:** This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Objects are compared by @@ -8174,15 +8387,13 @@ * // => false */ function isError(value) { - return (isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag) || false; + 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 ES `Number.isFinite`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite) - * for more details. + * **Note:** This method is based on [`Number.isFinite`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite). * * @static * @memberOf _ @@ -8234,11 +8445,9 @@ }; /** - * Checks if `value` is the language type of `Object`. + * 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('')`) * - * **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details. - * * @static * @memberOf _ * @category Lang @@ -8259,7 +8468,7 @@ // 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 type == 'function' || (value && type == 'object') || false; + return type == 'function' || (!!value && type == 'object'); } /** @@ -8267,7 +8476,7 @@ * `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). + * 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 @@ -8305,13 +8514,19 @@ var props = keys(source), length = props.length; + if (!length) { + return true; + } + if (object == null) { + return false; + } customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); if (!customizer && length == 1) { var key = props[0], value = source[key]; if (isStrictComparable(value)) { - return object != null && value === object[key] && hasOwnProperty.call(object, key); + return value === object[key] && (typeof value != 'undefined' || (key in toObject(object))); } } var values = Array(length), @@ -8321,15 +8536,14 @@ value = values[length] = source[props[length]]; strictCompareFlags[length] = isStrictComparable(value); } - return baseIsMatch(object, props, values, strictCompareFlags, customizer); + return baseIsMatch(toObject(object), props, values, strictCompareFlags, customizer); } /** * Checks if `value` is `NaN`. * - * **Note:** This method is not the same as native `isNaN` which returns `true` - * for `undefined` and other non-numeric values. See the [ES5 spec](https://es5.github.io/#x15.1.2.4) - * for more details. + * **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 _ @@ -8379,7 +8593,7 @@ if (objToString.call(value) == funcTag) { return reNative.test(fnToString.call(value)); } - return (isObjectLike(value) && reHostCtor.test(value)) || false; + return isObjectLike(value) && reHostCtor.test(value); } /** @@ -8425,7 +8639,7 @@ * // => false */ function isNumber(value) { - return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag) || false; + return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag); } /** @@ -8507,7 +8721,7 @@ * // => false */ function isString(value) { - return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag) || false; + return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag); } /** @@ -8527,7 +8741,7 @@ * // => false */ function isTypedArray(value) { - return (isObjectLike(value) && isLength(value.length) && typedArrayTags[objToString.call(value)]) || false; + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; } /** @@ -8609,7 +8823,7 @@ * 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; + * The `customizer` is bound to `thisArg` and invoked with five arguments: * (objectValue, sourceValue, key, object, source). * * @static @@ -8694,18 +8908,18 @@ * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); * // => { 'user': 'barney', 'age': 36 } */ - function defaults(object) { + var defaults = restParam(function(args) { + var object = args[0]; if (object == null) { return object; } - var args = arrayCopy(arguments); args.push(assignDefaults); return assign.apply(undefined, args); - } + }); /** - * This method is like `_.findIndex` except that it returns the key of the - * first element `predicate` returns truthy for, instead of the element itself. + * 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. @@ -8751,10 +8965,7 @@ * _.findKey(users, 'active'); * // => 'barney' */ - function findKey(object, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return baseFind(object, predicate, baseForOwn, true); - } + var findKey = createFindKey(baseForOwn); /** * This method is like `_.findKey` except that it iterates over elements of @@ -8804,15 +9015,12 @@ * _.findLastKey(users, 'active'); * // => 'pebbles' */ - function findLastKey(object, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return baseFind(object, predicate, baseForOwnRight, true); - } + 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). Iterator functions may exit + * with three arguments: (value, key, object). Iterator functions may exit * iteration early by explicitly returning `false`. * * @static @@ -8836,12 +9044,7 @@ * }); * // => logs 'a', 'b', and 'c' (iteration order is not guaranteed) */ - function forIn(object, iteratee, thisArg) { - if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = bindCallback(iteratee, thisArg, 3); - } - return baseFor(object, iteratee, keysIn); - } + var forIn = createForIn(baseFor); /** * This method is like `_.forIn` except that it iterates over properties of @@ -8868,15 +9071,12 @@ * }); * // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c' */ - function forInRight(object, iteratee, thisArg) { - iteratee = bindCallback(iteratee, thisArg, 3); - return baseForRight(object, iteratee, keysIn); - } + 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). Iterator functions may exit iteration + * three arguments: (value, key, object). Iterator functions may exit iteration * early by explicitly returning `false`. * * @static @@ -8900,12 +9100,7 @@ * }); * // => logs 'a' and 'b' (iteration order is not guaranteed) */ - function forOwn(object, iteratee, thisArg) { - if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = bindCallback(iteratee, thisArg, 3); - } - return baseForOwn(object, iteratee); - } + var forOwn = createForOwn(baseForOwn); /** * This method is like `_.forOwn` except that it iterates over properties of @@ -8932,10 +9127,7 @@ * }); * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' */ - function forOwnRight(object, iteratee, thisArg) { - iteratee = bindCallback(iteratee, thisArg, 3); - return baseForRight(object, iteratee, keys); - } + var forOwnRight = createForOwn(baseForOwnRight); /** * Creates an array of function property names from all enumerable properties, @@ -9120,7 +9312,7 @@ /** * 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; + * 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` @@ -9175,7 +9367,7 @@ * 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). + * with five arguments: (objectValue, sourceValue, key, object, source). * * @static * @memberOf _ @@ -9224,7 +9416,7 @@ * 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` omitting the properties `predicate` returns truthy for. The - * predicate is bound to `thisArg` and invoked with three arguments; + * predicate is bound to `thisArg` and invoked with three arguments: * (value, key, object). * * @static @@ -9246,19 +9438,19 @@ * _.omit(object, _.isNumber); * // => { 'user': 'fred' } */ - function omit(object, predicate, thisArg) { + var omit = restParam(function(object, props) { if (object == null) { return {}; } - if (typeof predicate != 'function') { - var props = arrayMap(baseFlatten(arguments, false, false, 1), String); + if (typeof props[0] != 'function') { + var props = arrayMap(baseFlatten(props), String); return pickByArray(object, baseDifference(keysIn(object), props)); } - predicate = bindCallback(predicate, thisArg, 3); + 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`, @@ -9292,7 +9484,7 @@ * 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). + * bound to `thisArg` and invoked with three arguments: (value, key, object). * * @static * @memberOf _ @@ -9313,14 +9505,14 @@ * _.pick(object, _.isString); * // => { 'user': 'fred' } */ - function pick(object, predicate, thisArg) { + var pick = restParam(function(object, props) { if (object == null) { return {}; } - return typeof predicate == 'function' - ? pickByCallback(object, bindCallback(predicate, thisArg, 3)) - : pickByArray(object, baseFlatten(arguments, false, false, 1)); - } + return typeof props[0] == 'function' + ? pickByCallback(object, bindCallback(props[0], props[1], 3)) + : pickByArray(object, baseFlatten(props)); + }); /** * Resolves the value of property `key` on `object`. If the value of `key` is @@ -9365,7 +9557,7 @@ * `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). Iterator functions + * with four arguments: (accumulator, value, key, object). Iterator functions * may exit iteration early by explicitly returning `false`. * * @static @@ -9576,8 +9768,7 @@ /*------------------------------------------------------------------------*/ /** - * Converts `string` to camel case. - * See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details. + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). * * @static * @memberOf _ @@ -9619,9 +9810,8 @@ } /** - * Deburrs `string` by converting latin-1 supplementary letters to basic latin letters. - * See [Wikipedia](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * for more details. + * 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 _ @@ -9635,7 +9825,7 @@ */ function deburr(string) { string = baseToString(string); - return string && string.replace(reLatin1, deburrLetter); + return string && string.replace(reLatin1, deburrLetter).replace(reComboMarks, ''); } /** @@ -9690,9 +9880,8 @@ * [#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 to reduce - * XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping) - * 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 _ @@ -9713,8 +9902,8 @@ } /** - * Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", - * "+", "(", ")", "[", "]", "{" and "}" in `string`. + * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?", + * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`. * * @static * @memberOf _ @@ -9724,7 +9913,7 @@ * @example * * _.escapeRegExp('[lodash](https://lodash.com/)'); - * // => '\[lodash\]\(https://lodash\.com/\)' + * // => '\[lodash\]\(https:\/\/lodash\.com\/\)' */ function escapeRegExp(string) { string = baseToString(string); @@ -9734,9 +9923,7 @@ } /** - * Converts `string` to kebab case. - * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for - * more details. + * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). * * @static * @memberOf _ @@ -9759,9 +9946,8 @@ }); /** - * Pads `string` on the left and right sides if it is shorter then the given - * padding length. The `chars` string may be truncated if the number of padding - * characters can't be evenly divided by the padding length. + * Pads `string` on the left and right sides if it is shorter than `length`. + * Padding characters are truncated if they can't be evenly divided by `length`. * * @static * @memberOf _ @@ -9793,14 +9979,13 @@ leftLength = floor(mid), rightLength = ceil(mid); - chars = createPad('', rightLength, chars); + chars = createPadding('', rightLength, chars); return chars.slice(0, leftLength) + string + chars; } /** - * Pads `string` on the left side if it is shorter then the given padding - * length. The `chars` string may be truncated if the number of padding - * characters exceeds the padding length. + * Pads `string` on the left side if it is shorter than `length`. Padding + * characters are truncated if they exceed `length`. * * @static * @memberOf _ @@ -9820,15 +10005,11 @@ * _.padLeft('abc', 3); * // => 'abc' */ - function padLeft(string, length, chars) { - string = baseToString(string); - return string && (createPad(string, length, chars) + string); - } + var padLeft = createPadDir(); /** - * Pads `string` on the right side if it is shorter then the given padding - * length. The `chars` string may be truncated if the number of padding - * characters exceeds the padding length. + * Pads `string` on the right side if it is shorter than `length`. Padding + * characters are truncated if they exceed `length`. * * @static * @memberOf _ @@ -9848,18 +10029,15 @@ * _.padRight('abc', 3); * // => 'abc' */ - function padRight(string, length, chars) { - string = baseToString(string); - return string && (string + createPad(string, length, chars)); - } + 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 of `parseInt`. - * See the [ES5 spec](https://es5.github.io/#E) for more details. + * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E) + * of `parseInt`. * * @static * @memberOf _ @@ -9939,8 +10117,7 @@ } /** - * Converts `string` to snake case. - * See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details. + * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). * * @static * @memberOf _ @@ -9963,9 +10140,7 @@ }); /** - * Converts `string` to start case. - * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage) - * for more details. + * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). * * @static * @memberOf _ @@ -10024,9 +10199,9 @@ * 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 for easier debugging. - * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for more details. + * **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). @@ -10238,7 +10413,7 @@ * // => 'abc' * * _.map([' foo ', ' bar '], _.trim); - * // => ['foo', 'bar] + * // => ['foo', 'bar'] */ function trim(string, chars, guard) { var value = string; @@ -10346,7 +10521,7 @@ * 'length': 24, * 'separator': /,? +/ * }); - * //=> 'hi-diddly-ho there...' + * // => 'hi-diddly-ho there...' * * _.trunc('hi-diddly-ho there, neighborino', { * 'omission': ' [...]' @@ -10465,7 +10640,7 @@ * @static * @memberOf _ * @category Utility - * @param {*} func The function to attempt. + * @param {Function} func The function to attempt. * @returns {*} Returns the `func` result or error object. * @example * @@ -10478,20 +10653,13 @@ * elements = []; * } */ - function attempt() { - var func = arguments[0], - length = arguments.length, - args = Array(length ? (length - 1) : 0); - - while (--length > 0) { - args[length - 1] = arguments[length]; - } + var attempt = restParam(function(func, args) { try { return func.apply(undefined, args); } catch(e) { return isError(e) ? e : new Error(e); } - } + }); /** * Creates a function that invokes `func` with the `this` binding of `thisArg` @@ -10628,12 +10796,11 @@ * * var users = [ * { 'user': 'barney' }, - * { 'user': 'fred' }, - * { 'user': 'pebbles' } + * { 'user': 'fred' } * ]; * * _.find(users, _.matchesProperty('user', 'fred')); - * // => { 'user': 'fred', 'age': 40 } + * // => { 'user': 'fred' } */ function matchesProperty(key, value) { return baseMatchesProperty(key + '', baseClone(value, true)); @@ -10644,6 +10811,9 @@ * destination object. If `object` is a function then methods are added to * its prototype as well. * + * **Note:** Use `_.runInContext` to create a pristine `lodash` function + * for mixins to avoid conflicts caused by modifying the original. + * * @static * @memberOf _ * @category Utility @@ -10661,7 +10831,7 @@ * }); * } * - * // use `_.runInContext` to avoid potential conflicts (esp. in Node.js) + * // use `_.runInContext` to avoid conflicts (esp. in Node.js) * var _ = require('lodash').runInContext(); * * _.mixin({ 'vowels': vowels }); @@ -10711,12 +10881,10 @@ return function() { var chainAll = this.__chain__; if (chain || chainAll) { - var result = object(this.__wrapped__); - (result.__actions__ = arrayCopy(this.__actions__)).push({ - 'func': func, - 'args': arguments, - 'thisArg': object - }); + var result = object(this.__wrapped__), + actions = result.__actions__ = arrayCopy(this.__actions__); + + actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); result.__chain__ = chainAll; return result; } @@ -10783,7 +10951,7 @@ * var getName = _.property('user'); * * _.map(users, getName); - * // => ['fred', barney'] + * // => ['fred', 'barney'] * * _.pluck(_.sortBy(users, getName), 'user'); * // => ['barney', 'fred'] @@ -10793,7 +10961,7 @@ } /** - * The inverse of `_.property`; this method creates a function which returns + * The opposite of `_.property`; this method creates a function which returns * the property value of a given key on `object`. * * @static @@ -10971,16 +11139,16 @@ * `-Infinity` is returned. If an iteratee function is provided it is invoked * for each value in `collection` to generate the criterion by which the value * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). + * arguments: (value, index, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -11007,11 +11175,11 @@ * _.max(users, function(chr) { * return chr.age; * }); - * // => { 'user': 'fred', 'age': 40 }; + * // => { 'user': 'fred', 'age': 40 } * * // using the `_.property` callback shorthand * _.max(users, 'age'); - * // => { 'user': 'fred', 'age': 40 }; + * // => { 'user': 'fred', 'age': 40 } */ var max = createExtremum(arrayMax); @@ -11020,16 +11188,16 @@ * `Infinity` is returned. If an iteratee function is provided it is invoked * for each value in `collection` to generate the criterion by which the value * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). + * arguments: (value, index, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -11056,11 +11224,11 @@ * _.min(users, function(chr) { * return chr.age; * }); - * // => { 'user': 'barney', 'age': 36 }; + * // => { 'user': 'barney', 'age': 36 } * * // using the `_.property` callback shorthand * _.min(users, 'age'); - * // => { 'user': 'barney', 'age': 36 }; + * // => { 'user': 'barney', 'age': 36 } */ var min = createExtremum(arrayMin, true); @@ -11071,26 +11239,45 @@ * @memberOf _ * @category Math * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the sum. * @example * - * _.sum([4, 6, 2]); - * // => 12 + * _.sum([4, 6]); + * // => 10 + * + * _.sum({ 'a': 4, 'b': 6 }); + * // => 10 + * + * var objects = [ + * { 'n': 4 }, + * { 'n': 6 } + * ]; + * + * _.sum(objects, function(object) { + * return object.n; + * }); + * // => 10 * - * _.sum({ 'a': 4, 'b': 6, 'c': 2 }); - * // => 12 + * // using the `_.property` callback shorthand + * _.sum(objects, 'n'); + * // => 10 */ - function sum(collection) { - if (!isArray(collection)) { - collection = toIterable(collection); + function sum(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = null; } - var length = collection.length, - result = 0; + var func = getCallback(), + noIteratee = iteratee == null; - while (length--) { - result += +collection[length] || 0; + if (!(func === baseCallback && noIteratee)) { + noIteratee = false; + iteratee = func(iteratee, thisArg, 3); } - return result; + return noIteratee + ? arraySum(isArray(collection) ? collection : toIterable(collection)) + : baseSum(collection, iteratee); } /*------------------------------------------------------------------------*/ @@ -11189,6 +11376,7 @@ lodash.reject = reject; lodash.remove = remove; lodash.rest = rest; + lodash.restParam = restParam; lodash.shuffle = shuffle; lodash.slice = slice; lodash.sortBy = sortBy; @@ -11480,8 +11668,11 @@ // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { - var lodashFunc = lodash[methodName], - checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), + var lodashFunc = lodash[methodName]; + if (!lodashFunc) { + return; + } + var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { @@ -11540,6 +11731,19 @@ }; }); + // Map minified function names to their real names. + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var lodashFunc = lodash[methodName]; + if (lodashFunc) { + var key = lodashFunc.name, + names = realNames[key] || (realNames[key] = []); + + names.push({ 'name': methodName, 'func': lodashFunc }); + } + }); + + realNames[createHybridWrapper(null, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': null }]; + // Add functions to the lazy wrapper. LazyWrapper.prototype.clone = lazyClone; LazyWrapper.prototype.reverse = lazyReverse; diff --git a/lodash.min.js b/lodash.min.js index 8e2e7c364d..0f3a88ca1c 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,89 +1,89 @@ /** * @license - * lodash 3.5.0 (Custom Build) lodash.com/license | Underscore.js 1.8.2 underscorejs.org/LICENSE + * lodash 3.6.0 (Custom Build) lodash.com/license | Underscore.js 1.8.2 underscorejs.org/LICENSE * Build: `lodash modern -o ./lodash.js` */ -;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function _(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Yt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++ui(r,a,0)&&u.push(a);return u}function or(n,t){var r=n?n.length:0;if(!ae(r))return _r(n,t);for(var e=-1,u=ge(n);++et&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=xu(u);++eu(a,s,0)&&((r||f)&&a.push(s),c.push(l))}return c}function Tr(n,t){for(var r=-1,e=t.length,u=xu(e);++r>>1,i=n[o]; -(r?i<=t:ir||null==e)return e;var u=t[r-2],o=t[r-1],i=t[3];for(3=o&&f<=i&&(e=I&&t>u||e>u&&t>=I)||o)&&(t&w&&(r[2]=p[2],f|=e&w?0:A),(e=p[3])&&(u=r[3],r[3]=u?Lr(u,e,p[4]):Bt(e),r[4]=u?_(r[3],L):Bt(p[4])),(e=p[5])&&(u=r[5],r[5]=u?Br(u,e,p[6]):Bt(e),r[6]=u?_(r[5],L):Bt(p[6])),(e=p[7])&&(r[7]=Bt(e)),t&O&&(r[8]=null==r[8]?p[8]:ao(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9] -}return r[9]=null==f?a?0:n.length:fo(f-c,0)||0,(p?jo:Ro)(t==w?Mr(r[0],r[2]):t!=E&&t!=(w|E)||r[4].length?Yr.apply(m,r):Gr.apply(m,r),r)}function Xr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true;if(a!=c&&(!u||c<=a))return false;for(;l&&++fu)||i===e&&i===o)&&(u=i,o=n)}),o}function te(n,t,r){var e=Tt.callback||vu,e=e===vu?tr:e;return r?e(n,t,r):e}function re(n,r,e){var u=Tt.indexOf||we,u=u===we?t:u;return n?u(n,r,e):u}function ee(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Lu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function ue(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Iu),new n -}function oe(n,t,r){var e=n.constructor;switch(t){case G:return $r(n);case D:case M:return new e(+n);case J:case X:case H:case Q:case nt:case tt:case rt:case et:case ut:return t=n.buffer,new e(r?$r(t):t,n.byteOffset,n.length);case K:case Z:return new e(n);case Y:var u=new e(n.source,vt.exec(n));u.lastIndex=n.lastIndex}return u}function ie(n,t){return n=+n,t=null==t?bo:t,-1t?0:t)):[]}function de(n,t,r){var e=n?n.length:0; -return e?((r?fe(n,t,r):null==t)&&(t=1),t=e-(+t||0),Rr(n,0,0>t?0:t)):[]}function me(n,t,r){var e=-1,u=n?n.length:0;for(t=te(t,r,3);++ee?fo(u+e,0):e;else if(e)return e=Nr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e||0)}function xe(n){var t=n?n.length:0;return t?n[t-1]:m}function Ae(n){return ye(n,1)}function je(n,r,e,u){if(!n||!n.length)return[]; -null!=r&&typeof r!="boolean"&&(u=e,e=fe(n,r,u)?null:r,r=false);var o=te();if((o!==tr||null!=e)&&(e=o(e,u,3)),r&&re()==t){r=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e>>0,e=xu(r);++tr?fo(e+r,0):r||0:0,typeof n=="string"||!Uo(n)&&eu(n)?rarguments.length,or)}function $e(n,t,r,e){return(Uo(n)?Zt:Er)(n,te(t,e,4),r,3>arguments.length,ir)}function Le(n,t,r){return(r?fe(n,t,r):null==t)?(n=_e(n),t=n.length,0t?0:+t||0,n.length),n) -}function Be(n){n=_e(n);for(var t=-1,r=n.length,e=xu(r);++t=r||r>t?(f&&Vu(f),r=p,f=s=p=m,r&&(h=To(),a=n.apply(l,i),s||f||(i=l=null))):s=Hu(e,r)}function u(){s&&Vu(s),f=s=p=m,(g||_!==t)&&(h=To(),a=n.apply(l,i),s||f||(i=l=null)) -}function o(){if(i=arguments,c=To(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=Vu(f)),h=c,a=n.apply(l,i)):f||(f=Hu(u,o))}return y&&s?s=Vu(s):s||t===_||(s=Hu(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true;if(typeof n!="function")throw new Wu($);if(t=0>t?0:+t||0,true===r)var v=true,g=false;else Qe(r)&&(v=r.leading,_="maxWait"in r&&fo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&Vu(s),f&&Vu(f),f=s=p=m -},o}function Ye(n,t){function r(){var e=arguments,u=r.cache,o=t?t.apply(this,e):e[0];return u.has(o)?u.get(o):(e=n.apply(this,e),u.set(o,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new Wu($);return r.cache=new Ye.Cache,r}function Ze(n){var t=Rr(arguments,1),r=_(t,Ze.placeholder);return Jr(n,E,null,t,r)}function Ge(n){var t=Rr(arguments,1),r=_(t,Ge.placeholder);return Jr(n,R,null,t,r)}function Je(n){return ae(p(n)?n.length:m)&&zu.call(n)==B||false}function Xe(n){return n&&1===n.nodeType&&p(n)&&-1t||!n||!oo(t))return r;do t%2&&(r+=n),t=Yu(t/2),n+=n;while(t);return r}function hu(n,t,r){var u=n;return(n=e(n))?(r?fe(u,t,r):null==t)?n.slice(g(n),v(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function _u(n,t,r){return r&&fe(n,t,r)&&(t=null),n=e(n),n.match(t||Et)||[]}function gu(){for(var n=arguments[0],t=arguments.length,r=xu(t?t-1:0);0<--t;)r[t-1]=arguments[t];try{return n.apply(m,r)}catch(e){return He(e)?e:new ju(e)}}function vu(n,t,r){return r&&fe(n,t,r)&&(t=null),p(n)?mu(n):tr(n,t) -}function yu(n){return function(){return n}}function du(n){return n}function mu(n){return wr(rr(n,true))}function bu(n,t,r){if(null==r){var e=Qe(t),u=e&&zo(t);((u=u&&u.length&&vr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=vr(t,zo(t)));var o=true,e=-1,i=$o(n),f=u.length;false===r?o=false:Qe(r)&&"chain"in r&&(o=r.chain);for(;++e>>1,mo=ro?ro.BYTES_PER_ELEMENT:0,bo=Eu.pow(2,53)-1,wo=to&&new to,xo=Tt.support={};!function(n){xo.funcDecomp=!nu(h.WinRTError)&&jt.test(d),xo.funcNames=typeof ku.name=="string";try{xo.dom=11===Uu.createDocumentFragment().nodeType -}catch(t){xo.dom=false}try{xo.nonEnumArgs=!Ju.call(arguments,1)}catch(r){xo.nonEnumArgs=true}}(0,0),Tt.templateSettings={escape:pt,evaluate:ht,interpolate:_t,variable:"",imports:{_:Tt}};var Ao=function(){function n(){}return function(t){if(Qe(t)){n.prototype=t;var r=new n;n.prototype=null}return r||h.Object()}}(),jo=wo?function(n,t){return wo.set(n,t),n}:du;Pu||($r=qu&&no?function(n){var t=n.byteLength,r=ro?Yu(t/mo):0,e=r*mo,u=new qu(t);if(r){var o=new ro(u,0,r);o.set(new ro(n,0,r))}return t!=e&&(o=new no(u,e),o.set(new no(n,e))),u -}:yu(null));var ko=uo&&Xu?function(n){return new $t(n)}:yu(null),Eo=wo?function(n){return wo.get(n)}:wu,Ro=function(){var n=0,t=0;return function(r,e){var u=To(),o=S-(u-t);if(t=u,0=T)return r}else n=0;return jo(r,e)}}(),Io=zr(function(n,t,r){Lu.call(n,r)?++n[r]:n[r]=1}),Oo=zr(function(n,t,r){Lu.call(n,r)?n[r].push(t):n[r]=[t]}),Co=zr(function(n,t,r){n[r]=t}),Wo=zr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),To=co||function(){return(new Au).getTime()},So=qr(),No=qr(true),Uo=eo||function(n){return p(n)&&ae(n.length)&&zu.call(n)==z||false -};xo.dom||(Xe=function(n){return n&&1===n.nodeType&&p(n)&&!Lo(n)||false});var Fo=lo||function(n){return typeof n=="number"&&oo(n)},$o=r(/x/)||no&&!r(no)?function(n){return zu.call(n)==P}:r,Lo=Zu?function(n){if(!n||zu.call(n)!=V)return false;var t=n.valueOf,r=nu(t)&&(r=Zu(t))&&Zu(r);return r?n==r||Zu(n)==r:pe(n)}:pe,Bo=Dr(Ht),zo=io?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof n!="function"&&r&&ae(r)?he(n):Qe(n)?io(n):[]}:he,Do=Dr(Ar),Mo=Pr(function(n,t,r){return t=t.toLowerCase(),n+(r?t.charAt(0).toUpperCase()+t.slice(1):t) -}),qo=Pr(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()});8!=so(Rt+"08")&&(su=function(n,t,r){return(r?fe(n,t,r):null==t)?t=0:t&&(t=+t),n=hu(n),so(n,t||(dt.test(n)?16:10))});var Po=Pr(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Ko=Pr(function(n,t,r){return n+(r?" ":"")+(t.charAt(0).toUpperCase()+t.slice(1))}),Vo=Vr(Vt),Yo=Vr(function(n){for(var t=-1,r=n.length,e=_o;++t--n?t.apply(this,arguments):void 0 -}},Tt.ary=function(n,t,r){return r&&fe(n,t,r)&&(t=null),t=n&&null==t?n.length:fo(+t||0,0),Jr(n,O,null,null,null,null,t)},Tt.assign=Bo,Tt.at=function(n){return ae(n?n.length:0)&&(n=_e(n)),Qt(n,lr(arguments,false,false,1))},Tt.before=De,Tt.bind=Me,Tt.bindAll=function(n){for(var t=n,r=1r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r(s?Lt(s,f):o(l,f,0))){for(r=e;--r;){var p=u[r];if(0>(p?Lt(p,f):o(n[r],f,0)))continue n}s&&s.push(f),l.push(f) -}return l},Tt.invert=function(n,t,r){r&&fe(n,t,r)&&(t=null),r=-1;for(var e=zo(n),u=e.length,o={};++rt?0:t)):[]},Tt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?fe(n,t,r):null==t)&&(t=1),t=e-(+t||0),Rr(n,0>t?0:t)):[]},Tt.takeRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=te(t,r,3);e--&&t(n[e],e,n););return Rr(n,e+1)},Tt.takeWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];var u=-1;for(t=te(t,r,3);++un||!oo(n))return[];var e=-1,u=xu(ao(n,go));for(t=Fr(t,r,1);++er?0:+r||0,u),r-=t.length,0<=r&&n.indexOf(t,r)==r},Tt.escape=function(n){return(n=e(n))&&st.test(n)?n.replace(ct,c):n},Tt.escapeRegExp=lu,Tt.every=Oe,Tt.find=We,Tt.findIndex=me,Tt.findKey=function(n,t,r){return t=te(t,r,3),cr(n,t,_r,true)},Tt.findLast=function(n,t,r){return t=te(t,r,3),cr(n,t,ir)},Tt.findLastIndex=function(n,t,r){var e=n?n.length:0; -for(t=te(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Tt.findLastKey=function(n,t,r){return t=te(t,r,3),cr(n,t,gr,true)},Tt.findWhere=function(n,t){return We(n,wr(t))},Tt.first=be,Tt.has=function(n,t){return n?Lu.call(n,t):false},Tt.identity=du,Tt.includes=Ne,Tt.indexOf=we,Tt.inRange=function(n,t,r){return t=+t||0,"undefined"===typeof r?(r=t,t=0):r=+r||0,n>=t&&nr?fo(e+r,0):ao(r||0,e-1))+1;else if(r)return u=Nr(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1; -if(t!==t)return s(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Tt.max=Vo,Tt.min=Yo,Tt.noConflict=function(){return h._=Du,this},Tt.noop=wu,Tt.now=To,Tt.pad=function(n,t,r){n=e(n),t=+t;var u=n.length;return ur?0:+r||0,n.length),n.lastIndexOf(t,r)==r -},Tt.sum=function(n){Uo(n)||(n=_e(n));for(var t=n.length,r=0;t--;)r+=+n[t]||0;return r},Tt.template=function(n,t,r){var u=Tt.templateSettings;r&&fe(n,t,r)&&(t=r=null),n=e(n),t=Ht(Ht({},r||t),u,Xt),r=Ht(Ht({},t.imports),u.imports,Xt);var o,i,f=zo(r),a=Tr(r,f),c=0;r=t.interpolate||wt;var s="__p+='";r=Ou((t.escape||wt).source+"|"+r.source+"|"+(r===_t?gt:wt).source+"|"+(t.evaluate||wt).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),s+=n.slice(c,a).replace(kt,l),r&&(o=true,s+="'+__e("+r+")+'"),f&&(i=true,s+="';"+f+";\n__p+='"),e&&(s+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t -}),s+="';",(t=t.variable)||(s="with(obj){"+s+"}"),s=(i?s.replace(ot,""):s).replace(it,"$1").replace(ft,"$1;"),s="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+s+"return __p}",t=gu(function(){return ku(f,p+"return "+s).apply(m,a)}),t.source=s,He(t))throw t;return t},Tt.trim=hu,Tt.trimLeft=function(n,t,r){var u=n;return(n=e(n))?n.slice((r?fe(u,t,r):null==t)?g(n):o(n,t+"")):n -},Tt.trimRight=function(n,t,r){var u=n;return(n=e(n))?(r?fe(u,t,r):null==t)?n.slice(0,v(n)+1):n.slice(0,i(n,t+"")+1):n},Tt.trunc=function(n,t,r){r&&fe(n,t,r)&&(t=null);var u=C;if(r=W,null!=t)if(Qe(t)){var o="separator"in t?t.separator:o,u="length"in t?+t.length||0:u;r="omission"in t?e(t.omission):r}else u=+t||0;if(n=e(n),u>=n.length)return n;if(u-=r.length,1>u)return r;if(t=n.slice(0,u),null==o)return t+r;if(ru(o)){if(n.slice(u).search(o)){var i,f=n.slice(0,u);for(o.global||(o=Ou(o.source,(vt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index; -t=t.slice(0,null==i?u:i)}}else n.indexOf(o,u)!=u&&(o=t.lastIndexOf(o),-1u.__dir__?"Right":"")}),u},Ut.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Ut.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[r](n,t).reverse()}}),Mt(["first","last"],function(n,t){var r="take"+(t?"Right":"");Ut.prototype[n]=function(){return this[r](1).value()[0]}}),Mt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right"); -Ut.prototype[n]=function(){return this[r](1)}}),Mt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?wr:jr;Ut.prototype[n]=function(n){return this[r](e(n))}}),Ut.prototype.compact=function(){return this.filter(du)},Ut.prototype.reject=function(n,t){return n=te(n,t,1),this.filter(function(t){return!n(t)})},Ut.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Ut.prototype.toArray=function(){return this.drop(0) -},_r(Ut.prototype,function(n,t){var r=Tt[t],e=/^(?:filter|map|reject)|While$/.test(t),u=/^(?:first|last)$/.test(t);Tt.prototype[t]=function(){function t(n){return n=[n],Gu.apply(n,o),r.apply(Tt,n)}var o=arguments,i=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,c=f instanceof Ut,l=o[0],s=c||Uo(f);return s&&e&&typeof l=="function"&&1!=l.length&&(c=s=false),c=c&&!a,u&&!i?c?n.call(f):r.call(Tt,this.value()):s?(f=n.apply(c?f:new Ut(this),o),u||!a&&!f.__actions__||(f.__actions__||(f.__actions__=[])).push({func:Ie,args:[t],thisArg:Tt}),new Nt(f,i)):this.thru(t) -}}),Mt("concat join pop push replace shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?Nu:Tu)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);Tt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),Ut.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Ut(this.__wrapped__);return e.__actions__=n?Bt(n):null,e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=t?Bt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?Bt(r):null,e -},Ut.prototype.reverse=function(){if(this.__filtered__){var n=new Ut(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Ut.prototype.value=function(){var n=this.__wrapped__.value();if(!Uo(n))return Sr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++ip.index:u=_:!h(s))))continue n}else if(p=h(s),_==F)s=p;else if(!p){if(_==U)continue n;break n}}c[a++]=s}return c},Tt.prototype.chain=function(){return Re(this)},Tt.prototype.commit=function(){return new Nt(this.value(),this.__chain__)},Tt.prototype.plant=function(n){for(var t,r=this;r instanceof St;){var e=ve(r); -t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Tt.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Ut?(this.__actions__.length&&(n=new Ut(this)),new Nt(n.reverse(),this.__chain__)):this.thru(function(n){return n.reverse()})},Tt.prototype.toString=function(){return this.value()+""},Tt.prototype.run=Tt.prototype.toJSON=Tt.prototype.valueOf=Tt.prototype.value=function(){return Sr(this.__wrapped__,this.__actions__)},Tt.prototype.collect=Tt.prototype.map,Tt.prototype.head=Tt.prototype.first,Tt.prototype.select=Tt.prototype.filter,Tt.prototype.tail=Tt.prototype.rest,Tt -}var m,b="3.5.0",w=1,x=2,A=4,j=8,k=16,E=32,R=64,I=128,O=256,C=30,W="...",T=150,S=16,N=0,U=1,F=2,$="Expected a function",L="__lodash_placeholder__",B="[object Arguments]",z="[object Array]",D="[object Boolean]",M="[object Date]",q="[object Error]",P="[object Function]",K="[object Number]",V="[object Object]",Y="[object RegExp]",Z="[object String]",G="[object ArrayBuffer]",J="[object Float32Array]",X="[object Float64Array]",H="[object Int8Array]",Q="[object Int16Array]",nt="[object Int32Array]",tt="[object Uint8Array]",rt="[object Uint8ClampedArray]",et="[object Uint16Array]",ut="[object Uint32Array]",ot=/\b__p\+='';/g,it=/\b(__p\+=)''\+/g,ft=/(__e\(.*?\)|\b__t\))\+'';/g,at=/&(?:amp|lt|gt|quot|#39|#96);/g,ct=/[&<>"'`]/g,lt=RegExp(at.source),st=RegExp(ct.source),pt=/<%-([\s\S]+?)%>/g,ht=/<%([\s\S]+?)%>/g,_t=/<%=([\s\S]+?)%>/g,gt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vt=/\w*$/,yt=/^\s*function[ \n\r\t]+\w/,dt=/^0[xX]/,mt=/^\[object .+?Constructor\]$/,bt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,wt=/($^)/,xt=/[.*+?^${}()|[\]\/\\]/g,At=RegExp(xt.source),jt=/\bthis\b/,kt=/['\n\r\u2028\u2029\\]/g,Et=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),Rt=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",It="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Ot={}; -Ot[J]=Ot[X]=Ot[H]=Ot[Q]=Ot[nt]=Ot[tt]=Ot[rt]=Ot[et]=Ot[ut]=true,Ot[B]=Ot[z]=Ot[G]=Ot[D]=Ot[M]=Ot[q]=Ot[P]=Ot["[object Map]"]=Ot[K]=Ot[V]=Ot[Y]=Ot["[object Set]"]=Ot[Z]=Ot["[object WeakMap]"]=false;var Ct={};Ct[B]=Ct[z]=Ct[G]=Ct[D]=Ct[M]=Ct[J]=Ct[X]=Ct[H]=Ct[Q]=Ct[nt]=Ct[K]=Ct[V]=Ct[Y]=Ct[Z]=Ct[tt]=Ct[rt]=Ct[et]=Ct[ut]=true,Ct[q]=Ct[P]=Ct["[object Map]"]=Ct["[object Set]"]=Ct["[object WeakMap]"]=false;var Wt={leading:false,maxWait:0,trailing:false},Tt={"\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"},St={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Nt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ut={"function":true,object:true},Ft={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$t=Ut[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Ut[typeof module]&&module&&!module.nodeType&&module,Ut=Ut[typeof window]&&window,Bt=Lt&&Lt.exports===$t&&$t,zt=$t&&Lt&&typeof global=="object"&&global||Ut!==(this&&this.window)&&Ut||this,Dt=d(); -typeof define=="function"&&typeof define.amd=="object"&&define.amd?(zt._=Dt, define(function(){return Dt})):$t&&Lt?Bt?(Lt.exports=Dt)._=Dt:$t._=Dt:zt._=Dt}).call(this); \ No newline at end of file +;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Yt(n,t){for(var r=-1,e=n.length;++ri(t,a,0)&&u.push(a);return u}function er(n,t){var r=true;return Ao(n,function(n,e,u){return r=!!t(n,e,u)}),r}function ur(n,t){var r=[];return Ao(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function or(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function ir(n,t,r){for(var e=-1,u=n.length,o=-1,i=[];++et&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=wu(u);++eu(a,p,0)&&((t||f)&&a.push(p),c.push(l))}return c}function Ir(n,t){for(var r=-1,e=t.length,u=wu(e);++r>>1,i=n[o];(r?i<=t:ir||null==e)return e; +var u=t[r-2],o=t[r-1],i=t[3];for(3arguments.length;return typeof e=="function"&&typeof o=="undefined"&&si(r)?n(r,e,u,i):wr(r,le(e,o,4),u,i,t)}}function te(n,t,r,e,u,o,i,f,a,c){function l(){for(var b=arguments.length,j=b,k=wu(b);j--;)k[j]=arguments[j]; +if(e&&(k=Ur(k,e,u)),o&&(k=Fr(k,o,i)),_||y){var j=l.placeholder,E=v(k,j),b=b-E.length;if(bu)||i===e&&i===o)&&(u=i,o=n) +}),o}function le(n,t,r){var e=Wt.callback||_u,e=e===_u?Qt:e;return r?e(n,t,r):e}function pe(n,t,e){var u=Wt.indexOf||Ce,u=u===Ce?r:u;return n?u(n,t,e):u}function se(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Nu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function he(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Eu),new n}function _e(n,t,r){var e=n.constructor;switch(t){case J:return Tr(n);case D:case P:return new e(+n);case X:case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:return t=n.buffer,new e(r?Tr(t):t,n.byteOffset,n.length); +case V:case G:return new e(n);case Z:var u=new e(n.source,dt.exec(n));u.lastIndex=n.lastIndex}return u}function ve(n,t){return n=+n,t=null==t?yo:t,-1t?0:t)):[]}function Oe(n,t,r){var e=n?n.length:0;return e?((r?ge(n,t,r):null==t)&&(t=1),t=e-(+t||0),br(n,0,0>t?0:t)):[]}function Re(n){return n?n[0]:w}function Ce(n,t,e){var u=n?n.length:0; +if(!u)return-1;if(typeof e=="number")e=0>e?oo(u+e,0):e;else if(e)return e=Cr(n,t),n=n[e],(t===t?t===n:n!==n)?e:-1;return r(n,t,e||0)}function Se(n){var t=n?n.length:0;return t?n[t-1]:w}function We(n){return Ie(n,1)}function Te(n,t,e,u){if(!n||!n.length)return[];null!=t&&typeof t!="boolean"&&(u=e,e=ge(n,t,u)?null:t,t=false);var o=le();if((o!==Qt||null!=e)&&(e=o(e,u,3)),t&&pe()==r){t=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e>>0,e=wu(r);++tr?oo(u+r,0):r||0,typeof n=="string"||!si(n)&&ru(n)?rt?0:+t||0,n.length),n)}function Pe(n){n=je(n);for(var t=-1,r=n.length,e=wu(r);++t=r||r>t?(f&&qu(f),r=s,f=p=s=w,r&&(h=Qo(),a=n.apply(l,i),p||f||(i=l=null))):p=Ju(e,r)}function u(){p&&qu(p),f=p=s=w,(v||_!==t)&&(h=Qo(),a=n.apply(l,i),p||f||(i=l=null)) +}function o(){if(i=arguments,c=Qo(),l=this,s=v&&(p||!g),false===_)var r=g&&!p;else{f||g||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=qu(f)),h=c,a=n.apply(l,i)):f||(f=Ju(u,o))}return y&&p?p=qu(p):p||t===_||(p=Ju(e,t)),r&&(y=true,a=n.apply(l,i)),!y||p||f||(i=l=null),a}var i,f,a,c,l,p,s,h=0,_=false,v=true;if(typeof n!="function")throw new Ru(L);if(t=0>t?0:+t||0,true===r)var g=true,v=false;else He(r)&&(g=r.leading,_="maxWait"in r&&oo(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){p&&qu(p),f&&qu(f),f=p=s=w +},o}function Ye(n,t){function r(){var e=arguments,u=r.cache,o=t?t.apply(this,e):e[0];return u.has(o)?u.get(o):(e=n.apply(this,e),u.set(o,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new Ru(L);return r.cache=new Ye.Cache,r}function Ze(n,t){if(typeof n!="function")throw new Ru(L);return t=oo(typeof t=="undefined"?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=oo(r.length-t,0),o=wu(u);++et||!n||!eo(t))return r;do t%2&&(r+=n),t=Ku(t/2),n+=n;while(t);return r}function su(n,t,r){var e=n;return(n=u(n))?(r?ge(e,t,r):null==t)?n.slice(g(n),y(n)+1):(t+="",n.slice(i(n,t),f(n,t)+1)):n}function hu(n,t,r){return r&&ge(n,t,r)&&(t=null),n=u(n),n.match(t||Et)||[] +}function _u(n,t,r){return r&&ge(n,t,r)&&(t=null),h(n)?yu(n):Qt(n,t)}function vu(n){return function(){return n}}function gu(n){return n}function yu(n){return vr(nr(n,true))}function du(n,t,r){if(null==r){var e=He(t),u=e&&ji(t);((u=u&&u.length&&lr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=lr(t,ji(t)));var o=true,e=-1,i=_i(n),f=u.length;false===r?o=false:He(r)&&"chain"in r&&(o=r.chain);for(;++e>>1,go=no?no.BYTES_PER_ELEMENT:0,yo=ju.pow(2,53)-1,mo=Qu&&new Qu,wo={},bo=Wt.support={};!function(n){bo.funcDecomp=/\bthis\b/.test(function(){return this}),bo.funcNames=typeof Au.name=="string";try{bo.dom=11===Tu.createDocumentFragment().nodeType +}catch(t){bo.dom=false}try{bo.nonEnumArgs=!Zu.call(arguments,1)}catch(r){bo.nonEnumArgs=true}}(0,0),Wt.templateSettings={escape:ht,evaluate:_t,interpolate:vt,variable:"",imports:{_:Wt}};var xo=function(){function n(){}return function(t){if(He(t)){n.prototype=t;var r=new n;n.prototype=null}return r||_.Object()}}(),Ao=Lr(ar),jo=Lr(cr,true),ko=Br(),Eo=Br(true),Io=mo?function(n,t){return mo.set(n,t),n}:gu;Du||(Tr=Mu&&Hu?function(n){var t=n.byteLength,r=no?Ku(t/go):0,e=r*go,u=new Mu(t);if(r){var o=new no(u,0,r); +o.set(new no(n,0,r))}return t!=e&&(o=new Hu(u,e),o.set(new Hu(n,e))),u}:vu(null));var Oo=ro&&Gu?function(n){return new $t(n)}:vu(null),Ro=mo?function(n){return mo.get(n)}:mu,Co=function(){return bo.funcNames?"constant"==vu.name?dr("name"):function(n){for(var t=n.name,r=wo[t],e=r?r.length:0;e--;){var u=r[e],o=u.func;if(null==o||o==n)return u.name}return t}:vu("")}(),So=function(){var n=0,t=0;return function(r,e){var u=Qo(),o=U-(u-t);if(t=u,0=T)return r}else n=0;return Io(r,e)}}(),Wo=Ze(function(n,t){return si(n)||Ge(n)?rr(n,ir(t,false,true)):[] +}),To=Vr(),Uo=Vr(true),Fo=Ze(function(t,r){t||(t=[]),r=ir(r);var e=r.length,u=Xt(t,r);for(r.sort(n);e--;){var o=parseFloat(r[e]);if(o!=i&&ve(o)){var i=o;Xu.call(t,o,1)}}return u}),No=ue(),$o=ue(true),Lo=Ze(function(n){return Er(ir(n,false,true))}),Bo=Ze(function(n,t){return si(n)||Ge(n)?rr(n,t):[]}),zo=Ze(Ue),Mo=Ze(function(n,t){return de(n?n.length:0)&&(n=je(n)),Xt(n,ir(t))}),Do=Nr(function(n,t,r){Nu.call(n,r)?++n[r]:n[r]=1}),Po=Kr(Ao),qo=Kr(jo,true),Ko=Gr(zt,Ao),Vo=Gr(function(n,t){for(var r=n.length;r--&&false!==t(n[r],r,n););return n +},jo),Yo=Nr(function(n,t,r){Nu.call(n,r)?n[r].push(t):n[r]=[t]}),Zo=Nr(function(n,t,r){n[r]=t}),Go=Ze(function(n,t,r){var e=-1,u=typeof t=="function",o=n?n.length:0,i=de(o)?wu(o):[];return Ao(n,function(n){var o=u?t:null!=n&&n[t];i[++e]=o?o.apply(n,r):w}),i}),Jo=Nr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Xo=ne(function(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u--n?t.apply(this,arguments):void 0 +}},Wt.ary=function(n,t,r){return r&&ge(n,t,r)&&(t=null),t=n&&null==t?n.length:oo(+t||0,0),oe(n,R,null,null,null,null,t)},Wt.assign=gi,Wt.at=Mo,Wt.before=Ke,Wt.bind=ni,Wt.bindAll=ti,Wt.bindKey=ri,Wt.callback=_u,Wt.chain=Ne,Wt.chunk=function(n,t,r){t=(r?ge(n,t,r):null==t)?1:oo(+t||1,1),r=0;for(var e=n?n.length:0,u=-1,o=wu(Pu(e/t));rr&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r(p?Lt(p,f):o(l,f,0))){for(t=e;--t;){var s=u[t];if(0>(s?Lt(s,f):o(n[t],f,0)))continue n}p&&p.push(f),l.push(f)}return l},Wt.invert=function(n,t,r){r&&ge(n,t,r)&&(t=null),r=-1;for(var e=ji(n),u=e.length,o={};++rt?0:t)):[]},Wt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?ge(n,t,r):null==t)&&(t=1),t=e-(+t||0),br(n,0>t?0:t)):[] +},Wt.takeRightWhile=function(n,t,r){return n&&n.length?Or(n,le(t,r,3),false,true):[]},Wt.takeWhile=function(n,t,r){return n&&n.length?Or(n,le(t,r,3)):[]},Wt.tap=function(n,t,r){return t.call(r,n),n},Wt.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new Ru(L);return false===r?e=false:He(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),St.leading=e,St.maxWait=+t,St.trailing=u,Ve(n,t,St)},Wt.thru=$e,Wt.times=function(n,t,r){if(n=+n,1>n||!eo(n))return[];var e=-1,u=wu(io(n,ho)); +for(t=Wr(t,r,1);++er?0:+r||0,e),r-=t.length,0<=r&&n.indexOf(t,r)==r},Wt.escape=function(n){return(n=u(n))&&st.test(n)?n.replace(lt,l):n},Wt.escapeRegExp=cu,Wt.every=Le,Wt.find=Po,Wt.findIndex=To,Wt.findKey=di,Wt.findLast=qo,Wt.findLastIndex=Uo,Wt.findLastKey=mi,Wt.findWhere=function(n,t){return Po(n,vr(t))},Wt.first=Re,Wt.has=function(n,t){return n?Nu.call(n,t):false +},Wt.identity=gu,Wt.includes=ze,Wt.indexOf=Ce,Wt.inRange=function(n,t,r){return t=+t||0,"undefined"===typeof r?(r=t,t=0):r=+r||0,n>=t&&nr?oo(e+r,0):io(r||0,e-1))+1;else if(r)return u=Cr(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return s(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Wt.max=Fi,Wt.min=Ni,Wt.noConflict=function(){return _._=Bu,this},Wt.noop=mu,Wt.now=Qo,Wt.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return er?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Wt.sum=function(n,t,r){r&&ge(n,t,r)&&(t=null);var e=le(),u=null==t;if(e===Qt&&u||(u=false,t=e(t,r,3)),u){for(n=si(n)?n:je(n),t=n.length,r=0;t--;)r+=+n[t]||0;n=r}else n=kr(n,t);return n},Wt.template=function(n,t,r){var e=Wt.templateSettings;r&&ge(n,t,r)&&(t=r=null),n=u(n),t=Jt(Jt({},r||t),e,Gt),r=Jt(Jt({},t.imports),e.imports,Gt); +var o,i,f=ji(r),a=Ir(r,f),c=0;r=t.interpolate||xt;var l="__p+='";r=Iu((t.escape||xt).source+"|"+r.source+"|"+(r===vt?yt:xt).source+"|"+(t.evaluate||xt).source+"|$","g");var s="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(kt,p),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(it,""):l).replace(ft,"$1").replace(at,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Ui(function(){return Au(f,s+"return "+l).apply(w,a) +}),t.source=l,Xe(t))throw t;return t},Wt.trim=su,Wt.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?ge(e,t,r):null==t)?g(n):i(n,t+"")):n},Wt.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?ge(e,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,f(n,t+"")+1):n},Wt.trunc=function(n,t,r){r&&ge(n,t,r)&&(t=null);var e=S;if(r=W,null!=t)if(He(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r; +if(t=n.slice(0,e),null==o)return t+r;if(tu(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Iu(o.source,(dt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),-1u.__dir__?"Right":"")}),u},Ft.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Ft.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[r](n,t).reverse()}}),zt(["first","last"],function(n,t){var r="take"+(t?"Right":""); +Ft.prototype[n]=function(){return this[r](1).value()[0]}}),zt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Ft.prototype[n]=function(){return this[r](1)}}),zt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?vr:dr;Ft.prototype[n]=function(n){return this[r](e(n))}}),Ft.prototype.compact=function(){return this.filter(gu)},Ft.prototype.reject=function(n,t){return n=le(n,t,1),this.filter(function(t){return!n(t)})},Ft.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n); +return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Ft.prototype.toArray=function(){return this.drop(0)},ar(Ft.prototype,function(n,t){var r=Wt[t];if(r){var e=/^(?:filter|map|reject)|While$/.test(t),u=/^(?:first|last)$/.test(t);Wt.prototype[t]=function(){function t(n){return n=[n],Yu.apply(n,o),r.apply(Wt,n)}var o=arguments,i=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,c=f instanceof Ft,l=o[0],p=c||si(f);return p&&e&&typeof l=="function"&&1!=l.length&&(c=p=false),c=c&&!a,u&&!i?c?n.call(f):r.call(Wt,this.value()):p?(f=n.apply(c?f:new Ft(this),o),u||!a&&!f.__actions__||(f.__actions__||(f.__actions__=[])).push({func:$e,args:[t],thisArg:Wt}),new Ut(f,i)):this.thru(t) +}}}),zt("concat join pop push replace shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?Wu:Cu)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);Wt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),ar(Ft.prototype,function(n,t){var r=Wt[t];if(r){var e=r.name;(wo[e]||(wo[e]=[])).push({name:t,func:r})}}),wo[te(null,A).name]=[{name:"wrapper",func:null}],Ft.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Ft(this.__wrapped__); +return e.__actions__=n?Bt(n):null,e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=t?Bt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?Bt(r):null,e},Ft.prototype.reverse=function(){if(this.__filtered__){var n=new Ft(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Ft.prototype.value=function(){var n=this.__wrapped__.value();if(!si(n))return Rr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++is.index:u=_:!h(p))))continue n}else if(s=h(p),_==$)p=s;else if(!s){if(_==N)continue n; +break n}}c[a++]=p}return c},Wt.prototype.chain=function(){return Ne(this)},Wt.prototype.commit=function(){return new Ut(this.value(),this.__chain__)},Wt.prototype.plant=function(n){for(var t,r=this;r instanceof Tt;){var e=Ee(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Wt.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Ft?(this.__actions__.length&&(n=new Ft(this)),new Ut(n.reverse(),this.__chain__)):this.thru(function(n){return n.reverse()})},Wt.prototype.toString=function(){return this.value()+"" +},Wt.prototype.run=Wt.prototype.toJSON=Wt.prototype.valueOf=Wt.prototype.value=function(){return Rr(this.__wrapped__,this.__actions__)},Wt.prototype.collect=Wt.prototype.map,Wt.prototype.head=Wt.prototype.first,Wt.prototype.select=Wt.prototype.filter,Wt.prototype.tail=Wt.prototype.rest,Wt}var w,b="3.6.0",x=1,A=2,j=4,k=8,E=16,I=32,O=64,R=128,C=256,S=30,W="...",T=150,U=16,F=0,N=1,$=2,L="Expected a function",B="__lodash_placeholder__",z="[object Arguments]",M="[object Array]",D="[object Boolean]",P="[object Date]",q="[object Error]",K="[object Function]",V="[object Number]",Y="[object Object]",Z="[object RegExp]",G="[object String]",J="[object ArrayBuffer]",X="[object Float32Array]",H="[object Float64Array]",Q="[object Int8Array]",nt="[object Int16Array]",tt="[object Int32Array]",rt="[object Uint8Array]",et="[object Uint8ClampedArray]",ut="[object Uint16Array]",ot="[object Uint32Array]",it=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,at=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/&(?:amp|lt|gt|quot|#39|#96);/g,lt=/[&<>"'`]/g,pt=RegExp(ct.source),st=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,_t=/<%([\s\S]+?)%>/g,vt=/<%=([\s\S]+?)%>/g,gt=/[\u0300-\u036f\ufe20-\ufe23]/g,yt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,mt=/^0[xX]/,wt=/^\[object .+?Constructor\]$/,bt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,xt=/($^)/,At=/[.*+?^${}()|[\]\/\\]/g,jt=RegExp(At.source),kt=/['\n\r\u2028\u2029\\]/g,Et=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),It=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Ot="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window".split(" "),Rt={}; +Rt[X]=Rt[H]=Rt[Q]=Rt[nt]=Rt[tt]=Rt[rt]=Rt[et]=Rt[ut]=Rt[ot]=true,Rt[z]=Rt[M]=Rt[J]=Rt[D]=Rt[P]=Rt[q]=Rt[K]=Rt["[object Map]"]=Rt[V]=Rt[Y]=Rt[Z]=Rt["[object Set]"]=Rt[G]=Rt["[object WeakMap]"]=false;var Ct={};Ct[z]=Ct[M]=Ct[J]=Ct[D]=Ct[P]=Ct[X]=Ct[H]=Ct[Q]=Ct[nt]=Ct[tt]=Ct[V]=Ct[Y]=Ct[Z]=Ct[G]=Ct[rt]=Ct[et]=Ct[ut]=Ct[ot]=true,Ct[q]=Ct[K]=Ct["[object Map]"]=Ct["[object Set]"]=Ct["[object WeakMap]"]=false;var St={leading:false,maxWait:0,trailing:false},Wt={"\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"},Tt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ut={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ft={"function":true,object:true},Nt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$t=Ft[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Ft[typeof module]&&module&&!module.nodeType&&module,Bt=Ft[typeof self]&&self&&self.Object&&self,Ft=Ft[typeof window]&&window&&window.Object&&window,zt=Lt&&Lt.exports===$t&&$t,Mt=$t&&Lt&&typeof global=="object"&&global||Ft!==(this&&this.window)&&Ft||Bt||this,Dt=m(); +typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Mt._=Dt, define(function(){return Dt})):$t&&Lt?zt?(Lt.exports=Dt)._=Dt:$t._=Dt:Mt._=Dt}).call(this); \ No newline at end of file diff --git a/lodash.src.js b/lodash.src.js index b72802d51c..08c62e5eec 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.5.0 + * lodash 3.6.0 * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.8.2 * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -12,7 +12,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.5.0'; + var VERSION = '3.6.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -22,8 +22,8 @@ CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, - REARG_FLAG = 128, - ARY_FLAG = 256; + ARY_FLAG = 128, + REARG_FLAG = 256; /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, @@ -88,18 +88,18 @@ reInterpolate = /<%=([\s\S]+?)%>/g; /** - * Used to match ES template delimiters. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components) - * for more details. + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + */ + var reComboMarks = /[\u0300-\u036f\ufe20-\ufe23]/g; + + /** + * Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components). */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; - /** Used to detect named functions. */ - var reFuncName = /^\s*function[ \n\r\t]+\w/; - /** Used to detect hexadecimal string values. */ var reHexPrefix = /^0[xX]/; @@ -113,16 +113,13 @@ var reNoMatch = /($^)/; /** - * Used to match `RegExp` special characters. - * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) - * for more details. + * Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special). + * In addition to special characters the forward slash is escaped to allow for + * easier `eval` use and `Function` compilation. */ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, reHasRegExpChars = RegExp(reRegExpChars.source); - /** Used to detect functions containing a `this` reference. */ - var reThis = /\bthis\b/; - /** Used to match unescaped characters in compiled string literals. */ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; @@ -153,7 +150,7 @@ 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', - 'window', 'WinRTError' + 'window' ]; /** Used to fix the JScript `[[DontEnum]]` bug. */ @@ -268,8 +265,11 @@ /** Detect free variable `global` from Node.js. */ var freeGlobal = freeExports && freeModule && typeof 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; + var freeWindow = objectTypes[typeof window] && window && window.Object && window; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; @@ -280,7 +280,7 @@ * The `this` value is used if it is the global object to avoid Greasemonkey's * restricted `window` object, otherwise the `window` object is used. */ - var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this; + var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; /*--------------------------------------------------------------------------*/ @@ -308,6 +308,28 @@ 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. * @@ -494,7 +516,6 @@ /** * Gets the index at which the first occurrence of `NaN` is found in `array`. - * If `fromRight` is provided elements of `array` are iterated from right to left. * * @private * @param {Array} array The array to search. @@ -543,7 +564,7 @@ * @returns {boolean} Returns `true` if `value` is object-like, else `false`. */ function isObjectLike(value) { - return (value && typeof value == 'object') || false; + return !!value && typeof value == 'object'; } /** @@ -665,19 +686,19 @@ * @returns {Function} Returns a new `lodash` function. * @example * - * _.mixin({ 'add': function(a, b) { return a + b; } }); + * _.mixin({ 'foo': _.constant('foo') }); * * var lodash = _.runInContext(); - * lodash.mixin({ 'sub': function(a, b) { return a - b; } }); + * lodash.mixin({ 'bar': lodash.constant('bar') }); * - * _.isFunction(_.add); + * _.isFunction(_.foo); * // => true - * _.isFunction(_.sub); + * _.isFunction(_.bar); * // => false * - * lodash.isFunction(lodash.add); + * lodash.isFunction(lodash.foo); * // => false - * lodash.isFunction(lodash.sub); + * lodash.isFunction(lodash.bar); * // => true * * // using `context` to mock `Date#getTime` use in `_.now` @@ -731,9 +752,8 @@ var idCounter = 0; /** - * Used to resolve the `toStringTag` of values. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) - * for more details. + * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) + * of values. */ var objToString = objectProto.toString; @@ -798,15 +818,17 @@ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** - * Used as the maximum length of an array-like value. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) - * for more details. + * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) + * of an array-like value. */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; /** Used to store function metadata. */ var metaMap = WeakMap && new WeakMap; + /** Used to lookup unminified function names. */ + var realNames = {}; + /** Used to lookup a type array constructors by `toStringTag`. */ var ctorByTag = {}; ctorByTag[float32Tag] = context.Float32Array; @@ -1022,7 +1044,7 @@ * @memberOf _.support * @type boolean */ - support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext); + support.funcDecomp = /\bthis\b/.test(function() { return this; }); /** * Detect if `Function#name` is supported (all but IE). @@ -1461,7 +1483,7 @@ /** * A specialized version of `_.forEach` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1482,7 +1504,7 @@ /** * A specialized version of `_.forEachRight` for arrays without support for - * callback shorthands or `this` binding. + * callback shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1502,7 +1524,7 @@ /** * A specialized version of `_.every` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1524,7 +1546,7 @@ /** * A specialized version of `_.filter` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1548,7 +1570,7 @@ /** * A specialized version of `_.map` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1610,7 +1632,7 @@ /** * A specialized version of `_.reduce` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1635,7 +1657,7 @@ /** * A specialized version of `_.reduceRight` for arrays without support for - * callback shorthands or `this` binding. + * callback shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1658,7 +1680,7 @@ /** * A specialized version of `_.some` for arrays without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array} array The array to iterate over. @@ -1678,6 +1700,23 @@ return false; } + /** + * A specialized version of `_.sum` for arrays without support for iteratees. + * + * @private + * @param {Array} array The array to iterate over. + * @returns {number} Returns the sum. + */ + function arraySum(array) { + var length = array.length, + result = 0; + + while (length--) { + result += +array[length] || 0; + } + return result; + } + /** * Used by `_.defaults` to customize its `_.assign` use. * @@ -1792,26 +1831,6 @@ return object; } - /** - * The base implementation of `_.bindAll` without support for individual - * method name arguments. - * - * @private - * @param {Object} object The object to bind and assign the bound methods to. - * @param {string[]} methodNames The object method names to bind. - * @returns {Object} Returns `object`. - */ - function baseBindAll(object, methodNames) { - var index = -1, - length = methodNames.length; - - while (++index < length) { - var key = methodNames[index]; - object[key] = createWrapper(object[key], BIND_FLAG, object); - } - return object; - } - /** * The base implementation of `_.callback` which supports specifying the * number of arguments to provide to `func`. @@ -1825,9 +1844,9 @@ function baseCallback(func, thisArg, argCount) { var type = typeof func; if (type == 'function') { - return (typeof thisArg != 'undefined' && isBindable(func)) - ? bindCallback(func, thisArg, argCount) - : func; + return typeof thisArg == 'undefined' + ? func + : bindCallback(func, thisArg, argCount); } if (func == null) { return identity; @@ -1937,14 +1956,14 @@ * @private * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. - * @param {Object} args The `arguments` object to slice and provide to `func`. + * @param {Object} args The arguments provide to `func`. * @returns {number} Returns the timer id. */ - function baseDelay(func, wait, args, fromIndex) { + function baseDelay(func, wait, args) { if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - return setTimeout(function() { func.apply(undefined, baseSlice(args, fromIndex)); }, wait); + return setTimeout(function() { func.apply(undefined, args); }, wait); } /** @@ -2003,21 +2022,7 @@ * @param {Function} iteratee The function invoked per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEach(collection, iteratee) { - var length = collection ? collection.length : 0; - if (!isLength(length)) { - return baseForOwn(collection, iteratee); - } - var index = -1, - iterable = toObject(collection); - - while (++index < length) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - } + var baseEach = createBaseEach(baseForOwn); /** * The base implementation of `_.forEachRight` without support for callback @@ -2028,23 +2033,11 @@ * @param {Function} iteratee The function invoked per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEachRight(collection, iteratee) { - var length = collection ? collection.length : 0; - if (!isLength(length)) { - return baseForOwnRight(collection, iteratee); - } - var iterable = toObject(collection); - while (length--) { - if (iteratee(iterable[length], length, iterable) === false) { - break; - } - } - return collection; - } + var baseEachRight = createBaseEach(baseForOwnRight, true); /** * The base implementation of `_.every` without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2093,7 +2086,7 @@ /** * The base implementation of `_.filter` without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2142,11 +2135,10 @@ * @param {Array} array The array to flatten. * @param {boolean} isDeep Specify a deep flatten. * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects. - * @param {number} fromIndex The index to start from. * @returns {Array} Returns the new flattened array. */ - function baseFlatten(array, isDeep, isStrict, fromIndex) { - var index = fromIndex - 1, + function baseFlatten(array, isDeep, isStrict) { + var index = -1, length = array.length, resIndex = -1, result = []; @@ -2157,7 +2149,7 @@ if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) { if (isDeep) { // Recursively flatten arrays (susceptible to call stack limits). - value = baseFlatten(value, isDeep, isStrict, 0); + value = baseFlatten(value, isDeep, isStrict); } var valIndex = -1, valLength = value.length; @@ -2185,20 +2177,7 @@ * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseFor(object, iteratee, keysFunc) { - var index = -1, - iterable = toObject(object), - props = keysFunc(object), - length = props.length; - - while (++index < length) { - var key = props[index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - } + var baseFor = createBaseFor(); /** * This function is like `baseFor` except that it iterates over properties @@ -2210,19 +2189,7 @@ * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseForRight(object, iteratee, keysFunc) { - var iterable = toObject(object), - props = keysFunc(object), - length = props.length; - - while (length--) { - var key = props[length]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - } + var baseForRight = createBaseFor(true); /** * The base implementation of `_.forIn` without support for callback @@ -2287,30 +2254,6 @@ return result; } - /** - * The base implementation of `_.invoke` which requires additional arguments - * to be provided as an array of arguments rather than individually. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|string} methodName The name of the method to invoke or - * the function invoked per iteration. - * @param {Array} [args] The arguments to invoke the method with. - * @returns {Array} Returns the array of results. - */ - function baseInvoke(collection, methodName, args) { - var index = -1, - isFunc = typeof methodName == 'function', - length = collection ? collection.length : 0, - result = isLength(length) ? Array(length) : []; - - baseEach(collection, function(value) { - var func = isFunc ? methodName : (value != null && value[methodName]); - result[++index] = func ? func.apply(value, args) : undefined; - }); - return result; - } - /** * The base implementation of `_.isEqual` without support for `this` binding * `customizer` functions. @@ -2319,12 +2262,12 @@ * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { // Exit early for identical values. if (value === other) { // Treat `+0` vs. `-0` as not equal. @@ -2339,7 +2282,7 @@ // Return `false` unless both values are `NaN`. return value !== value && other !== other; } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB); + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); } /** @@ -2352,12 +2295,12 @@ * @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} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { var objIsArr = isArray(object), othIsArr = isArray(other), objTag = arrayTag, @@ -2379,21 +2322,27 @@ othIsArr = isTypedArray(other); } } - var objIsObj = objTag == objectTag && !isHostObject(object), - othIsObj = othTag == objectTag && !isHostObject(other), + var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)) && !isHostObject(object), + othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)) && !isHostObject(other), isSameTag = objTag == othTag; if (isSameTag && !(objIsArr || objIsObj)) { return equalByTag(object, other, objTag); } - var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + if (isLoose) { + if (!isSameTag && !(objIsObj && othIsObj)) { + return false; + } + } else { + var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - if (valWrapped || othWrapped) { - return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB); - } - if (!isSameTag) { - return false; + if (valWrapped || othWrapped) { + return equalFunc(valWrapped ? object.value() : object, othWrapped ? 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. @@ -2410,7 +2359,7 @@ stackA.push(object); stackB.push(other); - var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isWhere, stackA, stackB); + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); stackA.pop(); stackB.pop(); @@ -2420,7 +2369,7 @@ /** * The base implementation of `_.isMatch` without support for callback - * shorthands or `this` binding. + * shorthands and `this` binding. * * @private * @param {Object} object The object to inspect. @@ -2431,30 +2380,27 @@ * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ function baseIsMatch(object, props, values, strictCompareFlags, customizer) { - var length = props.length; - if (object == null) { - return !length; - } var index = -1, + length = props.length, noCustomizer = !customizer; while (++index < length) { if ((noCustomizer && strictCompareFlags[index]) ? values[index] !== object[props[index]] - : !hasOwnProperty.call(object, props[index]) + : !(props[index] in object) ) { return false; } } index = -1; while (++index < length) { - var key = props[index]; + var key = props[index], + objValue = object[key], + srcValue = values[index]; + if (noCustomizer && strictCompareFlags[index]) { - var result = hasOwnProperty.call(object, key); + var result = typeof objValue != 'undefined' || (key in object); } else { - var objValue = object[key], - srcValue = values[index]; - result = customizer ? customizer(objValue, srcValue, key) : undefined; if (typeof result == 'undefined') { result = baseIsEqual(srcValue, objValue, customizer, true); @@ -2469,7 +2415,7 @@ /** * The base implementation of `_.map` without support for callback shorthands - * or `this` binding. + * and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2495,13 +2441,17 @@ var props = keys(source), length = props.length; + if (!length) { + return constant(true); + } if (length == 1) { var key = props[0], value = source[key]; if (isStrictComparable(value)) { return function(object) { - return object != null && object[key] === value && hasOwnProperty.call(object, key); + return object != null && object[key] === value && + (typeof value != 'undefined' || (key in toObject(object))); }; } } @@ -2514,7 +2464,7 @@ strictCompareFlags[length] = isStrictComparable(value); } return function(object) { - return baseIsMatch(object, props, values, strictCompareFlags); + return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags); }; } @@ -2530,7 +2480,8 @@ function baseMatchesProperty(key, value) { if (isStrictComparable(value)) { return function(object) { - return object != null && object[key] === value; + return object != null && object[key] === value && + (typeof value != 'undefined' || (key in toObject(object))); }; } return function(object) { @@ -2610,7 +2561,7 @@ if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) { result = isArray(value) ? value - : (value ? arrayCopy(value) : []); + : ((value && value.length) ? arrayCopy(value) : []); } else if (isPlainObject(srcValue) || isArguments(srcValue)) { result = isArguments(value) @@ -2647,30 +2598,6 @@ }; } - /** - * The base implementation of `_.pullAt` without support for individual - * index arguments. - * - * @private - * @param {Array} array The array to modify. - * @param {number[]} indexes The indexes of elements to remove. - * @returns {Array} Returns the new array of removed elements. - */ - function basePullAt(array, indexes) { - var length = indexes.length, - result = baseAt(array, indexes); - - indexes.sort(baseCompareAscending); - while (length--) { - var index = parseFloat(indexes[length]); - if (index != previous && isIndex(index)) { - var previous = index; - splice.call(array, index, 1); - } - } - return result; - } - /** * The base implementation of `_.random` without support for argument juggling * and returning floating-point numbers. @@ -2686,7 +2613,7 @@ /** * The base implementation of `_.reduce` and `_.reduceRight` without support - * for callback shorthands or `this` binding, which iterates over `collection` + * for callback shorthands and `this` binding, which iterates over `collection` * using the provided `eachFunc`. * * @private @@ -2753,7 +2680,7 @@ /** * The base implementation of `_.some` without support for callback shorthands - * or `this` binding. + * and `this` binding. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2820,6 +2747,23 @@ }); } + /** + * 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. @@ -2893,6 +2837,27 @@ 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 @@ -2901,7 +2866,7 @@ * @private * @param {*} value The unwrapped value. * @param {Array} actions Actions to peform to resolve the unwrapped value. - * @returns {*} Returns the resolved unwrapped value. + * @returns {*} Returns the resolved value. */ function baseWrapperValue(value, actions) { var result = value; @@ -2928,8 +2893,7 @@ * @private * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {boolean} [retHighest] Specify returning the highest, instead - * of the lowest, index at which a value should be inserted into `array`. + * @param {boolean} [retHighest] Specify returning the highest qualified index. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ @@ -2962,8 +2926,7 @@ * @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, instead - * of the lowest, index at which a value should be inserted into `array`. + * @param {boolean} [retHighest] Specify returning the highest qualified index. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ @@ -3129,6 +3092,9 @@ * object composed from the results of running each element in the collection * through an iteratee. * + * **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`, + * and `_.partition`. + * * @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. @@ -3160,6 +3126,8 @@ * Creates a function that assigns properties of source object(s) to a given * destination object. * + * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`. + * * @private * @param {Function} assigner The function to assign values. * @returns {Function} Returns the new assigner function. @@ -3199,6 +3167,56 @@ }; } + /** + * 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 ? collection.length : 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`. @@ -3229,41 +3247,6 @@ return new SetCache(values); }; - /** - * Creates a function to compose other functions into a single function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new composer function. - */ - function createComposer(fromRight) { - return function() { - var length = arguments.length, - index = length, - fromIndex = fromRight ? (length - 1) : 0; - - if (!length) { - return function() { return arguments[0]; }; - } - var funcs = Array(length); - while (index--) { - funcs[index] = arguments[index]; - if (typeof funcs[index] != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - } - return function() { - var index = fromIndex, - result = funcs[index].apply(this, arguments); - - while ((fromRight ? index-- : ++index < length)) { - result = funcs[index].call(this, result); - } - return result; - }; - }; - } - /** * Creates a function that produces compound words out of the words in a * given string. @@ -3306,7 +3289,26 @@ } /** - * Creates a function that gets the extremum value of a collection. + * 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 = null; + } + var result = createWrapper(func, flag, null, null, null, null, null, arity); + result.placeholder = curryFunc.placeholder; + return result; + } + return curryFunc; + } + + /** + * Creates a `_.max` or `_.min` function. * * @private * @param {Function} arrayFunc The function to get the extremum value from an array. @@ -3338,6 +3340,204 @@ }; } + /** + * 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 length = arguments.length; + if (!length) { + return function() { return arguments[0]; }; + } + var wrapper, + 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); + } + var funcName = wrapper ? '' : getFuncName(func); + wrapper = funcName == 'wrapper' ? new LodashWrapper([]) : wrapper; + } + index = wrapper ? -1 : length; + while (++index < length) { + func = funcs[index]; + funcName = getFuncName(func); + + var data = funcName == 'wrapper' ? getData(func) : null; + if (data && isLaziable(data[0])) { + 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; + if (wrapper && args.length == 1 && isArray(args[0])) { + return wrapper.plant(args[0]).value(); + } + var index = 0, + result = funcs[index].apply(this, args); + + 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' && typeof 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' || typeof 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' || typeof thisArg != 'undefined') { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee); + }; + } + + /** + * 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 string && ((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, null, 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' && typeof 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. @@ -3401,7 +3601,12 @@ if (!isCurryBound) { bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); } - var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity); + 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; } @@ -3423,9 +3628,8 @@ } /** - * Creates the pad required for `string` based on the given padding length. - * The `chars` string may be truncated if the number of padding characters - * exceeds the padding length. + * 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. @@ -3433,7 +3637,7 @@ * @param {string} [chars=' '] The string used as padding. * @returns {string} Returns the pad for `string`. */ - function createPad(string, length, chars) { + function createPadding(string, length, chars) { var strLength = string.length; length = +length; @@ -3482,6 +3686,22 @@ return wrapper; } + /** + * 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 func = getCallback(iteratee); + return (func === baseCallback && iteratee == null) + ? binaryIndex(array, value, retHighest) + : binaryIndexBy(array, value, func(iteratee, thisArg, 1), retHighest); + }; + } + /** * Creates a function that either curries or invokes `func` with optional * `this` binding and partially applied arguments. @@ -3524,10 +3744,10 @@ partials = holders = null; } - var data = !isBindKey && getData(func), + var data = isBindKey ? null : getData(func), newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; - if (data && data !== true) { + if (data) { mergeData(newData, data); bitmask = newData[1]; arity = newData[9]; @@ -3556,18 +3776,18 @@ * @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} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { var index = -1, arrLength = array.length, othLength = other.length, result = true; - if (arrLength != othLength && !(isWhere && othLength > arrLength)) { + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { return false; } // Deep compare the contents, ignoring non-numeric properties. @@ -3577,23 +3797,23 @@ result = undefined; if (customizer) { - result = isWhere + result = isLoose ? customizer(othValue, arrValue, index) : customizer(arrValue, othValue, index); } if (typeof result == 'undefined') { // Recursively compare arrays (susceptible to call stack limits). - if (isWhere) { + if (isLoose) { var othIndex = othLength; while (othIndex--) { othValue = other[othIndex]; - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); if (result) { break; } } } else { - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB); + result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); } } } @@ -3649,26 +3869,26 @@ * @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} [isWhere] Specify performing partial comparisons. + * @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, isWhere, stackA, stackB) { + 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 && !isWhere) { + if (objLength != othLength && !isLoose) { return false; } - var hasCtor, + var skipCtor = isLoose, index = -1; while (++index < objLength) { var key = objProps[index], - result = hasOwnProperty.call(other, key); + result = isLoose ? key in other : hasOwnProperty.call(other, key); if (result) { var objValue = object[key], @@ -3676,21 +3896,21 @@ result = undefined; if (customizer) { - result = isWhere + result = isLoose ? customizer(othValue, objValue, key) : customizer(objValue, othValue, key); } if (typeof result == 'undefined') { // Recursively compare objects (susceptible to call stack limits). - result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isWhere, stackA, stackB); + result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB); } } if (!result) { return false; } - hasCtor || (hasCtor = key == 'constructor'); + skipCtor || (skipCtor = key == 'constructor'); } - if (!hasCtor) { + if (!skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; @@ -3708,7 +3928,7 @@ /** * 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, collection). + * The `iteratee` is invoked with three arguments: (value, index, collection). * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -3759,6 +3979,37 @@ return metaMap.get(func); }; + /** + * Gets the name of `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. + */ + var getFuncName = (function() { + if (!support.funcNames) { + return constant(''); + } + if (constant.name == 'constant') { + return baseProperty('name'); + } + return function(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 @@ -3880,31 +4131,6 @@ return result; } - /** - * Checks if `func` is eligible for `this` binding. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is eligible, else `false`. - */ - function isBindable(func) { - var support = lodash.support, - result = !(support.funcNames ? func.name : support.funcDecomp); - - if (!result) { - var source = fnToString.call(func); - if (!support.funcNames) { - result = !reFuncName.test(source); - } - if (!result) { - // Check if `func` references the `this` keyword and store the result. - result = reThis.test(source) || isNative(func); - baseSetData(func, result); - } - } - return result; - } - /** * Checks if `value` is a valid array-like index. * @@ -3946,12 +4172,22 @@ return false; } + /** + * 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); + return !!funcName && func === lodash[funcName] && funcName in LazyWrapper.prototype; + } + /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is based on ES `ToLength`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) - * for more details. + * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). * * @private * @param {*} value The value to check. @@ -3991,22 +4227,13 @@ function mergeData(data, source) { var bitmask = data[1], srcBitmask = source[1], - newBitmask = bitmask | srcBitmask; - - var arityFlags = ARY_FLAG | REARG_FLAG, - bindFlags = BIND_FLAG | BIND_KEY_FLAG, - comboFlags = arityFlags | bindFlags | CURRY_BOUND_FLAG | CURRY_RIGHT_FLAG; + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < ARY_FLAG; - var isAry = bitmask & ARY_FLAG && !(srcBitmask & ARY_FLAG), - isRearg = bitmask & REARG_FLAG && !(srcBitmask & REARG_FLAG), - argPos = (isRearg ? data : source)[7], - ary = (isAry ? data : source)[8]; - - var isCommon = !(bitmask >= REARG_FLAG && srcBitmask > bindFlags) && - !(bitmask > bindFlags && srcBitmask >= REARG_FLAG); - - var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) && - (bitmask < REARG_FLAG || ((isRearg || isAry) && argPos.length <= ary)); + 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)) { @@ -4347,10 +4574,9 @@ * Creates an array excluding all values of the provided arrays using * `SameValueZero` for equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -4363,19 +4589,11 @@ * _.difference([1, 2, 3], [4, 2]); * // => [1, 3] */ - function difference() { - var args = arguments, - index = -1, - length = args.length; - - while (++index < length) { - var value = args[index]; - if (isArray(value) || isArguments(value)) { - break; - } - } - return baseDifference(value, baseFlatten(args, false, true, ++index)); - } + var difference = restParam(function(array, values) { + return (isArray(array) || isArguments(array)) + ? baseDifference(array, baseFlatten(values, false, true)) + : []; + }); /** * Creates a slice of `array` with `n` elements dropped from the beginning. @@ -4451,7 +4669,7 @@ /** * 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). + * 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. @@ -4498,19 +4716,15 @@ * // => ['barney', 'fred', 'pebbles'] */ function dropRightWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - predicate = getCallback(predicate, thisArg, 3); - while (length-- && predicate(array[length], length, array)) {} - return baseSlice(array, 0, length + 1); + 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). + * 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. @@ -4557,14 +4771,9 @@ * // => ['barney', 'fred', 'pebbles'] */ function dropWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - var index = -1; - predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) {} - return baseSlice(array, index); + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3), true) + : []; } /** @@ -4581,6 +4790,19 @@ * @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; @@ -4596,7 +4818,7 @@ /** * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for, instead of the element itself. + * 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. @@ -4642,18 +4864,7 @@ * _.findIndex(users, 'active'); * // => 2 */ - function findIndex(array, predicate, thisArg) { - var index = -1, - length = array ? array.length : 0; - - predicate = getCallback(predicate, thisArg, 3); - while (++index < length) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; - } + var findIndex = createFindIndex(); /** * This method is like `_.findIndex` except that it iterates over elements @@ -4703,16 +4914,7 @@ * _.findLastIndex(users, 'active'); * // => 0 */ - function findLastIndex(array, predicate, thisArg) { - var length = array ? array.length : 0; - predicate = getCallback(predicate, thisArg, 3); - while (length--) { - if (predicate(array[length], length, array)) { - return length; - } - } - return -1; - } + var findLastIndex = createFindIndex(true); /** * Gets the first element of `array`. @@ -4749,18 +4951,18 @@ * @example * * _.flatten([1, [2, 3, [4]]]); - * // => [1, 2, 3, [4]]; + * // => [1, 2, 3, [4]] * * // using `isDeep` * _.flatten([1, [2, 3, [4]]], true); - * // => [1, 2, 3, 4]; + * // => [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, false, 0) : []; + return length ? baseFlatten(array, isDeep) : []; } /** @@ -4774,11 +4976,11 @@ * @example * * _.flattenDeep([1, [2, 3, [4]]]); - * // => [1, 2, 3, 4]; + * // => [1, 2, 3, 4] */ function flattenDeep(array) { var length = array ? array.length : 0; - return length ? baseFlatten(array, true, false, 0) : []; + return length ? baseFlatten(array, true) : []; } /** @@ -4787,10 +4989,9 @@ * it is used as the offset from the end of `array`. If `array` is sorted * providing `true` for `fromIndex` performs a faster binary search. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -4853,10 +5054,9 @@ * Creates an array of unique values in all provided arrays using `SameValueZero` * for equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -4984,10 +5184,10 @@ * comparisons. * * **Notes:** - * - Unlike `_.without`, this method mutates `array`. - * - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`, - * except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * - Unlike `_.without`, this method mutates `array` + * - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except + * that `NaN` matches `NaN` * * @static * @memberOf _ @@ -5050,14 +5250,28 @@ * console.log(evens); * // => [10, 20] */ - function pullAt(array) { - return basePullAt(array || [], baseFlatten(arguments, false, false, 1)); - } + var pullAt = restParam(function(array, indexes) { + array || (array = []); + indexes = baseFlatten(indexes); + + var length = indexes.length, + result = baseAt(array, indexes); + + indexes.sort(baseCompareAscending); + while (length--) { + var index = parseFloat(indexes[length]); + if (index != previous && isIndex(index)) { + var previous = index; + splice.call(array, index, 1); + } + } + 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). + * `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. @@ -5161,14 +5375,14 @@ * to compute their sort ranking. The iteratee is bound to `thisArg` and * invoked with one argument; (value). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -5202,12 +5416,7 @@ * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); * // => 1 */ - function sortedIndex(array, value, iteratee, thisArg) { - var func = getCallback(iteratee); - return (func === baseCallback && iteratee == null) - ? binaryIndex(array, value) - : binaryIndexBy(array, value, func(iteratee, thisArg, 1)); - } + var sortedIndex = createSortedIndex(); /** * This method is like `_.sortedIndex` except that it returns the highest @@ -5229,12 +5438,7 @@ * _.sortedLastIndex([4, 4, 5, 5], 5); * // => 4 */ - function sortedLastIndex(array, value, iteratee, thisArg) { - var func = getCallback(iteratee); - return (func === baseCallback && iteratee == null) - ? binaryIndex(array, value, true) - : binaryIndexBy(array, value, func(iteratee, thisArg, 1), true); - } + var sortedLastIndex = createSortedIndex(true); /** * Creates a slice of `array` with `n` elements taken from the beginning. @@ -5310,7 +5514,7 @@ /** * 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). + * 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. @@ -5357,19 +5561,15 @@ * // => [] */ function takeRightWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - predicate = getCallback(predicate, thisArg, 3); - while (length-- && predicate(array[length], length, array)) {} - return baseSlice(array, length + 1); + 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). + * `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. @@ -5416,24 +5616,18 @@ * // => [] */ function takeWhile(array, predicate, thisArg) { - var length = array ? array.length : 0; - if (!length) { - return []; - } - var index = -1; - predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) {} - return baseSlice(array, 0, index); + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3)) + : []; } /** * Creates an array of unique values, in order, of the provided arrays using * `SameValueZero` for equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -5445,9 +5639,9 @@ * _.union([1, 2], [4, 2], [2, 1]); * // => [1, 2, 4] */ - function union() { - return baseUniq(baseFlatten(arguments, false, true, 0)); - } + var union = restParam(function(arrays) { + return baseUniq(baseFlatten(arrays, false, true)); + }); /** * Creates a duplicate-value-free version of an array using `SameValueZero` @@ -5455,23 +5649,22 @@ * search algorithm for sorted arrays. If an iteratee function is provided it * is invoked for each value 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). + * with three arguments: (value, index, array). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -5553,10 +5746,9 @@ * Creates an array excluding all provided values using `SameValueZero` for * equality comparisons. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -5569,14 +5761,15 @@ * _.without([1, 2, 1, 3], 1, 2); * // => [3] */ - function without(array) { - return baseDifference(array, baseSlice(arguments, 1)); - } + var without = restParam(function(array, values) { + return (isArray(array) || isArguments(array)) + ? baseDifference(array, values) + : []; + }); /** - * Creates an array that is the symmetric difference of the provided arrays. - * See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for - * more details. + * Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * of the provided arrays. * * @static * @memberOf _ @@ -5618,20 +5811,13 @@ * _.zip(['fred', 'barney'], [30, 40], [true, false]); * // => [['fred', 30, true], ['barney', 40, false]] */ - function zip() { - var length = arguments.length, - array = Array(length); - - while (length--) { - array[length] = arguments[length]; - } - return unzip(array); - } + var zip = restParam(unzip); /** - * Creates 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. + * 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 _ @@ -5642,6 +5828,9 @@ * @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 } */ @@ -5738,13 +5927,14 @@ * @returns {*} Returns the result of `interceptor`. * @example * - * _([1, 2, 3]) - * .last() + * _(' abc ') + * .chain() + * .trim() * .thru(function(value) { * return [value]; * }) * .value(); - * // => [3] + * // => ['abc'] */ function thru(value, interceptor, thisArg) { return interceptor.call(thisArg, value); @@ -5934,32 +6124,32 @@ * _.at(['a', 'b', 'c'], [0, 2]); * // => ['a', 'c'] * - * _.at(['fred', 'barney', 'pebbles'], 0, 2); - * // => ['fred', 'pebbles'] + * _.at(['barney', 'fred', 'pebbles'], 0, 2); + * // => ['barney', 'pebbles'] */ - function at(collection) { + var at = restParam(function(collection, props) { var length = collection ? collection.length : 0; if (isLength(length)) { collection = toIterable(collection); } - return baseAt(collection, baseFlatten(arguments, false, false, 1)); - } + 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; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -5992,7 +6182,7 @@ /** * Checks if `predicate` returns truthy for **all** elements of `collection`. - * The predicate is bound to `thisArg` and invoked with three arguments; + * 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` @@ -6040,6 +6230,9 @@ */ function every(collection, predicate, thisArg) { var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = null; + } if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } @@ -6049,7 +6242,7 @@ /** * 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). + * 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. @@ -6104,7 +6297,7 @@ /** * 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). + * 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. @@ -6151,14 +6344,7 @@ * _.result(_.find(users, 'active'), 'user'); * // => 'barney' */ - function find(collection, predicate, thisArg) { - if (isArray(collection)) { - var index = findIndex(collection, predicate, thisArg); - return index > -1 ? collection[index] : undefined; - } - predicate = getCallback(predicate, thisArg, 3); - return baseFind(collection, predicate, baseEach); - } + var find = createFind(baseEach); /** * This method is like `_.find` except that it iterates over elements of @@ -6179,10 +6365,7 @@ * }); * // => 3 */ - function findLast(collection, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return baseFind(collection, predicate, baseEachRight); - } + var findLast = createFind(baseEachRight, true); /** * Performs a deep comparison between each element in `collection` and the @@ -6219,7 +6402,7 @@ /** * Iterates over elements of `collection` invoking `iteratee` for each element. - * The `iteratee` is bound to `thisArg` and invoked with three arguments; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). Iterator functions may exit iteration early * by explicitly returning `false`. * @@ -6247,11 +6430,7 @@ * }); * // => logs each value-key pair and returns the object (iteration order is not guaranteed) */ - function forEach(collection, iteratee, thisArg) { - return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEach(collection, iteratee) - : baseEach(collection, bindCallback(iteratee, thisArg, 3)); - } + var forEach = createForEach(arrayEach, baseEach); /** * This method is like `_.forEach` except that it iterates over elements of @@ -6269,30 +6448,26 @@ * * _([1, 2]).forEachRight(function(n) { * console.log(n); - * }).join(','); + * }).value(); * // => logs each value from right to left and returns the array */ - function forEachRight(collection, iteratee, thisArg) { - return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEachRight(collection, iteratee) - : baseEachRight(collection, bindCallback(iteratee, thisArg, 3)); - } + 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; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6333,10 +6508,9 @@ * comparisons. If `fromIndex` is negative, it is used as the offset from * the end of `collection`. * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. + * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * comparisons are like strict equality comparisons, e.g. `===`, except that + * `NaN` matches `NaN`. * * @static * @memberOf _ @@ -6345,6 +6519,7 @@ * @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 * @@ -6360,7 +6535,7 @@ * _.includes('pebbles', 'eb'); * // => true */ - function includes(collection, target, fromIndex) { + function includes(collection, target, fromIndex, guard) { var length = collection ? collection.length : 0; if (!isLength(length)) { collection = values(collection); @@ -6369,10 +6544,10 @@ if (!length) { return false; } - if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); - } else { + 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) @@ -6383,17 +6558,17 @@ * 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; + * iteratee function is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6451,23 +6626,32 @@ * _.invoke([123, 456], String.prototype.split, ''); * // => [['1', '2', '3'], ['4', '5', '6']] */ - function invoke(collection, methodName) { - return baseInvoke(collection, methodName, baseSlice(arguments, 2)); - } + var invoke = restParam(function(collection, methodName, args) { + var index = -1, + isFunc = typeof methodName == 'function', + length = collection ? collection.length : 0, + result = isLength(length) ? Array(length) : []; + + baseEach(collection, function(value) { + var func = isFunc ? methodName : (value != null && value[methodName]); + result[++index] = func ? func.apply(value, args) : undefined; + }); + 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). + * arguments: (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6476,9 +6660,9 @@ * * The guarded methods are: * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`, - * `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`, - * `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`, - * `trunc`, `random`, `range`, `sample`, `uniq`, and `words` + * `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, + * `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, + * `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words` * * @static * @memberOf _ @@ -6521,7 +6705,7 @@ * 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). + * 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. @@ -6612,14 +6796,14 @@ * 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; + * 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 interatees for methods like * `_.reduce`, `_.reduceRight`, and `_.transform`. * * The guarded methods are: - * `assign`, `defaults`, `merge`, and `sortAllBy` + * `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder` * * @static * @memberOf _ @@ -6643,10 +6827,7 @@ * }, {}); * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) */ - function reduce(collection, iteratee, accumulator, thisArg) { - var func = isArray(collection) ? arrayReduce : baseReduce; - return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach); - } + var reduce = createReduce(arrayReduce, baseEach); /** * This method is like `_.reduce` except that it iterates over elements of @@ -6670,10 +6851,7 @@ * }, []); * // => [4, 5, 2, 3, 0, 1] */ - function reduceRight(collection, iteratee, accumulator, thisArg) { - var func = isArray(collection) ? arrayReduceRight : baseReduce; - return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); - } + var reduceRight = createReduce(arrayReduceRight, baseEachRight); /** * The opposite of `_.filter`; this method returns the elements of `collection` @@ -6760,9 +6938,8 @@ } /** - * Creates an array of shuffled values, using a version of the Fisher-Yates - * shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle) - * for more details. + * Creates an array of shuffled values, using a version of the + * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). * * @static * @memberOf _ @@ -6820,7 +6997,7 @@ * 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). + * 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. @@ -6867,6 +7044,9 @@ */ function some(collection, predicate, thisArg) { var func = isArray(collection) ? arraySome : baseSome; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = null; + } if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } @@ -6877,17 +7057,17 @@ * 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; + * The `iteratee` is bound to `thisArg` and invoked with three arguments: * (value, index|key, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -6963,17 +7143,24 @@ * _.map(_.sortByAll(users, ['user', 'age']), _.values); * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ - function sortByAll(collection) { + function sortByAll() { + var args = arguments, + collection = args[0], + guard = args[3], + index = 0, + length = args.length - 1; + if (collection == null) { return []; } - var args = arguments, - guard = args[3]; - + var props = Array(length); + while (index < length) { + props[index] = args[++index]; + } if (guard && isIterateeCall(args[1], args[2], guard)) { - args = [collection, args[1]]; + props = args[1]; } - return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []); + return baseSortByOrder(collection, baseFlatten(props), []); } /** @@ -7192,7 +7379,7 @@ * @category Function * @param {Function} func The function to bind. * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new bound function. * @example * @@ -7211,16 +7398,14 @@ * bound('hi'); * // => 'hi fred!' */ - function bind(func, thisArg) { + var bind = restParam(function(func, thisArg, partials) { var bitmask = BIND_FLAG; - if (arguments.length > 2) { - var partials = baseSlice(arguments, 2), - holders = replaceHolders(partials, bind.placeholder); - + 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 @@ -7250,13 +7435,18 @@ * jQuery('#docs').on('click', view.onClick); * // => logs 'clicked docs' when the element is clicked */ - function bindAll(object) { - return baseBindAll(object, - arguments.length > 1 - ? baseFlatten(arguments, false, false, 1) - : functions(object) - ); - } + 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 @@ -7275,7 +7465,7 @@ * @category Function * @param {Object} object The object the method belongs to. * @param {string} key The key of the method. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new bound function. * @example * @@ -7302,16 +7492,14 @@ * bound('hi'); * // => 'hiya fred!' */ - function bindKey(object, key) { + var bindKey = restParam(function(object, key, partials) { var bitmask = BIND_FLAG | BIND_KEY_FLAG; - if (arguments.length > 2) { - var partials = baseSlice(arguments, 2), - holders = replaceHolders(partials, bindKey.placeholder); - + 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 @@ -7353,14 +7541,7 @@ * curried(1)(_, 3)(2); * // => [1, 2, 3] */ - function curry(func, arity, guard) { - if (guard && isIterateeCall(func, arity, guard)) { - arity = null; - } - var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity); - result.placeholder = curry.placeholder; - return result; - } + var curry = createCurry(CURRY_FLAG); /** * This method is like `_.curry` except that arguments are applied to `func` @@ -7399,14 +7580,7 @@ * curried(3)(1, _)(2); * // => [1, 2, 3] */ - function curryRight(func, arity, guard) { - if (guard && isIterateeCall(func, arity, guard)) { - arity = null; - } - var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity); - result.placeholder = curryRight.placeholder; - return result; - } + var curryRight = createCurry(CURRY_RIGHT_FLAG); /** * Creates a function that delays invoking `func` until after `wait` milliseconds @@ -7601,9 +7775,9 @@ * }, 'deferred'); * // logs 'deferred' after one or more milliseconds */ - function defer(func) { - return baseDelay(func, 1, arguments, 1); - } + var defer = restParam(function(func, args) { + return baseDelay(func, 1, args); + }); /** * Invokes `func` after `wait` milliseconds. Any additional arguments are @@ -7623,9 +7797,9 @@ * }, 1000, 'later'); * // => logs 'later' after one second */ - function delay(func, wait) { - return baseDelay(func, wait, arguments, 2); - } + var delay = restParam(function(func, wait, args) { + return baseDelay(func, wait, args); + }); /** * Creates a function that returns the result of invoking the provided @@ -7647,7 +7821,7 @@ * addSquare(1, 2); * // => 9 */ - var flow = createComposer(); + var flow = createFlow(); /** * This method is like `_.flow` except that it creates a function that @@ -7669,7 +7843,7 @@ * addSquare(1, 2); * // => 9 */ - var flowRight = createComposer(true); + var flowRight = createFlow(true); /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -7681,10 +7855,8 @@ * * **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 ES `Map` method interface - * of `get`, `has`, and `set`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object) - * for more details. + * constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object) + * method interface of `get`, `has`, and `set`. * * @static * @memberOf _ @@ -7775,7 +7947,7 @@ /** * 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 of the created function. + * with the `this` binding and arguments of the created function. * * @static * @memberOf _ @@ -7808,7 +7980,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to partially apply arguments to. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new partially applied function. * @example * @@ -7825,12 +7997,7 @@ * greetFred('hi'); * // => 'hi fred' */ - function partial(func) { - var partials = baseSlice(arguments, 1), - holders = replaceHolders(partials, partial.placeholder); - - return createWrapper(func, PARTIAL_FLAG, null, partials, holders); - } + var partial = createPartial(PARTIAL_FLAG); /** * This method is like `_.partial` except that partially applied arguments @@ -7846,7 +8013,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to partially apply arguments to. - * @param {...*} [args] The arguments to be partially applied. + * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new partially applied function. * @example * @@ -7863,12 +8030,7 @@ * sayHelloTo('fred'); * // => 'hello fred' */ - function partialRight(func) { - var partials = baseSlice(arguments, 1), - holders = replaceHolders(partials, partialRight.placeholder); - - return createWrapper(func, PARTIAL_RIGHT_FLAG, null, partials, holders); - } + var partialRight = createPartial(PARTIAL_RIGHT_FLAG); /** * Creates a function that invokes `func` with arguments arranged according @@ -7898,29 +8060,80 @@ * }, [1, 2, 3]); * // => [3, 6, 9] */ - function rearg(func) { - var indexes = baseFlatten(arguments, false, false, 1); - return createWrapper(func, REARG_FLAG, null, null, null, indexes); - } + var rearg = restParam(function(func, indexes) { + return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes)); + }); /** * Creates a function that invokes `func` with the `this` binding of the - * created function and the array of arguments provided to the created - * function much like [Function#apply](http://es5.github.io/#x15.3.4.3). + * 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(typeof 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 {*} Returns the new function. + * @returns {Function} Returns the new function. * @example * - * var spread = _.spread(function(who, what) { + * var say = _.spread(function(who, what) { * return who + ' says ' + what; * }); * - * spread(['Fred', 'hello']); - * // => 'Fred says hello' + * say(['fred', 'hello']); + * // => 'fred says hello' * * // with a Promise * var numbers = Promise.all([ @@ -8035,12 +8248,12 @@ * 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. + * **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. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) - * for more details. + * Maps, Sets, and WeakMaps. * * @static * @memberOf _ @@ -8098,12 +8311,12 @@ * 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. + * **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. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) - * for more details. + * Maps, Sets, and WeakMaps. * * @static * @memberOf _ @@ -8160,14 +8373,14 @@ */ function isArguments(value) { var length = isObjectLike(value) ? value.length : undefined; - return (isLength(length) && objToString.call(value) == argsTag) || false; + return isLength(length) && objToString.call(value) == argsTag; } // Fallback for environments without a `toStringTag` for `arguments` objects. if (!support.argsTag) { isArguments = function(value) { var length = isObjectLike(value) ? value.length : undefined; - return (isLength(length) && hasOwnProperty.call(value, 'callee') && - !propertyIsEnumerable.call(value, 'callee')) || false; + return isLength(length) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); }; } @@ -8188,7 +8401,7 @@ * // => false */ var isArray = nativeIsArray || function(value) { - return (isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag) || false; + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; }; /** @@ -8208,7 +8421,7 @@ * // => false */ function isBoolean(value) { - return (value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag) || false; + return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag); } /** @@ -8228,7 +8441,7 @@ * // => false */ function isDate(value) { - return (isObjectLike(value) && objToString.call(value) == dateTag) || false; + return isObjectLike(value) && objToString.call(value) == dateTag; } /** @@ -8248,13 +8461,13 @@ * // => false */ function isElement(value) { - return (value && value.nodeType === 1 && isObjectLike(value) && - (lodash.support.nodeTag ? (objToString.call(value).indexOf('Element') > -1) : isHostObject(value))) || false; + return !!value && value.nodeType === 1 && isObjectLike(value) && + (lodash.support.nodeTag ? (objToString.call(value).indexOf('Element') > -1) : isHostObject(value)); } // Fallback for environments without DOM support. if (!support.dom) { isElement = function(value) { - return (value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value)) || false; + return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); }; } @@ -8302,7 +8515,7 @@ * 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]). + * arguments: (value, other [, index|key]). * * **Note:** This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Objects are compared by @@ -8367,15 +8580,13 @@ * // => false */ function isError(value) { - return (isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag) || false; + 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 ES `Number.isFinite`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite) - * for more details. + * **Note:** This method is based on [`Number.isFinite`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite). * * @static * @memberOf _ @@ -8427,11 +8638,9 @@ }; /** - * Checks if `value` is the language type of `Object`. + * 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('')`) * - * **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details. - * * @static * @memberOf _ * @category Lang @@ -8452,7 +8661,7 @@ // 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 type == 'function' || (value && type == 'object') || false; + return type == 'function' || (!!value && type == 'object'); } /** @@ -8460,7 +8669,7 @@ * `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). + * 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 @@ -8498,13 +8707,19 @@ var props = keys(source), length = props.length; + if (!length) { + return true; + } + if (object == null) { + return false; + } customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); if (!customizer && length == 1) { var key = props[0], value = source[key]; if (isStrictComparable(value)) { - return object != null && value === object[key] && hasOwnProperty.call(object, key); + return value === object[key] && (typeof value != 'undefined' || (key in toObject(object))); } } var values = Array(length), @@ -8514,15 +8729,14 @@ value = values[length] = source[props[length]]; strictCompareFlags[length] = isStrictComparable(value); } - return baseIsMatch(object, props, values, strictCompareFlags, customizer); + return baseIsMatch(toObject(object), props, values, strictCompareFlags, customizer); } /** * Checks if `value` is `NaN`. * - * **Note:** This method is not the same as native `isNaN` which returns `true` - * for `undefined` and other non-numeric values. See the [ES5 spec](https://es5.github.io/#x15.1.2.4) - * for more details. + * **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 _ @@ -8572,8 +8786,7 @@ if (objToString.call(value) == funcTag) { return reNative.test(fnToString.call(value)); } - return (isObjectLike(value) && - (isHostObject(value) ? reNative : reHostCtor).test(value)) || false; + return isObjectLike(value) && (isHostObject(value) ? reNative : reHostCtor).test(value); } /** @@ -8619,7 +8832,7 @@ * // => false */ function isNumber(value) { - return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag) || false; + return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag); } /** @@ -8681,7 +8894,7 @@ * // => false */ function isRegExp(value) { - return (isObject(value) && objToString.call(value) == regexpTag) || false; + return isObject(value) && objToString.call(value) == regexpTag; } /** @@ -8701,7 +8914,7 @@ * // => false */ function isString(value) { - return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag) || false; + return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag); } /** @@ -8721,7 +8934,7 @@ * // => false */ function isTypedArray(value) { - return (isObjectLike(value) && isLength(value.length) && typedArrayTags[objToString.call(value)]) || false; + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; } /** @@ -8805,7 +9018,7 @@ * 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; + * The `customizer` is bound to `thisArg` and invoked with five arguments: * (objectValue, sourceValue, key, object, source). * * @static @@ -8890,18 +9103,18 @@ * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); * // => { 'user': 'barney', 'age': 36 } */ - function defaults(object) { + var defaults = restParam(function(args) { + var object = args[0]; if (object == null) { return object; } - var args = arrayCopy(arguments); args.push(assignDefaults); return assign.apply(undefined, args); - } + }); /** - * This method is like `_.findIndex` except that it returns the key of the - * first element `predicate` returns truthy for, instead of the element itself. + * 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. @@ -8947,10 +9160,7 @@ * _.findKey(users, 'active'); * // => 'barney' */ - function findKey(object, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return baseFind(object, predicate, baseForOwn, true); - } + var findKey = createFindKey(baseForOwn); /** * This method is like `_.findKey` except that it iterates over elements of @@ -9000,15 +9210,12 @@ * _.findLastKey(users, 'active'); * // => 'pebbles' */ - function findLastKey(object, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return baseFind(object, predicate, baseForOwnRight, true); - } + 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). Iterator functions may exit + * with three arguments: (value, key, object). Iterator functions may exit * iteration early by explicitly returning `false`. * * @static @@ -9032,12 +9239,7 @@ * }); * // => logs 'a', 'b', and 'c' (iteration order is not guaranteed) */ - function forIn(object, iteratee, thisArg) { - if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = bindCallback(iteratee, thisArg, 3); - } - return baseFor(object, iteratee, keysIn); - } + var forIn = createForIn(baseFor); /** * This method is like `_.forIn` except that it iterates over properties of @@ -9064,15 +9266,12 @@ * }); * // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c' */ - function forInRight(object, iteratee, thisArg) { - iteratee = bindCallback(iteratee, thisArg, 3); - return baseForRight(object, iteratee, keysIn); - } + 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). Iterator functions may exit iteration + * three arguments: (value, key, object). Iterator functions may exit iteration * early by explicitly returning `false`. * * @static @@ -9096,12 +9295,7 @@ * }); * // => logs 'a' and 'b' (iteration order is not guaranteed) */ - function forOwn(object, iteratee, thisArg) { - if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { - iteratee = bindCallback(iteratee, thisArg, 3); - } - return baseForOwn(object, iteratee); - } + var forOwn = createForOwn(baseForOwn); /** * This method is like `_.forOwn` except that it iterates over properties of @@ -9128,10 +9322,7 @@ * }); * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' */ - function forOwnRight(object, iteratee, thisArg) { - iteratee = bindCallback(iteratee, thisArg, 3); - return baseForRight(object, iteratee, keys); - } + var forOwnRight = createForOwn(baseForOwnRight); /** * Creates an array of function property names from all enumerable properties, @@ -9345,7 +9536,7 @@ /** * 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; + * 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` @@ -9400,7 +9591,7 @@ * 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). + * with five arguments: (objectValue, sourceValue, key, object, source). * * @static * @memberOf _ @@ -9449,7 +9640,7 @@ * 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` omitting the properties `predicate` returns truthy for. The - * predicate is bound to `thisArg` and invoked with three arguments; + * predicate is bound to `thisArg` and invoked with three arguments: * (value, key, object). * * @static @@ -9471,19 +9662,19 @@ * _.omit(object, _.isNumber); * // => { 'user': 'fred' } */ - function omit(object, predicate, thisArg) { + var omit = restParam(function(object, props) { if (object == null) { return {}; } - if (typeof predicate != 'function') { - var props = arrayMap(baseFlatten(arguments, false, false, 1), String); + if (typeof props[0] != 'function') { + var props = arrayMap(baseFlatten(props), String); return pickByArray(object, baseDifference(keysIn(object), props)); } - predicate = bindCallback(predicate, thisArg, 3); + 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`, @@ -9517,7 +9708,7 @@ * 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). + * bound to `thisArg` and invoked with three arguments: (value, key, object). * * @static * @memberOf _ @@ -9538,14 +9729,14 @@ * _.pick(object, _.isString); * // => { 'user': 'fred' } */ - function pick(object, predicate, thisArg) { + var pick = restParam(function(object, props) { if (object == null) { return {}; } - return typeof predicate == 'function' - ? pickByCallback(object, bindCallback(predicate, thisArg, 3)) - : pickByArray(object, baseFlatten(arguments, false, false, 1)); - } + return typeof props[0] == 'function' + ? pickByCallback(object, bindCallback(props[0], props[1], 3)) + : pickByArray(object, baseFlatten(props)); + }); /** * Resolves the value of property `key` on `object`. If the value of `key` is @@ -9590,7 +9781,7 @@ * `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). Iterator functions + * with four arguments: (accumulator, value, key, object). Iterator functions * may exit iteration early by explicitly returning `false`. * * @static @@ -9801,8 +9992,7 @@ /*------------------------------------------------------------------------*/ /** - * Converts `string` to camel case. - * See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details. + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). * * @static * @memberOf _ @@ -9844,9 +10034,8 @@ } /** - * Deburrs `string` by converting latin-1 supplementary letters to basic latin letters. - * See [Wikipedia](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * for more details. + * 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 _ @@ -9860,7 +10049,7 @@ */ function deburr(string) { string = baseToString(string); - return string && string.replace(reLatin1, deburrLetter); + return string && string.replace(reLatin1, deburrLetter).replace(reComboMarks, ''); } /** @@ -9915,9 +10104,8 @@ * [#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 to reduce - * XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping) - * 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 _ @@ -9938,8 +10126,8 @@ } /** - * Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", - * "+", "(", ")", "[", "]", "{" and "}" in `string`. + * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?", + * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`. * * @static * @memberOf _ @@ -9949,7 +10137,7 @@ * @example * * _.escapeRegExp('[lodash](https://lodash.com/)'); - * // => '\[lodash\]\(https://lodash\.com/\)' + * // => '\[lodash\]\(https:\/\/lodash\.com\/\)' */ function escapeRegExp(string) { string = baseToString(string); @@ -9959,9 +10147,7 @@ } /** - * Converts `string` to kebab case. - * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for - * more details. + * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). * * @static * @memberOf _ @@ -9984,9 +10170,8 @@ }); /** - * Pads `string` on the left and right sides if it is shorter then the given - * padding length. The `chars` string may be truncated if the number of padding - * characters can't be evenly divided by the padding length. + * Pads `string` on the left and right sides if it is shorter than `length`. + * Padding characters are truncated if they can't be evenly divided by `length`. * * @static * @memberOf _ @@ -10018,14 +10203,13 @@ leftLength = floor(mid), rightLength = ceil(mid); - chars = createPad('', rightLength, chars); + chars = createPadding('', rightLength, chars); return chars.slice(0, leftLength) + string + chars; } /** - * Pads `string` on the left side if it is shorter then the given padding - * length. The `chars` string may be truncated if the number of padding - * characters exceeds the padding length. + * Pads `string` on the left side if it is shorter than `length`. Padding + * characters are truncated if they exceed `length`. * * @static * @memberOf _ @@ -10045,15 +10229,11 @@ * _.padLeft('abc', 3); * // => 'abc' */ - function padLeft(string, length, chars) { - string = baseToString(string); - return string && (createPad(string, length, chars) + string); - } + var padLeft = createPadDir(); /** - * Pads `string` on the right side if it is shorter then the given padding - * length. The `chars` string may be truncated if the number of padding - * characters exceeds the padding length. + * Pads `string` on the right side if it is shorter than `length`. Padding + * characters are truncated if they exceed `length`. * * @static * @memberOf _ @@ -10073,18 +10253,15 @@ * _.padRight('abc', 3); * // => 'abc' */ - function padRight(string, length, chars) { - string = baseToString(string); - return string && (string + createPad(string, length, chars)); - } + 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 of `parseInt`. - * See the [ES5 spec](https://es5.github.io/#E) for more details. + * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E) + * of `parseInt`. * * @static * @memberOf _ @@ -10164,8 +10341,7 @@ } /** - * Converts `string` to snake case. - * See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details. + * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). * * @static * @memberOf _ @@ -10188,9 +10364,7 @@ }); /** - * Converts `string` to start case. - * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage) - * for more details. + * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). * * @static * @memberOf _ @@ -10249,9 +10423,9 @@ * 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 for easier debugging. - * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for more details. + * **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). @@ -10463,7 +10637,7 @@ * // => 'abc' * * _.map([' foo ', ' bar '], _.trim); - * // => ['foo', 'bar] + * // => ['foo', 'bar'] */ function trim(string, chars, guard) { var value = string; @@ -10571,7 +10745,7 @@ * 'length': 24, * 'separator': /,? +/ * }); - * //=> 'hi-diddly-ho there...' + * // => 'hi-diddly-ho there...' * * _.trunc('hi-diddly-ho there, neighborino', { * 'omission': ' [...]' @@ -10690,7 +10864,7 @@ * @static * @memberOf _ * @category Utility - * @param {*} func The function to attempt. + * @param {Function} func The function to attempt. * @returns {*} Returns the `func` result or error object. * @example * @@ -10703,20 +10877,13 @@ * elements = []; * } */ - function attempt() { - var func = arguments[0], - length = arguments.length, - args = Array(length ? (length - 1) : 0); - - while (--length > 0) { - args[length - 1] = arguments[length]; - } + var attempt = restParam(function(func, args) { try { return func.apply(undefined, args); } catch(e) { return isError(e) ? e : new Error(e); } - } + }); /** * Creates a function that invokes `func` with the `this` binding of `thisArg` @@ -10853,12 +11020,11 @@ * * var users = [ * { 'user': 'barney' }, - * { 'user': 'fred' }, - * { 'user': 'pebbles' } + * { 'user': 'fred' } * ]; * * _.find(users, _.matchesProperty('user', 'fred')); - * // => { 'user': 'fred', 'age': 40 } + * // => { 'user': 'fred' } */ function matchesProperty(key, value) { return baseMatchesProperty(key + '', baseClone(value, true)); @@ -10869,6 +11035,9 @@ * destination object. If `object` is a function then methods are added to * its prototype as well. * + * **Note:** Use `_.runInContext` to create a pristine `lodash` function + * for mixins to avoid conflicts caused by modifying the original. + * * @static * @memberOf _ * @category Utility @@ -10886,7 +11055,7 @@ * }); * } * - * // use `_.runInContext` to avoid potential conflicts (esp. in Node.js) + * // use `_.runInContext` to avoid conflicts (esp. in Node.js) * var _ = require('lodash').runInContext(); * * _.mixin({ 'vowels': vowels }); @@ -10936,12 +11105,10 @@ return function() { var chainAll = this.__chain__; if (chain || chainAll) { - var result = object(this.__wrapped__); - (result.__actions__ = arrayCopy(this.__actions__)).push({ - 'func': func, - 'args': arguments, - 'thisArg': object - }); + var result = object(this.__wrapped__), + actions = result.__actions__ = arrayCopy(this.__actions__); + + actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); result.__chain__ = chainAll; return result; } @@ -11008,7 +11175,7 @@ * var getName = _.property('user'); * * _.map(users, getName); - * // => ['fred', barney'] + * // => ['fred', 'barney'] * * _.pluck(_.sortBy(users, getName), 'user'); * // => ['barney', 'fred'] @@ -11018,7 +11185,7 @@ } /** - * The inverse of `_.property`; this method creates a function which returns + * The opposite of `_.property`; this method creates a function which returns * the property value of a given key on `object`. * * @static @@ -11196,16 +11363,16 @@ * `-Infinity` is returned. If an iteratee function is provided it is invoked * for each value in `collection` to generate the criterion by which the value * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). + * arguments: (value, index, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -11232,11 +11399,11 @@ * _.max(users, function(chr) { * return chr.age; * }); - * // => { 'user': 'fred', 'age': 40 }; + * // => { 'user': 'fred', 'age': 40 } * * // using the `_.property` callback shorthand * _.max(users, 'age'); - * // => { 'user': 'fred', 'age': 40 }; + * // => { 'user': 'fred', 'age': 40 } */ var max = createExtremum(arrayMax); @@ -11245,16 +11412,16 @@ * `Infinity` is returned. If an iteratee function is provided it is invoked * for each value in `collection` to generate the criterion by which the value * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). + * arguments: (value, index, collection). * - * If a property name is provided for `predicate` the created `_.property` + * 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 `predicate` the created `_.matches` style + * 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`. * @@ -11281,11 +11448,11 @@ * _.min(users, function(chr) { * return chr.age; * }); - * // => { 'user': 'barney', 'age': 36 }; + * // => { 'user': 'barney', 'age': 36 } * * // using the `_.property` callback shorthand * _.min(users, 'age'); - * // => { 'user': 'barney', 'age': 36 }; + * // => { 'user': 'barney', 'age': 36 } */ var min = createExtremum(arrayMin, true); @@ -11296,26 +11463,45 @@ * @memberOf _ * @category Math * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the sum. * @example * - * _.sum([4, 6, 2]); - * // => 12 + * _.sum([4, 6]); + * // => 10 + * + * _.sum({ 'a': 4, 'b': 6 }); + * // => 10 + * + * var objects = [ + * { 'n': 4 }, + * { 'n': 6 } + * ]; + * + * _.sum(objects, function(object) { + * return object.n; + * }); + * // => 10 * - * _.sum({ 'a': 4, 'b': 6, 'c': 2 }); - * // => 12 + * // using the `_.property` callback shorthand + * _.sum(objects, 'n'); + * // => 10 */ - function sum(collection) { - if (!isArray(collection)) { - collection = toIterable(collection); + function sum(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = null; } - var length = collection.length, - result = 0; + var func = getCallback(), + noIteratee = iteratee == null; - while (length--) { - result += +collection[length] || 0; + if (!(func === baseCallback && noIteratee)) { + noIteratee = false; + iteratee = func(iteratee, thisArg, 3); } - return result; + return noIteratee + ? arraySum(isArray(collection) ? collection : toIterable(collection)) + : baseSum(collection, iteratee); } /*------------------------------------------------------------------------*/ @@ -11414,6 +11600,7 @@ lodash.reject = reject; lodash.remove = remove; lodash.rest = rest; + lodash.restParam = restParam; lodash.shuffle = shuffle; lodash.slice = slice; lodash.sortBy = sortBy; @@ -11705,8 +11892,11 @@ // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { - var lodashFunc = lodash[methodName], - checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), + var lodashFunc = lodash[methodName]; + if (!lodashFunc) { + return; + } + var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { @@ -11776,6 +11966,19 @@ }; }); + // Map minified function names to their real names. + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var lodashFunc = lodash[methodName]; + if (lodashFunc) { + var key = lodashFunc.name, + names = realNames[key] || (realNames[key] = []); + + names.push({ 'name': methodName, 'func': lodashFunc }); + } + }); + + realNames[createHybridWrapper(null, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': null }]; + // Add functions to the lazy wrapper. LazyWrapper.prototype.clone = lazyClone; LazyWrapper.prototype.reverse = lazyReverse; diff --git a/package.json b/package.json index 21ab04f122..c788b2757a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "3.5.0", + "version": "3.6.0", "main": "lodash.src.js", "private": true, "devDependencies": { diff --git a/test/asset/set.js b/test/asset/set.js index d32d124edd..7b888ed2d7 100644 --- a/test/asset/set.js +++ b/test/asset/set.js @@ -9,17 +9,28 @@ /** Used as the `Set#toString` return value. */ var nativeString = String(Object.prototype.toString).replace(/toString/g, 'Set'); - /** Used as a reference to the global object. */ - var root = (objectTypes[typeof window] && window) || this; - /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ - var freeGlobal = objectTypes[typeof global] && global; - if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { - root = freeGlobal; - } + /** 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; + + /** 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; + + /** + * Used as a reference to the global object. + * + * The `this` value is used if it is 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; /*--------------------------------------------------------------------------*/ diff --git a/test/asset/weakmap.js b/test/asset/weakmap.js index 7040876e65..17ef091202 100644 --- a/test/asset/weakmap.js +++ b/test/asset/weakmap.js @@ -9,17 +9,28 @@ /** Used as the `WeakMap#toString` return value. */ var nativeString = String(Object.prototype.toString).replace(/toString/g, 'WeakMap'); - /** Used as a reference to the global object. */ - var root = (objectTypes[typeof window] && window) || this; - /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ - var freeGlobal = objectTypes[typeof global] && global; - if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { - root = freeGlobal; - } + /** 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; + + /** 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; + + /** + * Used as a reference to the global object. + * + * The `this` value is used if it is 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; /*--------------------------------------------------------------------------*/ diff --git a/test/saucelabs.js b/test/saucelabs.js index 76d8244536..a2dcb790ba 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -108,8 +108,8 @@ var platforms = [ ['Windows 8.1', 'firefox', '36'], ['Windows 8.1', 'firefox', '35'], ['Windows 8.1', 'firefox', '20'], + ['Windows 8.1', 'chrome', '41'], ['Windows 8.1', 'chrome', '40'], - ['Windows 8.1', 'chrome', '39'], ['Windows 8.1', 'internet explorer', '11'], ['Windows 8', 'internet explorer', '10'], ['Windows 7', 'internet explorer', '9'], @@ -543,9 +543,6 @@ function Job(properties) { EventEmitter.call(this); this.options = {}; - this.retries = maxJobRetries; - this.statusInterval = statusInterval; - _.merge(this, properties); _.defaults(this.options, _.cloneDeep(jobOptions)); @@ -706,7 +703,6 @@ Job.prototype.stop = function(callback) { function Tunnel(properties) { EventEmitter.call(this); - this.retries = maxTunnelRetries; _.merge(this, properties); var active = [], diff --git a/test/test.js b/test/test.js index e1e0c65091..79ee74008d 100644 --- a/test/test.js +++ b/test/test.js @@ -54,8 +54,10 @@ params = root.arguments, push = arrayProto.push, slice = arrayProto.slice, + Symbol = root.Symbol, system = root.system, - Uint8Array = root.Uint8Array; + Uint8Array = root.Uint8Array, + WeakMap = root.WeakMap; /** Math helpers. */ var add = function(x, y) { return x + y; }, @@ -233,6 +235,22 @@ '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' ]; + /** List of combining diacritical marks for spanning multiple characters. */ + var comboHalfs = [ + '\ufe20', '\ufe21', '\ufe22', '\ufe23' + ]; + + /** List of common combining diacritical marks. */ + var comboMarks = [ + '\u0300', '\u0301', '\u0302', '\u0303', '\u0304', '\u0305', '\u0306', '\u0307', '\u0308', '\u0309', '\u030a', '\u030b', '\u030c', '\u030d', '\u030e', '\u030f', + '\u0310', '\u0311', '\u0312', '\u0313', '\u0314', '\u0315', '\u0316', '\u0317', '\u0318', '\u0319', '\u031a', '\u031b', '\u031c', '\u031d', '\u031e', '\u031f', + '\u0320', '\u0321', '\u0322', '\u0323', '\u0324', '\u0325', '\u0326', '\u0327', '\u0328', '\u0329', '\u032a', '\u032b', '\u032c', '\u032d', '\u032e', '\u032f', + '\u0330', '\u0331', '\u0332', '\u0333', '\u0334', '\u0335', '\u0336', '\u0337', '\u0338', '\u0339', '\u033a', '\u033b', '\u033c', '\u033d', '\u033e', '\u033f', + '\u0340', '\u0341', '\u0342', '\u0343', '\u0344', '\u0345', '\u0346', '\u0347', '\u0348', '\u0349', '\u034a', '\u034b', '\u034c', '\u034d', '\u034e', '\u034f', + '\u0350', '\u0351', '\u0352', '\u0353', '\u0354', '\u0355', '\u0356', '\u0357', '\u0358', '\u0359', '\u035a', '\u035b', '\u035c', '\u035d', '\u035e', '\u035f', + '\u0360', '\u0361', '\u0362', '\u0363', '\u0364', '\u0365', '\u0366', '\u0367', '\u0368', '\u0369', '\u036a', '\u036b', '\u036c', '\u036d', '\u036e', '\u036f' + ]; + /** List of `burredLetters` translated to basic latin letters. */ var deburredLetters = [ 'A', 'A', 'A', 'A', 'A', 'A', 'Ae', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', @@ -1069,7 +1087,7 @@ deepEqual(capped('a'), ['a']); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var funcs = _.map([fn], _.ary), actual = funcs[0]('a', 'b', 'c'); @@ -1880,7 +1898,7 @@ deepEqual(actual, expected); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var actual = _.map([[1, 2], [3, 4]], _.chunk); deepEqual(actual, [[[1], [2]], [[3], [4]]]); }); @@ -2102,7 +2120,7 @@ } }); - test('`_.' + methodName + '` should perform a ' + (isDeep ? 'deep' : 'shallow') + ' clone when used as an iteratee for `_.map`', 3, function() { + test('`_.' + methodName + '` should perform a ' + (isDeep ? 'deep' : 'shallow') + ' clone when used as an iteratee for methods like `_.map`', 3, function() { var expected = [{ 'a': [0] }, { 'b': [1] }], actual = _.map(expected, func); @@ -2220,7 +2238,7 @@ notStrictEqual(func(_.noop), _.noop); }); - test('`_.' + methodName + '` should return an identity function when no arguments are provided', 2, function() { + test('`_.' + methodName + '` should return an identity function when no arguments are provided', 3, function() { var combined = func(); try { @@ -2228,9 +2246,37 @@ } catch(e) { ok(false, e.message); } + strictEqual(combined.length, 0); notStrictEqual(combined, _.identity); }); + test('`_.' + methodName + '` should support shortcut fusion', 3, function() { + var filterCount = 0, + mapCount = 0; + + var map = _.curry(_.rearg(_.ary(_.map, 2), 1, 0), 2), + filter = _.curry(_.rearg(_.ary(_.filter, 2), 1, 0), 2), + take = _.curry(_.rearg(_.ary(_.take, 2), 1, 0), 2); + + var partialMap = map(function(value) { mapCount++; return value * value; }), + partialFilter = filter(function(value) { filterCount++; return value % 2 == 0; }), + partialTake = take(2); + + var combined = isFlow + ? func(partialMap, partialFilter, _.compact, partialTake) + : func(partialTake, _.compact, partialFilter, partialMap); + + deepEqual(combined(_.range(100)), [4, 16]); + + if (!isNpm && WeakMap && _.support.funcNames) { + strictEqual(filterCount, 5, 'filterCount'); + strictEqual(mapCount, 5, 'mapCount'); + } + else { + skipTest(2); + } + }); + test('`_.' + methodName + '` should return a wrapped value when chaining', 1, function() { if (!isNpm) { var wrapped = _(_.noop)[methodName](); @@ -2450,7 +2496,7 @@ deepEqual(actual, expected); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [{ 'a': 1 }, { 'a': 1 }, { 'a': 1 }], expected = _.map(array, _.constant(true)), objects = _.map(array, _.create); @@ -2596,54 +2642,7 @@ } }); - test('should return the function provided when there is no `this` reference', 2, function() { - function a() {} - function b() { return this.b; } - - var object = {}; - - if (_.support.funcDecomp) { - strictEqual(_.callback(a, object), a); - notStrictEqual(_.callback(b, object), b); - } - else { - skipTest(2); - } - }); - - test('should work with bizarro `_.support.funcNames`', 6, function() { - function a() {} - - var b = function() {}; - - function c() { - return this; - } - - var object = {}, - supportBizarro = lodashBizarro ? lodashBizarro.support : {}, - funcDecomp = supportBizarro.funcDecomp, - funcNames = supportBizarro.funcNames; - - supportBizarro.funcNames = !supportBizarro.funcNames; - supportBizarro.funcDecomp = true; - - _.each([a, b, c], function(fn) { - if (lodashBizarro && _.support.funcDecomp) { - var callback = lodashBizarro.callback(fn, object); - strictEqual(callback(), fn === c ? object : undefined); - strictEqual(callback === fn, _.support.funcNames && fn === a); - } - else { - skipTest(2); - } - }); - - supportBizarro.funcDecomp = funcDecomp; - supportBizarro.funcNames = funcNames; - }); - - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var fn = function() { return this instanceof Number; }, array = [fn, fn, fn], callbacks = _.map(array, _.callback), @@ -2983,6 +2982,17 @@ } }); + test('`_.sum` should use `_.callback` internally', 1, function() { + if (!isModularize) { + _.callback = getPropB; + strictEqual(_.sum(objects), 1); + _.callback = callback; + } + else { + skipTest(); + } + }); + test('`_.takeRightWhile` should use `_.callback` internally', 1, function() { if (!isModularize) { _.callback = getPropB; @@ -3259,7 +3269,7 @@ fn = function(a, b) { return slice.call(arguments); }, isCurry = methodName == 'curry'; - test('`_.' + methodName + '` should work as an iteratee for `_.map`', 2, function() { + test('`_.' + methodName + '` should work as an iteratee for methods like `_.map`', 2, function() { var array = [fn, fn, fn], object = { 'a': fn, 'b': fn, 'c': fn }; @@ -3539,6 +3549,17 @@ deepEqual(actual, operators); }); + + test('should deburr combining diacritical marks', 1, function() { + var values = comboMarks.concat(comboHalfs), + expected = _.map(values, _.constant('ei')); + + var actual = _.map(values, function(chr) { + return _.deburr('e' + chr + 'i'); + }); + + deepEqual(actual, expected); + }); }()); /*--------------------------------------------------------------------------*/ @@ -3740,11 +3761,12 @@ deepEqual(_.difference([1, NaN, 3], largeArray), [1, 3]); }); - test('should ignore values that are not arrays or `arguments` objects', 3, function() { - var array = [0, 1, null, 3]; - deepEqual(_.difference(array, 3, null, { '0': 1 }), array); - deepEqual(_.difference(null, array, null, [2, 1]), [0, null, 3]); - deepEqual(_.difference(array, null, args, null), [0, null]); + test('should ignore values that are not arrays or `arguments` objects', 4, function() { + var array = [1, null, 3]; + deepEqual(_.difference(args, 3, { '0': 1 }), [1, 2, 3]); + deepEqual(_.difference(null, array, 1), []); + deepEqual(_.difference(array, args, null), [null]); + deepEqual(_.difference('abc', array, 'b'), []); }); }(1, 2, 3)); @@ -3783,7 +3805,7 @@ }); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.drop); @@ -3853,7 +3875,7 @@ }); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.dropRight); @@ -4200,19 +4222,30 @@ QUnit.module('lodash.escapeRegExp'); (function() { - var escaped = '\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\/\\\\', - unescaped = '.*+?^${}()|[\]\/\\'; + test('should escape values', 1, function() { + var escaped = '\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\/\\\\', + unescaped = '.*+?^${}()|[\]\/\\'; - escaped += escaped; - unescaped += unescaped; + escaped += escaped; + unescaped += unescaped; - test('should escape values', 1, function() { strictEqual(_.escapeRegExp(unescaped), escaped); }); test('should handle strings with nothing to escape', 1, function() { strictEqual(_.escapeRegExp('abc'), 'abc'); }); + + test('should work with `eval` and `Function`', 2, function() { + var string = '[lodash](https://lodash.com/)', + escaped = _.escapeRegExp(string), + regexp = eval('(/' + escaped + '/)'); + + ok(regexp.test(string)); + + regexp = Function('return /' + escaped + '/')(); + ok(regexp.test(string)); + }); }()); /*--------------------------------------------------------------------------*/ @@ -4276,6 +4309,11 @@ deepEqual(actual, expected); }); + test('should work as an iteratee for methods like `_.map`', 1, function() { + var actual = _.map([[1]], _.every); + deepEqual(actual, [true]); + }); + test('should be aliased', 1, function() { strictEqual(_.all, _.every); }); @@ -4419,7 +4457,7 @@ deepEqual(actual, [['a', 2, 3], ['a', 2, 3], ['a', 2, 3], [1, 'a', 'a'], ['a', 2, 3], [1, 2, 3]]); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2], [3, 4]], actual = _.map(array, _.fill); @@ -4639,10 +4677,11 @@ test('should return `undefined` when querying empty arrays', 1, function() { var array = []; array['-1'] = 1; + strictEqual(_.first(array), undefined); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.first); @@ -4722,7 +4761,7 @@ }); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.take); @@ -4792,7 +4831,7 @@ }); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.takeRight); @@ -5086,7 +5125,7 @@ deepEqual(_.flattenDeep(array), expected); }); - test('should work as an iteratee for `_.map`', 2, function() { + test('should work as an iteratee for methods like `_.map`', 2, function() { var array = [[[['a']]], [[['b']]]]; deepEqual(_.map(array, _.flatten), [[['a']], [['b']]]); @@ -5756,7 +5795,7 @@ deepEqual(actual, expected); }); - test('`_.' + methodName + '` should work as an iteratee for `_.reduce`', 1, function() { + test('`_.' + methodName + '` should work as an iteratee for methods like `_.reduce`', 1, function() { var array = [{ 'a': 1 }, { 'b': 2 }, { 'c': 3 }], expected = { 'a': 1, 'b': 2, 'c': 3 }; @@ -6203,6 +6242,13 @@ strictEqual(_.includes([-0], 0), true); }); + test('should work as an iteratee for methods like `_.reduce`', 1, function() { + var array1 = [1, 2, 3], + array2 = [2, 3, 1]; + + ok(_.every(array1, _.partial(_.includes, array2))); + }); + test('should be aliased', 2, function() { strictEqual(_.contains, _.includes); strictEqual(_.include, _.includes); @@ -6454,7 +6500,7 @@ deepEqual(_.initial([]), []); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.initial); @@ -6628,7 +6674,7 @@ ok(_.isEqual(_.invert(object, true), { 'hasOwnProperty': ['a'], 'constructor': ['b'] })); }); - test('should work as an iteratee for `_.map`', 2, function() { + test('should work as an iteratee for methods like `_.map`', 2, function() { var regular = { 'a': 1, 'b': 2, 'c': 1 }, inverted = { '1': 'c', '2': 'b' }; @@ -8336,7 +8382,8 @@ }); test('should return `false` for non-objects', 1, function() { - var values = falsey.concat(true, 1, 'a'), + var symbol = (Symbol || noop)(), + values = falsey.concat(true, 1, 'a', symbol), expected = _.map(values, _.constant(false)); var actual = _.map(values, function(value, index) { @@ -8921,10 +8968,11 @@ test('should return `undefined` when querying empty arrays', 1, function() { var array = []; array['-1'] = 1; + strictEqual(_.last([]), undefined); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.last); @@ -9040,7 +9088,8 @@ QUnit.module('indexOf methods'); _.each(['indexOf', 'lastIndexOf'], function(methodName) { - var func = _[methodName]; + var func = _[methodName], + isIndexOf = methodName == 'indexOf'; test('`_.' + methodName + '` should accept a falsey `array` argument', 1, function() { var expected = _.map(falsey, _.constant(-1)); @@ -9073,9 +9122,12 @@ strictEqual(func(array, 0, true), -1); }); - test('`_.' + methodName + '` should match `NaN`', 2, function() { - strictEqual(func([1, NaN, 3], NaN), 1); - strictEqual(func([1, 3, NaN], NaN, true), 2); + test('`_.' + methodName + '` should match `NaN`', 4, function() { + var array = [1, NaN, 3, NaN, 5, NaN]; + strictEqual(func(array, NaN), isIndexOf ? 1 : 5); + strictEqual(func(array, NaN, 2), isIndexOf ? 3 : 1); + strictEqual(func(array, NaN, -2), isIndexOf ? 5 : 3); + strictEqual(func([1, 2, NaN, NaN], NaN, true), isIndexOf ? 2 : 3); }); test('`_.' + methodName + '` should match `-0` as `0`', 1, function() { @@ -9453,12 +9505,41 @@ deepEqual(actual, expected); matches = _.matches({ 'a': { 'c': undefined } }); - objects = [{ 'a': { 'b': 1 } }, { 'a':{ 'b':1, 'c': 1 } }, { 'a': { 'b': 1, 'c': undefined } }]; + objects = [{ 'a': { 'b': 1 } }, { 'a': { 'b':1, 'c': 1 } }, { 'a': { 'b': 1, 'c': undefined } }]; actual = _.map(objects, matches); deepEqual(actual, expected); }); + test('should match inherited `value` properties', 1, function() { + function Foo() { this.a = 1; } + Foo.prototype.b = 2; + + var object = { 'a': new Foo }, + matches = _.matches({ 'a': { 'b': 2 } }); + + strictEqual(matches(object), true); + }); + + test('should match properties when `value` is a function', 1, function() { + function Foo() {} + Foo.a = function() {}; + Foo.a.b = 1; + Foo.a.c = 2; + + var matches = _.matches({ 'a': { 'b': 1 } }); + strictEqual(matches(Foo), true); + }); + + test('should match properties when `value` is not a plain object', 1, function() { + function Foo(object) { _.assign(this, object); } + + var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }), + matches = _.matches({ 'a': { 'b': 1 } }); + + strictEqual(matches(object), true); + }); + test('should not match by inherited `source` properties', 1, function() { function Foo() { this.a = 1; } Foo.prototype.b = 2; @@ -9609,7 +9690,7 @@ objects = [{ 'a': 1 }, { 'a': 1, 'b': 1 }, { 'a': 1, 'b': undefined }], actual = _.map(objects, matches); - deepEqual(actual, [true, false, true]); + deepEqual(actual, [false, false, true]); matches = _.matchesProperty('a', { 'b': undefined }); objects = [{ 'a': { 'a': 1 } }, { 'a': { 'a': 1, 'b': 1 } }, { 'a': { 'a': 1, 'b': undefined } }]; @@ -9618,7 +9699,36 @@ deepEqual(actual, [false, false, true]); }); - test('should not match by inherited `value` properties', 1, function() { + test('should match inherited `value` properties', 1, function() { + function Foo() { this.a = 1; } + Foo.prototype.b = 2; + + var object = { 'a': new Foo }, + matches = _.matchesProperty('a', { 'b': 2 }); + + strictEqual(matches(object), true); + }); + + test('should match properties when `value` is a function', 1, function() { + function Foo() {} + Foo.a = function() {}; + Foo.a.b = 1; + Foo.a.c = 2; + + var matches = _.matchesProperty('a', { 'b': 1 }); + strictEqual(matches(Foo), true); + }); + + test('should match properties when `value` is not a plain object', 1, function() { + function Foo(object) { _.assign(this, object); } + + var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }), + matches = _.matchesProperty('a', { 'b': 1 }); + + strictEqual(matches(object), true); + }); + + test('should not match inherited `source` properties', 1, function() { function Foo() { this.a = 1; } Foo.prototype.b = 2; @@ -9982,8 +10092,10 @@ }); test('should work with four arguments', 1, function() { - var expected = { 'a': 4 }; - deepEqual(_.merge({ 'a': 1 }, { 'a': 2 }, { 'a': 3 }, expected), expected); + var expected = { 'a': 4 }, + actual = _.merge({ 'a': 1 }, { 'a': 2 }, { 'a': 3 }, expected); + + deepEqual(actual, expected); }); test('should assign `null` values', 1, function() { @@ -9996,7 +10108,7 @@ deepEqual(actual, { 'a': 1 }); }); - test('should not not error on DOM elements', 1, function() { + test('should not error on DOM elements', 1, function() { var object1 = { 'el': document && document.createElement('div') }, object2 = { 'el': document && document.createElement('div') }, pairs = [[{}, object1], [object1, object2]], @@ -10025,6 +10137,16 @@ deepEqual(actual, expected); }); + test('should convert values to an array when merging with arrays of `source`', 2, function() { + var object = { 'a': { '1': 'y', 'b': 'z', 'length': 2 } }, + actual = _.merge(object, { 'a': ['x'] }); + + deepEqual(actual, { 'a': ['x', 'y'] }); + + actual = _.merge({ 'a': {} }, { 'a': [] }); + deepEqual(actual, { 'a': [] }); + }); + test('should work with a function `object` value', 2, function() { function Foo() {} @@ -10206,7 +10328,7 @@ strictEqual(func(array), isMax ? 499999 : 0); }); - test('`_.' + methodName + '` should work as an iteratee for `_.map`', 3, function() { + test('`_.' + methodName + '` should work as an iteratee for methods like `_.map`', 3, function() { var arrays = [[2, 1], [5, 4], [7, 8]], objects = [{ 'a': 2, 'b': 1 }, { 'a': 5, 'b': 4 }, { 'a': 7, 'b': 8 }], expected = isMax ? [2, 5, 8] : [1, 4, 7]; @@ -10857,7 +10979,7 @@ strictEqual(_.parseInt('0x20', object), 32); }); - test('should work as an iteratee for `_.map`', 2, function() { + test('should work as an iteratee for methods like `_.map`', 2, function() { var strings = _.map(['6', '08', '10'], Object), actual = _.map(strings, _.parseInt); @@ -11707,7 +11829,7 @@ ok(actual % 1 && actual >= 2 && actual <= 4); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [1, 2, 3], expected = _.map(array, _.constant(true)), randoms = _.map(array, _.random); @@ -11766,7 +11888,7 @@ deepEqual(actual, [[0], [0], [0], [], []]); }); - test('should work as an iteratee for `_.map`', 2, function() { + test('should work as an iteratee for methods like `_.map`', 2, function() { var array = [1, 2, 3], object = { 'a': 1, 'b': 2, 'c': 3 }, expected = [[0], [0, 1], [0, 1, 2]]; @@ -12394,7 +12516,7 @@ deepEqual(_.rest([]), []); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], actual = _.map(array, _.rest); @@ -12460,6 +12582,60 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.restParam'); + + (function() { + function fn(a, b, c) { + return slice.call(arguments); + } + + test('should apply a rest parameter to `func`', 1, function() { + var rp = _.restParam(fn); + deepEqual(rp(1, 2, 3, 4), [1, 2, [3, 4]]); + }); + + test('should work with `start`', 1, function() { + var rp = _.restParam(fn, 1); + deepEqual(rp(1, 2, 3, 4), [1, [2, 3, 4]]); + }); + + test('should treat `start` as `0` for negative or `NaN` values', 1, function() { + var values = [-1, NaN, 'x'], + expected = _.map(values, _.constant([[1, 2, 3, 4]])); + + var actual = _.map(values, function(value) { + var rp = _.restParam(fn, value); + return rp(1, 2, 3, 4); + }); + + deepEqual(actual, expected); + }); + + test('should use an empty array when `start` is not reached', 1, function() { + var rp = _.restParam(fn); + deepEqual(rp(1), [1, undefined, []]); + }); + + test('should work on functions with more than 3 params', 1, function() { + var rp = _.restParam(function(a, b, c, d) { + return slice.call(arguments); + }); + + deepEqual(rp(1, 2, 3, 4, 5), [1, 2, 3, [4, 5]]); + }); + + test('should not set a `this` binding', 1, function() { + var rp = _.restParam(function(x, y) { + return this[x] + this[y[0]]; + }); + + var object = { 'rp': rp, 'x': 4, 'y': 2 }; + strictEqual(object.rp('x', 'y'), 6); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.runInContext'); (function() { @@ -12572,7 +12748,7 @@ ok(actual.length == 2 && actual[0] !== actual[1] && _.includes(array, actual[0]) && _.includes(array, actual[1])); }); - test('should work as an iteratee for `_.map`', 2, function() { + test('should work as an iteratee for methods like `_.map`', 2, function() { var array1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], array2 = ['abc', 'def', 'ghi']; @@ -12847,7 +13023,7 @@ deepEqual(actual, [[1], [1], [1], [2, 3], [1], []]); }); - test('should work as an iteratee for `_.map`', 2, function() { + test('should work as an iteratee for methods like `_.map`', 2, function() { var array = [[1], [2, 3]], actual = _.map(array, _.slice); @@ -12954,6 +13130,11 @@ deepEqual(actual, expected); }); + test('should work as an iteratee for methods like `_.map`', 1, function() { + var actual = _.map([[1]], _.some); + deepEqual(actual, [true]); + }); + test('should be aliased', 1, function() { strictEqual(_.any, _.some); }); @@ -13068,7 +13249,7 @@ deepEqual(actual, [objects[0], objects[2], objects[1], objects[3]]); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var actual = _.map([[2, 1, 3], [3, 2, 1]], _.sortBy); deepEqual(actual, [[1, 2, 3], [1, 2, 3]]); }); @@ -13148,7 +13329,7 @@ deepEqual(actual, [objects[2], objects[0], objects[3], objects[1], undefined]); }); - test('`_.' + methodName + '` should work as an iteratee for `_.reduce`', 1, function() { + test('`_.' + methodName + '` should work as an iteratee for methods like `_.reduce`', 1, function() { var objects = [ { 'a': 'x', '0': 3 }, { 'a': 'y', '0': 4 }, @@ -13178,8 +13359,7 @@ objects = [{ 'x': 30 }, { 'x': 50 }]; test('`_.' + methodName + '` should return the correct insert index', 1, function() { - var array = [30, 50], - values = [30, 40, 50], + var values = [30, 40, 50], expected = isSortedIndex ? [0, 1, 1] : [1, 1, 2]; var actual = _.map(values, function(value) { @@ -13393,8 +13573,12 @@ QUnit.module('lodash.sum'); (function() { + var array = [6, 4, 2], + object = { 'a': 2, 'b': 3, 'c': 1 }, + objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }]; + test('should return the sum of an array of numbers', 1, function() { - strictEqual(_.sum([6, 4, 2]), 12); + strictEqual(_.sum(array), 12); }); test('should return `0` when passing empty `array` values', 1, function() { @@ -13412,7 +13596,7 @@ }); test('should iterate an object', 1, function() { - strictEqual(_.sum({ 'a': 1, 'b': 2, 'c': 3 }), 6); + strictEqual(_.sum(object), 6); }); test('should iterate a string', 2, function() { @@ -13420,6 +13604,50 @@ strictEqual(_.sum(value), 6); }); }); + + test('should work with an `iteratee` argument', 1, function() { + var actual = _.sum(objects, function(object) { + return object.a; + }); + + deepEqual(actual, 6); + }); + + test('should provide the correct `iteratee` arguments', 2, function() { + var args; + + _.sum(array, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, [6, 0, array]); + + args = null; + _.sum(object, function() { + args || (args = slice.call(arguments)); + }); + + deepEqual(args, [2, 'a', object]); + }); + + test('should support the `thisArg` argument', 1, function() { + var actual = _.sum([6.8, 4.5, 2.6], function(num) { + return this.floor(num); + }, Math); + + strictEqual(actual, 12); + }); + + test('should work with a "_.property" style `iteratee`', 2, function() { + var arrays = [[2], [3], [1]]; + strictEqual(_.sum(arrays, 0), 6); + strictEqual(_.sum(objects, 'a'), 6); + }); + + test('should perform basic sum when used as an iteratee for methods like `_.map`', 1, function() { + var actual = _.map([array, object], _.sum); + deepEqual(actual, [12, 6]); + }); }()); /*--------------------------------------------------------------------------*/ @@ -13915,7 +14143,7 @@ deepEqual(actual, expected); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var array = ['<%= a %>', '<%- b %>', '<% print(c) %>'], compiles = _.map(array, _.template), data = { 'a': 'one', 'b': '`two`', 'c': 'three' }; @@ -13981,7 +14209,7 @@ strictEqual(_.trunc({ 'toString': _.constant(string) }, 5), 'hi...'); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var actual = _.map([string, string, string], _.trunc), truncated = 'hi-diddly-ho there, neighbo...'; @@ -14816,7 +15044,7 @@ strictEqual(func(string, ''), string); }); - test('`_.' + methodName + '` should work as an iteratee for `_.map`', 1, function() { + test('`_.' + methodName + '` should work as an iteratee for methods like `_.map`', 1, function() { var string = Object(whitespace + 'a b c' + whitespace), trimmed = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''), actual = _.map([string, string, string], func); @@ -14986,7 +15214,7 @@ deepEqual(actual, arrays.slice(0, 3)); }); - test('should perform an unsorted uniq when used as an iteratee for `_.map`', 1, function() { + test('should perform an unsorted uniq when used as an iteratee for methods like `_.map`', 1, function() { var array = [[2, 1, 2], [1, 2, 1]], actual = _.map(array, _.uniq); @@ -14994,29 +15222,67 @@ }); test('should work with large arrays', 1, function() { - var object = {}; + var largeArray = [], + expected = [0, 'a', {}], + count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); - var largeArray = _.times(LARGE_ARRAY_SIZE, function(index) { - switch (index % 3) { - case 0: return 0; - case 1: return 'a'; - case 2: return object; - } + _.times(count, function() { + push.apply(largeArray, expected); }); - deepEqual(_.uniq(largeArray), [0, 'a', object]); + deepEqual(_.uniq(largeArray), expected); }); test('should work with large arrays of boolean, `NaN`, `null`, and `undefined` values', 1, function() { - var array = [], + var largeArray = [], expected = [true, false, NaN, null, undefined], count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); _.times(count, function() { - push.apply(array, expected); + push.apply(largeArray, expected); }); - deepEqual(_.uniq(array), expected); + deepEqual(_.uniq(largeArray), expected); + }); + + test('should work with large arrays of symbols', 1, function() { + if (Symbol) { + var largeArray = _.times(LARGE_ARRAY_SIZE, function() { + return Symbol(); + }); + + deepEqual(_.uniq(largeArray), largeArray); + } + else { + skipTest(); + } + }); + + test('should work with large arrays of well-known symbols', 1, function() { + if (Symbol) { + // See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-well-known-symbols. + var expected = [ + Symbol.hasInstance, Symbol.isConcatSpreadable, Symbol.iterator, + Symbol.match, Symbol.replace, Symbol.search, Symbol.species, + Symbol.split, Symbol.toPrimitive, Symbol.toStringTag, Symbol.unscopables + ]; + + var largeArray = [], + count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); + + expected = _.map(expected, function(symbol) { + return symbol || {}; + }); + + _.times(count, function() { + push.apply(largeArray, expected); + }); + + deepEqual(_.uniq(largeArray), expected); + } + else { + skipTest(); + } }); test('should distinguish between numbers and numeric strings', 1, function() { @@ -15163,7 +15429,11 @@ var array = [1, 2, 3, 1, 2, 3]; deepEqual(_.without(array, 1, 2), [3, 3]); }); - }()); + + test('should treat string values for `array` as empty', 1, function() { + deepEqual(_.without('abc', 'b'), []); + }); + }(1, 2, 3)); /*--------------------------------------------------------------------------*/ @@ -15190,7 +15460,7 @@ deepEqual(actual, expected); }); - test('should work as an iteratee for `_.map`', 1, function() { + test('should work as an iteratee for methods like `_.map`', 1, function() { var strings = _.map(['a', 'b', 'c'], Object), actual = _.map(strings, _.words); @@ -16124,7 +16394,7 @@ return '`_.' + methodName + '` should accept falsey primary arguments'; } - deepEqual(_.difference(null, array), array, message('difference')); + deepEqual(_.difference(null, array), [], message('difference')); deepEqual(_.intersection(null, array), array, message('intersection')); deepEqual(_.union(null, array), array, message('union')); deepEqual(_.xor(null, array), array, message('xor')); @@ -16200,6 +16470,7 @@ 'partial', 'partialRight', 'rearg', + 'restParam', 'spread', 'throttle' ]; @@ -16320,7 +16591,7 @@ }); }); - test('should throw an error for falsey arguments', 23, function() { + test('should throw an error for falsey arguments', 24, function() { _.each(rejectFalsey, function(methodName) { var expected = _.map(falsey, _.constant(true)), func = _[methodName];