diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f95d4900ce..b3427fd5cb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -11,9 +11,10 @@ may have already been discussed or fixed in `master`. To contribute, Feature requests should be submitted in the [issue tracker](https://github.com/lodash/lodash/issues), with a description of -the expected behavior & use case, where they’ll remain closed until sufficient -interest, e.g. :+1:’s, has been shown by the community. Before submitting a request, -please search for similar ones in the +the expected behavior & use case, where they’ll remain closed until sufficient interest, +[e.g. :+1: reactions](https://help.github.com/articles/about-discussions-in-issues-and-pull-requests/), +has been shown by the community. Before submitting a request, please search for +similar ones in the [closed issues](https://github.com/lodash/lodash/issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement). ## Pull Requests @@ -30,9 +31,9 @@ Run unit tests from the command-line via `npm test`, or open `test/index.html` & ## Contributor License Agreement -Lodash is a member of the [Dojo Foundation](http://dojofoundation.org/). -As such, we request that all contributors sign the Dojo Foundation -[contributor license agreement (CLA)](http://dojofoundation.org/about/claForm). +Lodash is a member of the [jQuery Foundation](https://jquery.org/). +As such, we request that all contributors sign the jQuery Foundation +[contributor license agreement (CLA)](https://contribute.jquery.org/CLA/). For more information about CLAs, please check out Alex Russell’s excellent post, [“Why Do I Need to Sign This?”](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/). @@ -61,7 +62,17 @@ established in the code. functions. Guidelines are enforced using [JSCS](https://www.npmjs.com/package/jscs): - ```bash $ npm run style ``` + +## Tips + +You can opt-in to a pre-push git hook by adding an `.opt-in` file to the root of +the project containing: +```txt +pre-push +``` + +With that, when you `git push`, the pre-push git hook will trigger and execute +`npm run validate`. diff --git a/.gitignore b/.gitignore index 2308a958af..6eb2db8763 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ lodash.compat.min.js coverage node_modules +.opt-in +.opt-out diff --git a/.travis.yml b/.travis.yml index 48bc1319f3..368c004d45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_install: PATTERN[1]="|\s*if\s*\(enumerate\b[\s\S]+?\};\s*\}|" PATTERN[2]="|\s*while\s*\([^)]+\)\s*\{\s*iteratee\(index\);\s*\}|" PATTERN[3]="|\s*else\s*\{\s*assocSet\(data\b[\s\S]+?\}|" - PATTERN[4]="|\s*if\s*\(ctorString\b[\s\S]+?\}\s*\}|" + PATTERN[4]="|\bcase\s+(?:set|map|weakMap)CtorString:.+|g" PATTERN[5]="|\bindex,\s*iterable\)\s*===\s*false\)[^}]+?(break;)|" PATTERN[6]="|\s*if\s*\(\!lodashFunc\)\s*\{\s*return;\s*\}|" PATTERN[7]="|\s*define\([\s\S]+?\);|" diff --git a/LICENSE b/LICENSE index bcbe13d67a..e0c69d5603 100644 --- a/LICENSE +++ b/LICENSE @@ -1,23 +1,47 @@ -The MIT License (MIT) +Copyright jQuery Foundation and other contributors -Copyright 2012-2016 The Dojo Foundation -Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas, +Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/lodash/lodash + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==== + +Copyright and related rights for sample code are waived via CC0. Sample +code is defined as all source code displayed within the prose of the +documentation. + +CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +==== + +Files located in the node_modules and vendor directories are externally +maintained libraries used by this software which have their own +licenses; we recommend you read them, as their terms may differ from the +terms above. diff --git a/README.md b/README.md index 1581d0a216..61b4ed5f5c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash v4.6.1 +# lodash v4.7.0 The [lodash](https://lodash.com/) library exported as a [UMD](https://github.com/umdjs/umd) module. @@ -20,11 +20,11 @@ $ lodash core -o ./dist/lodash.core.js ## Download -Lodash is released under the [MIT license](https://raw.githubusercontent.com/lodash/lodash/4.6.1/LICENSE) & supports [modern environments](#support).
+Lodash is released under the [MIT license](https://raw.githubusercontent.com/lodash/lodash/4.7.0/LICENSE) & supports [modern environments](#support).
Review the [build differences](https://github.com/lodash/lodash/wiki/build-differences) & pick one that’s right for you. - * [Core build](https://raw.githubusercontent.com/lodash/lodash/4.6.1/dist/lodash.core.js) ([~4 kB gzipped](https://raw.githubusercontent.com/lodash/lodash/4.6.1/dist/lodash.core.min.js)) - * [Full build](https://raw.githubusercontent.com/lodash/lodash/4.6.1/dist/lodash.js) ([~21 kB gzipped](https://raw.githubusercontent.com/lodash/lodash/4.6.1/dist/lodash.min.js)) + * [Core build](https://raw.githubusercontent.com/lodash/lodash/4.7.0/dist/lodash.core.js) ([~4 kB gzipped](https://raw.githubusercontent.com/lodash/lodash/4.7.0/dist/lodash.core.min.js)) + * [Full build](https://raw.githubusercontent.com/lodash/lodash/4.7.0/dist/lodash.js) ([~22 kB gzipped](https://raw.githubusercontent.com/lodash/lodash/4.7.0/dist/lodash.min.js)) * [CDN copies](https://www.jsdelivr.com/projects/lodash) ## Why Lodash? @@ -43,10 +43,10 @@ Lodash is available in a [variety of builds](https://lodash.com/custom-builds) & * [lodash](https://www.npmjs.com/package/lodash) & [per method packages](https://www.npmjs.com/browse/keyword/lodash-modularized) * [lodash-amd](https://www.npmjs.com/package/lodash-amd) * [lodash-es](https://www.npmjs.com/package/lodash-es) & [babel-plugin-lodash](https://www.npmjs.com/package/babel-plugin-lodash) - * [lodash/fp](https://github.com/lodash/lodash/tree/4.6.1-npm/fp) + * [lodash/fp](https://github.com/lodash/lodash/tree/4.7.0-npm/fp) ## Further Reading - * [Contributing](https://github.com/lodash/lodash/blob/4.6.1/.github/CONTRIBUTING.md) + * [Contributing](https://github.com/lodash/lodash/blob/4.7.0/.github/CONTRIBUTING.md) * [Release Notes](https://github.com/lodash/lodash/releases/tag/4.0.0) * [Wiki (Changelog, Roadmap, etc.)](https://github.com/lodash/lodash/wiki) diff --git a/dist/lodash.core.js b/dist/lodash.core.js index d8ba4fd60d..91cb9cb863 100644 --- a/dist/lodash.core.js +++ b/dist/lodash.core.js @@ -1,11 +1,11 @@ /** * @license - * lodash 4.6.1 (Custom Build) + * lodash 4.7.0 (Custom Build) * Build: `lodash core -o ./dist/lodash.core.js` - * Copyright 2012-2016 The Dojo Foundation + * Copyright jQuery Foundation and other contributors + * Released under MIT license * Based on Underscore.js 1.8.3 - * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ ;(function() { @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.6.1'; + var VERSION = '4.7.0'; /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; @@ -126,13 +126,7 @@ * @returns {Array} Returns `array`. */ function arrayPush(array, values) { - var index = -1, - length = values.length, - offset = array.length; - - while (++index < length) { - array[offset + index] = values[index]; - } + array.push.apply(array, values); return array; } @@ -174,7 +168,8 @@ * @param {Array|Object} collection The collection to search. * @param {Function} predicate The function invoked per iteration. * @param {Function} eachFunc The function to iterate over `collection`. - * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself. + * @param {boolean} [retKey] Specify returning the key of the found element + * instead of the element itself. * @returns {*} Returns the found element or its key, else `undefined`. */ function baseFind(collection, predicate, eachFunc, retKey) { @@ -196,7 +191,8 @@ * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ @@ -382,29 +378,32 @@ nativeKeys = Object.keys, nativeMax = Math.max; + /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */ + var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf'); + /*------------------------------------------------------------------------*/ /** * Creates a `lodash` object which wraps `value` to enable implicit method - * chaining. Methods that operate on and return arrays, collections, and - * functions can be chained together. Methods that retrieve a single value or - * may return a primitive value will automatically end the chain sequence and - * return the unwrapped value. Otherwise, the value must be unwrapped with - * `_#value`. + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. * - * Explicit chaining, which must be unwrapped with `_#value` in all cases, - * may be enabled using `_.chain`. + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. * * The execution of chained methods is lazy, that is, it's deferred until * `_#value` is implicitly or explicitly called. * - * Lazy evaluation allows several methods to support shortcut fusion. Shortcut - * fusion is an optimization to merge iteratee calls; this avoids the creation - * of intermediate arrays and can greatly reduce the number of iteratee executions. - * Sections of a chain sequence qualify for shortcut fusion if the section is - * applied to an array of at least two hundred elements and any iteratees - * accept only one argument. The heuristic for whether a section qualifies - * for shortcut fusion is subject to change. + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array of at least two hundred + * elements and any iteratees accept only one argument. The heuristic for + * whether a section qualifies for shortcut fusion is subject to change. * * Chaining is supported in custom builds as long as the `_#value` method is * directly or indirectly included in the build. @@ -429,48 +428,49 @@ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, - * `flatten`, `flattenDeep`, `flattenDepth`, `flip`, `flow`, `flowRight`, - * `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, `intersection`, - * `intersectionBy`, `intersectionWith`, `invert`, `invertBy`, `invokeMap`, - * `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, - * `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, - * `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, - * `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`, - * `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, - * `pullAll`, `pullAllBy`, `pullAllWith`, `pullAt`, `push`, `range`, - * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`, - * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`, - * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, - * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, - * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, - * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `update`, `values`, - * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, - * `zipObjectDeep`, and `zipWith` + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, - * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `each`, `eachRight`, - * `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, `floor`, - * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, - * `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, `includes`, - * `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, `isArrayBuffer`, - * `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, `isDate`, - * `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`, - * `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, `isMatchWith`, - * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, - * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isSet`, `isString`, - * `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, - * `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, - * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, - * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, - * `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`, - * `template`, `times`, `toInteger`, `toJSON`, `toLength`, `toLower`, - * `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`, - * `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`, - * `value`, and `words` + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`, + * `eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, + * `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, + * `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, + * `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, + * `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, + * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, + * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, + * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, + * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, + * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, + * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, + * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, + * `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`, + * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, + * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, + * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toInteger`, + * `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, `toString`, + * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, + * `uniqueId`, `upperCase`, `upperFirst`, `value`, and `words` * * @name _ * @constructor @@ -499,15 +499,9 @@ * // => true */ function lodash(value) { - if (isObjectLike(value) && !isArray(value)) { - if (value instanceof LodashWrapper) { - return value; - } - if (hasOwnProperty.call(value, '__wrapped__')) { - return wrapperClone(value); - } - } - return new LodashWrapper(value); + return value instanceof LodashWrapper + ? value + : new LodashWrapper(value); } /** @@ -515,7 +509,7 @@ * * @private * @param {*} value The value to wrap. - * @param {boolean} [chainAll] Enable chaining for all wrapper methods. + * @param {boolean} [chainAll] Enable explicit method chain sequences. */ function LodashWrapper(value, chainAll) { this.__wrapped__ = value; @@ -523,6 +517,9 @@ this.__chain__ = !!chainAll; } + LodashWrapper.prototype = baseCreate(lodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + /*------------------------------------------------------------------------*/ /** @@ -561,17 +558,6 @@ } } - /** - * Casts `value` to `identity` if it's not a function. - * - * @private - * @param {*} value The value to inspect. - * @returns {Array} Returns the array-like object. - */ - function baseCastFunction(value) { - return typeof value == 'function' ? value : identity; - } - /** * The base implementation of `_.create` without support for assigning * properties to the created object. @@ -617,7 +603,8 @@ * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false` + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` */ function baseEvery(collection, predicate) { var result = true; @@ -680,10 +667,9 @@ } /** - * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` invoking `iteratee` for - * each property. Iteratee functions may exit iteration early by explicitly - * returning `false`. + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` invoking `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. * * @private * @param {Object} object The object to iterate over. @@ -755,7 +741,8 @@ * @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 comparisons. - * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ @@ -797,7 +784,10 @@ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { - var result = equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack); + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + var result = equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); stack.pop(); return result; } @@ -818,13 +808,13 @@ * @returns {Function} Returns the iteratee. */ function baseIteratee(func) { - var type = typeof func; - if (type == 'function') { + if (typeof func == 'function') { return func; } - return func == null - ? identity - : (type == 'object' ? baseMatches : baseProperty)(func); + if (func == null) { + return identity; + } + return (typeof func == 'object' ? baseMatches : baseProperty)(func); } /** @@ -911,11 +901,11 @@ /** * The base implementation of `_.pick` without support for individual - * property names. + * property identifiers. * * @private * @param {Object} object The source object. - * @param {string[]} props The property names to pick. + * @param {string[]} props The property identifiers to pick. * @returns {Object} Returns the new object. */ function basePick(object, props) { @@ -989,7 +979,8 @@ * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. */ function baseSome(collection, predicate) { var result; @@ -1023,7 +1014,7 @@ * * @private * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. + * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @returns {Object} Returns `object`. */ @@ -1035,7 +1026,7 @@ * * @private * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. + * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. @@ -1116,7 +1107,7 @@ } /** - * Creates a base function for methods like `_.forIn`. + * Creates a base function for methods like `_.forIn` and `_.forOwn`. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. @@ -1169,9 +1160,11 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {*} thisArg The `this` binding of `func`. - * @param {Array} partials The arguments to prepend to those provided to the new function. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. * @returns {Function} Returns the new wrapped function. */ function createPartialWrapper(func, bitmask, thisArg, partials) { @@ -1209,7 +1202,8 @@ * @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 comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ @@ -1241,12 +1235,16 @@ // Recursively compare arrays (susceptible to call stack limits). if (isUnordered) { if (!baseSome(other, function(othValue) { - return arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack); + return arrValue === othValue || + equalFunc(arrValue, othValue, customizer, bitmask, stack); })) { result = false; break; } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, customizer, bitmask, stack) + )) { result = false; break; } @@ -1267,7 +1265,8 @@ * @param {string} tag The `toStringTag` of the objects to compare. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ @@ -1276,8 +1275,9 @@ case boolTag: case dateTag: - // Coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + // Coerce dates and booleans to numbers, dates to milliseconds and + // booleans to `1` or `0` treating invalid dates coerced to `NaN` as + // not equal. return +object == +other; case errorTag: @@ -1289,8 +1289,8 @@ case regexpTag: case stringTag: - // Coerce regexes to strings and treat strings primitives and string - // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See https://es5.github.io/#x15.10.6.4 for more details. return object == (other + ''); } @@ -1306,7 +1306,8 @@ * @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 comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ @@ -1364,8 +1365,9 @@ /** * Gets the "length" property value of `object`. * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. + * **Note:** This function is used to avoid a + * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects + * Safari on at least iOS 8.1-8.3 ARM64. * * @private * @param {Object} object The object to query. @@ -1404,19 +1406,6 @@ return value === proto; } - /** - * Creates a clone of `wrapper`. - * - * @private - * @param {Object} wrapper The wrapper to clone. - * @returns {Object} Returns the cloned wrapper. - */ - function wrapperClone(wrapper) { - var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); - result.__actions__ = copyArray(wrapper.__actions__); - return result; - } - /*------------------------------------------------------------------------*/ /** @@ -1425,6 +1414,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to compact. * @returns {Array} Returns the new array of filtered values. @@ -1443,6 +1433,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to concatenate. * @param {...*} [values] The values to concatenate. @@ -1458,19 +1449,26 @@ * console.log(array); * // => [1] */ - var concat = rest(function(array, values) { - if (!isArray(array)) { - array = array == null ? [] : [Object(array)]; + function concat() { + var length = arguments.length, + array = castArray(arguments[0]); + + if (length < 2) { + return length ? copyArray(array) : []; } - values = baseFlatten(values, 1); - return arrayConcat(array, values); - }); + var args = Array(length - 1); + while (length--) { + args[length - 1] = arguments[length]; + } + return arrayConcat(array, baseFlatten(args, 1)); + } /** * Flattens `array` a single level deep. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. @@ -1489,6 +1487,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. @@ -1507,6 +1506,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @alias first * @category Array * @param {Array} array The array to query. @@ -1531,6 +1531,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -1569,6 +1570,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to query. * @returns {*} Returns the last element of `array`. @@ -1585,11 +1587,13 @@ /** * Creates a slice of `array` from `start` up to, but not including, `end`. * - * **Note:** This method is used instead of [`Array#slice`](https://mdn.io/Array/slice) - * to ensure dense arrays are returned. + * **Note:** This method is used instead of + * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are + * returned. * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to slice. * @param {number} [start=0] The start position. @@ -1606,11 +1610,13 @@ /*------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps `value` with explicit method chaining enabled. - * The result of such method chaining must be unwrapped with `_#value`. + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. * * @static * @memberOf _ + * @since 1.3.0 * @category Seq * @param {*} value The value to wrap. * @returns {Object} Returns the new `lodash` wrapper instance. @@ -1641,10 +1647,11 @@ /** * This method invokes `interceptor` and returns `value`. The interceptor * is invoked with one argument; (value). The purpose of this method is to - * "tap into" a method chain in order to modify intermediate results. + * "tap into" a method chain sequence in order to modify intermediate results. * * @static * @memberOf _ + * @since 0.1.0 * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. @@ -1668,10 +1675,11 @@ /** * This method is like `_.tap` except that it returns the result of `interceptor`. * The purpose of this method is to "pass thru" values replacing intermediate - * results in a method chain. + * results in a method chain sequence. * * @static * @memberOf _ + * @since 3.0.0 * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. @@ -1692,10 +1700,11 @@ } /** - * Enables explicit method chaining on the wrapper object. + * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. * * @name chain * @memberOf _ + * @since 0.1.0 * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -1722,10 +1731,11 @@ } /** - * Executes the chained sequence to extract the unwrapped value. + * Executes the chain sequence to resolve the unwrapped value. * * @name value * @memberOf _ + * @since 0.1.0 * @alias toJSON, valueOf * @category Seq * @returns {*} Returns the resolved unwrapped value. @@ -1747,19 +1757,22 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. * @example * * _.every([true, 1, null, 'yes'], Boolean); * // => false * * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false } + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * * // The `_.matches` iteratee shorthand. @@ -1781,14 +1794,16 @@ /** * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three arguments: - * (value, index|key, collection). + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @example * @@ -1818,14 +1833,16 @@ /** * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three arguments: - * (value, index|key, collection). + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {*} Returns the matched element, else `undefined`. * @example * @@ -1859,12 +1876,13 @@ * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning `false`. * - * **Note:** As with other "Collections" methods, objects with a "length" property - * are iterated like arrays. To avoid this behavior use `_.forIn` or `_.forOwn` - * for object iteration. + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. * * @static * @memberOf _ + * @since 0.1.0 * @alias each * @category Collection * @param {Array|Object} collection The collection to iterate over. @@ -1875,15 +1893,15 @@ * _([1, 2]).forEach(function(value) { * console.log(value); * }); - * // => logs `1` then `2` + * // => Logs `1` then `2`. * * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { * console.log(key); * }); - * // => logs 'a' then 'b' (iteration order is not guaranteed) + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forEach(collection, iteratee) { - return baseEach(collection, baseCastFunction(iteratee)); + return baseEach(collection, baseIteratee(iteratee)); } /** @@ -1902,9 +1920,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new mapped array. * @example * @@ -1948,6 +1968,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -1972,10 +1993,11 @@ /** * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable properties for objects. + * values or the number of own enumerable string keyed properties for objects. * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to inspect. * @returns {number} Returns the collection size. @@ -2005,11 +2027,14 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. * @example * * _.some([null, 0, 'yes', false], Boolean); @@ -2045,30 +2070,32 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[]|Object|Object[]|string|string[])} [iteratees=[_.identity]] - * The iteratees to sort by, specified individually or in arrays. + * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])} + * [iteratees=[_.identity]] The iteratees to sort by, specified individually + * or in arrays. * @returns {Array} Returns the new sorted array. * @example * * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 42 }, + * { 'user': 'fred', 'age': 40 }, * { 'user': 'barney', 'age': 34 } * ]; * * _.sortBy(users, function(o) { return o.user; }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] * * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] + * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] * * _.sortBy(users, 'user', function(o) { * return Math.floor(o.age / 10); * }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] */ function sortBy(collection, iteratee) { var index = 0; @@ -2090,6 +2117,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {number} n The number of calls at which `func` is no longer invoked. * @param {Function} func The function to restrict. @@ -2129,6 +2157,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to bind. * @param {*} thisArg The `this` binding of `func`. @@ -2161,6 +2190,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to defer. * @param {...*} [args] The arguments to invoke `func` with. @@ -2170,7 +2200,7 @@ * _.defer(function(text) { * console.log(text); * }, 'deferred'); - * // => logs 'deferred' after one or more milliseconds + * // => Logs 'deferred' after one or more milliseconds. */ var defer = rest(function(func, args) { return baseDelay(func, 1, args); @@ -2182,6 +2212,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. @@ -2192,7 +2223,7 @@ * _.delay(function(text) { * console.log(text); * }, 1000, 'later'); - * // => logs 'later' after one second + * // => Logs 'later' after one second. */ var delay = rest(function(func, wait, args) { return baseDelay(func, toNumber(wait) || 0, args); @@ -2205,6 +2236,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} predicate The predicate to negate. * @returns {Function} Returns the new function. @@ -2233,6 +2265,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to restrict. * @returns {Function} Returns the new restricted function. @@ -2249,12 +2282,15 @@ /** * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as an array. + * created function and arguments from `start` and beyond provided as + * an array. * - * **Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters). + * **Note:** This method is based on the + * [rest parameter](https://mdn.io/rest_parameters). * * @static * @memberOf _ + * @since 4.0.0 * @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. @@ -2295,6 +2331,47 @@ /*------------------------------------------------------------------------*/ + /** + * Casts `value` as an array if it's not one. + * + * @static + * @memberOf _ + * @since 4.4.0 + * @category Lang + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast array. + * @example + * + * _.castArray(1); + * // => [1] + * + * _.castArray({ 'a': 1 }); + * // => [{ 'a': 1 }] + * + * _.castArray('abc'); + * // => ['abc'] + * + * _.castArray(null); + * // => [null] + * + * _.castArray(undefined); + * // => [undefined] + * + * _.castArray(); + * // => [] + * + * var array = [1, 2, 3]; + * console.log(_.castArray(array) === array); + * // => true + */ + function castArray() { + if (!arguments.length) { + return []; + } + var value = arguments[0]; + return isArray(value) ? value : [value]; + } + /** * Creates a shallow clone of `value`. * @@ -2308,6 +2385,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to clone. * @returns {*} Returns the cloned value. @@ -2327,11 +2405,13 @@ } /** - * Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. @@ -2365,10 +2445,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. * @example * * _.gt(3, 1); @@ -2389,9 +2471,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArguments(function() { return arguments; }()); @@ -2411,10 +2495,12 @@ * * @static * @memberOf _ + * @since 0.1.0 * @type {Function} * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArray([1, 2, 3]); @@ -2438,6 +2524,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. @@ -2465,9 +2552,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. * @example * * _.isArrayLikeObject([1, 2, 3]); @@ -2491,9 +2580,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isBoolean(false); @@ -2512,9 +2603,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isDate(new Date); @@ -2528,12 +2621,18 @@ } /** - * Checks if `value` is an empty collection or object. A value is considered - * empty if it's an `arguments` object, array, string, or jQuery-like collection - * with a length of `0` or has no own enumerable properties. + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is empty, else `false`. @@ -2565,7 +2664,7 @@ return false; } } - return true; + return !(nonEnumShadows && keys(value).length); } /** @@ -2580,10 +2679,12 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, + * else `false`. * @example * * var object = { 'user': 'fred' }; @@ -2602,13 +2703,16 @@ /** * Checks if `value` is a finite primitive number. * - * **Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite). + * **Note:** This method is based on + * [`Number.isFinite`](https://mdn.io/Number/isFinite). * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @returns {boolean} Returns `true` if `value` is a finite number, + * else `false`. * @example * * _.isFinite(3); @@ -2632,9 +2736,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isFunction(_); @@ -2654,13 +2760,16 @@ /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This function is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @returns {boolean} Returns `true` if `value` is a valid length, + * else `false`. * @example * * _.isLength(3); @@ -2686,6 +2795,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. @@ -2714,6 +2824,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. @@ -2738,11 +2849,13 @@ /** * Checks if `value` is `NaN`. * - * **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4) - * which returns `true` for `undefined` and other non-numeric values. + * **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 _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. @@ -2762,7 +2875,8 @@ */ function isNaN(value) { // An `NaN` primitive is the only value that is not equal to itself. - // Perform the `toStringTag` check first to avoid errors with some ActiveX objects in IE. + // Perform the `toStringTag` check first to avoid errors with some + // ActiveX objects in IE. return isNumber(value) && value != +value; } @@ -2771,6 +2885,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `null`, else `false`. @@ -2789,14 +2904,16 @@ /** * Checks if `value` is classified as a `Number` primitive or object. * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified - * as numbers, use the `_.isFinite` method. + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are + * classified as numbers, use the `_.isFinite` method. * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isNumber(3); @@ -2821,9 +2938,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isRegExp(/abc/); @@ -2840,10 +2959,12 @@ * Checks if `value` is classified as a `String` primitive or object. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isString('abc'); @@ -2861,6 +2982,7 @@ * Checks if `value` is `undefined`. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. @@ -2882,10 +3004,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. * @example * * _.lt(1, 3); @@ -2905,6 +3029,7 @@ * Converts `value` to an array. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to convert. @@ -2933,10 +3058,12 @@ /** * Converts `value` to an integer. * - * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). + * **Note:** This function is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. @@ -2961,6 +3088,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {number} Returns the number. @@ -2986,6 +3114,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {string} Returns the string. @@ -3010,15 +3139,16 @@ /*------------------------------------------------------------------------*/ /** - * Assigns own enumerable properties of source objects to the destination - * object. Source objects are applied from left to right. Subsequent sources - * overwrite property assignments of previous sources. + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object` and is loosely based on * [`Object.assign`](https://mdn.io/Object/assign). * * @static * @memberOf _ + * @since 0.10.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. @@ -3051,6 +3181,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @alias extend * @category Object * @param {Object} object The destination object. @@ -3077,15 +3208,16 @@ }); /** - * This method is like `_.assignIn` except that it accepts `customizer` which - * is invoked to produce the assigned values. If `customizer` returns `undefined` - * assignment is handled by the method instead. The `customizer` is invoked - * with five arguments: (objValue, srcValue, key, object, source). + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined` assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). * * **Note:** This method mutates `object`. * * @static * @memberOf _ + * @since 4.0.0 * @alias extendWith * @category Object * @param {Object} object The destination object. @@ -3108,11 +3240,13 @@ }); /** - * Creates an object that inherits from the `prototype` object. If a `properties` - * object is given its own enumerable properties are assigned to the created object. + * Creates an object that inherits from the `prototype` object. If a + * `properties` object is given its own enumerable string keyed properties + * are assigned to the created object. * * @static * @memberOf _ + * @since 2.3.0 * @category Object * @param {Object} prototype The object to inherit from. * @param {Object} [properties] The properties to assign to the object. @@ -3145,14 +3279,15 @@ } /** - * Assigns own and inherited enumerable properties of source objects to the - * destination object for all destination properties that resolve to `undefined`. - * Source objects are applied from left to right. Once a property is set, - * additional values of the same property are ignored. + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. * * **Note:** This method mutates `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The destination object. @@ -3172,6 +3307,7 @@ * Checks if `path` is a direct property of `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -3206,6 +3342,7 @@ * for more details. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -3252,6 +3389,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. @@ -3291,11 +3429,12 @@ * Creates an object composed of the picked `object` properties. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The source object. - * @param {...(string|string[])} [props] The property names to pick, specified - * individually or in arrays. + * @param {...(string|string[])} [props] The property identifiers to pick, + * specified individually or in arrays. * @returns {Object} Returns the new object. * @example * @@ -3309,16 +3448,17 @@ }); /** - * This method is like `_.get` except that if the resolved value is a function - * it's invoked with the `this` binding of its parent object and its result - * is returned. + * This method is like `_.get` except that if the resolved value is a + * function it's invoked with the `this` binding of its parent object and + * its result is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. * @returns {*} Returns the resolved value. * @example * @@ -3345,11 +3485,12 @@ } /** - * Creates an array of the own enumerable property values of `object`. + * Creates an array of the own enumerable string keyed property values of `object`. * * **Note:** Non-object values are coerced to objects. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -3384,20 +3525,22 @@ * * Though the ">" character is escaped for symmetry, characters like * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. - * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * unless they're part of a tag or unquoted attribute value. See + * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. * * Backticks are escaped because in IE < 9, they can break out of * attribute values or HTML comments. See [#59](https://html5sec.org/#59), * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and - * [#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/) - * for more details. + * [#133](https://html5sec.org/#133) of the + * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details. * - * When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping) - * to reduce XSS vectors. + * When working with HTML you should always + * [quote attribute values](http://wonko.com/post/html-escaping) to reduce + * XSS vectors. * * @static + * @since 0.1.0 * @memberOf _ * @category String * @param {string} [string=''] The string to escape. @@ -3420,6 +3563,7 @@ * This method returns the first argument given to it. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {*} value Any value. @@ -3437,12 +3581,13 @@ /** * Creates a function that invokes `func` with the arguments of the created - * function. If `func` is a property name the 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`. + * function. If `func` is a property name the created function returns the + * property value for a given element. If `func` is an array or object the + * created function returns `true` for elements that contain the equivalent + * source properties, otherwise it returns `false`. * * @static + * @since 4.0.0 * @memberOf _ * @category Util * @param {*} [func=_.identity] The value to convert to a callback. @@ -3450,20 +3595,31 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * + * // The `_.matches` iteratee shorthand. + * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); + * // => [{ 'user': 'barney', 'age': 36, 'active': true }] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, _.iteratee(['user', 'fred'])); + * // => [{ 'user': 'fred', 'age': 40 }] + * + * // The `_.property` iteratee shorthand. + * _.map(users, _.iteratee('user')); + * // => ['barney', 'fred'] + * * // Create custom iteratee shorthands. - * _.iteratee = _.wrap(_.iteratee, function(callback, func) { - * var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func); - * return !p ? callback(func) : function(object) { - * return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]); + * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { + * return !_.isRegExp(func) ? iteratee(func) : function(string) { + * return func.test(string); * }; * }); * - * _.filter(users, 'age > 36'); - * // => [{ 'user': 'fred', 'age': 40 }] + * _.filter(['abc', 'def'], /ef/); + * // => ['def'] */ var iteratee = baseIteratee; @@ -3477,6 +3633,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {Object} source The object of property values to match. * @returns {Function} Returns the new function. @@ -3495,21 +3652,21 @@ } /** - * 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. + * Adds all own enumerable string keyed 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 to * avoid conflicts caused by modifying the original. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {Function|Object} [object=lodash] The destination object. * @param {Object} source The object of functions to add. - * @param {Object} [options] The options object. - * @param {boolean} [options.chain=true] Specify whether the functions added - * are chainable. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.chain=true] Specify whether mixins are chainable. * @returns {Function|Object} Returns `object`. * @example * @@ -3571,6 +3728,7 @@ * the `lodash` function. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @returns {Function} Returns the `lodash` function. @@ -3591,6 +3749,7 @@ * * @static * @memberOf _ + * @since 2.3.0 * @category Util * @example * @@ -3607,6 +3766,7 @@ * Generates a unique ID. If `prefix` is given the ID is appended to it. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {string} [prefix=''] The value to prefix the ID with. @@ -3631,6 +3791,7 @@ * `undefined` is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Math * @param {Array} array The array to iterate over. @@ -3654,6 +3815,7 @@ * `undefined` is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Math * @param {Array} array The array to iterate over. @@ -3674,10 +3836,7 @@ /*------------------------------------------------------------------------*/ - LodashWrapper.prototype = baseCreate(lodash.prototype); - LodashWrapper.prototype.constructor = LodashWrapper; - - // Add functions that return wrapped values when chaining. + // Add methods that return wrapped values in chain sequences. lodash.assignIn = assignIn; lodash.before = before; lodash.bind = bind; @@ -3709,12 +3868,12 @@ // Add aliases. lodash.extend = assignIn; - // Add functions to `lodash.prototype`. + // Add methods to `lodash.prototype`. mixin(lodash, lodash); /*------------------------------------------------------------------------*/ - // Add functions that return unwrapped values when chaining. + // Add methods that return unwrapped values in chain sequences. lodash.clone = clone; lodash.escape = escape; lodash.every = every; @@ -3775,7 +3934,7 @@ */ lodash.VERSION = VERSION; - // Add `Array` and `String` methods to `lodash.prototype`. + // Add `Array` methods to `lodash.prototype`. baseEach(['pop', 'join', 'replace', 'reverse', 'split', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var func = (/^(?:replace|split)$/.test(methodName) ? String.prototype : arrayProto)[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', @@ -3784,15 +3943,16 @@ lodash.prototype[methodName] = function() { var args = arguments; if (retUnwrapped && !this.__chain__) { - return func.apply(this.value(), args); + var value = this.value(); + return func.apply(isArray(value) ? value : [], args); } return this[chainName](function(value) { - return func.apply(value, args); + return func.apply(isArray(value) ? value : [], args); }); }; }); - // Add chaining functions to the `lodash` wrapper. + // Add chain sequence methods to the `lodash` wrapper. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; /*--------------------------------------------------------------------------*/ diff --git a/dist/lodash.core.min.js b/dist/lodash.core.min.js index d6a4405219..11cdcffdca 100644 --- a/dist/lodash.core.min.js +++ b/dist/lodash.core.min.js @@ -1,29 +1,30 @@ /** * @license - * lodash 4.6.1 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE + * lodash 4.7.0 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE * Build: `lodash core -o ./dist/lodash.core.js` */ -;(function(){function n(n,t){for(var r=-1,e=t.length,u=n.length;++r-1&&0==n%1&&(null==t?9007199254740991:t)>n}function a(n){if(Y(n)&&!Pn(n)){if(n instanceof l)return n;if(An.call(n,"__wrapped__")){var t=new l(n.__wrapped__,n.__chain__);return t.__actions__=N(n.__actions__),t}}return new l(n)}function l(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function p(n,t,r,e){var u;return(u=n===an)||(u=xn[r], -u=(n===u||n!==n&&u!==u)&&!An.call(e,r)),u?t:n}function s(n){return X(n)?Fn(n):{}}function h(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function");return setTimeout(function(){n.apply(an,r)},t)}function v(n,t){var r=true;return $n(n,function(n,e,u){return r=!!t(n,e,u)}),r}function y(n,t){var r=[];return $n(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function _(t,r,e,u){u||(u=[]);for(var o=-1,i=t.length;++o0&&Y(c)&&L(c)&&(e||Pn(c)||K(c))?r>1?_(c,r-1,e,u):n(u,c):e||(u[u.length]=c); -}return u}function b(n,t){return n&&qn(n,t,en)}function g(n,t){return y(t,function(t){return Q(n[t])})}function j(n,t,r,e,u){return n===t?true:null==n||null==t||!X(n)&&!Y(t)?n!==n&&t!==t:d(n,t,j,r,e,u)}function d(n,t,r,e,u,o){var i=Pn(n),f=Pn(t),a="[object Array]",l="[object Array]";i||(a=kn.call(n),a="[object Arguments]"==a?"[object Object]":a),f||(l=kn.call(t),l="[object Arguments]"==l?"[object Object]":l);var p="[object Object]"==a&&!c(n),f="[object Object]"==l&&!c(t),l=a==l;o||(o=[]);var s=J(o,function(t){ -return t[0]===n});return s&&s[1]?s[1]==t:(o.push([n,t]),l&&!p?(t=i||isTypedArray(n)?I(n,t,r,e,u,o):$(n,t,a),o.pop(),t):2&u||(i=p&&An.call(n,"__wrapped__"),a=f&&An.call(t,"__wrapped__"),!i&&!a)?l?(t=q(n,t,r,e,u,o),o.pop(),t):false:(t=r(i?n.value():n,a?t.value():t,e,u,o),o.pop(),t))}function m(n){var t=typeof n;return"function"==t?n:null==n?cn:("object"==t?x:E)(n)}function w(n){n=null==n?n:Object(n);var t,r=[];for(t in n)r.push(t);return r}function O(n,t){var r=-1,e=L(n)?Array(n.length):[];return $n(n,function(n,u,o){ -e[++r]=t(n,u,o)}),e}function x(n){var t=en(n);return function(r){var e=t.length;if(null==r)return!e;for(r=Object(r);e--;){var u=t[e];if(!(u in r&&j(n[u],r[u],an,3)))return false}return true}}function A(n,t){return n=Object(n),P(t,function(t,r){return r in n&&(t[r]=n[r]),t},{})}function E(n){return function(t){return null==t?an:t[n]}}function k(n,t,r){var e=-1,u=n.length;for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e1?r[u-1]:an,o=typeof o=="function"?(u--,o):an;for(t=Object(t);++ef))return false;for(a=true;++iarguments.length,$n)}function U(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function");return n=Un(n),function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=an),r}}function V(n){var t;if(typeof n!="function")throw new TypeError("Expected a function"); -return t=In(t===an?n.length-1:Un(t),0),function(){for(var r=arguments,e=-1,u=In(r.length-t,0),o=Array(u);++et}function K(n){return Y(n)&&L(n)&&An.call(n,"callee")&&(!Rn.call(n,"callee")||"[object Arguments]"==kn.call(n))}function L(n){return null!=n&&W(zn(n))&&!Q(n)}function Q(n){return n=X(n)?kn.call(n):"","[object Function]"==n||"[object GeneratorFunction]"==n}function W(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n; -}function X(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function Y(n){return!!n&&typeof n=="object"}function Z(n){return typeof n=="number"||Y(n)&&"[object Number]"==kn.call(n)}function nn(n){return typeof n=="string"||!Pn(n)&&Y(n)&&"[object String]"==kn.call(n)}function tn(n,t){return t>n}function rn(n){return typeof n=="string"?n:null==n?"":n+""}function en(n){var t=C(n);if(!t&&!L(n))return Dn(Object(n));var r,e=z(n),u=!!e,e=e||[],o=e.length;for(r in n)!An.call(n,r)||u&&("length"==r||f(r,o))||t&&"constructor"==r||e.push(r); -return e}function un(n){for(var t=-1,r=C(n),e=w(n),u=e.length,o=z(n),i=!!o,o=o||[],c=o.length;++t"'`]/g,sn=RegExp(pn.source),hn=/^(?:0|[1-9]\d*)$/,vn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},yn={"function":true,object:true},_n=yn[typeof exports]&&exports&&!exports.nodeType?exports:an,bn=yn[typeof module]&&module&&!module.nodeType?module:an,gn=bn&&bn.exports===_n?_n:an,jn=o(yn[typeof self]&&self),dn=o(yn[typeof window]&&window),mn=o(yn[typeof this]&&this),wn=o(_n&&bn&&typeof global=="object"&&global)||dn!==(mn&&mn.window)&&dn||jn||mn||Function("return this")(),On=Array.prototype,xn=Object.prototype,An=xn.hasOwnProperty,En=0,kn=xn.toString,Nn=wn._,Sn=wn.Reflect,Tn=Sn?Sn.f:an,Fn=Object.create,Rn=xn.propertyIsEnumerable,Bn=wn.isFinite,Dn=Object.keys,In=Math.max,$n=function(n,t){ -return function(r,e){if(null==r)return r;if(!L(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++oe&&!c||!i||u&&!f&&a||o&&a){r=1;break n}if(e>r&&!u||!a||c&&!o&&i||f&&i){r=-1;break n}}r=0}return r||n.b-t.b; -}),E("c"))},a.tap=function(n,t){return t(n),n},a.thru=function(n,t){return t(n)},a.toArray=function(n){return L(n)?n.length?N(n):[]:on(n)},a.values=on,a.extend=Kn,fn(a,a),a.clone=function(n){return X(n)?Pn(n)?N(n):F(n,en(n)):n},a.escape=function(n){return(n=rn(n))&&sn.test(n)?n.replace(pn,i):n},a.every=function(n,t,r){return t=r?an:t,v(n,m(t))},a.find=J,a.forEach=M,a.has=function(n,t){return null!=n&&An.call(n,t)},a.head=G,a.identity=cn,a.indexOf=function(n,t,r){var e=n?n.length:0;r=typeof r=="number"?0>r?In(e+r,0):r:0, -r=(r||0)-1;for(var u=t===t;++r-1&&0==n%1&&(null==t?9007199254740991:t)>n}function a(n){return n instanceof l?n:new l(n)}function l(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function p(n,t,r,e){var u;return(u=n===ln)||(u=An[r],u=(n===u||n!==n&&u!==u)&&!En.call(e,r)),u?t:n}function s(n){return Y(n)?Rn(n):{}}function h(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function");return setTimeout(function(){ +n.apply(ln,r)},t)}function v(n,t){var r=true;return zn(n,function(n,e,u){return r=!!t(n,e,u)}),r}function y(n,t){var r=[];return zn(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function g(t,r,e,u){u||(u=[]);for(var o=-1,i=t.length;++o0&&Z(c)&&Q(c)&&(e||Un(c)||L(c))?r>1?g(c,r-1,e,u):n(u,c):e||(u[u.length]=c)}return u}function b(n,t){return n&&Cn(n,t,un)}function _(n,t){return y(t,function(t){return W(n[t])})}function j(n,t,r,e,u){return n===t?true:null==n||null==t||!Y(n)&&!Z(t)?n!==n&&t!==t:d(n,t,j,r,e,u); +}function d(n,t,r,e,u,o){var i=Un(n),f=Un(t),a="[object Array]",l="[object Array]";i||(a=Nn.call(n),a="[object Arguments]"==a?"[object Object]":a),f||(l=Nn.call(t),l="[object Arguments]"==l?"[object Object]":l);var p="[object Object]"==a&&!c(n),f="[object Object]"==l&&!c(t),l=a==l;o||(o=[]);var s=J(o,function(t){return t[0]===n});return s&&s[1]?s[1]==t:(o.push([n,t]),l&&!p?(r=i||isTypedArray(n)?I(n,t,r,e,u,o):$(n,t,a),o.pop(),r):2&u||(i=p&&En.call(n,"__wrapped__"),a=f&&En.call(t,"__wrapped__"),!i&&!a)?l?(r=q(n,t,r,e,u,o), +o.pop(),r):false:(i=i?n.value():n,t=a?t.value():t,r=r(i,t,e,u,o),o.pop(),r))}function m(n){return typeof n=="function"?n:null==n?fn:(typeof n=="object"?x:E)(n)}function O(n){n=null==n?n:Object(n);var t,r=[];for(t in n)r.push(t);return r}function w(n,t){var r=-1,e=Q(n)?Array(n.length):[];return zn(n,function(n,u,o){e[++r]=t(n,u,o)}),e}function x(n){var t=un(n);return function(r){var e=t.length;if(null==r)return!e;for(r=Object(r);e--;){var u=t[e];if(!(u in r&&j(n[u],r[u],ln,3)))return false}return true}}function A(n,t){ +return n=Object(n),P(t,function(t,r){return r in n&&(t[r]=n[r]),t},{})}function E(n){return function(t){return null==t?ln:t[n]}}function k(n,t,r){var e=-1,u=n.length;for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e1?r[u-1]:ln,o=typeof o=="function"?(u--,o):ln;for(t=Object(t);++ef))return false;for(a=true;++iarguments.length,zn)}function U(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function");return n=Vn(n),function(){ +return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=ln),r}}function V(n){var t;if(typeof n!="function")throw new TypeError("Expected a function");return t=$n(t===ln?n.length-1:Vn(t),0),function(){for(var r=arguments,e=-1,u=$n(r.length-t,0),o=Array(u);++et}function L(n){return Z(n)&&Q(n)&&En.call(n,"callee")&&(!Bn.call(n,"callee")||"[object Arguments]"==Nn.call(n)); +}function Q(n){return null!=n&&X(Gn(n))&&!W(n)}function W(n){return n=Y(n)?Nn.call(n):"","[object Function]"==n||"[object GeneratorFunction]"==n}function X(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n}function Y(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function Z(n){return!!n&&typeof n=="object"}function nn(n){return typeof n=="number"||Z(n)&&"[object Number]"==Nn.call(n)}function tn(n){return typeof n=="string"||!Un(n)&&Z(n)&&"[object String]"==Nn.call(n)}function rn(n,t){ +return t>n}function en(n){return typeof n=="string"?n:null==n?"":n+""}function un(n){var t=C(n);if(!t&&!Q(n))return In(Object(n));var r,e=z(n),u=!!e,e=e||[],o=e.length;for(r in n)!En.call(n,r)||u&&("length"==r||f(r,o))||t&&"constructor"==r||e.push(r);return e}function on(n){for(var t=-1,r=C(n),e=O(n),u=e.length,o=z(n),i=!!o,o=o||[],c=o.length;++t"'`]/g,hn=RegExp(sn.source),vn=/^(?:0|[1-9]\d*)$/,yn={ +"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},gn={"function":true,object:true},bn=gn[typeof exports]&&exports&&!exports.nodeType?exports:ln,_n=gn[typeof module]&&module&&!module.nodeType?module:ln,jn=_n&&_n.exports===bn?bn:ln,dn=o(gn[typeof self]&&self),mn=o(gn[typeof window]&&window),On=o(gn[typeof this]&&this),wn=o(bn&&_n&&typeof global=="object"&&global)||mn!==(On&&On.window)&&mn||dn||On||Function("return this")(),xn=Array.prototype,An=Object.prototype,En=An.hasOwnProperty,kn=0,Nn=An.toString,Sn=wn._,Tn=wn.Reflect,Fn=Tn?Tn.f:ln,Rn=Object.create,Bn=An.propertyIsEnumerable,Dn=wn.isFinite,In=Object.keys,$n=Math.max,qn=!Bn.call({ +valueOf:1},"valueOf");l.prototype=s(a.prototype),l.prototype.constructor=l;var zn=function(n,t){return function(r,e){if(null==r)return r;if(!Q(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++ot)return t?N(r):[];for(var e=Array(t-1);t--;)e[t-1]=arguments[t];return g(e,1),n(N(r),cn)},a.create=function(n,t){var r=s(n);return t?Kn(r,t):r},a.defaults=Wn,a.defer=Mn,a.delay=Pn,a.filter=function(n,t){return y(n,m(t))},a.flatten=function(n){return n&&n.length?g(n,1):[]},a.flattenDeep=function(n){return n&&n.length?g(n,pn):[]},a.iteratee=Yn,a.keys=un,a.map=function(n,t){return w(n,m(t))},a.matches=function(n){ +return x(Kn({},n))},a.mixin=an,a.negate=function(n){if(typeof n!="function")throw new TypeError("Expected a function");return function(){return!n.apply(this,arguments)}},a.once=function(n){return U(2,n)},a.pick=Xn,a.slice=function(n,t,r){var e=n?n.length:0;return r=r===ln?e:+r,e?k(n,null==t?0:+t,r):[]},a.sortBy=function(n,t){var r=0;return t=m(t),w(w(n,function(n,e,u){return{c:n,b:r++,a:t(n,e,u)}}).sort(function(n,t){var r;n:{r=n.a;var e=t.a;if(r!==e){var u=null===r,o=r===ln,i=r===r,c=null===e,f=e===ln,a=e===e; +if(r>e&&!c||!i||u&&!f&&a||o&&a){r=1;break n}if(e>r&&!u||!a||c&&!o&&i||f&&i){r=-1;break n}}r=0}return r||n.b-t.b}),E("c"))},a.tap=function(n,t){return t(n),n},a.thru=function(n,t){return t(n)},a.toArray=function(n){return Q(n)?n.length?N(n):[]:cn(n)},a.values=cn,a.extend=Ln,an(a,a),a.clone=function(n){return Y(n)?Un(n)?N(n):F(n,un(n)):n},a.escape=function(n){return(n=en(n))&&hn.test(n)?n.replace(sn,i):n},a.every=function(n,t,r){return t=r?ln:t,v(n,m(t))},a.find=J,a.forEach=M,a.has=function(n,t){return null!=n&&En.call(n,t); +},a.head=G,a.identity=fn,a.indexOf=function(n,t,r){var e=n?n.length:0;r=typeof r=="number"?0>r?$n(e+r,0):r:0,r=(r||0)-1;for(var u=t===t;++r2?r-2:1,n&&r>=n?i:B(i,r)):i}},mixin:function(t){return function(e){var r=this;if(!W(r))return t(r,Object(e));var i=[],n=[];return m(x(e),function(t){ -var a=e[t];W(a)&&(n.push(t),i.push(r.prototype[t]))}),t(r,Object(e)),m(n,function(t,e){var n=i[e];W(n)?r.prototype[t]=n:delete r.prototype[t]}),r}},runInContext:function(e){return function(r){return i(t,e(r),u)}}},L=function(t,e){t=n.aliasToReal[t]||t;var r=M[t];if(r)return r(e);var i=e;c.immutable&&(a.array[t]?i=w(e,E):a.object[t]?i=w(e,k(e)):a.set[t]&&(i=w(e,j)));var u;return m(b,function(e){return m(n.aryMethod[e],function(r){if(t==r){var a=!l&&n.iterateeAry[t],o=n.iterateeRearg[t],s=n.methodSpread[t]; -return u=i,c.fixed&&(u=void 0===s?d(u,e):I(u,s)),c.rearg&&e>1&&(h||!n.skipRearg[t])&&(u=R(u,n.methodRearg[t]||n.aryRearg[e])),c.cap&&(o?u=z(u,o):a&&(u=q(u,a))),c.curry&&e>1&&(u=g(u,e)),!1}}),!u}),u||(u=i),n.placeholder[t]&&(s=!0,e.placeholder=u.placeholder=o),u};if(!p)return L(e,r);var S=r,C=[];return m(b,function(t){m(n.aryMethod[t],function(t){var e=S[n.remap[t]||t];e&&C.push([t,L(t,e)])})}),m(C,function(t){S[t[0]]=t[1]}),s&&(S.placeholder=o),m(x(S),function(t){m(n.realToAlias[t]||[],function(e){ -S[e]=S[t]})}),S}var n=r(2),a=n.mutate,o={};t.exports=i},function(t,e){e.aliasToReal={__:"placeholder",all:"some",allPass:"overEvery",apply:"spread",assoc:"set",assocPath:"set",compose:"flowRight",contains:"includes",dissoc:"unset",dissocPath:"unset",each:"forEach",eachRight:"forEachRight",equals:"isEqual",extend:"assignIn",extendWith:"assignInWith",first:"head",init:"initial",mapObj:"mapValues",omitAll:"omit",nAry:"ary",path:"get",pathEq:"matchesProperty",pathOr:"getOr",pickAll:"pick",pipe:"flow", -prop:"get",propOf:"propertyOf",propOr:"getOr",somePass:"overSome",unapply:"rest",unnest:"flatten",useWith:"overArgs",whereEq:"filter",zipObj:"zipObject"},e.aryMethod={1:["attempt","castArray","ceil","create","curry","curryRight","floor","fromPairs","invert","iteratee","memoize","method","methodOf","mixin","over","overEvery","overSome","rest","reverse","round","runInContext","spread","template","trim","trimEnd","trimStart","uniqueId","words"],2:["add","after","ary","assign","assignIn","at","before","bind","bindKey","chunk","cloneDeepWith","cloneWith","concat","countBy","curryN","curryRightN","debounce","defaults","defaultsDeep","delay","difference","drop","dropRight","dropRightWhile","dropWhile","endsWith","eq","every","filter","find","find","findIndex","findKey","findLast","findLastIndex","findLastKey","flatMap","flattenDepth","forEach","forEachRight","forIn","forInRight","forOwn","forOwnRight","get","groupBy","gt","gte","has","hasIn","includes","indexOf","intersection","invertBy","invoke","invokeMap","isEqual","isMatch","join","keyBy","lastIndexOf","lt","lte","map","mapKeys","mapValues","matchesProperty","maxBy","merge","minBy","omit","omitBy","overArgs","pad","padEnd","padStart","parseInt","partial","partialRight","partition","pick","pickBy","pull","pullAll","pullAt","random","range","rangeRight","rearg","reject","remove","repeat","result","sampleSize","some","sortBy","sortedIndex","sortedIndexOf","sortedLastIndex","sortedLastIndexOf","sortedUniqBy","split","startsWith","subtract","sumBy","take","takeRight","takeRightWhile","takeWhile","tap","throttle","thru","times","trimChars","trimCharsEnd","trimCharsStart","truncate","union","uniqBy","uniqWith","unset","unzipWith","without","wrap","xor","zip","zipObject","zipObjectDeep"], -3:["assignInWith","assignWith","clamp","differenceBy","differenceWith","getOr","inRange","intersectionBy","intersectionWith","isEqualWith","isMatchWith","mergeWith","orderBy","pullAllBy","pullAllWith","reduce","reduceRight","replace","set","slice","sortedIndexBy","sortedLastIndexBy","transform","unionBy","unionWith","update","xorBy","xorWith","zipWith"],4:["fill","setWith","updateWith"]},e.aryRearg={2:[1,0],3:[2,0,1],4:[3,2,0,1]},e.iterateeAry={assignWith:2,assignInWith:2,cloneDeepWith:1,cloneWith:1, -dropRightWhile:1,dropWhile:1,every:1,filter:1,find:1,findIndex:1,findKey:1,findLast:1,findLastIndex:1,findLastKey:1,flatMap:1,forEach:1,forEachRight:1,forIn:1,forInRight:1,forOwn:1,forOwnRight:1,isEqualWith:2,isMatchWith:2,map:1,mapKeys:1,mapValues:1,partition:1,reduce:2,reduceRight:2,reject:1,remove:1,some:1,takeRightWhile:1,takeWhile:1,times:1,transform:2},e.iterateeRearg={mapKeys:[1]},e.methodRearg={assignInWith:[1,2,0],assignWith:[1,2,0],getOr:[2,1,0],isMatchWith:[2,1,0],mergeWith:[1,2,0],pullAllBy:[2,1,0], -pullAllWith:[2,1,0],setWith:[3,1,2,0],sortedIndexBy:[2,1,0],sortedLastIndexBy:[2,1,0],updateWith:[3,1,2,0],zipWith:[1,2,0]},e.methodSpread={partial:1,partialRight:1},e.mutate={array:{fill:!0,pull:!0,pullAll:!0,pullAllBy:!0,pullAllWith:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignIn:!0,assignInWith:!0,assignWith:!0,defaults:!0,defaultsDeep:!0,merge:!0,mergeWith:!0},set:{set:!0,setWith:!0,unset:!0,update:!0,updateWith:!0}},e.placeholder={bind:!0,bindKey:!0,curry:!0,curryRight:!0,partial:!0, -partialRight:!0},e.realToAlias=function(){var t=Object.prototype.hasOwnProperty,r=e.aliasToReal,i={};for(var n in r){var a=r[n];t.call(i,a)?i[a].push(n):i[a]=[n]}return i}(),e.remap={curryN:"curry",curryRightN:"curryRight",getOr:"get",trimChars:"trim",trimCharsEnd:"trimEnd",trimCharsStart:"trimStart"},e.skipRearg={add:!0,assign:!0,assignIn:!0,concat:!0,difference:!0,gt:!0,gte:!0,lt:!0,lte:!0,matchesProperty:!0,merge:!0,partial:!0,partialRight:!0,random:!0,range:!0,rangeRight:!0,subtract:!0,zip:!0, -zipObject:!0}}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fp=e():t.fp=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(t,e){return a(t,t,e)}var a=r(1);"function"==typeof _&&(_=n(_.runInContext())), +t.exports=n},function(t,e,r){function n(t,e,r,s){var u,p="function"==typeof e,l=e===Object(e);if(l&&(s=r,r=e,e=void 0),null==r)throw new TypeError;s||(s={});var c={cap:"cap"in s?s.cap:!0,curry:"curry"in s?s.curry:!0,fixed:"fixed"in s?s.fixed:!0,immutable:"immutable"in s?s.immutable:!0,rearg:"rearg"in s?s.rearg:!0},d="rearg"in s&&s.rearg,h=p?r:o,f=p?r.runInContext():void 0,y=p?r:{ary:t.ary,assign:t.assign,clone:t.clone,curry:t.curry,forEach:t.forEach,isArray:t.isArray,isFunction:t.isFunction,iteratee:t.iteratee, +keys:t.keys,rearg:t.rearg,spread:t.spread,toPath:t.toPath},g=y.ary,m=y.assign,v=y.clone,W=y.curry,x=y.forEach,R=y.isArray,I=y.isFunction,b=y.keys,A=y.rearg,O=y.spread,E=y.toPath,k=b(a.aryMethod),B=function(t,e){return 2==e?function(e,r){return t.apply(void 0,arguments)}:function(e){return t.apply(void 0,arguments)}},j=function(t,e){return 2==e?function(e,r){return t(e,r)}:function(e){return t(e)}},C=function(t){for(var e=t?t.length:0,r=Array(e);e--;)r[e]=t[e];return r},M=function(t,e){e=E(e);for(var r=-1,n=e.length,a=v(Object(t)),i=a;null!=i&&++r2?r-2:1,a&&r>=a?n:j(n,r)):n}},mixin:function(t){return function(e){var r=this;if(!I(r))return t(r,Object(e)); +var n=[],a=[];return x(b(e),function(t){var i=e[t];I(i)&&(a.push(t),n.push(r.prototype[t]))}),t(r,Object(e)),x(a,function(t,e){var a=n[e];I(a)?r.prototype[t]=a:delete r.prototype[t]}),r}},runInContext:function(e){return function(r){return n(t,e(r),s)}}},D=function(t,e){t=a.aliasToReal[t]||t;var r=L[t],o=function(r){var a=p?f:y,i=p?f[t]:e,o=m(m({},c),r);return n(a,t,i,o)};if(r){var s=r(e);return s.convert=o,s}var l=e;return c.immutable&&(i.array[t]?l=P(e,C):i.object[t]?l=P(e,q(e)):i.set[t]&&(l=P(e,M))), +x(k,function(e){return x(a.aryMethod[e],function(r){if(t==r){var n=!p&&a.iterateeAry[t],i=a.iterateeRearg[t],o=a.methodSpread[t];return s=l,c.fixed&&(s=void 0===o?g(s,e):O(s,o)),c.rearg&&e>1&&(d||!a.skipRearg[t])&&(s=A(s,a.methodRearg[t]||a.aryRearg[e])),c.cap&&(i?s=z(s,i):n&&(s=S(s,n))),c.curry&&e>1&&(s=W(s,e)),!1}}),!s}),s||(s=l),s==e&&(s=function(){return e.apply(this,arguments)}),s.convert=o,a.placeholder[t]&&(u=!0,s.placeholder=e.placeholder=h),s};if(!l)return D(e,r);var F=r,T=[];return x(k,function(t){ +x(a.aryMethod[t],function(t){var e=F[a.remap[t]||t];e&&T.push([t,D(t,e)])})}),x(T,function(t){F[t[0]]=t[1]}),F.convert=w,u&&(F.placeholder=h),x(b(F),function(t){x(a.realToAlias[t]||[],function(e){F[e]=F[t]})}),F}var a=r(2),i=a.mutate,o={};t.exports=n},function(t,e){e.aliasToReal={each:"forEach",eachRight:"forEachRight",entries:"toPairs",entriesIn:"toPairsIn",extend:"assignIn",extendWith:"assignInWith",first:"head",__:"placeholder",all:"every",allPass:"overEvery",always:"constant",any:"some",anyPass:"overSome", +apply:"spread",assoc:"set",assocPath:"set",complement:"negate",compose:"flowRight",contains:"includes",dissoc:"unset",dissocPath:"unset",equals:"isEqual",identical:"eq",init:"initial",invertObj:"invert",juxt:"over",mapObj:"mapValues",omitAll:"omit",nAry:"ary",path:"get",pathEq:"matchesProperty",pathOr:"getOr",pickAll:"pick",pipe:"flow",prop:"get",propOf:"propertyOf",propOr:"getOr",unapply:"rest",unnest:"flatten",useWith:"overArgs",whereEq:"filter",zipObj:"zipObject"},e.aryMethod={1:["attempt","castArray","ceil","create","curry","curryRight","floor","fromPairs","invert","iteratee","memoize","method","methodOf","mixin","over","overEvery","overSome","rest","reverse","round","runInContext","spread","template","trim","trimEnd","trimStart","uniqueId","words"], +2:["add","after","ary","assign","assignIn","at","before","bind","bindAll","bindKey","chunk","cloneDeepWith","cloneWith","concat","countBy","curryN","curryRightN","debounce","defaults","defaultsDeep","delay","difference","divide","drop","dropRight","dropRightWhile","dropWhile","endsWith","eq","every","filter","find","find","findIndex","findKey","findLast","findLastIndex","findLastKey","flatMap","flatMapDeep","flattenDepth","forEach","forEachRight","forIn","forInRight","forOwn","forOwnRight","get","groupBy","gt","gte","has","hasIn","includes","indexOf","intersection","invertBy","invoke","invokeMap","isEqual","isMatch","join","keyBy","lastIndexOf","lt","lte","map","mapKeys","mapValues","matchesProperty","maxBy","meanBy","merge","minBy","multiply","omit","omitBy","overArgs","pad","padEnd","padStart","parseInt","partial","partialRight","partition","pick","pickBy","pull","pullAll","pullAt","random","range","rangeRight","rearg","reject","remove","repeat","restFrom","result","sampleSize","some","sortBy","sortedIndex","sortedIndexOf","sortedLastIndex","sortedLastIndexOf","sortedUniqBy","split","spreadFrom","startsWith","subtract","sumBy","take","takeRight","takeRightWhile","takeWhile","tap","throttle","thru","times","trimChars","trimCharsEnd","trimCharsStart","truncate","union","uniqBy","uniqWith","unset","unzipWith","without","wrap","xor","zip","zipObject","zipObjectDeep"], +3:["assignInWith","assignWith","clamp","differenceBy","differenceWith","getOr","inRange","intersectionBy","intersectionWith","invokeArgs","invokeArgsMap","isEqualWith","isMatchWith","flatMapDepth","mergeWith","orderBy","padChars","padCharsEnd","padCharsStart","pullAllBy","pullAllWith","reduce","reduceRight","replace","set","slice","sortedIndexBy","sortedLastIndexBy","transform","unionBy","unionWith","update","xorBy","xorWith","zipWith"],4:["fill","setWith","updateWith"]},e.aryRearg={2:[1,0],3:[2,0,1], +4:[3,2,0,1]},e.iterateeAry={dropRightWhile:1,dropWhile:1,every:1,filter:1,find:1,findIndex:1,findKey:1,findLast:1,findLastIndex:1,findLastKey:1,flatMap:1,flatMapDeep:1,flatMapDepth:1,forEach:1,forEachRight:1,forIn:1,forInRight:1,forOwn:1,forOwnRight:1,map:1,mapKeys:1,mapValues:1,partition:1,reduce:2,reduceRight:2,reject:1,remove:1,some:1,takeRightWhile:1,takeWhile:1,times:1,transform:2},e.iterateeRearg={mapKeys:[1]},e.methodRearg={assignInWith:[1,2,0],assignWith:[1,2,0],getOr:[2,1,0],isEqualWith:[1,2,0], +isMatchWith:[2,1,0],mergeWith:[1,2,0],padChars:[2,1,0],padCharsEnd:[2,1,0],padCharsStart:[2,1,0],pullAllBy:[2,1,0],pullAllWith:[2,1,0],setWith:[3,1,2,0],sortedIndexBy:[2,1,0],sortedLastIndexBy:[2,1,0],updateWith:[3,1,2,0],zipWith:[1,2,0]},e.methodSpread={invokeArgs:2,invokeArgsMap:2,partial:1,partialRight:1,without:1},e.mutate={array:{fill:!0,pull:!0,pullAll:!0,pullAllBy:!0,pullAllWith:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignIn:!0,assignInWith:!0,assignWith:!0,defaults:!0,defaultsDeep:!0, +merge:!0,mergeWith:!0},set:{set:!0,setWith:!0,unset:!0,update:!0,updateWith:!0}},e.placeholder={bind:!0,bindKey:!0,curry:!0,curryRight:!0,partial:!0,partialRight:!0},e.realToAlias=function(){var t=Object.prototype.hasOwnProperty,r=e.aliasToReal,n={};for(var a in r){var i=r[a];t.call(n,i)?n[i].push(a):n[i]=[a]}return n}(),e.remap={curryN:"curry",curryRightN:"curryRight",getOr:"get",invokeArgs:"invoke",invokeArgsMap:"invokeMap",padChars:"pad",padCharsEnd:"padEnd",padCharsStart:"padStart",restFrom:"rest", +spreadFrom:"spread",trimChars:"trim",trimCharsEnd:"trimEnd",trimCharsStart:"trimStart"},e.skipRearg={add:!0,assign:!0,assignIn:!0,bind:!0,bindKey:!0,concat:!0,difference:!0,divide:!0,eq:!0,gt:!0,gte:!0,isEqual:!0,lt:!0,lte:!0,matchesProperty:!0,merge:!0,multiply:!0,partial:!0,partialRight:!0,random:!0,range:!0,rangeRight:!0,subtract:!0,without:!0,zip:!0,zipObject:!0}}])}); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index cab4e798f6..6387c6ba2e 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1,11 +1,11 @@ /** * @license - * lodash 4.6.1 (Custom Build) + * lodash 4.7.0 (Custom Build) * Build: `lodash -o ./dist/lodash.js` - * Copyright 2012-2016 The Dojo Foundation + * Copyright jQuery Foundation and other contributors + * Released under MIT license * Based on Underscore.js 1.8.3 - * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ ;(function() { @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.6.1'; + var VERSION = '4.7.0'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -78,6 +78,7 @@ mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', + promiseTag = '[object Promise]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', @@ -86,6 +87,7 @@ weakSetTag = '[object WeakSet]'; var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', @@ -144,7 +146,7 @@ /** Used to detect binary string values. */ var reIsBinary = /^0b[01]+$/i; - /** Used to detect host constructors (Safari > 5). */ + /** Used to detect host constructors (Safari). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; /** Used to detect octal string values. */ @@ -228,15 +230,15 @@ ].join('|'), 'g'); /** Used to detect strings that need a more robust regexp to match words. */ - var reHasComplexWord = /[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; /** Used to assign default `context` object properties. */ var contextProps = [ - 'Array', 'Buffer', 'Date', 'Error', 'Float32Array', 'Float64Array', + 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', - 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', - 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', '_', - 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' + 'Promise', 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', + 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' ]; /** Used to make template sourceURLs easier to identify. */ @@ -251,25 +253,26 @@ typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = - typedArrayTags[dateTag] = typedArrayTags[errorTag] = - typedArrayTags[funcTag] = typedArrayTags[mapTag] = - typedArrayTags[numberTag] = typedArrayTags[objectTag] = - typedArrayTags[regexpTag] = typedArrayTags[setTag] = - typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = + typedArrayTags[errorTag] = typedArrayTags[funcTag] = + typedArrayTags[mapTag] = typedArrayTags[numberTag] = + typedArrayTags[objectTag] = typedArrayTags[regexpTag] = + typedArrayTags[setTag] = typedArrayTags[stringTag] = + typedArrayTags[weakMapTag] = false; /** Used to identify `toStringTag` values supported by `_.clone`. */ var cloneableTags = {}; cloneableTags[argsTag] = cloneableTags[arrayTag] = - cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = - cloneableTags[dateTag] = cloneableTags[float32Tag] = - cloneableTags[float64Tag] = cloneableTags[int8Tag] = - cloneableTags[int16Tag] = cloneableTags[int32Tag] = - cloneableTags[mapTag] = cloneableTags[numberTag] = - cloneableTags[objectTag] = cloneableTags[regexpTag] = - cloneableTags[setTag] = cloneableTags[stringTag] = - cloneableTags[symbolTag] = cloneableTags[uint8Tag] = - cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = - cloneableTags[uint32Tag] = true; + cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = + cloneableTags[boolTag] = cloneableTags[dateTag] = + cloneableTags[float32Tag] = cloneableTags[float64Tag] = + cloneableTags[int8Tag] = cloneableTags[int16Tag] = + cloneableTags[int32Tag] = cloneableTags[mapTag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[setTag] = + cloneableTags[stringTag] = cloneableTags[symbolTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; @@ -514,7 +517,8 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. */ function arrayEvery(array, predicate) { var index = -1, @@ -633,7 +637,8 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduce(array, iteratee, accumulator, initAccum) { @@ -657,7 +662,8 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the last element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as + * the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduceRight(array, iteratee, accumulator, initAccum) { @@ -678,7 +684,8 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. */ function arraySome(array, predicate) { var index = -1, @@ -730,7 +737,8 @@ * @param {Array|Object} collection The collection to search. * @param {Function} predicate The function invoked per iteration. * @param {Function} eachFunc The function to iterate over `collection`. - * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself. + * @param {boolean} [retKey] Specify returning the key of the found element + * instead of the element itself. * @returns {*} Returns the found element or its key, else `undefined`. */ function baseFind(collection, predicate, eachFunc, retKey) { @@ -812,6 +820,20 @@ return -1; } + /** + * The base implementation of `_.mean` and `_.meanBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the mean. + */ + function baseMean(array, iteratee) { + var length = array ? array.length : 0; + return length ? (baseSum(array, iteratee) / length) : NAN; + } + /** * The base implementation of `_.reduce` and `_.reduceRight`, without support * for iteratee shorthands, which iterates over `collection` using `eachFunc`. @@ -820,7 +842,8 @@ * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ @@ -854,7 +877,8 @@ } /** - * The base implementation of `_.sum` without support for iteratee shorthands. + * The base implementation of `_.sum` and `_.sumBy` without support for + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -1051,7 +1075,7 @@ // for more details. // // This also ensures a stable sort in V8 and other engines. - // See https://code.google.com/p/v8/issues/detail?id=90 for more details. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. return object.index - other.index; } @@ -1075,6 +1099,29 @@ return result; } + /** + * Creates a function that performs a mathematical operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @returns {Function} Returns the new mathematical operation function. + */ + function createMathOperation(operator) { + return function(value, other) { + var result; + if (value === undefined && other === undefined) { + return 0; + } + if (value !== undefined) { + result = value; + } + if (other !== undefined) { + result = result === undefined ? other : operator(result, other); + } + return result; + }; + } + /** * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. * @@ -1286,6 +1333,7 @@ * * @static * @memberOf _ + * @since 1.1.0 * @category Util * @param {Object} [context=root] The context object. * @returns {Function} Returns a new `lodash` function. @@ -1364,7 +1412,6 @@ Uint8Array = context.Uint8Array, clearTimeout = context.clearTimeout, enumerate = Reflect ? Reflect.enumerate : undefined, - getPrototypeOf = Object.getPrototypeOf, getOwnPropertySymbols = Object.getOwnPropertySymbols, iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined, objectCreate = Object.create, @@ -1375,6 +1422,7 @@ /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeCeil = Math.ceil, nativeFloor = Math.floor, + nativeGetPrototype = Object.getPrototypeOf, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = Object.keys, @@ -1385,7 +1433,9 @@ nativeReverse = arrayProto.reverse; /* Built-in method references that are verified to be native. */ - var Map = getNative(context, 'Map'), + var DataView = getNative(context, 'DataView'), + Map = getNative(context, 'Map'), + Promise = getNative(context, 'Promise'), Set = getNative(context, 'Set'), WeakMap = getNative(context, 'WeakMap'), nativeCreate = getNative(Object, 'create'); @@ -1400,7 +1450,9 @@ var realNames = {}; /** Used to detect maps, sets, and weakmaps. */ - var mapCtorString = Map ? funcToString.call(Map) : '', + var dataViewCtorString = DataView ? (DataView + '') : '', + mapCtorString = Map ? funcToString.call(Map) : '', + promiseCtorString = Promise ? funcToString.call(Promise) : '', setCtorString = Set ? funcToString.call(Set) : '', weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : ''; @@ -1413,25 +1465,25 @@ /** * Creates a `lodash` object which wraps `value` to enable implicit method - * chaining. Methods that operate on and return arrays, collections, and - * functions can be chained together. Methods that retrieve a single value or - * may return a primitive value will automatically end the chain sequence and - * return the unwrapped value. Otherwise, the value must be unwrapped with - * `_#value`. + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. * - * Explicit chaining, which must be unwrapped with `_#value` in all cases, - * may be enabled using `_.chain`. + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. * * The execution of chained methods is lazy, that is, it's deferred until * `_#value` is implicitly or explicitly called. * - * Lazy evaluation allows several methods to support shortcut fusion. Shortcut - * fusion is an optimization to merge iteratee calls; this avoids the creation - * of intermediate arrays and can greatly reduce the number of iteratee executions. - * Sections of a chain sequence qualify for shortcut fusion if the section is - * applied to an array of at least two hundred elements and any iteratees - * accept only one argument. The heuristic for whether a section qualifies - * for shortcut fusion is subject to change. + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array of at least two hundred + * elements and any iteratees accept only one argument. The heuristic for + * whether a section qualifies for shortcut fusion is subject to change. * * Chaining is supported in custom builds as long as the `_#value` method is * directly or indirectly included in the build. @@ -1456,48 +1508,49 @@ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, - * `flatten`, `flattenDeep`, `flattenDepth`, `flip`, `flow`, `flowRight`, - * `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, `intersection`, - * `intersectionBy`, `intersectionWith`, `invert`, `invertBy`, `invokeMap`, - * `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, - * `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, - * `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, - * `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`, - * `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, - * `pullAll`, `pullAllBy`, `pullAllWith`, `pullAt`, `push`, `range`, - * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`, - * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`, - * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, - * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, - * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, - * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `update`, `values`, - * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, - * `zipObjectDeep`, and `zipWith` + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, - * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `each`, `eachRight`, - * `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, `floor`, - * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, - * `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, `includes`, - * `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, `isArrayBuffer`, - * `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, `isDate`, - * `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`, - * `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, `isMatchWith`, - * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, - * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isSet`, `isString`, - * `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, - * `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, - * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, - * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, - * `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`, - * `template`, `times`, `toInteger`, `toJSON`, `toLength`, `toLower`, - * `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`, - * `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`, - * `value`, and `words` + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`, + * `eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, + * `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, + * `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, + * `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, + * `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, + * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, + * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, + * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, + * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, + * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, + * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, + * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, + * `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`, + * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, + * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, + * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toInteger`, + * `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, `toString`, + * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, + * `uniqueId`, `upperCase`, `upperFirst`, `value`, and `words` * * @name _ * @constructor @@ -1538,7 +1591,7 @@ } /** - * The function whose prototype all chaining wrappers inherit from. + * The function whose prototype chain sequence wrappers inherit from. * * @private */ @@ -1551,7 +1604,7 @@ * * @private * @param {*} value The value to wrap. - * @param {boolean} [chainAll] Enable chaining for all wrapper methods. + * @param {boolean} [chainAll] Enable explicit method chain sequences. */ function LodashWrapper(value, chainAll) { this.__wrapped__ = value; @@ -1622,6 +1675,13 @@ } }; + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + lodash.prototype.constructor = lodash; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + /*------------------------------------------------------------------------*/ /** @@ -1738,6 +1798,10 @@ return result; } + // Ensure `LazyWrapper` is an instance of `baseLodash`. + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + /*------------------------------------------------------------------------*/ /** @@ -1801,6 +1865,9 @@ hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; } + // Avoid inheriting from `Object.prototype` when possible. + Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; + /*------------------------------------------------------------------------*/ /** @@ -1895,7 +1962,7 @@ * @memberOf MapCache * @param {string} key The key of the value to set. * @param {*} value The value to set. - * @returns {Object} Returns the map cache object. + * @returns {Object} Returns the map cache instance. */ function mapSet(key, value) { var data = this.__data__; @@ -1909,6 +1976,13 @@ return this; } + // Add methods to `MapCache`. + MapCache.prototype.clear = mapClear; + MapCache.prototype['delete'] = mapDelete; + MapCache.prototype.get = mapGet; + MapCache.prototype.has = mapHas; + MapCache.prototype.set = mapSet; + /*------------------------------------------------------------------------*/ /** @@ -1969,6 +2043,9 @@ } } + // Add methods to `SetCache`. + SetCache.prototype.push = cachePush; + /*------------------------------------------------------------------------*/ /** @@ -2056,7 +2133,7 @@ * @memberOf Stack * @param {string} key The key of the value to set. * @param {*} value The value to set. - * @returns {Object} Returns the stack cache object. + * @returns {Object} Returns the stack cache instance. */ function stackSet(key, value) { var data = this.__data__, @@ -2077,13 +2154,20 @@ return this; } + // Add methods to `Stack`. + Stack.prototype.clear = stackClear; + Stack.prototype['delete'] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + /*------------------------------------------------------------------------*/ /** * Removes `key` and its value from the associative array. * * @private - * @param {Array} array The array to query. + * @param {Array} array The array to modify. * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ @@ -2127,8 +2211,7 @@ } /** - * Gets the index at which the first occurrence of `key` is found in `array` - * of key-value pairs. + * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private * @param {Array} array The array to search. @@ -2272,7 +2355,7 @@ * * @private * @param {*} value The value to inspect. - * @returns {Array} Returns the array-like object. + * @returns {Array|Object} Returns the cast array-like object. */ function baseCastArrayLikeObject(value) { return isArrayLikeObject(value) ? value : []; @@ -2283,12 +2366,23 @@ * * @private * @param {*} value The value to inspect. - * @returns {Array} Returns the array-like object. + * @returns {Function} Returns cast function. */ function baseCastFunction(value) { return typeof value == 'function' ? value : identity; } + /** + * Casts `value` to a string if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the cast key. + */ + function baseCastKey(key) { + return (typeof key == 'string' || isSymbol(key)) ? key : (key + ''); + } + /** * Casts `value` to a path array if it's not one. * @@ -2365,14 +2459,13 @@ } result = initCloneObject(isFunc ? {} : value); if (!isDeep) { - result = baseAssign(result, value); - return isFull ? copySymbols(value, result) : result; + return copySymbols(value, baseAssign(result, value)); } } else { if (!cloneableTags[tag]) { return object ? value : {}; } - result = initCloneByTag(value, tag, isDeep); + result = initCloneByTag(value, tag, baseClone, isDeep); } } // Check for circular references and return its corresponding clone. @@ -2383,11 +2476,18 @@ } stack.set(value, result); + if (!isArr) { + var props = isFull ? getAllKeys(value) : keys(value); + } // Recursively populate clone (susceptible to call stack limits). - (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); }); - return (isFull && !isArr) ? copySymbols(value, result) : result; + return result; } /** @@ -2411,7 +2511,8 @@ predicate = source[key], value = object[key]; - if ((value === undefined && !(key in Object(object))) || !predicate(value)) { + if ((value === undefined && + !(key in Object(object))) || !predicate(value)) { return false; } } @@ -2449,8 +2550,8 @@ } /** - * The base implementation of methods like `_.difference` without support for - * excluding multiple arrays or iteratee shorthands. + * The base implementation of methods like `_.difference` without support + * for excluding multiple arrays or iteratee shorthands. * * @private * @param {Array} array The array to inspect. @@ -2529,7 +2630,8 @@ * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false` + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` */ function baseEvery(collection, predicate) { var result = true; @@ -2620,10 +2722,9 @@ } /** - * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` invoking `iteratee` for - * each property. Iteratee functions may exit iteration early by explicitly - * returning `false`. + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` invoking `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. * * @private * @param {Object} object The object to iterate over. @@ -2645,18 +2746,6 @@ */ var baseForRight = createBaseFor(true); - /** - * The base implementation of `_.forIn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForIn(object, iteratee) { - return object == null ? object : baseFor(object, iteratee, keysIn); - } - /** * The base implementation of `_.forOwn` without support for iteratee shorthands. * @@ -2705,7 +2794,7 @@ * @returns {*} Returns the resolved value. */ function baseGet(object, path) { - path = isKey(path, object) ? [path + ''] : baseCastPath(path); + path = isKey(path, object) ? [path] : baseCastPath(path); var index = 0, length = path.length; @@ -2716,6 +2805,24 @@ return (index && index == length) ? object : undefined; } + /** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) + ? result + : arrayPush(result, symbolsFunc(object)); + } + /** * The base implementation of `_.has` without support for deep paths. * @@ -2729,7 +2836,7 @@ // that are composed entirely of index properties, return `false` for // `hasOwnProperty` checks of them. return hasOwnProperty.call(object, key) || - (typeof object == 'object' && key in object && getPrototypeOf(object) === null); + (typeof object == 'object' && key in object && getPrototype(object) === null); } /** @@ -2892,7 +2999,8 @@ * @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 comparisons. - * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ @@ -2925,8 +3033,11 @@ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + stack || (stack = new Stack); - return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack); + return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); } } if (!isSameTag) { @@ -2975,9 +3086,10 @@ return false; } } else { - var stack = new Stack, - result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined; - + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result @@ -2997,14 +3109,15 @@ * @returns {Function} Returns the iteratee. */ function baseIteratee(value) { - var type = typeof value; - if (type == 'function') { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { return value; } if (value == null) { return identity; } - if (type == 'object') { + if (typeof value == 'object') { return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); @@ -3118,16 +3231,16 @@ * @param {Object} source The source object. * @param {number} srcIndex The index of `source`. * @param {Function} [customizer] The function to customize merged values. - * @param {Object} [stack] Tracks traversed source values and their merged counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. */ function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } - var props = (isArray(source) || isTypedArray(source)) - ? undefined - : keysIn(source); - + if (!(isArray(source) || isTypedArray(source))) { + var props = keysIn(source); + } arrayEach(props || source, function(srcValue, key) { if (props) { key = srcValue; @@ -3162,7 +3275,8 @@ * @param {number} srcIndex The index of `source`. * @param {Function} mergeFunc The function to merge values. * @param {Function} [customizer] The function to customize assigned values. - * @param {Object} [stack] Tracks traversed source values and their merged counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. */ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = object[key], @@ -3190,7 +3304,7 @@ } else { isCommon = false; - newValue = baseClone(srcValue, !customizer); + newValue = baseClone(srcValue, true); } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { @@ -3199,7 +3313,7 @@ } else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { isCommon = false; - newValue = baseClone(srcValue, !customizer); + newValue = baseClone(srcValue, true); } else { newValue = objValue; @@ -3230,7 +3344,7 @@ */ function baseOrderBy(collection, iteratees, orders) { var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : Array(1), getIteratee()); + iteratees = arrayMap(iteratees.length ? iteratees : [identity], getIteratee()); var result = baseMap(collection, function(value, key, collection) { var criteria = arrayMap(iteratees, function(iteratee) { @@ -3246,11 +3360,11 @@ /** * The base implementation of `_.pick` without support for individual - * property names. + * property identifiers. * * @private * @param {Object} object The source object. - * @param {string[]} props The property names to pick. + * @param {string[]} props The property identifiers to pick. * @returns {Object} Returns the new object. */ function basePick(object, props) { @@ -3272,12 +3386,19 @@ * @returns {Object} Returns the new object. */ function basePickBy(object, predicate) { - var result = {}; - baseForIn(object, function(value, key) { + var index = -1, + props = getAllKeysIn(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index], + value = object[key]; + if (predicate(value, key)) { result[key] = value; } - }); + } return result; } @@ -3414,6 +3535,34 @@ return result; } + /** + * The base implementation of `_.repeat` which doesn't coerce arguments. + * + * @private + * @param {string} string The string to repeat. + * @param {number} n The number of times to repeat the string. + * @returns {string} Returns the repeated string. + */ + function baseRepeat(string, n) { + var result = ''; + if (!string || n < 1 || n > MAX_SAFE_INTEGER) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = nativeFloor(n / 2); + if (n) { + string += string; + } + } while (n); + + return result; + } + /** * The base implementation of `_.set`. * @@ -3425,7 +3574,7 @@ * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { - path = isKey(path, object) ? [path + ''] : baseCastPath(path); + path = isKey(path, object) ? [path] : baseCastPath(path); var index = -1, length = path.length, @@ -3501,7 +3650,8 @@ * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. */ function baseSome(collection, predicate) { var result; @@ -3555,7 +3705,8 @@ * @param {*} value The value to evaluate. * @param {Function} iteratee The iteratee invoked per element. * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. */ function baseSortedIndexBy(array, value, iteratee, retHighest) { value = iteratee(value); @@ -3702,7 +3853,7 @@ * @returns {boolean} Returns `true` if the property is deleted, else `false`. */ function baseUnset(object, path) { - path = isKey(path, object) ? [path + ''] : baseCastPath(path); + path = isKey(path, object) ? [path] : baseCastPath(path); object = parent(object, path); var key = last(path); return (object != null && has(object, key)) ? delete object[key] : true; @@ -3794,7 +3945,7 @@ * This base implementation of `_.zipObject` which assigns values using `assignFunc`. * * @private - * @param {Array} props The property names. + * @param {Array} props The property identifiers. * @param {Array} values The property values. * @param {Function} assignFunc The function to assign values. * @returns {Object} Returns the new object. @@ -3806,7 +3957,8 @@ result = {}; while (++index < length) { - assignFunc(result, props[index], index < valsLength ? values[index] : undefined); + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); } return result; } @@ -3841,15 +3993,31 @@ return result; } + /** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ + function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); + } + /** * Creates a clone of `map`. * * @private * @param {Object} map The map to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned map. */ - function cloneMap(map) { - return arrayReduce(mapToArray(map), addMapEntry, new map.constructor); + function cloneMap(map, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map); + return arrayReduce(array, addMapEntry, new map.constructor); } /** @@ -3870,10 +4038,13 @@ * * @private * @param {Object} set The set to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned set. */ - function cloneSet(set) { - return arrayReduce(setToArray(set), addSetEntry, new set.constructor); + function cloneSet(set, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set); + return arrayReduce(array, addSetEntry, new set.constructor); } /** @@ -3996,7 +4167,7 @@ * * @private * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. + * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @returns {Object} Returns `object`. */ @@ -4010,7 +4181,7 @@ * * @private * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. + * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. @@ -4125,7 +4296,7 @@ } /** - * Creates a base function for methods like `_.forIn`. + * Creates a base function for methods like `_.forIn` and `_.forOwn`. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. @@ -4154,7 +4325,8 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {*} [thisArg] The `this` binding of `func`. * @returns {Function} Returns the new wrapped function. */ @@ -4242,7 +4414,8 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {number} arity The arity of `func`. * @returns {Function} Returns the new wrapped function. */ @@ -4314,7 +4487,9 @@ ) { wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); } else { - wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func); + wrapper = (func.length == 1 && isLaziable(func)) + ? wrapper[funcName]() + : wrapper.thru(func); } } return function() { @@ -4342,11 +4517,14 @@ * * @private * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to the new function. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [partialsRight] The arguments to append to those provided to the new function. + * @param {Array} [partialsRight] The arguments to append to those provided + * to the new function. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. * @param {number} [ary] The arity cap of `func`. @@ -4445,25 +4623,21 @@ * is truncated if the number of characters exceeds `length`. * * @private - * @param {string} string The string to create padding for. - * @param {number} [length=0] The padding length. + * @param {number} length The padding length. * @param {string} [chars=' '] The string used as padding. * @returns {string} Returns the padding for `string`. */ - function createPadding(string, length, chars) { - length = toInteger(length); - - var strLength = stringSize(string); - if (!length || strLength >= length) { - return ''; - } - var padLength = length - strLength; + function createPadding(length, chars) { chars = chars === undefined ? ' ' : (chars + ''); - var result = repeat(chars, nativeCeil(padLength / stringSize(chars))); + var charsLength = chars.length; + if (charsLength < 2) { + return charsLength ? baseRepeat(chars, length) : chars; + } + var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); return reHasComplexSymbol.test(chars) - ? stringToArray(result).slice(0, padLength).join('') - : result.slice(0, padLength); + ? stringToArray(result).slice(0, length).join('') + : result.slice(0, length); } /** @@ -4473,9 +4647,11 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {*} thisArg The `this` binding of `func`. - * @param {Array} partials The arguments to prepend to those provided to the new function. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. * @returns {Function} Returns the new wrapped function. */ function createPartialWrapper(func, bitmask, thisArg, partials) { @@ -4532,11 +4708,13 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {Function} wrapFunc The function to create the `func` wrapper. * @param {*} placeholder The placeholder value. * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to the new function. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. * @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. * @param {number} [ary] The arity cap of `func`. @@ -4695,7 +4873,8 @@ * @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 comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ @@ -4737,12 +4916,16 @@ // Recursively compare arrays (susceptible to call stack limits). if (isUnordered) { if (!arraySome(other, function(othValue) { - return arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack); + return arrValue === othValue || + equalFunc(arrValue, othValue, customizer, bitmask, stack); })) { result = false; break; } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, customizer, bitmask, stack) + )) { result = false; break; } @@ -4764,12 +4947,21 @@ * @param {string} tag The `toStringTag` of the objects to compare. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) { switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + case arrayBufferTag: if ((object.byteLength != other.byteLength) || !equalFunc(new Uint8Array(object), new Uint8Array(other))) { @@ -4779,8 +4971,9 @@ case boolTag: case dateTag: - // Coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + // Coerce dates and booleans to numbers, dates to milliseconds and + // booleans to `1` or `0` treating invalid dates coerced to `NaN` as + // not equal. return +object == +other; case errorTag: @@ -4792,8 +4985,8 @@ case regexpTag: case stringTag: - // Coerce regexes to strings and treat strings primitives and string - // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See https://es5.github.io/#x15.10.6.4 for more details. return object == (other + ''); case mapTag: @@ -4811,8 +5004,11 @@ if (stacked) { return stacked == other; } + bitmask |= UNORDERED_COMPARE_FLAG; + stack.set(object, other); + // Recursively compare objects (susceptible to call stack limits). - return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other)); + return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); case symbolTag: if (symbolValueOf) { @@ -4831,7 +5027,8 @@ * @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 comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ @@ -4897,6 +5094,29 @@ return result; } + /** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); + } + + /** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); + } + /** * Gets metadata for `func`. * @@ -4950,8 +5170,9 @@ /** * Gets the "length" property value of `object`. * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. + * **Note:** This function is used to avoid a + * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects + * Safari on at least iOS 8.1-8.3 ARM64. * * @private * @param {Object} object The object to query. @@ -5002,14 +5223,51 @@ } /** - * Creates an array of the own symbol properties of `object`. + * Gets the `[[Prototype]]` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {null|Object} Returns the `[[Prototype]]`. + */ + function getPrototype(value) { + return nativeGetPrototype(Object(value)); + } + + /** + * Creates an array of the own enumerable symbol properties of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ - var getSymbols = getOwnPropertySymbols || function() { - return []; + function getSymbols(object) { + // Coerce `object` to an object to avoid non-object errors in V8. + // See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details. + return getOwnPropertySymbols(Object(object)); + } + + // Fallback for IE < 11. + if (!getOwnPropertySymbols) { + getSymbols = function() { + return []; + }; + } + + /** + * Creates an array of the own and inherited enumerable symbol properties + * of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbolsIn = !getOwnPropertySymbols ? getSymbols : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; }; /** @@ -5023,8 +5281,11 @@ return objectToString.call(value); } - // Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps. - if ((Map && getTag(new Map) != mapTag) || + // Fallback for data views, maps, sets, and weak maps in IE 11, + // for data views in Edge, and promises in Node.js. + if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || (Set && getTag(new Set) != setTag) || (WeakMap && getTag(new WeakMap) != weakMapTag)) { getTag = function(value) { @@ -5034,7 +5295,9 @@ if (ctorString) { switch (ctorString) { + case dataViewCtorString: return dataViewTag; case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; case setCtorString: return setTag; case weakMapCtorString: return weakMapTag; } @@ -5087,10 +5350,16 @@ var result = hasFunc(object, path); if (!result && !isKey(path)) { path = baseCastPath(path); - object = parent(object, path); - if (object != null) { - path = last(path); - result = hasFunc(object, path); + + var index = -1, + length = path.length; + + while (object != null && ++index < length) { + var key = path[index]; + if (!(result = hasFunc(object, key))) { + break; + } + object = object[key]; } } var length = object ? object.length : undefined; @@ -5128,7 +5397,7 @@ */ function initCloneObject(object) { return (typeof object.constructor == 'function' && !isPrototype(object)) - ? baseCreate(getPrototypeOf(object)) + ? baseCreate(getPrototype(object)) : {}; } @@ -5141,10 +5410,11 @@ * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringTag` of the object to clone. + * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the initialized clone. */ - function initCloneByTag(object, tag, isDeep) { + function initCloneByTag(object, tag, cloneFunc, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: @@ -5154,13 +5424,16 @@ case dateTag: return new Ctor(+object); + case dataViewTag: + return cloneDataView(object, isDeep); + case float32Tag: case float64Tag: case int8Tag: case int16Tag: case int32Tag: case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: return cloneTypedArray(object, isDeep); case mapTag: - return cloneMap(object); + return cloneMap(object, isDeep, cloneFunc); case numberTag: case stringTag: @@ -5170,7 +5443,7 @@ return cloneRegExp(object); case setTag: - return cloneSet(object); + return cloneSet(object, isDeep, cloneFunc); case symbolTag: return cloneSymbol(object); @@ -5201,7 +5474,8 @@ * @param {*} value The potential iteratee value argument. * @param {*} index The potential iteratee index or key argument. * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. */ function isIterateeCall(value, index, object) { if (!isObject(object)) { @@ -5209,8 +5483,9 @@ } var type = typeof index; if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object)) { + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { return eq(object[index], value); } return false; @@ -5225,11 +5500,12 @@ * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ function isKey(value, object) { - if (typeof value == 'number') { + var type = typeof value; + if (type == 'number' || type == 'symbol') { return true; } return !isArray(value) && - (reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) || (object != null && value in Object(object))); } @@ -5251,7 +5527,8 @@ * * @private * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, + * else `false`. */ function isLaziable(func) { var funcName = getFuncName(func), @@ -5298,10 +5575,11 @@ * * Merging metadata reduces the number of wrappers used to invoke a function. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` - * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg` - * modify function arguments, making the order in which they are executed important, - * preventing the merging of metadata. However, we make an exception for a safe - * combined case where curried functions have `_.ary` and or `_.rearg` applied. + * may be applied regardless of execution order. Methods like `_.ary` and + * `_.rearg` modify function arguments, making the order in which they are + * executed important, preventing the merging of metadata. However, we make + * an exception for a safe combined case where curried functions have `_.ary` + * and or `_.rearg` applied. * * @private * @param {Array} data The destination metadata. @@ -5372,7 +5650,8 @@ * @param {string} key The key of the property to merge. * @param {Object} object The parent object of `objValue`. * @param {Object} source The parent object of `srcValue`. - * @param {Object} [stack] Tracks traversed source values and their merged counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. * @returns {*} Returns the value to assign. */ function mergeDefaults(objValue, srcValue, key, object, source, stack) { @@ -5391,7 +5670,7 @@ * @returns {*} Returns the parent value. */ function parent(object, path) { - return path.length == 1 ? object : get(object, baseSlice(path, 0, -1)); + return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); } /** @@ -5420,8 +5699,9 @@ * Sets metadata for `func`. * * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity function - * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070) + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) * for more details. * * @private @@ -5456,13 +5736,13 @@ * @param {string} string The string to convert. * @returns {Array} Returns the property path array. */ - function stringToPath(string) { + var stringToPath = memoize(function(string) { var result = []; toString(string).replace(rePropName, function(match, number, quote, string) { result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); }); return result; - } + }); /** * Creates a clone of `wrapper`. @@ -5491,6 +5771,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to process. * @param {number} [size=0] The length of each chunk. @@ -5526,6 +5807,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to compact. * @returns {Array} Returns the new array of filtered values. @@ -5555,6 +5837,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to concatenate. * @param {...*} [values] The values to concatenate. @@ -5570,22 +5853,29 @@ * console.log(array); * // => [1] */ - var concat = rest(function(array, values) { - if (!isArray(array)) { - array = array == null ? [] : [Object(array)]; + function concat() { + var length = arguments.length, + array = castArray(arguments[0]); + + if (length < 2) { + return length ? copyArray(array) : []; } - values = baseFlatten(values, 1); - return arrayConcat(array, values); - }); + var args = Array(length - 1); + while (length--) { + args[length - 1] = arguments[length]; + } + return arrayConcat(array, baseFlatten(args, 1)); + } /** - * Creates an array of unique `array` values not included in the other - * given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * Creates an array of unique `array` values not included in the other given + * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * for equality comparisons. The order of result values is determined by the * order they occur in the first array. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to inspect. * @param {...Array} [values] The values to exclude. @@ -5609,10 +5899,12 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {...Array} [values] The values to exclude. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of filtered values. * @example * @@ -5641,6 +5933,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {...Array} [values] The values to exclude. @@ -5668,10 +5961,11 @@ * * @static * @memberOf _ + * @since 0.5.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -5701,10 +5995,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -5737,9 +6032,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -5777,9 +6074,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -5818,6 +6117,7 @@ * * @static * @memberOf _ + * @since 3.2.0 * @category Array * @param {Array} array The array to fill. * @param {*} value The value to fill `array` with. @@ -5856,9 +6156,11 @@ * * @static * @memberOf _ + * @since 1.1.0 * @category Array * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {number} Returns the index of the found element, else `-1`. * @example * @@ -5895,9 +6197,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Array * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {number} Returns the index of the found element, else `-1`. * @example * @@ -5933,6 +6237,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. @@ -5951,6 +6256,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. @@ -5969,6 +6275,7 @@ * * @static * @memberOf _ + * @since 4.4.0 * @category Array * @param {Array} array The array to flatten. * @param {number} [depth=1] The maximum recursion depth. @@ -5998,6 +6305,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} pairs The key-value pairs. * @returns {Object} Returns the new object. @@ -6023,6 +6331,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @alias first * @category Array * @param {Array} array The array to query. @@ -6047,6 +6356,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6078,6 +6388,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to query. * @returns {Array} Returns the slice of `array`. @@ -6098,6 +6409,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of intersecting values. @@ -6121,9 +6433,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of intersecting values. * @example * @@ -6156,6 +6470,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -6187,6 +6502,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to convert. * @param {string} [separator=','] The element separator. @@ -6205,6 +6521,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to query. * @returns {*} Returns the last element of `array`. @@ -6224,6 +6541,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6246,7 +6564,11 @@ var index = length; if (fromIndex !== undefined) { index = toInteger(fromIndex); - index = (index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1)) + 1; + index = ( + index < 0 + ? nativeMax(length + index, 0) + : nativeMin(index, length - 1) + ) + 1; } if (value !== value) { return indexOfNaN(array, index, true); @@ -6269,6 +6591,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Array * @param {Array} array The array to modify. * @param {...*} [values] The values to remove. @@ -6290,6 +6613,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. @@ -6317,10 +6641,12 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns `array`. * @example * @@ -6345,6 +6671,7 @@ * * @static * @memberOf _ + * @since 4.6.0 * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. @@ -6372,6 +6699,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to modify. * @param {...(number|number[])} [indexes] The indexes of elements to remove, @@ -6406,9 +6734,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Array * @param {Array} array The array to modify. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new array of removed elements. * @example * @@ -6453,7 +6783,9 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array + * @param {Array} array The array to modify. * @returns {Array} Returns `array`. * @example * @@ -6472,11 +6804,13 @@ /** * Creates a slice of `array` from `start` up to, but not including, `end`. * - * **Note:** This method is used instead of [`Array#slice`](https://mdn.io/Array/slice) - * to ensure dense arrays are returned. + * **Note:** This method is used instead of + * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are + * returned. * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to slice. * @param {number} [start=0] The start position. @@ -6500,15 +6834,17 @@ } /** - * Uses a binary search to determine the lowest index at which `value` should - * be inserted into `array` in order to maintain its sort order. + * Uses a binary search to determine the lowest index at which `value` + * should be inserted into `array` in order to maintain its sort order. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * _.sortedIndex([30, 50], 40); @@ -6528,11 +6864,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 }; @@ -6554,6 +6893,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6581,10 +6921,12 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * _.sortedLastIndex([4, 5], 4); @@ -6601,11 +6943,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * // The `_.property` iteratee shorthand. @@ -6622,6 +6967,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6648,6 +6994,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @returns {Array} Returns the new duplicate free array. @@ -6668,6 +7015,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {Function} [iteratee] The iteratee invoked per element. @@ -6688,6 +7036,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to query. * @returns {Array} Returns the slice of `array`. @@ -6705,10 +7054,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -6737,10 +7087,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -6768,14 +7119,16 @@ /** * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is invoked with three - * arguments: (value, index, array). + * taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -6813,9 +7166,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -6853,6 +7208,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of combined values. @@ -6867,14 +7223,17 @@ /** * This method is like `_.union` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by which - * uniqueness is computed. The iteratee is invoked with one argument: (value). + * invoked for each element of each `arrays` to generate the criterion by + * which uniqueness is computed. The iteratee is invoked with one argument: + * (value). * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of combined values. * @example * @@ -6900,6 +7259,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -6923,11 +7283,12 @@ /** * Creates a duplicate-free version of an array, using * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurrence of each element - * is kept. + * for equality comparisons, in which only the first occurrence of each + * element is kept. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to inspect. * @returns {Array} Returns the new duplicate free array. @@ -6949,9 +7310,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new duplicate free array. * @example * @@ -6975,6 +7338,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -6999,6 +7363,7 @@ * * @static * @memberOf _ + * @since 1.2.0 * @category Array * @param {Array} array The array of grouped elements to process. * @returns {Array} Returns the new array of regrouped elements. @@ -7033,9 +7398,11 @@ * * @static * @memberOf _ + * @since 3.8.0 * @category Array * @param {Array} array The array of grouped elements to process. - * @param {Function} [iteratee=_.identity] The function to combine regrouped values. + * @param {Function} [iteratee=_.identity] The function to combine + * regrouped values. * @returns {Array} Returns the new array of regrouped elements. * @example * @@ -7065,6 +7432,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to filter. * @param {...*} [values] The values to exclude. @@ -7081,12 +7449,14 @@ }); /** - * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * Creates an array of unique values that is the + * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) * of the given arrays. The order of result values is determined by the order * they occur in the arrays. * * @static * @memberOf _ + * @since 2.4.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of values. @@ -7101,14 +7471,17 @@ /** * This method is like `_.xor` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by which - * by which they're compared. The iteratee is invoked with one argument: (value). + * invoked for each element of each `arrays` to generate the criterion by + * which by which they're compared. The iteratee is invoked with one argument: + * (value). * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of values. * @example * @@ -7134,6 +7507,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -7155,12 +7529,13 @@ }); /** - * Creates an array of grouped elements, the first of which contains the first - * elements of the given arrays, the second of which contains the second elements - * of the given arrays, and so on. + * Creates an array of grouped elements, the first of which contains the + * first elements of the given arrays, the second of which contains the + * second elements of the given arrays, and so on. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {...Array} [arrays] The arrays to process. * @returns {Array} Returns the new array of grouped elements. @@ -7173,12 +7548,13 @@ /** * This method is like `_.fromPairs` except that it accepts two arrays, - * one of property names and one of corresponding values. + * one of property identifiers and one of corresponding values. * * @static * @memberOf _ + * @since 0.4.0 * @category Array - * @param {Array} [props=[]] The property names. + * @param {Array} [props=[]] The property identifiers. * @param {Array} [values=[]] The property values. * @returns {Object} Returns the new object. * @example @@ -7195,8 +7571,9 @@ * * @static * @memberOf _ + * @since 4.1.0 * @category Array - * @param {Array} [props=[]] The property names. + * @param {Array} [props=[]] The property identifiers. * @param {Array} [values=[]] The property values. * @returns {Object} Returns the new object. * @example @@ -7215,6 +7592,7 @@ * * @static * @memberOf _ + * @since 3.8.0 * @category Array * @param {...Array} [arrays] The arrays to process. * @param {Function} [iteratee=_.identity] The function to combine grouped values. @@ -7237,11 +7615,13 @@ /*------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps `value` with explicit method chaining enabled. - * The result of such method chaining must be unwrapped with `_#value`. + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. * * @static * @memberOf _ + * @since 1.3.0 * @category Seq * @param {*} value The value to wrap. * @returns {Object} Returns the new `lodash` wrapper instance. @@ -7272,10 +7652,11 @@ /** * This method invokes `interceptor` and returns `value`. The interceptor * is invoked with one argument; (value). The purpose of this method is to - * "tap into" a method chain in order to modify intermediate results. + * "tap into" a method chain sequence in order to modify intermediate results. * * @static * @memberOf _ + * @since 0.1.0 * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. @@ -7299,10 +7680,11 @@ /** * This method is like `_.tap` except that it returns the result of `interceptor`. * The purpose of this method is to "pass thru" values replacing intermediate - * results in a method chain. + * results in a method chain sequence. * * @static * @memberOf _ + * @since 3.0.0 * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. @@ -7327,6 +7709,7 @@ * * @name at * @memberOf _ + * @since 1.0.0 * @category Seq * @param {...(string|string[])} [paths] The property paths of elements to pick, * specified individually or in arrays. @@ -7367,10 +7750,11 @@ }); /** - * Enables explicit method chaining on the wrapper object. + * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. * * @name chain * @memberOf _ + * @since 0.1.0 * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -7397,10 +7781,11 @@ } /** - * Executes the chained sequence and returns the wrapped result. + * Executes the chain sequence and returns the wrapped result. * * @name commit * @memberOf _ + * @since 3.2.0 * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -7425,33 +7810,13 @@ return new LodashWrapper(this.value(), this.__chain__); } - /** - * This method is the wrapper version of `_.flatMap`. - * - * @name flatMap - * @memberOf _ - * @category Seq - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function duplicate(n) { - * return [n, n]; - * } - * - * _([1, 2]).flatMap(duplicate).value(); - * // => [1, 1, 2, 2] - */ - function wrapperFlatMap(iteratee) { - return this.map(iteratee).flatten(); - } - /** * Gets the next value on a wrapped object following the * [iterator protocol](https://mdn.io/iteration_protocols#iterator). * * @name next * @memberOf _ + * @since 4.0.0 * @category Seq * @returns {Object} Returns the next iterator value. * @example @@ -7482,6 +7847,7 @@ * * @name Symbol.iterator * @memberOf _ + * @since 4.0.0 * @category Seq * @returns {Object} Returns the wrapper object. * @example @@ -7499,10 +7865,11 @@ } /** - * Creates a clone of the chained sequence planting `value` as the wrapped value. + * Creates a clone of the chain sequence planting `value` as the wrapped value. * * @name plant * @memberOf _ + * @since 3.2.0 * @category Seq * @param {*} value The value to plant. * @returns {Object} Returns the new `lodash` wrapper instance. @@ -7548,6 +7915,7 @@ * * @name reverse * @memberOf _ + * @since 0.1.0 * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -7579,10 +7947,11 @@ } /** - * Executes the chained sequence to extract the unwrapped value. + * Executes the chain sequence to resolve the unwrapped value. * * @name value * @memberOf _ + * @since 0.1.0 * @alias toJSON, valueOf * @category Seq * @returns {*} Returns the resolved unwrapped value. @@ -7605,9 +7974,11 @@ * * @static * @memberOf _ + * @since 0.5.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7628,19 +7999,22 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. * @example * * _.every([true, 1, null, 'yes'], Boolean); * // => false * * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false } + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * * // The `_.matches` iteratee shorthand. @@ -7665,14 +8039,16 @@ /** * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three arguments: - * (value, index|key, collection). + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @example * @@ -7703,14 +8079,16 @@ /** * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three arguments: - * (value, index|key, collection). + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {*} Returns the matched element, else `undefined`. * @example * @@ -7750,9 +8128,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Collection * @param {Array|Object} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {*} Returns the matched element, else `undefined`. * @example * @@ -7771,15 +8151,17 @@ } /** - * Creates an array of flattened values by running each element in `collection` - * through `iteratee` and concating its result to the other mapped values. - * The iteratee is invoked with three arguments: (value, index|key, collection). + * Creates a flattened array of values by running each element in `collection` + * through `iteratee` and flattening the mapped results. The iteratee is + * invoked with three arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new flattened array. * @example * @@ -7794,17 +8176,70 @@ return baseFlatten(map(collection, iteratee), 1); } + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDeep([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ + function flatMapDeep(collection, iteratee) { + return baseFlatten(map(collection, iteratee), INFINITY); + } + + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results up to `depth` times. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDepth([1, 2], duplicate, 2); + * // => [[1, 1], [2, 2]] + */ + function flatMapDepth(collection, iteratee, depth) { + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(map(collection, iteratee), depth); + } + /** * Iterates over elements of `collection` invoking `iteratee` for each element. * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning `false`. * - * **Note:** As with other "Collections" methods, objects with a "length" property - * are iterated like arrays. To avoid this behavior use `_.forIn` or `_.forOwn` - * for object iteration. + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. * * @static * @memberOf _ + * @since 0.1.0 * @alias each * @category Collection * @param {Array|Object} collection The collection to iterate over. @@ -7815,17 +8250,17 @@ * _([1, 2]).forEach(function(value) { * console.log(value); * }); - * // => logs `1` then `2` + * // => Logs `1` then `2`. * * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { * console.log(key); * }); - * // => logs 'a' then 'b' (iteration order is not guaranteed) + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forEach(collection, iteratee) { return (typeof iteratee == 'function' && isArray(collection)) ? arrayEach(collection, iteratee) - : baseEach(collection, baseCastFunction(iteratee)); + : baseEach(collection, getIteratee(iteratee)); } /** @@ -7834,6 +8269,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @alias eachRight * @category Collection * @param {Array|Object} collection The collection to iterate over. @@ -7844,12 +8280,12 @@ * _.forEachRight([1, 2], function(value) { * console.log(value); * }); - * // => logs `2` then `1` + * // => Logs `2` then `1`. */ function forEachRight(collection, iteratee) { return (typeof iteratee == 'function' && isArray(collection)) ? arrayEachRight(collection, iteratee) - : baseEachRight(collection, baseCastFunction(iteratee)); + : baseEachRight(collection, getIteratee(iteratee)); } /** @@ -7860,9 +8296,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7882,18 +8320,20 @@ }); /** - * Checks if `value` is in `collection`. If `collection` is a string it's checked - * for a substring of `value`, otherwise [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * Checks if `value` is in `collection`. If `collection` is a string it's + * checked for a substring of `value`, otherwise + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * is used for equality comparisons. If `fromIndex` is negative, it's used as * the offset from the end of `collection`. * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object|string} collection The collection to search. * @param {*} value The value to search for. * @param {number} [fromIndex=0] The index to search from. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. * @returns {boolean} Returns `true` if `value` is found, else `false`. * @example * @@ -7930,6 +8370,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Array|Function|string} path The path of the method to invoke or @@ -7965,9 +8406,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -8004,9 +8447,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new mapped array. * @example * @@ -8042,24 +8487,26 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} [iteratees=[_.identity]] The iteratees to sort by. + * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] + * The iteratees to sort by. * @param {string[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. * @returns {Array} Returns the new sorted array. * @example * * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 42 }, + * { 'user': 'fred', 'age': 40 }, * { 'user': 'barney', 'age': 36 } * ]; * * // Sort by `user` in ascending order and by `age` in descending order. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] */ function orderBy(collection, iteratees, orders, guard) { if (collection == null) { @@ -8083,9 +8530,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the array of grouped elements. * @example * @@ -8131,6 +8580,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -8162,6 +8612,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -8189,9 +8640,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @example * @@ -8228,6 +8681,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Collection * @param {Array|Object} collection The collection to sample. * @returns {*} Returns the random element. @@ -8249,6 +8703,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to sample. * @param {number} [n=0] The number of elements to sample. @@ -8285,6 +8740,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to shuffle. * @returns {Array} Returns the new shuffled array. @@ -8299,10 +8755,11 @@ /** * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable properties for objects. + * values or the number of own enumerable string keyed properties for objects. * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to inspect. * @returns {number} Returns the collection size. @@ -8325,6 +8782,12 @@ var result = collection.length; return (result && isString(collection)) ? stringSize(collection) : result; } + if (isObjectLike(collection)) { + var tag = getTag(collection); + if (tag == mapTag || tag == setTag) { + return collection.size; + } + } return keys(collection).length; } @@ -8335,11 +8798,14 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. * @example * * _.some([null, 0, 'yes', false], Boolean); @@ -8378,30 +8844,32 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[]|Object|Object[]|string|string[])} [iteratees=[_.identity]] - * The iteratees to sort by, specified individually or in arrays. + * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])} + * [iteratees=[_.identity]] The iteratees to sort by, specified individually + * or in arrays. * @returns {Array} Returns the new sorted array. * @example * * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 42 }, + * { 'user': 'fred', 'age': 40 }, * { 'user': 'barney', 'age': 34 } * ]; * * _.sortBy(users, function(o) { return o.user; }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] * * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] + * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] * * _.sortBy(users, 'user', function(o) { * return Math.floor(o.age / 10); * }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] */ var sortBy = rest(function(collection, iteratees) { if (collection == null) { @@ -8424,6 +8892,7 @@ * * @static * @memberOf _ + * @since 2.4.0 * @type {Function} * @category Date * @returns {number} Returns the timestamp. @@ -8432,7 +8901,7 @@ * _.defer(function(stamp) { * console.log(_.now() - stamp); * }, _.now()); - * // => logs the number of milliseconds it took for the deferred function to be invoked + * // => Logs the number of milliseconds it took for the deferred function to be invoked. */ var now = Date.now; @@ -8444,6 +8913,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {number} n The number of calls before `func` is invoked. * @param {Function} func The function to restrict. @@ -8459,7 +8929,7 @@ * _.forEach(saves, function(type) { * asyncSave({ 'type': type, 'complete': done }); * }); - * // => logs 'done saving!' after the two async saves have completed + * // => Logs 'done saving!' after the two async saves have completed. */ function after(n, func) { if (typeof func != 'function') { @@ -8479,10 +8949,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} func The function to cap arguments for. * @param {number} [n=func.length] The arity cap. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the new function. * @example * @@ -8502,6 +8973,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {number} n The number of calls at which `func` is no longer invoked. * @param {Function} func The function to restrict. @@ -8541,6 +9013,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to bind. * @param {*} thisArg The `this` binding of `func`. @@ -8577,8 +9050,8 @@ * any additional `_.bindKey` arguments to those provided to the bound function. * * This method differs from `_.bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. - * See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * methods that may be redefined or don't yet exist. See + * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) * for more details. * * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic @@ -8586,6 +9059,7 @@ * * @static * @memberOf _ + * @since 0.10.0 * @category Function * @param {Object} object The object to invoke the method on. * @param {string} key The key of the method. @@ -8639,10 +9113,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -8683,10 +9158,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -8735,16 +9211,17 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to debounce. * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=false] Specify invoking on the leading - * edge of the timeout. - * @param {number} [options.maxWait] The maximum time `func` is allowed to be - * delayed before it's invoked. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. * @returns {Function} Returns the new debounced function. * @example * @@ -8766,14 +9243,12 @@ * jQuery(window).on('popstate', debounced.cancel); */ function debounce(func, wait, options) { - var args, - maxTimeoutId, + var lastArgs, + lastThis, result, - stamp, - thisArg, - timeoutId, - trailingCall, - lastCalled = 0, + timerId, + lastCallTime = 0, + lastInvokeTime = 0, leading = false, maxWait = false, trailing = true; @@ -8788,92 +9263,94 @@ trailing = 'trailing' in options ? !!options.trailing : trailing; } - function cancel() { - if (timeoutId) { - clearTimeout(timeoutId); - } - if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - } - lastCalled = 0; - args = maxTimeoutId = thisArg = timeoutId = trailingCall = undefined; + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; } - function complete(isCalled, id) { - if (id) { - clearTimeout(id); - } - maxTimeoutId = timeoutId = trailingCall = undefined; - if (isCalled) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = undefined; - } - } + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; } - function delayed() { - var remaining = wait - (now() - stamp); - if (remaining <= 0 || remaining > wait) { - complete(trailingCall, maxTimeoutId); - } else { - timeoutId = setTimeout(delayed, remaining); + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + result = wait - timeSinceLastCall; + + return maxWait === false ? result : nativeMin(result, maxWait - timeSinceLastInvoke); + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (!lastCallTime || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxWait !== false && timeSinceLastInvoke >= maxWait)); + } + + function timerExpired() { + var time = now(); + if (shouldInvoke(time)) { + return trailingEdge(time); } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); } - function flush() { - if ((timeoutId && trailingCall) || (maxTimeoutId && trailing)) { - result = func.apply(thisArg, args); + function trailingEdge(time) { + clearTimeout(timerId); + timerId = undefined; + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); } - cancel(); + lastArgs = lastThis = undefined; return result; } - function maxDelayed() { - complete(trailing, timeoutId); + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastCallTime = lastInvokeTime = 0; + lastArgs = lastThis = timerId = undefined; } - function debounced() { - args = arguments; - stamp = now(); - thisArg = this; - trailingCall = trailing && (timeoutId || !leading); + function flush() { + return timerId === undefined ? result : trailingEdge(now()); + } - if (maxWait === false) { - var leadingCall = leading && !timeoutId; - } else { - if (!lastCalled && !maxTimeoutId && !leading) { - lastCalled = stamp; - } - var remaining = maxWait - (stamp - lastCalled); + function debounced() { + var time = now(), + isInvoking = shouldInvoke(time); - var isCalled = (remaining <= 0 || remaining > maxWait) && - (leading || maxTimeoutId); + lastArgs = arguments; + lastThis = this; + lastCallTime = time; - if (isCalled) { - if (maxTimeoutId) { - maxTimeoutId = clearTimeout(maxTimeoutId); - } - lastCalled = stamp; - result = func.apply(thisArg, args); + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); } - else if (!maxTimeoutId) { - maxTimeoutId = setTimeout(maxDelayed, remaining); - } - } - if (isCalled && timeoutId) { - timeoutId = clearTimeout(timeoutId); - } - else if (!timeoutId && wait !== maxWait) { - timeoutId = setTimeout(delayed, wait); - } - if (leadingCall) { - isCalled = true; - result = func.apply(thisArg, args); - } - if (isCalled && !timeoutId && !maxTimeoutId) { - args = thisArg = undefined; + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); } return result; } @@ -8888,6 +9365,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to defer. * @param {...*} [args] The arguments to invoke `func` with. @@ -8897,7 +9375,7 @@ * _.defer(function(text) { * console.log(text); * }, 'deferred'); - * // => logs 'deferred' after one or more milliseconds + * // => Logs 'deferred' after one or more milliseconds. */ var defer = rest(function(func, args) { return baseDelay(func, 1, args); @@ -8909,6 +9387,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. @@ -8919,7 +9398,7 @@ * _.delay(function(text) { * console.log(text); * }, 1000, 'later'); - * // => logs 'later' after one second + * // => Logs 'later' after one second. */ var delay = rest(function(func, wait, args) { return baseDelay(func, toNumber(wait) || 0, args); @@ -8930,6 +9409,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Function * @param {Function} func The function to flip arguments for. * @returns {Function} Returns the new function. @@ -8955,11 +9435,13 @@ * * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) * method interface of `delete`, `get`, `has`, and `set`. * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to have its output memoized. * @param {Function} [resolver] The function to resolve the cache key. @@ -9004,10 +9486,13 @@ memoized.cache = cache.set(key, result); return result; }; - memoized.cache = new memoize.Cache; + memoized.cache = new (memoize.Cache || MapCache); return memoized; } + // Assign cache to `_.memoize`. + memoize.Cache = MapCache; + /** * Creates a function that negates the result of the predicate `func`. The * `func` predicate is invoked with the `this` binding and arguments of the @@ -9015,6 +9500,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} predicate The predicate to negate. * @returns {Function} Returns the new function. @@ -9043,6 +9529,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to restrict. * @returns {Function} Returns the new restricted function. @@ -9062,6 +9549,7 @@ * corresponding `transforms`. * * @static + * @since 4.0.0 * @memberOf _ * @category Function * @param {Function} func The function to wrap. @@ -9116,6 +9604,7 @@ * * @static * @memberOf _ + * @since 0.2.0 * @category Function * @param {Function} func The function to partially apply arguments to. * @param {...*} [partials] The arguments to be partially applied. @@ -9152,6 +9641,7 @@ * * @static * @memberOf _ + * @since 1.0.0 * @category Function * @param {Function} func The function to partially apply arguments to. * @param {...*} [partials] The arguments to be partially applied. @@ -9184,6 +9674,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} func The function to rearrange arguments for. * @param {...(number|number[])} indexes The arranged argument indexes, @@ -9204,12 +9695,15 @@ /** * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as an array. + * created function and arguments from `start` and beyond provided as + * an array. * - * **Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters). + * **Note:** This method is based on the + * [rest parameter](https://mdn.io/rest_parameters). * * @static * @memberOf _ + * @since 4.0.0 * @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. @@ -9254,13 +9748,16 @@ } /** - * 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). + * Creates a function that invokes `func` with the `this` binding of the + * create 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://mdn.io/spread_operator). + * **Note:** This method is based on the + * [spread operator](https://mdn.io/spread_operator). * * @static * @memberOf _ + * @since 3.2.0 * @category Function * @param {Function} func The function to spread arguments over. * @param {number} [start=0] The start position of the spread. @@ -9310,23 +9807,24 @@ * throttled function. Subsequent calls to the throttled function return the * result of the last `func` invocation. * - * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked - * on the trailing edge of the timeout only if the throttled function is - * invoked more than once during the `wait` timeout. + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the throttled function + * is invoked more than once during the `wait` timeout. * * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) * for details over the differences between `_.throttle` and `_.debounce`. * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to throttle. * @param {number} [wait=0] The number of milliseconds to throttle invocations to. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=true] Specify invoking on the leading - * edge of the timeout. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=true] + * Specify invoking on the leading edge of the timeout. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. * @returns {Function} Returns the new throttled function. * @example * @@ -9364,6 +9862,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Function * @param {Function} func The function to cap arguments for. * @returns {Function} Returns the new function. @@ -9384,6 +9883,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {*} value The value to wrap. * @param {Function} [wrapper=identity] The wrapper function. @@ -9409,6 +9909,7 @@ * * @static * @memberOf _ + * @since 4.4.0 * @category Lang * @param {*} value The value to inspect. * @returns {Array} Returns the cast array. @@ -9457,6 +9958,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to clone. * @returns {*} Returns the cloned value. @@ -9480,6 +9982,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to clone. * @param {Function} [customizer] The function to customize cloning. @@ -9510,6 +10013,7 @@ * * @static * @memberOf _ + * @since 1.0.0 * @category Lang * @param {*} value The value to recursively clone. * @returns {*} Returns the deep cloned value. @@ -9530,6 +10034,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to recursively clone. * @param {Function} [customizer] The function to customize cloning. @@ -9556,11 +10061,13 @@ } /** - * Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. @@ -9594,10 +10101,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. * @example * * _.gt(3, 1); @@ -9618,10 +10127,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is greater than or equal to + * `other`, else `false`. * @example * * _.gte(3, 1); @@ -9642,9 +10153,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArguments(function() { return arguments; }()); @@ -9664,10 +10177,12 @@ * * @static * @memberOf _ + * @since 0.1.0 * @type {Function} * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArray([1, 2, 3]); @@ -9689,9 +10204,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArrayBuffer(new ArrayBuffer(2)); @@ -9711,6 +10228,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. @@ -9738,9 +10256,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. * @example * * _.isArrayLikeObject([1, 2, 3]); @@ -9764,9 +10284,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isBoolean(false); @@ -9785,6 +10307,7 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. @@ -9805,9 +10328,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isDate(new Date); @@ -9825,9 +10350,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. + * @returns {boolean} Returns `true` if `value` is a DOM element, + * else `false`. * @example * * _.isElement(document.body); @@ -9841,12 +10368,18 @@ } /** - * Checks if `value` is an empty collection or object. A value is considered - * empty if it's an `arguments` object, array, string, or jQuery-like collection - * with a length of `0` or has no own enumerable properties. + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is empty, else `false`. @@ -9869,16 +10402,22 @@ */ function isEmpty(value) { if (isArrayLike(value) && - (isArray(value) || isString(value) || - isFunction(value.splice) || isArguments(value))) { + (isArray(value) || isString(value) || isFunction(value.splice) || + isArguments(value) || isBuffer(value))) { return !value.length; } + if (isObjectLike(value)) { + var tag = getTag(value); + if (tag == mapTag || tag == setTag) { + return !value.size; + } + } for (var key in value) { if (hasOwnProperty.call(value, key)) { return false; } } - return true; + return !(nonEnumShadows && keys(value).length); } /** @@ -9893,10 +10432,12 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, + * else `false`. * @example * * var object = { 'user': 'fred' }; @@ -9920,11 +10461,13 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, + * else `false`. * @example * * function isGreeting(value) { @@ -9955,9 +10498,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. + * @returns {boolean} Returns `true` if `value` is an error object, + * else `false`. * @example * * _.isError(new Error); @@ -9977,13 +10522,16 @@ /** * Checks if `value` is a finite primitive number. * - * **Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite). + * **Note:** This method is based on + * [`Number.isFinite`](https://mdn.io/Number/isFinite). * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @returns {boolean} Returns `true` if `value` is a finite number, + * else `false`. * @example * * _.isFinite(3); @@ -10007,9 +10555,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isFunction(_); @@ -10029,10 +10579,12 @@ /** * Checks if `value` is an integer. * - * **Note:** This method is based on [`Number.isInteger`](https://mdn.io/Number/isInteger). + * **Note:** This method is based on + * [`Number.isInteger`](https://mdn.io/Number/isInteger). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an integer, else `false`. @@ -10057,13 +10609,16 @@ /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This function is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @returns {boolean} Returns `true` if `value` is a valid length, + * else `false`. * @example * * _.isLength(3); @@ -10089,6 +10644,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. @@ -10117,6 +10673,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. @@ -10143,9 +10700,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isMap(new Map); @@ -10167,6 +10726,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {Object} object The object to inspect. * @param {Object} source The object of property values to match. @@ -10193,6 +10753,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {Object} object The object to inspect. * @param {Object} source The object of property values to match. @@ -10224,11 +10785,13 @@ /** * Checks if `value` is `NaN`. * - * **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4) - * which returns `true` for `undefined` and other non-numeric values. + * **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 _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. @@ -10248,7 +10811,8 @@ */ function isNaN(value) { // An `NaN` primitive is the only value that is not equal to itself. - // Perform the `toStringTag` check first to avoid errors with some ActiveX objects in IE. + // Perform the `toStringTag` check first to avoid errors with some + // ActiveX objects in IE. return isNumber(value) && value != +value; } @@ -10257,9 +10821,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. * @example * * _.isNative(Array.prototype.push); @@ -10284,6 +10850,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `null`, else `false`. @@ -10304,6 +10871,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is nullish, else `false`. @@ -10325,14 +10893,16 @@ /** * Checks if `value` is classified as a `Number` primitive or object. * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified - * as numbers, use the `_.isFinite` method. + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are + * classified as numbers, use the `_.isFinite` method. * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isNumber(3); @@ -10358,9 +10928,11 @@ * * @static * @memberOf _ + * @since 0.8.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @returns {boolean} Returns `true` if `value` is a plain object, + * else `false`. * @example * * function Foo() { @@ -10384,11 +10956,11 @@ objectToString.call(value) != objectTag || isHostObject(value)) { return false; } - var proto = getPrototypeOf(value); + var proto = getPrototype(value); if (proto === null) { return true; } - var Ctor = proto.constructor; + var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; return (typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); } @@ -10398,9 +10970,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isRegExp(/abc/); @@ -10417,13 +10991,16 @@ * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 * double precision number which isn't the result of a rounded unsafe integer. * - * **Note:** This method is based on [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). + * **Note:** This method is based on + * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. + * @returns {boolean} Returns `true` if `value` is a safe integer, + * else `false`. * @example * * _.isSafeInteger(3); @@ -10447,9 +11024,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isSet(new Set); @@ -10466,10 +11045,12 @@ * Checks if `value` is classified as a `String` primitive or object. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isString('abc'); @@ -10488,9 +11069,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isSymbol(Symbol.iterator); @@ -10509,9 +11092,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isTypedArray(new Uint8Array); @@ -10529,6 +11114,7 @@ * Checks if `value` is `undefined`. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. @@ -10550,9 +11136,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isWeakMap(new WeakMap); @@ -10570,9 +11158,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isWeakSet(new WeakSet); @@ -10590,10 +11180,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. * @example * * _.lt(1, 3); @@ -10614,10 +11206,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than or equal to `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is less than or equal to + * `other`, else `false`. * @example * * _.lte(1, 3); @@ -10637,6 +11231,7 @@ * Converts `value` to an array. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to convert. @@ -10674,10 +11269,12 @@ /** * Converts `value` to an integer. * - * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). + * **Note:** This function is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. @@ -10712,10 +11309,12 @@ * Converts `value` to an integer suitable for use as the length of an * array-like object. * - * **Note:** This method is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This method is based on + * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. @@ -10742,6 +11341,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {number} Returns the number. @@ -10760,12 +11360,18 @@ * // => 3 */ function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } if (isObject(value)) { var other = isFunction(value.valueOf) ? value.valueOf() : value; value = isObject(other) ? (other + '') : other; } if (typeof value != 'string') { - return value === 0 ? value : +value; + return value === 0 ? value : +value; } value = value.replace(reTrim, ''); var isBinary = reIsBinary.test(value); @@ -10775,11 +11381,12 @@ } /** - * Converts `value` to a plain object flattening inherited enumerable - * properties of `value` to own properties of the plain object. + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to convert. * @returns {Object} Returns the converted plain object. @@ -10807,6 +11414,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. @@ -10834,6 +11442,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {string} Returns the string. @@ -10866,15 +11475,16 @@ /*------------------------------------------------------------------------*/ /** - * Assigns own enumerable properties of source objects to the destination - * object. Source objects are applied from left to right. Subsequent sources - * overwrite property assignments of previous sources. + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object` and is loosely based on * [`Object.assign`](https://mdn.io/Object/assign). * * @static * @memberOf _ + * @since 0.10.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. @@ -10915,6 +11525,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @alias extend * @category Object * @param {Object} object The destination object. @@ -10947,15 +11558,16 @@ }); /** - * This method is like `_.assignIn` except that it accepts `customizer` which - * is invoked to produce the assigned values. If `customizer` returns `undefined` - * assignment is handled by the method instead. The `customizer` is invoked - * with five arguments: (objValue, srcValue, key, object, source). + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined` assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). * * **Note:** This method mutates `object`. * * @static * @memberOf _ + * @since 4.0.0 * @alias extendWith * @category Object * @param {Object} object The destination object. @@ -10978,15 +11590,16 @@ }); /** - * This method is like `_.assign` except that it accepts `customizer` which - * is invoked to produce the assigned values. If `customizer` returns `undefined` - * assignment is handled by the method instead. The `customizer` is invoked - * with five arguments: (objValue, srcValue, key, object, source). + * This method is like `_.assign` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined` assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). * * **Note:** This method mutates `object`. * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The destination object. * @param {...Object} sources The source objects. @@ -11012,6 +11625,7 @@ * * @static * @memberOf _ + * @since 1.0.0 * @category Object * @param {Object} object The object to iterate over. * @param {...(string|string[])} [paths] The property paths of elements to pick, @@ -11032,11 +11646,13 @@ }); /** - * Creates an object that inherits from the `prototype` object. If a `properties` - * object is given its own enumerable properties are assigned to the created object. + * Creates an object that inherits from the `prototype` object. If a + * `properties` object is given its own enumerable string keyed properties + * are assigned to the created object. * * @static * @memberOf _ + * @since 2.3.0 * @category Object * @param {Object} prototype The object to inherit from. * @param {Object} [properties] The properties to assign to the object. @@ -11069,14 +11685,15 @@ } /** - * Assigns own and inherited enumerable properties of source objects to the - * destination object for all destination properties that resolve to `undefined`. - * Source objects are applied from left to right. Once a property is set, - * additional values of the same property are ignored. + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. * * **Note:** This method mutates `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The destination object. @@ -11100,6 +11717,7 @@ * * @static * @memberOf _ + * @since 3.10.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. @@ -11121,10 +11739,13 @@ * * @static * @memberOf _ + * @since 1.1.0 * @category Object * @param {Object} object The object to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, else `undefined`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. * @example * * var users = { @@ -11158,10 +11779,13 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Object * @param {Object} object The object to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, else `undefined`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. * @example * * var users = { @@ -11190,13 +11814,14 @@ } /** - * Iterates over own and inherited enumerable properties of an object invoking - * `iteratee` for each property. The iteratee is invoked with three arguments: - * (value, key, object). Iteratee functions may exit iteration early by explicitly - * returning `false`. + * Iterates over own and inherited enumerable string keyed properties of an + * object invoking `iteratee` for each property. The iteratee is invoked with + * three arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. * * @static * @memberOf _ + * @since 0.3.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11213,12 +11838,12 @@ * _.forIn(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'a', 'b', then 'c' (iteration order is not guaranteed) + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). */ function forIn(object, iteratee) { return object == null ? object - : baseFor(object, baseCastFunction(iteratee), keysIn); + : baseFor(object, getIteratee(iteratee), keysIn); } /** @@ -11227,6 +11852,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11243,22 +11869,23 @@ * _.forInRight(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c' + * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. */ function forInRight(object, iteratee) { return object == null ? object - : baseForRight(object, baseCastFunction(iteratee), keysIn); + : baseForRight(object, getIteratee(iteratee), keysIn); } /** - * Iterates over own enumerable properties of an object invoking `iteratee` - * for each property. The iteratee is invoked with three arguments: + * Iterates over own enumerable string keyed properties of an object invoking + * `iteratee` for each property. The iteratee is invoked with three arguments: * (value, key, object). Iteratee functions may exit iteration early by * explicitly returning `false`. * * @static * @memberOf _ + * @since 0.3.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11275,10 +11902,10 @@ * _.forOwn(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'a' then 'b' (iteration order is not guaranteed) + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forOwn(object, iteratee) { - return object && baseForOwn(object, baseCastFunction(iteratee)); + return object && baseForOwn(object, getIteratee(iteratee)); } /** @@ -11287,6 +11914,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11303,10 +11931,10 @@ * _.forOwnRight(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b' + * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. */ function forOwnRight(object, iteratee) { - return object && baseForOwnRight(object, baseCastFunction(iteratee)); + return object && baseForOwnRight(object, getIteratee(iteratee)); } /** @@ -11314,6 +11942,7 @@ * of `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to inspect. @@ -11340,6 +11969,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to inspect. * @returns {Array} Returns the new array of property names. @@ -11365,10 +11995,11 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. * @returns {*} Returns the resolved value. * @example * @@ -11392,6 +12023,7 @@ * Checks if `path` is a direct property of `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -11423,6 +12055,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path to check. @@ -11449,11 +12082,12 @@ /** * Creates an object composed of the inverted keys and values of `object`. - * If `object` contains duplicate values, subsequent values overwrite property - * assignments of previous values. + * If `object` contains duplicate values, subsequent values overwrite + * property assignments of previous values. * * @static * @memberOf _ + * @since 0.7.0 * @category Object * @param {Object} object The object to invert. * @returns {Object} Returns the new inverted object. @@ -11477,9 +12111,11 @@ * * @static * @memberOf _ + * @since 4.1.0 * @category Object * @param {Object} object The object to invert. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Object} Returns the new inverted object. * @example * @@ -11506,6 +12142,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the method to invoke. @@ -11528,6 +12165,7 @@ * for more details. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -11574,6 +12212,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. @@ -11612,14 +12251,16 @@ /** * The opposite of `_.mapValues`; this method creates an object with the * same values as `object` and keys generated by running each own enumerable - * property of `object` through `iteratee`. The iteratee is invoked with - * three arguments: (value, key, object). + * string keyed property of `object` through `iteratee`. The iteratee is + * invoked with three arguments: (value, key, object). * * @static * @memberOf _ + * @since 3.8.0 * @category Object * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Object} Returns the new mapped object. * @example * @@ -11640,14 +12281,17 @@ /** * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through `iteratee`. The - * iteratee is invoked with three arguments: (value, key, object). + * running each own enumerable string keyed property of `object` through + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). * * @static * @memberOf _ + * @since 2.4.0 * @category Object * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Object} Returns the new mapped object. * @example * @@ -11675,17 +12319,18 @@ /** * This method is like `_.assign` except that it recursively merges own and - * inherited enumerable properties of source objects into the destination - * object. Source properties that resolve to `undefined` are skipped if a - * destination value exists. Array and plain object properties are merged - * recursively.Other objects and value types are overridden by assignment. - * Source objects are applied from left to right. Subsequent sources - * overwrite property assignments of previous sources. + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively.Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object`. * * @static * @memberOf _ + * @since 0.5.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. @@ -11718,6 +12363,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The destination object. * @param {...Object} sources The source objects. @@ -11750,14 +12396,16 @@ /** * The opposite of `_.pick`; this method creates an object composed of the - * own and inherited enumerable properties of `object` that are not omitted. + * own and inherited enumerable string keyed properties of `object` that are + * not omitted. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The source object. - * @param {...(string|string[])} [props] The property names to omit, specified - * individually or in arrays. + * @param {...(string|string[])} [props] The property identifiers to omit, + * specified individually or in arrays. * @returns {Object} Returns the new object. * @example * @@ -11770,21 +12418,23 @@ if (object == null) { return {}; } - props = arrayMap(baseFlatten(props, 1), String); - return basePick(object, baseDifference(keysIn(object), props)); + props = arrayMap(baseFlatten(props, 1), baseCastKey); + return basePick(object, baseDifference(getAllKeysIn(object), props)); }); /** * The opposite of `_.pickBy`; this method creates an object composed of - * the own and inherited enumerable properties of `object` that `predicate` - * doesn't return truthy for. The predicate is invoked with two arguments: - * (value, key). + * the own and inherited enumerable string keyed properties of `object` that + * `predicate` doesn't return truthy for. The predicate is invoked with two + * arguments: (value, key). * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The source object. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per property. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per property. * @returns {Object} Returns the new object. * @example * @@ -11804,11 +12454,12 @@ * Creates an object composed of the picked `object` properties. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The source object. - * @param {...(string|string[])} [props] The property names to pick, specified - * individually or in arrays. + * @param {...(string|string[])} [props] The property identifiers to pick, + * specified individually or in arrays. * @returns {Object} Returns the new object. * @example * @@ -11827,9 +12478,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The source object. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per property. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per property. * @returns {Object} Returns the new object. * @example * @@ -11843,16 +12496,17 @@ } /** - * This method is like `_.get` except that if the resolved value is a function - * it's invoked with the `this` binding of its parent object and its result - * is returned. + * This method is like `_.get` except that if the resolved value is a + * function it's invoked with the `this` binding of its parent object and + * its result is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. * @returns {*} Returns the resolved value. * @example * @@ -11871,17 +12525,25 @@ * // => 'default' */ function result(object, path, defaultValue) { - if (!isKey(path, object)) { - path = baseCastPath(path); - var result = get(object, path); - object = parent(object, path); - } else { - result = object == null ? undefined : object[path]; + path = isKey(path, object) ? [path] : baseCastPath(path); + + var index = -1, + length = path.length; + + // Ensure the loop is entered when path is empty. + if (!length) { + object = undefined; + length = 1; } - if (result === undefined) { - result = defaultValue; + while (++index < length) { + var value = object == null ? undefined : object[path[index]]; + if (value === undefined) { + index = length; + value = defaultValue; + } + object = isFunction(value) ? value.call(object) : value; } - return isFunction(result) ? result.call(object) : result; + return object; } /** @@ -11894,6 +12556,7 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -11925,6 +12588,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -11944,11 +12608,13 @@ } /** - * Creates an array of own enumerable key-value pairs for `object` which - * can be consumed by `_.fromPairs`. + * Creates an array of own enumerable string keyed-value pairs for `object` + * which can be consumed by `_.fromPairs`. * * @static * @memberOf _ + * @since 4.0.0 + * @alias entries * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the new array of key-value pairs. @@ -11969,11 +12635,13 @@ } /** - * Creates an array of own and inherited enumerable key-value pairs for - * `object` which can be consumed by `_.fromPairs`. + * Creates an array of own and inherited enumerable string keyed-value pairs + * for `object` which can be consumed by `_.fromPairs`. * * @static * @memberOf _ + * @since 4.0.0 + * @alias entriesIn * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the new array of key-value pairs. @@ -11996,13 +12664,14 @@ /** * 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 invoked with four arguments: + * string keyed properties through `iteratee`, with each invocation potentially + * mutating the `accumulator` object. The iteratee is invoked with four arguments: * (accumulator, value, key, object). Iteratee functions may exit iteration * early by explicitly returning `false`. * * @static * @memberOf _ + * @since 1.3.0 * @category Object * @param {Array|Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -12031,7 +12700,7 @@ if (isArr) { accumulator = isArray(object) ? new Ctor : []; } else { - accumulator = isFunction(Ctor) ? baseCreate(getPrototypeOf(object)) : {}; + accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; } } else { accumulator = {}; @@ -12050,6 +12719,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to unset. @@ -12082,6 +12752,7 @@ * * @static * @memberOf _ + * @since 4.6.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -12113,6 +12784,7 @@ * * @static * @memberOf _ + * @since 4.6.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -12132,11 +12804,12 @@ } /** - * Creates an array of the own enumerable property values of `object`. + * Creates an array of the own enumerable string keyed property values of `object`. * * **Note:** Non-object values are coerced to objects. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -12161,12 +12834,14 @@ } /** - * Creates an array of the own and inherited enumerable property values of `object`. + * Creates an array of the own and inherited enumerable string keyed property + * values of `object`. * * **Note:** Non-object values are coerced to objects. * * @static * @memberOf _ + * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. @@ -12193,6 +12868,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Number * @param {number} number The number to clamp. * @param {number} [lower] The lower bound. @@ -12230,6 +12906,7 @@ * * @static * @memberOf _ + * @since 3.3.0 * @category Number * @param {number} number The number to check. * @param {number} [start=0] The start of the range. @@ -12273,14 +12950,15 @@ /** * Produces a random number between the inclusive `lower` and `upper` bounds. * If only one argument is provided a number between `0` and the given number - * is returned. If `floating` is `true`, or either `lower` or `upper` are floats, - * a floating-point number is returned instead of an integer. + * is returned. If `floating` is `true`, or either `lower` or `upper` are + * floats, a floating-point number is returned instead of an integer. * * **Note:** JavaScript follows the IEEE-754 standard for resolving * floating-point values which can produce unexpected results. * * @static * @memberOf _ + * @since 0.7.0 * @category Number * @param {number} [lower=0] The lower bound. * @param {number} [upper=1] The upper bound. @@ -12346,6 +13024,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the camel cased string. @@ -12354,10 +13033,10 @@ * _.camelCase('Foo Bar'); * // => 'fooBar' * - * _.camelCase('--foo-bar'); + * _.camelCase('--foo-bar--'); * // => 'fooBar' * - * _.camelCase('__foo_bar__'); + * _.camelCase('__FOO_BAR__'); * // => 'fooBar' */ var camelCase = createCompounder(function(result, word, index) { @@ -12371,6 +13050,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to capitalize. * @returns {string} Returns the capitalized string. @@ -12384,11 +13064,14 @@ } /** - * 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). + * 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 _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to deburr. * @returns {string} Returns the deburred string. @@ -12407,11 +13090,13 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to search. * @param {string} [target] The string to search for. * @param {number} [position=string.length] The position to search from. - * @returns {boolean} Returns `true` if `string` ends with `target`, else `false`. + * @returns {boolean} Returns `true` if `string` ends with `target`, + * else `false`. * @example * * _.endsWith('abc', 'c'); @@ -12445,20 +13130,22 @@ * * Though the ">" character is escaped for symmetry, characters like * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. - * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * unless they're part of a tag or unquoted attribute value. See + * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. * * Backticks are escaped because in IE < 9, they can break out of * attribute values or HTML comments. See [#59](https://html5sec.org/#59), * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and - * [#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/) - * for more details. + * [#133](https://html5sec.org/#133) of the + * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details. * - * When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping) - * to reduce XSS vectors. + * When working with HTML you should always + * [quote attribute values](http://wonko.com/post/html-escaping) to reduce + * XSS vectors. * * @static + * @since 0.1.0 * @memberOf _ * @category String * @param {string} [string=''] The string to escape. @@ -12481,6 +13168,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to escape. * @returns {string} Returns the escaped string. @@ -12497,10 +13185,12 @@ } /** - * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * Converts `string` to + * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the kebab cased string. @@ -12512,7 +13202,7 @@ * _.kebabCase('fooBar'); * // => 'foo-bar' * - * _.kebabCase('__foo_bar__'); + * _.kebabCase('__FOO_BAR__'); * // => 'foo-bar' */ var kebabCase = createCompounder(function(result, word, index) { @@ -12524,12 +13214,13 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the lower cased string. * @example * - * _.lowerCase('--Foo-Bar'); + * _.lowerCase('--Foo-Bar--'); * // => 'foo bar' * * _.lowerCase('fooBar'); @@ -12547,6 +13238,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the converted string. @@ -12560,30 +13252,13 @@ */ var lowerFirst = createCaseFirst('toLowerCase'); - /** - * Converts the first character of `string` to upper case. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.upperFirst('fred'); - * // => 'Fred' - * - * _.upperFirst('FRED'); - * // => 'FRED' - */ - var upperFirst = createCaseFirst('toUpperCase'); - /** * Pads `string` on the left and right sides if it's shorter than `length`. * Padding characters are truncated if they can't be evenly divided by `length`. * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to pad. * @param {number} [length=0] The padding length. @@ -12604,15 +13279,16 @@ string = toString(string); length = toInteger(length); - var strLength = stringSize(string); + var strLength = length ? stringSize(string) : 0; if (!length || strLength >= length) { return string; } - var mid = (length - strLength) / 2, - leftLength = nativeFloor(mid), - rightLength = nativeCeil(mid); - - return createPadding('', leftLength, chars) + string + createPadding('', rightLength, chars); + var mid = (length - strLength) / 2; + return ( + createPadding(nativeFloor(mid), chars) + + string + + createPadding(nativeCeil(mid), chars) + ); } /** @@ -12621,6 +13297,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to pad. * @param {number} [length=0] The padding length. @@ -12639,7 +13316,12 @@ */ function padEnd(string, length, chars) { string = toString(string); - return string + createPadding(string, length, chars); + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (string + createPadding(length - strLength, chars)) + : string; } /** @@ -12648,6 +13330,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to pad. * @param {number} [length=0] The padding length. @@ -12666,23 +13349,29 @@ */ function padStart(string, length, chars) { string = toString(string); - return createPadding(string, length, chars) + string; + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (createPadding(length - strLength, chars) + string) + : string; } /** * 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. + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a + * hexadecimal, in which case a `radix` of `16` is used. * - * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2) - * of `parseInt`. + * **Note:** This method aligns with the + * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. * * @static * @memberOf _ + * @since 1.1.0 * @category String * @param {string} string The string to convert. * @param {number} [radix=10] The radix to interpret `value` by. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {number} Returns the converted integer. * @example * @@ -12694,7 +13383,7 @@ */ function parseInt(string, radix, guard) { // Chrome fails to trim leading whitespace characters. - // See https://code.google.com/p/v8/issues/detail?id=3109 for more details. + // See https://bugs.chromium.org/p/v8/issues/detail?id=3109 for more details. if (guard || radix == null) { radix = 0; } else if (radix) { @@ -12709,6 +13398,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to repeat. * @param {number} [n=0] The number of times to repeat the string. @@ -12725,33 +13415,18 @@ * // => '' */ function repeat(string, n) { - string = toString(string); - n = toInteger(n); - - var result = ''; - if (!string || n < 1 || n > MAX_SAFE_INTEGER) { - return result; - } - // Leverage the exponentiation by squaring algorithm for a faster repeat. - // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. - do { - if (n % 2) { - result += string; - } - n = nativeFloor(n / 2); - string += string; - } while (n); - - return result; + return baseRepeat(toString(string), toInteger(n)); } /** * Replaces matches for `pattern` in `string` with `replacement`. * - * **Note:** This method is based on [`String#replace`](https://mdn.io/String/replace). + * **Note:** This method is based on + * [`String#replace`](https://mdn.io/String/replace). * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to modify. * @param {RegExp|string} pattern The pattern to replace. @@ -12770,10 +13445,12 @@ } /** - * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). + * Converts `string` to + * [snake case](https://en.wikipedia.org/wiki/Snake_case). * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the snake cased string. @@ -12785,7 +13462,7 @@ * _.snakeCase('fooBar'); * // => 'foo_bar' * - * _.snakeCase('--foo-bar'); + * _.snakeCase('--FOO-BAR--'); * // => 'foo_bar' */ var snakeCase = createCompounder(function(result, word, index) { @@ -12795,10 +13472,12 @@ /** * Splits `string` by `separator`. * - * **Note:** This method is based on [`String#split`](https://mdn.io/String/split). + * **Note:** This method is based on + * [`String#split`](https://mdn.io/String/split). * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to split. * @param {RegExp|string} separator The separator pattern to split by. @@ -12814,26 +13493,28 @@ } /** - * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * Converts `string` to + * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). * * @static * @memberOf _ + * @since 3.1.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the start cased string. * @example * - * _.startCase('--foo-bar'); + * _.startCase('--foo-bar--'); * // => 'Foo Bar' * * _.startCase('fooBar'); * // => 'Foo Bar' * - * _.startCase('__foo_bar__'); - * // => 'Foo Bar' + * _.startCase('__FOO_BAR__'); + * // => 'FOO BAR' */ var startCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + capitalize(word); + return result + (index ? ' ' : '') + upperFirst(word); }); /** @@ -12841,11 +13522,13 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to search. * @param {string} [target] The string to search for. * @param {number} [position=0] The position to search from. - * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`. + * @returns {boolean} Returns `true` if `string` starts with `target`, + * else `false`. * @example * * _.startsWith('abc', 'a'); @@ -12881,17 +13564,24 @@ * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). * * @static + * @since 0.1.0 * @memberOf _ * @category String * @param {string} [string=''] The template string. - * @param {Object} [options] The options object. - * @param {RegExp} [options.escape] The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate] The "evaluate" delimiter. - * @param {Object} [options.imports] An object to import into the template as free variables. - * @param {RegExp} [options.interpolate] The "interpolate" delimiter. - * @param {string} [options.sourceURL] The sourceURL of the template's compiled source. - * @param {string} [options.variable] The data object variable name. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param {Object} [options={}] The options object. + * @param {RegExp} [options.escape=_.templateSettings.escape] + * The HTML "escape" delimiter. + * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] + * The "evaluate" delimiter. + * @param {Object} [options.imports=_.templateSettings.imports] + * An object to import into the template as free variables. + * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] + * The "interpolate" delimiter. + * @param {string} [options.sourceURL='lodash.templateSources[n]'] + * The sourceURL of the compiled template. + * @param {string} [options.variable='obj'] + * The data object variable name. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the compiled template function. * @example * @@ -12940,7 +13630,7 @@ * // Use the `sourceURL` option to specify a custom sourceURL for the template. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); * compiled(data); - * // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector + * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. * * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); @@ -12960,7 +13650,8 @@ * '); */ function template(string, options, guard) { - // Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/) + // Based on John Resig's `tmpl` implementation + // (http://ejohn.org/blog/javascript-micro-templating/) // and Laura Doktorova's doT.js (https://github.com/olado/doT). var settings = lodash.templateSettings; @@ -13072,13 +13763,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the lower cased string. * @example * - * _.toLower('--Foo-Bar'); - * // => '--foo-bar' + * _.toLower('--Foo-Bar--'); + * // => '--foo-bar--' * * _.toLower('fooBar'); * // => 'foobar' @@ -13096,13 +13788,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the upper cased string. * @example * - * _.toUpper('--foo-bar'); - * // => '--FOO-BAR' + * _.toUpper('--foo-bar--'); + * // => '--FOO-BAR--' * * _.toUpper('fooBar'); * // => 'FOOBAR' @@ -13119,10 +13812,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -13160,10 +13854,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -13196,10 +13891,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -13234,9 +13930,10 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to truncate. - * @param {Object} [options=({})] The options object. + * @param {Object} [options={}] The options object. * @param {number} [options.length=30] The maximum string length. * @param {string} [options.omission='...'] The string to indicate text is omitted. * @param {RegExp|string} [options.separator] The separator pattern to truncate to. @@ -13321,14 +14018,15 @@ /** * The inverse of `_.escape`; this method converts the HTML entities - * `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their - * corresponding characters. + * `&`, `<`, `>`, `"`, `'`, and ``` in `string` to + * their corresponding characters. * - * **Note:** No other HTML entities are unescaped. To unescape additional HTML - * entities use a third-party library like [_he_](https://mths.be/he). + * **Note:** No other HTML entities are unescaped. To unescape additional + * HTML entities use a third-party library like [_he_](https://mths.be/he). * * @static * @memberOf _ + * @since 0.6.0 * @category String * @param {string} [string=''] The string to unescape. * @returns {string} Returns the unescaped string. @@ -13349,6 +14047,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the upper cased string. @@ -13367,15 +14066,35 @@ return result + (index ? ' ' : '') + word.toUpperCase(); }); + /** + * Converts the first character of `string` to upper case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.upperFirst('fred'); + * // => 'Fred' + * + * _.upperFirst('FRED'); + * // => 'FRED' + */ + var upperFirst = createCaseFirst('toUpperCase'); + /** * Splits `string` into an array of its words. * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to inspect. * @param {RegExp|string} [pattern] The pattern to match words. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the words of `string`. * @example * @@ -13403,8 +14122,10 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {Function} func The function to attempt. + * @param {...*} [args] The arguments to invoke `func` with. * @returns {*} Returns the `func` result or error object. * @example * @@ -13432,6 +14153,7 @@ * **Note:** This method doesn't set the "length" property of bound functions. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {Object} object The object to bind and assign the bound methods to. @@ -13449,7 +14171,7 @@ * * _.bindAll(view, 'onClick'); * jQuery(element).on('click', view.onClick); - * // => logs 'clicked docs' when clicked + * // => Logs 'clicked docs' when clicked. */ var bindAll = rest(function(object, methodNames) { arrayEach(baseFlatten(methodNames, 1), function(key) { @@ -13466,6 +14188,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {Array} pairs The predicate-function pairs. * @returns {Function} Returns the new function. @@ -13515,6 +14238,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {Object} source The object of property predicates to conform to. * @returns {Function} Returns the new function. @@ -13537,6 +14261,7 @@ * * @static * @memberOf _ + * @since 2.4.0 * @category Util * @param {*} value The value to return from the new function. * @returns {Function} Returns the new function. @@ -13561,6 +14286,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {...(Function|Function[])} [funcs] Functions to invoke. * @returns {Function} Returns the new function. @@ -13581,6 +14307,7 @@ * invokes the given functions from right to left. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {...(Function|Function[])} [funcs] Functions to invoke. @@ -13601,6 +14328,7 @@ * This method returns the first argument given to it. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {*} value Any value. @@ -13618,12 +14346,13 @@ /** * Creates a function that invokes `func` with the arguments of the created - * function. If `func` is a property name the 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`. + * function. If `func` is a property name the created function returns the + * property value for a given element. If `func` is an array or object the + * created function returns `true` for elements that contain the equivalent + * source properties, otherwise it returns `false`. * * @static + * @since 4.0.0 * @memberOf _ * @category Util * @param {*} [func=_.identity] The value to convert to a callback. @@ -13631,20 +14360,31 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * + * // The `_.matches` iteratee shorthand. + * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); + * // => [{ 'user': 'barney', 'age': 36, 'active': true }] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, _.iteratee(['user', 'fred'])); + * // => [{ 'user': 'fred', 'age': 40 }] + * + * // The `_.property` iteratee shorthand. + * _.map(users, _.iteratee('user')); + * // => ['barney', 'fred'] + * * // Create custom iteratee shorthands. - * _.iteratee = _.wrap(_.iteratee, function(callback, func) { - * var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func); - * return !p ? callback(func) : function(object) { - * return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]); + * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { + * return !_.isRegExp(func) ? iteratee(func) : function(string) { + * return func.test(string); * }; * }); * - * _.filter(users, 'age > 36'); - * // => [{ 'user': 'fred', 'age': 40 }] + * _.filter(['abc', 'def'], /ef/); + * // => ['def'] */ function iteratee(func) { return baseIteratee(typeof func == 'function' ? func : baseClone(func, true)); @@ -13660,6 +14400,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {Object} source The object of property values to match. * @returns {Function} Returns the new function. @@ -13686,6 +14427,7 @@ * * @static * @memberOf _ + * @since 3.2.0 * @category Util * @param {Array|string} path The path of the property to get. * @param {*} srcValue The value to match. @@ -13710,6 +14452,7 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Util * @param {Array|string} path The path of the method to invoke. * @param {...*} [args] The arguments to invoke the method with. @@ -13724,8 +14467,8 @@ * _.map(objects, _.method('a.b.c')); * // => [2, 1] * - * _.invokeMap(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); - * // => [1, 2] + * _.map(objects, _.method(['a', 'b', 'c'])); + * // => [2, 1] */ var method = rest(function(path, args) { return function(object) { @@ -13740,6 +14483,7 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Util * @param {Object} object The object to query. * @param {...*} [args] The arguments to invoke the method with. @@ -13762,21 +14506,21 @@ }); /** - * 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. + * Adds all own enumerable string keyed 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 to * avoid conflicts caused by modifying the original. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {Function|Object} [object=lodash] The destination object. * @param {Object} source The object of functions to add. - * @param {Object} [options] The options object. - * @param {boolean} [options.chain=true] Specify whether the functions added - * are chainable. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.chain=true] Specify whether mixins are chainable. * @returns {Function|Object} Returns `object`. * @example * @@ -13838,6 +14582,7 @@ * the `lodash` function. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @returns {Function} Returns the `lodash` function. @@ -13858,6 +14603,7 @@ * * @static * @memberOf _ + * @since 2.3.0 * @category Util * @example * @@ -13875,6 +14621,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {number} [n=0] The index of the argument to return. * @returns {Function} Returns the new function. @@ -13898,6 +14645,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {...(Function|Function[])} iteratees The iteratees to invoke. * @returns {Function} Returns the new function. @@ -13916,6 +14664,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {...(Function|Function[])} predicates The predicates to check. * @returns {Function} Returns the new function. @@ -13940,6 +14689,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {...(Function|Function[])} predicates The predicates to check. * @returns {Function} Returns the new function. @@ -13963,6 +14713,7 @@ * * @static * @memberOf _ + * @since 2.4.0 * @category Util * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new function. @@ -13989,6 +14740,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {Object} object The object to query. * @returns {Function} Returns the new function. @@ -14019,6 +14771,7 @@ * floating-point values which can produce unexpected results. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {number} [start=0] The start of the range. @@ -14056,6 +14809,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {number} [start=0] The start of the range. * @param {number} end The end of the range. @@ -14091,6 +14845,7 @@ * each invocation. The iteratee is invoked with one argument; (index). * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {number} n The number of times to invoke `iteratee`. @@ -14112,7 +14867,7 @@ var index = MAX_ARRAY_LENGTH, length = nativeMin(n, MAX_ARRAY_LENGTH); - iteratee = baseCastFunction(iteratee); + iteratee = getIteratee(iteratee); n -= MAX_ARRAY_LENGTH; var result = baseTimes(length, iteratee); @@ -14127,6 +14882,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {*} value The value to convert. * @returns {Array} Returns the new property path array. @@ -14148,13 +14904,17 @@ * // => false */ function toPath(value) { - return isArray(value) ? arrayMap(value, String) : stringToPath(value); + if (isArray(value)) { + return arrayMap(value, baseCastKey); + } + return isSymbol(value) ? [value] : copyArray(stringToPath(value)); } /** * Generates a unique ID. If `prefix` is given the ID is appended to it. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {string} [prefix=''] The value to prefix the ID with. @@ -14179,6 +14939,7 @@ * * @static * @memberOf _ + * @since 3.4.0 * @category Math * @param {number} augend The first number in an addition. * @param {number} addend The second number in an addition. @@ -14188,25 +14949,16 @@ * _.add(6, 4); * // => 10 */ - function add(augend, addend) { - var result; - if (augend === undefined && addend === undefined) { - return 0; - } - if (augend !== undefined) { - result = augend; - } - if (addend !== undefined) { - result = result === undefined ? addend : (result + addend); - } - return result; - } + var add = createMathOperation(function(augend, addend) { + return augend + addend; + }); /** * Computes `number` rounded up to `precision`. * * @static * @memberOf _ + * @since 3.10.0 * @category Math * @param {number} number The number to round up. * @param {number} [precision=0] The precision to round up to. @@ -14224,11 +14976,31 @@ */ var ceil = createRound('ceil'); + /** + * Divide two numbers. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {number} dividend The first number in a division. + * @param {number} divisor The second number in a division. + * @returns {number} Returns the quotient. + * @example + * + * _.divide(6, 4); + * // => 1.5 + */ + var divide = createMathOperation(function(dividend, divisor) { + return dividend / divisor; + }); + /** * Computes `number` rounded down to `precision`. * * @static * @memberOf _ + * @since 3.10.0 * @category Math * @param {number} number The number to round down. * @param {number} [precision=0] The precision to round down to. @@ -14251,6 +15023,7 @@ * `undefined` is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Math * @param {Array} array The array to iterate over. @@ -14276,9 +15049,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {*} Returns the maximum value. * @example * @@ -14302,6 +15077,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. * @returns {number} Returns the mean. @@ -14311,7 +15087,35 @@ * // => 5 */ function mean(array) { - return sum(array) / (array ? array.length : 0); + return baseMean(array, identity); + } + + /** + * This method is like `_.mean` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the value to be averaged. + * The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. + * @returns {number} Returns the mean. + * @example + * + * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; + * + * _.meanBy(objects, function(o) { return o.n; }); + * // => 5 + * + * // The `_.property` iteratee shorthand. + * _.meanBy(objects, 'n'); + * // => 5 + */ + function meanBy(array, iteratee) { + return baseMean(array, getIteratee(iteratee)); } /** @@ -14319,6 +15123,7 @@ * `undefined` is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Math * @param {Array} array The array to iterate over. @@ -14344,9 +15149,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {*} Returns the minimum value. * @example * @@ -14365,11 +15172,31 @@ : undefined; } + /** + * Multiply two numbers. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {number} multiplier The first number in a multiplication. + * @param {number} multiplicand The second number in a multiplication. + * @returns {number} Returns the product. + * @example + * + * _.multiply(6, 4); + * // => 24 + */ + var multiply = createMathOperation(function(multiplier, multiplicand) { + return multiplier * multiplicand; + }); + /** * Computes `number` rounded to `precision`. * * @static * @memberOf _ + * @since 3.10.0 * @category Math * @param {number} number The number to round. * @param {number} [precision=0] The precision to round to. @@ -14392,6 +15219,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {number} minuend The first number in a subtraction. * @param {number} subtrahend The second number in a subtraction. @@ -14401,25 +15229,16 @@ * _.subtract(6, 4); * // => 2 */ - function subtract(minuend, subtrahend) { - var result; - if (minuend === undefined && subtrahend === undefined) { - return 0; - } - if (minuend !== undefined) { - result = minuend; - } - if (subtrahend !== undefined) { - result = result === undefined ? subtrahend : (result - subtrahend); - } - return result; - } + var subtract = createMathOperation(function(minuend, subtrahend) { + return minuend - subtrahend; + }); /** * Computes the sum of the values in `array`. * * @static * @memberOf _ + * @since 3.4.0 * @category Math * @param {Array} array The array to iterate over. * @returns {number} Returns the sum. @@ -14441,9 +15260,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {number} Returns the sum. * @example * @@ -14464,40 +15285,7 @@ /*------------------------------------------------------------------------*/ - // Ensure wrappers are instances of `baseLodash`. - lodash.prototype = baseLodash.prototype; - lodash.prototype.constructor = lodash; - - LodashWrapper.prototype = baseCreate(baseLodash.prototype); - LodashWrapper.prototype.constructor = LodashWrapper; - - LazyWrapper.prototype = baseCreate(baseLodash.prototype); - LazyWrapper.prototype.constructor = LazyWrapper; - - // Avoid inheriting from `Object.prototype` when possible. - Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; - - // Add functions to the `MapCache`. - MapCache.prototype.clear = mapClear; - MapCache.prototype['delete'] = mapDelete; - MapCache.prototype.get = mapGet; - MapCache.prototype.has = mapHas; - MapCache.prototype.set = mapSet; - - // Add functions to the `SetCache`. - SetCache.prototype.push = cachePush; - - // Add functions to the `Stack` cache. - Stack.prototype.clear = stackClear; - Stack.prototype['delete'] = stackDelete; - Stack.prototype.get = stackGet; - Stack.prototype.has = stackHas; - Stack.prototype.set = stackSet; - - // Assign cache to `_.memoize`. - memoize.Cache = MapCache; - - // Add functions that return wrapped values when chaining. + // Add methods that return wrapped values in chain sequences. lodash.after = after; lodash.ary = ary; lodash.assign = assign; @@ -14536,6 +15324,8 @@ lodash.fill = fill; lodash.filter = filter; lodash.flatMap = flatMap; + lodash.flatMapDeep = flatMapDeep; + lodash.flatMapDepth = flatMapDepth; lodash.flatten = flatten; lodash.flattenDeep = flattenDeep; lodash.flattenDepth = flattenDepth; @@ -14647,15 +15437,17 @@ lodash.zipWith = zipWith; // Add aliases. + lodash.entries = toPairs; + lodash.entriesIn = toPairsIn; lodash.extend = assignIn; lodash.extendWith = assignInWith; - // Add functions to `lodash.prototype`. + // Add methods to `lodash.prototype`. mixin(lodash, lodash); /*------------------------------------------------------------------------*/ - // Add functions that return unwrapped values when chaining. + // Add methods that return unwrapped values in chain sequences. lodash.add = add; lodash.attempt = attempt; lodash.camelCase = camelCase; @@ -14667,6 +15459,7 @@ lodash.cloneDeepWith = cloneDeepWith; lodash.cloneWith = cloneWith; lodash.deburr = deburr; + lodash.divide = divide; lodash.endsWith = endsWith; lodash.eq = eq; lodash.escape = escape; @@ -14744,8 +15537,10 @@ lodash.max = max; lodash.maxBy = maxBy; lodash.mean = mean; + lodash.meanBy = meanBy; lodash.min = min; lodash.minBy = minBy; + lodash.multiply = multiply; lodash.noConflict = noConflict; lodash.noop = noop; lodash.now = now; @@ -14985,7 +15780,7 @@ }; }); - // Add `Array` and `String` methods to `lodash.prototype`. + // Add `Array` methods to `lodash.prototype`. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', @@ -14994,15 +15789,16 @@ lodash.prototype[methodName] = function() { var args = arguments; if (retUnwrapped && !this.__chain__) { - return func.apply(this.value(), args); + var value = this.value(); + return func.apply(isArray(value) ? value : [], args); } return this[chainName](function(value) { - return func.apply(value, args); + return func.apply(isArray(value) ? value : [], args); }); }; }); - // Map minified function names to their real names. + // Map minified method names to their real names. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName]; if (lodashFunc) { @@ -15018,16 +15814,15 @@ 'func': undefined }]; - // Add functions to the lazy wrapper. + // Add methods to `LazyWrapper`. LazyWrapper.prototype.clone = lazyClone; LazyWrapper.prototype.reverse = lazyReverse; LazyWrapper.prototype.value = lazyValue; - // Add chaining functions to the `lodash` wrapper. + // Add chain sequence methods to the `lodash` wrapper. lodash.prototype.at = wrapperAt; lodash.prototype.chain = wrapperChain; lodash.prototype.commit = wrapperCommit; - lodash.prototype.flatMap = wrapperFlatMap; lodash.prototype.next = wrapperNext; lodash.prototype.plant = wrapperPlant; lodash.prototype.reverse = wrapperReverse; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 12c24c4979..a9176a61dc 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -1,121 +1,124 @@ /** * @license - * lodash 4.6.1 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE + * lodash 4.7.0 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.js` */ -;(function(){function n(n,t){return n.set(t[0],t[1]),n}function t(n,t){return n.add(t),n}function r(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}function e(n,t,r,e){for(var u=-1,o=n.length;++ut&&!o||!u||r&&!i&&f||e&&f)return 1;if(t>n&&!r||!f||o&&!e&&u||i&&u)return-1}return 0}function R(n){return zn[n]}function W(n){return Mn[n]}function B(n){return"\\"+Fn[n]}function C(n,t,r){ -var e=n.length;for(t+=r?0:-1;r?t--:++t-1&&0==n%1&&(null==t?9007199254740991:t)>n}function M(n){for(var t,r=[];!(t=n.next()).done;)r.push(t.value);return r}function L(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n]}),r}function $(n,t){for(var r=-1,e=n.length,u=0,o=[];++rr?false:(r==n.length-1?n.pop():Iu.call(n,r,1),true)}function qn(n,t){var r=Tn(n,t);return 0>r?q:n[r][1]}function Tn(n,t){for(var r=n.length;r--;)if(pe(n[r][0],t))return r;return-1}function Kn(n,t,r){var e=Tn(n,t);0>e?n.push([t,r]):n[e][1]=r}function Gn(n,t,r,e){return n===q||pe(n,cu[r])&&!lu.call(e,r)?t:n}function Yn(n,t,r){(r===q||pe(n[t],r))&&(typeof t!="number"||r!==q||t in n)||(n[t]=r); -}function Hn(n,t,r){var e=n[t];lu.call(n,t)&&pe(e,r)&&(r!==q||t in n)||(n[t]=r)}function Qn(n,t,r,e){return Qu(n,function(n,u,o){t(e,n,r(n),o)}),e}function Xn(n,t){return n&&tr(t,De(t),n)}function nt(n,t){for(var r=-1,e=null==n,u=t.length,o=Array(u);++rr?r:n),t!==q&&(n=t>n?t:n)),n}function ot(n,t,r,e,o,i,f){ -var c;if(e&&(c=i?e(n,o,i,f):e(n)),c!==q)return c;if(!me(n))return n;if(o=qo(n)){if(c=Br(n),!t)return nr(n,c)}else{var a=Rr(n),l="[object Function]"==a||"[object GeneratorFunction]"==a;if(Po(n))return Yt(n,t);if("[object Object]"==a||"[object Arguments]"==a||l&&!i){if(U(n))return i?n:{};if(c=Cr(l?{}:n),!t)return c=Xn(c,n),r?er(n,c):c}else{if(!Un[a])return i?n:{};c=Ur(n,a,t)}}return f||(f=new Fn),(i=f.get(n))?i:(f.set(n,c),(o?u:_t)(n,function(u,o){Hn(c,o,ot(u,t,r,e,o,n,f))}),r&&!o?er(n,c):c)}function it(n){ -var t=De(n),r=t.length;return function(e){if(null==e)return!r;for(var u=r;u--;){var o=t[u],i=n[o],f=e[o];if(f===q&&!(o in Object(e))||!i(f))return false}return true}}function ft(n){return me(n)?Ou(n):{}}function ct(n,t,r){if(typeof n!="function")throw new iu("Expected a function");return Eu(function(){n.apply(q,r)},t)}function at(n,t,r,e){var u=-1,o=f,i=true,l=n.length,s=[],h=t.length;if(!l)return s;r&&(t=a(t,A(r))),e?(o=c,i=false):t.length>=200&&(o=$n,i=false,t=new Ln(t));n:for(;++u0&&de(i)&&(r||qo(i)||ve(i))?t>1?ht(i,t-1,r,e):l(e,i):r||(e[e.length]=i)}return e}function pt(n,t){null==n||no(n,t,Ze)}function _t(n,t){return n&&no(n,t,De)}function vt(n,t){return n&&to(n,t,De); -}function gt(n,t){return i(t,function(t){return be(n[t])})}function dt(n,t){t=Lr(t,n)?[t+""]:et(t);for(var r=0,e=t.length;null!=n&&e>r;)n=n[t[r++]];return r&&r==e?n:q}function yt(n,t){return lu.call(n,t)||typeof n=="object"&&t in n&&null===mu(n)}function bt(n,t){return t in Object(n)}function xt(n,t,r){for(var e=r?c:f,u=n[0].length,o=n.length,i=o,l=Array(o),s=1/0,h=[];i--;){var p=n[i];i&&t&&(p=a(p,A(t))),s=zu(p.length,s),l[i]=r||!t&&(120>u||120>p.length)?q:new Ln(i&&p)}var p=n[0],_=-1,v=l[0];n:for(;++_h.length;){ -var g=p[_],d=t?t(g):g;if(v?!$n(v,d):!e(h,d,r)){for(i=o;--i;){var y=l[i];if(y?!$n(y,d):!e(n[i],d,r))continue n}v&&v.push(d),h.push(g)}}return h}function jt(n,t,r){var e={};return _t(n,function(n,u,o){t(e,r(n),u,o)}),e}function mt(n,t,e){return Lr(t,n)||(t=et(t),n=Zr(n,t),t=Vr(t)),t=null==n?n:n[t],null==t?q:r(t,n,e)}function wt(n,t,r,e,u){if(n===t)n=true;else if(null==n||null==t||!me(n)&&!we(t))n=n!==n&&t!==t;else n:{var o=qo(n),i=qo(t),f="[object Array]",c="[object Array]";o||(f=Rr(n),f="[object Arguments]"==f?"[object Object]":f), -i||(c=Rr(t),c="[object Arguments]"==c?"[object Object]":c);var a="[object Object]"==f&&!U(n),i="[object Object]"==c&&!U(t);if((c=f==c)&&!a)u||(u=new Fn),n=o||Re(n)?wr(n,t,wt,r,e,u):Ar(n,t,f,wt,r,e,u);else{if(!(2&e)&&(o=a&&lu.call(n,"__wrapped__"),f=i&&lu.call(t,"__wrapped__"),o||f)){u||(u=new Fn),n=wt(o?n.value():n,f?t.value():t,r,e,u);break n}if(c)t:if(u||(u=new Fn),o=2&e,f=De(n),i=f.length,c=De(t).length,i==c||o){for(a=i;a--;){var l=f[a];if(!(o?l in t:yt(t,l))){n=false;break t}}if(c=u.get(n))n=c==t;else{ -c=true,u.set(n,t);for(var s=o;++ae?c*("desc"==r[e]?-1:1):c;break n}}e=n.b-t.b}return e})}function Bt(n,t){return n=Object(n),s(t,function(t,r){return r in n&&(t[r]=n[r]), -t},{})}function Ct(n,t){var r={};return pt(n,function(n,e){t(n,e)&&(r[e]=n)}),r}function Ut(n){return function(t){return null==t?q:t[n]}}function zt(n){return function(t){return dt(t,n)}}function Mt(n,t,r,e){var u=e?y:d,o=-1,i=t.length,f=n;for(r&&(f=a(n,A(r)));++ot&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e=u){for(;u>e;){var o=e+u>>>1,i=n[o];(r?t>=i:t>i)&&null!==i?e=o+1:u=o}return u}return qt(n,t,Ye,r)}function qt(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=null===t,c=t===q;o>u;){var a=Ru((u+o)/2),l=r(n[a]),s=l!==q,h=l===l;(i?h||e:f?h&&s&&(e||null!=l):c?h&&(e||s):null==l?0:e?t>=l:t>l)?u=a+1:o=a}return zu(o,4294967294)}function Pt(n,t){for(var r=0,e=n.length,u=n[0],o=t?t(u):u,i=o,f=1,c=[u];++re?t[e]:q);return i}function Yt(n,t){if(t)return n.slice();var r=new n.constructor(n.length);return n.copy(r),r}function Ht(n){var t=new n.constructor(n.byteLength);return new bu(t).set(new bu(n)), -t}function Qt(n,t,r,e){var u=-1,o=n.length,i=r.length,f=-1,c=t.length,a=Uu(o-i,0),l=Array(c+a);for(e=!e;++fu)&&(l[r[u]]=n[u]);for(;a--;)l[f++]=n[u++];return l}function Xt(n,t,r,e){var u=-1,o=n.length,i=-1,f=r.length,c=-1,a=t.length,l=Uu(o-f,0),s=Array(l+a);for(e=!e;++uu)&&(s[l+r[i]]=n[u++]);return s}function nr(n,t){var r=-1,e=n.length;for(t||(t=Array(e));++r1?r[u-1]:q,i=u>2?r[2]:q,o=typeof o=="function"?(u--,o):q;for(i&&Mr(r[0],r[1],i)&&(o=3>u?q:o,u=1),t=Object(t);++ei&&f[0]!==a&&f[i-1]!==a?[]:$(f,a),i-=c.length,e>i?xr(n,t,_r,u.placeholder,q,f,c,q,q,e-i):r(this&&this!==Vn&&this instanceof u?o:n,this,f)}var o=sr(n);return u}function pr(n){return he(function(t){t=ht(t,1);var r=t.length,e=r,u=An.prototype.thru;for(n&&t.reverse();e--;){var o=t[e];if(typeof o!="function")throw new iu("Expected a function");if(u&&!i&&"wrapper"==Or(o))var i=new An([],true)}for(e=i?e:r;++e=200)return i.plant(e).value();for(var u=0,n=r?t[u].apply(this,n):e;++ud)return j=$(b,j),xr(n,t,_r,l.placeholder,r,b,j,f,c,a-d);if(j=h?r:this,y=p?j[n]:n,d=b.length,f){x=b.length; -for(var m=zu(f.length,x),w=nr(b);m--;){var A=f[m];b[m]=z(A,x)?w[A]:q}}else v&&d>1&&b.reverse();return s&&d>c&&(b.length=c),this&&this!==Vn&&this instanceof l&&(y=g||sr(y)),y.apply(j,b)}var s=128&t,h=1&t,p=2&t,_=24&t,v=512&t,g=p?q:sr(n);return l}function vr(n,t){return function(r,e){return jt(r,n,t(e))}}function gr(n){return he(function(t){return t=a(ht(t,1),kr()),he(function(e){var u=this;return n(t,function(n){return r(n,u,e)})})})}function dr(n,t,r){return t=Ce(t),n=N(n),t&&t>n?(t-=n,r=r===q?" ":r+"", -n=Ge(r,Su(t/N(r))),In.test(r)?n.match(En).slice(0,t).join(""):n.slice(0,t)):""}function yr(n,t,e,u){function o(){for(var t=-1,c=arguments.length,a=-1,l=u.length,s=Array(l+c),h=this&&this!==Vn&&this instanceof o?f:n;++at?1:-1:ze(e)||0;var u=-1;r=Uu(Su((r-t)/(e||1)),0);for(var o=Array(r);r--;)o[n?r:++u]=t, -t+=e;return o}}function xr(n,t,r,e,u,o,i,f,c,a){var l=8&t;f=f?nr(f):q;var s=l?i:q;i=l?q:i;var h=l?o:q;return o=l?q:o,t=(t|(l?32:64))&~(l?64:32),4&t||(t&=-4),t=[n,t,u,h,s,o,i,f,c,a],r=r.apply(q,t),Fr(n)&&fo(r,t),r.placeholder=e,r}function jr(n){var t=uu[n];return function(n,r){if(n=ze(n),r=Ce(r)){var e=(Le(n)+"e").split("e"),e=t(e[0]+"e"+(+e[1]+r)),e=(Le(e)+"e").split("e");return+(e[0]+"e"+(+e[1]-r))}return t(n)}}function mr(n,t,r,e,u,o,i,f){var c=2&t;if(!c&&typeof n!="function")throw new iu("Expected a function"); -var a=e?e.length:0;if(a||(t&=-97,e=u=q),i=i===q?i:Uu(Ce(i),0),f=f===q?f:Ce(f),a-=u?u.length:0,64&t){var l=e,s=u;e=u=q}var h=c?q:uo(n);return o=[n,t,r,e,u,l,s,o,i,f],h&&(r=o[1],n=h[1],t=r|n,e=128==n&&8==r||128==n&&256==r&&h[8]>=o[7].length||384==n&&h[8]>=h[7].length&&8==r,131>t||e)&&(1&n&&(o[2]=h[2],t|=1&r?0:4),(r=h[3])&&(e=o[3],o[3]=e?Qt(e,r,h[4]):nr(r),o[4]=e?$(o[3],"__lodash_placeholder__"):nr(h[4])),(r=h[5])&&(e=o[5],o[5]=e?Xt(e,r,h[6]):nr(r),o[6]=e?$(o[5],"__lodash_placeholder__"):nr(h[6])),(r=h[7])&&(o[7]=nr(r)), -128&n&&(o[8]=null==o[8]?h[8]:zu(o[8],h[8])),null==o[9]&&(o[9]=h[9]),o[0]=h[0],o[1]=t),n=o[0],t=o[1],r=o[2],e=o[3],u=o[4],f=o[9]=null==o[9]?c?0:n.length:Uu(o[9]-a,0),!f&&24&t&&(t&=-25),(h?ro:fo)(t&&1!=t?8==t||16==t?hr(n,t,f):32!=t&&33!=t||u.length?_r.apply(q,o):yr(n,t,r,e):cr(n,t,r),o)}function wr(n,t,r,e,u,o){var i=-1,f=2&u,c=1&u,a=n.length,l=t.length;if(!(a==l||f&&l>a))return false;if(l=o.get(n))return l==t;for(l=true,o.set(n,t);++it?0:t,e)):[]}function Kr(n,t,r){var e=n?n.length:0; -return e?(t=r||t===q?1:Ce(t),t=e-t,Nt(n,0,0>t?0:t)):[]}function Gr(n){return n?n[0]:q}function Vr(n){var t=n?n.length:0;return t?n[t-1]:q}function Jr(n,t){return n&&n.length&&t&&t.length?Mt(n,t):n}function Yr(n){return n?$u.call(n):n}function Hr(n){if(!n||!n.length)return[];var t=0;return n=i(n,function(n){return de(n)?(t=Uu(n.length,t),true):void 0}),m(t,function(t){return a(n,Ut(t))})}function Qr(n,t){if(!n||!n.length)return[];var e=Hr(n);return null==t?e:a(e,function(n){return r(t,q,n)})}function Xr(n){ -return n=bn(n),n.__chain__=true,n}function ne(n,t){return t(n)}function te(){return this}function re(n,t){return typeof t=="function"&&qo(n)?u(n,t):Qu(n,rt(t))}function ee(n,t){var r;if(typeof t=="function"&&qo(n)){for(r=n.length;r--&&false!==t(n[r],r,n););r=n}else r=Xu(n,rt(t));return r}function ue(n,t){return(qo(n)?a:Et)(n,kr(t,3))}function oe(n,t){var r=-1,e=Be(n),u=e.length,o=u-1;for(t=ut(Ce(t),0,u);++r=n&&(t=q),r}}function ce(n,t,r){return t=r?q:t,n=mr(n,8,q,q,q,q,q,t),n.placeholder=ce.placeholder,n}function ae(n,t,r){return t=r?q:t,n=mr(n,16,q,q,q,q,q,t),n.placeholder=ae.placeholder,n}function le(n,t,r){function e(){p&&xu(p),a&&xu(a),v=0,c=a=h=p=_=q}function u(t,r){r&&xu(r),a=p=_=q,t&&(v=Uo(),l=n.apply(h,c), -p||a||(c=h=q))}function o(){var n=t-(Uo()-s);0>=n||n>t?u(_,a):p=Eu(o,n)}function i(){u(y,p)}function f(){if(c=arguments,s=Uo(),h=this,_=y&&(p||!g),false===d)var r=g&&!p;else{v||a||g||(v=s);var e=d-(s-v),u=(0>=e||e>d)&&(g||a);u?(a&&(a=xu(a)),v=s,l=n.apply(h,c)):a||(a=Eu(i,e))}return u&&p?p=xu(p):p||t===d||(p=Eu(o,t)),r&&(u=true,l=n.apply(h,c)),!u||p||a||(c=h=q),l}var c,a,l,s,h,p,_,v=0,g=false,d=false,y=true;if(typeof n!="function")throw new iu("Expected a function");return t=ze(t)||0,me(r)&&(g=!!r.leading,d="maxWait"in r&&Uu(ze(r.maxWait)||0,t), -y="trailing"in r?!!r.trailing:y),f.cancel=e,f.flush=function(){return(p&&_||a&&y)&&(l=n.apply(h,c)),e(),l},f}function se(n,t){function r(){var e=arguments,u=t?t.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=n.apply(this,e),r.cache=o.set(u,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new iu("Expected a function");return r.cache=new se.Cache,r}function he(n,t){if(typeof n!="function")throw new iu("Expected a function");return t=Uu(t===q?n.length-1:Ce(t),0),function(){for(var e=arguments,u=-1,o=Uu(e.length-t,0),i=Array(o);++ut}function ve(n){return de(n)&&lu.call(n,"callee")&&(!ku.call(n,"callee")||"[object Arguments]"==pu.call(n))}function ge(n){return null!=n&&je(oo(n))&&!be(n)}function de(n){return we(n)&&ge(n)}function ye(n){return we(n)?"[object Error]"==pu.call(n)||typeof n.message=="string"&&typeof n.name=="string":false; -}function be(n){return n=me(n)?pu.call(n):"","[object Function]"==n||"[object GeneratorFunction]"==n}function xe(n){return typeof n=="number"&&n==Ce(n)}function je(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n}function me(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function we(n){return!!n&&typeof n=="object"}function Ae(n){return null==n?false:be(n)?vu.test(au.call(n)):we(n)&&(U(n)?vu:dn).test(n)}function Oe(n){return typeof n=="number"||we(n)&&"[object Number]"==pu.call(n); -}function ke(n){return!we(n)||"[object Object]"!=pu.call(n)||U(n)?false:(n=mu(n),null===n?true:(n=n.constructor,typeof n=="function"&&n instanceof n&&au.call(n)==hu))}function Ee(n){return me(n)&&"[object RegExp]"==pu.call(n)}function Ie(n){return typeof n=="string"||!qo(n)&&we(n)&&"[object String]"==pu.call(n)}function Se(n){return typeof n=="symbol"||we(n)&&"[object Symbol]"==pu.call(n)}function Re(n){return we(n)&&je(n.length)&&!!Cn[pu.call(n)]}function We(n,t){return t>n}function Be(n){if(!n)return[]; -if(ge(n))return Ie(n)?n.match(En):nr(n);if(Au&&n[Au])return M(n[Au]());var t=Rr(n);return("[object Map]"==t?L:"[object Set]"==t?F:Pe)(n)}function Ce(n){if(!n)return 0===n?n:0;if(n=ze(n),n===P||n===-P)return 1.7976931348623157e308*(0>n?-1:1);var t=n%1;return n===n?t?n-t:n:0}function Ue(n){return n?ut(Ce(n),0,4294967295):0}function ze(n){if(me(n)&&(n=be(n.valueOf)?n.valueOf():n,n=me(n)?n+"":n),typeof n!="string")return 0===n?n:+n;n=n.replace(cn,"");var t=gn.test(n);return t||yn.test(n)?Dn(n.slice(2),t?2:8):vn.test(n)?T:+n; -}function Me(n){return tr(n,Ze(n))}function Le(n){if(typeof n=="string")return n;if(null==n)return"";if(Se(n))return Hu?Hu.call(n):"";var t=n+"";return"0"==t&&1/n==-P?"-0":t}function $e(n,t,r){return n=null==n?q:dt(n,t),n===q?r:n}function Fe(n,t){return Wr(n,t,yt)}function Ne(n,t){return Wr(n,t,bt)}function De(n){var t=Nr(n);if(!t&&!ge(n))return Cu(Object(n));var r,e=zr(n),u=!!e,e=e||[],o=e.length;for(r in n)!yt(n,r)||u&&("length"==r||z(r,o))||t&&"constructor"==r||e.push(r);return e}function Ze(n){ -for(var t=-1,r=Nr(n),e=kt(n),u=e.length,o=zr(n),i=!!o,o=o||[],f=o.length;++tt||t>9007199254740991)return r;do t%2&&(r+=n),t=Ru(t/2),n+=n;while(t);return r}function Ve(n,t,r){ -return n=Le(n),t=r?q:t,t===q&&(t=Wn.test(n)?Rn:Sn),n.match(t)||[]}function Je(n){return function(){return n}}function Ye(n){return n}function He(n){return Ot(typeof n=="function"?n:ot(n,true))}function Qe(n,t,r){var e=De(t),o=gt(t,e);null!=r||me(t)&&(o.length||!e.length)||(r=t,t=n,n=this,o=gt(t,De(t)));var i=me(r)&&"chain"in r?r.chain:true,f=be(n);return u(o,function(r){var e=t[r];n[r]=e,f&&(n.prototype[r]=function(){var t=this.__chain__;if(i||t){var r=n(this.__wrapped__);return(r.__actions__=nr(this.__actions__)).push({ -func:e,args:arguments,thisArg:n}),r.__chain__=t,r}return e.apply(n,l([this.value()],arguments))})}),n}function Xe(){}function nu(n){return Lr(n)?Ut(n):zt(n)}function tu(n){return n&&n.length?j(n,Ye):0}I=I?Jn.defaults({},I,Jn.pick(Vn,Bn)):Vn;var ru=I.Date,eu=I.Error,uu=I.Math,ou=I.RegExp,iu=I.TypeError,fu=I.Array.prototype,cu=I.Object.prototype,au=I.Function.prototype.toString,lu=cu.hasOwnProperty,su=0,hu=au.call(Object),pu=cu.toString,_u=Vn._,vu=ou("^"+au.call(lu).replace(on,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),gu=Pn?I.Buffer:q,du=I.Reflect,yu=I.Symbol,bu=I.Uint8Array,xu=I.clearTimeout,ju=du?du.f:q,mu=Object.getPrototypeOf,wu=Object.getOwnPropertySymbols,Au=typeof(Au=yu&&yu.iterator)=="symbol"?Au:q,Ou=Object.create,ku=cu.propertyIsEnumerable,Eu=I.setTimeout,Iu=fu.splice,Su=uu.ceil,Ru=uu.floor,Wu=I.isFinite,Bu=fu.join,Cu=Object.keys,Uu=uu.max,zu=uu.min,Mu=I.parseInt,Lu=uu.random,$u=fu.reverse,Fu=Ir(I,"Map"),Nu=Ir(I,"Set"),Du=Ir(I,"WeakMap"),Zu=Ir(Object,"create"),qu=Du&&new Du,Pu=!ku.call({ -valueOf:1},"valueOf"),Tu={},Ku=Fu?au.call(Fu):"",Gu=Nu?au.call(Nu):"",Vu=Du?au.call(Du):"",Ju=yu?yu.prototype:q,Yu=Ju?Ju.valueOf:q,Hu=Ju?Ju.toString:q;bn.templateSettings={escape:X,evaluate:nn,interpolate:tn,variable:"",imports:{_:bn}};var Qu=ir(_t),Xu=ir(vt,true),no=fr(),to=fr(true);ju&&!ku.call({valueOf:1},"valueOf")&&(kt=function(n){return M(ju(n))});var ro=qu?function(n,t){return qu.set(n,t),n}:Ye,eo=Nu&&2===new Nu([1,2]).size?function(n){return new Nu(n)}:Xe,uo=qu?function(n){return qu.get(n)}:Xe,oo=Ut("length"),io=wu||function(){ -return[]};(Fu&&"[object Map]"!=Rr(new Fu)||Nu&&"[object Set]"!=Rr(new Nu)||Du&&"[object WeakMap]"!=Rr(new Du))&&(Rr=function(n){var t=pu.call(n);if(n="[object Object]"==t?n.constructor:null,n=typeof n=="function"?au.call(n):"")switch(n){case Ku:return"[object Map]";case Gu:return"[object Set]";case Vu:return"[object WeakMap]"}return t});var fo=function(){var n=0,t=0;return function(r,e){var u=Uo(),o=16-(u-t);if(t=u,o>0){if(150<=++n)return r}else n=0;return ro(r,e)}}(),co=he(function(n,t){qo(n)||(n=null==n?[]:[Object(n)]), -t=ht(t,1);for(var r=n,e=t,u=-1,o=r.length,i=-1,f=e.length,c=Array(o+f);++u1?n[t-1]:q,t=typeof t=="function"?(n.pop(),t):q;return Qr(n,t)}),Eo=he(function(n){function t(t){return nt(t,n)}n=ht(n,1);var r=n.length,e=r?n[0]:0,u=this.__wrapped__;return 1>=r&&!this.__actions__.length&&u instanceof On&&z(e)?(u=u.slice(e,+e+(r?1:0)),u.__actions__.push({func:ne,args:[t],thisArg:q}),new An(u,this.__chain__).thru(function(n){return r&&!n.length&&n.push(q), -n})):this.thru(t)}),Io=ur(function(n,t,r){lu.call(n,r)?++n[r]:n[r]=1}),So=ur(function(n,t,r){lu.call(n,r)?n[r].push(t):n[r]=[t]}),Ro=he(function(n,t,e){var u=-1,o=typeof t=="function",i=Lr(t),f=ge(n)?Array(n.length):[];return Qu(n,function(n){var c=o?t:i&&null!=n?n[t]:q;f[++u]=c?r(c,n,e):mt(n,t,e)}),f}),Wo=ur(function(n,t,r){n[r]=t}),Bo=ur(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Co=he(function(n,t){if(null==n)return[];var r=t.length;return r>1&&Mr(n,t[0],t[1])?t=[]:r>2&&Mr(t[0],t[1],t[2])&&(t.length=1), -Wt(n,ht(t,1),[])}),Uo=ru.now,zo=he(function(n,t,r){var e=1;if(r.length)var u=$(r,Sr(zo)),e=32|e;return mr(n,e,t,r,u)}),Mo=he(function(n,t,r){var e=3;if(r.length)var u=$(r,Sr(Mo)),e=32|e;return mr(t,e,n,r,u)}),Lo=he(function(n,t){return ct(n,1,t)}),$o=he(function(n,t,r){return ct(n,ze(t)||0,r)}),Fo=he(function(n,t){t=a(ht(t,1),kr());var e=t.length;return he(function(u){for(var o=-1,i=zu(u.length,e);++oe.length?Kn(e,n,t):(r.array=null,r.map=new Mn(e))),(r=r.map)&&r.set(n,t),this},se.Cache=Mn,bn.after=function(n,t){if(typeof t!="function")throw new iu("Expected a function");return n=Ce(n),function(){return 1>--n?t.apply(this,arguments):void 0}},bn.ary=ie,bn.assign=To,bn.assignIn=Ko, -bn.assignInWith=Go,bn.assignWith=Vo,bn.at=Jo,bn.before=fe,bn.bind=zo,bn.bindAll=_i,bn.bindKey=Mo,bn.castArray=function(){if(!arguments.length)return[];var n=arguments[0];return qo(n)?n:[n]},bn.chain=Xr,bn.chunk=function(n,t){t=Uu(Ce(t),0);var r=n?n.length:0;if(!r||1>t)return[];for(var e=0,u=0,o=Array(Su(r/t));r>e;)o[u++]=Nt(n,e,e+=t);return o},bn.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++tr&&(r=-r>u?0:u+r),e=e===q||e>u?u:Ce(e),0>e&&(e+=u),e=r>e?0:Ue(e);e>r;)n[r++]=t;return n},bn.filter=function(n,t){return(qo(n)?i:st)(n,kr(t,3))},bn.flatMap=function(n,t){return ht(ue(n,t),1)},bn.flatten=function(n){ -return n&&n.length?ht(n,1):[]},bn.flattenDeep=function(n){return n&&n.length?ht(n,P):[]},bn.flattenDepth=function(n,t){return n&&n.length?(t=t===q?1:Ce(t),ht(n,t)):[]},bn.flip=function(n){return mr(n,512)},bn.flow=vi,bn.flowRight=gi,bn.fromPairs=function(n){for(var t=-1,r=n?n.length:0,e={};++tt?0:t)):[]},bn.takeRight=function(n,t,r){var e=n?n.length:0;return e?(t=r||t===q?1:Ce(t),t=e-t,Nt(n,0>t?0:t,e)):[]},bn.takeRightWhile=function(n,t){return n&&n.length?Kt(n,kr(t,3),false,true):[]},bn.takeWhile=function(n,t){return n&&n.length?Kt(n,kr(t,3)):[]},bn.tap=function(n,t){return t(n),n},bn.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new iu("Expected a function");return me(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),le(n,t,{leading:e,maxWait:t, -trailing:u})},bn.thru=ne,bn.toArray=Be,bn.toPairs=qe,bn.toPairsIn=function(n){return w(n,Ze(n))},bn.toPath=function(n){return qo(n)?a(n,String):qr(n)},bn.toPlainObject=Me,bn.transform=function(n,t,r){var e=qo(n)||Re(n);if(t=kr(t,4),null==r)if(e||me(n)){var o=n.constructor;r=e?qo(n)?new o:[]:be(o)?ft(mu(n)):{}}else r={};return(e?u:_t)(n,function(n,e,u){return t(r,n,e,u)}),r},bn.unary=function(n){return ie(n,1)},bn.union=yo,bn.unionBy=bo,bn.unionWith=xo,bn.uniq=function(n){return n&&n.length?Tt(n):[]; -},bn.uniqBy=function(n,t){return n&&n.length?Tt(n,kr(t)):[]},bn.uniqWith=function(n,t){return n&&n.length?Tt(n,q,t):[]},bn.unset=function(n,t){var r;if(null==n)r=true;else{r=n;var e=t,e=Lr(e,r)?[e+""]:et(e);r=Zr(r,e),e=Vr(e),r=null!=r&&Fe(r,e)?delete r[e]:true}return r},bn.unzip=Hr,bn.unzipWith=Qr,bn.update=function(n,t,r){return null==n?n:Ft(n,t,rt(r)(dt(n,t)),void 0)},bn.updateWith=function(n,t,r,e){return e=typeof e=="function"?e:q,null!=n&&(n=Ft(n,t,rt(r)(dt(n,t)),e)),n},bn.values=Pe,bn.valuesIn=function(n){ -return null==n?[]:O(n,Ze(n))},bn.without=jo,bn.words=Ve,bn.wrap=function(n,t){return t=null==t?Ye:t,No(t,n)},bn.xor=mo,bn.xorBy=wo,bn.xorWith=Ao,bn.zip=Oo,bn.zipObject=function(n,t){return Jt(n||[],t||[],Hn)},bn.zipObjectDeep=function(n,t){return Jt(n||[],t||[],Ft)},bn.zipWith=ko,bn.extend=Ko,bn.extendWith=Go,Qe(bn,bn),bn.add=function(n,t){var r;return n===q&&t===q?0:(n!==q&&(r=n),t!==q&&(r=r===q?t:r+t),r)},bn.attempt=pi,bn.camelCase=oi,bn.capitalize=Te,bn.ceil=Ai,bn.clamp=function(n,t,r){return r===q&&(r=t, -t=q),r!==q&&(r=ze(r),r=r===r?r:0),t!==q&&(t=ze(t),t=t===t?t:0),ut(ze(n),t,r)},bn.clone=function(n){return ot(n,false,true)},bn.cloneDeep=function(n){return ot(n,true,true)},bn.cloneDeepWith=function(n,t){return ot(n,true,true,t)},bn.cloneWith=function(n,t){return ot(n,false,true,t)},bn.deburr=Ke,bn.endsWith=function(n,t,r){n=Le(n),t=typeof t=="string"?t:t+"";var e=n.length;return r=r===q?e:ut(Ce(r),0,e),r-=t.length,r>=0&&n.indexOf(t,r)==r},bn.eq=pe,bn.escape=function(n){return(n=Le(n))&&Q.test(n)?n.replace(Y,W):n}, -bn.escapeRegExp=function(n){return(n=Le(n))&&fn.test(n)?n.replace(on,"\\$&"):n},bn.every=function(n,t,r){var e=qo(n)?o:lt;return r&&Mr(n,t,r)&&(t=q),e(n,kr(t,3))},bn.find=function(n,t){if(t=kr(t,3),qo(n)){var r=g(n,t);return r>-1?n[r]:q}return v(n,t,Qu)},bn.findIndex=function(n,t){return n&&n.length?g(n,kr(t,3)):-1},bn.findKey=function(n,t){return v(n,kr(t,3),_t,true)},bn.findLast=function(n,t){if(t=kr(t,3),qo(n)){var r=g(n,t,true);return r>-1?n[r]:q}return v(n,t,Xu)},bn.findLastIndex=function(n,t){return n&&n.length?g(n,kr(t,3),true):-1; -},bn.findLastKey=function(n,t){return v(n,kr(t,3),vt,true)},bn.floor=Oi,bn.forEach=re,bn.forEachRight=ee,bn.forIn=function(n,t){return null==n?n:no(n,rt(t),Ze)},bn.forInRight=function(n,t){return null==n?n:to(n,rt(t),Ze)},bn.forOwn=function(n,t){return n&&_t(n,rt(t))},bn.forOwnRight=function(n,t){return n&&vt(n,rt(t))},bn.get=$e,bn.gt=_e,bn.gte=function(n,t){return n>=t},bn.has=Fe,bn.hasIn=Ne,bn.head=Gr,bn.identity=Ye,bn.includes=function(n,t,r,e){return n=ge(n)?n:Pe(n),r=r&&!e?Ce(r):0,e=n.length,0>r&&(r=Uu(e+r,0)), -Ie(n)?e>=r&&-1r&&(r=Uu(e+r,0)),d(n,t,r)):-1},bn.inRange=function(n,t,r){return t=ze(t)||0,r===q?(r=t,t=0):r=ze(r)||0,n=ze(n),n>=zu(t,r)&&n=-9007199254740991&&9007199254740991>=n; -},bn.isSet=function(n){return we(n)&&"[object Set]"==Rr(n)},bn.isString=Ie,bn.isSymbol=Se,bn.isTypedArray=Re,bn.isUndefined=function(n){return n===q},bn.isWeakMap=function(n){return we(n)&&"[object WeakMap]"==Rr(n)},bn.isWeakSet=function(n){return we(n)&&"[object WeakSet]"==pu.call(n)},bn.join=function(n,t){return n?Bu.call(n,t):""},bn.kebabCase=ii,bn.last=Vr,bn.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(r!==q&&(u=Ce(r),u=(0>u?Uu(e+u,0):zu(u,e-1))+1),t!==t)return C(n,u,true); -for(;u--;)if(n[u]===t)return u;return-1},bn.lowerCase=fi,bn.lowerFirst=ci,bn.lt=We,bn.lte=function(n,t){return t>=n},bn.max=function(n){return n&&n.length?_(n,Ye,_e):q},bn.maxBy=function(n,t){return n&&n.length?_(n,kr(t),_e):q},bn.mean=function(n){return tu(n)/(n?n.length:0)},bn.min=function(n){return n&&n.length?_(n,Ye,We):q},bn.minBy=function(n,t){return n&&n.length?_(n,kr(t),We):q},bn.noConflict=function(){return Vn._===this&&(Vn._=_u),this},bn.noop=Xe,bn.now=Uo,bn.pad=function(n,t,r){n=Le(n), -t=Ce(t);var e=N(n);return t&&t>e?(e=(t-e)/2,t=Ru(e),e=Su(e),dr("",t,r)+n+dr("",e,r)):n},bn.padEnd=function(n,t,r){return n=Le(n),n+dr(n,t,r)},bn.padStart=function(n,t,r){return n=Le(n),dr(n,t,r)+n},bn.parseInt=function(n,t,r){return r||null==t?t=0:t&&(t=+t),n=Le(n).replace(cn,""),Mu(n,t||(_n.test(n)?16:10))},bn.random=function(n,t,r){if(r&&typeof r!="boolean"&&Mr(n,t,r)&&(t=r=q),r===q&&(typeof t=="boolean"?(r=t,t=q):typeof n=="boolean"&&(r=n,n=q)),n===q&&t===q?(n=0,t=1):(n=ze(n)||0,t===q?(t=n,n=0):t=ze(t)||0), -n>t){var e=n;n=t,t=e}return r||n%1||t%1?(r=Lu(),zu(n+r*(t-n+Nn("1e-"+((r+"").length-1))),t)):$t(n,t)},bn.reduce=function(n,t,r){var e=qo(n)?s:b,u=3>arguments.length;return e(n,kr(t,4),r,u,Qu)},bn.reduceRight=function(n,t,r){var e=qo(n)?h:b,u=3>arguments.length;return e(n,kr(t,4),r,u,Xu)},bn.repeat=Ge,bn.replace=function(){var n=arguments,t=Le(n[0]);return 3>n.length?t:t.replace(n[1],n[2])},bn.result=function(n,t,r){if(Lr(t,n))e=null==n?q:n[t];else{t=et(t);var e=$e(n,t);n=Zr(n,t)}return e===q&&(e=r), -be(e)?e.call(n):e},bn.round=ki,bn.runInContext=Z,bn.sample=function(n){n=ge(n)?n:Pe(n);var t=n.length;return t>0?n[$t(0,t-1)]:q},bn.size=function(n){if(null==n)return 0;if(ge(n)){var t=n.length;return t&&Ie(n)?N(n):t}return De(n).length},bn.snakeCase=li,bn.some=function(n,t,r){var e=qo(n)?p:Dt;return r&&Mr(n,t,r)&&(t=q),e(n,kr(t,3))},bn.sortedIndex=function(n,t){return Zt(n,t)},bn.sortedIndexBy=function(n,t,r){return qt(n,t,kr(r))},bn.sortedIndexOf=function(n,t){var r=n?n.length:0;if(r){var e=Zt(n,t); -if(r>e&&pe(n[e],t))return e}return-1},bn.sortedLastIndex=function(n,t){return Zt(n,t,true)},bn.sortedLastIndexBy=function(n,t,r){return qt(n,t,kr(r),true)},bn.sortedLastIndexOf=function(n,t){if(n&&n.length){var r=Zt(n,t,true)-1;if(pe(n[r],t))return r}return-1},bn.startCase=si,bn.startsWith=function(n,t,r){return n=Le(n),r=ut(Ce(r),0,n.length),n.lastIndexOf(t,r)==r},bn.subtract=function(n,t){var r;return n===q&&t===q?0:(n!==q&&(r=n),t!==q&&(r=r===q?t:r-t),r)},bn.sum=tu,bn.sumBy=function(n,t){return n&&n.length?j(n,kr(t)):0; -},bn.template=function(n,t,r){var e=bn.templateSettings;r&&Mr(n,t,r)&&(t=q),n=Le(n),t=Go({},t,e,Gn),r=Go({},t.imports,e.imports,Gn);var u,o,i=De(r),f=O(r,i),c=0;r=t.interpolate||jn;var a="__p+='";r=ou((t.escape||jn).source+"|"+r.source+"|"+(r===tn?hn:jn).source+"|"+(t.evaluate||jn).source+"|$","g");var l="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,i,f,l){return e||(e=i),a+=n.slice(c,l).replace(mn,B),r&&(u=true,a+="'+__e("+r+")+'"),f&&(o=true,a+="';"+f+";\n__p+='"), -e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),c=l+t.length,t}),a+="';",(t=t.variable)||(a="with(obj){"+a+"}"),a=(o?a.replace(K,""):a).replace(G,"$1").replace(V,"$1;"),a="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+a+"return __p}",t=pi(function(){return Function(i,l+"return "+a).apply(q,f)}),t.source=a,ye(t))throw t;return t},bn.times=function(n,t){if(n=Ce(n),1>n||n>9007199254740991)return[]; -var r=4294967295,e=zu(n,4294967295);for(t=rt(t),n-=4294967295,e=m(e,t);++r=o)return n;if(o=r-N(e),1>o)return e; -if(r=i?i.slice(0,o).join(""):n.slice(0,o),u===q)return r+e;if(i&&(o+=r.length-o),Ee(u)){if(n.slice(o).search(u)){var f=r;for(u.global||(u=ou(u.source,Le(pn.exec(u))+"g")),u.lastIndex=0;i=u.exec(f);)var c=i.index;r=r.slice(0,c===q?o:c)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),u>-1&&(r=r.slice(0,u)));return r+e},bn.unescape=function(n){return(n=Le(n))&&H.test(n)?n.replace(J,D):n},bn.uniqueId=function(n){var t=++su;return Le(n)+t},bn.upperCase=hi,bn.upperFirst=ai,bn.each=re,bn.eachRight=ee,bn.first=Gr, -Qe(bn,function(){var n={};return _t(bn,function(t,r){lu.call(bn.prototype,r)||(n[r]=t)}),n}(),{chain:false}),bn.VERSION="4.6.1",u("bind bindKey curry curryRight partial partialRight".split(" "),function(n){bn[n].placeholder=bn}),u(["drop","take"],function(n,t){On.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new On(this);r=r===q?1:Uu(Ce(r),0);var u=this.clone();return e?u.__takeCount__=zu(r,u.__takeCount__):u.__views__.push({size:zu(r,4294967295),type:n+(0>u.__dir__?"Right":"")}), -u},On.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),u(["filter","map","takeWhile"],function(n,t){var r=t+1,e=1==r||3==r;On.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({iteratee:kr(n,3),type:r}),t.__filtered__=t.__filtered__||e,t}}),u(["head","last"],function(n,t){var r="take"+(t?"Right":"");On.prototype[n]=function(){return this[r](1).value()[0]}}),u(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");On.prototype[n]=function(){return this.__filtered__?new On(this):this[r](1); -}}),On.prototype.compact=function(){return this.filter(Ye)},On.prototype.find=function(n){return this.filter(n).head()},On.prototype.findLast=function(n){return this.reverse().find(n)},On.prototype.invokeMap=he(function(n,t){return typeof n=="function"?new On(this):this.map(function(r){return mt(r,n,t)})}),On.prototype.reject=function(n){return n=kr(n,3),this.filter(function(t){return!n(t)})},On.prototype.slice=function(n,t){n=Ce(n);var r=this;return r.__filtered__&&(n>0||0>t)?new On(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)), -t!==q&&(t=Ce(t),r=0>t?r.dropRight(-t):r.take(t-n)),r)},On.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},On.prototype.toArray=function(){return this.take(4294967295)},_t(On.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=bn[e?"take"+("last"==t?"Right":""):t],o=e||/^find/.test(t);u&&(bn.prototype[t]=function(){function t(n){return n=u.apply(bn,l([n],f)),e&&h?n[0]:n}var i=this.__wrapped__,f=e?[1]:arguments,c=i instanceof On,a=f[0],s=c||qo(i); -s&&r&&typeof a=="function"&&1!=a.length&&(c=s=false);var h=this.__chain__,p=!!this.__actions__.length,a=o&&!h,c=c&&!p;return!o&&s?(i=c?i:new On(this),i=n.apply(i,f),i.__actions__.push({func:ne,args:[t],thisArg:q}),new An(i,h)):a&&c?n.apply(this,f):(i=this.thru(t),a?e?i.value()[0]:i.value():i)})}),u("pop push shift sort splice unshift".split(" "),function(n){var t=fu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/.test(n);bn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){ -return t.apply(r,n)})}}),_t(On.prototype,function(n,t){var r=bn[t];if(r){var e=r.name+"";(Tu[e]||(Tu[e]=[])).push({name:t,func:r})}}),Tu[_r(q,2).name]=[{name:"wrapper",func:q}],On.prototype.clone=function(){var n=new On(this.__wrapped__);return n.__actions__=nr(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=nr(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=nr(this.__views__),n},On.prototype.reverse=function(){if(this.__filtered__){var n=new On(this); -n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},On.prototype.value=function(){var n,t=this.__wrapped__.value(),r=this.__dir__,e=qo(t),u=0>r,o=e?t.length:0;n=o;for(var i=this.__views__,f=0,c=-1,a=i.length;++co||o==n&&a==n)return Gt(t,this.__actions__); -e=[];n:for(;n--&&a>c;){for(u+=r,o=-1,l=t[u];++o=this.__values__.length,t=n?q:this.__values__[this.__index__++]; -return{done:n,value:t}},bn.prototype.plant=function(n){for(var t,r=this;r instanceof wn;){var e=Pr(r);e.__index__=0,e.__values__=q,t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},bn.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof On?(this.__actions__.length&&(n=new On(this)),n=n.reverse(),n.__actions__.push({func:ne,args:[Yr],thisArg:q}),new An(n,this.__chain__)):this.thru(Yr)},bn.prototype.toJSON=bn.prototype.valueOf=bn.prototype.value=function(){return Gt(this.__wrapped__,this.__actions__); -},Au&&(bn.prototype[Au]=te),bn}var q,P=1/0,T=NaN,K=/\b__p\+='';/g,G=/\b(__p\+=)''\+/g,V=/(__e\(.*?\)|\b__t\))\+'';/g,J=/&(?:amp|lt|gt|quot|#39|#96);/g,Y=/[&<>"'`]/g,H=RegExp(J.source),Q=RegExp(Y.source),X=/<%-([\s\S]+?)%>/g,nn=/<%([\s\S]+?)%>/g,tn=/<%=([\s\S]+?)%>/g,rn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,en=/^\w*$/,un=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,on=/[\\^$.*+?()[\]{}|]/g,fn=RegExp(on.source),cn=/^\s+|\s+$/g,an=/^\s+/,ln=/\s+$/,sn=/\\(\\)?/g,hn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pn=/\w*$/,_n=/^0x/i,vn=/^[-+]0x[0-9a-f]+$/i,gn=/^0b[01]+$/i,dn=/^\[object .+?Constructor\]$/,yn=/^0o[0-7]+$/i,bn=/^(?:0|[1-9]\d*)$/,xn=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,jn=/($^)/,mn=/['\n\r\u2028\u2029\\]/g,wn="[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|\\ud83c[\\udffb-\\udfff])?(?:\\u200d(?:[^\\ud800-\\udfff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|\\ud83c[\\udffb-\\udfff])?)*",An="(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])"+wn,On="(?:[^\\ud800-\\udfff][\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]?|[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\ud800-\\udfff])",kn=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]","g"),En=RegExp("\\ud83c[\\udffb-\\udfff](?=\\ud83c[\\udffb-\\udfff])|"+On+wn,"g"),In=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),Sn=/[a-zA-Z0-9]+/g,Rn=RegExp(["[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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]|[A-Z\\xc0-\\xd6\\xd8-\\xde]|$)|(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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]|[A-Z\\xc0-\\xd6\\xd8-\\xde](?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])|$)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?(?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|\\d+",An].join("|"),"g"),Wn=/[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Bn="Array Buffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Map Math Object Reflect RegExp Set String Symbol TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap _ clearTimeout isFinite parseInt setTimeout".split(" "),Cn={}; -Cn["[object Float32Array]"]=Cn["[object Float64Array]"]=Cn["[object Int8Array]"]=Cn["[object Int16Array]"]=Cn["[object Int32Array]"]=Cn["[object Uint8Array]"]=Cn["[object Uint8ClampedArray]"]=Cn["[object Uint16Array]"]=Cn["[object Uint32Array]"]=true,Cn["[object Arguments]"]=Cn["[object Array]"]=Cn["[object ArrayBuffer]"]=Cn["[object Boolean]"]=Cn["[object Date]"]=Cn["[object Error]"]=Cn["[object Function]"]=Cn["[object Map]"]=Cn["[object Number]"]=Cn["[object Object]"]=Cn["[object RegExp]"]=Cn["[object Set]"]=Cn["[object String]"]=Cn["[object WeakMap]"]=false; -var Un={};Un["[object Arguments]"]=Un["[object Array]"]=Un["[object ArrayBuffer]"]=Un["[object Boolean]"]=Un["[object Date]"]=Un["[object Float32Array]"]=Un["[object Float64Array]"]=Un["[object Int8Array]"]=Un["[object Int16Array]"]=Un["[object Int32Array]"]=Un["[object Map]"]=Un["[object Number]"]=Un["[object Object]"]=Un["[object RegExp]"]=Un["[object Set]"]=Un["[object String]"]=Un["[object Symbol]"]=Un["[object Uint8Array]"]=Un["[object Uint8ClampedArray]"]=Un["[object Uint16Array]"]=Un["[object Uint32Array]"]=true, -Un["[object Error]"]=Un["[object Function]"]=Un["[object WeakMap]"]=false;var zn={"\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"},Mn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ln={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},$n={"function":true,object:true},Fn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029" -},Nn=parseFloat,Dn=parseInt,Zn=$n[typeof exports]&&exports&&!exports.nodeType?exports:q,qn=$n[typeof module]&&module&&!module.nodeType?module:q,Pn=qn&&qn.exports===Zn?Zn:q,Tn=I($n[typeof self]&&self),Kn=I($n[typeof window]&&window),Gn=I($n[typeof this]&&this),Vn=I(Zn&&qn&&typeof global=="object"&&global)||Kn!==(Gn&&Gn.window)&&Kn||Tn||Gn||Function("return this")(),Jn=Z();(Kn||Tn||{})._=Jn,typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return Jn}):Zn&&qn?(Pn&&((qn.exports=Jn)._=Jn), -Zn._=Jn):Vn._=Jn}).call(this); \ No newline at end of file +;(function(){function t(t,n){return t.set(n[0],n[1]),t}function n(t,n){return t.add(n),t}function r(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function e(t,n,r,e){for(var u=-1,o=t.length;++un&&!o||!u||r&&!i&&f||e&&f)return 1;if(n>t&&!r||!f||o&&!e&&u||i&&u)return-1}return 0}function W(t){return function(n,r){var e; +return n===T&&r===T?0:(n!==T&&(e=n),r!==T&&(e=e===T?r:t(e,r)),e)}}function B(t){return Mt[t]}function C(t){return Lt[t]}function z(t){return"\\"+Ft[t]}function U(t,n,r){var e=t.length;for(n+=r?0:-1;r?n--:++n-1&&0==t%1&&(null==n?9007199254740991:n)>t}function $(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value); +return r}function D(t){var n=-1,r=Array(t.size);return t.forEach(function(t,e){r[++n]=[e,t]}),r}function F(t,n){for(var r=-1,e=t.length,u=0,o=[];++rr?false:(r==t.length-1?t.pop():Ru.call(t,r,1),true)}function qt(t,n){var r=Vt(t,n);return 0>r?T:t[r][1]}function Vt(t,n){for(var r=t.length;r--;)if(de(t[r][0],n))return r;return-1}function Kt(t,n,r){ +var e=Vt(t,n);0>e?t.push([n,r]):t[e][1]=r}function Gt(t,n,r,e){return t===T||de(t,su[r])&&!pu.call(e,r)?n:t}function Ht(t,n,r){(r===T||de(t[n],r))&&(typeof n!="number"||r!==T||n in t)||(t[n]=r)}function Qt(t,n,r){var e=t[n];pu.call(t,n)&&de(e,r)&&(r!==T||n in t)||(t[n]=r)}function Xt(t,n,r,e){return oo(t,function(t,u,o){n(e,t,r(t),o)}),e}function tn(t,n){return t&&ur(n,Te(n),t)}function nn(t,n){for(var r=-1,e=null==t,u=n.length,o=Array(u);++rr?r:t),n!==T&&(t=n>t?n:t)),t}function fn(t,n,r,e,o,i,f){var c;if(e&&(c=i?e(t,o,i,f):e(t)),c!==T)return c;if(!ke(t))return t;if(o=Yo(t)){if(c=Mr(t),!n)return er(t,c)}else{var a=zr(t),l="[object Function]"==a||"[object GeneratorFunction]"==a;if(Ho(t))return Xn(t,n);if("[object Object]"==a||"[object Arguments]"==a||l&&!i){if(M(t))return i?t:{};if(c=Lr(l?{}:t),!n)return ir(t,tn(c,t)); +}else{if(!Ut[a])return i?t:{};c=$r(t,a,fn,n)}}if(f||(f=new Ft),i=f.get(t))return i;if(f.set(t,c),!o)var s=r?bn(t,Te,Cr):Te(t);return u(s||t,function(u,o){s&&(o=u,u=t[o]),Qt(c,o,fn(u,n,r,e,o,t,f))}),c}function cn(t){var n=Te(t),r=n.length;return function(e){if(null==e)return!r;for(var u=r;u--;){var o=n[u],i=t[o],f=e[o];if(f===T&&!(o in Object(e))||!i(f))return false}return true}}function an(t){return ke(t)?Eu(t):{}}function ln(t,n,r){if(typeof t!="function")throw new au("Expected a function");return Su(function(){ +t.apply(T,r)},n)}function sn(t,n,r,e){var u=-1,o=f,i=true,l=t.length,s=[],h=n.length;if(!l)return s;r&&(n=a(n,O(r))),e?(o=c,i=false):n.length>=200&&(o=Dt,i=false,n=new $t(n));t:for(;++u0&&je(i)&&(r||Yo(i)||be(i))?n>1?_n(i,n-1,r,e):l(e,i):r||(e[e.length]=i)}return e}function vn(t,n){return t&&fo(t,n,Te)}function gn(t,n){return t&&co(t,n,Te)}function dn(t,n){return i(n,function(n){return we(t[n])})}function yn(t,n){n=Nr(n,t)?[n]:un(n);for(var r=0,e=n.length;null!=t&&e>r;)t=t[n[r++]];return r&&r==e?t:T}function bn(t,n,r){return n=n(t),Yo(t)?n:l(n,r(t))}function xn(t,n){return pu.call(t,n)||typeof t=="object"&&n in t&&null===Cu(Object(t))}function jn(t,n){return n in Object(t); +}function mn(t,n,r){for(var e=r?c:f,u=t[0].length,o=t.length,i=o,l=Array(o),s=1/0,h=[];i--;){var p=t[i];i&&n&&(p=a(p,O(n))),s=$u(p.length,s),l[i]=r||!n&&(120>u||120>p.length)?T:new $t(i&&p)}var p=t[0],_=-1,v=l[0];t:for(;++_h.length;){var g=p[_],d=n?n(g):g;if(v?!Dt(v,d):!e(h,d,r)){for(i=o;--i;){var y=l[i];if(y?!Dt(y,d):!e(t[i],d,r))continue t}v&&v.push(d),h.push(g)}}return h}function wn(t,n,r){var e={};return vn(t,function(t,u,o){n(e,r(t),u,o)}),e}function An(t,n,e){return Nr(n,t)||(n=un(n), +t=Vr(t,n),n=Hr(n)),n=null==t?t:t[n],null==n?T:r(n,t,e)}function On(t,n,r,e,u){if(t===n)n=true;else if(null==t||null==n||!ke(t)&&!Ee(n))n=t!==t&&n!==n;else t:{var o=Yo(t),i=Yo(n),f="[object Array]",c="[object Array]";o||(f=zr(t),f="[object Arguments]"==f?"[object Object]":f),i||(c=zr(n),c="[object Arguments]"==c?"[object Object]":c);var a="[object Object]"==f&&!M(t),i="[object Object]"==c&&!M(n);if((c=f==c)&&!a)u||(u=new Ft),n=o||ze(t)?kr(t,n,On,r,e,u):Er(t,n,f,On,r,e,u);else{if(!(2&e)&&(o=a&&pu.call(t,"__wrapped__"), +f=i&&pu.call(n,"__wrapped__"),o||f)){t=o?t.value():t,n=f?n.value():n,u||(u=new Ft),n=On(t,n,r,e,u);break t}if(c)n:if(u||(u=new Ft),o=2&e,f=Te(t),i=f.length,c=Te(n).length,i==c||o){for(a=i;a--;){var l=f[a];if(!(o?l in n:xn(n,l))){n=false;break n}}if(c=u.get(t))n=c==n;else{c=true,u.set(t,n);for(var s=o;++ae?c*("desc"==r[e]?-1:1):c;break t}}e=t.b-n.b}return e})}function zn(t,n){return t=Object(t),s(n,function(n,r){return r in t&&(n[r]=t[r]),n},{})}function Un(t,n){for(var r=-1,e=bn(t,Ve,po),u=e.length,o={};++rn||n>9007199254740991)return r;do n%2&&(r+=t),(n=Bu(n/2))&&(t+=t);while(n);return r; +}function Pn(t,n,r,e){n=Nr(n,t)?[n]:un(n);for(var u=-1,o=n.length,i=o-1,f=t;null!=f&&++un&&(n=-n>u?0:u+n),r=r>u?u:r,0>r&&(r+=u),u=n>r?0:r-n>>>0,n>>>=0,r=Array(u);++e=u){ +for(;u>e;){var o=e+u>>>1,i=t[o];(r?n>=i:n>i)&&null!==i?e=o+1:u=o}return u}return Vn(t,n,tu,r)}function Vn(t,n,r,e){n=r(n);for(var u=0,o=t?t.length:0,i=n!==n,f=null===n,c=n===T;o>u;){var a=Bu((u+o)/2),l=r(t[a]),s=l!==T,h=l===l;(i?h||e:f?h&&s&&(e||null!=l):c?h&&(e||s):null==l?0:e?n>=l:n>l)?u=a+1:o=a}return $u(o,4294967294)}function Kn(t,n){for(var r=0,e=t.length,u=t[0],o=n?n(u):u,i=o,f=1,c=[u];++re?n[e]:T);return i}function Xn(t,n){if(n)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}function tr(t){var n=new t.constructor(t.byteLength);return new mu(n).set(new mu(t)),n}function nr(t,n,r,e){var u=-1,o=t.length,i=r.length,f=-1,c=n.length,a=Lu(o-i,0),l=Array(c+a);for(e=!e;++fu)&&(l[r[u]]=t[u]);for(;a--;)l[f++]=t[u++];return l}function rr(t,n,r,e){var u=-1,o=t.length,i=-1,f=r.length,c=-1,a=n.length,l=Lu(o-f,0),s=Array(l+a);for(e=!e;++uu)&&(s[l+r[i]]=t[u++]);return s}function er(t,n){var r=-1,e=t.length;for(n||(n=Array(e));++r1?r[u-1]:T,i=u>2?r[2]:T,o=typeof o=="function"?(u--,o):T;for(i&&Fr(r[0],r[1],i)&&(o=3>u?T:o,u=1),n=Object(n);++ei&&f[0]!==a&&f[i-1]!==a?[]:F(f,a),i-=c.length,e>i?wr(t,n,dr,u.placeholder,T,f,c,T,T,e-i):r(this&&this!==Jt&&this instanceof u?o:t,this,f)}var o=_r(t);return u}function gr(t){return ve(function(n){n=_n(n,1);var r=n.length,e=r,u=Ot.prototype.thru;for(t&&n.reverse();e--;){var o=n[e];if(typeof o!="function")throw new au("Expected a function");if(u&&!i&&"wrapper"==Ir(o))var i=new Ot([],true)}for(e=i?e:r;++e=200)return i.plant(e).value();for(var u=0,t=r?n[u].apply(this,t):e;++ud)return j=F(b,j),wr(t,n,dr,l.placeholder,r,b,j,f,c,a-d);if(j=h?r:this,y=p?j[t]:t,d=b.length,f){x=b.length; +for(var m=$u(f.length,x),w=er(b);m--;){var A=f[m];b[m]=L(A,x)?w[A]:T}}else v&&d>1&&b.reverse();return s&&d>c&&(b.length=c),this&&this!==Jt&&this instanceof l&&(y=g||_r(y)),y.apply(j,b)}var s=128&n,h=1&n,p=2&n,_=24&n,v=512&n,g=p?T:_r(t);return l}function yr(t,n){return function(r,e){return wn(r,t,n(e))}}function br(t){return ve(function(n){return n=a(_n(n,1),Sr()),ve(function(e){var u=this;return t(n,function(t){return r(t,u,e)})})})}function xr(t,n){n=n===T?" ":n+"";var r=n.length;return 2>r?r?Nn(n,t):n:(r=Nn(n,Wu(t/P(n))), +St.test(n)?r.match(It).slice(0,t).join(""):r.slice(0,t))}function jr(t,n,e,u){function o(){for(var n=-1,c=arguments.length,a=-1,l=u.length,s=Array(l+c),h=this&&this!==Jt&&this instanceof o?f:t;++an?1:-1:De(e)||0;var u=-1;r=Lu(Wu((r-n)/(e||1)),0);for(var o=Array(r);r--;)o[t?r:++u]=n, +n+=e;return o}}function wr(t,n,r,e,u,o,i,f,c,a){var l=8&n;f=f?er(f):T;var s=l?i:T;i=l?T:i;var h=l?o:T;return o=l?T:o,n=(n|(l?32:64))&~(l?64:32),4&n||(n&=-4),n=[t,n,u,h,s,o,i,f,c,a],r=r.apply(T,n),Zr(t)&&_o(r,n),r.placeholder=e,r}function Ar(t){var n=fu[t];return function(t,r){if(t=De(t),r=Le(r)){var e=(Ne(t)+"e").split("e"),e=n(e[0]+"e"+(+e[1]+r)),e=(Ne(e)+"e").split("e");return+(e[0]+"e"+(+e[1]-r))}return n(t)}}function Or(t,n,r,e,u,o,i,f){var c=2&n;if(!c&&typeof t!="function")throw new au("Expected a function"); +var a=e?e.length:0;if(a||(n&=-97,e=u=T),i=i===T?i:Lu(Le(i),0),f=f===T?f:Le(f),a-=u?u.length:0,64&n){var l=e,s=u;e=u=T}var h=c?T:so(t);return o=[t,n,r,e,u,l,s,o,i,f],h&&(r=o[1],t=h[1],n=r|t,e=128==t&&8==r||128==t&&256==r&&h[8]>=o[7].length||384==t&&h[8]>=h[7].length&&8==r,131>n||e)&&(1&t&&(o[2]=h[2],n|=1&r?0:4),(r=h[3])&&(e=o[3],o[3]=e?nr(e,r,h[4]):er(r),o[4]=e?F(o[3],"__lodash_placeholder__"):er(h[4])),(r=h[5])&&(e=o[5],o[5]=e?rr(e,r,h[6]):er(r),o[6]=e?F(o[5],"__lodash_placeholder__"):er(h[6])),(r=h[7])&&(o[7]=er(r)), +128&t&&(o[8]=null==o[8]?h[8]:$u(o[8],h[8])),null==o[9]&&(o[9]=h[9]),o[0]=h[0],o[1]=n),t=o[0],n=o[1],r=o[2],e=o[3],u=o[4],f=o[9]=null==o[9]?c?0:t.length:Lu(o[9]-a,0),!f&&24&n&&(n&=-25),(h?ao:_o)(n&&1!=n?8==n||16==n?vr(t,n,f):32!=n&&33!=n||u.length?dr.apply(T,o):jr(t,n,r,e):sr(t,n,r),o)}function kr(t,n,r,e,u,o){var i=-1,f=2&u,c=1&u,a=t.length,l=n.length;if(!(a==l||f&&l>a))return false;if(l=o.get(t))return l==n;for(l=true,o.set(t,n);++in?0:n,e)):[]}function Jr(t,n,r){var e=t?t.length:0;return e?(n=r||n===T?1:Le(n),n=e-n,Zn(t,0,0>n?0:n)):[]}function Yr(t){return t?t[0]:T}function Hr(t){var n=t?t.length:0;return n?t[n-1]:T}function Qr(t,n){return t&&t.length&&n&&n.length?$n(t,n):t}function Xr(t){return t?Nu.call(t):t}function te(t){if(!t||!t.length)return[];var n=0;return t=i(t,function(t){ +return je(t)?(n=Lu(t.length,n),true):void 0}),w(n,function(n){return a(t,Mn(n))})}function ne(t,n){if(!t||!t.length)return[];var e=te(t);return null==n?e:a(e,function(t){return r(n,T,t)})}function re(t){return t=xt(t),t.__chain__=true,t}function ee(t,n){return n(t)}function ue(){return this}function oe(t,n){return typeof n=="function"&&Yo(t)?u(t,n):oo(t,Sr(n))}function ie(t,n){var r;if(typeof n=="function"&&Yo(t)){for(r=t.length;r--&&false!==n(t[r],r,t););r=t}else r=io(t,Sr(n));return r}function fe(t,n){ +return(Yo(t)?a:Sn)(t,Sr(n,3))}function ce(t,n){var r=-1,e=Me(t),u=e.length,o=u-1;for(n=on(Le(n),0,u);++r=t&&(n=T),r}}function se(t,n,r){return n=r?T:n,t=Or(t,8,T,T,T,T,T,n),t.placeholder=se.placeholder,t}function he(t,n,r){ +return n=r?T:n,t=Or(t,16,T,T,T,T,T,n),t.placeholder=he.placeholder,t}function pe(t,n,r){function e(n){var r=c,e=a;return c=a=T,p=n,l=t.apply(e,r)}function u(t){var r=t-h;return t-=p,!h||r>=n||0>r||false!==v&&t>=v}function o(){var t=No();if(u(t))return i(t);var r;r=t-p,t=n-(t-h),r=false===v?t:$u(t,v-r),s=Su(o,r)}function i(t){return wu(s),s=T,g&&c?e(t):(c=a=T,l)}function f(){var t=No(),r=u(t);return c=arguments,a=this,h=t,r?s===T?(p=t=h,s=Su(o,n),_?e(t):l):(wu(s),s=Su(o,n),e(h)):l}var c,a,l,s,h=0,p=0,_=false,v=false,g=true; +if(typeof t!="function")throw new au("Expected a function");return n=De(n)||0,ke(r)&&(_=!!r.leading,v="maxWait"in r&&Lu(De(r.maxWait)||0,n),g="trailing"in r?!!r.trailing:g),f.cancel=function(){s!==T&&wu(s),h=p=0,c=a=s=T},f.flush=function(){return s===T?l:i(No())},f}function _e(t,n){function r(){var e=arguments,u=n?n.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=t.apply(this,e),r.cache=o.set(u,e),e)}if(typeof t!="function"||n&&typeof n!="function")throw new au("Expected a function");return r.cache=new(_e.Cache||Lt), +r}function ve(t,n){if(typeof t!="function")throw new au("Expected a function");return n=Lu(n===T?t.length-1:Le(n),0),function(){for(var e=arguments,u=-1,o=Lu(e.length-n,0),i=Array(o);++un}function be(t){return je(t)&&pu.call(t,"callee")&&(!Iu.call(t,"callee")||"[object Arguments]"==gu.call(t))}function xe(t){return null!=t&&Oe(ho(t))&&!we(t)}function je(t){return Ee(t)&&xe(t)}function me(t){return Ee(t)?"[object Error]"==gu.call(t)||typeof t.message=="string"&&typeof t.name=="string":false}function we(t){return t=ke(t)?gu.call(t):"","[object Function]"==t||"[object GeneratorFunction]"==t}function Ae(t){return typeof t=="number"&&t==Le(t)}function Oe(t){return typeof t=="number"&&t>-1&&0==t%1&&9007199254740991>=t; +}function ke(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function Ee(t){return!!t&&typeof t=="object"}function Ie(t){return null==t?false:we(t)?yu.test(hu.call(t)):Ee(t)&&(M(t)?yu:yt).test(t)}function Se(t){return typeof t=="number"||Ee(t)&&"[object Number]"==gu.call(t)}function Re(t){return!Ee(t)||"[object Object]"!=gu.call(t)||M(t)?false:(t=Cu(Object(t)),null===t?true:(t=pu.call(t,"constructor")&&t.constructor,typeof t=="function"&&t instanceof t&&hu.call(t)==vu))}function We(t){return ke(t)&&"[object RegExp]"==gu.call(t); +}function Be(t){return typeof t=="string"||!Yo(t)&&Ee(t)&&"[object String]"==gu.call(t)}function Ce(t){return typeof t=="symbol"||Ee(t)&&"[object Symbol]"==gu.call(t)}function ze(t){return Ee(t)&&Oe(t.length)&&!!zt[gu.call(t)]}function Ue(t,n){return n>t}function Me(t){if(!t)return[];if(xe(t))return Be(t)?t.match(It):er(t);if(ku&&t[ku])return $(t[ku]());var n=zr(t);return("[object Map]"==n?D:"[object Set]"==n?N:Je)(t)}function Le(t){if(!t)return 0===t?t:0;if(t=De(t),t===V||t===-V)return 1.7976931348623157e308*(0>t?-1:1); +var n=t%1;return t===t?n?t-n:t:0}function $e(t){return t?on(Le(t),0,4294967295):0}function De(t){if(typeof t=="number")return t;if(Ce(t))return K;if(ke(t)&&(t=we(t.valueOf)?t.valueOf():t,t=ke(t)?t+"":t),typeof t!="string")return 0===t?t:+t;t=t.replace(at,"");var n=dt.test(t);return n||bt.test(t)?Pt(t.slice(2),n?2:8):gt.test(t)?K:+t}function Fe(t){return ur(t,Ve(t))}function Ne(t){if(typeof t=="string")return t;if(null==t)return"";if(Ce(t))return uo?uo.call(t):"";var n=t+"";return"0"==n&&1/t==-V?"-0":n; +}function Pe(t,n,r){return t=null==t?T:yn(t,n),t===T?r:t}function Ze(t,n){return Ur(t,n,xn)}function qe(t,n){return Ur(t,n,jn)}function Te(t){var n=qr(t);if(!n&&!xe(t))return Mu(Object(t));var r,e=Dr(t),u=!!e,e=e||[],o=e.length;for(r in t)!xn(t,r)||u&&("length"==r||L(r,o))||n&&"constructor"==r||e.push(r);return e}function Ve(t){for(var n=-1,r=qr(t),e=In(t),u=e.length,o=Dr(t),i=!!o,o=o||[],f=o.length;++ne.length?Kt(e,t,n):(r.array=null,r.map=new Lt(e))),(r=r.map)&&r.set(t,n),this};var oo=ar(vn),io=ar(gn,true),fo=lr(),co=lr(true); +Au&&!Iu.call({valueOf:1},"valueOf")&&(In=function(t){return $(Au(t))});var ao=Gu?function(t,n){return Gu.set(t,n),t}:tu,lo=Tu&&2===new Tu([1,2]).size?function(t){return new Tu(t)}:eu,so=Gu?function(t){return Gu.get(t)}:eu,ho=Mn("length");Ou||(Cr=function(){return[]});var po=Ou?function(t){for(var n=[];t;)l(n,Cr(t)),t=Cu(Object(t));return n}:Cr;(Pu&&"[object DataView]"!=zr(new Pu(new ArrayBuffer(1)))||Zu&&"[object Map]"!=zr(new Zu)||qu&&"[object Promise]"!=zr(qu.resolve())||Tu&&"[object Set]"!=zr(new Tu)||Vu&&"[object WeakMap]"!=zr(new Vu))&&(zr=function(t){ +var n=gu.call(t);if(t="[object Object]"==n?t.constructor:null,t=typeof t=="function"?hu.call(t):"")switch(t){case Hu:return"[object DataView]";case Qu:return"[object Map]";case Xu:return"[object Promise]";case to:return"[object Set]";case no:return"[object WeakMap]"}return n});var _o=function(){var t=0,n=0;return function(r,e){var u=No(),o=16-(u-n);if(n=u,o>0){if(150<=++t)return r}else t=0;return ao(r,e)}}(),vo=_e(function(t){var n=[];return Ne(t).replace(it,function(t,r,e,u){n.push(e?u.replace(ht,"$1"):r||t); +}),n}),go=ve(function(t,n){return je(t)?sn(t,_n(n,1,true)):[]}),yo=ve(function(t,n){var r=Hr(n);return je(r)&&(r=T),je(t)?sn(t,_n(n,1,true),Sr(r)):[]}),bo=ve(function(t,n){var r=Hr(n);return je(r)&&(r=T),je(t)?sn(t,_n(n,1,true),T,r):[]}),xo=ve(function(t){var n=a(t,rn);return n.length&&n[0]===t[0]?mn(n):[]}),jo=ve(function(t){var n=Hr(t),r=a(t,rn);return n===Hr(r)?n=T:r.pop(),r.length&&r[0]===t[0]?mn(r,Sr(n)):[]}),mo=ve(function(t){var n=Hr(t),r=a(t,rn);return n===Hr(r)?n=T:r.pop(),r.length&&r[0]===t[0]?mn(r,T,n):[]; +}),wo=ve(Qr),Ao=ve(function(t,n){n=a(_n(n,1),String);var r=nn(t,n);return Dn(t,n.sort(R)),r}),Oo=ve(function(t){return Gn(_n(t,1,true))}),ko=ve(function(t){var n=Hr(t);return je(n)&&(n=T),Gn(_n(t,1,true),Sr(n))}),Eo=ve(function(t){var n=Hr(t);return je(n)&&(n=T),Gn(_n(t,1,true),T,n)}),Io=ve(function(t,n){return je(t)?sn(t,n):[]}),So=ve(function(t){return Hn(i(t,je))}),Ro=ve(function(t){var n=Hr(t);return je(n)&&(n=T),Hn(i(t,je),Sr(n))}),Wo=ve(function(t){var n=Hr(t);return je(n)&&(n=T),Hn(i(t,je),T,n)}),Bo=ve(te),Co=ve(function(t){ +var n=t.length,n=n>1?t[n-1]:T,n=typeof n=="function"?(t.pop(),n):T;return ne(t,n)}),zo=ve(function(t){function n(n){return nn(n,t)}t=_n(t,1);var r=t.length,e=r?t[0]:0,u=this.__wrapped__;return 1>=r&&!this.__actions__.length&&u instanceof kt&&L(e)?(u=u.slice(e,+e+(r?1:0)),u.__actions__.push({func:ee,args:[n],thisArg:T}),new Ot(u,this.__chain__).thru(function(t){return r&&!t.length&&t.push(T),t})):this.thru(n)}),Uo=fr(function(t,n,r){pu.call(t,r)?++t[r]:t[r]=1}),Mo=fr(function(t,n,r){pu.call(t,r)?t[r].push(n):t[r]=[n]; +}),Lo=ve(function(t,n,e){var u=-1,o=typeof n=="function",i=Nr(n),f=xe(t)?Array(t.length):[];return oo(t,function(t){var c=o?n:i&&null!=t?t[n]:T;f[++u]=c?r(c,t,e):An(t,n,e)}),f}),$o=fr(function(t,n,r){t[r]=n}),Do=fr(function(t,n,r){t[r?0:1].push(n)},function(){return[[],[]]}),Fo=ve(function(t,n){if(null==t)return[];var r=n.length;return r>1&&Fr(t,n[0],n[1])?n=[]:r>2&&Fr(n[0],n[1],n[2])&&(n.length=1),Cn(t,_n(n,1),[])}),No=ou.now,Po=ve(function(t,n,r){var e=1;if(r.length)var u=F(r,Br(Po)),e=32|e;return Or(t,e,n,r,u); +}),Zo=ve(function(t,n,r){var e=3;if(r.length)var u=F(r,Br(Zo)),e=32|e;return Or(n,e,t,r,u)}),qo=ve(function(t,n){return ln(t,1,n)}),To=ve(function(t,n,r){return ln(t,De(n)||0,r)});_e.Cache=Lt;var Vo=ve(function(t,n){n=a(_n(n,1),Sr());var e=n.length;return ve(function(u){for(var o=-1,i=$u(u.length,e);++o--t?n.apply(this,arguments):void 0}},xt.ary=ae,xt.assign=Qo,xt.assignIn=Xo,xt.assignInWith=ti,xt.assignWith=ni,xt.at=ri,xt.before=le,xt.bind=Po,xt.bindAll=ji,xt.bindKey=Zo,xt.castArray=ge,xt.chain=re,xt.chunk=function(t,n){ +n=Lu(Le(n),0);var r=t?t.length:0;if(!r||1>n)return[];for(var e=0,u=0,o=Array(Wu(r/n));r>e;)o[u++]=Zn(t,e,e+=n);return o},xt.compact=function(t){for(var n=-1,r=t?t.length:0,e=0,u=[];++nt)return t?er(n):[];for(var r=Array(t-1);t--;)r[t-1]=arguments[t];for(var t=_n(r,1),r=-1,e=n.length,u=-1,o=t.length,i=Array(e+o);++rr&&(r=-r>u?0:u+r),e=e===T||e>u?u:Le(e),0>e&&(e+=u),e=r>e?0:$e(e);e>r;)t[r++]=n;return t},xt.filter=function(t,n){return(Yo(t)?i:pn)(t,Sr(n,3))},xt.flatMap=function(t,n){return _n(fe(t,n),1)},xt.flatMapDeep=function(t,n){ +return _n(fe(t,n),V)},xt.flatMapDepth=function(t,n,r){return r=r===T?1:Le(r),_n(fe(t,n),r)},xt.flatten=function(t){return t&&t.length?_n(t,1):[]},xt.flattenDeep=function(t){return t&&t.length?_n(t,V):[]},xt.flattenDepth=function(t,n){return t&&t.length?(n=n===T?1:Le(n),_n(t,n)):[]},xt.flip=function(t){return Or(t,512)},xt.flow=mi,xt.flowRight=wi,xt.fromPairs=function(t){for(var n=-1,r=t?t.length:0,e={};++nn?0:n)):[]},xt.takeRight=function(t,n,r){var e=t?t.length:0;return e?(n=r||n===T?1:Le(n),n=e-n,Zn(t,0>n?0:n,e)):[]},xt.takeRightWhile=function(t,n){return t&&t.length?Jn(t,Sr(n,3),false,true):[]},xt.takeWhile=function(t,n){return t&&t.length?Jn(t,Sr(n,3)):[]},xt.tap=function(t,n){return n(t),t},xt.throttle=function(t,n,r){var e=true,u=true;if(typeof t!="function")throw new au("Expected a function"); +return ke(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),pe(t,n,{leading:e,maxWait:n,trailing:u})},xt.thru=ee,xt.toArray=Me,xt.toPairs=Ke,xt.toPairsIn=Ge,xt.toPath=function(t){return Yo(t)?a(t,en):Ce(t)?[t]:er(vo(t))},xt.toPlainObject=Fe,xt.transform=function(t,n,r){var e=Yo(t)||ze(t);if(n=Sr(n,4),null==r)if(e||ke(t)){var o=t.constructor;r=e?Yo(t)?new o:[]:we(o)?an(Cu(Object(t))):{}}else r={};return(e?u:vn)(t,function(t,e,u){return n(r,t,e,u)}),r},xt.unary=function(t){return ae(t,1); +},xt.union=Oo,xt.unionBy=ko,xt.unionWith=Eo,xt.uniq=function(t){return t&&t.length?Gn(t):[]},xt.uniqBy=function(t,n){return t&&t.length?Gn(t,Sr(n)):[]},xt.uniqWith=function(t,n){return t&&t.length?Gn(t,T,n):[]},xt.unset=function(t,n){var r;if(null==t)r=true;else{r=t;var e=n,e=Nr(e,r)?[e]:un(e);r=Vr(r,e),e=Hr(e),r=null!=r&&Ze(r,e)?delete r[e]:true}return r},xt.unzip=te,xt.unzipWith=ne,xt.update=function(t,n,r){return null==t?t:Pn(t,n,(typeof r=="function"?r:tu)(yn(t,n)),void 0)},xt.updateWith=function(t,n,r,e){ +return e=typeof e=="function"?e:T,null!=t&&(t=Pn(t,n,(typeof r=="function"?r:tu)(yn(t,n)),e)),t},xt.values=Je,xt.valuesIn=function(t){return null==t?[]:k(t,Ve(t))},xt.without=Io,xt.words=Qe,xt.wrap=function(t,n){return n=null==n?tu:n,Ko(n,t)},xt.xor=So,xt.xorBy=Ro,xt.xorWith=Wo,xt.zip=Bo,xt.zipObject=function(t,n){return Qn(t||[],n||[],Qt)},xt.zipObjectDeep=function(t,n){return Qn(t||[],n||[],Pn)},xt.zipWith=Co,xt.entries=Ke,xt.entriesIn=Ge,xt.extend=Xo,xt.extendWith=ti,ru(xt,xt),xt.add=Wi,xt.attempt=xi, +xt.camelCase=hi,xt.capitalize=Ye,xt.ceil=Bi,xt.clamp=function(t,n,r){return r===T&&(r=n,n=T),r!==T&&(r=De(r),r=r===r?r:0),n!==T&&(n=De(n),n=n===n?n:0),on(De(t),n,r)},xt.clone=function(t){return fn(t,false,true)},xt.cloneDeep=function(t){return fn(t,true,true)},xt.cloneDeepWith=function(t,n){return fn(t,true,true,n)},xt.cloneWith=function(t,n){return fn(t,false,true,n)},xt.deburr=He,xt.divide=Ci,xt.endsWith=function(t,n,r){t=Ne(t),n=typeof n=="string"?n:n+"";var e=t.length;return r=r===T?e:on(Le(r),0,e),r-=n.length, +r>=0&&t.indexOf(n,r)==r},xt.eq=de,xt.escape=function(t){return(t=Ne(t))&&tt.test(t)?t.replace(Q,C):t},xt.escapeRegExp=function(t){return(t=Ne(t))&&ct.test(t)?t.replace(ft,"\\$&"):t},xt.every=function(t,n,r){var e=Yo(t)?o:hn;return r&&Fr(t,n,r)&&(n=T),e(t,Sr(n,3))},xt.find=function(t,n){if(n=Sr(n,3),Yo(t)){var r=g(t,n);return r>-1?t[r]:T}return v(t,n,oo)},xt.findIndex=function(t,n){return t&&t.length?g(t,Sr(n,3)):-1},xt.findKey=function(t,n){return v(t,Sr(n,3),vn,true)},xt.findLast=function(t,n){if(n=Sr(n,3), +Yo(t)){var r=g(t,n,true);return r>-1?t[r]:T}return v(t,n,io)},xt.findLastIndex=function(t,n){return t&&t.length?g(t,Sr(n,3),true):-1},xt.findLastKey=function(t,n){return v(t,Sr(n,3),gn,true)},xt.floor=zi,xt.forEach=oe,xt.forEachRight=ie,xt.forIn=function(t,n){return null==t?t:fo(t,Sr(n),Ve)},xt.forInRight=function(t,n){return null==t?t:co(t,Sr(n),Ve)},xt.forOwn=function(t,n){return t&&vn(t,Sr(n))},xt.forOwnRight=function(t,n){return t&&gn(t,Sr(n))},xt.get=Pe,xt.gt=ye,xt.gte=function(t,n){return t>=n},xt.has=Ze, +xt.hasIn=qe,xt.head=Yr,xt.identity=tu,xt.includes=function(t,n,r,e){return t=xe(t)?t:Je(t),r=r&&!e?Le(r):0,e=t.length,0>r&&(r=Lu(e+r,0)),Be(t)?e>=r&&-1r&&(r=Lu(e+r,0)),d(t,n,r)):-1},xt.inRange=function(t,n,r){return n=De(n)||0,r===T?(r=n,n=0):r=De(r)||0,t=De(t),t>=$u(n,r)&&t=-9007199254740991&&9007199254740991>=t},xt.isSet=function(t){return Ee(t)&&"[object Set]"==zr(t)},xt.isString=Be,xt.isSymbol=Ce,xt.isTypedArray=ze,xt.isUndefined=function(t){return t===T},xt.isWeakMap=function(t){return Ee(t)&&"[object WeakMap]"==zr(t)},xt.isWeakSet=function(t){return Ee(t)&&"[object WeakSet]"==gu.call(t); +},xt.join=function(t,n){return t?Uu.call(t,n):""},xt.kebabCase=pi,xt.last=Hr,xt.lastIndexOf=function(t,n,r){var e=t?t.length:0;if(!e)return-1;var u=e;if(r!==T&&(u=Le(r),u=(0>u?Lu(e+u,0):$u(u,e-1))+1),n!==n)return U(t,u,true);for(;u--;)if(t[u]===n)return u;return-1},xt.lowerCase=_i,xt.lowerFirst=vi,xt.lt=Ue,xt.lte=function(t,n){return n>=t},xt.max=function(t){return t&&t.length?_(t,tu,ye):T},xt.maxBy=function(t,n){return t&&t.length?_(t,Sr(n),ye):T},xt.mean=function(t){return b(t,tu)},xt.meanBy=function(t,n){ +return b(t,Sr(n))},xt.min=function(t){return t&&t.length?_(t,tu,Ue):T},xt.minBy=function(t,n){return t&&t.length?_(t,Sr(n),Ue):T},xt.multiply=Ui,xt.noConflict=function(){return Jt._===this&&(Jt._=du),this},xt.noop=eu,xt.now=No,xt.pad=function(t,n,r){t=Ne(t);var e=(n=Le(n))?P(t):0;return n&&n>e?(n=(n-e)/2,xr(Bu(n),r)+t+xr(Wu(n),r)):t},xt.padEnd=function(t,n,r){t=Ne(t);var e=(n=Le(n))?P(t):0;return n&&n>e?t+xr(n-e,r):t},xt.padStart=function(t,n,r){t=Ne(t);var e=(n=Le(n))?P(t):0;return n&&n>e?xr(n-e,r)+t:t; +},xt.parseInt=function(t,n,r){return r||null==n?n=0:n&&(n=+n),t=Ne(t).replace(at,""),Du(t,n||(vt.test(t)?16:10))},xt.random=function(t,n,r){if(r&&typeof r!="boolean"&&Fr(t,n,r)&&(n=r=T),r===T&&(typeof n=="boolean"?(r=n,n=T):typeof t=="boolean"&&(r=t,t=T)),t===T&&n===T?(t=0,n=1):(t=De(t)||0,n===T?(n=t,t=0):n=De(n)||0),t>n){var e=t;t=n,n=e}return r||t%1||n%1?(r=Fu(),$u(t+r*(n-t+Nt("1e-"+((r+"").length-1))),n)):Fn(t,n)},xt.reduce=function(t,n,r){var e=Yo(t)?s:x,u=3>arguments.length;return e(t,Sr(n,4),r,u,oo); +},xt.reduceRight=function(t,n,r){var e=Yo(t)?h:x,u=3>arguments.length;return e(t,Sr(n,4),r,u,io)},xt.repeat=function(t,n){return Nn(Ne(t),Le(n))},xt.replace=function(){var t=arguments,n=Ne(t[0]);return 3>t.length?n:n.replace(t[1],t[2])},xt.result=function(t,n,r){n=Nr(n,t)?[n]:un(n);var e=-1,u=n.length;for(u||(t=T,u=1);++e0?t[Fn(0,n-1)]:T; +},xt.size=function(t){if(null==t)return 0;if(xe(t)){var n=t.length;return n&&Be(t)?P(t):n}return Ee(t)&&(n=zr(t),"[object Map]"==n||"[object Set]"==n)?t.size:Te(t).length},xt.snakeCase=gi,xt.some=function(t,n,r){var e=Yo(t)?p:qn;return r&&Fr(t,n,r)&&(n=T),e(t,Sr(n,3))},xt.sortedIndex=function(t,n){return Tn(t,n)},xt.sortedIndexBy=function(t,n,r){return Vn(t,n,Sr(r))},xt.sortedIndexOf=function(t,n){var r=t?t.length:0;if(r){var e=Tn(t,n);if(r>e&&de(t[e],n))return e}return-1},xt.sortedLastIndex=function(t,n){ +return Tn(t,n,true)},xt.sortedLastIndexBy=function(t,n,r){return Vn(t,n,Sr(r),true)},xt.sortedLastIndexOf=function(t,n){if(t&&t.length){var r=Tn(t,n,true)-1;if(de(t[r],n))return r}return-1},xt.startCase=di,xt.startsWith=function(t,n,r){return t=Ne(t),r=on(Le(r),0,t.length),t.lastIndexOf(n,r)==r},xt.subtract=Li,xt.sum=function(t){return t&&t.length?m(t,tu):0},xt.sumBy=function(t,n){return t&&t.length?m(t,Sr(n)):0},xt.template=function(t,n,r){var e=xt.templateSettings;r&&Fr(t,n,r)&&(n=T),t=Ne(t),n=ti({},n,e,Gt), +r=ti({},n.imports,e.imports,Gt);var u,o,i=Te(r),f=k(r,i),c=0;r=n.interpolate||mt;var a="__p+='";r=cu((n.escape||mt).source+"|"+r.source+"|"+(r===et?pt:mt).source+"|"+(n.evaluate||mt).source+"|$","g");var l="sourceURL"in n?"//# sourceURL="+n.sourceURL+"\n":"";if(t.replace(r,function(n,r,e,i,f,l){return e||(e=i),a+=t.slice(c,l).replace(wt,z),r&&(u=true,a+="'+__e("+r+")+'"),f&&(o=true,a+="';"+f+";\n__p+='"),e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),c=l+n.length,n}),a+="';",(n=n.variable)||(a="with(obj){"+a+"}"), +a=(o?a.replace(G,""):a).replace(J,"$1").replace(Y,"$1;"),a="function("+(n||"obj")+"){"+(n?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+a+"return __p}",n=xi(function(){return Function(i,l+"return "+a).apply(T,f)}),n.source=a,me(n))throw n;return n},xt.times=function(t,n){if(t=Le(t),1>t||t>9007199254740991)return[];var r=4294967295,e=$u(t,4294967295);for(n=Sr(n),t-=4294967295,e=w(e,n);++r=o)return t;if(o=r-P(e),1>o)return e;if(r=i?i.slice(0,o).join(""):t.slice(0,o),u===T)return r+e;if(i&&(o+=r.length-o),We(u)){if(t.slice(o).search(u)){ +var f=r;for(u.global||(u=cu(u.source,Ne(_t.exec(u))+"g")),u.lastIndex=0;i=u.exec(f);)var c=i.index;r=r.slice(0,c===T?o:c)}}else t.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),u>-1&&(r=r.slice(0,u)));return r+e},xt.unescape=function(t){return(t=Ne(t))&&X.test(t)?t.replace(H,Z):t},xt.uniqueId=function(t){var n=++_u;return Ne(t)+n},xt.upperCase=yi,xt.upperFirst=bi,xt.each=oe,xt.eachRight=ie,xt.first=Yr,ru(xt,function(){var t={};return vn(xt,function(n,r){pu.call(xt.prototype,r)||(t[r]=n)}),t}(),{chain:false}), +xt.VERSION="4.7.0",u("bind bindKey curry curryRight partial partialRight".split(" "),function(t){xt[t].placeholder=xt}),u(["drop","take"],function(t,n){kt.prototype[t]=function(r){var e=this.__filtered__;if(e&&!n)return new kt(this);r=r===T?1:Lu(Le(r),0);var u=this.clone();return e?u.__takeCount__=$u(r,u.__takeCount__):u.__views__.push({size:$u(r,4294967295),type:t+(0>u.__dir__?"Right":"")}),u},kt.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}}),u(["filter","map","takeWhile"],function(t,n){ +var r=n+1,e=1==r||3==r;kt.prototype[t]=function(t){var n=this.clone();return n.__iteratees__.push({iteratee:Sr(t,3),type:r}),n.__filtered__=n.__filtered__||e,n}}),u(["head","last"],function(t,n){var r="take"+(n?"Right":"");kt.prototype[t]=function(){return this[r](1).value()[0]}}),u(["initial","tail"],function(t,n){var r="drop"+(n?"":"Right");kt.prototype[t]=function(){return this.__filtered__?new kt(this):this[r](1)}}),kt.prototype.compact=function(){return this.filter(tu)},kt.prototype.find=function(t){ +return this.filter(t).head()},kt.prototype.findLast=function(t){return this.reverse().find(t)},kt.prototype.invokeMap=ve(function(t,n){return typeof t=="function"?new kt(this):this.map(function(r){return An(r,t,n)})}),kt.prototype.reject=function(t){return t=Sr(t,3),this.filter(function(n){return!t(n)})},kt.prototype.slice=function(t,n){t=Le(t);var r=this;return r.__filtered__&&(t>0||0>n)?new kt(r):(0>t?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==T&&(n=Le(n),r=0>n?r.dropRight(-n):r.take(n-t)),r)},kt.prototype.takeRightWhile=function(t){ +return this.reverse().takeWhile(t).reverse()},kt.prototype.toArray=function(){return this.take(4294967295)},vn(kt.prototype,function(t,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),e=/^(?:head|last)$/.test(n),u=xt[e?"take"+("last"==n?"Right":""):n],o=e||/^find/.test(n);u&&(xt.prototype[n]=function(){function n(t){return t=u.apply(xt,l([t],f)),e&&h?t[0]:t}var i=this.__wrapped__,f=e?[1]:arguments,c=i instanceof kt,a=f[0],s=c||Yo(i);s&&r&&typeof a=="function"&&1!=a.length&&(c=s=false);var h=this.__chain__,p=!!this.__actions__.length,a=o&&!h,c=c&&!p; +return!o&&s?(i=c?i:new kt(this),i=t.apply(i,f),i.__actions__.push({func:ee,args:[n],thisArg:T}),new Ot(i,h)):a&&c?t.apply(this,f):(i=this.thru(n),a?e?i.value()[0]:i.value():i)})}),u("pop push shift sort splice unshift".split(" "),function(t){var n=lu[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",e=/^(?:pop|shift)$/.test(t);xt.prototype[t]=function(){var t=arguments;if(e&&!this.__chain__){var u=this.value();return n.apply(Yo(u)?u:[],t)}return this[r](function(r){return n.apply(Yo(r)?r:[],t)}); +}}),vn(kt.prototype,function(t,n){var r=xt[n];if(r){var e=r.name+"";(Yu[e]||(Yu[e]=[])).push({name:n,func:r})}}),Yu[dr(T,2).name]=[{name:"wrapper",func:T}],kt.prototype.clone=function(){var t=new kt(this.__wrapped__);return t.__actions__=er(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=er(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=er(this.__views__),t},kt.prototype.reverse=function(){if(this.__filtered__){var t=new kt(this);t.__dir__=-1, +t.__filtered__=true}else t=this.clone(),t.__dir__*=-1;return t},kt.prototype.value=function(){var t,n=this.__wrapped__.value(),r=this.__dir__,e=Yo(n),u=0>r,o=e?n.length:0;t=o;for(var i=this.__views__,f=0,c=-1,a=i.length;++co||o==t&&a==t)return Yn(n,this.__actions__); +e=[];t:for(;t--&&a>c;){for(u+=r,o=-1,l=n[u];++o=this.__values__.length,n=t?T:this.__values__[this.__index__++];return{done:t,value:n}},xt.prototype.plant=function(t){ +for(var n,r=this;r instanceof At;){var e=Kr(r);e.__index__=0,e.__values__=T,n?u.__wrapped__=e:n=e;var u=e,r=r.__wrapped__}return u.__wrapped__=t,n},xt.prototype.reverse=function(){var t=this.__wrapped__;return t instanceof kt?(this.__actions__.length&&(t=new kt(this)),t=t.reverse(),t.__actions__.push({func:ee,args:[Xr],thisArg:T}),new Ot(t,this.__chain__)):this.thru(Xr)},xt.prototype.toJSON=xt.prototype.valueOf=xt.prototype.value=function(){return Yn(this.__wrapped__,this.__actions__)},ku&&(xt.prototype[ku]=ue), +xt}var T,V=1/0,K=NaN,G=/\b__p\+='';/g,J=/\b(__p\+=)''\+/g,Y=/(__e\(.*?\)|\b__t\))\+'';/g,H=/&(?:amp|lt|gt|quot|#39|#96);/g,Q=/[&<>"'`]/g,X=RegExp(H.source),tt=RegExp(Q.source),nt=/<%-([\s\S]+?)%>/g,rt=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,ut=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ot=/^\w*$/,it=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,ft=/[\\^$.*+?()[\]{}|]/g,ct=RegExp(ft.source),at=/^\s+|\s+$/g,lt=/^\s+/,st=/\s+$/,ht=/\\(\\)?/g,pt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,_t=/\w*$/,vt=/^0x/i,gt=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,yt=/^\[object .+?Constructor\]$/,bt=/^0o[0-7]+$/i,xt=/^(?:0|[1-9]\d*)$/,jt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,mt=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,At="[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|\\ud83c[\\udffb-\\udfff])?(?:\\u200d(?:[^\\ud800-\\udfff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|\\ud83c[\\udffb-\\udfff])?)*",Ot="(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])"+At,kt="(?:[^\\ud800-\\udfff][\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]?|[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\ud800-\\udfff])",Et=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]","g"),It=RegExp("\\ud83c[\\udffb-\\udfff](?=\\ud83c[\\udffb-\\udfff])|"+kt+At,"g"),St=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),Rt=/[a-zA-Z0-9]+/g,Wt=RegExp(["[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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]|[A-Z\\xc0-\\xd6\\xd8-\\xde]|$)|(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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]|[A-Z\\xc0-\\xd6\\xd8-\\xde](?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])|$)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?(?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\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\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|\\d+",Ot].join("|"),"g"),Bt=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ct="Array Buffer DataView Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Map Math Object Promise Reflect RegExp Set String Symbol TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap _ clearTimeout isFinite parseInt setTimeout".split(" "),zt={}; +zt["[object Float32Array]"]=zt["[object Float64Array]"]=zt["[object Int8Array]"]=zt["[object Int16Array]"]=zt["[object Int32Array]"]=zt["[object Uint8Array]"]=zt["[object Uint8ClampedArray]"]=zt["[object Uint16Array]"]=zt["[object Uint32Array]"]=true,zt["[object Arguments]"]=zt["[object Array]"]=zt["[object ArrayBuffer]"]=zt["[object Boolean]"]=zt["[object DataView]"]=zt["[object Date]"]=zt["[object Error]"]=zt["[object Function]"]=zt["[object Map]"]=zt["[object Number]"]=zt["[object Object]"]=zt["[object RegExp]"]=zt["[object Set]"]=zt["[object String]"]=zt["[object WeakMap]"]=false; +var Ut={};Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object DataView]"]=Ut["[object Boolean]"]=Ut["[object Date]"]=Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object Symbol]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=true, +Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object WeakMap]"]=false;var Mt={"\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"},Lt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},$t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Dt={"function":true,object:true},Ft={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029" +},Nt=parseFloat,Pt=parseInt,Zt=Dt[typeof exports]&&exports&&!exports.nodeType?exports:T,qt=Dt[typeof module]&&module&&!module.nodeType?module:T,Tt=qt&&qt.exports===Zt?Zt:T,Vt=S(Dt[typeof self]&&self),Kt=S(Dt[typeof window]&&window),Gt=S(Dt[typeof this]&&this),Jt=S(Zt&&qt&&typeof global=="object"&&global)||Kt!==(Gt&&Gt.window)&&Kt||Vt||Gt||Function("return this")(),Yt=q();(Kt||Vt||{})._=Yt,typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return Yt}):Zt&&qt?(Tt&&((qt.exports=Yt)._=Yt), +Zt._=Yt):Jt._=Yt}).call(this); \ No newline at end of file diff --git a/dist/mapping.fp.js b/dist/mapping.fp.js index aace6560a4..5f5a819de6 100644 --- a/dist/mapping.fp.js +++ b/dist/mapping.fp.js @@ -56,23 +56,36 @@ return /******/ (function(modules) { // webpackBootstrap /** Used to map aliases to their real names. */ exports.aliasToReal = { + + // Lodash aliases. + 'each': 'forEach', + 'eachRight': 'forEachRight', + 'entries': 'toPairs', + 'entriesIn': 'toPairsIn', + 'extend': 'assignIn', + 'extendWith': 'assignInWith', + 'first': 'head', + + // Ramda aliases. '__': 'placeholder', - 'all': 'some', + 'all': 'every', 'allPass': 'overEvery', + 'always': 'constant', + 'any': 'some', + 'anyPass': 'overSome', 'apply': 'spread', 'assoc': 'set', 'assocPath': 'set', + 'complement': 'negate', 'compose': 'flowRight', 'contains': 'includes', 'dissoc': 'unset', 'dissocPath': 'unset', - 'each': 'forEach', - 'eachRight': 'forEachRight', 'equals': 'isEqual', - 'extend': 'assignIn', - 'extendWith': 'assignInWith', - 'first': 'head', + 'identical': 'eq', 'init': 'initial', + 'invertObj': 'invert', + 'juxt': 'over', 'mapObj': 'mapValues', 'omitAll': 'omit', 'nAry': 'ary', @@ -84,7 +97,6 @@ return /******/ (function(modules) { // webpackBootstrap 'prop': 'get', 'propOf': 'propertyOf', 'propOr': 'getOr', - 'somePass': 'overSome', 'unapply': 'rest', 'unnest': 'flatten', 'useWith': 'overArgs', @@ -101,32 +113,35 @@ return /******/ (function(modules) { // webpackBootstrap 'spread', 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words' ], '2': [ - 'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey', - 'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN', + 'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindAll', + 'bindKey', 'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN', 'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference', - 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every', - 'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex', - 'findLastKey', 'flatMap', 'flattenDepth', 'forEach', 'forEachRight', 'forIn', - 'forInRight', 'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', - 'hasIn', 'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap', - 'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map', - 'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit', - 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial', - 'partialRight', 'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', - 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'result', + 'divide', 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', + 'eq', 'every', 'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', + 'findLastIndex', 'findLastKey', 'flatMap', 'flatMapDeep', 'flattenDepth', + 'forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', + 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', + 'intersection', 'invertBy', 'invoke', 'invokeMap', 'isEqual', 'isMatch', + 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map', 'mapKeys', 'mapValues', + 'matchesProperty', 'maxBy', 'meanBy', 'merge', 'minBy', 'multiply', 'omit', 'omitBy', + 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial', 'partialRight', + 'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', 'random', 'range', + 'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex', - 'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', 'subtract', 'sumBy', - 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', - 'times', 'trimChars', 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', - 'uniqBy', 'uniqWith', 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', - 'zipObject', 'zipObjectDeep' + 'sortedLastIndexOf', 'sortedUniqBy', 'split', 'spreadFrom', 'startsWith', + 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', + 'throttle', 'thru', 'times', 'trimChars', 'trimCharsEnd', 'trimCharsStart', + 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset', 'unzipWith', 'without', + 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep' ], '3': [ 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith', - 'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith', - 'isMatchWith', 'mergeWith', 'orderBy', 'pullAllBy', 'pullAllWith', 'reduce', - 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', - 'transform', 'unionBy', 'unionWith', 'update', 'xorBy', 'xorWith', 'zipWith' + 'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'invokeArgs', + 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth', 'mergeWith', + 'orderBy', 'padChars', 'padCharsEnd', 'padCharsStart', 'pullAllBy', + 'pullAllWith', 'reduce', 'reduceRight', 'replace', 'set', 'slice', + 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy', 'unionWith', + 'update', 'xorBy', 'xorWith', 'zipWith' ], '4': [ 'fill', 'setWith', 'updateWith' @@ -142,10 +157,6 @@ return /******/ (function(modules) { // webpackBootstrap /** Used to map method names to their iteratee ary. */ exports.iterateeAry = { - 'assignWith': 2, - 'assignInWith': 2, - 'cloneDeepWith': 1, - 'cloneWith': 1, 'dropRightWhile': 1, 'dropWhile': 1, 'every': 1, @@ -157,14 +168,14 @@ return /******/ (function(modules) { // webpackBootstrap 'findLastIndex': 1, 'findLastKey': 1, 'flatMap': 1, + 'flatMapDeep': 1, + 'flatMapDepth': 1, 'forEach': 1, 'forEachRight': 1, 'forIn': 1, 'forInRight': 1, 'forOwn': 1, 'forOwnRight': 1, - 'isEqualWith': 2, - 'isMatchWith': 2, 'map': 1, 'mapKeys': 1, 'mapValues': 1, @@ -190,8 +201,12 @@ return /******/ (function(modules) { // webpackBootstrap 'assignInWith': [1, 2, 0], 'assignWith': [1, 2, 0], 'getOr': [2, 1, 0], + 'isEqualWith': [1, 2, 0], 'isMatchWith': [2, 1, 0], 'mergeWith': [1, 2, 0], + 'padChars': [2, 1, 0], + 'padCharsEnd': [2, 1, 0], + 'padCharsStart': [2, 1, 0], 'pullAllBy': [2, 1, 0], 'pullAllWith': [2, 1, 0], 'setWith': [3, 1, 2, 0], @@ -203,8 +218,11 @@ return /******/ (function(modules) { // webpackBootstrap /** Used to map method names to spread configs. */ exports.methodSpread = { + 'invokeArgs': 2, + 'invokeArgsMap': 2, 'partial': 1, - 'partialRight': 1 + 'partialRight': 1, + 'without': 1 }; /** Used to identify methods which mutate arrays or objects. */ @@ -270,6 +288,13 @@ return /******/ (function(modules) { // webpackBootstrap 'curryN': 'curry', 'curryRightN': 'curryRight', 'getOr': 'get', + 'invokeArgs': 'invoke', + 'invokeArgsMap': 'invokeMap', + 'padChars': 'pad', + 'padCharsEnd': 'padEnd', + 'padCharsStart': 'padStart', + 'restFrom': 'rest', + 'spreadFrom': 'spread', 'trimChars': 'trim', 'trimCharsEnd': 'trimEnd', 'trimCharsStart': 'trimStart' @@ -280,20 +305,27 @@ return /******/ (function(modules) { // webpackBootstrap 'add': true, 'assign': true, 'assignIn': true, + 'bind': true, + 'bindKey': true, 'concat': true, 'difference': true, + 'divide': true, + 'eq': true, 'gt': true, 'gte': true, + 'isEqual': true, 'lt': true, 'lte': true, 'matchesProperty': true, 'merge': true, + 'multiply': true, 'partial': true, 'partialRight': true, 'random': true, 'range': true, 'rangeRight': true, 'subtract': true, + 'without': true, 'zip': true, 'zipObject': true }; diff --git a/doc/README.md b/doc/README.md index cce7cf433c..e2d247da8d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# lodash v4.6.1 +# lodash v4.7.0 @@ -38,7 +38,7 @@ * `_.pullAllWith` * `_.pullAt` * `_.remove` -* `_.reverse` +* `_.reverse` * `_.slice` * `_.sortedIndex` * `_.sortedIndexBy` @@ -83,6 +83,8 @@ * `_.find` * `_.findLast` * `_.flatMap` +* `_.flatMapDeep` +* `_.flatMapDepth` * `_.forEach` * `_.forEachRight` * `_.groupBy` @@ -90,7 +92,7 @@ * `_.invokeMap` * `_.keyBy` * `_.map` -* `_.orderBy` +* `_.orderBy` * `_.partition` * `_.reduce` * `_.reduceRight` @@ -100,7 +102,7 @@ * `_.shuffle` * `_.size` * `_.some` -* `_.sortBy` +* `_.sortBy` @@ -121,7 +123,7 @@ * `_.bindKey` * `_.curry` * `_.curryRight` -* `_.debounce` +* `_.debounce` * `_.defer` * `_.delay` * `_.flip` @@ -134,7 +136,7 @@ * `_.rearg` * `_.rest` * `_.spread` -* `_.throttle` +* `_.throttle` * `_.unary` * `_.wrap` @@ -205,12 +207,15 @@ ## `Math` * `_.add` * `_.ceil` +* `_.divide` * `_.floor` * `_.max` * `_.maxBy` * `_.mean` +* `_.meanBy` * `_.min` * `_.minBy` +* `_.multiply` * `_.round` * `_.subtract` * `_.sum` @@ -238,6 +243,8 @@ * `_.create` * `_.defaults` * `_.defaultsDeep` +* `_.entries` -> `toPairs` +* `_.entriesIn` -> `toPairsIn` * `_.extend` -> `assignIn` * `_.extendWith` -> `assignInWith` * `_.findKey` @@ -289,13 +296,11 @@ * `_.prototype.at` * `_.prototype.chain` * `_.prototype.commit` -* `_.prototype.flatMap` * `_.prototype.next` * `_.prototype.plant` * `_.prototype.reverse` * `_.prototype.toJSON` -> `value` * `_.prototype.value` -* `_.prototype.valueOf` -> `value` @@ -321,7 +326,7 @@ * `_.split` * `_.startCase` * `_.startsWith` -* `_.template` +* `_.template` * `_.toLower` * `_.toUpper` * `_.trim` @@ -338,7 +343,7 @@ ## `Util` -* `_.attempt` +* `_.attempt` * `_.bindAll` * `_.cond` * `_.conforms` @@ -351,7 +356,7 @@ * `_.matchesProperty` * `_.method` * `_.methodOf` -* `_.mixin` +* `_.mixin` * `_.noConflict` * `_.noop` * `_.nthArg` @@ -377,12 +382,18 @@ * `_.templateSettings.escape` * `_.templateSettings.evaluate` * `_.templateSettings.imports` -* `_.templateSettings.imports._` * `_.templateSettings.interpolate` * `_.templateSettings.variable` + + +## `Methods` +* `_.templateSettings.imports._` + + + @@ -394,18 +405,20 @@ ### `_.chunk(array, [size=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5505 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L5786 "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 `array` can't be split evenly, the final chunk will be the remaining elements. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to process. 2. `[size=0]` *(number)*: The length of each chunk. #### Returns -*(Array)*: Returns the new array containing chunks. +*(Array)*: Returns the new array containing chunks. #### Example ```js @@ -422,16 +435,18 @@ _.chunk(['a', 'b', 'c', 'd'], 3); ### `_.compact(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5536 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.compact "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L5818 "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. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to compact. #### Returns -*(Array)*: Returns the new array of filtered values. +*(Array)*: Returns the new array of filtered values. #### Example ```js @@ -445,17 +460,19 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.concat(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5572 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.concat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L5855 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.concat "See the npm package") Creates a new array concatenating `array` with any additional arrays and/or values. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to concatenate. 2. `[values]` *(...*)*: The values to concatenate. #### Returns -*(Array)*: Returns the new concatenated array. +*(Array)*: Returns the new concatenated array. #### Example ```js @@ -475,19 +492,21 @@ console.log(array); ### `_.difference(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5597 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L5887 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the npm package") -Creates an array of unique `array` values not included in the other -given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) +Creates an array of unique `array` values not included in the other given +arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) for equality comparisons. The order of result values is determined by the order they occur in the first array. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `[values]` *(...Array)*: The values to exclude. #### Returns -*(Array)*: Returns the new array of filtered values. +*(Array)*: Returns the new array of filtered values. #### Example ```js @@ -501,20 +520,22 @@ _.difference([3, 2, 1], [4, 2]); ### `_.differenceBy(array, [values], [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5625 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.differenceby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L5917 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.differenceby "See the npm package") This method is like `_.difference` except that it accepts `iteratee` which is invoked for each element of `array` and `values` to generate the criterion by which they're compared. Result values are chosen from the first array. -The iteratee is invoked with one argument: (value). +The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `[values]` *(...Array)*: The values to exclude. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +3. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns the new array of filtered values. +*(Array)*: Returns the new array of filtered values. #### Example ```js @@ -532,20 +553,22 @@ _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); ### `_.differenceWith(array, [values], [comparator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5655 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.differencewith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L5948 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.differencewith "See the npm package") This method is like `_.difference` except that it accepts `comparator` which is invoked to compare elements of `array` to `values`. Result values are chosen from the first array. The comparator is invoked with two arguments:
-(arrVal, othVal). +*(arrVal, othVal)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `[values]` *(...Array)*: The values to exclude. 3. `[comparator]` *(Function)*: The comparator invoked per element. #### Returns -*(Array)*: Returns the new array of filtered values. +*(Array)*: Returns the new array of filtered values. #### Example ```js @@ -561,16 +584,18 @@ _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); ### `_.drop(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5689 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.drop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L5983 "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. +#### Since +0.5.0 #### Arguments 1. `array` *(Array)*: The array to query. 2. `[n=1]` *(number)*: The number of elements to drop. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -593,16 +618,18 @@ _.drop([1, 2, 3], 0); ### `_.dropRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5722 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6017 "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. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to query. 2. `[n=1]` *(number)*: The number of elements to drop. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -625,18 +652,20 @@ _.dropRight([1, 2, 3], 0); ### `_.dropRightWhile(array, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5766 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6063 "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 -invoked with three arguments: (value, index, array). +invoked with three arguments: *(value, index, array)*. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -668,18 +697,20 @@ _.dropRightWhile(users, 'active'); ### `_.dropWhile(array, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5806 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6105 "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 -invoked with three arguments: (value, index, array). +invoked with three arguments: *(value, index, array)*. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -711,7 +742,7 @@ _.dropWhile(users, 'active'); ### `_.fill(array, value, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5840 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6140 "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`. @@ -719,6 +750,8 @@ including, `end`.
**Note:** This method mutates `array`. +#### Since +3.2.0 #### Arguments 1. `array` *(Array)*: The array to fill. 2. `value` *(*)*: The value to fill `array` with. @@ -726,7 +759,7 @@ including, `end`. 4. `[end=array.length]` *(number)*: The end position. #### Returns -*(Array)*: Returns `array`. +*(Array)*: Returns `array`. #### Example ```js @@ -749,17 +782,19 @@ _.fill([4, 6, 8, 10], '*', 1, 3); ### `_.findIndex(array, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5885 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6187 "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. +#### Since +1.1.0 #### Arguments 1. `array` *(Array)*: The array to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(number)*: Returns the index of the found element, else `-1`. +*(number)*: Returns the index of the found element, else `-1`. #### Example ```js @@ -791,17 +826,19 @@ _.findIndex(users, 'active'); ### `_.findLastIndex(array, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5924 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6228 "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. +#### Since +2.0.0 #### Arguments 1. `array` *(Array)*: The array to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(number)*: Returns the index of the found element, else `-1`. +*(number)*: Returns the index of the found element, else `-1`. #### Example ```js @@ -833,15 +870,17 @@ _.findLastIndex(users, 'active'); ### `_.flatten(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5943 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6248 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") Flattens `array` a single level deep. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to flatten. #### Returns -*(Array)*: Returns the new flattened array. +*(Array)*: Returns the new flattened array. #### Example ```js @@ -855,15 +894,17 @@ _.flatten([1, [2, [3, [4]], 5]]); ### `_.flattenDeep(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5961 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6267 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") Recursively flattens `array`. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to flatten. #### Returns -*(Array)*: Returns the new flattened array. +*(Array)*: Returns the new flattened array. #### Example ```js @@ -877,16 +918,18 @@ _.flattenDeep([1, [2, [3, [4]], 5]]); ### `_.flattenDepth(array, [depth=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L5985 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendepth "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6292 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendepth "See the npm package") Recursively flatten `array` up to `depth` times. +#### Since +4.4.0 #### Arguments 1. `array` *(Array)*: The array to flatten. 2. `[depth=1]` *(number)*: The maximum recursion depth. #### Returns -*(Array)*: Returns the new flattened array. +*(Array)*: Returns the new flattened array. #### Example ```js @@ -905,16 +948,18 @@ _.flattenDepth(array, 2); ### `_.fromPairs(pairs)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6008 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.frompairs "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6316 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.frompairs "See the npm package") The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. +#### Since +4.0.0 #### Arguments 1. `pairs` *(Array)*: The key-value pairs. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -928,10 +973,12 @@ _.fromPairs([['fred', 30], ['barney', 40]]); ### `_.head(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6037 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.head "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6346 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.head "See the npm package") Gets the first element of `array`. +#### Since +0.1.0 #### Aliases *_.first* @@ -939,7 +986,7 @@ Gets the first element of `array`. 1. `array` *(Array)*: The array to query. #### Returns -*(*)*: Returns the first element of `array`. +*(*)*: Returns the first element of `array`. #### Example ```js @@ -956,20 +1003,22 @@ _.head([]); ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6063 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6373 "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`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) for equality comparisons. If `fromIndex` is negative, it's used as the offset from the end of `array`. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to search. 2. `value` *(*)*: The value to search for. 3. `[fromIndex=0]` *(number)*: The index to search from. #### Returns -*(number)*: Returns the index of the matched value, else `-1`. +*(number)*: Returns the index of the matched value, else `-1`. #### Example ```js @@ -987,15 +1036,17 @@ _.indexOf([1, 2, 1, 2], 2, 2); ### `_.initial(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6088 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6399 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") Gets all but the last element of `array`. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to query. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -1009,18 +1060,20 @@ _.initial([1, 2, 3]); ### `_.intersection([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6108 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6420 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the npm package") Creates an array of unique values that are included in all given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) for equality comparisons. The order of result values is determined by the order they occur in the first array. +#### Since +0.1.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. #### Returns -*(Array)*: Returns the new array of intersecting values. +*(Array)*: Returns the new array of intersecting values. #### Example ```js @@ -1034,19 +1087,21 @@ _.intersection([2, 1], [4, 2], [1, 2]); ### `_.intersectionBy([arrays], [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6136 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersectionby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6450 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersectionby "See the npm package") This method is like `_.intersection` except that it accepts `iteratee` which is invoked for each element of each `arrays` to generate the criterion by which they're compared. Result values are chosen from the first array. -The iteratee is invoked with one argument: (value). +The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns the new array of intersecting values. +*(Array)*: Returns the new array of intersecting values. #### Example ```js @@ -1064,19 +1119,21 @@ _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); ### `_.intersectionWith([arrays], [comparator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6170 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersectionwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6485 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersectionwith "See the npm package") This method is like `_.intersection` except that it accepts `comparator` which is invoked to compare elements of `arrays`. Result values are chosen from the first array. The comparator is invoked with two arguments:
-(arrVal, othVal). +*(arrVal, othVal)*. +#### Since +4.0.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. 2. `[comparator]` *(Function)*: The comparator invoked per element. #### Returns -*(Array)*: Returns the new array of intersecting values. +*(Array)*: Returns the new array of intersecting values. #### Example ```js @@ -1093,16 +1150,18 @@ _.intersectionWith(objects, others, _.isEqual); ### `_.join(array, [separator=','])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6198 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.join "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6514 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.join "See the npm package") Converts all elements in `array` into a string separated by `separator`. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to convert. 2. `[separator=',']` *(string)*: The element separator. #### Returns -*(string)*: Returns the joined string. +*(string)*: Returns the joined string. #### Example ```js @@ -1116,15 +1175,17 @@ _.join(['a', 'b', 'c'], '~'); ### `_.last(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6215 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6532 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") Gets the last element of `array`. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to query. #### Returns -*(*)*: Returns the last element of `array`. +*(*)*: Returns the last element of `array`. #### Example ```js @@ -1138,18 +1199,20 @@ _.last([1, 2, 3]); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6240 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6558 "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. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to search. 2. `value` *(*)*: The value to search for. 3. `[fromIndex=array.length-1]` *(number)*: The index to search from. #### Returns -*(number)*: Returns the index of the matched value, else `-1`. +*(number)*: Returns the index of the matched value, else `-1`. #### Example ```js @@ -1167,7 +1230,7 @@ _.lastIndexOf([1, 2, 1, 2], 2, 2); ### `_.pull(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6283 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6606 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") Removes all given values from `array` using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -1177,12 +1240,14 @@ for equality comparisons. **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` to remove elements from an array by predicate. +#### Since +2.0.0 #### Arguments 1. `array` *(Array)*: The array to modify. 2. `[values]` *(...*)*: The values to remove. #### Returns -*(Array)*: Returns `array`. +*(Array)*: Returns `array`. #### Example ```js @@ -1199,19 +1264,21 @@ console.log(array); ### `_.pullAll(array, values)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6304 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullall "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6628 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullall "See the npm package") This method is like `_.pull` except that it accepts an array of values to remove.

**Note:** Unlike `_.difference`, this method mutates `array`. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to modify. 2. `values` *(Array)*: The values to remove. #### Returns -*(Array)*: Returns `array`. +*(Array)*: Returns `array`. #### Example ```js @@ -1228,22 +1295,24 @@ console.log(array); ### `_.pullAllBy(array, values, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6332 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullallby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6658 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullallby "See the npm package") This method is like `_.pullAll` except that it accepts `iteratee` which is invoked for each element of `array` and `values` to generate the criterion -by which they're compared. The iteratee is invoked with one argument: (value). +by which they're compared. The iteratee is invoked with one argument: *(value)*.

**Note:** Unlike `_.differenceBy`, this method mutates `array`. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to modify. 2. `values` *(Array)*: The values to remove. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +3. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns `array`. +*(Array)*: Returns `array`. #### Example ```js @@ -1260,22 +1329,24 @@ console.log(array); ### `_.pullAllWith(array, values, [comparator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6360 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullallwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6687 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullallwith "See the npm package") This method is like `_.pullAll` except that it accepts `comparator` which is invoked to compare elements of `array` to `values`. The comparator is -invoked with two arguments: (arrVal, othVal). +invoked with two arguments: *(arrVal, othVal)*.

**Note:** Unlike `_.differenceWith`, this method mutates `array`. +#### Since +4.6.0 #### Arguments 1. `array` *(Array)*: The array to modify. 2. `values` *(Array)*: The values to remove. 3. `[comparator]` *(Function)*: The comparator invoked per element. #### Returns -*(Array)*: Returns `array`. +*(Array)*: Returns `array`. #### Example ```js @@ -1292,7 +1363,7 @@ console.log(array); ### `_.pullAt(array, [indexes])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6390 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6718 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm package") Removes elements from `array` corresponding to `indexes` and returns an array of removed elements. @@ -1300,12 +1371,14 @@ array of removed elements.
**Note:** Unlike `_.at`, this method mutates `array`. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to modify. -2. `[indexes]` *(...(number|number[])*: The indexes of elements to remove, specified individually or in arrays. +2. `[indexes]` *(...(number|number[]))*: The indexes of elements to remove, specified individually or in arrays. #### Returns -*(Array)*: Returns the new array of removed elements. +*(Array)*: Returns the new array of removed elements. #### Example ```js @@ -1325,22 +1398,24 @@ console.log(evens); ### `_.remove(array, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6425 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6755 "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 invoked -with three arguments: (value, index, array). +with three arguments: *(value, index, array)*.

**Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` to pull elements from an array by value. +#### Since +2.0.0 #### Arguments 1. `array` *(Array)*: The array to modify. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the new array of removed elements. +*(Array)*: Returns the new array of removed elements. #### Example ```js @@ -1361,8 +1436,8 @@ console.log(evens); -### `_.reverse()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6467 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reverse "See the npm package") +### `_.reverse(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6799 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reverse "See the npm package") Reverses `array` so that the first element becomes the last, the second element becomes the second to last, and so on. @@ -1371,8 +1446,13 @@ element becomes the second to last, and so on. **Note:** This method mutates `array` and is based on [`Array#reverse`](https://mdn.io/Array/reverse). +#### Since +4.0.0 +#### Arguments +1. `array` *(Array)*: The array to modify. + #### Returns -*(Array)*: Returns `array`. +*(Array)*: Returns `array`. #### Example ```js @@ -1391,21 +1471,24 @@ console.log(array); ### `_.slice(array, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6485 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.slice "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6819 "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`.

-**Note:** This method is used instead of [`Array#slice`](https://mdn.io/Array/slice) -to ensure dense arrays are returned. +**Note:** This method is used instead of +[`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are +returned. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to slice. 2. `[start=0]` *(number)*: The start position. 3. `[end=array.length]` *(number)*: The end position. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. * * * @@ -1414,17 +1497,19 @@ to ensure dense arrays are returned. ### `_.sortedIndex(array, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6519 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6855 "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. +Uses a binary search to determine the lowest index at which `value` +should be inserted into `array` in order to maintain its sort order. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. #### Returns -*(number)*: Returns the index at which `value` should be inserted into `array`. +*(number)*: Returns the index at which `value` should be inserted into `array`. #### Example ```js @@ -1441,19 +1526,21 @@ _.sortedIndex([4, 5], 4); ### `_.sortedIndexBy(array, value, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6546 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindexby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6885 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindexby "See the npm package") This method is like `_.sortedIndex` except that it accepts `iteratee` which is invoked for `value` and each element of `array` to compute their -sort ranking. The iteratee is invoked with one argument: (value). +sort ranking. The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +3. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(number)*: Returns the index at which `value` should be inserted into `array`. +*(number)*: Returns the index at which `value` should be inserted into `array`. #### Example ```js @@ -1473,17 +1560,19 @@ _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); ### `_.sortedIndexOf(array, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6565 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6905 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindexof "See the npm package") This method is like `_.indexOf` except that it performs a binary search on a sorted `array`. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to search. 2. `value` *(*)*: The value to search for. #### Returns -*(number)*: Returns the index of the matched value, else `-1`. +*(number)*: Returns the index of the matched value, else `-1`. #### Example ```js @@ -1497,18 +1586,20 @@ _.sortedIndexOf([1, 1, 2, 2], 2); ### `_.sortedLastIndex(array, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6592 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6934 "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 maintain its sort order. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. #### Returns -*(number)*: Returns the index at which `value` should be inserted into `array`. +*(number)*: Returns the index at which `value` should be inserted into `array`. #### Example ```js @@ -1522,19 +1613,21 @@ _.sortedLastIndex([4, 5], 4); ### `_.sortedLastIndexBy(array, value, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6614 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindexby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6959 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindexby "See the npm package") This method is like `_.sortedLastIndex` except that it accepts `iteratee` which is invoked for `value` and each element of `array` to compute their -sort ranking. The iteratee is invoked with one argument: (value). +sort ranking. The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +3. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(number)*: Returns the index at which `value` should be inserted into `array`. +*(number)*: Returns the index at which `value` should be inserted into `array`. #### Example ```js @@ -1549,17 +1642,19 @@ _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); ### `_.sortedLastIndexOf(array, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6633 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L6979 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindexof "See the npm package") This method is like `_.lastIndexOf` except that it performs a binary search on a sorted `array`. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to search. 2. `value` *(*)*: The value to search for. #### Returns -*(number)*: Returns the index of the matched value, else `-1`. +*(number)*: Returns the index of the matched value, else `-1`. #### Example ```js @@ -1573,16 +1668,18 @@ _.sortedLastIndexOf([1, 1, 2, 2], 2); ### `_.sortedUniq(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6658 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sorteduniq "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7005 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sorteduniq "See the npm package") This method is like `_.uniq` except that it's designed and optimized for sorted arrays. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to inspect. #### Returns -*(Array)*: Returns the new duplicate free array. +*(Array)*: Returns the new duplicate free array. #### Example ```js @@ -1596,17 +1693,19 @@ _.sortedUniq([1, 1, 2]); ### `_.sortedUniqBy(array, [iteratee])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6679 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sorteduniqby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7027 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sorteduniqby "See the npm package") This method is like `_.uniqBy` except that it's designed and optimized for sorted arrays. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `[iteratee]` *(Function)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns the new duplicate free array. +*(Array)*: Returns the new duplicate free array. #### Example ```js @@ -1620,15 +1719,17 @@ _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); ### `_.tail(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6698 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tail "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7047 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tail "See the npm package") Gets all but the first element of `array`. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to query. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -1642,16 +1743,18 @@ _.tail([1, 2, 3]); ### `_.take(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6726 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.take "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7076 "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. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to query. 2. `[n=1]` *(number)*: The number of elements to take. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -1674,16 +1777,18 @@ _.take([1, 2, 3], 0); ### `_.takeRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6758 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takeright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7109 "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. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to query. 2. `[n=1]` *(number)*: The number of elements to take. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -1706,18 +1811,20 @@ _.takeRight([1, 2, 3], 0); ### `_.takeRightWhile(array, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6802 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7155 "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 invoked with three -arguments: (value, index, array). +taken until `predicate` returns falsey. The predicate is invoked with +three arguments: *(value, index, array)*. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -1749,18 +1856,20 @@ _.takeRightWhile(users, 'active'); ### `_.takeWhile(array, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6842 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7197 "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 invoked with -three arguments: (value, index, array). +three arguments: *(value, index, array)*. +#### Since +3.0.0 #### Arguments 1. `array` *(Array)*: The array to query. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the slice of `array`. +*(Array)*: Returns the slice of `array`. #### Example ```js @@ -1792,17 +1901,19 @@ _.takeWhile(users, 'active'); ### `_.union([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6863 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7219 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm package") Creates an array of unique values, in order, from all given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) for equality comparisons. +#### Since +0.1.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. #### Returns -*(Array)*: Returns the new array of combined values. +*(Array)*: Returns the new array of combined values. #### Example ```js @@ -1816,18 +1927,21 @@ _.union([2, 1], [4, 2], [1, 2]); ### `_.unionBy([arrays], [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6887 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unionby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7246 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unionby "See the npm package") This method is like `_.union` except that it accepts `iteratee` which is -invoked for each element of each `arrays` to generate the criterion by which -uniqueness is computed. The iteratee is invoked with one argument: (value). +invoked for each element of each `arrays` to generate the criterion by +which uniqueness is computed. The iteratee is invoked with one argument:
+*(value)*. +#### Since +4.0.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns the new array of combined values. +*(Array)*: Returns the new array of combined values. #### Example ```js @@ -1845,18 +1959,20 @@ _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unionWith([arrays], [comparator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6914 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unionwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7274 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unionwith "See the npm package") This method is like `_.union` except that it accepts `comparator` which is invoked to compare elements of `arrays`. The comparator is invoked -with two arguments: (arrVal, othVal). +with two arguments: *(arrVal, othVal)*. +#### Since +4.0.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. 2. `[comparator]` *(Function)*: The comparator invoked per element. #### Returns -*(Array)*: Returns the new array of combined values. +*(Array)*: Returns the new array of combined values. #### Example ```js @@ -1873,18 +1989,20 @@ _.unionWith(objects, others, _.isEqual); ### `_.uniq(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6938 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7299 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm package") Creates a duplicate-free version of an array, using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) -for equality comparisons, in which only the first occurrence of each element -is kept. +for equality comparisons, in which only the first occurrence of each +element is kept. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to inspect. #### Returns -*(Array)*: Returns the new duplicate free array. +*(Array)*: Returns the new duplicate free array. #### Example ```js @@ -1898,18 +2016,20 @@ _.uniq([2, 1, 2]); ### `_.uniqBy(array, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6964 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7327 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqby "See the npm package") This method is like `_.uniq` except that it accepts `iteratee` which is invoked for each element in `array` to generate the criterion by which -uniqueness is computed. The iteratee is invoked with one argument: (value). +uniqueness is computed. The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to inspect. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns the new duplicate free array. +*(Array)*: Returns the new duplicate free array. #### Example ```js @@ -1927,18 +2047,20 @@ _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.uniqWith(array, [comparator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L6988 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7352 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqwith "See the npm package") This method is like `_.uniq` except that it accepts `comparator` which is invoked to compare elements of `array`. The comparator is invoked with -two arguments: (arrVal, othVal). +two arguments: *(arrVal, othVal)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to inspect. 2. `[comparator]` *(Function)*: The comparator invoked per element. #### Returns -*(Array)*: Returns the new duplicate free array. +*(Array)*: Returns the new duplicate free array. #### Example ```js @@ -1954,17 +2076,19 @@ _.uniqWith(objects, _.isEqual); ### `_.unzip(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7012 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7377 "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 configuration. +#### Since +1.2.0 #### Arguments 1. `array` *(Array)*: The array of grouped elements to process. #### Returns -*(Array)*: Returns the new array of regrouped elements. +*(Array)*: Returns the new array of regrouped elements. #### Example ```js @@ -1981,18 +2105,20 @@ _.unzip(zipped); ### `_.unzipWith(array, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7047 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzipwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7414 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzipwith "See the npm package") This method is like `_.unzip` except that it accepts `iteratee` to specify how regrouped values should be combined. The iteratee is invoked with the -elements of each group: (...group). +elements of each group: *(...group)*. +#### Since +3.8.0 #### Arguments 1. `array` *(Array)*: The array of grouped elements to process. 2. `[iteratee=_.identity]` *(Function)*: The function to combine regrouped values. #### Returns -*(Array)*: Returns the new array of regrouped elements. +*(Array)*: Returns the new array of regrouped elements. #### Example ```js @@ -2009,18 +2135,20 @@ _.unzipWith(zipped, _.add); ### `_.without(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7076 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7444 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") Creates an array excluding all given values using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) for equality comparisons. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to filter. 2. `[values]` *(...*)*: The values to exclude. #### Returns -*(Array)*: Returns the new array of filtered values. +*(Array)*: Returns the new array of filtered values. #### Example ```js @@ -2034,17 +2162,20 @@ _.without([1, 2, 1, 3], 1, 2); ### `_.xor([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7097 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7467 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm package") -Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) +Creates an array of unique values that is the +[symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) of the given arrays. The order of result values is determined by the order they occur in the arrays. +#### Since +2.4.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. #### Returns -*(Array)*: Returns the new array of values. +*(Array)*: Returns the new array of values. #### Example ```js @@ -2058,18 +2189,21 @@ _.xor([2, 1], [4, 2]); ### `_.xorBy([arrays], [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7121 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xorby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7494 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xorby "See the npm package") This method is like `_.xor` except that it accepts `iteratee` which is -invoked for each element of each `arrays` to generate the criterion by which -by which they're compared. The iteratee is invoked with one argument: (value). +invoked for each element of each `arrays` to generate the criterion by +which by which they're compared. The iteratee is invoked with one argument:
+*(value)*. +#### Since +4.0.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns the new array of values. +*(Array)*: Returns the new array of values. #### Example ```js @@ -2087,18 +2221,20 @@ _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); ### `_.xorWith([arrays], [comparator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7148 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xorwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7522 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xorwith "See the npm package") This method is like `_.xor` except that it accepts `comparator` which is invoked to compare elements of `arrays`. The comparator is invoked with -two arguments: (arrVal, othVal). +two arguments: *(arrVal, othVal)*. +#### Since +4.0.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to inspect. 2. `[comparator]` *(Function)*: The comparator invoked per element. #### Returns -*(Array)*: Returns the new array of values. +*(Array)*: Returns the new array of values. #### Example ```js @@ -2115,17 +2251,19 @@ _.xorWith(objects, others, _.isEqual); ### `_.zip([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7171 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7546 "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 -of the given arrays, and so on. +Creates an array of grouped elements, the first of which contains the +first elements of the given arrays, the second of which contains the +second elements of the given arrays, and so on. +#### Since +0.1.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to process. #### Returns -*(Array)*: Returns the new array of grouped elements. +*(Array)*: Returns the new array of grouped elements. #### Example ```js @@ -2139,17 +2277,19 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]); ### `_.zipObject([props=[]], [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7188 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7564 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") This method is like `_.fromPairs` except that it accepts two arrays, -one of property names and one of corresponding values. +one of property identifiers and one of corresponding values. +#### Since +0.4.0 #### Arguments -1. `[props=[]]` *(Array)*: The property names. +1. `[props=[]]` *(Array)*: The property identifiers. 2. `[values=[]]` *(Array)*: The property values. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -2163,16 +2303,18 @@ _.zipObject(['a', 'b'], [1, 2]); ### `_.zipObjectDeep([props=[]], [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7206 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobjectdeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7583 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobjectdeep "See the npm package") This method is like `_.zipObject` except that it supports property paths. +#### Since +4.1.0 #### Arguments -1. `[props=[]]` *(Array)*: The property names. +1. `[props=[]]` *(Array)*: The property identifiers. 2. `[values=[]]` *(Array)*: The property values. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -2186,18 +2328,20 @@ _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); ### `_.zipWith([arrays], [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7228 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7606 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipwith "See the npm package") This method is like `_.zip` except that it accepts `iteratee` to specify how grouped values should be combined. The iteratee is invoked with the -elements of each group: (...group). +elements of each group: *(...group)*. +#### Since +3.8.0 #### Arguments 1. `[arrays]` *(...Array)*: The arrays to process. 2. `[iteratee=_.identity]` *(Function)*: The function to combine grouped values. #### Returns -*(Array)*: Returns the new array of grouped elements. +*(Array)*: Returns the new array of grouped elements. #### Example ```js @@ -2219,19 +2363,21 @@ _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { ### `_.countBy(collection, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7619 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7990 "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 invoked with one argument: (value). +The iteratee is invoked with one argument: *(value)*. +#### Since +0.5.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee to transform keys. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee to transform keys. #### Returns -*(Object)*: Returns the composed aggregate object. +*(Object)*: Returns the composed aggregate object. #### Example ```js @@ -2248,18 +2394,20 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7657 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8031 "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`. Iteration is stopped once `predicate` returns falsey. The predicate is -invoked with three arguments: (value, index|key, collection). +invoked with three arguments: *(value, index|key, collection)*. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(boolean)*: Returns `true` if all elements pass the predicate check, else `false`. +*(boolean)*: Returns `true` if all elements pass the predicate check, else `false`. #### Example ```js @@ -2267,8 +2415,8 @@ _.every([true, 1, null, 'yes'], Boolean); // => false var users = [ - { 'user': 'barney', 'active': false }, - { 'user': 'fred', 'active': false } + { 'user': 'barney', 'age': 36, 'active': false }, + { 'user': 'fred', 'age': 40, 'active': false } ]; // The `_.matches` iteratee shorthand. @@ -2290,18 +2438,20 @@ _.every(users, 'active'); ### `_.filter(collection, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7698 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8074 "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 invoked with three arguments:
-(value, index|key, collection). +`predicate` returns truthy for. The predicate is invoked with three +arguments: *(value, index|key, collection)*. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the new filtered array. +*(Array)*: Returns the new filtered array. #### Example ```js @@ -2332,18 +2482,20 @@ _.filter(users, 'active'); ### `_.find(collection, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7737 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8115 "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 invoked with three arguments:
-(value, index|key, collection). +`predicate` returns truthy for. The predicate is invoked with three +arguments: *(value, index|key, collection)*. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(*)*: Returns the matched element, else `undefined`. +*(*)*: Returns the matched element, else `undefined`. #### Example ```js @@ -2375,17 +2527,19 @@ _.find(users, 'active'); ### `_.findLast(collection, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7763 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8143 "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. +#### Since +2.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(*)*: Returns the matched element, else `undefined`. +*(*)*: Returns the matched element, else `undefined`. #### Example ```js @@ -2401,18 +2555,20 @@ _.findLast([1, 2, 3, 4], function(n) { ### `_.flatMap(collection, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7792 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatmap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8174 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatmap "See the npm package") -Creates an array of flattened values by running each element in `collection` -through `iteratee` and concating its result to the other mapped values. -The iteratee is invoked with three arguments: (value, index|key, collection). +Creates a flattened array of values by running each element in `collection` +through `iteratee` and flattening the mapped results. The iteratee is +invoked with three arguments: *(value, index|key, collection)*. +#### Since +4.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the new flattened array. +*(Array)*: Returns the new flattened array. #### Example ```js @@ -2429,18 +2585,81 @@ _.flatMap([1, 2], duplicate); +### `_.flatMapDeep(collection, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8199 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatmapdeep "See the npm package") + +This method is like `_.flatMap` except that it recursively flattens the +mapped results. + +#### Since +4.7.0 +#### Arguments +1. `collection` *(Array|Object)*: The collection to iterate over. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. + +#### Returns +*(Array)*: Returns the new flattened array. + +#### Example +```js +function duplicate(n) { + return [[[n, n]]]; +} + +_.flatMapDeep([1, 2], duplicate); +// => [1, 1, 2, 2] +``` +* * * + + + + + +### `_.flatMapDepth(collection, [iteratee=_.identity], [depth=1])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8225 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatmapdepth "See the npm package") + +This method is like `_.flatMap` except that it recursively flattens the +mapped results up to `depth` times. + +#### Since +4.7.0 +#### Arguments +1. `collection` *(Array|Object)*: The collection to iterate over. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. +3. `[depth=1]` *(number)*: The maximum recursion depth. + +#### Returns +*(Array)*: Returns the new flattened array. + +#### Example +```js +function duplicate(n) { + return [[[n, n]]]; +} + +_.flatMapDepth([1, 2], duplicate, 2); +// => [[1, 1], [2, 2]] +``` +* * * + + + + + ### `_.forEach(collection, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7824 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8259 "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 invoked with three arguments: (value, index|key, collection). +The iteratee is invoked with three arguments: *(value, index|key, collection)*. Iteratee functions may exit iteration early by explicitly returning `false`.

-**Note:** As with other "Collections" methods, objects with a "length" property -are iterated like arrays. To avoid this behavior use `_.forIn` or `_.forOwn` -for object iteration. +**Note:** As with other "Collections" methods, objects with a "length" +property are iterated like arrays. To avoid this behavior use `_.forIn` +or `_.forOwn` for object iteration. +#### Since +0.1.0 #### Aliases *_.each* @@ -2449,19 +2668,19 @@ for object iteration. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. #### Returns -*(Array|Object)*: Returns `collection`. +*(*)*: Returns `collection`. #### Example ```js _([1, 2]).forEach(function(value) { console.log(value); }); -// => logs `1` then `2` +// => Logs `1` then `2`. _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { console.log(key); }); -// => logs 'a' then 'b' (iteration order is not guaranteed) +// => Logs 'a' then 'b' (iteration order is not guaranteed). ``` * * * @@ -2470,11 +2689,13 @@ _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { ### `_.forEachRight(collection, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7848 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8284 "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. +#### Since +2.0.0 #### Aliases *_.eachRight* @@ -2483,14 +2704,14 @@ This method is like `_.forEach` except that it iterates over elements of 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. #### Returns -*(Array|Object)*: Returns `collection`. +*(*)*: Returns `collection`. #### Example ```js _.forEachRight([1, 2], function(value) { console.log(value); }); -// => logs `2` then `1` +// => Logs `2` then `1`. ``` * * * @@ -2499,19 +2720,21 @@ _.forEachRight([1, 2], function(value) { ### `_.groupBy(collection, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7875 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8313 "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 elements responsible for generating the key. -The iteratee is invoked with one argument: (value). +The iteratee is invoked with one argument: *(value)*. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee to transform keys. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee to transform keys. #### Returns -*(Object)*: Returns the composed aggregate object. +*(Object)*: Returns the composed aggregate object. #### Example ```js @@ -2529,20 +2752,23 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.includes(collection, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7911 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8351 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") -Checks if `value` is in `collection`. If `collection` is a string it's checked -for a substring of `value`, otherwise [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) +Checks if `value` is in `collection`. If `collection` is a string it's +checked for a substring of `value`, otherwise +[`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) is used for equality comparisons. If `fromIndex` is negative, it's used as the offset from the end of `collection`. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. 2. `value` *(*)*: The value to search for. 3. `[fromIndex=0]` *(number)*: The index to search from. #### Returns -*(boolean)*: Returns `true` if `value` is found, else `false`. +*(boolean)*: Returns `true` if `value` is found, else `false`. #### Example ```js @@ -2565,20 +2791,22 @@ _.includes('pebbles', 'eb'); ### `_.invokeMap(collection, path, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7946 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invokemap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8387 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invokemap "See the npm package") Invokes the method at `path` of each element in `collection`, returning an array of the results of each invoked method. Any additional arguments are provided to each invoked method. If `methodName` is a function it's invoked for, and `this` bound to, each element in `collection`. +#### Since +4.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. 2. `path` *(Array|Function|string)*: The path of the method to invoke or the function invoked per iteration. 3. `[args]` *(...*)*: The arguments to invoke each method with. #### Returns -*(Array)*: Returns the array of results. +*(Array)*: Returns the array of results. #### Example ```js @@ -2595,19 +2823,21 @@ _.invokeMap([123, 456], String.prototype.split, ''); ### `_.keyBy(collection, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7986 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keyby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8429 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keyby "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 is invoked with one argument: (value). +iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee to transform keys. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee to transform keys. #### Returns -*(Object)*: Returns the composed aggregate object. +*(Object)*: Returns the composed aggregate object. #### Example ```js @@ -2631,11 +2861,11 @@ _.keyBy(array, 'dir'); ### `_.map(collection, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8031 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8476 "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 invoked with three arguments:
-(value, index|key, collection). +*(value, index|key, collection)*.

Many lodash methods are guarded to work as iteratees for methods like @@ -2648,12 +2878,14 @@ The guarded methods are:
`sortBy`, `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`, and `words` +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the new mapped array. +*(Array)*: Returns the new mapped array. #### Example ```js @@ -2682,34 +2914,36 @@ _.map(users, 'user'); -### `_.orderBy(collection, [iteratees=[_.identity]], [orders])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8063 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.orderby "See the npm package") +### `_.orderBy(collection, [iteratees=[_.identity]], [orders])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8510 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.orderby "See the npm package") This method is like `_.sortBy` except that it allows specifying the sort orders of the iteratees to sort by. If `orders` is unspecified, all values are sorted in ascending order. Otherwise, specify an order of "desc" for descending or "asc" for ascending sort order of corresponding values. +#### Since +4.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[iteratees=[_.identity]]` *(Function[]|Object[]|string[])*: The iteratees to sort by. +2. `[iteratees=[_.identity]]` *(Array[]|Function[]|Object[]|string[])*: The iteratees to sort by. 3. `[orders]` *(string[])*: The sort orders of `iteratees`. #### Returns -*(Array)*: Returns the new sorted array. +*(Array)*: Returns the new sorted array. #### Example ```js var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 34 }, - { 'user': 'fred', 'age': 42 }, + { 'user': 'fred', 'age': 40 }, { 'user': 'barney', 'age': 36 } ]; // Sort by `user` in ascending order and by `age` in descending order. _.orderBy(users, ['user', 'age'], ['asc', 'desc']); -// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] +// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] ``` * * * @@ -2718,19 +2952,21 @@ _.orderBy(users, ['user', 'age'], ['asc', 'desc']); ### `_.partition(collection, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8112 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8561 "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, the second of which contains elements `predicate` returns falsey for. The predicate is -invoked with one argument: (value). +invoked with one argument: *(value)*. +#### Since +3.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the array of grouped elements. +*(Array)*: Returns the array of grouped elements. #### Example ```js @@ -2762,14 +2998,14 @@ _.partition(users, 'active'); ### `_.reduce(collection, [iteratee=_.identity], [accumulator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8151 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8601 "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 given the first element of `collection` is used as the initial value. The iteratee is invoked with four arguments:
-(accumulator, value, index|key, collection). +*(accumulator, value, index|key, collection)*.

Many lodash methods are guarded to work as iteratees for methods like @@ -2780,13 +3016,15 @@ The guarded methods are:
`assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, and `sortBy` +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. 3. `[accumulator]` *(*)*: The initial value. #### Returns -*(*)*: Returns the accumulated value. +*(*)*: Returns the accumulated value. #### Example ```js @@ -2808,18 +3046,20 @@ _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { ### `_.reduceRight(collection, [iteratee=_.identity], [accumulator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8178 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8629 "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. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. 3. `[accumulator]` *(*)*: The initial value. #### Returns -*(*)*: Returns the accumulated value. +*(*)*: Returns the accumulated value. #### Example ```js @@ -2837,17 +3077,19 @@ _.reduceRight(array, function(flattened, other) { ### `_.reject(collection, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8217 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8670 "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. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the new filtered array. +*(Array)*: Returns the new filtered array. #### Example ```js @@ -2878,15 +3120,17 @@ _.reject(users, 'active'); ### `_.sample(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8238 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8692 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") Gets a random element from `collection`. +#### Since +2.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to sample. #### Returns -*(*)*: Returns the random element. +*(*)*: Returns the random element. #### Example ```js @@ -2900,17 +3144,19 @@ _.sample([1, 2, 3, 4]); ### `_.sampleSize(collection, [n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8263 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.samplesize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8718 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.samplesize "See the npm package") Gets `n` random elements at unique keys from `collection` up to the size of `collection`. +#### Since +4.0.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to sample. 2. `[n=0]` *(number)*: The number of elements to sample. #### Returns -*(Array)*: Returns the random elements. +*(Array)*: Returns the random elements. #### Example ```js @@ -2927,16 +3173,18 @@ _.sampleSize([1, 2, 3], 4); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8295 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.shuffle "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8751 "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](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to shuffle. #### Returns -*(Array)*: Returns the new shuffled array. +*(Array)*: Returns the new shuffled array. #### Example ```js @@ -2950,16 +3198,18 @@ _.shuffle([1, 2, 3, 4]); ### `_.size(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8319 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.size "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8776 "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. +values or the number of own enumerable string keyed properties for objects. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to inspect. #### Returns -*(number)*: Returns the collection size. +*(number)*: Returns the collection size. #### Example ```js @@ -2979,18 +3229,20 @@ _.size('pebbles'); ### `_.some(collection, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8364 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8830 "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`. Iteration is stopped once `predicate` returns truthy. The predicate is -invoked with three arguments: (value, index|key, collection). +invoked with three arguments: *(value, index|key, collection)*. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(boolean)*: Returns `true` if any element passes the predicate check, else `false`. +*(boolean)*: Returns `true` if any element passes the predicate check, else `false`. #### Example ```js @@ -3020,40 +3272,42 @@ _.some(users, 'active'); -### `_.sortBy(collection, [iteratees=[_.identity]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8405 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortby "See the npm package") +### `_.sortBy(collection, [iteratees=[_.identity]])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8873 "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 each iteratee. This method performs a stable sort, that is, it preserves the original sort order of -equal elements. The iteratees are invoked with one argument: (value). +equal elements. The iteratees are invoked with one argument: *(value)*. +#### Since +0.1.0 #### Arguments 1. `collection` *(Array|Object)*: The collection to iterate over. -2. `[iteratees=[_.identity]]` *(...(Function|Function[]|Object|Object[]|string|string[])*: The iteratees to sort by, specified individually or in arrays. +2. `[iteratees=[_.identity]]` *(...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[]))*: The iteratees to sort by, specified individually or in arrays. #### Returns -*(Array)*: Returns the new sorted array. +*(Array)*: Returns the new sorted array. #### Example ```js var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 42 }, + { 'user': 'fred', 'age': 40 }, { 'user': 'barney', 'age': 34 } ]; _.sortBy(users, function(o) { return o.user; }); -// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] +// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] _.sortBy(users, ['user', 'age']); -// => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] +// => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] _.sortBy(users, 'user', function(o) { return Math.floor(o.age / 10); }); -// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] +// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] ``` * * * @@ -3068,20 +3322,22 @@ _.sortBy(users, 'user', function(o) { ### `_.now()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8436 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8905 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") -({Function}): Gets the timestamp of the number of milliseconds that have elapsed since -the Unix epoch (1 January 1970 00:00:00 UTC). +Gets the timestamp of the number of milliseconds that have elapsed since +the Unix epoch *(1 January `1970 00`:00:00 UTC)*. +#### Since +2.4.0 #### Returns -*(number)*: Returns the timestamp. +*(number)*: Returns the timestamp. #### Example ```js _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); -// => logs the number of milliseconds it took for the deferred function to be invoked +// => Logs the number of milliseconds it took for the deferred function to be invoked. ``` * * * @@ -3096,17 +3352,19 @@ _.defer(function(stamp) { ### `_.after(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8463 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.after "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8933 "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's called `n` or more times. +#### Since +0.1.0 #### Arguments 1. `n` *(number)*: The number of calls before `func` is invoked. 2. `func` *(Function)*: The function to restrict. #### Returns -*(Function)*: Returns the new restricted function. +*(Function)*: Returns the new restricted function. #### Example ```js @@ -3119,7 +3377,7 @@ var done = _.after(saves.length, function() { _.forEach(saves, function(type) { asyncSave({ 'type': type, 'complete': done }); }); -// => logs 'done saving!' after the two async saves have completed +// => Logs 'done saving!' after the two async saves have completed. ``` * * * @@ -3128,17 +3386,19 @@ _.forEach(saves, function(type) { ### `_.ary(func, [n=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8491 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ary "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8962 "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. +#### Since +3.0.0 #### Arguments 1. `func` *(Function)*: The function to cap arguments for. 2. `[n=func.length]` *(number)*: The arity cap. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3152,18 +3412,20 @@ _.map(['6', '8', '10'], _.ary(parseInt, 1)); ### `_.before(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8513 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.before "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L8985 "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's called less than `n` times. Subsequent calls to the created function return the result of the last `func` invocation. +#### Since +3.0.0 #### Arguments 1. `n` *(number)*: The number of calls at which `func` is no longer invoked. 2. `func` *(Function)*: The function to restrict. #### Returns -*(Function)*: Returns the new restricted function. +*(Function)*: Returns the new restricted function. #### Example ```js @@ -3177,7 +3439,7 @@ jQuery(element).on('click', _.before(5, addContactToList)); ### `_.bind(func, thisArg, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8565 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bind "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9038 "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 @@ -3191,13 +3453,15 @@ may be used as a placeholder for partially applied arguments. **Note:** Unlike native `Function#bind` this method doesn't set the "length" property of bound functions. +#### Since +0.1.0 #### Arguments 1. `func` *(Function)*: The function to bind. 2. `thisArg` *(*)*: The `this` binding of `func`. 3. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns -*(Function)*: Returns the new bound function. +*(Function)*: Returns the new bound function. #### Example ```js @@ -3223,28 +3487,30 @@ bound('hi'); ### `_.bindKey(object, key, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8618 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9092 "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.

This method differs from `_.bind` by allowing bound functions to reference -methods that may be redefined or don't yet exist. -See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) +methods that may be redefined or don't yet exist. See +[Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) for more details.

The `_.bindKey.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for partially applied arguments. +#### Since +0.10.0 #### Arguments 1. `object` *(Object)*: The object to invoke the method on. 2. `key` *(string)*: The key of the method. 3. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns -*(Function)*: Returns the new bound function. +*(Function)*: Returns the new bound function. #### Example ```js @@ -3278,7 +3544,7 @@ bound('hi'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8667 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9142 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") Creates a function that accepts arguments of `func` and either invokes `func` returning its result, if at least `arity` number of arguments have @@ -3293,12 +3559,14 @@ may be used as a placeholder for provided arguments.
**Note:** This method doesn't set the "length" property of curried functions. +#### Since +2.0.0 #### Arguments 1. `func` *(Function)*: The function to curry. 2. `[arity=func.length]` *(number)*: The arity of `func`. #### Returns -*(Function)*: Returns the new curried function. +*(Function)*: Returns the new curried function. #### Example ```js @@ -3328,7 +3596,7 @@ curried(1)(_, 3)(2); ### `_.curryRight(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8711 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curryright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9187 "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`. @@ -3340,12 +3608,14 @@ builds, may be used as a placeholder for provided arguments.
**Note:** This method doesn't set the "length" property of curried functions. +#### Since +3.0.0 #### Arguments 1. `func` *(Function)*: The function to curry. 2. `[arity=func.length]` *(number)*: The arity of `func`. #### Returns -*(Function)*: Returns the new curried function. +*(Function)*: Returns the new curried function. #### Example ```js @@ -3374,8 +3644,8 @@ curried(3)(1, _)(2); -### `_.debounce(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8767 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the npm package") +### `_.debounce(func, [wait=0], [options={}], [options.leading=false], [options.maxWait], [options.trailing=true])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9244 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the npm package") Creates a debounced function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time the debounced function was @@ -3395,16 +3665,18 @@ invoked more than once during the `wait` timeout. See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) for details over the differences between `_.debounce` and `_.throttle`. +#### Since +0.1.0 #### Arguments 1. `func` *(Function)*: The function to debounce. 2. `[wait=0]` *(number)*: The number of milliseconds to delay. -3. `[options]` *(Object)*: The options object. +3. `[options={}]` *(Object)*: The options object. 4. `[options.leading=false]` *(boolean)*: Specify invoking on the leading edge of the timeout. 5. `[options.maxWait]` *(number)*: The maximum time `func` is allowed to be delayed before it's invoked. 6. `[options.trailing=true]` *(boolean)*: Specify invoking on the trailing edge of the timeout. #### Returns -*(Function)*: Returns the new debounced function. +*(Function)*: Returns the new debounced function. #### Example ```js @@ -3432,24 +3704,26 @@ jQuery(window).on('popstate', debounced.cancel); ### `_.defer(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8901 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defer "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9379 "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's invoked. +#### Since +0.1.0 #### Arguments 1. `func` *(Function)*: The function to defer. 2. `[args]` *(...*)*: The arguments to invoke `func` with. #### Returns -*(number)*: Returns the timer id. +*(number)*: Returns the timer id. #### Example ```js _.defer(function(text) { console.log(text); }, 'deferred'); -// => logs 'deferred' after one or more milliseconds +// => Logs 'deferred' after one or more milliseconds. ``` * * * @@ -3458,25 +3732,27 @@ _.defer(function(text) { ### `_.delay(func, wait, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8923 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.delay "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9402 "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's invoked. +#### Since +0.1.0 #### Arguments 1. `func` *(Function)*: The function to delay. 2. `wait` *(number)*: The number of milliseconds to delay invocation. 3. `[args]` *(...*)*: The arguments to invoke `func` with. #### Returns -*(number)*: Returns the timer id. +*(number)*: Returns the timer id. #### Example ```js _.delay(function(text) { console.log(text); }, 1000, 'later'); -// => logs 'later' after one second +// => Logs 'later' after one second. ``` * * * @@ -3485,15 +3761,17 @@ _.delay(function(text) { ### `_.flip(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8944 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9424 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flip "See the npm package") Creates a function that invokes `func` with arguments reversed. +#### Since +4.0.0 #### Arguments 1. `func` *(Function)*: The function to flip arguments for. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3511,7 +3789,7 @@ flipped('a', 'b', 'c', 'd'); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L8990 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.memoize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9472 "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 @@ -3522,15 +3800,18 @@ is invoked with the `this` binding of the memoized function.
**Note:** The cache is exposed as the `cache` property on the memoized function. Its creation may be customized by replacing the `_.memoize.Cache` -constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) +constructor with one whose instances implement the +[`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) method interface of `delete`, `get`, `has`, and `set`. +#### Since +0.1.0 #### Arguments 1. `func` *(Function)*: The function to have its output memoized. 2. `[resolver]` *(Function)*: The function to resolve the cache key. #### Returns -*(Function)*: Returns the new memoizing function. +*(Function)*: Returns the new memoizing function. #### Example ```js @@ -3563,17 +3844,19 @@ _.memoize.Cache = WeakMap; ### `_.negate(predicate)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9029 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.negate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9515 "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 created function. +#### Since +3.0.0 #### Arguments 1. `predicate` *(Function)*: The predicate to negate. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3591,17 +3874,19 @@ _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); ### `_.once(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9055 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9542 "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 invocation. The `func` is invoked with the `this` binding and arguments of the created function. +#### Since +0.1.0 #### Arguments 1. `func` *(Function)*: The function to restrict. #### Returns -*(Function)*: Returns the new restricted function. +*(Function)*: Returns the new restricted function. #### Example ```js @@ -3617,17 +3902,20 @@ initialize(); ### `_.overArgs(func, [transforms])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9090 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.overargs "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9578 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.overargs "See the npm package") Creates a function that invokes `func` with arguments transformed by corresponding `transforms`. +#### Since +4.0.0 #### Arguments 1. `func` *(Function)*: The function to wrap. -2. `[transforms]` *(...(Function|Function[])*: The functions to transform arguments, specified individually or in arrays. +2. `[transforms]` *(...(Function|Function[]))*: The functions to transform +arguments, specified individually or in arrays. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3656,7 +3944,7 @@ func(10, 5); ### `_.partial(func, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9137 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partial "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9626 "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 @@ -3670,12 +3958,14 @@ builds, may be used as a placeholder for partially applied arguments. **Note:** This method doesn't set the "length" property of partially applied functions. +#### Since +0.2.0 #### Arguments 1. `func` *(Function)*: The function to partially apply arguments to. 2. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns -*(Function)*: Returns the new partially applied function. +*(Function)*: Returns the new partially applied function. #### Example ```js @@ -3699,7 +3989,7 @@ greetFred('hi'); ### `_.partialRight(func, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9173 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partialright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9663 "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. @@ -3712,12 +4002,14 @@ builds, may be used as a placeholder for partially applied arguments. **Note:** This method doesn't set the "length" property of partially applied functions. +#### Since +1.0.0 #### Arguments 1. `func` *(Function)*: The function to partially apply arguments to. 2. `[partials]` *(...*)*: The arguments to be partially applied. #### Returns -*(Function)*: Returns the new partially applied function. +*(Function)*: Returns the new partially applied function. #### Example ```js @@ -3741,19 +4033,21 @@ sayHelloTo('fred'); ### `_.rearg(func, indexes)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9200 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rearg "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9691 "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 provided as the first argument, the argument value at the second index is provided as the second argument, and so on. +#### Since +3.0.0 #### Arguments 1. `func` *(Function)*: The function to rearrange arguments for. -2. `indexes` *(...(number|number[])*: The arranged argument indexes, specified individually or in arrays. +2. `indexes` *(...(number|number[]))*: The arranged argument indexes, specified individually or in arrays. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3771,20 +4065,24 @@ rearged('b', 'c', 'a') ### `_.rest(func, [start=func.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9226 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9720 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") Creates a function that invokes `func` with the `this` binding of the -created function and arguments from `start` and beyond provided as an array. +created function and arguments from `start` and beyond provided as +an array.

-**Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters). +**Note:** This method is based on the +[rest parameter](https://mdn.io/rest_parameters). +#### Since +4.0.0 #### 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. +*(Function)*: Returns the new function. #### Example ```js @@ -3803,20 +4101,24 @@ say('hello', 'fred', 'barney', 'pebbles'); ### `_.spread(func, [start=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9286 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.spread "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9783 "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`](https://es5.github.io/#x15.3.4.3). +Creates a function that invokes `func` with the `this` binding of the +create 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://mdn.io/spread_operator). +**Note:** This method is based on the +[spread operator](https://mdn.io/spread_operator). +#### Since +3.2.0 #### Arguments 1. `func` *(Function)*: The function to spread arguments over. 2. `[start=0]` *(number)*: The start position of the spread. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3843,8 +4145,8 @@ numbers.then(_.spread(function(x, y) { -### `_.throttle(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9342 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the npm package") +### `_.throttle(func, [wait=0], [options={}], [options.leading=true], [options.trailing=true])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9840 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the npm package") Creates a throttled function that only invokes `func` at most once per every `wait` milliseconds. The throttled function comes with a `cancel` @@ -3856,23 +4158,25 @@ throttled function. Subsequent calls to the throttled function return the result of the last `func` invocation.

-**Note:** If `leading` and `trailing` options are `true`, `func` is invoked -on the trailing edge of the timeout only if the throttled function is -invoked more than once during the `wait` timeout. +**Note:** If `leading` and `trailing` options are `true`, `func` is +invoked on the trailing edge of the timeout only if the throttled function +is invoked more than once during the `wait` timeout.

See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) for details over the differences between `_.throttle` and `_.debounce`. +#### Since +0.1.0 #### Arguments 1. `func` *(Function)*: The function to throttle. 2. `[wait=0]` *(number)*: The number of milliseconds to throttle invocations to. -3. `[options]` *(Object)*: The options object. +3. `[options={}]` *(Object)*: The options object. 4. `[options.leading=true]` *(boolean)*: Specify invoking on the leading edge of the timeout. 5. `[options.trailing=true]` *(boolean)*: Specify invoking on the trailing edge of the timeout. #### Returns -*(Function)*: Returns the new throttled function. +*(Function)*: Returns the new throttled function. #### Example ```js @@ -3893,16 +4197,18 @@ jQuery(window).on('popstate', throttled.cancel); ### `_.unary(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9374 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unary "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9873 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unary "See the npm package") Creates a function that accepts up to one argument, ignoring any additional arguments. +#### Since +4.0.0 #### Arguments 1. `func` *(Function)*: The function to cap arguments for. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3916,19 +4222,21 @@ _.map(['6', '8', '10'], _.unary(parseInt)); ### `_.wrap(value, [wrapper=identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9399 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.wrap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9899 "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 appended to those provided to the wrapper function. The wrapper is invoked with the `this` binding of the created function. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to wrap. 2. `[wrapper=identity]` *(Function)*: The wrapper function. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -3952,15 +4260,17 @@ p('fred, barney, & pebbles'); ### `_.castArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9438 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.castarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9939 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.castarray "See the npm package") Casts `value` as an array if it's not one. +#### Since +4.4.0 #### Arguments 1. `value` *(*)*: The value to inspect. #### Returns -*(Array)*: Returns the cast array. +*(Array)*: Returns the cast array. #### Example ```js @@ -3993,7 +4303,7 @@ console.log(_.castArray(array) === array); ### `_.clone(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9470 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L9972 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") Creates a shallow clone of `value`.
@@ -4006,11 +4316,13 @@ arrays. The own enumerable properties of `arguments` objects are cloned as plain objects. An empty object is returned for uncloneable values such as error objects, functions, DOM nodes, and WeakMaps. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to clone. #### Returns -*(*)*: Returns the cloned value. +*(*)*: Returns the cloned value. #### Example ```js @@ -4027,15 +4339,17 @@ console.log(shallow[0] === objects[0]); ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9523 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10027 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") This method is like `_.clone` except that it recursively clones `value`. +#### Since +1.0.0 #### Arguments 1. `value` *(*)*: The value to recursively clone. #### Returns -*(*)*: Returns the deep cloned value. +*(*)*: Returns the deep cloned value. #### Example ```js @@ -4052,16 +4366,18 @@ console.log(deep[0] === objects[0]); ### `_.cloneDeepWith(value, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9553 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeepwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10058 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeepwith "See the npm package") This method is like `_.cloneWith` except that it recursively clones `value`. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to recursively clone. 2. `[customizer]` *(Function)*: The function to customize cloning. #### Returns -*(*)*: Returns the deep cloned value. +*(*)*: Returns the deep cloned value. #### Example ```js @@ -4087,19 +4403,21 @@ console.log(el.childNodes.length); ### `_.cloneWith(value, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9503 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonewith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10006 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonewith "See the npm package") This method is like `_.clone` except that it accepts `customizer` which is invoked to produce the cloned value. If `customizer` returns `undefined` cloning is handled by the method instead. The `customizer` is invoked with -up to four arguments; (value [, index|key, object, stack]). +up to four arguments; *(value [, index|key, object, stack])*. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to clone. 2. `[customizer]` *(Function)*: The function to customize cloning. #### Returns -*(*)*: Returns the cloned value. +*(*)*: Returns the cloned value. #### Example ```js @@ -4125,17 +4443,20 @@ console.log(el.childNodes.length); ### `_.eq(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9587 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.eq "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10094 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.eq "See the npm package") -Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) +Performs a +[`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) comparison between two values to determine if they are equivalent. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. #### Returns -*(boolean)*: Returns `true` if the values are equivalent, else `false`. +*(boolean)*: Returns `true` if the values are equivalent, else `false`. #### Example ```js @@ -4164,16 +4485,18 @@ _.eq(NaN, NaN); ### `_.gt(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9611 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.gt "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10120 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.gt "See the npm package") Checks if `value` is greater than `other`. +#### Since +3.9.0 #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. #### Returns -*(boolean)*: Returns `true` if `value` is greater than `other`, else `false`. +*(boolean)*: Returns `true` if `value` is greater than `other`, else `false`. #### Example ```js @@ -4193,16 +4516,18 @@ _.gt(1, 3); ### `_.gte(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9635 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.gte "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10146 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.gte "See the npm package") Checks if `value` is greater than or equal to `other`. +#### Since +3.9.0 #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. #### Returns -*(boolean)*: Returns `true` if `value` is greater than or equal to `other`, else `false`. +*(boolean)*: Returns `true` if `value` is greater than or equal to `other`, else `false`. #### Example ```js @@ -4222,15 +4547,17 @@ _.gte(1, 3); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9655 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10168 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") Checks if `value` is likely an `arguments` object. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4247,15 +4574,17 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9684 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10199 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") -({Function}): Checks if `value` is classified as an `Array` object. +Checks if `value` is classified as an `Array` object. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4278,15 +4607,17 @@ _.isArray(_.noop); ### `_.isArrayBuffer(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9702 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarraybuffer "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10219 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarraybuffer "See the npm package") Checks if `value` is classified as an `ArrayBuffer` object. +#### Since +4.3.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4303,17 +4634,19 @@ _.isArrayBuffer(new Array(2)); ### `_.isArrayLike(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9730 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarraylike "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10248 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarraylike "See the npm package") Checks if `value` is array-like. A value is considered array-like if it's not a function and has a `value.length` that's an integer greater than or equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is array-like, else `false`. +*(boolean)*: Returns `true` if `value` is array-like, else `false`. #### Example ```js @@ -4336,16 +4669,18 @@ _.isArrayLike(_.noop); ### `_.isArrayLikeObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9757 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarraylikeobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10277 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarraylikeobject "See the npm package") This method is like `_.isArrayLike` except that it also checks if `value` is an object. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is an array-like object, else `false`. +*(boolean)*: Returns `true` if `value` is an array-like object, else `false`. #### Example ```js @@ -4368,15 +4703,17 @@ _.isArrayLikeObject(_.noop); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9777 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isboolean "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10299 "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. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4393,15 +4730,17 @@ _.isBoolean(null); ### `_.isBuffer(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9798 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isbuffer "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10321 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isbuffer "See the npm package") Checks if `value` is a buffer. +#### Since +4.3.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is a buffer, else `false`. +*(boolean)*: Returns `true` if `value` is a buffer, else `false`. #### Example ```js @@ -4418,15 +4757,17 @@ _.isBuffer(new Uint8Array(2)); ### `_.isDate(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9818 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10343 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") Checks if `value` is classified as a `Date` object. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4443,15 +4784,17 @@ _.isDate('Mon April 23 2012'); ### `_.isElement(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9838 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10365 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") Checks if `value` is likely a DOM element. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is a DOM element, else `false`. +*(boolean)*: Returns `true` if `value` is a DOM element, else `false`. #### Example ```js @@ -4468,17 +4811,26 @@ _.isElement(''); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9869 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10402 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") -Checks if `value` is an empty collection or object. A value is considered -empty if it's an `arguments` object, array, string, or jQuery-like collection -with a length of `0` or has no own enumerable properties. +Checks if `value` is an empty object, collection, map, or set. +
+
+Objects are considered empty if they have no own enumerable string keyed +properties. +
+
+Array-like values such as `arguments` objects, arrays, buffers, strings, or +jQuery-like collections are considered empty if they have a `length` of `0`. +Similarly, maps and sets are considered empty if they have a `size` of `0`. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is empty, else `false`. +*(boolean)*: Returns `true` if `value` is empty, else `false`. #### Example ```js @@ -4504,7 +4856,7 @@ _.isEmpty({ 'a': 1 }); ### `_.isEqual(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9910 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10451 "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. @@ -4516,12 +4868,14 @@ sets, strings, symbols, and typed arrays. `Object` objects are compared by their own, not inherited, enumerable properties. Functions and DOM nodes are **not** supported. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. #### Returns -*(boolean)*: Returns `true` if the values are equivalent, else `false`. +*(boolean)*: Returns `true` if the values are equivalent, else `false`. #### Example ```js @@ -4541,20 +4895,22 @@ object === other; ### `_.isEqualWith(value, other, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9945 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequalwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10488 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequalwith "See the npm package") This method is like `_.isEqual` except that it accepts `customizer` which is invoked to compare values. If `customizer` returns `undefined` comparisons are handled by the method instead. The `customizer` is invoked with up to -six arguments: (objValue, othValue [, index|key, object, other, stack]). +six arguments: *(objValue, othValue [, index|key, object, other, stack])*. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. 3. `[customizer]` *(Function)*: The function to customize comparisons. #### Returns -*(boolean)*: Returns `true` if the values are equivalent, else `false`. +*(boolean)*: Returns `true` if the values are equivalent, else `false`. #### Example ```js @@ -4581,16 +4937,18 @@ _.isEqualWith(array, other, customizer); ### `_.isError(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L9968 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iserror "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10513 "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. +#### Since +3.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is an error object, else `false`. +*(boolean)*: Returns `true` if `value` is an error object, else `false`. #### Example ```js @@ -4607,18 +4965,21 @@ _.isError(Error); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10000 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10548 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") Checks if `value` is a finite primitive number.

-**Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite). +**Note:** This method is based on +[`Number.isFinite`](https://mdn.io/Number/isFinite). +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is a finite number, else `false`. +*(boolean)*: Returns `true` if `value` is a finite number, else `false`. #### Example ```js @@ -4641,15 +5002,17 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10020 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10570 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") Checks if `value` is classified as a `Function` object. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4666,18 +5029,21 @@ _.isFunction(/abc/); ### `_.isInteger(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10052 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isinteger "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10604 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isinteger "See the npm package") Checks if `value` is an integer.

-**Note:** This method is based on [`Number.isInteger`](https://mdn.io/Number/isInteger). +**Note:** This method is based on +[`Number.isInteger`](https://mdn.io/Number/isInteger). +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is an integer, else `false`. +*(boolean)*: Returns `true` if `value` is an integer, else `false`. #### Example ```js @@ -4700,18 +5066,21 @@ _.isInteger('3'); ### `_.isLength(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10080 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.islength "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10635 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.islength "See the npm package") Checks if `value` is a valid array-like length.

-**Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). +**Note:** This function is loosely based on +[`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is a valid length, else `false`. +*(boolean)*: Returns `true` if `value` is a valid length, else `false`. #### Example ```js @@ -4734,15 +5103,17 @@ _.isLength('3'); ### `_.isMap(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10156 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10715 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismap "See the npm package") Checks if `value` is classified as a `Map` object. +#### Since +4.3.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4759,7 +5130,7 @@ _.isMap(new WeakMap); ### `_.isMatch(object, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10183 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10743 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") Performs a partial deep comparison between `object` and `source` to determine if `object` contains equivalent property values. This method is @@ -4768,12 +5139,14 @@ equivalent to a `_.matches` function when `source` is partially applied.
**Note:** This method supports comparing the same values as `_.isEqual`. +#### Since +3.0.0 #### Arguments 1. `object` *(Object)*: The object to inspect. 2. `source` *(Object)*: The object of property values to match. #### Returns -*(boolean)*: Returns `true` if `object` is a match, else `false`. +*(boolean)*: Returns `true` if `object` is a match, else `false`. #### Example ```js @@ -4792,20 +5165,22 @@ _.isMatch(object, { 'age': 36 }); ### `_.isMatchWith(object, source, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10218 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatchwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10779 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatchwith "See the npm package") This method is like `_.isMatch` except that it accepts `customizer` which is invoked to compare values. If `customizer` returns `undefined` comparisons are handled by the method instead. The `customizer` is invoked with five -arguments: (objValue, srcValue, index|key, object, source). +arguments: *(objValue, srcValue, index|key, object, source)*. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The object to inspect. 2. `source` *(Object)*: The object of property values to match. 3. `[customizer]` *(Function)*: The function to customize comparisons. #### Returns -*(boolean)*: Returns `true` if `object` is a match, else `false`. +*(boolean)*: Returns `true` if `object` is a match, else `false`. #### Example ```js @@ -4832,19 +5207,22 @@ _.isMatchWith(object, source, customizer); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10248 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10811 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") Checks if `value` is `NaN`.

-**Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4) -which returns `true` for `undefined` and other non-numeric values. +**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. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is `NaN`, else `false`. +*(boolean)*: Returns `true` if `value` is `NaN`, else `false`. #### Example ```js @@ -4867,15 +5245,17 @@ _.isNaN(undefined); ### `_.isNative(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10270 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10836 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") Checks if `value` is a native function. +#### Since +3.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is a native function, else `false`. +*(boolean)*: Returns `true` if `value` is a native function, else `false`. #### Example ```js @@ -4892,15 +5272,17 @@ _.isNative(_); ### `_.isNil(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10320 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnil "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10888 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnil "See the npm package") Checks if `value` is `null` or `undefined`. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is nullish, else `false`. +*(boolean)*: Returns `true` if `value` is nullish, else `false`. #### Example ```js @@ -4920,15 +5302,17 @@ _.isNil(NaN); ### `_.isNull(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10297 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10864 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") Checks if `value` is `null`. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is `null`, else `false`. +*(boolean)*: Returns `true` if `value` is `null`, else `false`. #### Example ```js @@ -4945,19 +5329,21 @@ _.isNull(void 0); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10349 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnumber "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10919 "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.

-**Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified -as numbers, use the `_.isFinite` method. +**Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are +classified as numbers, use the `_.isFinite` method. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -4980,16 +5366,18 @@ _.isNumber('3'); ### `_.isObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10108 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10664 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the npm package") 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('')`) +*(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is an object, else `false`. +*(boolean)*: Returns `true` if `value` is an object, else `false`. #### Example ```js @@ -5012,16 +5400,18 @@ _.isObject(null); ### `_.isObjectLike(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10136 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobjectlike "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10693 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobjectlike "See the npm package") Checks if `value` is object-like. A value is object-like if it's not `null` and has a `typeof` result of "object". +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is object-like, else `false`. +*(boolean)*: Returns `true` if `value` is object-like, else `false`. #### Example ```js @@ -5044,16 +5434,18 @@ _.isObjectLike(null); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10381 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10953 "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`. +#### Since +0.8.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is a plain object, else `false`. +*(boolean)*: Returns `true` if `value` is a plain object, else `false`. #### Example ```js @@ -5080,15 +5472,17 @@ _.isPlainObject(Object.create(null)); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10411 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L10985 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") Checks if `value` is classified as a `RegExp` object. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -5105,19 +5499,22 @@ _.isRegExp('/abc/'); ### `_.isSafeInteger(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10440 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.issafeinteger "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11017 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.issafeinteger "See the npm package") Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 double precision number which isn't the result of a rounded unsafe integer.

-**Note:** This method is based on [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). +**Note:** This method is based on +[`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is a safe integer, else `false`. +*(boolean)*: Returns `true` if `value` is a safe integer, else `false`. #### Example ```js @@ -5140,15 +5537,17 @@ _.isSafeInteger('3'); ### `_.isSet(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10460 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isset "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11039 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isset "See the npm package") Checks if `value` is classified as a `Set` object. +#### Since +4.3.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -5165,15 +5564,17 @@ _.isSet(new WeakSet); ### `_.isString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10480 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isstring "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11061 "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. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -5190,15 +5591,17 @@ _.isString(1); ### `_.isSymbol(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10501 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.issymbol "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11084 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.issymbol "See the npm package") Checks if `value` is classified as a `Symbol` primitive or object. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -5215,15 +5618,17 @@ _.isSymbol('abc'); ### `_.isTypedArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10522 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11107 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") Checks if `value` is classified as a typed array. +#### Since +3.0.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -5240,15 +5645,17 @@ _.isTypedArray([]); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10543 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11129 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") Checks if `value` is `undefined`. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is `undefined`, else `false`. +*(boolean)*: Returns `true` if `value` is `undefined`, else `false`. #### Example ```js @@ -5265,15 +5672,17 @@ _.isUndefined(null); ### `_.isWeakMap(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10563 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isweakmap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11151 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isweakmap "See the npm package") Checks if `value` is classified as a `WeakMap` object. +#### Since +4.3.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -5290,15 +5699,17 @@ _.isWeakMap(new Map); ### `_.isWeakSet(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10583 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isweakset "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11173 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isweakset "See the npm package") Checks if `value` is classified as a `WeakSet` object. +#### Since +4.3.0 #### Arguments 1. `value` *(*)*: The value to check. #### Returns -*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. #### Example ```js @@ -5315,16 +5726,18 @@ _.isWeakSet(new Set); ### `_.lt(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10607 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lt "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11199 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lt "See the npm package") Checks if `value` is less than `other`. +#### Since +3.9.0 #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. #### Returns -*(boolean)*: Returns `true` if `value` is less than `other`, else `false`. +*(boolean)*: Returns `true` if `value` is less than `other`, else `false`. #### Example ```js @@ -5344,16 +5757,18 @@ _.lt(3, 1); ### `_.lte(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10631 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lte "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11225 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lte "See the npm package") Checks if `value` is less than or equal to `other`. +#### Since +3.9.0 #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. #### Returns -*(boolean)*: Returns `true` if `value` is less than or equal to `other`, else `false`. +*(boolean)*: Returns `true` if `value` is less than or equal to `other`, else `false`. #### Example ```js @@ -5373,15 +5788,17 @@ _.lte(3, 1); ### `_.toArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10657 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11252 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") Converts `value` to an array. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to convert. #### Returns -*(Array)*: Returns the converted array. +*(Array)*: Returns the converted array. #### Example ```js @@ -5404,18 +5821,21 @@ _.toArray(null); ### `_.toInteger(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10697 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tointeger "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11294 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tointeger "See the npm package") Converts `value` to an integer.

-**Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). +**Note:** This function is loosely based on +[`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to convert. #### Returns -*(number)*: Returns the converted integer. +*(number)*: Returns the converted integer. #### Example ```js @@ -5438,19 +5858,22 @@ _.toInteger('3'); ### `_.toLength(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10735 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tolength "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11334 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tolength "See the npm package") Converts `value` to an integer suitable for use as the length of an array-like object.

-**Note:** This method is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). +**Note:** This method is based on +[`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to convert. #### Returns -*(number)*: Returns the converted integer. +*(number)*: Returns the converted integer. #### Example ```js @@ -5473,15 +5896,17 @@ _.toLength('3'); ### `_.toNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10761 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tonumber "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11361 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tonumber "See the npm package") Converts `value` to a number. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to process. #### Returns -*(number)*: Returns the number. +*(number)*: Returns the number. #### Example ```js @@ -5504,16 +5929,18 @@ _.toNumber('3'); ### `_.toPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10799 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11406 "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. +Converts `value` to a plain object flattening inherited enumerable string +keyed properties of `value` to own properties of the plain object. +#### Since +3.0.0 #### Arguments 1. `value` *(*)*: The value to convert. #### Returns -*(Object)*: Returns the converted plain object. +*(Object)*: Returns the converted plain object. #### Example ```js @@ -5536,16 +5963,18 @@ _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); ### `_.toSafeInteger(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10826 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tosafeinteger "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11434 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tosafeinteger "See the npm package") Converts `value` to a safe integer. A safe integer can be compared and represented correctly. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to convert. #### Returns -*(number)*: Returns the converted integer. +*(number)*: Returns the converted integer. #### Example ```js @@ -5568,16 +5997,18 @@ _.toSafeInteger('3'); ### `_.toString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10850 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tostring "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11459 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tostring "See the npm package") Converts `value` to a string if it's not one. An empty string is returned for `null` and `undefined` values. The sign of `-0` is preserved. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to process. #### Returns -*(string)*: Returns the string. +*(string)*: Returns the string. #### Example ```js @@ -5603,16 +6034,18 @@ _.toString([1, 2, 3]); ### `_.add(augend, addend)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14190 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14951 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm package") Adds two numbers. +#### Since +3.4.0 #### Arguments 1. `augend` *(number)*: The first number in an addition. 2. `addend` *(number)*: The second number in an addition. #### Returns -*(number)*: Returns the total. +*(number)*: Returns the total. #### Example ```js @@ -5626,16 +6059,18 @@ _.add(6, 4); ### `_.ceil(number, [precision=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14224 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ceil "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14976 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ceil "See the npm package") Computes `number` rounded up to `precision`. +#### Since +3.10.0 #### Arguments 1. `number` *(number)*: The number to round up. 2. `[precision=0]` *(number)*: The precision to round up to. #### Returns -*(number)*: Returns the rounded up number. +*(number)*: Returns the rounded up number. #### Example ```js @@ -5654,17 +6089,44 @@ _.ceil(6040, -2); +### `_.divide(dividend, divisor)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14993 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.divide "See the npm package") + +Divide two numbers. + +#### Since +4.7.0 +#### Arguments +1. `dividend` *(number)*: The first number in a division. +2. `divisor` *(number)*: The second number in a division. + +#### Returns +*(number)*: Returns the quotient. + +#### Example +```js +_.divide(6, 4); +// => 1.5 +``` +* * * + + + + + ### `_.floor(number, [precision=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14246 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.floor "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15018 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.floor "See the npm package") Computes `number` rounded down to `precision`. +#### Since +3.10.0 #### Arguments 1. `number` *(number)*: The number to round down. 2. `[precision=0]` *(number)*: The precision to round down to. #### Returns -*(number)*: Returns the rounded down number. +*(number)*: Returns the rounded down number. #### Example ```js @@ -5684,16 +6146,18 @@ _.floor(4060, -2); ### `_.max(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14265 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15038 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm package") Computes the maximum value of `array`. If `array` is empty or falsey `undefined` is returned. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to iterate over. #### Returns -*(*)*: Returns the maximum value. +*(*)*: Returns the maximum value. #### Example ```js @@ -5710,18 +6174,20 @@ _.max([]); ### `_.maxBy(array, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14293 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.maxby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15068 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.maxby "See the npm package") This method is like `_.max` except that it accepts `iteratee` which is invoked for each element in `array` to generate the criterion by which -the value is ranked. The iteratee is invoked with one argument: (value). +the value is ranked. The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(*)*: Returns the maximum value. +*(*)*: Returns the maximum value. #### Example ```js @@ -5741,15 +6207,17 @@ _.maxBy(objects, 'n'); ### `_.mean(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14312 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mean "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15088 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mean "See the npm package") Computes the mean of the values in `array`. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to iterate over. #### Returns -*(number)*: Returns the mean. +*(number)*: Returns the mean. #### Example ```js @@ -5762,17 +6230,52 @@ _.mean([4, 2, 8, 6]); +### `_.meanBy(array, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15116 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.meanby "See the npm package") + +This method is like `_.mean` except that it accepts `iteratee` which is +invoked for each element in `array` to generate the value to be averaged. +The iteratee is invoked with one argument: *(value)*. + +#### Since +4.7.0 +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. + +#### Returns +*(number)*: Returns the mean. + +#### Example +```js +var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; + +_.meanBy(objects, function(o) { return o.n; }); +// => 5 + +// The `_.property` iteratee shorthand. +_.meanBy(objects, 'n'); +// => 5 +``` +* * * + + + + + ### `_.min(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14333 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.min "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15138 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.min "See the npm package") Computes the minimum value of `array`. If `array` is empty or falsey `undefined` is returned. +#### Since +0.1.0 #### Arguments 1. `array` *(Array)*: The array to iterate over. #### Returns -*(*)*: Returns the minimum value. +*(*)*: Returns the minimum value. #### Example ```js @@ -5789,18 +6292,20 @@ _.min([]); ### `_.minBy(array, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14361 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.minby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15168 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.minby "See the npm package") This method is like `_.min` except that it accepts `iteratee` which is invoked for each element in `array` to generate the criterion by which -the value is ranked. The iteratee is invoked with one argument: (value). +the value is ranked. The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(*)*: Returns the minimum value. +*(*)*: Returns the minimum value. #### Example ```js @@ -5819,17 +6324,44 @@ _.minBy(objects, 'n'); +### `_.multiply(multiplier, multiplicand)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15189 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.multiply "See the npm package") + +Multiply two numbers. + +#### Since +4.7.0 +#### Arguments +1. `multiplier` *(number)*: The first number in a multiplication. +2. `multiplicand` *(number)*: The second number in a multiplication. + +#### Returns +*(number)*: Returns the product. + +#### Example +```js +_.multiply(6, 4); +// => 24 +``` +* * * + + + + + ### `_.round(number, [precision=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14387 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.round "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15214 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.round "See the npm package") Computes `number` rounded to `precision`. +#### Since +3.10.0 #### Arguments 1. `number` *(number)*: The number to round. 2. `[precision=0]` *(number)*: The precision to round to. #### Returns -*(number)*: Returns the rounded number. +*(number)*: Returns the rounded number. #### Example ```js @@ -5849,16 +6381,18 @@ _.round(4060, -2); ### `_.subtract(minuend, subtrahend)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14403 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.subtract "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15231 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.subtract "See the npm package") Subtract two numbers. +#### Since +4.0.0 #### Arguments 1. `minuend` *(number)*: The first number in a subtraction. 2. `subtrahend` *(number)*: The second number in a subtraction. #### Returns -*(number)*: Returns the difference. +*(number)*: Returns the difference. #### Example ```js @@ -5872,15 +6406,17 @@ _.subtract(6, 4); ### `_.sum(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14430 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sum "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15249 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sum "See the npm package") Computes the sum of the values in `array`. +#### Since +3.4.0 #### Arguments 1. `array` *(Array)*: The array to iterate over. #### Returns -*(number)*: Returns the sum. +*(number)*: Returns the sum. #### Example ```js @@ -5894,18 +6430,20 @@ _.sum([4, 2, 8, 6]); ### `_.sumBy(array, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14458 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sumby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15279 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sumby "See the npm package") This method is like `_.sum` except that it accepts `iteratee` which is invoked for each element in `array` to generate the value to be summed. -The iteratee is invoked with one argument: (value). +The iteratee is invoked with one argument: *(value)*. +#### Since +4.0.0 #### Arguments 1. `array` *(Array)*: The array to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(number)*: Returns the sum. +*(number)*: Returns the sum. #### Example ```js @@ -5931,17 +6469,19 @@ _.sumBy(objects, 'n'); ### `_.clamp(number, [lower], upper)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12208 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clamp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12884 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clamp "See the npm package") Clamps `number` within the inclusive `lower` and `upper` bounds. +#### Since +4.0.0 #### Arguments 1. `number` *(number)*: The number to clamp. 2. `[lower]` *(number)*: The lower bound. 3. `upper` *(number)*: The upper bound. #### Returns -*(number)*: Returns the clamped number. +*(number)*: Returns the clamped number. #### Example ```js @@ -5958,20 +6498,22 @@ _.clamp(10, -5, 5); ### `_.inRange(number, [start=0], end)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12260 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.inrange "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12937 "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's set to `start` with `start` then set to `0`. If `start` is greater than `end` the params are swapped to support negative ranges. +#### Since +3.3.0 #### Arguments 1. `number` *(number)*: The number to check. 2. `[start=0]` *(number)*: The start of the range. 3. `end` *(number)*: The end of the range. #### Returns -*(boolean)*: Returns `true` if `number` is in the range, else `false`. +*(boolean)*: Returns `true` if `number` is in the range, else `false`. #### Example ```js @@ -6003,24 +6545,26 @@ _.inRange(-3, -2, -6); ### `_.random([lower=0], [upper=1], [floating])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12302 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12980 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") Produces a random number between the inclusive `lower` and `upper` bounds. If only one argument is provided a number between `0` and the given number -is returned. If `floating` is `true`, or either `lower` or `upper` are floats, -a floating-point number is returned instead of an integer. +is returned. If `floating` is `true`, or either `lower` or `upper` are +floats, a floating-point number is returned instead of an integer.

**Note:** JavaScript follows the IEEE-754 standard for resolving floating-point values which can produce unexpected results. +#### Since +0.7.0 #### Arguments 1. `[lower=0]` *(number)*: The lower bound. 2. `[upper=1]` *(number)*: The upper bound. 3. `[floating]` *(boolean)*: Specify returning a floating-point number. #### Returns -*(number)*: Returns the random number. +*(number)*: Returns the random number. #### Example ```js @@ -6049,22 +6593,24 @@ _.random(1.2, 5.2); ### `_.assign(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10897 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11507 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") -Assigns own enumerable properties of source objects to the destination -object. Source objects are applied from left to right. Subsequent sources -overwrite property assignments of previous sources. +Assigns own enumerable string keyed properties of source objects to the +destination object. Source objects are applied from left to right. +Subsequent sources overwrite property assignments of previous sources.

**Note:** This method mutates `object` and is loosely based on [`Object.assign`](https://mdn.io/Object/assign). +#### Since +0.10.0 #### Arguments 1. `object` *(Object)*: The destination object. 2. `[sources]` *(...Object)*: The source objects. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6089,7 +6635,7 @@ _.assign({ 'a': 1 }, new Foo, new Bar); ### `_.assignIn(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10938 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assignin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11549 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assignin "See the npm package") This method is like `_.assign` except that it iterates over own and inherited source properties. @@ -6097,6 +6643,8 @@ inherited source properties.
**Note:** This method mutates `object`. +#### Since +4.0.0 #### Aliases *_.extend* @@ -6105,7 +6653,7 @@ inherited source properties. 2. `[sources]` *(...Object)*: The source objects. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6130,16 +6678,18 @@ _.assignIn({ 'a': 1 }, new Foo, new Bar); ### `_.assignInWith(object, sources, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L10975 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assigninwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11587 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assigninwith "See the npm package") -This method is like `_.assignIn` except that it accepts `customizer` which -is invoked to produce the assigned values. If `customizer` returns `undefined` -assignment is handled by the method instead. The `customizer` is invoked -with five arguments: (objValue, srcValue, key, object, source). +This method is like `_.assignIn` except that it accepts `customizer` +which is invoked to produce the assigned values. If `customizer` returns +`undefined` assignment is handled by the method instead. The `customizer` +is invoked with five arguments: *(objValue, srcValue, key, object, source)*.

**Note:** This method mutates `object`. +#### Since +4.0.0 #### Aliases *_.extendWith* @@ -6149,7 +6699,7 @@ with five arguments: (objValue, srcValue, key, object, source). 3. `[customizer]` *(Function)*: The function to customize assigned values. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6169,23 +6719,25 @@ defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); ### `_.assignWith(object, sources, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11005 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assignwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11618 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assignwith "See the npm package") -This method is like `_.assign` except that it accepts `customizer` which -is invoked to produce the assigned values. If `customizer` returns `undefined` -assignment is handled by the method instead. The `customizer` is invoked -with five arguments: (objValue, srcValue, key, object, source). +This method is like `_.assign` except that it accepts `customizer` +which is invoked to produce the assigned values. If `customizer` returns +`undefined` assignment is handled by the method instead. The `customizer` +is invoked with five arguments: *(objValue, srcValue, key, object, source)*.

**Note:** This method mutates `object`. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The destination object. 2. `sources` *(...Object)*: The source objects. 3. `[customizer]` *(Function)*: The function to customize assigned values. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6205,16 +6757,18 @@ defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); ### `_.at(object, [paths])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11029 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.at "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11643 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.at "See the npm package") Creates an array of values corresponding to `paths` of `object`. +#### Since +1.0.0 #### Arguments 1. `object` *(Object)*: The object to iterate over. -2. `[paths]` *(...(string|string[])*: The property paths of elements to pick, specified individually or in arrays. +2. `[paths]` *(...(string|string[]))*: The property paths of elements to pick, specified individually or in arrays. #### Returns -*(Array)*: Returns the new array of picked elements. +*(Array)*: Returns the new array of picked elements. #### Example ```js @@ -6233,17 +6787,20 @@ _.at(['a', 'b', 'c'], 0, 2); ### `_.create(prototype, [properties])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11065 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11681 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") -Creates an object that inherits from the `prototype` object. If a `properties` -object is given its own enumerable properties are assigned to the created object. +Creates an object that inherits from the `prototype` object. If a +`properties` object is given its own enumerable string keyed properties +are assigned to the created object. +#### Since +2.3.0 #### Arguments 1. `prototype` *(Object)*: The object to inherit from. 2. `[properties]` *(Object)*: The properties to assign to the object. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -6274,22 +6831,24 @@ circle instanceof Shape; ### `_.defaults(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11089 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11706 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") -Assigns own and inherited enumerable properties of source objects to the -destination object for all destination properties that resolve to `undefined`. -Source objects are applied from left to right. Once a property is set, -additional values of the same property are ignored. +Assigns own and inherited enumerable string keyed properties of source +objects to the destination object for all destination properties that +resolve to `undefined`. Source objects are applied from left to right. +Once a property is set, additional values of the same property are ignored.

**Note:** This method mutates `object`. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The destination object. 2. `[sources]` *(...Object)*: The source objects. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6303,7 +6862,7 @@ _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.defaultsDeep(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11112 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaultsdeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11730 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaultsdeep "See the npm package") This method is like `_.defaults` except that it recursively assigns default properties. @@ -6311,12 +6870,14 @@ default properties.
**Note:** This method mutates `object`. +#### Since +3.10.0 #### Arguments 1. `object` *(Object)*: The destination object. 2. `[sources]` *(...Object)*: The source objects. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6330,17 +6891,19 @@ _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'ag ### `_.findKey(object, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11150 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11771 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findkey "See the npm package") This method is like `_.find` except that it returns the key of the first element `predicate` returns truthy for instead of the element itself. +#### Since +1.1.0 #### Arguments 1. `object` *(Object)*: The object to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(string|undefined)*: Returns the key of the matched element, else `undefined`. +*(*)*: Returns the key of the matched element, else `undefined`. #### Example ```js @@ -6372,17 +6935,19 @@ _.findKey(users, 'active'); ### `_.findLastKey(object, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11187 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11811 "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. +#### Since +2.0.0 #### Arguments 1. `object` *(Object)*: The object to search. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(string|undefined)*: Returns the key of the matched element, else `undefined`. +*(*)*: Returns the key of the matched element, else `undefined`. #### Example ```js @@ -6414,19 +6979,21 @@ _.findLastKey(users, 'active'); ### `_.forIn(object, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11217 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11842 "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 invoked with three arguments:
-(value, key, object). Iteratee functions may exit iteration early by explicitly -returning `false`. +Iterates over own and inherited enumerable string keyed properties of an +object invoking `iteratee` for each property. The iteratee is invoked with +three arguments: *(value, key, object)*. Iteratee functions may exit iteration +early by explicitly returning `false`. +#### Since +0.3.0 #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6440,7 +7007,7 @@ Foo.prototype.c = 3; _.forIn(new Foo, function(value, key) { console.log(key); }); -// => logs 'a', 'b', then 'c' (iteration order is not guaranteed) +// => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). ``` * * * @@ -6449,17 +7016,19 @@ _.forIn(new Foo, function(value, key) { ### `_.forInRight(object, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11247 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forinright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11873 "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. +#### Since +2.0.0 #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6473,7 +7042,7 @@ Foo.prototype.c = 3; _.forInRight(new Foo, function(value, key) { console.log(key); }); -// => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c' +// => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. ``` * * * @@ -6482,19 +7051,21 @@ _.forInRight(new Foo, function(value, key) { ### `_.forOwn(object, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11279 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forown "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11906 "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 invoked with three arguments:
-(value, key, object). Iteratee functions may exit iteration early by +Iterates over own enumerable string keyed properties of an object invoking +`iteratee` for each property. The iteratee is invoked with three arguments:
+*(value, key, object)*. Iteratee functions may exit iteration early by explicitly returning `false`. +#### Since +0.3.0 #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6508,7 +7079,7 @@ Foo.prototype.c = 3; _.forOwn(new Foo, function(value, key) { console.log(key); }); -// => logs 'a' then 'b' (iteration order is not guaranteed) +// => Logs 'a' then 'b' (iteration order is not guaranteed). ``` * * * @@ -6517,17 +7088,19 @@ _.forOwn(new Foo, function(value, key) { ### `_.forOwnRight(object, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11307 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forownright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11935 "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. +#### Since +2.0.0 #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6541,7 +7114,7 @@ Foo.prototype.c = 3; _.forOwnRight(new Foo, function(value, key) { console.log(key); }); -// => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b' +// => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. ``` * * * @@ -6550,16 +7123,18 @@ _.forOwnRight(new Foo, function(value, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11332 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11961 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") Creates an array of function property names from own enumerable properties of `object`. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The object to inspect. #### Returns -*(Array)*: Returns the new array of property names. +*(Array)*: Returns the new array of property names. #### Example ```js @@ -6580,16 +7155,18 @@ _.functions(new Foo); ### `_.functionsIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11357 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functionsin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L11987 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functionsin "See the npm package") Creates an array of function property names from own and inherited enumerable properties of `object`. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The object to inspect. #### Returns -*(Array)*: Returns the new array of property names. +*(Array)*: Returns the new array of property names. #### Example ```js @@ -6610,18 +7187,20 @@ _.functionsIn(new Foo); ### `_.get(object, path, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11385 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.get "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12016 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.get "See the npm package") Gets the value at `path` of `object`. If the resolved value is `undefined` the `defaultValue` is used in its place. +#### Since +3.7.0 #### Arguments 1. `object` *(Object)*: The object to query. 2. `path` *(Array|string)*: The path of the property to get. -3. `[defaultValue]` *(*)*: The value returned if the resolved value is `undefined`. +3. `[defaultValue]` *(*)*: The value returned for `undefined` resolved values. #### Returns -*(*)*: Returns the resolved value. +*(*)*: Returns the resolved value. #### Example ```js @@ -6643,16 +7222,18 @@ _.get(object, 'a.b.c', 'default'); ### `_.has(object, path)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11416 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12048 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") Checks if `path` is a direct property of `object`. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The object to query. 2. `path` *(Array|string)*: The path to check. #### Returns -*(boolean)*: Returns `true` if `path` exists, else `false`. +*(boolean)*: Returns `true` if `path` exists, else `false`. #### Example ```js @@ -6678,16 +7259,18 @@ _.has(other, 'a'); ### `_.hasIn(object, path)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11445 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.hasin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12078 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.hasin "See the npm package") Checks if `path` is a direct or inherited property of `object`. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The object to query. 2. `path` *(Array|string)*: The path to check. #### Returns -*(boolean)*: Returns `true` if `path` exists, else `false`. +*(boolean)*: Returns `true` if `path` exists, else `false`. #### Example ```js @@ -6712,17 +7295,19 @@ _.hasIn(object, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11466 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invert "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12100 "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 -assignments of previous values. +If `object` contains duplicate values, subsequent values overwrite +property assignments of previous values. +#### Since +0.7.0 #### Arguments 1. `object` *(Object)*: The object to invert. #### Returns -*(Object)*: Returns the new inverted object. +*(Object)*: Returns the new inverted object. #### Example ```js @@ -6738,20 +7323,22 @@ _.invert(object); ### `_.invertBy(object, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11495 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invertby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12131 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invertby "See the npm package") This method is like `_.invert` except that the inverted object is generated from the results of running each element of `object` through `iteratee`. The corresponding inverted value of each inverted key is an array of keys responsible for generating the inverted value. The iteratee is invoked -with one argument: (value). +with one argument: *(value)*. +#### Since +4.1.0 #### Arguments 1. `object` *(Object)*: The object to invert. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Object)*: Returns the new inverted object. +*(Object)*: Returns the new inverted object. #### Example ```js @@ -6772,17 +7359,19 @@ _.invertBy(object, function(value) { ### `_.invoke(object, path, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11520 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12157 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "See the npm package") Invokes the method at `path` of `object`. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The object to query. 2. `path` *(Array|string)*: The path of the method to invoke. 3. `[args]` *(...*)*: The arguments to invoke the method with. #### Returns -*(*)*: Returns the result of the invoked method. +*(*)*: Returns the result of the invoked method. #### Example ```js @@ -6798,7 +7387,7 @@ _.invoke(object, 'a[0].b.c.slice', 1, 3); ### `_.keys(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11549 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keys "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12187 "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`.
@@ -6807,11 +7396,13 @@ Creates an array of the own enumerable property names of `object`. [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) for more details. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The object to query. #### Returns -*(Array)*: Returns the array of property names. +*(Array)*: Returns the array of property names. #### Example ```js @@ -6835,18 +7426,20 @@ _.keys('hi'); ### `_.keysIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11591 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keysin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12230 "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`.

**Note:** Non-object values are coerced to objects. +#### Since +3.0.0 #### Arguments 1. `object` *(Object)*: The object to query. #### Returns -*(Array)*: Returns the array of property names. +*(Array)*: Returns the array of property names. #### Example ```js @@ -6867,19 +7460,21 @@ _.keysIn(new Foo); ### `_.mapKeys(object, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11630 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapkeys "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12271 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapkeys "See the npm package") The opposite of `_.mapValues`; this method creates an object with the same values as `object` and keys generated by running each own enumerable -property of `object` through `iteratee`. The iteratee is invoked with -three arguments: (value, key, object). +string keyed property of `object` through `iteratee`. The iteratee is +invoked with three arguments: *(value, key, object)*. +#### Since +3.8.0 #### Arguments 1. `object` *(Object)*: The object to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Object)*: Returns the new mapped object. +*(Object)*: Returns the new mapped object. #### Example ```js @@ -6895,18 +7490,21 @@ _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { ### `_.mapValues(object, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11665 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapvalues "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12309 "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 is invoked with three arguments: (value, key, object). +running each own enumerable string keyed property of `object` through +`iteratee`. The iteratee is invoked with three arguments:
+*(value, key, object)*. +#### Since +2.4.0 #### Arguments 1. `object` *(Object)*: The object to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. +2. `[iteratee=_.identity]` *(Array|Function|Object|string)*: The function invoked per iteration. #### Returns -*(Object)*: Returns the new mapped object. +*(Object)*: Returns the new mapped object. #### Example ```js @@ -6929,25 +7527,27 @@ _.mapValues(users, 'age'); ### `_.merge(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11705 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12350 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") This method is like `_.assign` except that it recursively merges own and -inherited enumerable properties of source objects into the destination -object. Source properties that resolve to `undefined` are skipped if a -destination value exists. Array and plain object properties are merged -recursively.Other objects and value types are overridden by assignment. -Source objects are applied from left to right. Subsequent sources -overwrite property assignments of previous sources. +inherited enumerable string keyed properties of source objects into the +destination object. Source properties that resolve to `undefined` are +skipped if a destination value exists. Array and plain object properties +are merged recursively.Other objects and value types are overridden by +assignment. Source objects are applied from left to right. Subsequent +sources overwrite property assignments of previous sources.

**Note:** This method mutates `object`. +#### Since +0.5.0 #### Arguments 1. `object` *(Object)*: The destination object. 2. `[sources]` *(...Object)*: The source objects. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -6969,24 +7569,26 @@ _.merge(users, ages); ### `_.mergeWith(object, sources, customizer)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11746 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mergewith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12392 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mergewith "See the npm package") This method is like `_.merge` except that it accepts `customizer` which 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 invoked with seven arguments:
-(objValue, srcValue, key, object, source, stack). +*(objValue, srcValue, key, object, source, stack)*.

**Note:** This method mutates `object`. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The destination object. 2. `sources` *(...Object)*: The source objects. 3. `customizer` *(Function)*: The function to customize assigned values. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -7016,17 +7618,20 @@ _.mergeWith(object, other, customizer); ### `_.omit(object, [props])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11768 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omit "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12416 "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. +own and inherited enumerable string keyed properties of `object` that are +not omitted. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The source object. -2. `[props]` *(...(string|string[])*: The property names to omit, specified individually or in arrays. +2. `[props]` *(...(string|string[]))*: The property identifiers to omit, specified individually or in arrays. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -7042,19 +7647,21 @@ _.omit(object, ['a', 'c']); ### `_.omitBy(object, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11795 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omitby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12445 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omitby "See the npm package") The opposite of `_.pickBy`; this method creates an object composed of -the own and inherited enumerable properties of `object` that `predicate` -doesn't return truthy for. The predicate is invoked with two arguments:
-(value, key). +the own and inherited enumerable string keyed properties of `object` that +`predicate` doesn't return truthy for. The predicate is invoked with two +arguments: *(value, key)*. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The source object. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per property. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per property. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -7070,16 +7677,18 @@ _.omitBy(object, _.isNumber); ### `_.pick(object, [props])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11819 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12470 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") Creates an object composed of the picked `object` properties. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The source object. -2. `[props]` *(...(string|string[])*: The property names to pick, specified individually or in arrays. +2. `[props]` *(...(string|string[]))*: The property identifiers to pick, specified individually or in arrays. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -7095,17 +7704,19 @@ _.pick(object, ['a', 'c']); ### `_.pickBy(object, [predicate=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11840 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pickby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12493 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pickby "See the npm package") Creates an object composed of the `object` properties `predicate` returns -truthy for. The predicate is invoked with two arguments: (value, key). +truthy for. The predicate is invoked with two arguments: *(value, key)*. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The source object. -2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per property. +2. `[predicate=_.identity]` *(Array|Function|Object|string)*: The function invoked per property. #### Returns -*(Object)*: Returns the new object. +*(Object)*: Returns the new object. #### Example ```js @@ -7121,19 +7732,21 @@ _.pickBy(object, _.isNumber); ### `_.result(object, path, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11872 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.result "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12526 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.result "See the npm package") -This method is like `_.get` except that if the resolved value is a function -it's invoked with the `this` binding of its parent object and its result -is returned. +This method is like `_.get` except that if the resolved value is a +function it's invoked with the `this` binding of its parent object and +its result is returned. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The object to query. 2. `path` *(Array|string)*: The path of the property to resolve. -3. `[defaultValue]` *(*)*: The value returned if the resolved value is `undefined`. +3. `[defaultValue]` *(*)*: The value returned for `undefined` resolved values. #### Returns -*(*)*: Returns the resolved value. +*(*)*: Returns the resolved value. #### Example ```js @@ -7158,7 +7771,7 @@ _.result(object, 'a[0].b.c3', _.constant('default')); ### `_.set(object, path, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11913 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.set "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12576 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.set "See the npm package") Sets the value at `path` of `object`. If a portion of `path` doesn't exist it's created. Arrays are created for missing index properties while objects @@ -7168,13 +7781,15 @@ are created for all other missing properties. Use `_.setWith` to customize
**Note:** This method mutates `object`. +#### Since +3.7.0 #### Arguments 1. `object` *(Object)*: The object to modify. 2. `path` *(Array|string)*: The path of the property to set. 3. `value` *(*)*: The value to set. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -7195,16 +7810,18 @@ console.log(object.x[0].y.z); ### `_.setWith(object, path, value, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11940 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.setwith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12604 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.setwith "See the npm package") This method is like `_.set` except that it accepts `customizer` which is invoked to produce the objects of `path`. If `customizer` returns `undefined` path creation is handled by the method instead. The `customizer` is invoked -with three arguments: (nsValue, key, nsObject). +with three arguments: *(nsValue, key, nsObject)*.

**Note:** This method mutates `object`. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The object to modify. 2. `path` *(Array|string)*: The path of the property to set. @@ -7212,7 +7829,7 @@ with three arguments: (nsValue, key, nsObject). 4. `[customizer]` *(Function)*: The function to customize assigned values. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -7228,16 +7845,21 @@ _.setWith(object, '[0][1]', 'a', Object); ### `_.toPairs(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11966 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.topairs "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12632 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.topairs "See the npm package") -Creates an array of own enumerable key-value pairs for `object` which -can be consumed by `_.fromPairs`. +Creates an array of own enumerable string keyed-value pairs for `object` +which can be consumed by `_.fromPairs`. + +#### Since +4.0.0 +#### Aliases +*_.entries* #### Arguments 1. `object` *(Object)*: The object to query. #### Returns -*(Array)*: Returns the new array of key-value pairs. +*(Array)*: Returns the new array of key-value pairs. #### Example ```js @@ -7258,16 +7880,21 @@ _.toPairs(new Foo); ### `_.toPairsIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L11991 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.topairsin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12659 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.topairsin "See the npm package") -Creates an array of own and inherited enumerable key-value pairs for -`object` which can be consumed by `_.fromPairs`. +Creates an array of own and inherited enumerable string keyed-value pairs +for `object` which can be consumed by `_.fromPairs`. + +#### Since +4.0.0 +#### Aliases +*_.entriesIn* #### Arguments 1. `object` *(Object)*: The object to query. #### Returns -*(Array)*: Returns the new array of key-value pairs. +*(Array)*: Returns the new array of key-value pairs. #### Example ```js @@ -7288,22 +7915,24 @@ _.toPairsIn(new Foo); ### `_.transform(object, [iteratee=_.identity], [accumulator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12023 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.transform "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12692 "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 invoked with four arguments:
-(accumulator, value, key, object). Iteratee functions may exit iteration +string keyed properties through `iteratee`, with each invocation potentially +mutating the `accumulator` object. The iteratee is invoked with four arguments:
+*(accumulator, value, key, object)*. Iteratee functions may exit iteration early by explicitly returning `false`. +#### Since +1.3.0 #### Arguments 1. `object` *(Array|Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. 3. `[accumulator]` *(*)*: The custom accumulator value. #### Returns -*(*)*: Returns the accumulated value. +*(*)*: Returns the accumulated value. #### Example ```js @@ -7325,19 +7954,21 @@ _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { ### `_.unset(object, path)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12071 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unset "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12741 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unset "See the npm package") Removes the property at `path` of `object`.

**Note:** This method mutates `object`. +#### Since +4.0.0 #### Arguments 1. `object` *(Object)*: The object to modify. 2. `path` *(Array|string)*: The path of the property to unset. #### Returns -*(boolean)*: Returns `true` if the property is deleted, else `false`. +*(boolean)*: Returns `true` if the property is deleted, else `false`. #### Example ```js @@ -7361,22 +7992,24 @@ console.log(object); ### `_.update(object, path, updater)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12101 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.update "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12772 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.update "See the npm package") This method is like `_.set` except that accepts `updater` to produce the value to set. Use `_.updateWith` to customize `path` creation. The `updater` -is invoked with one argument: (value). +is invoked with one argument: *(value)*.

**Note:** This method mutates `object`. +#### Since +4.6.0 #### Arguments 1. `object` *(Object)*: The object to modify. 2. `path` *(Array|string)*: The path of the property to set. 3. `updater` *(Function)*: The function to produce the updated value. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -7397,16 +8030,18 @@ console.log(object.x[0].y.z); ### `_.updateWith(object, path, updater, [customizer])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12128 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.updatewith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12800 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.updatewith "See the npm package") This method is like `_.update` except that it accepts `customizer` which is invoked to produce the objects of `path`. If `customizer` returns `undefined` path creation is handled by the method instead. The `customizer` is invoked -with three arguments: (nsValue, key, nsObject). +with three arguments: *(nsValue, key, nsObject)*.

**Note:** This method mutates `object`. +#### Since +4.6.0 #### Arguments 1. `object` *(Object)*: The object to modify. 2. `path` *(Array|string)*: The path of the property to set. @@ -7414,7 +8049,7 @@ with three arguments: (nsValue, key, nsObject). 4. `[customizer]` *(Function)*: The function to customize assigned values. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -7430,18 +8065,20 @@ _.updateWith(object, '[0][1]', _.constant('a'), Object); ### `_.values(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12158 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.values "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12831 "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`. +Creates an array of the own enumerable string keyed property values of `object`.

**Note:** Non-object values are coerced to objects. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The object to query. #### Returns -*(Array)*: Returns the array of property values. +*(Array)*: Returns the array of property values. #### Example ```js @@ -7465,18 +8102,21 @@ _.values('hi'); ### `_.valuesIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12184 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.valuesin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L12859 "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`. +Creates an array of the own and inherited enumerable string keyed property +values of `object`.

**Note:** Non-object values are coerced to objects. +#### Since +3.0.0 #### Arguments 1. `object` *(Object)*: The object to query. #### Returns -*(Array)*: Returns the array of property values. +*(Array)*: Returns the array of property values. #### Example ```js @@ -7503,31 +8143,31 @@ _.valuesIn(new Foo); ### `_(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1527 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1580 "View in source") [Ⓣ][1] Creates a `lodash` object which wraps `value` to enable implicit method -chaining. Methods that operate on and return arrays, collections, and -functions can be chained together. Methods that retrieve a single value or -may return a primitive value will automatically end the chain sequence and -return the unwrapped value. Otherwise, the value must be unwrapped with -`_#value`. +chain sequences. Methods that operate on and return arrays, collections, +and functions can be chained together. Methods that retrieve a single value +or may return a primitive value will automatically end the chain sequence +and return the unwrapped value. Otherwise, the value must be unwrapped +with `_#value`.

-Explicit chaining, which must be unwrapped with `_#value` in all cases, -may be enabled using `_.chain`. +Explicit chain sequences, which must be unwrapped with `_#value`, may be +enabled using `_.chain`.

The execution of chained methods is lazy, that is, it's deferred until `_#value` is implicitly or explicitly called.

-Lazy evaluation allows several methods to support shortcut fusion. Shortcut -fusion is an optimization to merge iteratee calls; this avoids the creation -of intermediate arrays and can greatly reduce the number of iteratee executions. -Sections of a chain sequence qualify for shortcut fusion if the section is -applied to an array of at least two hundred elements and any iteratees -accept only one argument. The heuristic for whether a section qualifies -for shortcut fusion is subject to change. +Lazy evaluation allows several methods to support shortcut fusion. +Shortcut fusion is an optimization to merge iteratee calls; this avoids +the creation of intermediate arrays and can greatly reduce the number of +iteratee executions. Sections of a chain sequence qualify for shortcut +fusion if the section is applied to an array of at least two hundred +elements and any iteratees accept only one argument. The heuristic for +whether a section qualifies for shortcut fusion is subject to change.

Chaining is supported in custom builds as long as the `_#value` method is @@ -7558,55 +8198,56 @@ The chainable wrapper methods are:
`curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, -`flatten`, `flattenDeep`, `flattenDepth`, `flip`, `flow`, `flowRight`, -`fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, `intersection`, -`intersectionBy`, `intersectionWith`, `invert`, `invertBy`, `invokeMap`, -`iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, -`matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, -`methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, -`over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`, -`partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, -`pullAll`, `pullAllBy`, `pullAllWith`, `pullAt`, `push`, `range`, -`rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`, -`set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`, -`tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, -`thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, -`transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, -`uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `update`, `values`, -`valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, -`zipObjectDeep`, and `zipWith` +`flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, +`flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, +`functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, +`intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, +`keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, +`memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, +`nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, +`overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, +`pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, +`pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, +`remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, +`slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, +`takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, +`toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, +`union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, +`unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, +`valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, +`zipObject`, `zipObjectDeep`, and `zipWith`

The wrapper methods that are **not** chainable by default are:
`add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, -`cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `each`, `eachRight`, -`endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, -`findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, `floor`, -`forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, -`get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, `includes`, -`indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, `isArrayBuffer`, -`isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, `isDate`, -`isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`, -`isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, `isMatchWith`, -`isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, -`isPlainObject`, `isRegExp`, `isSafeInteger`, `isSet`, `isString`, -`isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, -`last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, -`maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, -`padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, -`repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, -`snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, -`sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`, -`template`, `times`, `toInteger`, `toJSON`, `toLength`, `toLower`, -`toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`, -`trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`, -`value`, and `words` +`cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`, +`eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, +`findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, +`floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, +`forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, +`includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, +`isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, +`isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, +`isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, +`isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, +`isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, +`isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, +`join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, +`lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`, +`noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`, +`pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, +`runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, +`sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, +`startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toInteger`, +`toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, `toString`, +`toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, +`uniqueId`, `upperCase`, `upperFirst`, `value`, and `words` #### Arguments 1. `value` *(*)*: The value to wrap in a `lodash` instance. #### Returns -*(Object)*: Returns the new `lodash` wrapper instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -7636,16 +8277,19 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7645 "View in source") [Ⓣ][1] -Creates a `lodash` object that wraps `value` with explicit method chaining enabled. -The result of such method chaining must be unwrapped with `_#value`. +Creates a `lodash` wrapper instance that wraps `value` with explicit method +chain sequences enabled. The result of such sequences must be unwrapped +with `_#value`. +#### Since +1.3.0 #### Arguments 1. `value` *(*)*: The value to wrap. #### Returns -*(Object)*: Returns the new `lodash` wrapper instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -7672,18 +8316,20 @@ var youngest = _ ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7674 "View in source") [Ⓣ][1] This method invokes `interceptor` and returns `value`. The interceptor -is invoked with one argument; (value). The purpose of this method is to -"tap into" a method chain in order to modify intermediate results. +is invoked with one argument; *(value)*. The purpose of this method is to +"tap into" a method chain sequence in order to modify intermediate results. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: The value to provide to `interceptor`. 2. `interceptor` *(Function)*: The function to invoke. #### Returns -*(*)*: Returns `value`. +*(*)*: Returns `value`. #### Example ```js @@ -7703,18 +8349,20 @@ _([1, 2, 3]) ### `_.thru(value, interceptor)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7320 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7702 "View in source") [Ⓣ][1] This method is like `_.tap` except that it returns the result of `interceptor`. The purpose of this method is to "pass thru" values replacing intermediate -results in a method chain. +results in a method chain sequence. +#### Since +3.0.0 #### Arguments 1. `value` *(*)*: The value to provide to `interceptor`. 2. `interceptor` *(Function)*: The function to invoke. #### Returns -*(*)*: Returns the result of `interceptor`. +*(*)*: Returns the result of `interceptor`. #### Example ```js @@ -7734,12 +8382,14 @@ _(' abc ') ### `_.prototype[Symbol.iterator]()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7862 "View in source") [Ⓣ][1] Enables the wrapper to be iterable. +#### Since +4.0.0 #### Returns -*(Object)*: Returns the wrapper object. +*(Object)*: Returns the wrapper object. #### Example ```js @@ -7758,15 +8408,17 @@ Array.from(wrapped); ### `_.prototype.at([paths])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7343 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7726 "View in source") [Ⓣ][1] This method is the wrapper version of `_.at`. +#### Since +1.0.0 #### Arguments -1. `[paths]` *(...(string|string[])*: The property paths of elements to pick, specified individually or in arrays. +1. `[paths]` *(...(string|string[]))*: The property paths of elements to pick, specified individually or in arrays. #### Returns -*(Object)*: Returns the new `lodash` wrapper instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -7785,12 +8437,14 @@ _(['a', 'b', 'c']).at(0, 2).value(); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7394 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7778 "View in source") [Ⓣ][1] -Enables explicit method chaining on the wrapper object. +Creates a `lodash` wrapper instance with explicit method chain sequences enabled. +#### Since +0.1.0 #### Returns -*(Object)*: Returns the new `lodash` wrapper instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -7818,12 +8472,14 @@ _(users) ### `_.prototype.commit()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7423 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7808 "View in source") [Ⓣ][1] -Executes the chained sequence and returns the wrapped result. +Executes the chain sequence and returns the wrapped result. +#### Since +3.2.0 #### Returns -*(Object)*: Returns the new `lodash` wrapper instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -7849,40 +8505,16 @@ console.log(array); -### `_.prototype.flatMap([iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7444 "View in source") [Ⓣ][1] - -This method is the wrapper version of `_.flatMap`. - -#### Arguments -1. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. - -#### Returns -*(Object)*: Returns the new `lodash` wrapper instance. - -#### Example -```js -function duplicate(n) { - return [n, n]; -} - -_([1, 2]).flatMap(duplicate).value(); -// => [1, 1, 2, 2] -``` -* * * - - - - - ### `_.prototype.next()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7469 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7834 "View in source") [Ⓣ][1] Gets the next value on a wrapped object following the [iterator protocol](https://mdn.io/iteration_protocols#iterator). +#### Since +4.0.0 #### Returns -*(Object)*: Returns the next iterator value. +*(Object)*: Returns the next iterator value. #### Example ```js @@ -7904,15 +8536,17 @@ wrapped.next(); ### `_.prototype.plant(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7523 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7890 "View in source") [Ⓣ][1] -Creates a clone of the chained sequence planting `value` as the wrapped value. +Creates a clone of the chain sequence planting `value` as the wrapped value. +#### Since +3.2.0 #### Arguments 1. `value` *(*)*: The value to plant. #### Returns -*(Object)*: Returns the new `lodash` wrapper instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -7936,15 +8570,17 @@ wrapped.value(); ### `_.prototype.reverse()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7562 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7930 "View in source") [Ⓣ][1] This method is the wrapper version of `_.reverse`.

**Note:** This method mutates the wrapped array. +#### Since +0.1.0 #### Returns -*(Object)*: Returns the new `lodash` wrapper instance. +*(Object)*: Returns the new `lodash` wrapper instance. #### Example ```js @@ -7963,15 +8599,17 @@ console.log(array); ### `_.prototype.value()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L7593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L7962 "View in source") [Ⓣ][1] -Executes the chained sequence to extract the unwrapped value. +Executes the chain sequence to resolve the unwrapped value. +#### Since +0.1.0 #### Aliases -*_.prototype.toJSON, _.prototype.valueOf* +*_.prototype.toJSON* #### Returns -*(*)*: Returns the resolved unwrapped value. +*(*)*: Returns the resolved unwrapped value. #### Example ```js @@ -7991,25 +8629,27 @@ _([1, 2, 3]).value(); ### `_.camelCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12362 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.camelcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13041 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.camelcase "See the npm package") Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the camel cased string. +*(string)*: Returns the camel cased string. #### Example ```js _.camelCase('Foo Bar'); // => 'fooBar' -_.camelCase('--foo-bar'); +_.camelCase('--foo-bar--'); // => 'fooBar' -_.camelCase('__foo_bar__'); +_.camelCase('__FOO_BAR__'); // => 'fooBar' ``` * * * @@ -8019,16 +8659,18 @@ _.camelCase('__foo_bar__'); ### `_.capitalize([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12381 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13061 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") Converts the first character of `string` to upper case and the remaining to lower case. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to capitalize. #### Returns -*(string)*: Returns the capitalized string. +*(string)*: Returns the capitalized string. #### Example ```js @@ -8042,16 +8684,20 @@ _.capitalize('FRED'); ### `_.deburr([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12399 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.deburr "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13082 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.deburr "See the npm package") -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). +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). +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to deburr. #### Returns -*(string)*: Returns the deburred string. +*(string)*: Returns the deburred string. #### Example ```js @@ -8065,17 +8711,19 @@ _.deburr('déjà vu'); ### `_.endsWith([string=''], [target], [position=string.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12425 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13110 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") Checks if `string` ends with the given target string. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to search. 2. `[target]` *(string)*: The string to search for. 3. `[position=string.length]` *(number)*: The position to search from. #### Returns -*(boolean)*: Returns `true` if `string` ends with `target`, else `false`. +*(boolean)*: Returns `true` if `string` ends with `target`, else `false`. #### Example ```js @@ -8095,7 +8743,7 @@ _.endsWith('abc', 'b', 2); ### `_.escape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12470 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13157 "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. @@ -8107,26 +8755,29 @@ characters use a third-party library like [_he_](https://mths.be/he).
Though the ">" character is escaped for symmetry, characters like ">" and "/" don't need escaping in HTML and have no special meaning -unless they're part of a tag or unquoted attribute value. -See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) -(under "semi-related fun fact") for more details. +unless they're part of a tag or unquoted attribute value. See +[Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) +*(under "semi-related fun fact")* for more details.

-Backticks are escaped because in IE < 9, they can break out of +Backticks are escaped because in IE < `9`, they can break out of attribute values or HTML comments. See [#59](https://html5sec.org/#59), [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and -[#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/) -for more details. +[#133](https://html5sec.org/#133) of the +[HTML5 Security Cheatsheet](https://html5sec.org/) for more details.

-When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping) -to reduce XSS vectors. +When working with HTML you should always +[quote attribute values](http://wonko.com/post/html-escaping) to reduce +XSS vectors. +#### Since +0.1.0 #### Arguments 1. `[string='']` *(string)*: The string to escape. #### Returns -*(string)*: Returns the escaped string. +*(string)*: Returns the escaped string. #### Example ```js @@ -8140,16 +8791,18 @@ _.escape('fred, barney, & pebbles'); ### `_.escapeRegExp([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12491 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13179 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to escape. #### Returns -*(string)*: Returns the escaped string. +*(string)*: Returns the escaped string. #### Example ```js @@ -8163,15 +8816,18 @@ _.escapeRegExp('[lodash](https://lodash.com/)'); ### `_.kebabCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12517 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13207 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") -Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). +Converts `string` to +[kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the kebab cased string. +*(string)*: Returns the kebab cased string. #### Example ```js @@ -8181,7 +8837,7 @@ _.kebabCase('Foo Bar'); _.kebabCase('fooBar'); // => 'foo-bar' -_.kebabCase('__foo_bar__'); +_.kebabCase('__FOO_BAR__'); // => 'foo-bar' ``` * * * @@ -8191,19 +8847,21 @@ _.kebabCase('__foo_bar__'); ### `_.lowerCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12540 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lowercase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13231 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lowercase "See the npm package") Converts `string`, as space separated words, to lower case. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the lower cased string. +*(string)*: Returns the lower cased string. #### Example ```js -_.lowerCase('--Foo-Bar'); +_.lowerCase('--Foo-Bar--'); // => 'foo bar' _.lowerCase('fooBar'); @@ -8219,15 +8877,17 @@ _.lowerCase('__FOO_BAR__'); ### `_.lowerFirst([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12560 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lowerfirst "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13252 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lowerfirst "See the npm package") Converts the first character of `string` to lower case. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the converted string. +*(string)*: Returns the converted string. #### Example ```js @@ -8244,18 +8904,20 @@ _.lowerFirst('FRED'); ### `_.pad([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12602 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pad "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13277 "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's shorter than `length`. Padding characters are truncated if they can't be evenly divided by `length`. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to pad. 2. `[length=0]` *(number)*: The padding length. 3. `[chars=' ']` *(string)*: The string used as padding. #### Returns -*(string)*: Returns the padded string. +*(string)*: Returns the padded string. #### Example ```js @@ -8275,18 +8937,20 @@ _.pad('abc', 3); ### `_.padEnd([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12639 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padend "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13316 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padend "See the npm package") Pads `string` on the right side if it's shorter than `length`. Padding characters are truncated if they exceed `length`. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to pad. 2. `[length=0]` *(number)*: The padding length. 3. `[chars=' ']` *(string)*: The string used as padding. #### Returns -*(string)*: Returns the padded string. +*(string)*: Returns the padded string. #### Example ```js @@ -8306,18 +8970,20 @@ _.padEnd('abc', 3); ### `_.padStart([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12666 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padstart "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13349 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padstart "See the npm package") Pads `string` on the left side if it's shorter than `length`. Padding characters are truncated if they exceed `length`. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to pad. 2. `[length=0]` *(number)*: The padding length. 3. `[chars=' ']` *(string)*: The string used as padding. #### Returns -*(string)*: Returns the padded string. +*(string)*: Returns the padded string. #### Example ```js @@ -8337,22 +9003,24 @@ _.padStart('abc', 3); ### `_.parseInt(string, [radix=10])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12694 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.parseint "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13383 "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, -in which case a `radix` of `16` is used. +`undefined` or `0`, a `radix` of `10` is used unless `value` is a +hexadecimal, in which case a `radix` of `16` is used.

-**Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2) -of `parseInt`. +**Note:** This method aligns with the +[ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. +#### Since +1.1.0 #### Arguments 1. `string` *(string)*: The string to convert. 2. `[radix=10]` *(number)*: The radix to interpret `value` by. #### Returns -*(number)*: Returns the converted integer. +*(number)*: Returns the converted integer. #### Example ```js @@ -8369,16 +9037,18 @@ _.map(['6', '08', '10'], _.parseInt); ### `_.repeat([string=''], [n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12726 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13416 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") Repeats the given string `n` times. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to repeat. 2. `[n=0]` *(number)*: The number of times to repeat the string. #### Returns -*(string)*: Returns the repeated string. +*(string)*: Returns the repeated string. #### Example ```js @@ -8398,20 +9068,23 @@ _.repeat('abc', 0); ### `_.replace([string=''], pattern, replacement)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12764 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.replace "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13439 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.replace "See the npm package") Replaces matches for `pattern` in `string` with `replacement`.

-**Note:** This method is based on [`String#replace`](https://mdn.io/String/replace). +**Note:** This method is based on +[`String#replace`](https://mdn.io/String/replace). +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to modify. 2. `pattern` *(RegExp|string)*: The pattern to replace. 3. `replacement` *(Function|string)*: The match replacement. #### Returns -*(string)*: Returns the modified string. +*(string)*: Returns the modified string. #### Example ```js @@ -8425,15 +9098,18 @@ _.replace('Hi Fred', 'Fred', 'Barney'); ### `_.snakeCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12790 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.snakecase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13467 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.snakecase "See the npm package") -Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). +Converts `string` to +[snake case](https://en.wikipedia.org/wiki/Snake_case). +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the snake cased string. +*(string)*: Returns the snake cased string. #### Example ```js @@ -8443,7 +9119,7 @@ _.snakeCase('Foo Bar'); _.snakeCase('fooBar'); // => 'foo_bar' -_.snakeCase('--foo-bar'); +_.snakeCase('--FOO-BAR--'); // => 'foo_bar' ``` * * * @@ -8453,20 +9129,23 @@ _.snakeCase('--foo-bar'); ### `_.split([string=''], separator, [limit])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12811 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.split "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13490 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.split "See the npm package") Splits `string` by `separator`.

-**Note:** This method is based on [`String#split`](https://mdn.io/String/split). +**Note:** This method is based on +[`String#split`](https://mdn.io/String/split). +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to split. 2. `separator` *(RegExp|string)*: The separator pattern to split by. 3. `[limit]` *(number)*: The length to truncate results to. #### Returns -*(Array)*: Returns the new array of string segments. +*(Array)*: Returns the new array of string segments. #### Example ```js @@ -8480,26 +9159,29 @@ _.split('a-b-c', '-', 2); ### `_.startCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12834 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13515 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startcase "See the npm package") -Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). +Converts `string` to +[start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). +#### Since +3.1.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the start cased string. +*(string)*: Returns the start cased string. #### Example ```js -_.startCase('--foo-bar'); +_.startCase('--foo-bar--'); // => 'Foo Bar' _.startCase('fooBar'); // => 'Foo Bar' -_.startCase('__foo_bar__'); -// => 'Foo Bar' +_.startCase('__FOO_BAR__'); +// => 'FOO BAR' ``` * * * @@ -8508,17 +9190,19 @@ _.startCase('__foo_bar__'); ### `_.startsWith([string=''], [target], [position=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12859 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13542 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") Checks if `string` starts with the given target string. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to search. 2. `[target]` *(string)*: The string to search for. 3. `[position=0]` *(number)*: The position to search from. #### Returns -*(boolean)*: Returns `true` if `string` starts with `target`, else `false`. +*(boolean)*: Returns `true` if `string` starts with `target`, else `false`. #### Example ```js @@ -8537,8 +9221,8 @@ _.startsWith('abc', 'b', 1); -### `_.template([string=''], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12961 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.template "See the npm package") +### `_.template([string=''], [options={}], [options.escape=_.templateSettings.escape], [options.evaluate=_.templateSettings.evaluate], [options.imports=_.templateSettings.imports], [options.interpolate=_.templateSettings.interpolate], [options.sourceURL='lodash.templateSources[n]'], [options.variable='obj'])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13651 "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 @@ -8559,18 +9243,20 @@ For more information on precompiling templates see For more information on Chrome extension sandboxes see [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). +#### Since +0.1.0 #### Arguments 1. `[string='']` *(string)*: The template string. -2. `[options]` *(Object)*: The options object. -3. `[options.escape]` *(RegExp)*: The HTML "escape" delimiter. -4. `[options.evaluate]` *(RegExp)*: The "evaluate" delimiter. -5. `[options.imports]` *(Object)*: An object to import into the template as free variables. -6. `[options.interpolate]` *(RegExp)*: The "interpolate" delimiter. -7. `[options.sourceURL]` *(string)*: The sourceURL of the template's compiled source. -8. `[options.variable]` *(string)*: The data object variable name. +2. `[options={}]` *(Object)*: The options object. +3. `[options.escape=_.templateSettings.escape]` *(RegExp)*: The HTML "escape" delimiter. +4. `[options.evaluate=_.templateSettings.evaluate]` *(RegExp)*: The "evaluate" delimiter. +5. `[options.imports=_.templateSettings.imports]` *(Object)*: An object to import into the template as free variables. +6. `[options.interpolate=_.templateSettings.interpolate]` *(RegExp)*: The "interpolate" delimiter. +7. `[options.sourceURL='lodash.templateSources[n]']` *(string)*: The sourceURL of the compiled template. +8. `[options.variable='obj']` *(string)*: The data object variable name. #### Returns -*(Function)*: Returns the compiled template function. +*(Function)*: Returns the compiled template function. #### Example ```js @@ -8619,7 +9305,7 @@ compiled({ 'users': ['fred', 'barney'] }); // Use the `sourceURL` option to specify a custom sourceURL for the template. var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); compiled(data); -// => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector +// => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. // Use the `variable` option to ensure a with-statement isn't used in the compiled template. var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); @@ -8645,21 +9331,23 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.toLower([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13088 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tolower "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13780 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tolower "See the npm package") Converts `string`, as a whole, to lower case just like [String#toLowerCase](https://mdn.io/toLowerCase). +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the lower cased string. +*(string)*: Returns the lower cased string. #### Example ```js -_.toLower('--Foo-Bar'); -// => '--foo-bar' +_.toLower('--Foo-Bar--'); +// => '--foo-bar--' _.toLower('fooBar'); // => 'foobar' @@ -8674,21 +9362,23 @@ _.toLower('__FOO_BAR__'); ### `_.toUpper([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13112 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toupper "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13805 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toupper "See the npm package") Converts `string`, as a whole, to upper case just like [String#toUpperCase](https://mdn.io/toUpperCase). +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the upper cased string. +*(string)*: Returns the upper cased string. #### Example ```js -_.toUpper('--foo-bar'); -// => '--FOO-BAR' +_.toUpper('--foo-bar--'); +// => '--FOO-BAR--' _.toUpper('fooBar'); // => 'FOOBAR' @@ -8703,16 +9393,18 @@ _.toUpper('__foo_bar__'); ### `_.trim([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13137 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trim "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13831 "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`. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to trim. 2. `[chars=whitespace]` *(string)*: The characters to trim. #### Returns -*(string)*: Returns the trimmed string. +*(string)*: Returns the trimmed string. #### Example ```js @@ -8732,16 +9424,18 @@ _.map([' foo ', ' bar '], _.trim); ### `_.trimEnd([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13175 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimend "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13870 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimend "See the npm package") Removes trailing whitespace or specified characters from `string`. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to trim. 2. `[chars=whitespace]` *(string)*: The characters to trim. #### Returns -*(string)*: Returns the trimmed string. +*(string)*: Returns the trimmed string. #### Example ```js @@ -8758,16 +9452,18 @@ _.trimEnd('-_-abc-_-', '_-'); ### `_.trimStart([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13211 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimstart "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13907 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimstart "See the npm package") Removes leading whitespace or specified characters from `string`. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to trim. 2. `[chars=whitespace]` *(string)*: The characters to trim. #### Returns -*(string)*: Returns the trimmed string. +*(string)*: Returns the trimmed string. #### Example ```js @@ -8783,22 +9479,24 @@ _.trimStart('-_-abc-_-', '_-'); -### `_.truncate([string=''], [options=({})], [options.length=30], [options.omission='...'], [options.separator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13265 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.truncate "See the npm package") +### `_.truncate([string=''], [options={}], [options.length=30], [options.omission='...'], [options.separator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L13962 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.truncate "See the npm package") Truncates `string` if it's longer than the given maximum string length. The last characters of the truncated string are replaced with the omission string which defaults to "...". +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to truncate. -2. `[options=({})]` *(Object)*: The options object. +2. `[options={}]` *(Object)*: The options object. 3. `[options.length=30]` *(number)*: The maximum string length. 4. `[options.omission='...']` *(string)*: The string to indicate text is omitted. 5. `[options.separator]` *(RegExp|string)*: The separator pattern to truncate to. #### Returns -*(string)*: Returns the truncated string. +*(string)*: Returns the truncated string. #### Example ```js @@ -8829,21 +9527,23 @@ _.truncate('hi-diddly-ho there, neighborino', { ### `_.unescape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13339 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unescape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14037 "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 -corresponding characters. +`&`, `<`, `>`, `"`, `'`, and ``` in `string` to +their corresponding characters.

-**Note:** No other HTML entities are unescaped. To unescape additional HTML -entities use a third-party library like [_he_](https://mths.be/he). +**Note:** No other HTML entities are unescaped. To unescape additional +HTML entities use a third-party library like [_he_](https://mths.be/he). +#### Since +0.6.0 #### Arguments 1. `[string='']` *(string)*: The string to unescape. #### Returns -*(string)*: Returns the unescaped string. +*(string)*: Returns the unescaped string. #### Example ```js @@ -8857,15 +9557,17 @@ _.unescape('fred, barney, & pebbles'); ### `_.upperCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13365 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uppercase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14064 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uppercase "See the npm package") Converts `string`, as space separated words, to upper case. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the upper cased string. +*(string)*: Returns the upper cased string. #### Example ```js @@ -8885,15 +9587,17 @@ _.upperCase('__foo_bar__'); ### `_.upperFirst([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L12578 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.upperfirst "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14085 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.upperfirst "See the npm package") Converts the first character of `string` to upper case. +#### Since +4.0.0 #### Arguments 1. `[string='']` *(string)*: The string to convert. #### Returns -*(string)*: Returns the converted string. +*(string)*: Returns the converted string. #### Example ```js @@ -8910,16 +9614,18 @@ _.upperFirst('FRED'); ### `_.words([string=''], [pattern])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13387 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14106 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") Splits `string` into an array of its words. +#### Since +3.0.0 #### Arguments 1. `[string='']` *(string)*: The string to inspect. 2. `[pattern]` *(RegExp|string)*: The pattern to match words. #### Returns -*(Array)*: Returns the words of `string`. +*(Array)*: Returns the words of `string`. #### Example ```js @@ -8941,17 +9647,20 @@ _.words('fred, barney, & pebbles', /[^, ]+/g); -### `_.attempt(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13419 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.attempt "See the npm package") +### `_.attempt(func, [args])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14140 "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's invoked. +#### Since +3.0.0 #### Arguments 1. `func` *(Function)*: The function to attempt. +2. `[args]` *(...*)*: The arguments to invoke `func` with. #### Returns -*(*)*: Returns the `func` result or error object. +*(*)*: Returns the `func` result or error object. #### Example ```js @@ -8971,7 +9680,7 @@ if (_.isError(elements)) { ### `_.bindAll(object, methodNames)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13453 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindall "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14175 "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. @@ -8979,12 +9688,14 @@ method.
**Note:** This method doesn't set the "length" property of bound functions. +#### Since +0.1.0 #### Arguments 1. `object` *(Object)*: The object to bind and assign the bound methods to. -2. `methodNames` *(...(string|string[])*: The object method names to bind, specified individually or in arrays. +2. `methodNames` *(...(string|string[]))*: The object method names to bind, specified individually or in arrays. #### Returns -*(Object)*: Returns `object`. +*(Object)*: Returns `object`. #### Example ```js @@ -8997,7 +9708,7 @@ var view = { _.bindAll(view, 'onClick'); jQuery(element).on('click', view.onClick); -// => logs 'clicked docs' when clicked +// => Logs 'clicked docs' when clicked. ``` * * * @@ -9006,18 +9717,20 @@ jQuery(element).on('click', view.onClick); ### `_.cond(pairs)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13488 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.cond "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14211 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.cond "See the npm package") Creates a function that iterates over `pairs` invoking the corresponding function of the first predicate to return truthy. The predicate-function pairs are invoked with the `this` binding and arguments of the created function. +#### Since +4.0.0 #### Arguments 1. `pairs` *(Array)*: The predicate-function pairs. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9043,17 +9756,19 @@ func({ 'a': '1', 'b': '2' }); ### `_.conforms(source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13530 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.conforms "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14254 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.conforms "See the npm package") Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`. +#### Since +4.0.0 #### Arguments 1. `source` *(Object)*: The object of property predicates to conform to. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9072,15 +9787,17 @@ _.filter(users, _.conforms({ 'age': _.partial(_.gt, _, 38) })); ### `_.constant(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13550 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14275 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") Creates a function that returns `value`. +#### Since +2.4.0 #### Arguments 1. `value` *(*)*: The value to return from the new function. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9097,17 +9814,19 @@ getter() === object; ### `_.flow([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13576 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flow "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14302 "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 given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous. +#### Since +3.0.0 #### Arguments -1. `[funcs]` *(...(Function|Function[])*: Functions to invoke. +1. `[funcs]` *(...(Function|Function[]))*: Functions to invoke. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9126,16 +9845,18 @@ addSquare(1, 2); ### `_.flowRight([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13597 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flowright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14324 "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 given functions from right to left. +#### Since +0.1.0 #### Arguments -1. `[funcs]` *(...(Function|Function[])*: Functions to invoke. +1. `[funcs]` *(...(Function|Function[]))*: Functions to invoke. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9154,15 +9875,17 @@ addSquare(1, 2); ### `_.identity(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13614 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14342 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") This method returns the first argument given to it. +#### Since +0.1.0 #### Arguments 1. `value` *(*)*: Any value. #### Returns -*(*)*: Returns `value`. +*(*)*: Returns `value`. #### Example ```js @@ -9178,37 +9901,50 @@ _.identity(object) === object; ### `_.iteratee([func=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13648 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iteratee "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14388 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iteratee "See the npm package") Creates a function that invokes `func` with the arguments of the created -function. If `func` is a property name the 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`. +function. If `func` is a property name the created function returns the +property value for a given element. If `func` is an array or object the +created function returns `true` for elements that contain the equivalent +source properties, otherwise it returns `false`. +#### Since +4.0.0 #### Arguments 1. `[func=_.identity]` *(*)*: The value to convert to a callback. #### Returns -*(Function)*: Returns the callback. +*(Function)*: Returns the callback. #### Example ```js var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } + { 'user': 'barney', 'age': 36, 'active': true }, + { 'user': 'fred', 'age': 40, 'active': false } ]; +// The `_.matches` iteratee shorthand. +_.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); +// => [{ 'user': 'barney', 'age': 36, 'active': true }] + +// The `_.matchesProperty` iteratee shorthand. +_.filter(users, _.iteratee(['user', 'fred'])); +// => [{ 'user': 'fred', 'age': 40 }] + +// The `_.property` iteratee shorthand. +_.map(users, _.iteratee('user')); +// => ['barney', 'fred'] + // Create custom iteratee shorthands. -_.iteratee = _.wrap(_.iteratee, function(callback, func) { - var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func); - return !p ? callback(func) : function(object) { - return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]); +_.iteratee = _.wrap(_.iteratee, function(iteratee, func) { + return !_.isRegExp(func) ? iteratee(func) : function(string) { + return func.test(string); }; }); -_.filter(users, 'age > 36'); -// => [{ 'user': 'fred', 'age': 40 }] +_.filter(['abc', 'def'], /ef/); +// => ['def'] ``` * * * @@ -9217,7 +9953,7 @@ _.filter(users, 'age > 36'); ### `_.matches(source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13675 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14416 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") Creates a function that performs a partial deep comparison between a given object and `source`, returning `true` if the given object has equivalent @@ -9227,11 +9963,13 @@ property values, else `false`. The created function is equivalent to
**Note:** This method supports comparing the same values as `_.isEqual`. +#### Since +3.0.0 #### Arguments 1. `source` *(Object)*: The object of property values to match. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9250,7 +9988,7 @@ _.filter(users, _.matches({ 'age': 40, 'active': false })); ### `_.matchesProperty(path, srcValue)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13702 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14444 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") Creates a function that performs a partial deep comparison between the value at `path` of a given object to `srcValue`, returning `true` if the @@ -9259,12 +9997,14 @@ object value is equivalent, else `false`.
**Note:** This method supports comparing the same values as `_.isEqual`. +#### Since +3.2.0 #### Arguments 1. `path` *(Array|string)*: The path of the property to get. 2. `srcValue` *(*)*: The value to match. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9283,17 +10023,19 @@ _.find(users, _.matchesProperty('user', 'fred')); ### `_.method(path, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13729 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.method "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14472 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.method "See the npm package") Creates a function that invokes the method at `path` of a given object. Any additional arguments are provided to the invoked method. +#### Since +3.7.0 #### Arguments 1. `path` *(Array|string)*: The path of the method to invoke. 2. `[args]` *(...*)*: The arguments to invoke the method with. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9305,8 +10047,8 @@ var objects = [ _.map(objects, _.method('a.b.c')); // => [2, 1] -_.invokeMap(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); -// => [1, 2] +_.map(objects, _.method(['a', 'b', 'c'])); +// => [2, 1] ``` * * * @@ -9315,18 +10057,20 @@ _.invokeMap(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); ### `_.methodOf(object, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13757 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.methodof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14501 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.methodof "See the npm package") The opposite of `_.method`; this method creates a function that invokes the method at a given path of `object`. Any additional arguments are provided to the invoked method. +#### Since +3.7.0 #### Arguments 1. `object` *(Object)*: The object to query. 2. `[args]` *(...*)*: The arguments to invoke the method with. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9345,25 +10089,27 @@ _.map([['a', '2'], ['c', '0']], _.methodOf(object)); -### `_.mixin([object=lodash], source, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13799 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mixin "See the npm package") +### `_.mixin([object=lodash], source, [options={}], [options.chain=true])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14543 "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. +Adds all own enumerable string keyed 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 to avoid conflicts caused by modifying the original. +#### Since +0.1.0 #### Arguments 1. `[object=lodash]` *(Function|Object)*: The destination object. 2. `source` *(Object)*: The object of functions to add. -3. `[options]` *(Object)*: The options object. -4. `[options.chain=true]` *(boolean)*: Specify whether the functions added are chainable. +3. `[options={}]` *(Object)*: The options object. +4. `[options.chain=true]` *(boolean)*: Specify whether mixins are chainable. #### Returns -*(Function|Object)*: Returns `object`. +*(*)*: Returns `object`. #### Example ```js @@ -9391,13 +10137,15 @@ _('fred').vowels(); ### `_.noConflict()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13847 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noconflict "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14592 "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. +#### Since +0.1.0 #### Returns -*(Function)*: Returns the `lodash` function. +*(Function)*: Returns the `lodash` function. #### Example ```js @@ -9410,11 +10158,13 @@ var lodash = _.noConflict(); ### `_.noop()` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13868 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14614 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") A no-operation function that returns `undefined` regardless of the arguments it receives. +#### Since +2.3.0 #### Example ```js var object = { 'user': 'fred' }; @@ -9429,15 +10179,17 @@ _.noop(object) === undefined; ### `_.nthArg([n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13887 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ntharg "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14634 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ntharg "See the npm package") Creates a function that returns its nth argument. +#### Since +4.0.0 #### Arguments 1. `[n=0]` *(number)*: The index of the argument to return. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9453,16 +10205,18 @@ func('a', 'b', 'c'); ### `_.over(iteratees)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13910 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.over "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14658 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.over "See the npm package") Creates a function that invokes `iteratees` with the arguments provided to the created function and returns their results. +#### Since +4.0.0 #### Arguments -1. `iteratees` *(...(Function|Function[])*: The iteratees to invoke. +1. `iteratees` *(...(Function|Function[]))*: The iteratees to invoke. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9478,16 +10232,18 @@ func(1, 2, 3, 4); ### `_.overEvery(predicates)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13934 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.overevery "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14683 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.overevery "See the npm package") Creates a function that checks if **all** of the `predicates` return truthy when invoked with the arguments provided to the created function. +#### Since +4.0.0 #### Arguments -1. `predicates` *(...(Function|Function[])*: The predicates to check. +1. `predicates` *(...(Function|Function[]))*: The predicates to check. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9509,16 +10265,18 @@ func(NaN); ### `_.overSome(predicates)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13958 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.oversome "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14708 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.oversome "See the npm package") Creates a function that checks if **any** of the `predicates` return truthy when invoked with the arguments provided to the created function. +#### Since +4.0.0 #### Arguments -1. `predicates` *(...(Function|Function[])*: The predicates to check. +1. `predicates` *(...(Function|Function[]))*: The predicates to check. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9540,15 +10298,17 @@ func(NaN); ### `_.property(path)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L13981 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.property "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14732 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.property "See the npm package") Creates a function that returns the value at `path` of a given object. +#### Since +2.4.0 #### Arguments 1. `path` *(Array|string)*: The path of the property to get. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9570,16 +10330,18 @@ _.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); ### `_.propertyOf(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14005 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.propertyof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14757 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.propertyof "See the npm package") The opposite of `_.property`; this method creates a function that returns the value at a given path of `object`. +#### Since +3.0.0 #### Arguments 1. `object` *(Object)*: The object to query. #### Returns -*(Function)*: Returns the new function. +*(Function)*: Returns the new function. #### Example ```js @@ -9599,9 +10361,9 @@ _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14050 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.range "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14803 "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 +Creates an array of numbers *(positive and/or negative)* progressing from `start` up to, but not including, `end`. A step of `-1` is used if a negative `start` is specified without an `end` or `step`. If `end` is not specified it's set to `start` with `start` then set to `0`. @@ -9610,13 +10372,15 @@ it's set to `start` with `start` then set to `0`. **Note:** JavaScript follows the IEEE-754 standard for resolving floating-point values which can produce unexpected results. +#### Since +0.1.0 #### Arguments 1. `[start=0]` *(number)*: The start of the range. 2. `end` *(number)*: The end of the range. 3. `[step=1]` *(number)*: The value to increment or decrement by. #### Returns -*(Array)*: Returns the new array of numbers. +*(Array)*: Returns the new array of numbers. #### Example ```js @@ -9648,18 +10412,20 @@ _.range(0); ### `_.rangeRight([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14086 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rangeright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14840 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rangeright "See the npm package") This method is like `_.range` except that it populates values in descending order. +#### Since +4.0.0 #### Arguments 1. `[start=0]` *(number)*: The start of the range. 2. `end` *(number)*: The end of the range. 3. `[step=1]` *(number)*: The value to increment or decrement by. #### Returns -*(Array)*: Returns the new array of numbers. +*(Array)*: Returns the new array of numbers. #### Example ```js @@ -9691,15 +10457,17 @@ _.rangeRight(0); ### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1318 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.runincontext "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1366 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.runincontext "See the npm package") Create a new pristine `lodash` function using the `context` object. +#### Since +1.1.0 #### Arguments 1. `[context=root]` *(Object)*: The context object. #### Returns -*(Function)*: Returns a new `lodash` function. +*(Function)*: Returns a new `lodash` function. #### Example ```js @@ -9735,17 +10503,19 @@ var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; ### `_.times(n, [iteratee=_.identity])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14106 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14861 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") Invokes the iteratee `n` times, returning an array of the results of -each invocation. The iteratee is invoked with one argument; (index). +each invocation. The iteratee is invoked with one argument; *(index)*. +#### Since +0.1.0 #### Arguments 1. `n` *(number)*: The number of times to invoke `iteratee`. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. #### Returns -*(Array)*: Returns the array of results. +*(Array)*: Returns the array of results. #### Example ```js @@ -9762,15 +10532,17 @@ _.times(3, String); ### `_.toPath(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14149 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.topath "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14905 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.topath "See the npm package") Converts `value` to a property path array. +#### Since +4.0.0 #### Arguments 1. `value` *(*)*: The value to convert. #### Returns -*(Array)*: Returns the new property path array. +*(Array)*: Returns the new property path array. #### Example ```js @@ -9796,15 +10568,17 @@ console.log(path === newPath); ### `_.uniqueId([prefix=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14169 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L14929 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") Generates a unique ID. If `prefix` is given the ID is appended to it. +#### Since +0.1.0 #### Arguments 1. `[prefix='']` *(string)*: The value to prefix the ID with. #### Returns -*(string)*: Returns the unique ID. +*(string)*: Returns the unique ID. #### Example ```js @@ -9827,9 +10601,9 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L14820 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L15615 "View in source") [Ⓣ][1] -({string}): The semantic version number. +(string): The semantic version number. * * * @@ -9838,10 +10612,10 @@ _.uniqueId(); ### `_.templateSettings` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1572 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.templatesettings "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1625 "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 +(Object): By default, the template delimiters used by lodash are like those in +embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. * * * @@ -9851,9 +10625,9 @@ alternative delimiters. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1580 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1633 "View in source") [Ⓣ][1] -({RegExp}): Used to detect `data` property values to be HTML-escaped. +(RegExp): Used to detect `data` property values to be HTML-escaped. * * * @@ -9862,9 +10636,9 @@ alternative delimiters. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1588 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1641 "View in source") [Ⓣ][1] -({RegExp}): Used to detect code to be evaluated. +(RegExp): Used to detect code to be evaluated. * * * @@ -9873,9 +10647,9 @@ alternative delimiters. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1612 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1665 "View in source") [Ⓣ][1] -({Object}): Used to import variables into the compiled template. +(Object): Used to import variables into the compiled template. * * * @@ -9883,10 +10657,10 @@ alternative delimiters. -### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1620 "View in source") [Ⓣ][1] +### `_.templateSettings.interpolate` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1649 "View in source") [Ⓣ][1] -({Function}): A reference to the `lodash` function. +(RegExp): Used to detect `data` property values to inject. * * * @@ -9894,21 +10668,27 @@ alternative delimiters. -### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1596 "View in source") [Ⓣ][1] +### `_.templateSettings.variable` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1657 "View in source") [Ⓣ][1] -({RegExp}): Used to detect `data` property values to inject. +(string): Used to reference the data object in the template text. * * * + + -### `_.templateSettings.variable` -# [Ⓢ](https://github.com/lodash/lodash/blob/4.6.1/lodash.js#L1604 "View in source") [Ⓣ][1] +## `Methods` + + + +### `_.templateSettings.imports._` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.7.0/lodash.js#L1673 "View in source") [Ⓣ][1] -({string}): Used to reference the data object in the template text. +A reference to the `lodash` function. * * * diff --git a/fp/_baseConvert.js b/fp/_baseConvert.js index b074100730..eea400d521 100644 --- a/fp/_baseConvert.js +++ b/fp/_baseConvert.js @@ -41,10 +41,12 @@ function baseConvert(util, name, func, options) { }; var forceRearg = ('rearg' in options) && options.rearg, - placeholder = isLib ? func : fallbackHolder; + placeholder = isLib ? func : fallbackHolder, + pristine = isLib ? func.runInContext() : undefined; var helpers = isLib ? func : { 'ary': util.ary, + 'assign': util.assign, 'clone': util.clone, 'curry': util.curry, 'forEach': util.forEach, @@ -58,6 +60,7 @@ function baseConvert(util, name, func, options) { }; var ary = helpers.ary, + assign = helpers.assign, clone = helpers.clone, curry = helpers.curry, each = helpers.forEach, @@ -112,6 +115,10 @@ function baseConvert(util, name, func, options) { return result; }; + var convertLib = function(options) { + return _.runInContext.convert(options)(); + }; + var createCloner = function(func) { return function(object) { return func({}, object); @@ -226,8 +233,19 @@ function baseConvert(util, name, func, options) { var wrap = function(name, func) { name = mapping.aliasToReal[name] || name; var wrapper = wrappers[name]; + + var convertMethod = function(options) { + var newUtil = isLib ? pristine : helpers, + newFunc = isLib ? pristine[name] : func, + newOptions = assign(assign({}, config), options); + + return baseConvert(newUtil, name, newFunc, newOptions); + }; + if (wrapper) { - return wrapper(func); + var result = wrapper(func); + result.convert = convertMethod; + return result; } var wrapped = func; if (config.immutable) { @@ -241,7 +259,6 @@ function baseConvert(util, name, func, options) { wrapped = immutWrap(func, cloneByPath); } } - var result; each(aryMethodKeys, function(aryKey) { each(mapping.aryMethod[aryKey], function(otherName) { if (name == otherName) { @@ -275,9 +292,15 @@ function baseConvert(util, name, func, options) { }); result || (result = wrapped); + if (result == func) { + result = function() { + return func.apply(this, arguments); + }; + } + result.convert = convertMethod; if (mapping.placeholder[name]) { setPlaceholder = true; - func.placeholder = result.placeholder = placeholder; + result.placeholder = func.placeholder = placeholder; } return result; }; @@ -303,10 +326,11 @@ function baseConvert(util, name, func, options) { _[pair[0]] = pair[1]; }); + _.convert = convertLib; if (setPlaceholder) { _.placeholder = placeholder; } - // Wrap the lodash method and its aliases. + // Reassign aliases. each(keys(_), function(key) { each(mapping.realToAlias[key] || [], function(alias) { _[alias] = _[key]; diff --git a/fp/_mapping.js b/fp/_mapping.js index 1d33d4b0a6..584ca2e781 100644 --- a/fp/_mapping.js +++ b/fp/_mapping.js @@ -1,22 +1,35 @@ /** Used to map aliases to their real names. */ exports.aliasToReal = { + + // Lodash aliases. + 'each': 'forEach', + 'eachRight': 'forEachRight', + 'entries': 'toPairs', + 'entriesIn': 'toPairsIn', + 'extend': 'assignIn', + 'extendWith': 'assignInWith', + 'first': 'head', + + // Ramda aliases. '__': 'placeholder', - 'all': 'some', + 'all': 'every', 'allPass': 'overEvery', + 'always': 'constant', + 'any': 'some', + 'anyPass': 'overSome', 'apply': 'spread', 'assoc': 'set', 'assocPath': 'set', + 'complement': 'negate', 'compose': 'flowRight', 'contains': 'includes', 'dissoc': 'unset', 'dissocPath': 'unset', - 'each': 'forEach', - 'eachRight': 'forEachRight', 'equals': 'isEqual', - 'extend': 'assignIn', - 'extendWith': 'assignInWith', - 'first': 'head', + 'identical': 'eq', 'init': 'initial', + 'invertObj': 'invert', + 'juxt': 'over', 'mapObj': 'mapValues', 'omitAll': 'omit', 'nAry': 'ary', @@ -28,7 +41,6 @@ exports.aliasToReal = { 'prop': 'get', 'propOf': 'propertyOf', 'propOr': 'getOr', - 'somePass': 'overSome', 'unapply': 'rest', 'unnest': 'flatten', 'useWith': 'overArgs', @@ -45,32 +57,35 @@ exports.aryMethod = { 'spread', 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words' ], '2': [ - 'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey', - 'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN', + 'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindAll', + 'bindKey', 'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN', 'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference', - 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every', - 'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex', - 'findLastKey', 'flatMap', 'flattenDepth', 'forEach', 'forEachRight', 'forIn', - 'forInRight', 'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', - 'hasIn', 'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap', - 'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map', - 'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit', - 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial', - 'partialRight', 'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', - 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'result', + 'divide', 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', + 'eq', 'every', 'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', + 'findLastIndex', 'findLastKey', 'flatMap', 'flatMapDeep', 'flattenDepth', + 'forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', + 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', + 'intersection', 'invertBy', 'invoke', 'invokeMap', 'isEqual', 'isMatch', + 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map', 'mapKeys', 'mapValues', + 'matchesProperty', 'maxBy', 'meanBy', 'merge', 'minBy', 'multiply', 'omit', 'omitBy', + 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial', 'partialRight', + 'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', 'random', 'range', + 'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex', - 'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', 'subtract', 'sumBy', - 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', - 'times', 'trimChars', 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', - 'uniqBy', 'uniqWith', 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', - 'zipObject', 'zipObjectDeep' + 'sortedLastIndexOf', 'sortedUniqBy', 'split', 'spreadFrom', 'startsWith', + 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', + 'throttle', 'thru', 'times', 'trimChars', 'trimCharsEnd', 'trimCharsStart', + 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset', 'unzipWith', 'without', + 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep' ], '3': [ 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith', - 'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith', - 'isMatchWith', 'mergeWith', 'orderBy', 'pullAllBy', 'pullAllWith', 'reduce', - 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', - 'transform', 'unionBy', 'unionWith', 'update', 'xorBy', 'xorWith', 'zipWith' + 'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'invokeArgs', + 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth', 'mergeWith', + 'orderBy', 'padChars', 'padCharsEnd', 'padCharsStart', 'pullAllBy', + 'pullAllWith', 'reduce', 'reduceRight', 'replace', 'set', 'slice', + 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy', 'unionWith', + 'update', 'xorBy', 'xorWith', 'zipWith' ], '4': [ 'fill', 'setWith', 'updateWith' @@ -86,10 +101,6 @@ exports.aryRearg = { /** Used to map method names to their iteratee ary. */ exports.iterateeAry = { - 'assignWith': 2, - 'assignInWith': 2, - 'cloneDeepWith': 1, - 'cloneWith': 1, 'dropRightWhile': 1, 'dropWhile': 1, 'every': 1, @@ -101,14 +112,14 @@ exports.iterateeAry = { 'findLastIndex': 1, 'findLastKey': 1, 'flatMap': 1, + 'flatMapDeep': 1, + 'flatMapDepth': 1, 'forEach': 1, 'forEachRight': 1, 'forIn': 1, 'forInRight': 1, 'forOwn': 1, 'forOwnRight': 1, - 'isEqualWith': 2, - 'isMatchWith': 2, 'map': 1, 'mapKeys': 1, 'mapValues': 1, @@ -134,8 +145,12 @@ exports.methodRearg = { 'assignInWith': [1, 2, 0], 'assignWith': [1, 2, 0], 'getOr': [2, 1, 0], + 'isEqualWith': [1, 2, 0], 'isMatchWith': [2, 1, 0], 'mergeWith': [1, 2, 0], + 'padChars': [2, 1, 0], + 'padCharsEnd': [2, 1, 0], + 'padCharsStart': [2, 1, 0], 'pullAllBy': [2, 1, 0], 'pullAllWith': [2, 1, 0], 'setWith': [3, 1, 2, 0], @@ -147,8 +162,11 @@ exports.methodRearg = { /** Used to map method names to spread configs. */ exports.methodSpread = { + 'invokeArgs': 2, + 'invokeArgsMap': 2, 'partial': 1, - 'partialRight': 1 + 'partialRight': 1, + 'without': 1 }; /** Used to identify methods which mutate arrays or objects. */ @@ -214,6 +232,13 @@ exports.remap = { 'curryN': 'curry', 'curryRightN': 'curryRight', 'getOr': 'get', + 'invokeArgs': 'invoke', + 'invokeArgsMap': 'invokeMap', + 'padChars': 'pad', + 'padCharsEnd': 'padEnd', + 'padCharsStart': 'padStart', + 'restFrom': 'rest', + 'spreadFrom': 'spread', 'trimChars': 'trim', 'trimCharsEnd': 'trimEnd', 'trimCharsStart': 'trimStart' @@ -224,20 +249,27 @@ exports.skipRearg = { 'add': true, 'assign': true, 'assignIn': true, + 'bind': true, + 'bindKey': true, 'concat': true, 'difference': true, + 'divide': true, + 'eq': true, 'gt': true, 'gte': true, + 'isEqual': true, 'lt': true, 'lte': true, 'matchesProperty': true, 'merge': true, + 'multiply': true, 'partial': true, 'partialRight': true, 'random': true, 'range': true, 'rangeRight': true, 'subtract': true, + 'without': true, 'zip': true, 'zipObject': true }; diff --git a/lib/fp/template/doc/wiki.jst b/lib/fp/template/doc/wiki.jst index 7b69bf584d..4600ab6e0a 100644 --- a/lib/fp/template/doc/wiki.jst +++ b/lib/fp/template/doc/wiki.jst @@ -14,7 +14,7 @@ In a browser: In Node.js: ```js // Load the fp build. -var _ = require('lodash/fp'); +var fp = require('lodash/fp'); // Load a method category. var object = require('lodash/fp/object'); @@ -23,53 +23,6 @@ var object = require('lodash/fp/object'); var extend = require('lodash/fp/extend'); ``` -## Convert - -Although `lodash/fp` & its method modules come pre-converted, there are times when -you may want to convert another lodash package or create a customized conversion. -That’s when the `convert` module comes in handy. - -```js -var convert = require('lodash/fp/convert'); - -// Convert by name. -var assign = convert('assign', require('lodash.assign')); - -// Convert by object. -var fp = convert({ - 'assign': require('lodash.assign'), - 'chunk': require('lodash.chunk') -}); - -// Convert by `lodash` instance. -var fp = convert(lodash.runInContext()); -``` - -It’s even customizable. -```js -// Every option is `true` by default. -var filter = convert('filter', _.filter, { - // Specify capping iteratee arguments. - 'cap': true, - // Specify currying. - 'curry': true, - // Specify fixed arity. - 'fixed': true, - // Specify immutable operations. - 'immutable': true, - // Specify rearranging arguments. - 'rearg': true -}); - -// Specify `cap` of `false` to create a function that doesn’t cap iteratee arguments. -var filter = convert('filter', _.filter, { 'cap': false }); - -filter(function(value, index) { - return index % 2 == 0; -})(['a', 'b', 'c']); -// => ['a', 'c'] -``` - ## Mapping Immutable auto-curried iteratee-first data-last methods sound great, but what @@ -78,6 +31,17 @@ to convert each method. #### Capped Iteratee Arguments +Iteratee arguments are capped to avoid gotchas with variadic iteratees. +```js +// The `lodash/map` iteratee recieves three arguments: (value, index|key, collection). +_.map(['6', '8', '10'], parseInt); +// → [6, NaN, 2] + +// The `lodash/fp/map` iteratee is capped at one argument: (value). +fp.map(parseInt)(['6', '8', '10']); +// → [6, 8, 10] +``` + Methods that cap iteratees to one argument:
<%= toFuncList(_.keys(_.pickBy(mapping.iterateeAry, _.partial(_.eq, _, 1)))) %> @@ -88,6 +52,19 @@ The iteratee of `mapKeys` is invoked with one argument: (key) #### Fixed Arity +Methods have fixed arities to support auto-currying. +```js +// The `lodash/padStart` method accepts an optional `chars` param. +_.padStart('a', 3, '-') +// → '--a' + +// The `lodash/fp/padStart` method does not. +fp.padStart(3)('a'); +// → ' a' +fp.padCharsStart('-')(3)('a'); +// → '--a' +``` + Methods with a fixed arity of one:
<%= toFuncList(mapping.aryMethod[1]) %> @@ -102,6 +79,19 @@ Methods with a fixed arity of four:
#### Rearranged Arguments +Method arguments are rearranged to make composition easier. +```js +// The `lodash/filter` method accepts (collection, iteratee). +var compact = _.partial(_.filter, _, Boolean); +compact(['a', null, 'c']); +// → ['a', 'c'] + +// The `lodash/fp/filter` method accepts (iteratee, collection) +var compact = fp.filter(Boolean); +compact(['a', null, 'c']); +// → ['a', 'c'] +``` + Methods with a fixed arity of two have an argument order of:
<%= toArgOrder(mapping.aryRearg[2]) %> @@ -112,7 +102,8 @@ Methods with a fixed arity of four have an argument order of:
<%= toArgOrder(mapping.aryRearg[4]) %> Methods with custom argument orders:
-<%= _.map(mapping.methodRearg, function(orders, methodName) { +<%= _.map(_.keys(mapping.methodRearg), function(methodName) { + var orders = mapping.methodRearg[methodName]; return ' * `_.' + methodName + '` has an order of ' + toArgOrder(orders); }).join('\n') %> @@ -124,12 +115,70 @@ apply as their second parameter. #### New Methods +Not all variadic methods have corresponding new method variants. Feel free to +[request](https://github.com/lodash/lodash/blob/master/.github/CONTRIBUTING.md#feature-requests) +any additions. + Methods created to accommodate Lodash’s variadic methods:
<%= toFuncList(_.keys(mapping.remap)) %> #### Aliases There are <%= _.size(mapping.aliasToReal) %> method aliases:
-<%= _.map(mapping.aliasToReal, function(realName, alias) { +<%= _.map(_.keys(mapping.aliasToReal).sort(), function(alias) { + var realName = mapping.aliasToReal[alias]; return ' * `_.' + alias + '` is an alias of `_.' + realName + '`'; }).join('\n') %> + +## Chaining + +The `lodash/fp` module **does not** convert chain sequence methods. See +[Izaak Schroeder’s article](https://medium.com/making-internets/why-using-chain-is-a-mistake-9bc1f80d51ba) +for more details. + +## Convert + +Although `lodash/fp` & its method modules come pre-converted, there are times +when you may want to customize the conversion. That’s when the `convert` method +comes in handy. +```js +// Every option is `true` by default. +var _fp = fp.convert({ + // Specify capping iteratee arguments. + 'cap': true, + // Specify currying. + 'curry': true, + // Specify fixed arity. + 'fixed': true, + // Specify immutable operations. + 'immutable': true, + // Specify rearranging arguments. + 'rearg': true +}); + +// The `convert` method is available on each method too. +var mapValuesWithKey = fp.mapValues.convert({ 'cap': false }); + +// Here’s an example of disabling iteratee argument caps to access the `key` param. +mapValuesWithKey(function(value, key) { + return key == 'a' ? -1 : value; +})({ 'a': 1, 'b': 1 }); +// => { 'a': -1, 'b': 1 } +``` + +// Manual conversions are also possible with the `convert` module. +```js +var convert = require('lodash/fp/convert'); + +// Convert by name. +var assign = convert('assign', require('lodash.assign')); + +// Convert by object. +var fp = convert({ + 'assign': require('lodash.assign'), + 'chunk': require('lodash.chunk') +}); + +// Convert by `lodash` instance. +var fp = convert(lodash.runInContext()); +``` diff --git a/lib/fp/template/modules/_util.jst b/lib/fp/template/modules/_util.jst index afa811bc60..d450396fc4 100644 --- a/lib/fp/template/modules/_util.jst +++ b/lib/fp/template/modules/_util.jst @@ -1,5 +1,6 @@ module.exports = { 'ary': require('../ary'), + 'assign': require('../_baseAssign'), 'clone': require('../clone'), 'curry': require('../curry'), 'forEach': require('../_arrayEach'), diff --git a/lib/main/build-doc.js b/lib/main/build-doc.js index e4057260ef..97569549c0 100644 --- a/lib/main/build-doc.js +++ b/lib/main/build-doc.js @@ -33,8 +33,13 @@ var config = { }; function postprocess(string) { - // Fix docdown bug by wrapping symbol property identifiers in brackets. - return string.replace(/\.(Symbol\.(?:[a-z]+[A-Z]?)+)/g, '[$1]'); + // Fix docdown bugs. + return string + // Repair the default value of `chars`. + // See https://github.com/eslint/doctrine/issues/157 for more details. + .replace(/\bchars=''/g, "chars=' '") + // Wrap symbol property identifiers in brackets. + .replace(/\.(Symbol\.(?:[a-z]+[A-Z]?)+)/g, '[$1]'); } /*----------------------------------------------------------------------------*/ diff --git a/lodash.js b/lodash.js index 402910dd48..2e45854139 100644 --- a/lodash.js +++ b/lodash.js @@ -1,10 +1,10 @@ /** * @license - * lodash 4.6.1 - * Copyright 2012-2016 The Dojo Foundation + * lodash 4.7.0 + * Copyright jQuery Foundation and other contributors + * Released under MIT license * Based on Underscore.js 1.8.3 - * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ ;(function() { @@ -12,7 +12,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.6.1'; + var VERSION = '4.7.0'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -77,6 +77,7 @@ mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', + promiseTag = '[object Promise]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', @@ -85,6 +86,7 @@ weakSetTag = '[object WeakSet]'; var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', @@ -143,7 +145,7 @@ /** Used to detect binary string values. */ var reIsBinary = /^0b[01]+$/i; - /** Used to detect host constructors (Safari > 5). */ + /** Used to detect host constructors (Safari). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; /** Used to detect octal string values. */ @@ -227,15 +229,15 @@ ].join('|'), 'g'); /** Used to detect strings that need a more robust regexp to match words. */ - var reHasComplexWord = /[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; /** Used to assign default `context` object properties. */ var contextProps = [ - 'Array', 'Buffer', 'Date', 'Error', 'Float32Array', 'Float64Array', + 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', - 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', - 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', '_', - 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' + 'Promise', 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', + 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' ]; /** Used to make template sourceURLs easier to identify. */ @@ -250,25 +252,26 @@ typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = - typedArrayTags[dateTag] = typedArrayTags[errorTag] = - typedArrayTags[funcTag] = typedArrayTags[mapTag] = - typedArrayTags[numberTag] = typedArrayTags[objectTag] = - typedArrayTags[regexpTag] = typedArrayTags[setTag] = - typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = + typedArrayTags[errorTag] = typedArrayTags[funcTag] = + typedArrayTags[mapTag] = typedArrayTags[numberTag] = + typedArrayTags[objectTag] = typedArrayTags[regexpTag] = + typedArrayTags[setTag] = typedArrayTags[stringTag] = + typedArrayTags[weakMapTag] = false; /** Used to identify `toStringTag` values supported by `_.clone`. */ var cloneableTags = {}; cloneableTags[argsTag] = cloneableTags[arrayTag] = - cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = - cloneableTags[dateTag] = cloneableTags[float32Tag] = - cloneableTags[float64Tag] = cloneableTags[int8Tag] = - cloneableTags[int16Tag] = cloneableTags[int32Tag] = - cloneableTags[mapTag] = cloneableTags[numberTag] = - cloneableTags[objectTag] = cloneableTags[regexpTag] = - cloneableTags[setTag] = cloneableTags[stringTag] = - cloneableTags[symbolTag] = cloneableTags[uint8Tag] = - cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = - cloneableTags[uint32Tag] = true; + cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = + cloneableTags[boolTag] = cloneableTags[dateTag] = + cloneableTags[float32Tag] = cloneableTags[float64Tag] = + cloneableTags[int8Tag] = cloneableTags[int16Tag] = + cloneableTags[int32Tag] = cloneableTags[mapTag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[setTag] = + cloneableTags[stringTag] = cloneableTags[symbolTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; @@ -513,7 +516,8 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. */ function arrayEvery(array, predicate) { var index = -1, @@ -632,7 +636,8 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduce(array, iteratee, accumulator, initAccum) { @@ -656,7 +661,8 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the last element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as + * the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduceRight(array, iteratee, accumulator, initAccum) { @@ -677,7 +683,8 @@ * @private * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. */ function arraySome(array, predicate) { var index = -1, @@ -729,7 +736,8 @@ * @param {Array|Object} collection The collection to search. * @param {Function} predicate The function invoked per iteration. * @param {Function} eachFunc The function to iterate over `collection`. - * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself. + * @param {boolean} [retKey] Specify returning the key of the found element + * instead of the element itself. * @returns {*} Returns the found element or its key, else `undefined`. */ function baseFind(collection, predicate, eachFunc, retKey) { @@ -811,6 +819,20 @@ return -1; } + /** + * The base implementation of `_.mean` and `_.meanBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the mean. + */ + function baseMean(array, iteratee) { + var length = array ? array.length : 0; + return length ? (baseSum(array, iteratee) / length) : NAN; + } + /** * The base implementation of `_.reduce` and `_.reduceRight`, without support * for iteratee shorthands, which iterates over `collection` using `eachFunc`. @@ -819,7 +841,8 @@ * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ @@ -853,7 +876,8 @@ } /** - * The base implementation of `_.sum` without support for iteratee shorthands. + * The base implementation of `_.sum` and `_.sumBy` without support for + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -1050,7 +1074,7 @@ // for more details. // // This also ensures a stable sort in V8 and other engines. - // See https://code.google.com/p/v8/issues/detail?id=90 for more details. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. return object.index - other.index; } @@ -1074,6 +1098,29 @@ return result; } + /** + * Creates a function that performs a mathematical operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @returns {Function} Returns the new mathematical operation function. + */ + function createMathOperation(operator) { + return function(value, other) { + var result; + if (value === undefined && other === undefined) { + return 0; + } + if (value !== undefined) { + result = value; + } + if (other !== undefined) { + result = result === undefined ? other : operator(result, other); + } + return result; + }; + } + /** * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. * @@ -1285,6 +1332,7 @@ * * @static * @memberOf _ + * @since 1.1.0 * @category Util * @param {Object} [context=root] The context object. * @returns {Function} Returns a new `lodash` function. @@ -1363,7 +1411,6 @@ Uint8Array = context.Uint8Array, clearTimeout = context.clearTimeout, enumerate = Reflect ? Reflect.enumerate : undefined, - getPrototypeOf = Object.getPrototypeOf, getOwnPropertySymbols = Object.getOwnPropertySymbols, iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined, objectCreate = Object.create, @@ -1374,6 +1421,7 @@ /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeCeil = Math.ceil, nativeFloor = Math.floor, + nativeGetPrototype = Object.getPrototypeOf, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = Object.keys, @@ -1384,7 +1432,9 @@ nativeReverse = arrayProto.reverse; /* Built-in method references that are verified to be native. */ - var Map = getNative(context, 'Map'), + var DataView = getNative(context, 'DataView'), + Map = getNative(context, 'Map'), + Promise = getNative(context, 'Promise'), Set = getNative(context, 'Set'), WeakMap = getNative(context, 'WeakMap'), nativeCreate = getNative(Object, 'create'); @@ -1399,7 +1449,9 @@ var realNames = {}; /** Used to detect maps, sets, and weakmaps. */ - var mapCtorString = Map ? funcToString.call(Map) : '', + var dataViewCtorString = DataView ? (DataView + '') : '', + mapCtorString = Map ? funcToString.call(Map) : '', + promiseCtorString = Promise ? funcToString.call(Promise) : '', setCtorString = Set ? funcToString.call(Set) : '', weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : ''; @@ -1412,25 +1464,25 @@ /** * Creates a `lodash` object which wraps `value` to enable implicit method - * chaining. Methods that operate on and return arrays, collections, and - * functions can be chained together. Methods that retrieve a single value or - * may return a primitive value will automatically end the chain sequence and - * return the unwrapped value. Otherwise, the value must be unwrapped with - * `_#value`. + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. * - * Explicit chaining, which must be unwrapped with `_#value` in all cases, - * may be enabled using `_.chain`. + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. * * The execution of chained methods is lazy, that is, it's deferred until * `_#value` is implicitly or explicitly called. * - * Lazy evaluation allows several methods to support shortcut fusion. Shortcut - * fusion is an optimization to merge iteratee calls; this avoids the creation - * of intermediate arrays and can greatly reduce the number of iteratee executions. - * Sections of a chain sequence qualify for shortcut fusion if the section is - * applied to an array of at least two hundred elements and any iteratees - * accept only one argument. The heuristic for whether a section qualifies - * for shortcut fusion is subject to change. + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array of at least two hundred + * elements and any iteratees accept only one argument. The heuristic for + * whether a section qualifies for shortcut fusion is subject to change. * * Chaining is supported in custom builds as long as the `_#value` method is * directly or indirectly included in the build. @@ -1455,48 +1507,49 @@ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, - * `flatten`, `flattenDeep`, `flattenDepth`, `flip`, `flow`, `flowRight`, - * `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, `intersection`, - * `intersectionBy`, `intersectionWith`, `invert`, `invertBy`, `invokeMap`, - * `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, - * `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, - * `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, - * `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`, - * `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, - * `pullAll`, `pullAllBy`, `pullAllWith`, `pullAt`, `push`, `range`, - * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`, - * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`, - * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, - * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, - * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, - * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `update`, `values`, - * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, - * `zipObjectDeep`, and `zipWith` + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, - * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `each`, `eachRight`, - * `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, `floor`, - * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, - * `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, `includes`, - * `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, `isArrayBuffer`, - * `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, `isDate`, - * `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`, - * `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, `isMatchWith`, - * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, - * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isSet`, `isString`, - * `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, - * `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, - * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, - * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, - * `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`, - * `template`, `times`, `toInteger`, `toJSON`, `toLength`, `toLower`, - * `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`, - * `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`, - * `value`, and `words` + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`, + * `eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, + * `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, + * `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, + * `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, + * `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, + * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, + * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, + * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, + * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, + * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, + * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, + * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, + * `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`, + * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, + * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, + * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toInteger`, + * `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, `toString`, + * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, + * `uniqueId`, `upperCase`, `upperFirst`, `value`, and `words` * * @name _ * @constructor @@ -1537,7 +1590,7 @@ } /** - * The function whose prototype all chaining wrappers inherit from. + * The function whose prototype chain sequence wrappers inherit from. * * @private */ @@ -1550,7 +1603,7 @@ * * @private * @param {*} value The value to wrap. - * @param {boolean} [chainAll] Enable chaining for all wrapper methods. + * @param {boolean} [chainAll] Enable explicit method chain sequences. */ function LodashWrapper(value, chainAll) { this.__wrapped__ = value; @@ -1621,6 +1674,13 @@ } }; + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + lodash.prototype.constructor = lodash; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + /*------------------------------------------------------------------------*/ /** @@ -1737,6 +1797,10 @@ return result; } + // Ensure `LazyWrapper` is an instance of `baseLodash`. + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + /*------------------------------------------------------------------------*/ /** @@ -1800,6 +1864,9 @@ hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; } + // Avoid inheriting from `Object.prototype` when possible. + Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; + /*------------------------------------------------------------------------*/ /** @@ -1894,7 +1961,7 @@ * @memberOf MapCache * @param {string} key The key of the value to set. * @param {*} value The value to set. - * @returns {Object} Returns the map cache object. + * @returns {Object} Returns the map cache instance. */ function mapSet(key, value) { var data = this.__data__; @@ -1908,6 +1975,13 @@ return this; } + // Add methods to `MapCache`. + MapCache.prototype.clear = mapClear; + MapCache.prototype['delete'] = mapDelete; + MapCache.prototype.get = mapGet; + MapCache.prototype.has = mapHas; + MapCache.prototype.set = mapSet; + /*------------------------------------------------------------------------*/ /** @@ -1968,6 +2042,9 @@ } } + // Add methods to `SetCache`. + SetCache.prototype.push = cachePush; + /*------------------------------------------------------------------------*/ /** @@ -2055,7 +2132,7 @@ * @memberOf Stack * @param {string} key The key of the value to set. * @param {*} value The value to set. - * @returns {Object} Returns the stack cache object. + * @returns {Object} Returns the stack cache instance. */ function stackSet(key, value) { var data = this.__data__, @@ -2076,13 +2153,20 @@ return this; } + // Add methods to `Stack`. + Stack.prototype.clear = stackClear; + Stack.prototype['delete'] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + /*------------------------------------------------------------------------*/ /** * Removes `key` and its value from the associative array. * * @private - * @param {Array} array The array to query. + * @param {Array} array The array to modify. * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ @@ -2126,8 +2210,7 @@ } /** - * Gets the index at which the first occurrence of `key` is found in `array` - * of key-value pairs. + * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private * @param {Array} array The array to search. @@ -2271,7 +2354,7 @@ * * @private * @param {*} value The value to inspect. - * @returns {Array} Returns the array-like object. + * @returns {Array|Object} Returns the cast array-like object. */ function baseCastArrayLikeObject(value) { return isArrayLikeObject(value) ? value : []; @@ -2282,12 +2365,23 @@ * * @private * @param {*} value The value to inspect. - * @returns {Array} Returns the array-like object. + * @returns {Function} Returns cast function. */ function baseCastFunction(value) { return typeof value == 'function' ? value : identity; } + /** + * Casts `value` to a string if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the cast key. + */ + function baseCastKey(key) { + return (typeof key == 'string' || isSymbol(key)) ? key : (key + ''); + } + /** * Casts `value` to a path array if it's not one. * @@ -2364,14 +2458,13 @@ } result = initCloneObject(isFunc ? {} : value); if (!isDeep) { - result = baseAssign(result, value); - return isFull ? copySymbols(value, result) : result; + return copySymbols(value, baseAssign(result, value)); } } else { if (!cloneableTags[tag]) { return object ? value : {}; } - result = initCloneByTag(value, tag, isDeep); + result = initCloneByTag(value, tag, baseClone, isDeep); } } // Check for circular references and return its corresponding clone. @@ -2382,11 +2475,18 @@ } stack.set(value, result); + if (!isArr) { + var props = isFull ? getAllKeys(value) : keys(value); + } // Recursively populate clone (susceptible to call stack limits). - (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); }); - return (isFull && !isArr) ? copySymbols(value, result) : result; + return result; } /** @@ -2410,7 +2510,8 @@ predicate = source[key], value = object[key]; - if ((value === undefined && !(key in Object(object))) || !predicate(value)) { + if ((value === undefined && + !(key in Object(object))) || !predicate(value)) { return false; } } @@ -2448,8 +2549,8 @@ } /** - * The base implementation of methods like `_.difference` without support for - * excluding multiple arrays or iteratee shorthands. + * The base implementation of methods like `_.difference` without support + * for excluding multiple arrays or iteratee shorthands. * * @private * @param {Array} array The array to inspect. @@ -2528,7 +2629,8 @@ * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false` + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` */ function baseEvery(collection, predicate) { var result = true; @@ -2619,10 +2721,9 @@ } /** - * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` invoking `iteratee` for - * each property. Iteratee functions may exit iteration early by explicitly - * returning `false`. + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` invoking `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. * * @private * @param {Object} object The object to iterate over. @@ -2644,18 +2745,6 @@ */ var baseForRight = createBaseFor(true); - /** - * The base implementation of `_.forIn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForIn(object, iteratee) { - return object == null ? object : baseFor(object, iteratee, keysIn); - } - /** * The base implementation of `_.forOwn` without support for iteratee shorthands. * @@ -2704,7 +2793,7 @@ * @returns {*} Returns the resolved value. */ function baseGet(object, path) { - path = isKey(path, object) ? [path + ''] : baseCastPath(path); + path = isKey(path, object) ? [path] : baseCastPath(path); var index = 0, length = path.length; @@ -2715,6 +2804,24 @@ return (index && index == length) ? object : undefined; } + /** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) + ? result + : arrayPush(result, symbolsFunc(object)); + } + /** * The base implementation of `_.has` without support for deep paths. * @@ -2728,7 +2835,7 @@ // that are composed entirely of index properties, return `false` for // `hasOwnProperty` checks of them. return hasOwnProperty.call(object, key) || - (typeof object == 'object' && key in object && getPrototypeOf(object) === null); + (typeof object == 'object' && key in object && getPrototype(object) === null); } /** @@ -2891,7 +2998,8 @@ * @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 comparisons. - * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ @@ -2924,8 +3032,11 @@ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + stack || (stack = new Stack); - return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack); + return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); } } if (!isSameTag) { @@ -2974,9 +3085,10 @@ return false; } } else { - var stack = new Stack, - result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined; - + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result @@ -2996,14 +3108,15 @@ * @returns {Function} Returns the iteratee. */ function baseIteratee(value) { - var type = typeof value; - if (type == 'function') { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { return value; } if (value == null) { return identity; } - if (type == 'object') { + if (typeof value == 'object') { return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); @@ -3117,16 +3230,16 @@ * @param {Object} source The source object. * @param {number} srcIndex The index of `source`. * @param {Function} [customizer] The function to customize merged values. - * @param {Object} [stack] Tracks traversed source values and their merged counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. */ function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } - var props = (isArray(source) || isTypedArray(source)) - ? undefined - : keysIn(source); - + if (!(isArray(source) || isTypedArray(source))) { + var props = keysIn(source); + } arrayEach(props || source, function(srcValue, key) { if (props) { key = srcValue; @@ -3161,7 +3274,8 @@ * @param {number} srcIndex The index of `source`. * @param {Function} mergeFunc The function to merge values. * @param {Function} [customizer] The function to customize assigned values. - * @param {Object} [stack] Tracks traversed source values and their merged counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. */ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = object[key], @@ -3189,7 +3303,7 @@ } else { isCommon = false; - newValue = baseClone(srcValue, !customizer); + newValue = baseClone(srcValue, true); } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { @@ -3198,7 +3312,7 @@ } else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { isCommon = false; - newValue = baseClone(srcValue, !customizer); + newValue = baseClone(srcValue, true); } else { newValue = objValue; @@ -3229,7 +3343,7 @@ */ function baseOrderBy(collection, iteratees, orders) { var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : Array(1), getIteratee()); + iteratees = arrayMap(iteratees.length ? iteratees : [identity], getIteratee()); var result = baseMap(collection, function(value, key, collection) { var criteria = arrayMap(iteratees, function(iteratee) { @@ -3245,11 +3359,11 @@ /** * The base implementation of `_.pick` without support for individual - * property names. + * property identifiers. * * @private * @param {Object} object The source object. - * @param {string[]} props The property names to pick. + * @param {string[]} props The property identifiers to pick. * @returns {Object} Returns the new object. */ function basePick(object, props) { @@ -3271,12 +3385,19 @@ * @returns {Object} Returns the new object. */ function basePickBy(object, predicate) { - var result = {}; - baseForIn(object, function(value, key) { + var index = -1, + props = getAllKeysIn(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index], + value = object[key]; + if (predicate(value, key)) { result[key] = value; } - }); + } return result; } @@ -3413,6 +3534,34 @@ return result; } + /** + * The base implementation of `_.repeat` which doesn't coerce arguments. + * + * @private + * @param {string} string The string to repeat. + * @param {number} n The number of times to repeat the string. + * @returns {string} Returns the repeated string. + */ + function baseRepeat(string, n) { + var result = ''; + if (!string || n < 1 || n > MAX_SAFE_INTEGER) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = nativeFloor(n / 2); + if (n) { + string += string; + } + } while (n); + + return result; + } + /** * The base implementation of `_.set`. * @@ -3424,7 +3573,7 @@ * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { - path = isKey(path, object) ? [path + ''] : baseCastPath(path); + path = isKey(path, object) ? [path] : baseCastPath(path); var index = -1, length = path.length, @@ -3500,7 +3649,8 @@ * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. */ function baseSome(collection, predicate) { var result; @@ -3554,7 +3704,8 @@ * @param {*} value The value to evaluate. * @param {Function} iteratee The iteratee invoked per element. * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. */ function baseSortedIndexBy(array, value, iteratee, retHighest) { value = iteratee(value); @@ -3701,7 +3852,7 @@ * @returns {boolean} Returns `true` if the property is deleted, else `false`. */ function baseUnset(object, path) { - path = isKey(path, object) ? [path + ''] : baseCastPath(path); + path = isKey(path, object) ? [path] : baseCastPath(path); object = parent(object, path); var key = last(path); return (object != null && has(object, key)) ? delete object[key] : true; @@ -3793,7 +3944,7 @@ * This base implementation of `_.zipObject` which assigns values using `assignFunc`. * * @private - * @param {Array} props The property names. + * @param {Array} props The property identifiers. * @param {Array} values The property values. * @param {Function} assignFunc The function to assign values. * @returns {Object} Returns the new object. @@ -3805,7 +3956,8 @@ result = {}; while (++index < length) { - assignFunc(result, props[index], index < valsLength ? values[index] : undefined); + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); } return result; } @@ -3840,15 +3992,31 @@ return result; } + /** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ + function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); + } + /** * Creates a clone of `map`. * * @private * @param {Object} map The map to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned map. */ - function cloneMap(map) { - return arrayReduce(mapToArray(map), addMapEntry, new map.constructor); + function cloneMap(map, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map); + return arrayReduce(array, addMapEntry, new map.constructor); } /** @@ -3869,10 +4037,13 @@ * * @private * @param {Object} set The set to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned set. */ - function cloneSet(set) { - return arrayReduce(setToArray(set), addSetEntry, new set.constructor); + function cloneSet(set, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set); + return arrayReduce(array, addSetEntry, new set.constructor); } /** @@ -3995,7 +4166,7 @@ * * @private * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. + * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @returns {Object} Returns `object`. */ @@ -4009,7 +4180,7 @@ * * @private * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. + * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. @@ -4124,7 +4295,7 @@ } /** - * Creates a base function for methods like `_.forIn`. + * Creates a base function for methods like `_.forIn` and `_.forOwn`. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. @@ -4153,7 +4324,8 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {*} [thisArg] The `this` binding of `func`. * @returns {Function} Returns the new wrapped function. */ @@ -4241,7 +4413,8 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {number} arity The arity of `func`. * @returns {Function} Returns the new wrapped function. */ @@ -4313,7 +4486,9 @@ ) { wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); } else { - wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func); + wrapper = (func.length == 1 && isLaziable(func)) + ? wrapper[funcName]() + : wrapper.thru(func); } } return function() { @@ -4341,11 +4516,14 @@ * * @private * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to the new function. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [partialsRight] The arguments to append to those provided to the new function. + * @param {Array} [partialsRight] The arguments to append to those provided + * to the new function. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. * @param {number} [ary] The arity cap of `func`. @@ -4444,25 +4622,21 @@ * is truncated if the number of characters exceeds `length`. * * @private - * @param {string} string The string to create padding for. - * @param {number} [length=0] The padding length. + * @param {number} length The padding length. * @param {string} [chars=' '] The string used as padding. * @returns {string} Returns the padding for `string`. */ - function createPadding(string, length, chars) { - length = toInteger(length); - - var strLength = stringSize(string); - if (!length || strLength >= length) { - return ''; - } - var padLength = length - strLength; + function createPadding(length, chars) { chars = chars === undefined ? ' ' : (chars + ''); - var result = repeat(chars, nativeCeil(padLength / stringSize(chars))); + var charsLength = chars.length; + if (charsLength < 2) { + return charsLength ? baseRepeat(chars, length) : chars; + } + var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); return reHasComplexSymbol.test(chars) - ? stringToArray(result).slice(0, padLength).join('') - : result.slice(0, padLength); + ? stringToArray(result).slice(0, length).join('') + : result.slice(0, length); } /** @@ -4472,9 +4646,11 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {*} thisArg The `this` binding of `func`. - * @param {Array} partials The arguments to prepend to those provided to the new function. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. * @returns {Function} Returns the new wrapped function. */ function createPartialWrapper(func, bitmask, thisArg, partials) { @@ -4531,11 +4707,13 @@ * * @private * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` + * for more details. * @param {Function} wrapFunc The function to create the `func` wrapper. * @param {*} placeholder The placeholder value. * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to the new function. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. * @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. * @param {number} [ary] The arity cap of `func`. @@ -4694,7 +4872,8 @@ * @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 comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ @@ -4736,12 +4915,16 @@ // Recursively compare arrays (susceptible to call stack limits). if (isUnordered) { if (!arraySome(other, function(othValue) { - return arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack); + return arrValue === othValue || + equalFunc(arrValue, othValue, customizer, bitmask, stack); })) { result = false; break; } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, customizer, bitmask, stack) + )) { result = false; break; } @@ -4763,12 +4946,21 @@ * @param {string} tag The `toStringTag` of the objects to compare. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) { switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + case arrayBufferTag: if ((object.byteLength != other.byteLength) || !equalFunc(new Uint8Array(object), new Uint8Array(other))) { @@ -4778,8 +4970,9 @@ case boolTag: case dateTag: - // Coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + // Coerce dates and booleans to numbers, dates to milliseconds and + // booleans to `1` or `0` treating invalid dates coerced to `NaN` as + // not equal. return +object == +other; case errorTag: @@ -4791,8 +4984,8 @@ case regexpTag: case stringTag: - // Coerce regexes to strings and treat strings primitives and string - // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See https://es5.github.io/#x15.10.6.4 for more details. return object == (other + ''); case mapTag: @@ -4810,8 +5003,11 @@ if (stacked) { return stacked == other; } + bitmask |= UNORDERED_COMPARE_FLAG; + stack.set(object, other); + // Recursively compare objects (susceptible to call stack limits). - return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other)); + return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); case symbolTag: if (symbolValueOf) { @@ -4830,7 +5026,8 @@ * @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 comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ @@ -4896,6 +5093,29 @@ return result; } + /** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); + } + + /** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); + } + /** * Gets metadata for `func`. * @@ -4949,8 +5169,9 @@ /** * Gets the "length" property value of `object`. * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. + * **Note:** This function is used to avoid a + * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects + * Safari on at least iOS 8.1-8.3 ARM64. * * @private * @param {Object} object The object to query. @@ -5001,14 +5222,51 @@ } /** - * Creates an array of the own symbol properties of `object`. + * Gets the `[[Prototype]]` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {null|Object} Returns the `[[Prototype]]`. + */ + function getPrototype(value) { + return nativeGetPrototype(Object(value)); + } + + /** + * Creates an array of the own enumerable symbol properties of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ - var getSymbols = getOwnPropertySymbols || function() { - return []; + function getSymbols(object) { + // Coerce `object` to an object to avoid non-object errors in V8. + // See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details. + return getOwnPropertySymbols(Object(object)); + } + + // Fallback for IE < 11. + if (!getOwnPropertySymbols) { + getSymbols = function() { + return []; + }; + } + + /** + * Creates an array of the own and inherited enumerable symbol properties + * of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbolsIn = !getOwnPropertySymbols ? getSymbols : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; }; /** @@ -5022,8 +5280,11 @@ return objectToString.call(value); } - // Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps. - if ((Map && getTag(new Map) != mapTag) || + // Fallback for data views, maps, sets, and weak maps in IE 11, + // for data views in Edge, and promises in Node.js. + if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || (Set && getTag(new Set) != setTag) || (WeakMap && getTag(new WeakMap) != weakMapTag)) { getTag = function(value) { @@ -5033,7 +5294,9 @@ if (ctorString) { switch (ctorString) { + case dataViewCtorString: return dataViewTag; case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; case setCtorString: return setTag; case weakMapCtorString: return weakMapTag; } @@ -5086,10 +5349,16 @@ var result = hasFunc(object, path); if (!result && !isKey(path)) { path = baseCastPath(path); - object = parent(object, path); - if (object != null) { - path = last(path); - result = hasFunc(object, path); + + var index = -1, + length = path.length; + + while (object != null && ++index < length) { + var key = path[index]; + if (!(result = hasFunc(object, key))) { + break; + } + object = object[key]; } } var length = object ? object.length : undefined; @@ -5127,7 +5396,7 @@ */ function initCloneObject(object) { return (typeof object.constructor == 'function' && !isPrototype(object)) - ? baseCreate(getPrototypeOf(object)) + ? baseCreate(getPrototype(object)) : {}; } @@ -5140,10 +5409,11 @@ * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringTag` of the object to clone. + * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the initialized clone. */ - function initCloneByTag(object, tag, isDeep) { + function initCloneByTag(object, tag, cloneFunc, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: @@ -5153,13 +5423,16 @@ case dateTag: return new Ctor(+object); + case dataViewTag: + return cloneDataView(object, isDeep); + case float32Tag: case float64Tag: case int8Tag: case int16Tag: case int32Tag: case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: return cloneTypedArray(object, isDeep); case mapTag: - return cloneMap(object); + return cloneMap(object, isDeep, cloneFunc); case numberTag: case stringTag: @@ -5169,7 +5442,7 @@ return cloneRegExp(object); case setTag: - return cloneSet(object); + return cloneSet(object, isDeep, cloneFunc); case symbolTag: return cloneSymbol(object); @@ -5200,7 +5473,8 @@ * @param {*} value The potential iteratee value argument. * @param {*} index The potential iteratee index or key argument. * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. */ function isIterateeCall(value, index, object) { if (!isObject(object)) { @@ -5208,8 +5482,9 @@ } var type = typeof index; if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object)) { + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { return eq(object[index], value); } return false; @@ -5224,11 +5499,12 @@ * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ function isKey(value, object) { - if (typeof value == 'number') { + var type = typeof value; + if (type == 'number' || type == 'symbol') { return true; } return !isArray(value) && - (reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) || (object != null && value in Object(object))); } @@ -5250,7 +5526,8 @@ * * @private * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, + * else `false`. */ function isLaziable(func) { var funcName = getFuncName(func), @@ -5297,10 +5574,11 @@ * * Merging metadata reduces the number of wrappers used to invoke a function. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` - * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg` - * modify function arguments, making the order in which they are executed important, - * preventing the merging of metadata. However, we make an exception for a safe - * combined case where curried functions have `_.ary` and or `_.rearg` applied. + * may be applied regardless of execution order. Methods like `_.ary` and + * `_.rearg` modify function arguments, making the order in which they are + * executed important, preventing the merging of metadata. However, we make + * an exception for a safe combined case where curried functions have `_.ary` + * and or `_.rearg` applied. * * @private * @param {Array} data The destination metadata. @@ -5371,7 +5649,8 @@ * @param {string} key The key of the property to merge. * @param {Object} object The parent object of `objValue`. * @param {Object} source The parent object of `srcValue`. - * @param {Object} [stack] Tracks traversed source values and their merged counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. * @returns {*} Returns the value to assign. */ function mergeDefaults(objValue, srcValue, key, object, source, stack) { @@ -5390,7 +5669,7 @@ * @returns {*} Returns the parent value. */ function parent(object, path) { - return path.length == 1 ? object : get(object, baseSlice(path, 0, -1)); + return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); } /** @@ -5419,8 +5698,9 @@ * Sets metadata for `func`. * * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity function - * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070) + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) * for more details. * * @private @@ -5455,13 +5735,13 @@ * @param {string} string The string to convert. * @returns {Array} Returns the property path array. */ - function stringToPath(string) { + var stringToPath = memoize(function(string) { var result = []; toString(string).replace(rePropName, function(match, number, quote, string) { result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); }); return result; - } + }); /** * Creates a clone of `wrapper`. @@ -5490,6 +5770,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to process. * @param {number} [size=0] The length of each chunk. @@ -5525,6 +5806,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to compact. * @returns {Array} Returns the new array of filtered values. @@ -5554,6 +5836,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to concatenate. * @param {...*} [values] The values to concatenate. @@ -5569,22 +5852,29 @@ * console.log(array); * // => [1] */ - var concat = rest(function(array, values) { - if (!isArray(array)) { - array = array == null ? [] : [Object(array)]; + function concat() { + var length = arguments.length, + array = castArray(arguments[0]); + + if (length < 2) { + return length ? copyArray(array) : []; } - values = baseFlatten(values, 1); - return arrayConcat(array, values); - }); + var args = Array(length - 1); + while (length--) { + args[length - 1] = arguments[length]; + } + return arrayConcat(array, baseFlatten(args, 1)); + } /** - * Creates an array of unique `array` values not included in the other - * given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * Creates an array of unique `array` values not included in the other given + * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * for equality comparisons. The order of result values is determined by the * order they occur in the first array. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to inspect. * @param {...Array} [values] The values to exclude. @@ -5608,10 +5898,12 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {...Array} [values] The values to exclude. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of filtered values. * @example * @@ -5640,6 +5932,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {...Array} [values] The values to exclude. @@ -5667,10 +5960,11 @@ * * @static * @memberOf _ + * @since 0.5.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -5700,10 +5994,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -5736,9 +6031,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -5776,9 +6073,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -5817,6 +6116,7 @@ * * @static * @memberOf _ + * @since 3.2.0 * @category Array * @param {Array} array The array to fill. * @param {*} value The value to fill `array` with. @@ -5855,9 +6155,11 @@ * * @static * @memberOf _ + * @since 1.1.0 * @category Array * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {number} Returns the index of the found element, else `-1`. * @example * @@ -5894,9 +6196,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Array * @param {Array} array The array to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {number} Returns the index of the found element, else `-1`. * @example * @@ -5932,6 +6236,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. @@ -5950,6 +6255,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. @@ -5968,6 +6274,7 @@ * * @static * @memberOf _ + * @since 4.4.0 * @category Array * @param {Array} array The array to flatten. * @param {number} [depth=1] The maximum recursion depth. @@ -5997,6 +6304,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} pairs The key-value pairs. * @returns {Object} Returns the new object. @@ -6022,6 +6330,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @alias first * @category Array * @param {Array} array The array to query. @@ -6046,6 +6355,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6077,6 +6387,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to query. * @returns {Array} Returns the slice of `array`. @@ -6097,6 +6408,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of intersecting values. @@ -6120,9 +6432,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of intersecting values. * @example * @@ -6155,6 +6469,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -6186,6 +6501,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to convert. * @param {string} [separator=','] The element separator. @@ -6204,6 +6520,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to query. * @returns {*} Returns the last element of `array`. @@ -6223,6 +6540,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6245,7 +6563,11 @@ var index = length; if (fromIndex !== undefined) { index = toInteger(fromIndex); - index = (index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1)) + 1; + index = ( + index < 0 + ? nativeMax(length + index, 0) + : nativeMin(index, length - 1) + ) + 1; } if (value !== value) { return indexOfNaN(array, index, true); @@ -6268,6 +6590,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Array * @param {Array} array The array to modify. * @param {...*} [values] The values to remove. @@ -6289,6 +6612,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. @@ -6316,10 +6640,12 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns `array`. * @example * @@ -6344,6 +6670,7 @@ * * @static * @memberOf _ + * @since 4.6.0 * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. @@ -6371,6 +6698,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to modify. * @param {...(number|number[])} [indexes] The indexes of elements to remove, @@ -6405,9 +6733,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Array * @param {Array} array The array to modify. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new array of removed elements. * @example * @@ -6452,7 +6782,9 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array + * @param {Array} array The array to modify. * @returns {Array} Returns `array`. * @example * @@ -6471,11 +6803,13 @@ /** * Creates a slice of `array` from `start` up to, but not including, `end`. * - * **Note:** This method is used instead of [`Array#slice`](https://mdn.io/Array/slice) - * to ensure dense arrays are returned. + * **Note:** This method is used instead of + * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are + * returned. * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to slice. * @param {number} [start=0] The start position. @@ -6499,15 +6833,17 @@ } /** - * Uses a binary search to determine the lowest index at which `value` should - * be inserted into `array` in order to maintain its sort order. + * Uses a binary search to determine the lowest index at which `value` + * should be inserted into `array` in order to maintain its sort order. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * _.sortedIndex([30, 50], 40); @@ -6527,11 +6863,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 }; @@ -6553,6 +6892,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6580,10 +6920,12 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * _.sortedLastIndex([4, 5], 4); @@ -6600,11 +6942,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted into `array`. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * * // The `_.property` iteratee shorthand. @@ -6621,6 +6966,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to search. * @param {*} value The value to search for. @@ -6647,6 +6993,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @returns {Array} Returns the new duplicate free array. @@ -6667,6 +7014,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {Function} [iteratee] The iteratee invoked per element. @@ -6687,6 +7035,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to query. * @returns {Array} Returns the slice of `array`. @@ -6704,10 +7053,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -6736,10 +7086,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the slice of `array`. * @example * @@ -6767,14 +7118,16 @@ /** * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is invoked with three - * arguments: (value, index, array). + * taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -6812,9 +7165,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Array * @param {Array} array The array to query. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * @@ -6852,6 +7207,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of combined values. @@ -6866,14 +7222,17 @@ /** * This method is like `_.union` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by which - * uniqueness is computed. The iteratee is invoked with one argument: (value). + * invoked for each element of each `arrays` to generate the criterion by + * which uniqueness is computed. The iteratee is invoked with one argument: + * (value). * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of combined values. * @example * @@ -6899,6 +7258,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -6922,11 +7282,12 @@ /** * Creates a duplicate-free version of an array, using * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurrence of each element - * is kept. + * for equality comparisons, in which only the first occurrence of each + * element is kept. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to inspect. * @returns {Array} Returns the new duplicate free array. @@ -6948,9 +7309,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new duplicate free array. * @example * @@ -6974,6 +7337,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {Array} array The array to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -6998,6 +7362,7 @@ * * @static * @memberOf _ + * @since 1.2.0 * @category Array * @param {Array} array The array of grouped elements to process. * @returns {Array} Returns the new array of regrouped elements. @@ -7032,9 +7397,11 @@ * * @static * @memberOf _ + * @since 3.8.0 * @category Array * @param {Array} array The array of grouped elements to process. - * @param {Function} [iteratee=_.identity] The function to combine regrouped values. + * @param {Function} [iteratee=_.identity] The function to combine + * regrouped values. * @returns {Array} Returns the new array of regrouped elements. * @example * @@ -7064,6 +7431,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {Array} array The array to filter. * @param {...*} [values] The values to exclude. @@ -7080,12 +7448,14 @@ }); /** - * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * Creates an array of unique values that is the + * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) * of the given arrays. The order of result values is determined by the order * they occur in the arrays. * * @static * @memberOf _ + * @since 2.4.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of values. @@ -7100,14 +7470,17 @@ /** * This method is like `_.xor` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by which - * by which they're compared. The iteratee is invoked with one argument: (value). + * invoked for each element of each `arrays` to generate the criterion by + * which by which they're compared. The iteratee is invoked with one argument: + * (value). * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Array} Returns the new array of values. * @example * @@ -7133,6 +7506,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @param {Function} [comparator] The comparator invoked per element. @@ -7154,12 +7528,13 @@ }); /** - * Creates an array of grouped elements, the first of which contains the first - * elements of the given arrays, the second of which contains the second elements - * of the given arrays, and so on. + * Creates an array of grouped elements, the first of which contains the + * first elements of the given arrays, the second of which contains the + * second elements of the given arrays, and so on. * * @static * @memberOf _ + * @since 0.1.0 * @category Array * @param {...Array} [arrays] The arrays to process. * @returns {Array} Returns the new array of grouped elements. @@ -7172,12 +7547,13 @@ /** * This method is like `_.fromPairs` except that it accepts two arrays, - * one of property names and one of corresponding values. + * one of property identifiers and one of corresponding values. * * @static * @memberOf _ + * @since 0.4.0 * @category Array - * @param {Array} [props=[]] The property names. + * @param {Array} [props=[]] The property identifiers. * @param {Array} [values=[]] The property values. * @returns {Object} Returns the new object. * @example @@ -7194,8 +7570,9 @@ * * @static * @memberOf _ + * @since 4.1.0 * @category Array - * @param {Array} [props=[]] The property names. + * @param {Array} [props=[]] The property identifiers. * @param {Array} [values=[]] The property values. * @returns {Object} Returns the new object. * @example @@ -7214,6 +7591,7 @@ * * @static * @memberOf _ + * @since 3.8.0 * @category Array * @param {...Array} [arrays] The arrays to process. * @param {Function} [iteratee=_.identity] The function to combine grouped values. @@ -7236,11 +7614,13 @@ /*------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps `value` with explicit method chaining enabled. - * The result of such method chaining must be unwrapped with `_#value`. + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. * * @static * @memberOf _ + * @since 1.3.0 * @category Seq * @param {*} value The value to wrap. * @returns {Object} Returns the new `lodash` wrapper instance. @@ -7271,10 +7651,11 @@ /** * This method invokes `interceptor` and returns `value`. The interceptor * is invoked with one argument; (value). The purpose of this method is to - * "tap into" a method chain in order to modify intermediate results. + * "tap into" a method chain sequence in order to modify intermediate results. * * @static * @memberOf _ + * @since 0.1.0 * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. @@ -7298,10 +7679,11 @@ /** * This method is like `_.tap` except that it returns the result of `interceptor`. * The purpose of this method is to "pass thru" values replacing intermediate - * results in a method chain. + * results in a method chain sequence. * * @static * @memberOf _ + * @since 3.0.0 * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. @@ -7326,6 +7708,7 @@ * * @name at * @memberOf _ + * @since 1.0.0 * @category Seq * @param {...(string|string[])} [paths] The property paths of elements to pick, * specified individually or in arrays. @@ -7366,10 +7749,11 @@ }); /** - * Enables explicit method chaining on the wrapper object. + * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. * * @name chain * @memberOf _ + * @since 0.1.0 * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -7396,10 +7780,11 @@ } /** - * Executes the chained sequence and returns the wrapped result. + * Executes the chain sequence and returns the wrapped result. * * @name commit * @memberOf _ + * @since 3.2.0 * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -7424,33 +7809,13 @@ return new LodashWrapper(this.value(), this.__chain__); } - /** - * This method is the wrapper version of `_.flatMap`. - * - * @name flatMap - * @memberOf _ - * @category Seq - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function duplicate(n) { - * return [n, n]; - * } - * - * _([1, 2]).flatMap(duplicate).value(); - * // => [1, 1, 2, 2] - */ - function wrapperFlatMap(iteratee) { - return this.map(iteratee).flatten(); - } - /** * Gets the next value on a wrapped object following the * [iterator protocol](https://mdn.io/iteration_protocols#iterator). * * @name next * @memberOf _ + * @since 4.0.0 * @category Seq * @returns {Object} Returns the next iterator value. * @example @@ -7481,6 +7846,7 @@ * * @name Symbol.iterator * @memberOf _ + * @since 4.0.0 * @category Seq * @returns {Object} Returns the wrapper object. * @example @@ -7498,10 +7864,11 @@ } /** - * Creates a clone of the chained sequence planting `value` as the wrapped value. + * Creates a clone of the chain sequence planting `value` as the wrapped value. * * @name plant * @memberOf _ + * @since 3.2.0 * @category Seq * @param {*} value The value to plant. * @returns {Object} Returns the new `lodash` wrapper instance. @@ -7547,6 +7914,7 @@ * * @name reverse * @memberOf _ + * @since 0.1.0 * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -7578,10 +7946,11 @@ } /** - * Executes the chained sequence to extract the unwrapped value. + * Executes the chain sequence to resolve the unwrapped value. * * @name value * @memberOf _ + * @since 0.1.0 * @alias toJSON, valueOf * @category Seq * @returns {*} Returns the resolved unwrapped value. @@ -7604,9 +7973,11 @@ * * @static * @memberOf _ + * @since 0.5.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7627,19 +7998,22 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. * @example * * _.every([true, 1, null, 'yes'], Boolean); * // => false * * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false } + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * * // The `_.matches` iteratee shorthand. @@ -7664,14 +8038,16 @@ /** * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three arguments: - * (value, index|key, collection). + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @example * @@ -7702,14 +8078,16 @@ /** * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three arguments: - * (value, index|key, collection). + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {*} Returns the matched element, else `undefined`. * @example * @@ -7749,9 +8127,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Collection * @param {Array|Object} collection The collection to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {*} Returns the matched element, else `undefined`. * @example * @@ -7770,15 +8150,17 @@ } /** - * Creates an array of flattened values by running each element in `collection` - * through `iteratee` and concating its result to the other mapped values. - * The iteratee is invoked with three arguments: (value, index|key, collection). + * Creates a flattened array of values by running each element in `collection` + * through `iteratee` and flattening the mapped results. The iteratee is + * invoked with three arguments: (value, index|key, collection). * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new flattened array. * @example * @@ -7793,17 +8175,70 @@ return baseFlatten(map(collection, iteratee), 1); } + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDeep([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ + function flatMapDeep(collection, iteratee) { + return baseFlatten(map(collection, iteratee), INFINITY); + } + + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results up to `depth` times. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDepth([1, 2], duplicate, 2); + * // => [[1, 1], [2, 2]] + */ + function flatMapDepth(collection, iteratee, depth) { + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(map(collection, iteratee), depth); + } + /** * Iterates over elements of `collection` invoking `iteratee` for each element. * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning `false`. * - * **Note:** As with other "Collections" methods, objects with a "length" property - * are iterated like arrays. To avoid this behavior use `_.forIn` or `_.forOwn` - * for object iteration. + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. * * @static * @memberOf _ + * @since 0.1.0 * @alias each * @category Collection * @param {Array|Object} collection The collection to iterate over. @@ -7814,17 +8249,17 @@ * _([1, 2]).forEach(function(value) { * console.log(value); * }); - * // => logs `1` then `2` + * // => Logs `1` then `2`. * * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { * console.log(key); * }); - * // => logs 'a' then 'b' (iteration order is not guaranteed) + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forEach(collection, iteratee) { return (typeof iteratee == 'function' && isArray(collection)) ? arrayEach(collection, iteratee) - : baseEach(collection, baseCastFunction(iteratee)); + : baseEach(collection, getIteratee(iteratee)); } /** @@ -7833,6 +8268,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @alias eachRight * @category Collection * @param {Array|Object} collection The collection to iterate over. @@ -7843,12 +8279,12 @@ * _.forEachRight([1, 2], function(value) { * console.log(value); * }); - * // => logs `2` then `1` + * // => Logs `2` then `1`. */ function forEachRight(collection, iteratee) { return (typeof iteratee == 'function' && isArray(collection)) ? arrayEachRight(collection, iteratee) - : baseEachRight(collection, baseCastFunction(iteratee)); + : baseEachRight(collection, getIteratee(iteratee)); } /** @@ -7859,9 +8295,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7881,18 +8319,20 @@ }); /** - * Checks if `value` is in `collection`. If `collection` is a string it's checked - * for a substring of `value`, otherwise [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * Checks if `value` is in `collection`. If `collection` is a string it's + * checked for a substring of `value`, otherwise + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * is used for equality comparisons. If `fromIndex` is negative, it's used as * the offset from the end of `collection`. * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object|string} collection The collection to search. * @param {*} value The value to search for. * @param {number} [fromIndex=0] The index to search from. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. * @returns {boolean} Returns `true` if `value` is found, else `false`. * @example * @@ -7929,6 +8369,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Array|Function|string} path The path of the method to invoke or @@ -7964,9 +8405,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -8003,9 +8446,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new mapped array. * @example * @@ -8041,24 +8486,26 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} [iteratees=[_.identity]] The iteratees to sort by. + * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] + * The iteratees to sort by. * @param {string[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. * @returns {Array} Returns the new sorted array. * @example * * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 42 }, + * { 'user': 'fred', 'age': 40 }, * { 'user': 'barney', 'age': 36 } * ]; * * // Sort by `user` in ascending order and by `age` in descending order. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] */ function orderBy(collection, iteratees, orders, guard) { if (collection == null) { @@ -8082,9 +8529,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the array of grouped elements. * @example * @@ -8130,6 +8579,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -8161,6 +8611,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -8188,9 +8639,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @example * @@ -8227,6 +8680,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Collection * @param {Array|Object} collection The collection to sample. * @returns {*} Returns the random element. @@ -8248,6 +8702,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Collection * @param {Array|Object} collection The collection to sample. * @param {number} [n=0] The number of elements to sample. @@ -8284,6 +8739,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to shuffle. * @returns {Array} Returns the new shuffled array. @@ -8298,10 +8754,11 @@ /** * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable properties for objects. + * values or the number of own enumerable string keyed properties for objects. * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to inspect. * @returns {number} Returns the collection size. @@ -8324,6 +8781,12 @@ var result = collection.length; return (result && isString(collection)) ? stringSize(collection) : result; } + if (isObjectLike(collection)) { + var tag = getTag(collection); + if (tag == mapTag || tag == setTag) { + return collection.size; + } + } return keys(collection).length; } @@ -8334,11 +8797,14 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. - * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. * @example * * _.some([null, 0, 'yes', false], Boolean); @@ -8377,30 +8843,32 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[]|Object|Object[]|string|string[])} [iteratees=[_.identity]] - * The iteratees to sort by, specified individually or in arrays. + * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])} + * [iteratees=[_.identity]] The iteratees to sort by, specified individually + * or in arrays. * @returns {Array} Returns the new sorted array. * @example * * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 42 }, + * { 'user': 'fred', 'age': 40 }, * { 'user': 'barney', 'age': 34 } * ]; * * _.sortBy(users, function(o) { return o.user; }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] * * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] + * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] * * _.sortBy(users, 'user', function(o) { * return Math.floor(o.age / 10); * }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] */ var sortBy = rest(function(collection, iteratees) { if (collection == null) { @@ -8423,6 +8891,7 @@ * * @static * @memberOf _ + * @since 2.4.0 * @type {Function} * @category Date * @returns {number} Returns the timestamp. @@ -8431,7 +8900,7 @@ * _.defer(function(stamp) { * console.log(_.now() - stamp); * }, _.now()); - * // => logs the number of milliseconds it took for the deferred function to be invoked + * // => Logs the number of milliseconds it took for the deferred function to be invoked. */ var now = Date.now; @@ -8443,6 +8912,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {number} n The number of calls before `func` is invoked. * @param {Function} func The function to restrict. @@ -8458,7 +8928,7 @@ * _.forEach(saves, function(type) { * asyncSave({ 'type': type, 'complete': done }); * }); - * // => logs 'done saving!' after the two async saves have completed + * // => Logs 'done saving!' after the two async saves have completed. */ function after(n, func) { if (typeof func != 'function') { @@ -8478,10 +8948,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} func The function to cap arguments for. * @param {number} [n=func.length] The arity cap. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the new function. * @example * @@ -8501,6 +8972,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {number} n The number of calls at which `func` is no longer invoked. * @param {Function} func The function to restrict. @@ -8540,6 +9012,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to bind. * @param {*} thisArg The `this` binding of `func`. @@ -8576,8 +9049,8 @@ * any additional `_.bindKey` arguments to those provided to the bound function. * * This method differs from `_.bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. - * See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * methods that may be redefined or don't yet exist. See + * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) * for more details. * * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic @@ -8585,6 +9058,7 @@ * * @static * @memberOf _ + * @since 0.10.0 * @category Function * @param {Object} object The object to invoke the method on. * @param {string} key The key of the method. @@ -8638,10 +9112,11 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -8682,10 +9157,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} func The function to curry. * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the new curried function. * @example * @@ -8734,16 +9210,17 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to debounce. * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=false] Specify invoking on the leading - * edge of the timeout. - * @param {number} [options.maxWait] The maximum time `func` is allowed to be - * delayed before it's invoked. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. * @returns {Function} Returns the new debounced function. * @example * @@ -8765,14 +9242,12 @@ * jQuery(window).on('popstate', debounced.cancel); */ function debounce(func, wait, options) { - var args, - maxTimeoutId, + var lastArgs, + lastThis, result, - stamp, - thisArg, - timeoutId, - trailingCall, - lastCalled = 0, + timerId, + lastCallTime = 0, + lastInvokeTime = 0, leading = false, maxWait = false, trailing = true; @@ -8787,92 +9262,94 @@ trailing = 'trailing' in options ? !!options.trailing : trailing; } - function cancel() { - if (timeoutId) { - clearTimeout(timeoutId); - } - if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - } - lastCalled = 0; - args = maxTimeoutId = thisArg = timeoutId = trailingCall = undefined; + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; } - function complete(isCalled, id) { - if (id) { - clearTimeout(id); - } - maxTimeoutId = timeoutId = trailingCall = undefined; - if (isCalled) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = undefined; - } - } + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; } - function delayed() { - var remaining = wait - (now() - stamp); - if (remaining <= 0 || remaining > wait) { - complete(trailingCall, maxTimeoutId); - } else { - timeoutId = setTimeout(delayed, remaining); + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + result = wait - timeSinceLastCall; + + return maxWait === false ? result : nativeMin(result, maxWait - timeSinceLastInvoke); + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (!lastCallTime || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxWait !== false && timeSinceLastInvoke >= maxWait)); + } + + function timerExpired() { + var time = now(); + if (shouldInvoke(time)) { + return trailingEdge(time); } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); } - function flush() { - if ((timeoutId && trailingCall) || (maxTimeoutId && trailing)) { - result = func.apply(thisArg, args); + function trailingEdge(time) { + clearTimeout(timerId); + timerId = undefined; + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); } - cancel(); + lastArgs = lastThis = undefined; return result; } - function maxDelayed() { - complete(trailing, timeoutId); + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastCallTime = lastInvokeTime = 0; + lastArgs = lastThis = timerId = undefined; } - function debounced() { - args = arguments; - stamp = now(); - thisArg = this; - trailingCall = trailing && (timeoutId || !leading); + function flush() { + return timerId === undefined ? result : trailingEdge(now()); + } - if (maxWait === false) { - var leadingCall = leading && !timeoutId; - } else { - if (!lastCalled && !maxTimeoutId && !leading) { - lastCalled = stamp; - } - var remaining = maxWait - (stamp - lastCalled); + function debounced() { + var time = now(), + isInvoking = shouldInvoke(time); - var isCalled = (remaining <= 0 || remaining > maxWait) && - (leading || maxTimeoutId); + lastArgs = arguments; + lastThis = this; + lastCallTime = time; - if (isCalled) { - if (maxTimeoutId) { - maxTimeoutId = clearTimeout(maxTimeoutId); - } - lastCalled = stamp; - result = func.apply(thisArg, args); + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); } - else if (!maxTimeoutId) { - maxTimeoutId = setTimeout(maxDelayed, remaining); - } - } - if (isCalled && timeoutId) { - timeoutId = clearTimeout(timeoutId); - } - else if (!timeoutId && wait !== maxWait) { - timeoutId = setTimeout(delayed, wait); - } - if (leadingCall) { - isCalled = true; - result = func.apply(thisArg, args); - } - if (isCalled && !timeoutId && !maxTimeoutId) { - args = thisArg = undefined; + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); } return result; } @@ -8887,6 +9364,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to defer. * @param {...*} [args] The arguments to invoke `func` with. @@ -8896,7 +9374,7 @@ * _.defer(function(text) { * console.log(text); * }, 'deferred'); - * // => logs 'deferred' after one or more milliseconds + * // => Logs 'deferred' after one or more milliseconds. */ var defer = rest(function(func, args) { return baseDelay(func, 1, args); @@ -8908,6 +9386,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. @@ -8918,7 +9397,7 @@ * _.delay(function(text) { * console.log(text); * }, 1000, 'later'); - * // => logs 'later' after one second + * // => Logs 'later' after one second. */ var delay = rest(function(func, wait, args) { return baseDelay(func, toNumber(wait) || 0, args); @@ -8929,6 +9408,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Function * @param {Function} func The function to flip arguments for. * @returns {Function} Returns the new function. @@ -8954,11 +9434,13 @@ * * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) * method interface of `delete`, `get`, `has`, and `set`. * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to have its output memoized. * @param {Function} [resolver] The function to resolve the cache key. @@ -9003,10 +9485,13 @@ memoized.cache = cache.set(key, result); return result; }; - memoized.cache = new memoize.Cache; + memoized.cache = new (memoize.Cache || MapCache); return memoized; } + // Assign cache to `_.memoize`. + memoize.Cache = MapCache; + /** * Creates a function that negates the result of the predicate `func`. The * `func` predicate is invoked with the `this` binding and arguments of the @@ -9014,6 +9499,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} predicate The predicate to negate. * @returns {Function} Returns the new function. @@ -9042,6 +9528,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to restrict. * @returns {Function} Returns the new restricted function. @@ -9061,6 +9548,7 @@ * corresponding `transforms`. * * @static + * @since 4.0.0 * @memberOf _ * @category Function * @param {Function} func The function to wrap. @@ -9115,6 +9603,7 @@ * * @static * @memberOf _ + * @since 0.2.0 * @category Function * @param {Function} func The function to partially apply arguments to. * @param {...*} [partials] The arguments to be partially applied. @@ -9151,6 +9640,7 @@ * * @static * @memberOf _ + * @since 1.0.0 * @category Function * @param {Function} func The function to partially apply arguments to. * @param {...*} [partials] The arguments to be partially applied. @@ -9183,6 +9673,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Function * @param {Function} func The function to rearrange arguments for. * @param {...(number|number[])} indexes The arranged argument indexes, @@ -9203,12 +9694,15 @@ /** * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as an array. + * created function and arguments from `start` and beyond provided as + * an array. * - * **Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters). + * **Note:** This method is based on the + * [rest parameter](https://mdn.io/rest_parameters). * * @static * @memberOf _ + * @since 4.0.0 * @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. @@ -9253,13 +9747,16 @@ } /** - * 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). + * Creates a function that invokes `func` with the `this` binding of the + * create 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://mdn.io/spread_operator). + * **Note:** This method is based on the + * [spread operator](https://mdn.io/spread_operator). * * @static * @memberOf _ + * @since 3.2.0 * @category Function * @param {Function} func The function to spread arguments over. * @param {number} [start=0] The start position of the spread. @@ -9309,23 +9806,24 @@ * throttled function. Subsequent calls to the throttled function return the * result of the last `func` invocation. * - * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked - * on the trailing edge of the timeout only if the throttled function is - * invoked more than once during the `wait` timeout. + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the throttled function + * is invoked more than once during the `wait` timeout. * * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) * for details over the differences between `_.throttle` and `_.debounce`. * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {Function} func The function to throttle. * @param {number} [wait=0] The number of milliseconds to throttle invocations to. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=true] Specify invoking on the leading - * edge of the timeout. - * @param {boolean} [options.trailing=true] Specify invoking on the trailing - * edge of the timeout. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=true] + * Specify invoking on the leading edge of the timeout. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. * @returns {Function} Returns the new throttled function. * @example * @@ -9363,6 +9861,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Function * @param {Function} func The function to cap arguments for. * @returns {Function} Returns the new function. @@ -9383,6 +9882,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Function * @param {*} value The value to wrap. * @param {Function} [wrapper=identity] The wrapper function. @@ -9408,6 +9908,7 @@ * * @static * @memberOf _ + * @since 4.4.0 * @category Lang * @param {*} value The value to inspect. * @returns {Array} Returns the cast array. @@ -9456,6 +9957,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to clone. * @returns {*} Returns the cloned value. @@ -9479,6 +9981,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to clone. * @param {Function} [customizer] The function to customize cloning. @@ -9509,6 +10012,7 @@ * * @static * @memberOf _ + * @since 1.0.0 * @category Lang * @param {*} value The value to recursively clone. * @returns {*} Returns the deep cloned value. @@ -9529,6 +10033,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to recursively clone. * @param {Function} [customizer] The function to customize cloning. @@ -9555,11 +10060,13 @@ } /** - * Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. @@ -9593,10 +10100,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. * @example * * _.gt(3, 1); @@ -9617,10 +10126,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is greater than or equal to + * `other`, else `false`. * @example * * _.gte(3, 1); @@ -9641,9 +10152,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArguments(function() { return arguments; }()); @@ -9663,10 +10176,12 @@ * * @static * @memberOf _ + * @since 0.1.0 * @type {Function} * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArray([1, 2, 3]); @@ -9688,9 +10203,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArrayBuffer(new ArrayBuffer(2)); @@ -9710,6 +10227,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. @@ -9737,9 +10255,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. * @example * * _.isArrayLikeObject([1, 2, 3]); @@ -9763,9 +10283,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isBoolean(false); @@ -9784,6 +10306,7 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. @@ -9804,9 +10327,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isDate(new Date); @@ -9824,9 +10349,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. + * @returns {boolean} Returns `true` if `value` is a DOM element, + * else `false`. * @example * * _.isElement(document.body); @@ -9840,12 +10367,18 @@ } /** - * Checks if `value` is an empty collection or object. A value is considered - * empty if it's an `arguments` object, array, string, or jQuery-like collection - * with a length of `0` or has no own enumerable properties. + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is empty, else `false`. @@ -9868,16 +10401,22 @@ */ function isEmpty(value) { if (isArrayLike(value) && - (isArray(value) || isString(value) || - isFunction(value.splice) || isArguments(value))) { + (isArray(value) || isString(value) || isFunction(value.splice) || + isArguments(value) || isBuffer(value))) { return !value.length; } + if (isObjectLike(value)) { + var tag = getTag(value); + if (tag == mapTag || tag == setTag) { + return !value.size; + } + } for (var key in value) { if (hasOwnProperty.call(value, key)) { return false; } } - return true; + return !(nonEnumShadows && keys(value).length); } /** @@ -9892,10 +10431,12 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, + * else `false`. * @example * * var object = { 'user': 'fred' }; @@ -9919,11 +10460,13 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, + * else `false`. * @example * * function isGreeting(value) { @@ -9954,9 +10497,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. + * @returns {boolean} Returns `true` if `value` is an error object, + * else `false`. * @example * * _.isError(new Error); @@ -9976,13 +10521,16 @@ /** * Checks if `value` is a finite primitive number. * - * **Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite). + * **Note:** This method is based on + * [`Number.isFinite`](https://mdn.io/Number/isFinite). * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @returns {boolean} Returns `true` if `value` is a finite number, + * else `false`. * @example * * _.isFinite(3); @@ -10006,9 +10554,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isFunction(_); @@ -10028,10 +10578,12 @@ /** * Checks if `value` is an integer. * - * **Note:** This method is based on [`Number.isInteger`](https://mdn.io/Number/isInteger). + * **Note:** This method is based on + * [`Number.isInteger`](https://mdn.io/Number/isInteger). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an integer, else `false`. @@ -10056,13 +10608,16 @@ /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This function is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @returns {boolean} Returns `true` if `value` is a valid length, + * else `false`. * @example * * _.isLength(3); @@ -10088,6 +10643,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. @@ -10116,6 +10672,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. @@ -10142,9 +10699,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isMap(new Map); @@ -10166,6 +10725,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {Object} object The object to inspect. * @param {Object} source The object of property values to match. @@ -10192,6 +10752,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {Object} object The object to inspect. * @param {Object} source The object of property values to match. @@ -10223,11 +10784,13 @@ /** * Checks if `value` is `NaN`. * - * **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4) - * which returns `true` for `undefined` and other non-numeric values. + * **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 _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. @@ -10247,7 +10810,8 @@ */ function isNaN(value) { // An `NaN` primitive is the only value that is not equal to itself. - // Perform the `toStringTag` check first to avoid errors with some ActiveX objects in IE. + // Perform the `toStringTag` check first to avoid errors with some + // ActiveX objects in IE. return isNumber(value) && value != +value; } @@ -10256,9 +10820,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. * @example * * _.isNative(Array.prototype.push); @@ -10283,6 +10849,7 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `null`, else `false`. @@ -10303,6 +10870,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is nullish, else `false`. @@ -10324,14 +10892,16 @@ /** * Checks if `value` is classified as a `Number` primitive or object. * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified - * as numbers, use the `_.isFinite` method. + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are + * classified as numbers, use the `_.isFinite` method. * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isNumber(3); @@ -10357,9 +10927,11 @@ * * @static * @memberOf _ + * @since 0.8.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @returns {boolean} Returns `true` if `value` is a plain object, + * else `false`. * @example * * function Foo() { @@ -10383,11 +10955,11 @@ objectToString.call(value) != objectTag || isHostObject(value)) { return false; } - var proto = getPrototypeOf(value); + var proto = getPrototype(value); if (proto === null) { return true; } - var Ctor = proto.constructor; + var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; return (typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); } @@ -10397,9 +10969,11 @@ * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isRegExp(/abc/); @@ -10416,13 +10990,16 @@ * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 * double precision number which isn't the result of a rounded unsafe integer. * - * **Note:** This method is based on [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). + * **Note:** This method is based on + * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. + * @returns {boolean} Returns `true` if `value` is a safe integer, + * else `false`. * @example * * _.isSafeInteger(3); @@ -10446,9 +11023,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isSet(new Set); @@ -10465,10 +11044,12 @@ * Checks if `value` is classified as a `String` primitive or object. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isString('abc'); @@ -10487,9 +11068,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isSymbol(Symbol.iterator); @@ -10508,9 +11091,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isTypedArray(new Uint8Array); @@ -10528,6 +11113,7 @@ * Checks if `value` is `undefined`. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. @@ -10549,9 +11135,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isWeakMap(new WeakMap); @@ -10569,9 +11157,11 @@ * * @static * @memberOf _ + * @since 4.3.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isWeakSet(new WeakSet); @@ -10589,10 +11179,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. * @example * * _.lt(1, 3); @@ -10613,10 +11205,12 @@ * * @static * @memberOf _ + * @since 3.9.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than or equal to `other`, else `false`. + * @returns {boolean} Returns `true` if `value` is less than or equal to + * `other`, else `false`. * @example * * _.lte(1, 3); @@ -10636,6 +11230,7 @@ * Converts `value` to an array. * * @static + * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to convert. @@ -10673,10 +11268,12 @@ /** * Converts `value` to an integer. * - * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). + * **Note:** This function is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. @@ -10711,10 +11308,12 @@ * Converts `value` to an integer suitable for use as the length of an * array-like object. * - * **Note:** This method is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This method is based on + * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. @@ -10741,6 +11340,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {number} Returns the number. @@ -10759,12 +11359,18 @@ * // => 3 */ function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } if (isObject(value)) { var other = isFunction(value.valueOf) ? value.valueOf() : value; value = isObject(other) ? (other + '') : other; } if (typeof value != 'string') { - return value === 0 ? value : +value; + return value === 0 ? value : +value; } value = value.replace(reTrim, ''); var isBinary = reIsBinary.test(value); @@ -10774,11 +11380,12 @@ } /** - * Converts `value` to a plain object flattening inherited enumerable - * properties of `value` to own properties of the plain object. + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. * * @static * @memberOf _ + * @since 3.0.0 * @category Lang * @param {*} value The value to convert. * @returns {Object} Returns the converted plain object. @@ -10806,6 +11413,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. @@ -10833,6 +11441,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {string} Returns the string. @@ -10865,15 +11474,16 @@ /*------------------------------------------------------------------------*/ /** - * Assigns own enumerable properties of source objects to the destination - * object. Source objects are applied from left to right. Subsequent sources - * overwrite property assignments of previous sources. + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object` and is loosely based on * [`Object.assign`](https://mdn.io/Object/assign). * * @static * @memberOf _ + * @since 0.10.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. @@ -10914,6 +11524,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @alias extend * @category Object * @param {Object} object The destination object. @@ -10946,15 +11557,16 @@ }); /** - * This method is like `_.assignIn` except that it accepts `customizer` which - * is invoked to produce the assigned values. If `customizer` returns `undefined` - * assignment is handled by the method instead. The `customizer` is invoked - * with five arguments: (objValue, srcValue, key, object, source). + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined` assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). * * **Note:** This method mutates `object`. * * @static * @memberOf _ + * @since 4.0.0 * @alias extendWith * @category Object * @param {Object} object The destination object. @@ -10977,15 +11589,16 @@ }); /** - * This method is like `_.assign` except that it accepts `customizer` which - * is invoked to produce the assigned values. If `customizer` returns `undefined` - * assignment is handled by the method instead. The `customizer` is invoked - * with five arguments: (objValue, srcValue, key, object, source). + * This method is like `_.assign` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined` assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). * * **Note:** This method mutates `object`. * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The destination object. * @param {...Object} sources The source objects. @@ -11011,6 +11624,7 @@ * * @static * @memberOf _ + * @since 1.0.0 * @category Object * @param {Object} object The object to iterate over. * @param {...(string|string[])} [paths] The property paths of elements to pick, @@ -11031,11 +11645,13 @@ }); /** - * Creates an object that inherits from the `prototype` object. If a `properties` - * object is given its own enumerable properties are assigned to the created object. + * Creates an object that inherits from the `prototype` object. If a + * `properties` object is given its own enumerable string keyed properties + * are assigned to the created object. * * @static * @memberOf _ + * @since 2.3.0 * @category Object * @param {Object} prototype The object to inherit from. * @param {Object} [properties] The properties to assign to the object. @@ -11068,14 +11684,15 @@ } /** - * Assigns own and inherited enumerable properties of source objects to the - * destination object for all destination properties that resolve to `undefined`. - * Source objects are applied from left to right. Once a property is set, - * additional values of the same property are ignored. + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. * * **Note:** This method mutates `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The destination object. @@ -11099,6 +11716,7 @@ * * @static * @memberOf _ + * @since 3.10.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. @@ -11120,10 +11738,13 @@ * * @static * @memberOf _ + * @since 1.1.0 * @category Object * @param {Object} object The object to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, else `undefined`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. * @example * * var users = { @@ -11157,10 +11778,13 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Object * @param {Object} object The object to search. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, else `undefined`. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. * @example * * var users = { @@ -11189,13 +11813,14 @@ } /** - * Iterates over own and inherited enumerable properties of an object invoking - * `iteratee` for each property. The iteratee is invoked with three arguments: - * (value, key, object). Iteratee functions may exit iteration early by explicitly - * returning `false`. + * Iterates over own and inherited enumerable string keyed properties of an + * object invoking `iteratee` for each property. The iteratee is invoked with + * three arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. * * @static * @memberOf _ + * @since 0.3.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11212,12 +11837,12 @@ * _.forIn(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'a', 'b', then 'c' (iteration order is not guaranteed) + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). */ function forIn(object, iteratee) { return object == null ? object - : baseFor(object, baseCastFunction(iteratee), keysIn); + : baseFor(object, getIteratee(iteratee), keysIn); } /** @@ -11226,6 +11851,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11242,22 +11868,23 @@ * _.forInRight(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c' + * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. */ function forInRight(object, iteratee) { return object == null ? object - : baseForRight(object, baseCastFunction(iteratee), keysIn); + : baseForRight(object, getIteratee(iteratee), keysIn); } /** - * Iterates over own enumerable properties of an object invoking `iteratee` - * for each property. The iteratee is invoked with three arguments: + * Iterates over own enumerable string keyed properties of an object invoking + * `iteratee` for each property. The iteratee is invoked with three arguments: * (value, key, object). Iteratee functions may exit iteration early by * explicitly returning `false`. * * @static * @memberOf _ + * @since 0.3.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11274,10 +11901,10 @@ * _.forOwn(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'a' then 'b' (iteration order is not guaranteed) + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forOwn(object, iteratee) { - return object && baseForOwn(object, baseCastFunction(iteratee)); + return object && baseForOwn(object, getIteratee(iteratee)); } /** @@ -11286,6 +11913,7 @@ * * @static * @memberOf _ + * @since 2.0.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -11302,10 +11930,10 @@ * _.forOwnRight(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b' + * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. */ function forOwnRight(object, iteratee) { - return object && baseForOwnRight(object, baseCastFunction(iteratee)); + return object && baseForOwnRight(object, getIteratee(iteratee)); } /** @@ -11313,6 +11941,7 @@ * of `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to inspect. @@ -11339,6 +11968,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to inspect. * @returns {Array} Returns the new array of property names. @@ -11364,10 +11994,11 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. * @returns {*} Returns the resolved value. * @example * @@ -11391,6 +12022,7 @@ * Checks if `path` is a direct property of `object`. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -11422,6 +12054,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path to check. @@ -11448,11 +12081,12 @@ /** * Creates an object composed of the inverted keys and values of `object`. - * If `object` contains duplicate values, subsequent values overwrite property - * assignments of previous values. + * If `object` contains duplicate values, subsequent values overwrite + * property assignments of previous values. * * @static * @memberOf _ + * @since 0.7.0 * @category Object * @param {Object} object The object to invert. * @returns {Object} Returns the new inverted object. @@ -11476,9 +12110,11 @@ * * @static * @memberOf _ + * @since 4.1.0 * @category Object * @param {Object} object The object to invert. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {Object} Returns the new inverted object. * @example * @@ -11505,6 +12141,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the method to invoke. @@ -11527,6 +12164,7 @@ * for more details. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -11573,6 +12211,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. @@ -11611,14 +12250,16 @@ /** * The opposite of `_.mapValues`; this method creates an object with the * same values as `object` and keys generated by running each own enumerable - * property of `object` through `iteratee`. The iteratee is invoked with - * three arguments: (value, key, object). + * string keyed property of `object` through `iteratee`. The iteratee is + * invoked with three arguments: (value, key, object). * * @static * @memberOf _ + * @since 3.8.0 * @category Object * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Object} Returns the new mapped object. * @example * @@ -11639,14 +12280,17 @@ /** * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through `iteratee`. The - * iteratee is invoked with three arguments: (value, key, object). + * running each own enumerable string keyed property of `object` through + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). * * @static * @memberOf _ + * @since 2.4.0 * @category Object * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The function invoked per iteration. * @returns {Object} Returns the new mapped object. * @example * @@ -11674,17 +12318,18 @@ /** * This method is like `_.assign` except that it recursively merges own and - * inherited enumerable properties of source objects into the destination - * object. Source properties that resolve to `undefined` are skipped if a - * destination value exists. Array and plain object properties are merged - * recursively.Other objects and value types are overridden by assignment. - * Source objects are applied from left to right. Subsequent sources - * overwrite property assignments of previous sources. + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively.Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object`. * * @static * @memberOf _ + * @since 0.5.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. @@ -11717,6 +12362,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The destination object. * @param {...Object} sources The source objects. @@ -11749,14 +12395,16 @@ /** * The opposite of `_.pick`; this method creates an object composed of the - * own and inherited enumerable properties of `object` that are not omitted. + * own and inherited enumerable string keyed properties of `object` that are + * not omitted. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The source object. - * @param {...(string|string[])} [props] The property names to omit, specified - * individually or in arrays. + * @param {...(string|string[])} [props] The property identifiers to omit, + * specified individually or in arrays. * @returns {Object} Returns the new object. * @example * @@ -11769,21 +12417,23 @@ if (object == null) { return {}; } - props = arrayMap(baseFlatten(props, 1), String); - return basePick(object, baseDifference(keysIn(object), props)); + props = arrayMap(baseFlatten(props, 1), baseCastKey); + return basePick(object, baseDifference(getAllKeysIn(object), props)); }); /** * The opposite of `_.pickBy`; this method creates an object composed of - * the own and inherited enumerable properties of `object` that `predicate` - * doesn't return truthy for. The predicate is invoked with two arguments: - * (value, key). + * the own and inherited enumerable string keyed properties of `object` that + * `predicate` doesn't return truthy for. The predicate is invoked with two + * arguments: (value, key). * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The source object. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per property. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per property. * @returns {Object} Returns the new object. * @example * @@ -11803,11 +12453,12 @@ * Creates an object composed of the picked `object` properties. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The source object. - * @param {...(string|string[])} [props] The property names to pick, specified - * individually or in arrays. + * @param {...(string|string[])} [props] The property identifiers to pick, + * specified individually or in arrays. * @returns {Object} Returns the new object. * @example * @@ -11826,9 +12477,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The source object. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per property. + * @param {Array|Function|Object|string} [predicate=_.identity] + * The function invoked per property. * @returns {Object} Returns the new object. * @example * @@ -11842,16 +12495,17 @@ } /** - * This method is like `_.get` except that if the resolved value is a function - * it's invoked with the `this` binding of its parent object and its result - * is returned. + * This method is like `_.get` except that if the resolved value is a + * function it's invoked with the `this` binding of its parent object and + * its result is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. * @returns {*} Returns the resolved value. * @example * @@ -11870,17 +12524,25 @@ * // => 'default' */ function result(object, path, defaultValue) { - if (!isKey(path, object)) { - path = baseCastPath(path); - var result = get(object, path); - object = parent(object, path); - } else { - result = object == null ? undefined : object[path]; + path = isKey(path, object) ? [path] : baseCastPath(path); + + var index = -1, + length = path.length; + + // Ensure the loop is entered when path is empty. + if (!length) { + object = undefined; + length = 1; } - if (result === undefined) { - result = defaultValue; + while (++index < length) { + var value = object == null ? undefined : object[path[index]]; + if (value === undefined) { + index = length; + value = defaultValue; + } + object = isFunction(value) ? value.call(object) : value; } - return isFunction(result) ? result.call(object) : result; + return object; } /** @@ -11893,6 +12555,7 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -11924,6 +12587,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -11943,11 +12607,13 @@ } /** - * Creates an array of own enumerable key-value pairs for `object` which - * can be consumed by `_.fromPairs`. + * Creates an array of own enumerable string keyed-value pairs for `object` + * which can be consumed by `_.fromPairs`. * * @static * @memberOf _ + * @since 4.0.0 + * @alias entries * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the new array of key-value pairs. @@ -11968,11 +12634,13 @@ } /** - * Creates an array of own and inherited enumerable key-value pairs for - * `object` which can be consumed by `_.fromPairs`. + * Creates an array of own and inherited enumerable string keyed-value pairs + * for `object` which can be consumed by `_.fromPairs`. * * @static * @memberOf _ + * @since 4.0.0 + * @alias entriesIn * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the new array of key-value pairs. @@ -11995,13 +12663,14 @@ /** * 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 invoked with four arguments: + * string keyed properties through `iteratee`, with each invocation potentially + * mutating the `accumulator` object. The iteratee is invoked with four arguments: * (accumulator, value, key, object). Iteratee functions may exit iteration * early by explicitly returning `false`. * * @static * @memberOf _ + * @since 1.3.0 * @category Object * @param {Array|Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. @@ -12030,7 +12699,7 @@ if (isArr) { accumulator = isArray(object) ? new Ctor : []; } else { - accumulator = isFunction(Ctor) ? baseCreate(getPrototypeOf(object)) : {}; + accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; } } else { accumulator = {}; @@ -12049,6 +12718,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to unset. @@ -12081,6 +12751,7 @@ * * @static * @memberOf _ + * @since 4.6.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -12112,6 +12783,7 @@ * * @static * @memberOf _ + * @since 4.6.0 * @category Object * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. @@ -12131,11 +12803,12 @@ } /** - * Creates an array of the own enumerable property values of `object`. + * Creates an array of the own enumerable string keyed property values of `object`. * * **Note:** Non-object values are coerced to objects. * * @static + * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. @@ -12160,12 +12833,14 @@ } /** - * Creates an array of the own and inherited enumerable property values of `object`. + * Creates an array of the own and inherited enumerable string keyed property + * values of `object`. * * **Note:** Non-object values are coerced to objects. * * @static * @memberOf _ + * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. @@ -12192,6 +12867,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Number * @param {number} number The number to clamp. * @param {number} [lower] The lower bound. @@ -12229,6 +12905,7 @@ * * @static * @memberOf _ + * @since 3.3.0 * @category Number * @param {number} number The number to check. * @param {number} [start=0] The start of the range. @@ -12272,14 +12949,15 @@ /** * Produces a random number between the inclusive `lower` and `upper` bounds. * If only one argument is provided a number between `0` and the given number - * is returned. If `floating` is `true`, or either `lower` or `upper` are floats, - * a floating-point number is returned instead of an integer. + * is returned. If `floating` is `true`, or either `lower` or `upper` are + * floats, a floating-point number is returned instead of an integer. * * **Note:** JavaScript follows the IEEE-754 standard for resolving * floating-point values which can produce unexpected results. * * @static * @memberOf _ + * @since 0.7.0 * @category Number * @param {number} [lower=0] The lower bound. * @param {number} [upper=1] The upper bound. @@ -12345,6 +13023,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the camel cased string. @@ -12353,10 +13032,10 @@ * _.camelCase('Foo Bar'); * // => 'fooBar' * - * _.camelCase('--foo-bar'); + * _.camelCase('--foo-bar--'); * // => 'fooBar' * - * _.camelCase('__foo_bar__'); + * _.camelCase('__FOO_BAR__'); * // => 'fooBar' */ var camelCase = createCompounder(function(result, word, index) { @@ -12370,6 +13049,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to capitalize. * @returns {string} Returns the capitalized string. @@ -12383,11 +13063,14 @@ } /** - * 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). + * 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 _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to deburr. * @returns {string} Returns the deburred string. @@ -12406,11 +13089,13 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to search. * @param {string} [target] The string to search for. * @param {number} [position=string.length] The position to search from. - * @returns {boolean} Returns `true` if `string` ends with `target`, else `false`. + * @returns {boolean} Returns `true` if `string` ends with `target`, + * else `false`. * @example * * _.endsWith('abc', 'c'); @@ -12444,20 +13129,22 @@ * * Though the ">" character is escaped for symmetry, characters like * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. - * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * unless they're part of a tag or unquoted attribute value. See + * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. * * Backticks are escaped because in IE < 9, they can break out of * attribute values or HTML comments. See [#59](https://html5sec.org/#59), * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and - * [#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/) - * for more details. + * [#133](https://html5sec.org/#133) of the + * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details. * - * When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping) - * to reduce XSS vectors. + * When working with HTML you should always + * [quote attribute values](http://wonko.com/post/html-escaping) to reduce + * XSS vectors. * * @static + * @since 0.1.0 * @memberOf _ * @category String * @param {string} [string=''] The string to escape. @@ -12480,6 +13167,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to escape. * @returns {string} Returns the escaped string. @@ -12496,10 +13184,12 @@ } /** - * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * Converts `string` to + * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the kebab cased string. @@ -12511,7 +13201,7 @@ * _.kebabCase('fooBar'); * // => 'foo-bar' * - * _.kebabCase('__foo_bar__'); + * _.kebabCase('__FOO_BAR__'); * // => 'foo-bar' */ var kebabCase = createCompounder(function(result, word, index) { @@ -12523,12 +13213,13 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the lower cased string. * @example * - * _.lowerCase('--Foo-Bar'); + * _.lowerCase('--Foo-Bar--'); * // => 'foo bar' * * _.lowerCase('fooBar'); @@ -12546,6 +13237,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the converted string. @@ -12559,30 +13251,13 @@ */ var lowerFirst = createCaseFirst('toLowerCase'); - /** - * Converts the first character of `string` to upper case. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.upperFirst('fred'); - * // => 'Fred' - * - * _.upperFirst('FRED'); - * // => 'FRED' - */ - var upperFirst = createCaseFirst('toUpperCase'); - /** * Pads `string` on the left and right sides if it's shorter than `length`. * Padding characters are truncated if they can't be evenly divided by `length`. * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to pad. * @param {number} [length=0] The padding length. @@ -12603,15 +13278,16 @@ string = toString(string); length = toInteger(length); - var strLength = stringSize(string); + var strLength = length ? stringSize(string) : 0; if (!length || strLength >= length) { return string; } - var mid = (length - strLength) / 2, - leftLength = nativeFloor(mid), - rightLength = nativeCeil(mid); - - return createPadding('', leftLength, chars) + string + createPadding('', rightLength, chars); + var mid = (length - strLength) / 2; + return ( + createPadding(nativeFloor(mid), chars) + + string + + createPadding(nativeCeil(mid), chars) + ); } /** @@ -12620,6 +13296,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to pad. * @param {number} [length=0] The padding length. @@ -12638,7 +13315,12 @@ */ function padEnd(string, length, chars) { string = toString(string); - return string + createPadding(string, length, chars); + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (string + createPadding(length - strLength, chars)) + : string; } /** @@ -12647,6 +13329,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to pad. * @param {number} [length=0] The padding length. @@ -12665,23 +13348,29 @@ */ function padStart(string, length, chars) { string = toString(string); - return createPadding(string, length, chars) + string; + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (createPadding(length - strLength, chars) + string) + : string; } /** * 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. + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a + * hexadecimal, in which case a `radix` of `16` is used. * - * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2) - * of `parseInt`. + * **Note:** This method aligns with the + * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. * * @static * @memberOf _ + * @since 1.1.0 * @category String * @param {string} string The string to convert. * @param {number} [radix=10] The radix to interpret `value` by. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {number} Returns the converted integer. * @example * @@ -12693,7 +13382,7 @@ */ function parseInt(string, radix, guard) { // Chrome fails to trim leading whitespace characters. - // See https://code.google.com/p/v8/issues/detail?id=3109 for more details. + // See https://bugs.chromium.org/p/v8/issues/detail?id=3109 for more details. if (guard || radix == null) { radix = 0; } else if (radix) { @@ -12708,6 +13397,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to repeat. * @param {number} [n=0] The number of times to repeat the string. @@ -12724,33 +13414,18 @@ * // => '' */ function repeat(string, n) { - string = toString(string); - n = toInteger(n); - - var result = ''; - if (!string || n < 1 || n > MAX_SAFE_INTEGER) { - return result; - } - // Leverage the exponentiation by squaring algorithm for a faster repeat. - // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. - do { - if (n % 2) { - result += string; - } - n = nativeFloor(n / 2); - string += string; - } while (n); - - return result; + return baseRepeat(toString(string), toInteger(n)); } /** * Replaces matches for `pattern` in `string` with `replacement`. * - * **Note:** This method is based on [`String#replace`](https://mdn.io/String/replace). + * **Note:** This method is based on + * [`String#replace`](https://mdn.io/String/replace). * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to modify. * @param {RegExp|string} pattern The pattern to replace. @@ -12769,10 +13444,12 @@ } /** - * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). + * Converts `string` to + * [snake case](https://en.wikipedia.org/wiki/Snake_case). * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the snake cased string. @@ -12784,7 +13461,7 @@ * _.snakeCase('fooBar'); * // => 'foo_bar' * - * _.snakeCase('--foo-bar'); + * _.snakeCase('--FOO-BAR--'); * // => 'foo_bar' */ var snakeCase = createCompounder(function(result, word, index) { @@ -12794,10 +13471,12 @@ /** * Splits `string` by `separator`. * - * **Note:** This method is based on [`String#split`](https://mdn.io/String/split). + * **Note:** This method is based on + * [`String#split`](https://mdn.io/String/split). * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to split. * @param {RegExp|string} separator The separator pattern to split by. @@ -12813,26 +13492,28 @@ } /** - * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * Converts `string` to + * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). * * @static * @memberOf _ + * @since 3.1.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the start cased string. * @example * - * _.startCase('--foo-bar'); + * _.startCase('--foo-bar--'); * // => 'Foo Bar' * * _.startCase('fooBar'); * // => 'Foo Bar' * - * _.startCase('__foo_bar__'); - * // => 'Foo Bar' + * _.startCase('__FOO_BAR__'); + * // => 'FOO BAR' */ var startCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + capitalize(word); + return result + (index ? ' ' : '') + upperFirst(word); }); /** @@ -12840,11 +13521,13 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to search. * @param {string} [target] The string to search for. * @param {number} [position=0] The position to search from. - * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`. + * @returns {boolean} Returns `true` if `string` starts with `target`, + * else `false`. * @example * * _.startsWith('abc', 'a'); @@ -12880,17 +13563,24 @@ * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). * * @static + * @since 0.1.0 * @memberOf _ * @category String * @param {string} [string=''] The template string. - * @param {Object} [options] The options object. - * @param {RegExp} [options.escape] The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate] The "evaluate" delimiter. - * @param {Object} [options.imports] An object to import into the template as free variables. - * @param {RegExp} [options.interpolate] The "interpolate" delimiter. - * @param {string} [options.sourceURL] The sourceURL of the template's compiled source. - * @param {string} [options.variable] The data object variable name. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param {Object} [options={}] The options object. + * @param {RegExp} [options.escape=_.templateSettings.escape] + * The HTML "escape" delimiter. + * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] + * The "evaluate" delimiter. + * @param {Object} [options.imports=_.templateSettings.imports] + * An object to import into the template as free variables. + * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] + * The "interpolate" delimiter. + * @param {string} [options.sourceURL='lodash.templateSources[n]'] + * The sourceURL of the compiled template. + * @param {string} [options.variable='obj'] + * The data object variable name. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Function} Returns the compiled template function. * @example * @@ -12939,7 +13629,7 @@ * // Use the `sourceURL` option to specify a custom sourceURL for the template. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); * compiled(data); - * // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector + * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. * * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); @@ -12959,7 +13649,8 @@ * '); */ function template(string, options, guard) { - // Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/) + // Based on John Resig's `tmpl` implementation + // (http://ejohn.org/blog/javascript-micro-templating/) // and Laura Doktorova's doT.js (https://github.com/olado/doT). var settings = lodash.templateSettings; @@ -13071,13 +13762,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the lower cased string. * @example * - * _.toLower('--Foo-Bar'); - * // => '--foo-bar' + * _.toLower('--Foo-Bar--'); + * // => '--foo-bar--' * * _.toLower('fooBar'); * // => 'foobar' @@ -13095,13 +13787,14 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the upper cased string. * @example * - * _.toUpper('--foo-bar'); - * // => '--FOO-BAR' + * _.toUpper('--foo-bar--'); + * // => '--FOO-BAR--' * * _.toUpper('fooBar'); * // => 'FOOBAR' @@ -13118,10 +13811,11 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -13159,10 +13853,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -13195,10 +13890,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {string} Returns the trimmed string. * @example * @@ -13233,9 +13929,10 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to truncate. - * @param {Object} [options=({})] The options object. + * @param {Object} [options={}] The options object. * @param {number} [options.length=30] The maximum string length. * @param {string} [options.omission='...'] The string to indicate text is omitted. * @param {RegExp|string} [options.separator] The separator pattern to truncate to. @@ -13320,14 +14017,15 @@ /** * The inverse of `_.escape`; this method converts the HTML entities - * `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their - * corresponding characters. + * `&`, `<`, `>`, `"`, `'`, and ``` in `string` to + * their corresponding characters. * - * **Note:** No other HTML entities are unescaped. To unescape additional HTML - * entities use a third-party library like [_he_](https://mths.be/he). + * **Note:** No other HTML entities are unescaped. To unescape additional + * HTML entities use a third-party library like [_he_](https://mths.be/he). * * @static * @memberOf _ + * @since 0.6.0 * @category String * @param {string} [string=''] The string to unescape. * @returns {string} Returns the unescaped string. @@ -13348,6 +14046,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the upper cased string. @@ -13366,15 +14065,35 @@ return result + (index ? ' ' : '') + word.toUpperCase(); }); + /** + * Converts the first character of `string` to upper case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.upperFirst('fred'); + * // => 'Fred' + * + * _.upperFirst('FRED'); + * // => 'FRED' + */ + var upperFirst = createCaseFirst('toUpperCase'); + /** * Splits `string` into an array of its words. * * @static * @memberOf _ + * @since 3.0.0 * @category String * @param {string} [string=''] The string to inspect. * @param {RegExp|string} [pattern] The pattern to match words. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the words of `string`. * @example * @@ -13402,8 +14121,10 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {Function} func The function to attempt. + * @param {...*} [args] The arguments to invoke `func` with. * @returns {*} Returns the `func` result or error object. * @example * @@ -13431,6 +14152,7 @@ * **Note:** This method doesn't set the "length" property of bound functions. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {Object} object The object to bind and assign the bound methods to. @@ -13448,7 +14170,7 @@ * * _.bindAll(view, 'onClick'); * jQuery(element).on('click', view.onClick); - * // => logs 'clicked docs' when clicked + * // => Logs 'clicked docs' when clicked. */ var bindAll = rest(function(object, methodNames) { arrayEach(baseFlatten(methodNames, 1), function(key) { @@ -13465,6 +14187,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {Array} pairs The predicate-function pairs. * @returns {Function} Returns the new function. @@ -13514,6 +14237,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {Object} source The object of property predicates to conform to. * @returns {Function} Returns the new function. @@ -13536,6 +14260,7 @@ * * @static * @memberOf _ + * @since 2.4.0 * @category Util * @param {*} value The value to return from the new function. * @returns {Function} Returns the new function. @@ -13560,6 +14285,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {...(Function|Function[])} [funcs] Functions to invoke. * @returns {Function} Returns the new function. @@ -13580,6 +14306,7 @@ * invokes the given functions from right to left. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {...(Function|Function[])} [funcs] Functions to invoke. @@ -13600,6 +14327,7 @@ * This method returns the first argument given to it. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {*} value Any value. @@ -13617,12 +14345,13 @@ /** * Creates a function that invokes `func` with the arguments of the created - * function. If `func` is a property name the 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`. + * function. If `func` is a property name the created function returns the + * property value for a given element. If `func` is an array or object the + * created function returns `true` for elements that contain the equivalent + * source properties, otherwise it returns `false`. * * @static + * @since 4.0.0 * @memberOf _ * @category Util * @param {*} [func=_.identity] The value to convert to a callback. @@ -13630,20 +14359,31 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * + * // The `_.matches` iteratee shorthand. + * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); + * // => [{ 'user': 'barney', 'age': 36, 'active': true }] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, _.iteratee(['user', 'fred'])); + * // => [{ 'user': 'fred', 'age': 40 }] + * + * // The `_.property` iteratee shorthand. + * _.map(users, _.iteratee('user')); + * // => ['barney', 'fred'] + * * // Create custom iteratee shorthands. - * _.iteratee = _.wrap(_.iteratee, function(callback, func) { - * var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func); - * return !p ? callback(func) : function(object) { - * return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]); + * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { + * return !_.isRegExp(func) ? iteratee(func) : function(string) { + * return func.test(string); * }; * }); * - * _.filter(users, 'age > 36'); - * // => [{ 'user': 'fred', 'age': 40 }] + * _.filter(['abc', 'def'], /ef/); + * // => ['def'] */ function iteratee(func) { return baseIteratee(typeof func == 'function' ? func : baseClone(func, true)); @@ -13659,6 +14399,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {Object} source The object of property values to match. * @returns {Function} Returns the new function. @@ -13685,6 +14426,7 @@ * * @static * @memberOf _ + * @since 3.2.0 * @category Util * @param {Array|string} path The path of the property to get. * @param {*} srcValue The value to match. @@ -13709,6 +14451,7 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Util * @param {Array|string} path The path of the method to invoke. * @param {...*} [args] The arguments to invoke the method with. @@ -13723,8 +14466,8 @@ * _.map(objects, _.method('a.b.c')); * // => [2, 1] * - * _.invokeMap(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); - * // => [1, 2] + * _.map(objects, _.method(['a', 'b', 'c'])); + * // => [2, 1] */ var method = rest(function(path, args) { return function(object) { @@ -13739,6 +14482,7 @@ * * @static * @memberOf _ + * @since 3.7.0 * @category Util * @param {Object} object The object to query. * @param {...*} [args] The arguments to invoke the method with. @@ -13761,21 +14505,21 @@ }); /** - * 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. + * Adds all own enumerable string keyed 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 to * avoid conflicts caused by modifying the original. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {Function|Object} [object=lodash] The destination object. * @param {Object} source The object of functions to add. - * @param {Object} [options] The options object. - * @param {boolean} [options.chain=true] Specify whether the functions added - * are chainable. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.chain=true] Specify whether mixins are chainable. * @returns {Function|Object} Returns `object`. * @example * @@ -13837,6 +14581,7 @@ * the `lodash` function. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @returns {Function} Returns the `lodash` function. @@ -13857,6 +14602,7 @@ * * @static * @memberOf _ + * @since 2.3.0 * @category Util * @example * @@ -13874,6 +14620,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {number} [n=0] The index of the argument to return. * @returns {Function} Returns the new function. @@ -13897,6 +14644,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {...(Function|Function[])} iteratees The iteratees to invoke. * @returns {Function} Returns the new function. @@ -13915,6 +14663,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {...(Function|Function[])} predicates The predicates to check. * @returns {Function} Returns the new function. @@ -13939,6 +14688,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {...(Function|Function[])} predicates The predicates to check. * @returns {Function} Returns the new function. @@ -13962,6 +14712,7 @@ * * @static * @memberOf _ + * @since 2.4.0 * @category Util * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new function. @@ -13988,6 +14739,7 @@ * * @static * @memberOf _ + * @since 3.0.0 * @category Util * @param {Object} object The object to query. * @returns {Function} Returns the new function. @@ -14018,6 +14770,7 @@ * floating-point values which can produce unexpected results. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {number} [start=0] The start of the range. @@ -14055,6 +14808,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {number} [start=0] The start of the range. * @param {number} end The end of the range. @@ -14090,6 +14844,7 @@ * each invocation. The iteratee is invoked with one argument; (index). * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {number} n The number of times to invoke `iteratee`. @@ -14111,7 +14866,7 @@ var index = MAX_ARRAY_LENGTH, length = nativeMin(n, MAX_ARRAY_LENGTH); - iteratee = baseCastFunction(iteratee); + iteratee = getIteratee(iteratee); n -= MAX_ARRAY_LENGTH; var result = baseTimes(length, iteratee); @@ -14126,6 +14881,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Util * @param {*} value The value to convert. * @returns {Array} Returns the new property path array. @@ -14147,13 +14903,17 @@ * // => false */ function toPath(value) { - return isArray(value) ? arrayMap(value, String) : stringToPath(value); + if (isArray(value)) { + return arrayMap(value, baseCastKey); + } + return isSymbol(value) ? [value] : copyArray(stringToPath(value)); } /** * Generates a unique ID. If `prefix` is given the ID is appended to it. * * @static + * @since 0.1.0 * @memberOf _ * @category Util * @param {string} [prefix=''] The value to prefix the ID with. @@ -14178,6 +14938,7 @@ * * @static * @memberOf _ + * @since 3.4.0 * @category Math * @param {number} augend The first number in an addition. * @param {number} addend The second number in an addition. @@ -14187,25 +14948,16 @@ * _.add(6, 4); * // => 10 */ - function add(augend, addend) { - var result; - if (augend === undefined && addend === undefined) { - return 0; - } - if (augend !== undefined) { - result = augend; - } - if (addend !== undefined) { - result = result === undefined ? addend : (result + addend); - } - return result; - } + var add = createMathOperation(function(augend, addend) { + return augend + addend; + }); /** * Computes `number` rounded up to `precision`. * * @static * @memberOf _ + * @since 3.10.0 * @category Math * @param {number} number The number to round up. * @param {number} [precision=0] The precision to round up to. @@ -14223,11 +14975,31 @@ */ var ceil = createRound('ceil'); + /** + * Divide two numbers. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {number} dividend The first number in a division. + * @param {number} divisor The second number in a division. + * @returns {number} Returns the quotient. + * @example + * + * _.divide(6, 4); + * // => 1.5 + */ + var divide = createMathOperation(function(dividend, divisor) { + return dividend / divisor; + }); + /** * Computes `number` rounded down to `precision`. * * @static * @memberOf _ + * @since 3.10.0 * @category Math * @param {number} number The number to round down. * @param {number} [precision=0] The precision to round down to. @@ -14250,6 +15022,7 @@ * `undefined` is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Math * @param {Array} array The array to iterate over. @@ -14275,9 +15048,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {*} Returns the maximum value. * @example * @@ -14301,6 +15076,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. * @returns {number} Returns the mean. @@ -14310,7 +15086,35 @@ * // => 5 */ function mean(array) { - return sum(array) / (array ? array.length : 0); + return baseMean(array, identity); + } + + /** + * This method is like `_.mean` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the value to be averaged. + * The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. + * @returns {number} Returns the mean. + * @example + * + * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; + * + * _.meanBy(objects, function(o) { return o.n; }); + * // => 5 + * + * // The `_.property` iteratee shorthand. + * _.meanBy(objects, 'n'); + * // => 5 + */ + function meanBy(array, iteratee) { + return baseMean(array, getIteratee(iteratee)); } /** @@ -14318,6 +15122,7 @@ * `undefined` is returned. * * @static + * @since 0.1.0 * @memberOf _ * @category Math * @param {Array} array The array to iterate over. @@ -14343,9 +15148,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {*} Returns the minimum value. * @example * @@ -14364,11 +15171,31 @@ : undefined; } + /** + * Multiply two numbers. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {number} multiplier The first number in a multiplication. + * @param {number} multiplicand The second number in a multiplication. + * @returns {number} Returns the product. + * @example + * + * _.multiply(6, 4); + * // => 24 + */ + var multiply = createMathOperation(function(multiplier, multiplicand) { + return multiplier * multiplicand; + }); + /** * Computes `number` rounded to `precision`. * * @static * @memberOf _ + * @since 3.10.0 * @category Math * @param {number} number The number to round. * @param {number} [precision=0] The precision to round to. @@ -14391,6 +15218,7 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {number} minuend The first number in a subtraction. * @param {number} subtrahend The second number in a subtraction. @@ -14400,25 +15228,16 @@ * _.subtract(6, 4); * // => 2 */ - function subtract(minuend, subtrahend) { - var result; - if (minuend === undefined && subtrahend === undefined) { - return 0; - } - if (minuend !== undefined) { - result = minuend; - } - if (subtrahend !== undefined) { - result = result === undefined ? subtrahend : (result - subtrahend); - } - return result; - } + var subtract = createMathOperation(function(minuend, subtrahend) { + return minuend - subtrahend; + }); /** * Computes the sum of the values in `array`. * * @static * @memberOf _ + * @since 3.4.0 * @category Math * @param {Array} array The array to iterate over. * @returns {number} Returns the sum. @@ -14440,9 +15259,11 @@ * * @static * @memberOf _ + * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Array|Function|Object|string} [iteratee=_.identity] + * The iteratee invoked per element. * @returns {number} Returns the sum. * @example * @@ -14463,40 +15284,7 @@ /*------------------------------------------------------------------------*/ - // Ensure wrappers are instances of `baseLodash`. - lodash.prototype = baseLodash.prototype; - lodash.prototype.constructor = lodash; - - LodashWrapper.prototype = baseCreate(baseLodash.prototype); - LodashWrapper.prototype.constructor = LodashWrapper; - - LazyWrapper.prototype = baseCreate(baseLodash.prototype); - LazyWrapper.prototype.constructor = LazyWrapper; - - // Avoid inheriting from `Object.prototype` when possible. - Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; - - // Add functions to the `MapCache`. - MapCache.prototype.clear = mapClear; - MapCache.prototype['delete'] = mapDelete; - MapCache.prototype.get = mapGet; - MapCache.prototype.has = mapHas; - MapCache.prototype.set = mapSet; - - // Add functions to the `SetCache`. - SetCache.prototype.push = cachePush; - - // Add functions to the `Stack` cache. - Stack.prototype.clear = stackClear; - Stack.prototype['delete'] = stackDelete; - Stack.prototype.get = stackGet; - Stack.prototype.has = stackHas; - Stack.prototype.set = stackSet; - - // Assign cache to `_.memoize`. - memoize.Cache = MapCache; - - // Add functions that return wrapped values when chaining. + // Add methods that return wrapped values in chain sequences. lodash.after = after; lodash.ary = ary; lodash.assign = assign; @@ -14535,6 +15323,8 @@ lodash.fill = fill; lodash.filter = filter; lodash.flatMap = flatMap; + lodash.flatMapDeep = flatMapDeep; + lodash.flatMapDepth = flatMapDepth; lodash.flatten = flatten; lodash.flattenDeep = flattenDeep; lodash.flattenDepth = flattenDepth; @@ -14646,15 +15436,17 @@ lodash.zipWith = zipWith; // Add aliases. + lodash.entries = toPairs; + lodash.entriesIn = toPairsIn; lodash.extend = assignIn; lodash.extendWith = assignInWith; - // Add functions to `lodash.prototype`. + // Add methods to `lodash.prototype`. mixin(lodash, lodash); /*------------------------------------------------------------------------*/ - // Add functions that return unwrapped values when chaining. + // Add methods that return unwrapped values in chain sequences. lodash.add = add; lodash.attempt = attempt; lodash.camelCase = camelCase; @@ -14666,6 +15458,7 @@ lodash.cloneDeepWith = cloneDeepWith; lodash.cloneWith = cloneWith; lodash.deburr = deburr; + lodash.divide = divide; lodash.endsWith = endsWith; lodash.eq = eq; lodash.escape = escape; @@ -14743,8 +15536,10 @@ lodash.max = max; lodash.maxBy = maxBy; lodash.mean = mean; + lodash.meanBy = meanBy; lodash.min = min; lodash.minBy = minBy; + lodash.multiply = multiply; lodash.noConflict = noConflict; lodash.noop = noop; lodash.now = now; @@ -14984,7 +15779,7 @@ }; }); - // Add `Array` and `String` methods to `lodash.prototype`. + // Add `Array` methods to `lodash.prototype`. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', @@ -14993,15 +15788,16 @@ lodash.prototype[methodName] = function() { var args = arguments; if (retUnwrapped && !this.__chain__) { - return func.apply(this.value(), args); + var value = this.value(); + return func.apply(isArray(value) ? value : [], args); } return this[chainName](function(value) { - return func.apply(value, args); + return func.apply(isArray(value) ? value : [], args); }); }; }); - // Map minified function names to their real names. + // Map minified method names to their real names. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName]; if (lodashFunc) { @@ -15017,16 +15813,15 @@ 'func': undefined }]; - // Add functions to the lazy wrapper. + // Add methods to `LazyWrapper`. LazyWrapper.prototype.clone = lazyClone; LazyWrapper.prototype.reverse = lazyReverse; LazyWrapper.prototype.value = lazyValue; - // Add chaining functions to the `lodash` wrapper. + // Add chain sequence methods to the `lodash` wrapper. lodash.prototype.at = wrapperAt; lodash.prototype.chain = wrapperChain; lodash.prototype.commit = wrapperCommit; - lodash.prototype.flatMap = wrapperFlatMap; lodash.prototype.next = wrapperNext; lodash.prototype.plant = wrapperPlant; lodash.prototype.reverse = wrapperReverse; diff --git a/package.json b/package.json index 2f9987fc09..af14bfafd5 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,36 @@ { "name": "lodash", - "version": "4.6.1", + "version": "4.7.0", + "license": "MIT", "main": "lodash.js", "private": true, "devDependencies": { "async": "^1.5.2", "benchmark": "^2.1.0", - "chalk": "^1.1.1", + "chalk": "^1.1.3", "codecov.io": "~0.1.6", - "coveralls": "^2.11.8", + "coveralls": "^2.11.9", "curl-amd": "~0.8.12", - "docdown": "~0.4.1", - "dojo": "^1.10.4", + "docdown": "~0.5.0", + "dojo": "^1.11.0", "ecstatic": "^1.4.0", - "fs-extra": "~0.26.5", - "glob": "^7.0.0", + "fs-extra": "~0.26.7", + "glob": "^7.0.3", "istanbul": "0.4.2", - "jquery": "^2.2.1", - "jscs": "^2.10.1", + "jquery": "^2.2.2", + "jscs": "^2.11.0", "lodash": "4.5.0", "platform": "^1.3.1", "qunit-extras": "^1.5.0", - "qunitjs": "~1.22.0", + "qunitjs": "~1.23.0", "request": "^2.69.0", - "requirejs": "^2.1.22", + "requirejs": "^2.2.0", "sauce-tunnel": "^2.4.0", "uglify-js": "2.6.2", "webpack": "^1.12.14" }, "scripts": { - "build": "npm run build:main & npm run build:fp", + "build": "npm run build:main & npm run build:fp & wait", "build:fp": "node lib/fp/build-dist.js", "build:fp-modules": "node lib/fp/build-modules.js", "build:main": "node lib/main/build-dist.js", @@ -38,13 +39,14 @@ "doc:fp": "node lib/fp/build-doc", "doc:site": "node lib/main/build-doc site", "pretest": "npm run build", - "style": "npm run style:main & npm run style:fp & npm run style:perf & npm run style:test", + "style": "npm run style:main & npm run style:fp & npm run style:perf & npm run style:test & wait", "style:fp": "jscs fp/*.js lib/**/*.js", "style:main": "jscs lodash.js", "style:perf": "jscs perf/*.js perf/**/*.js", "style:test": "jscs test/*.js test/**/*.js", "test": "npm run test:main && npm run test:fp", "test:fp": "node test/test-fp", - "test:main": "node test/test" + "test:main": "node test/test", + "validate": "npm run style & npm run test & wait" } } diff --git a/perf/perf.js b/perf/perf.js index 2c98039c6b..bf70d61089 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -565,11 +565,11 @@ suites.push( Benchmark.Suite('`_.assign`') .add(buildName, { - 'fn': 'lodashAssign({}, object)', + 'fn': 'lodashAssign({}, { "a": 1, "b": 2, "c": 3 })', 'teardown': 'function assign(){}' }) .add(otherName, { - 'fn': '_assign({}, object)', + 'fn': '_assign({}, { "a": 1, "b": 2, "c": 3 })', 'teardown': 'function assign(){}' }) ); @@ -577,11 +577,11 @@ suites.push( Benchmark.Suite('`_.assign` with multiple sources') .add(buildName, { - 'fn': 'lodashAssign({}, object, object)', + 'fn': 'lodashAssign({}, { "a": 1, "b": 2 }, { "c": 3, "d": 4 })', 'teardown': 'function assign(){}' }) .add(otherName, { - 'fn': '_assign({}, object, object)', + 'fn': '_assign({}, { "a": 1, "b": 2 }, { "c": 3, "d": 4 })', 'teardown': 'function assign(){}' }) ); diff --git a/test/index.html b/test/index.html index df0d11759c..aee3942499 100644 --- a/test/index.html +++ b/test/index.html @@ -119,6 +119,9 @@ setProperty(Map, 'toString', createToString('Map')); } + setProperty(window, '_Promise', window.Promise); + setProperty(window, 'Promise', noop); + setProperty(window, '_Set', window.Set); setProperty(window, 'Set', noop); @@ -158,6 +161,11 @@ } else { setProperty(window, 'Map', undefined); } + if (_Promise) { + Promise = _Promise; + } else { + setProperty(window, 'Promise', undefined); + } if (_Set) { Set = _Set; } else { @@ -172,6 +180,7 @@ setProperty(window, 'WeakMap', undefined); } setProperty(window, '_Map', undefined); + setProperty(window, '_Promise', undefined); setProperty(window, '_Set', undefined); setProperty(window, '_Symbol', undefined); setProperty(window, '_WeakMap', undefined); diff --git a/test/saucelabs.js b/test/saucelabs.js index d962064c1c..5d09a51b32 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -97,17 +97,18 @@ var browserNameMap = { 'googlechrome': 'Chrome', 'iehta': 'Internet Explorer', 'ipad': 'iPad', - 'iphone': 'iPhone' + 'iphone': 'iPhone', + 'microsoftedge': 'Edge' }; /** List of platforms to load the runner on. */ var platforms = [ ['Linux', 'android', '5.1'], + ['Windows 10', 'chrome', '49'], ['Windows 10', 'chrome', '48'], - ['Windows 10', 'chrome', '47'], + ['Windows 10', 'firefox', '45'], ['Windows 10', 'firefox', '44'], - ['Windows 10', 'firefox', '43'], - ['Windows 10', 'microsoftedge', '20.10240'], + ['Windows 10', 'microsoftedge', '13'], ['Windows 10', 'internet explorer', '11'], ['Windows 8', 'internet explorer', '10'], ['Windows 7', 'internet explorer', '9'], diff --git a/test/test-fp.js b/test/test-fp.js index c69d9486d2..d79d97f393 100644 --- a/test/test-fp.js +++ b/test/test-fp.js @@ -67,6 +67,14 @@ }; }()); + var allFalseOptions = { + 'cap': false, + 'curry': false, + 'fixed': false, + 'immutable': false, + 'rearg': false + }; + var fp = root.fp ? (fp = _.noConflict(), _ = root._, fp) : convert(_.runInContext()); @@ -95,18 +103,39 @@ console.log('Running lodash/fp tests.'); } - QUnit.module('convert'); + QUnit.module('convert module'); (function() { - var allFalseOptions = { - 'cap': false, - 'curry': false, - 'fixed': false, - 'immutable': false, - 'rearg': false - }; + QUnit.test('should work with `name` and `func`', function(assert) { + assert.expect(2); + + var array = [1, 2, 3, 4], + remove = convert('remove', _.remove); + + var actual = remove(function(n) { + return n % 2 == 0; + })(array); + + assert.deepEqual(array, [1, 2, 3, 4]); + assert.deepEqual(actual, [1, 3]); + }); + + QUnit.test('should work with `name`, `func`, and `options`', function(assert) { + assert.expect(3); + + var array = [1, 2, 3, 4], + remove = convert('remove', _.remove, allFalseOptions); - QUnit.test('should work when given an object', function(assert) { + var actual = remove(array, function(n, index) { + return index % 2 == 0; + }); + + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(remove(), []); + }); + + QUnit.test('should work with an object', function(assert) { assert.expect(2); if (!document) { @@ -125,44 +154,55 @@ } }); - QUnit.test('should only add a `placeholder` property if needed', function(assert) { - assert.expect(2); + QUnit.test('should work with an object and `options`', function(assert) { + assert.expect(3); if (!document) { - var methodNames = _.keys(mapping.placeholder), - expected = _.map(methodNames, _.constant(true)); - - var actual = _.map(methodNames, function(methodName) { - var object = {}; - object[methodName] = _[methodName]; + var array = [1, 2, 3, 4], + lodash = convert({ 'remove': _.remove }, allFalseOptions); - var lodash = convert(object); - return methodName in lodash; + var actual = lodash.remove(array, function(n, index) { + return index % 2 == 0; }); - assert.deepEqual(actual, expected); - - var lodash = convert({ 'add': _.add }); - assert.notOk('placeholder' in lodash); + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(lodash.remove(), []); } else { - skipAssert(assert, 2); + skipAssert(assert, 3); } }); - QUnit.test('should accept an `options` argument', function(assert) { + QUnit.test('should work with lodash and `options`', function(assert) { assert.expect(3); var array = [1, 2, 3, 4], - remove = convert('remove', _.remove, allFalseOptions); + lodash = convert(_.runInContext(), allFalseOptions); - var actual = remove(array, function(n, index) { + var actual = lodash.remove(array, function(n, index) { return index % 2 == 0; }); assert.deepEqual(array, [2, 4]); assert.deepEqual(actual, [1, 3]); - assert.deepEqual(remove(), []); + assert.deepEqual(lodash.remove(), []); + }); + + QUnit.test('should work with `runInContext` and `options`', function(assert) { + assert.expect(3); + + var array = [1, 2, 3, 4], + runInContext = convert('runInContext', _.runInContext, allFalseOptions), + lodash = runInContext(); + + var actual = lodash.remove(array, function(n, index) { + return index % 2 == 0; + }); + + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(lodash.remove(), []); }); QUnit.test('should accept a variety of options', function(assert) { @@ -220,57 +260,71 @@ assert.strictEqual(add('2')('1'), '12'); }); - QUnit.test('should use `options` in `runInContext`', function(assert) { - assert.expect(3); + QUnit.test('should only add a `placeholder` property if needed', function(assert) { + assert.expect(2); - var array = [1, 2, 3, 4], - runInContext = convert('runInContext', _.runInContext, allFalseOptions), - lodash = runInContext(); + if (!document) { + var methodNames = _.keys(mapping.placeholder), + expected = _.map(methodNames, _.constant(true)); - var actual = lodash.remove(array, function(n, index) { - return index % 2 == 0; - }); + var actual = _.map(methodNames, function(methodName) { + var object = {}; + object[methodName] = _[methodName]; - assert.deepEqual(array, [2, 4]); - assert.deepEqual(actual, [1, 3]); - assert.deepEqual(lodash.remove(), []); + var lodash = convert(object); + return methodName in lodash; + }); + + assert.deepEqual(actual, expected); + + var lodash = convert({ 'add': _.add }); + assert.notOk('placeholder' in lodash); + } + else { + skipAssert(assert, 2); + } }); + }()); + + /*--------------------------------------------------------------------------*/ - QUnit.test('should work when given lodash and `options`', function(assert) { + QUnit.module('convert methods'); + + _.each(['fp.convert', 'method.convert'], function(methodName) { + var isFp = methodName == 'fp.convert', + func = isFp ? fp.convert : fp.remove.convert; + + QUnit.test('`' + methodName + '` should work with an object', function(assert) { assert.expect(3); var array = [1, 2, 3, 4], - lodash = convert(_.runInContext(), allFalseOptions); + lodash = func(allFalseOptions), + remove = isFp ? lodash.remove : lodash; - var actual = lodash.remove(array, function(n, index) { + var actual = remove(array, function(n, index) { return index % 2 == 0; }); assert.deepEqual(array, [2, 4]); assert.deepEqual(actual, [1, 3]); - assert.deepEqual(lodash.remove(), []); + assert.deepEqual(remove(), []); }); - QUnit.test('should work when given an object and `options`', function(assert) { - assert.expect(3); + QUnit.test('`' + methodName + '` should extend existing configs', function(assert) { + assert.expect(2); - if (!document) { - var array = [1, 2, 3, 4], - lodash = convert({ 'remove': _.remove }, allFalseOptions); + var array = [1, 2, 3, 4], + lodash = func({ 'cap': false }), + remove = (isFp ? lodash.remove : lodash).convert({ 'rearg': false }); - var actual = lodash.remove(array, function(n, index) { - return index % 2 == 0; - }); + var actual = remove(array)(function(n, index) { + return index % 2 == 0; + }); - assert.deepEqual(array, [2, 4]); - assert.deepEqual(actual, [1, 3]); - assert.deepEqual(lodash.remove(), []); - } - else { - skipAssert(assert, 3); - } + assert.deepEqual(array, [1, 2, 3, 4]); + assert.deepEqual(actual, [2, 4]); }); - }()); + }); /*--------------------------------------------------------------------------*/ @@ -358,8 +412,9 @@ assert.expect(1); var funcMethods = [ - 'after', 'ary', 'before', 'bind', 'bindKey', 'curryN', 'debounce', 'delay', - 'overArgs', 'partial', 'partialRight', 'rearg', 'throttle', 'wrap' + 'after', 'ary', 'before', 'bind', 'bindKey', 'curryN', 'debounce', + 'delay', 'overArgs', 'partial', 'partialRight', 'rearg', 'throttle', + 'wrap' ]; var exceptions = _.difference(funcMethods.concat('matchesProperty'), ['cloneDeepWith', 'cloneWith', 'delay']), @@ -416,7 +471,7 @@ assert.expect(10); var array = ['a', 'b', 'c'], - other = ['b', 'b', 'd'], + other = ['b', 'd', 'b'], object = { 'a': 1, 'b': 2, 'c': 2 }, actual = fp.difference(array)(other); @@ -440,7 +495,7 @@ actual = fp.uniqBy(_.identity, other); assert.deepEqual(actual, ['b', 'd'], 'fp.uniqBy'); - actual = fp.without('b')(array); + actual = fp.without(array)(other); assert.deepEqual(actual, ['a', 'c'], 'fp.without'); actual = fp.xor(other)(array); @@ -813,7 +868,7 @@ object = { 'a': 1 }; QUnit.test('should provide the correct `customizer` arguments', function(assert) { - assert.expect(5); + assert.expect(7); var args, value = _.clone(object); @@ -833,11 +888,36 @@ assert.deepEqual(args, [undefined, 2, 'b', { 'a': 1 }, { 'b': 2 }], 'fp.extendWith'); - var stack = { '__data__': { 'array': [], 'map': null } }, - expected = [[1], [2, 3], 'a', { 'a': [1] }, { 'a': [2, 3] }, stack]; + var iteration = 0, + objects = [{ 'a': 1 }, { 'a': 2 }], + stack = { '__data__': { 'array': [[objects[0], objects[1]]], 'map': null } }, + expected = [1, 2, 'a', objects[0], objects[1], stack]; + + args = undefined; + + fp.isEqualWith(function() { + if (++iteration == 2) { + args = _.map(arguments, _.cloneDeep); + } + })(objects[0])(objects[1]); + + args[5] = _.omitBy(args[5], _.isFunction); + assert.deepEqual(args, expected, 'fp.isEqualWith'); + + args = undefined; + stack = { '__data__': { 'array': [], 'map': null } }; + expected = [2, 1, 'a', objects[1], objects[0], stack]; + + fp.isMatchWith(function() { + args || (args = _.map(arguments, _.cloneDeep)); + })(objects[0])(objects[1]); + + args[5] = _.omitBy(args[5], _.isFunction); + assert.deepEqual(args, expected, 'fp.isMatchWith'); args = undefined; value = { 'a': [1] }; + expected = [[1], [2, 3], 'a', { 'a': [1] }, { 'a': [2, 3] }, stack]; fp.mergeWith(function() { args || (args = _.map(arguments, _.cloneDeep)); @@ -874,7 +954,7 @@ var func = fp[methodName], isAdd = methodName == 'add'; - QUnit.test('`fp.' + methodName + '` should have `rearg` applied', function(assert) { + QUnit.test('`fp.' + methodName + '` should not have `rearg` applied', function(assert) { assert.expect(1); assert.strictEqual(func('1')('2'), isAdd ? '12' : -1); @@ -966,6 +1046,21 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('fp.divide and fp.multiply'); + + _.each(['divide', 'multiply'], function(methodName) { + var func = fp[methodName], + isDivide = methodName == 'divide'; + + QUnit.test('`fp.' + methodName + '` should not have `rearg` applied', function(assert) { + assert.expect(1); + + assert.strictEqual(func('2')('4'), isDivide ? 0.5 : 8); + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.extend'); (function() { @@ -1000,6 +1095,27 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('fp.flatMapDepth'); + + (function() { + QUnit.test('should have an argument order of `iteratee`, `depth`, then `collection`', function(assert) { + assert.expect(2); + + function duplicate(n) { + return [[[n, n]]]; + } + + var array = [1, 2], + object = { 'a': 1, 'b': 2 }, + expected = [[1, 1], [2, 2]]; + + assert.deepEqual(fp.flatMapDepth(duplicate)(2)(array), expected); + assert.deepEqual(fp.flatMapDepth(duplicate)(2)(object), expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.flow and fp.flowRight'); _.each(['flow', 'flowRight'], function(methodName) { @@ -1049,12 +1165,14 @@ QUnit.module('fp.getOr'); - QUnit.test('should accept a `defaultValue` param', function(assert) { - assert.expect(1); + (function() { + QUnit.test('should accept a `defaultValue` param', function(assert) { + assert.expect(1); - var actual = fp.getOr('default')('path')({}); - assert.strictEqual(actual, 'default'); - }); + var actual = fp.getOr('default')('path')({}); + assert.strictEqual(actual, 'default'); + }); + }()); /*--------------------------------------------------------------------------*/ @@ -1085,6 +1203,58 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('fp.invoke'); + + (function() { + QUnit.test('should not accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invoke('toUpperCase')('a'); + assert.strictEqual(actual, 'A'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.invokeMap'); + + (function() { + QUnit.test('should not accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invokeMap('toUpperCase')(['a', 'b']); + assert.deepEqual(actual, ['A', 'B']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.invokeArgs'); + + (function() { + QUnit.test('should accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invokeArgs('concat')(['b', 'c'])('a'); + assert.strictEqual(actual, 'abc'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.invokeArgsMap'); + + (function() { + QUnit.test('should accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invokeArgsMap('concat')(['b', 'c'])(['a', 'A']); + assert.deepEqual(actual, ['abc', 'Abc']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.iteratee'); (function() { @@ -1278,6 +1448,26 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('padChars methods'); + + _.each(['padChars', 'padCharsStart', 'padCharsEnd'], function(methodName) { + var func = fp[methodName], + isPad = methodName == 'padChars', + isStart = methodName == 'padCharsStart'; + + QUnit.test('`_.' + methodName + '` should truncate pad characters to fit the pad length', function(assert) { + assert.expect(1); + + if (isPad) { + assert.strictEqual(func('_-')(8)('abc'), '_-abc_-_'); + } else { + assert.strictEqual(func('_-')(6)('abc'), isStart ? '_-_abc' : 'abc_-_'); + } + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.partial and fp.partialRight'); _.each(['partial', 'partialRight'], function(methodName) { @@ -1391,6 +1581,22 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('fp.restFrom'); + + (function() { + QUnit.test('should accept a `start` param', function(assert) { + assert.expect(1); + + var actual = fp.restFrom(2)(function() { + return slice.call(arguments); + })('a', 'b', 'c', 'd'); + + assert.deepEqual(actual, ['a', 'b', ['c', 'd']]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.runInContext'); (function() { @@ -1410,7 +1616,23 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('fp.trimChars'); + QUnit.module('fp.spreadFrom'); + + (function() { + QUnit.test('should accept a `start` param', function(assert) { + assert.expect(1); + + var actual = fp.spreadFrom(2)(function() { + return slice.call(arguments); + })('a', 'b', ['c', 'd']); + + assert.deepEqual(actual, ['a', 'b', 'c', 'd']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('trimChars methods'); _.each(['trimChars', 'trimCharsStart', 'trimCharsEnd'], function(methodName, index) { var func = fp[methodName], diff --git a/test/test.js b/test/test.js index dc8aa17056..29442e928d 100644 --- a/test/test.js +++ b/test/test.js @@ -50,6 +50,7 @@ create = Object.create, fnToString = funcProto.toString, freeze = Object.freeze, + getSymbols = Object.getOwnPropertySymbols, identity = function(value) { return value; }, JSON = root.JSON, noop = function() {}, @@ -61,6 +62,8 @@ var ArrayBuffer = root.ArrayBuffer, Buffer = root.Buffer, + DataView = root.DataView, + Promise = root.Promise, Map = root.Map, Set = root.Set, Symbol = root.Symbol, @@ -70,6 +73,7 @@ var arrayBuffer = ArrayBuffer ? new ArrayBuffer(2) : undefined, map = Map ? new Map : undefined, + promise = Promise ? Promise.resolve(1) : undefined, set = Set ? new Set : undefined, symbol = Symbol ? Symbol('a') : undefined, weakMap = WeakMap ? new WeakMap : undefined, @@ -103,6 +107,82 @@ alwaysEmptyObject = function() { return {}; }, alwaysEmptyString = function() { return ''; }; + /** List of latin-1 supplementary letters to basic latin letters. */ + var burredLetters = [ + '\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', + '\xcf', '\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', + '\xdf', '\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', + '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' + ]; + + /** List of 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', + '\ufe20', '\ufe21', '\ufe22', '\ufe23' + ]; + + /** 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', + 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'Th', + 'ss', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', + 'i', 'd', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y' + ]; + + /** Used to provide falsey values to methods. */ + var falsey = [, null, undefined, false, 0, NaN, '']; + + /** Used to specify the emoji style glyph variant of characters. */ + var emojiVar = '\ufe0f'; + + /** Used to provide empty values to methods. */ + var empties = [[], {}].concat(falsey.slice(1)); + + /** Used to test error objects. */ + var errors = [ + new Error, + new EvalError, + new RangeError, + new ReferenceError, + new SyntaxError, + new TypeError, + new URIError + ]; + + /** List of fitzpatrick modifiers. */ + var fitzModifiers = [ + '\ud83c\udffb', + '\ud83c\udffc', + '\ud83c\udffd', + '\ud83c\udffe', + '\ud83c\udfff' + ]; + + /** Used to provide primitive values to methods. */ + var primitives = [null, undefined, false, true, 1, NaN, 'a']; + + /** Used to check whether methods support typed arrays. */ + var typedArrays = [ + 'Float32Array', + 'Float64Array', + 'Int8Array', + 'Int16Array', + 'Int32Array', + 'Uint8Array', + 'Uint8ClampedArray', + 'Uint16Array', + 'Uint32Array' + ]; + + /** Used to check whether methods support array views. */ + var arrayViews = typedArrays.concat('DataView'); + /** The file path of the lodash file to test. */ var filePath = (function() { var min = 2, @@ -256,83 +336,13 @@ return /^(?:\$\$cov_\d+\$\$)$/.test(key); })]; - /** Used to restore the `_` reference. */ - var oldDash = root._; - /** Used to test generator functions. */ var generator = lodashStable.attempt(function() { return Function('return function*(){}'); }); - /** List of latin-1 supplementary letters to basic latin letters. */ - var burredLetters = [ - '\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', - '\xcf', '\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', - '\xdf', '\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', - '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' - ]; - - /** List of 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', - '\ufe20', '\ufe21', '\ufe22', '\ufe23' - ]; - - /** 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', - 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'Th', - 'ss', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', - 'i', 'd', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y' - ]; - - /** Used to specify the emoji style glyph variant of characters. */ - var emojiVar = '\ufe0f'; - - /** Used to provide falsey values to methods. */ - var falsey = [, '', 0, false, NaN, null, undefined]; - - /** Used to provide empty values to methods. */ - var empties = [[], {}].concat(falsey.slice(1)); - - /** Used to test error objects. */ - var errors = [ - new Error, - new EvalError, - new RangeError, - new ReferenceError, - new SyntaxError, - new TypeError, - new URIError - ]; - - /** List of fitzpatrick modifiers. */ - var fitzModifiers = [ - '\ud83c\udffb', - '\ud83c\udffc', - '\ud83c\udffd', - '\ud83c\udffe', - '\ud83c\udfff' - ]; - - /** Used to check whether methods support typed arrays. */ - var typedArrays = [ - 'Float32Array', - 'Float64Array', - 'Int8Array', - 'Int16Array', - 'Int32Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Uint16Array', - 'Uint32Array' - ]; + /** Used to restore the `_` reference. */ + var oldDash = root._; /** * Used to check for problems removing whitespace. For a whitespace reference, @@ -369,7 +379,7 @@ }); /** - * Removes all own enumerable properties from a given object. + * Removes all own enumerable string keyed properties from a given object. * * @private * @param {Object} object The object to empty. @@ -481,7 +491,6 @@ }; }())); - var _getOwnPropertySymbols = Object.getOwnPropertySymbols; setProperty(Object, 'getOwnPropertySymbols', undefined); var _propertyIsEnumerable = objectProto.propertyIsEnumerable; @@ -517,6 +526,7 @@ setProperty(root.Map, 'toString', createToString('Map')); } + setProperty(root, 'Promise', noop); setProperty(root, 'Set', noop); setProperty(root, 'Symbol', undefined); setProperty(root, 'WeakMap', noop); @@ -536,8 +546,8 @@ setProperty(objectProto, 'propertyIsEnumerable', _propertyIsEnumerable); setProperty(root, 'Buffer', Buffer); - if (_getOwnPropertySymbols) { - Object.getOwnPropertySymbols = _getOwnPropertySymbols; + if (getSymbols) { + Object.getOwnPropertySymbols = getSymbols; } else { delete Object.getOwnPropertySymbols; } @@ -546,6 +556,11 @@ } else { delete root.Map; } + if (Promise) { + setProperty(root, 'Promise', Promise); + } else { + delete root.Promise; + } if (Set) { setProperty(root, 'Set', Set); } else { @@ -573,6 +588,7 @@ ' root = this;', '', ' var object = {', + " 'ArrayBuffer': root.ArrayBuffer,", " 'arguments': (function() { return arguments; }(1, 2, 3)),", " 'array': [1],", " 'arrayBuffer': root.ArrayBuffer ? new root.ArrayBuffer : undefined,", @@ -585,6 +601,7 @@ " 'null': null,", " 'number': Object(0),", " 'object': { 'a': 1 },", + " 'promise': root.Promise ? Promise.resolve(1) : undefined,", " 'regexp': /x/,", " 'set': root.Set ? new root.Set : undefined,", " 'string': Object('a'),", @@ -594,8 +611,9 @@ " 'weakSet': root.WeakSet ? new root.WeakSet : undefined", ' };', '', - " ['" + typedArrays.join("', '") + "'].forEach(function(type) {", + " ['" + arrayViews.join("', '") + "'].forEach(function(type) {", ' var Ctor = root[type]', + ' object[type] = Ctor;', ' object[type.toLowerCase()] = Ctor ? new Ctor(new ArrayBuffer(24)) : undefined;', ' });', '', @@ -621,6 +639,7 @@ ' root = this;', '', 'var object = {', + " 'ArrayBuffer': root.ArrayBuffer,", " 'arguments': (function() { return arguments; }(1, 2, 3)),", " 'array': [1],", " 'arrayBuffer': root.ArrayBuffer ? new root.ArrayBuffer : undefined,", @@ -633,6 +652,7 @@ " 'null': null,", " 'number': Object(0),", " 'object': { 'a': 1 },", + " 'promise': root.Promise ? Promise.resolve(1) : undefined,", " 'regexp': /x/,", " 'set': root.Set ? new root.Set : undefined,", " 'string': Object('a'),", @@ -642,8 +662,9 @@ " 'weakSet': root.WeakSet ? new root.WeakSet : undefined", '};', '', - "_.each(['" + typedArrays.join("', '") + "'], function(type) {", + "_.each(['" + arrayViews.join("', '") + "'], function(type) {", ' var Ctor = root[type];', + ' object[type] = Ctor;', ' object[type.toLowerCase()] = Ctor ? new Ctor(new ArrayBuffer(24)) : undefined;', '});', '', @@ -771,7 +792,9 @@ return '`' + lodashMethod + '` should avoid overwritten native `' + nativeMethod + '`'; } - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var object = { 'a': 1 }, @@ -1041,48 +1064,12 @@ assert.strictEqual(_.add(-6, -4), -10); }); - QUnit.test('should return `0` when no arguments are given', function(assert) { - assert.expect(1); - - assert.strictEqual(_.add(), 0); - }); - QUnit.test('should not coerce arguments to numbers', function(assert) { assert.expect(2); assert.strictEqual(_.add('6', '4'), '64'); assert.strictEqual(_.add('x', 'y'), 'xy'); }); - - QUnit.test('should work with only an `augend` or `addend`', function(assert) { - assert.expect(3); - - assert.strictEqual(_.add(6), 6); - assert.strictEqual(_.add(6, undefined), 6); - assert.strictEqual(_.add(undefined, 4), 4); - }); - - QUnit.test('should return an unwrapped value when implicitly chaining', function(assert) { - assert.expect(1); - - if (!isNpm) { - assert.strictEqual(_(1).add(2), 3); - } - else { - skipAssert(assert); - } - }); - - QUnit.test('should return a wrapped value when explicitly chaining', function(assert) { - assert.expect(1); - - if (!isNpm) { - assert.ok(_(1).chain().add(2) instanceof _); - } - else { - skipAssert(assert); - } - }); }()); /*--------------------------------------------------------------------------*/ @@ -1460,7 +1447,9 @@ QUnit.test('should pluck inherited property values', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var actual = _.at(new Foo, 'b'); @@ -2083,7 +2072,7 @@ var strings = [ 'foo bar', 'Foo bar', 'foo Bar', 'Foo Bar', - 'FOO BAR', 'fooBar', '--foo-bar', '__foo_bar__' + 'FOO BAR', 'fooBar', '--foo-bar--', '__foo_bar__' ]; var converted = (function() { @@ -2101,7 +2090,8 @@ assert.expect(1); var actual = lodashStable.map(strings, function(string) { - return func(string) === converted; + var expected = (caseName == 'start' && string == 'FOO BAR') ? string : converted; + return func(string) === expected; }); assert.deepEqual(actual, lodashStable.map(strings, alwaysTrue)); @@ -2111,7 +2101,8 @@ assert.expect(1); var actual = lodashStable.map(strings, function(string) { - return func(func(string)) === converted; + var expected = (caseName == 'start' && string == 'FOO BAR') ? string : converted; + return func(func(string)) === expected; }); assert.deepEqual(actual, lodashStable.map(strings, alwaysTrue)); @@ -2239,7 +2230,7 @@ QUnit.module('lodash.castArray'); (function() { - QUnit.test('should wrap non array items in an array', function(assert) { + QUnit.test('should wrap non-array items in an array', function(assert) { assert.expect(1); var values = falsey.concat(true, 1, 'a', { 'a': 1 }), @@ -2493,7 +2484,9 @@ QUnit.module('clone methods'); (function() { - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 1; Foo.c = function() {}; @@ -2585,7 +2578,7 @@ assert.expect(164); var Stack, - keys = [true, false, 1, -Infinity, NaN, {}, null, 'a', symbol || {}, undefined]; + keys = [null, undefined, false, true, 1, -Infinity, NaN, {}, 'a', symbol || {}]; var pairs = lodashStable.map(keys, function(key, index) { var lastIndex = keys.length - 1; @@ -2700,7 +2693,7 @@ QUnit.test('`_.' + methodName + '` should clone expando properties', function(assert) { assert.expect(1); - var values = lodashStable.map([true, false, 1, 'a'], function(value) { + var values = lodashStable.map([false, true, 1, 'a'], function(value) { var object = Object(value); object.a = 1; return object; @@ -2766,24 +2759,34 @@ }); QUnit.test('`_.' + methodName + '` should clone symbol properties', function(assert) { - assert.expect(2); + assert.expect(3); + + function Foo() { + this[symbol] = { 'c': 1 }; + } if (Symbol) { - var object = {}; - object[symbol] = {}; - assert.strictEqual(func(object)[symbol], object[symbol]); + var symbol2 = Symbol('b'); + Foo.prototype[symbol2] = 2; + + var object = { 'a': { 'b': new Foo } }; + object[symbol] = { 'b': 1 }; + + var actual = func(object); + + assert.deepEqual(getSymbols(actual.a.b), [symbol]); if (isDeep) { - object = { 'a': { 'b': {} } }; - object.a.b[symbol] = {}; - assert.strictEqual(func(object).a.b[symbol], object.a.b[symbol]); + assert.deepEqual(actual[symbol], object[symbol]); + assert.deepEqual(actual.a.b[symbol], object.a.b[symbol]); } else { - skipAssert(assert); + assert.strictEqual(actual[symbol], object[symbol]); + assert.strictEqual(actual.a, object.a); } } else { - skipAssert(assert, 2); + skipAssert(assert, 3); } }); @@ -2889,8 +2892,8 @@ } }); - lodashStable.each(typedArrays, function(type) { - QUnit.test('`_.' + methodName + '` should clone ' + type + ' arrays', function(assert) { + lodashStable.each(arrayViews, function(type) { + QUnit.test('`_.' + methodName + '` should clone ' + type + ' values', function(assert) { assert.expect(10); var Ctor = root[type]; @@ -2898,14 +2901,14 @@ lodashStable.times(2, function(index) { if (Ctor) { var buffer = new ArrayBuffer(24), - array = index ? new Ctor(buffer, 8, 1) : new Ctor(buffer), - actual = func(array); - - assert.deepEqual(actual, array); - assert.notStrictEqual(actual, array); - assert.strictEqual(actual.buffer === array.buffer, !isDeep); - assert.strictEqual(actual.byteOffset, array.byteOffset); - assert.strictEqual(actual.length, array.length); + view = index ? new Ctor(buffer, 8, 1) : new Ctor(buffer), + actual = func(view); + + assert.deepEqual(actual, view); + assert.notStrictEqual(actual, view); + assert.strictEqual(actual.buffer === view.buffer, !isDeep); + assert.strictEqual(actual.byteOffset, view.byteOffset); + assert.strictEqual(actual.length, view.length); } else { skipAssert(assert, 5); @@ -2942,16 +2945,16 @@ assert.expect(1); var argsList = [], - foo = new Foo; + object = new Foo; - func(foo, function() { + func(object, function() { var length = arguments.length, args = slice.call(arguments, 0, length - (length > 1 ? 1 : 0)); argsList.push(args); }); - assert.deepEqual(argsList, isDeep ? [[foo], [1, 'a', foo]] : [[foo]]); + assert.deepEqual(argsList, isDeep ? [[object], [1, 'a', object]] : [[object]]); }); QUnit.test('`_.' + methodName + '` should handle cloning if `customizer` returns `undefined`', function(assert) { @@ -3053,6 +3056,16 @@ QUnit.module('lodash.concat'); (function() { + QUnit.test('should shallow clone `array`', function(assert) { + assert.expect(2); + + var array = [1, 2, 3], + actual = _.concat(array); + + assert.deepEqual(actual, array); + assert.notStrictEqual(actual, array); + }); + QUnit.test('should concat arrays and values', function(assert) { assert.expect(2); @@ -3063,31 +3076,27 @@ assert.deepEqual(array, [1]); }); - QUnit.test('should return an empty array when `array` is nullish', function(assert) { - assert.expect(1); + QUnit.test('should cast non-array `array` values to arrays', function(assert) { + assert.expect(2); - var values = [, null, undefined], - expected = lodashStable.map(values, alwaysEmptyArray); + var values = [, null, undefined, false, true, 1, NaN, 'a']; + + var expected = lodashStable.map(values, function(value, index) { + return index ? [value] : []; + }); var actual = lodashStable.map(values, function(value, index) { - try { - return index ? _.concat(value) : _.concat(); - } catch (e) {} + return index ? _.concat(value) : _.concat(); }); assert.deepEqual(actual, expected); - }); - - QUnit.test('should treat nullish `array` values as empty arrays', function(assert) { - assert.expect(1); - var values = [null, undefined], - expected = lodashStable.map(values, lodashStable.constant([1, 2, [3]])); + expected = lodashStable.map(values, function(value) { + return [value, 2, [3]]; + }); - var actual = lodashStable.map(values, function(value) { - try { - return _.concat(value, 1, [2], [[3]]); - } catch (e) {} + actual = lodashStable.map(values, function(value) { + return _.concat(value, [2], [[3]]); }); assert.deepEqual(actual, expected); @@ -3184,7 +3193,7 @@ QUnit.test('should throw a TypeError if `pairs` is not composed of functions', function(assert) { assert.expect(2); - lodashStable.each([true, false], function(value) { + lodashStable.each([false, true], function(value) { assert.raises(function() { _.cond([[alwaysTrue, value]])(); }, TypeError); }); }); @@ -3239,7 +3248,6 @@ return value > 1; }; } - Foo.prototype.b = function(value) { return value > 8; }; @@ -3590,8 +3598,7 @@ QUnit.test('should ignore primitive `prototype` arguments and use an empty object instead', function(assert) { assert.expect(1); - var primitives = [true, null, 1, 'a', undefined], - expected = lodashStable.map(primitives, alwaysTrue); + var expected = lodashStable.map(primitives, alwaysTrue); var actual = lodashStable.map(primitives, function(value, index) { return lodashStable.isPlainObject(index ? _.create(value) : _.create()); @@ -3707,7 +3714,7 @@ assert.deepEqual(curried(1, 2, 3, 4, 5, 6), [1, 2, 3, 4, 5, 6]); }); - QUnit.test('should return a function with a `length` of `0`', function(assert) { + QUnit.test('should create a function with a `length` of `0`', function(assert) { assert.expect(6); lodashStable.times(2, function(index) { @@ -3721,9 +3728,9 @@ QUnit.test('should ensure `new curried` is an instance of `func`', function(assert) { assert.expect(2); - var Foo = function(value) { + function Foo(value) { return value && object; - }; + } var curried = _.curry(Foo), object = {}; @@ -3866,7 +3873,7 @@ assert.deepEqual(curried(1, 2, 3, 4, 5, 6), [1, 2, 3, 4, 5, 6]); }); - QUnit.test('should return a function with a `length` of `0`', function(assert) { + QUnit.test('should create a function with a `length` of `0`', function(assert) { assert.expect(6); lodashStable.times(2, function(index) { @@ -3880,9 +3887,9 @@ QUnit.test('should ensure `new curried` is an instance of `func`', function(assert) { assert.expect(2); - var Foo = function(value) { + function Foo(value) { return value && object; - }; + } var curried = _.curryRight(Foo), object = {}; @@ -3994,23 +4001,38 @@ (function() { QUnit.test('should debounce a function', function(assert) { - assert.expect(2); + assert.expect(6); var done = assert.async(); - var callCount = 0, - debounced = _.debounce(function() { callCount++; }, 32); + var callCount = 0; - debounced(); - debounced(); - debounced(); + var debounced = _.debounce(function(value) { + ++callCount; + return value; + }, 32); + // Leading should not fire. + var actual = [debounced(0), debounced(1), debounced(2)]; + assert.deepEqual(actual, [undefined, undefined, undefined]); assert.strictEqual(callCount, 0); setTimeout(function() { + // Trailing should fire by now. assert.strictEqual(callCount, 1); + + // Do it again. + var actual = [debounced(3), debounced(4), debounced(5)]; + + // Previous result. + assert.deepEqual(actual, [2, 2, 2]); + assert.strictEqual(callCount, 1); + }, 128); + + setTimeout(function() { + assert.strictEqual(callCount, 2); done(); - }, 96); + }, 256); }); QUnit.test('subsequent debounced calls return the last `func` result', function(assert) { @@ -4133,19 +4155,54 @@ }); QUnit.test('should support a `maxWait` option', function(assert) { - assert.expect(1); + assert.expect(6); var done = assert.async(); - var limit = (argv || isPhantom) ? 1000 : 320, - withCount = 0, - withoutCount = 0; - - var withMaxWait = _.debounce(function() { - withCount++; - }, 64, { 'maxWait': 128 }); + var callCount = 0; - var withoutMaxWait = _.debounce(function() { + var debounced = _.debounce(function(value) { + ++callCount; + return value; + }, 32, { 'maxWait': 64 }); + + // Leading should not fire. + var actual = [debounced(0), debounced(1), debounced(2)]; + assert.deepEqual(actual, [undefined, undefined, undefined]); + assert.strictEqual(callCount, 0); + + setTimeout(function() { + // Trailing should fire by now. + assert.strictEqual(callCount, 1); + + // Do it again. + var actual = [debounced(3), debounced(4), debounced(5)]; + + // Previous result. + assert.deepEqual(actual, [2, 2, 2]); + assert.strictEqual(callCount, 1); + }, 128); + + setTimeout(function() { + assert.strictEqual(callCount, 2); + done(); + }, 256); + }); + + QUnit.test('should support `maxWait` in a tight loop', function(assert) { + assert.expect(1); + + var done = assert.async(); + + var limit = (argv || isPhantom) ? 1000 : 320, + withCount = 0, + withoutCount = 0; + + var withMaxWait = _.debounce(function() { + withCount++; + }, 64, { 'maxWait': 128 }); + + var withoutMaxWait = _.debounce(function() { withoutCount++; }, 96); @@ -4154,10 +4211,10 @@ withMaxWait(); withoutMaxWait(); } - var actual = [Boolean(withCount), Boolean(withoutCount)]; + var actual = [Boolean(withoutCount), Boolean(withCount)]; setTimeout(function() { - assert.deepEqual(actual, [true, false]); + assert.deepEqual(actual, [false, true]); done(); }, 1); }); @@ -4666,6 +4723,27 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.divide'); + + (function() { + QUnit.test('should divide two numbers', function(assert) { + assert.expect(3); + + assert.strictEqual(_.divide(6, 4), 1.5); + assert.strictEqual(_.divide(-6, 4), -1.5); + assert.strictEqual(_.divide(-6, -4), 1.5); + }); + + QUnit.test('should coerce arguments to numbers', function(assert) { + assert.expect(2); + + assert.strictEqual(_.divide('6', '4'), 1.5); + assert.deepEqual(_.divide('x', 'y'), NaN); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.drop'); (function() { @@ -5466,7 +5544,7 @@ QUnit.test('should iterate over an object with numeric keys (test in Mobile Safari 8)', function(assert) { assert.expect(1); - // Trigger a Mobile Safari 8 JIT bug. + // Trigger a mobile Safari 8 JIT bug. // See https://github.com/lodash/lodash/issues/799. var counter = 0, object = { '1': 'foo', '8': 'bar', '50': 'baz' }; @@ -5689,108 +5767,130 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.flatMap'); + QUnit.module('lodash.flatMapDepth'); (function() { - var array = [1, 2, 3, 4]; + var array = [1, [2, [3, [4]], 5]]; + + QUnit.test('should use a default `depth` of `1`', function(assert) { + assert.expect(1); + + assert.deepEqual(_.flatMapDepth(array, identity), [1, 2, [3, [4]], 5]); + }); + + QUnit.test('should use `_.identity` when `iteratee` is nullish', function(assert) { + assert.expect(1); + + var values = [, null, undefined], + expected = lodashStable.map(values, lodashStable.constant([1, 2, [3, [4]], 5])); + + var actual = lodashStable.map(values, function(value, index) { + return index ? _.flatMapDepth(array, value) : _.flatMapDepth(array); + }); + + assert.deepEqual(actual, expected); + }); + + QUnit.test('should treat a `depth` of < `1` as a shallow clone', function(assert) { + assert.expect(2); + + lodashStable.each([-1, 0], function(depth) { + assert.deepEqual(_.flatMapDepth(array, identity, depth), [1, [2, [3, [4]], 5]]); + }); + }); + + QUnit.test('should coerce `depth` to an integer', function(assert) { + assert.expect(1); + + assert.deepEqual(_.flatMapDepth(array, identity, 2.2), [1, 2, 3, [4], 5]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('flatMap methods'); + + lodashStable.each(['flatMap', 'flatMapDeep', 'flatMapDepth'], function(methodName) { + var func = _[methodName], + isDeep = methodName == 'flatMapDeep', + array = [1, 2, 3, 4]; function duplicate(n) { return [n, n]; } - QUnit.test('should map values in `array` to a new flattened array', function(assert) { + QUnit.test('`_.' + methodName + '` should map values in `array` to a new flattened array', function(assert) { assert.expect(1); - var actual = _.flatMap(array, duplicate), + var actual = func(array, duplicate), expected = lodashStable.flatten(lodashStable.map(array, duplicate)); assert.deepEqual(actual, expected); }); - QUnit.test('should work with "_.property" shorthands', function(assert) { + QUnit.test('`_.' + methodName + '` should work with "_.property" shorthands', function(assert) { assert.expect(1); var objects = [{ 'a': [1, 2] }, { 'a': [3, 4] }]; - assert.deepEqual(_.flatMap(objects, 'a'), array); + assert.deepEqual(func(objects, 'a'), array); }); - QUnit.test('should iterate over own properties of objects', function(assert) { + QUnit.test('`_.' + methodName + '` should iterate over own string keyed properties of objects', function(assert) { assert.expect(1); - function Foo() { this.a = [1, 2]; } + function Foo() { + this.a = [1, 2]; + } Foo.prototype.b = [3, 4]; - var actual = _.flatMap(new Foo, identity); + var actual = func(new Foo, identity); assert.deepEqual(actual, [1, 2]); }); - QUnit.test('should use `_.identity` when `iteratee` is nullish', function(assert) { - assert.expect(1); + QUnit.test('`_.' + methodName + '` should use `_.identity` when `iteratee` is nullish', function(assert) { + assert.expect(2); var array = [[1, 2], [3, 4]], + object = { 'a': [1, 2], 'b': [3, 4] }, values = [, null, undefined], expected = lodashStable.map(values, lodashStable.constant([1, 2, 3, 4])); - var actual = lodashStable.map(values, function(value, index) { - return index ? _.flatMap(array, value) : _.flatMap(array); - }); - - assert.deepEqual(actual, expected); - }); - - QUnit.test('should work on an object with no `iteratee`', function(assert) { - assert.expect(1); - - var actual = _.flatMap({ 'a': [1, 2], 'b': [3, 4] }); - assert.deepEqual(actual, array); - }); - - QUnit.test('should handle object arguments with non-number length properties', function(assert) { - assert.expect(1); + lodashStable.each([array, object], function(collection) { + var actual = lodashStable.map(values, function(value, index) { + return index ? func(collection, value) : func(collection); + }); - var object = { 'length': [1, 2] }; - assert.deepEqual(_.flatMap(object, identity), [1, 2]); + assert.deepEqual(actual, expected); + }); }); - QUnit.test('should accept a falsey `collection` argument', function(assert) { + QUnit.test('`_.' + methodName + '` should accept a falsey `collection` argument', function(assert) { assert.expect(1); var expected = lodashStable.map(falsey, alwaysEmptyArray); var actual = lodashStable.map(falsey, function(collection, index) { try { - return index ? _.flatMap(collection) : _.flatMap(); + return index ? func(collection) : func(); } catch (e) {} }); assert.deepEqual(actual, expected); }); - QUnit.test('should treat number values for `collection` as empty', function(assert) { + QUnit.test('`_.' + methodName + '` should treat number values for `collection` as empty', function(assert) { assert.expect(1); - assert.deepEqual(_.flatMap(1), []); + assert.deepEqual(func(1), []); }); - QUnit.test('should work in a lazy sequence', function(assert) { - assert.expect(2); - - if (!isNpm) { - var largeArray = lodashStable.range(LARGE_ARRAY_SIZE), - smallArray = array; - - lodashStable.times(2, function(index) { - var array = index ? largeArray : smallArray, - actual = _(array).filter(isEven).flatMap(duplicate).take(2).value(); + QUnit.test('`_.' + methodName + '` should work with objects with non-number length properties', function(assert) { + assert.expect(1); - assert.deepEqual(actual, _.take(_.flatMap(_.filter(array, isEven), duplicate), 2)); - }); - } - else { - skipAssert(assert, 2); - } + var object = { 'length': [1, 2] }; + assert.deepEqual(func(object, identity), [1, 2]); }); - }()); + }); /*--------------------------------------------------------------------------*/ @@ -6075,10 +6175,12 @@ lodashStable.each(['forIn', 'forInRight'], function(methodName) { var func = _[methodName]; - QUnit.test('`_.' + methodName + '` iterates over inherited properties', function(assert) { + QUnit.test('`_.' + methodName + '` iterates over inherited string keyed properties', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var keys = []; @@ -6383,10 +6485,12 @@ var array = [1, 2, 3], func = _[methodName]; - QUnit.test('`_.' + methodName + '` iterates over own properties of objects', function(assert) { + QUnit.test('`_.' + methodName + '` iterates over own string keyed properties of objects', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; if (func) { @@ -6519,20 +6623,25 @@ QUnit.test('`_.' + methodName + '` should coerce primitives to objects', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysTrue); + var expected = lodashStable.map(primitives, function(value) { + var object = Object(value); + object.a = 1; + return object; + }); - var actual = lodashStable.map(falsey, function(object, index) { - var result = index ? func(object) : func(); - return lodashStable.isEqual(result, Object(object)); + var actual = lodashStable.map(primitives, function(value) { + return func(value, { 'a': 1 }); }); assert.deepEqual(actual, expected); }); - QUnit.test('`_.' + methodName + '` should assign own ' + (isAssign ? '' : 'and inherited ') + 'source properties', function(assert) { + QUnit.test('`_.' + methodName + '` should assign own ' + (isAssign ? '' : 'and inherited ') + 'string keyed source properties', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var expected = isAssign ? { 'a': 1 } : { 'a': 1, 'b': 2 }; @@ -6842,8 +6951,10 @@ QUnit.test('should return the function names of an object', function(assert) { assert.expect(1); - var object = { 'a': 'a', 'b': identity, 'c': /x/, 'd': lodashStable.each }; - assert.deepEqual(_.functions(object).sort(), ['b', 'd']); + var object = { 'a': 'a', 'b': identity, 'c': /x/, 'd': noop }, + actual = _.functions(object).sort(); + + assert.deepEqual(actual, ['b', 'd']); }); QUnit.test('should not include inherited functions', function(assert) { @@ -6854,7 +6965,8 @@ this.b = 'b'; } Foo.prototype.c = noop; - assert.deepEqual(_.functions(new Foo).sort(), ['a']); + + assert.deepEqual(_.functions(new Foo), ['a']); }); }()); @@ -7052,7 +7164,7 @@ assert.strictEqual(func(args, 1), true); }); - QUnit.test('`_.' + methodName + '` should work with non-string `path` arguments', function(assert) { + QUnit.test('`_.' + methodName + '` should work with a non-string `path`', function(assert) { assert.expect(2); var array = [1, 2, 3]; @@ -7062,6 +7174,25 @@ }); }); + QUnit.test('`_.' + methodName + '` should work with a symbol `path`', function(assert) { + assert.expect(1); + + function Foo() { + this[symbol] = 1; + } + + if (Symbol) { + var symbol2 = Symbol('b'); + Foo.prototype[symbol2] = 2; + var path = isHas ? symbol : symbol2; + + assert.strictEqual(func(new Foo, path), true); + } + else { + skipAssert(assert); + } + }); + QUnit.test('`_.' + methodName + '` should work for objects with a `[[Prototype]]` of `null`', function(assert) { assert.expect(1); @@ -7096,6 +7227,17 @@ }); }); + QUnit.test('`_.' + methodName + '` should return `' + (isHas ? 'false' : 'true') + '` for nested inherited properties', function(assert) { + assert.expect(2); + + function Foo() {} + Foo.prototype.a = { 'b': 1 }; + + lodashStable.each(['a.b', ['a', 'b']], function(path) { + assert.strictEqual(func(new Foo, path), !isHas); + }); + }); + QUnit.test('`_.' + methodName + '` should return `true` for index values within bounds for arrays, `arguments` objects, and strings', function(assert) { assert.expect(1); @@ -8377,7 +8519,7 @@ } }); - QUnit.test('should return `false` for non buffers', function(assert) { + QUnit.test('should return `false` for non-buffers', function(assert) { assert.expect(13); var expected = lodashStable.map(falsey, alwaysFalse); @@ -8533,7 +8675,7 @@ var args = arguments; QUnit.test('should return `true` for empty values', function(assert) { - assert.expect(8); + assert.expect(10); var expected = lodashStable.map(empties, alwaysTrue), actual = lodashStable.map(empties, _.isEmpty); @@ -8547,6 +8689,14 @@ assert.strictEqual(_.isEmpty(/x/), true); assert.strictEqual(_.isEmpty(symbol), true); assert.strictEqual(_.isEmpty(), true); + + if (Buffer) { + assert.strictEqual(_.isEmpty(new Buffer(0)), true); + assert.strictEqual(_.isEmpty(new Buffer(1)), false); + } + else { + skipAssert(assert, 2); + } }); QUnit.test('should return `false` for non-empty values', function(assert) { @@ -8572,12 +8722,46 @@ QUnit.test('should work with jQuery/MooTools DOM query collections', function(assert) { assert.expect(1); - function Foo(elements) { push.apply(this, elements); } + function Foo(elements) { + push.apply(this, elements); + } Foo.prototype = { 'length': 0, 'splice': arrayProto.splice }; assert.strictEqual(_.isEmpty(new Foo([])), true); }); + QUnit.test('should work with maps', function(assert) { + assert.expect(4); + + if (Map) { + lodashStable.each([new Map, realm.map], function(map) { + assert.strictEqual(_.isEmpty(map), true); + map.set('a', 1); + assert.strictEqual(_.isEmpty(map), false); + map.clear(); + }); + } + else { + skipAssert(assert, 4); + } + }); + + QUnit.test('should work with sets', function(assert) { + assert.expect(4); + + if (Set) { + lodashStable.each([new Set, realm.set], function(set) { + assert.strictEqual(_.isEmpty(set), true); + set.add(1); + assert.strictEqual(_.isEmpty(set), false); + set.clear(); + }); + } + else { + skipAssert(assert, 4); + } + }); + QUnit.test('should not treat objects with negative lengths as array-like', function(assert) { assert.expect(1); @@ -8812,10 +8996,14 @@ QUnit.test('should compare object instances', function(assert) { assert.expect(4); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.a = 1; - function Bar() { this.a = 1; } + function Bar() { + this.a = 1; + } Bar.prototype.a = 2; assert.strictEqual(_.isEqual(new Foo, new Foo), true); @@ -8954,7 +9142,9 @@ QUnit.test('should treat objects created by `Object.create(null)` like a plain object', function(assert) { assert.expect(2); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.constructor = null; var object2 = { 'a': 1 }; @@ -9046,6 +9236,33 @@ } }); + QUnit.test('should compare array views', function(assert) { + assert.expect(2); + + lodashStable.times(2, function(index) { + var ns = index ? realm : root; + + var pairs = lodashStable.map(arrayViews, function(type, viewIndex) { + var otherType = arrayViews[(viewIndex + 1) % arrayViews.length], + CtorA = ns[type] || function(n) { this.n = n; }, + CtorB = ns[otherType] || function(n) { this.n = n; }, + bufferA = ns[type] ? new ns.ArrayBuffer(8) : 8, + bufferB = ns[otherType] ? new ns.ArrayBuffer(8) : 8, + bufferC = ns[otherType] ? new ns.ArrayBuffer(16) : 16; + + return [new CtorA(bufferA), new CtorA(bufferA), new CtorB(bufferB), new CtorB(bufferC)]; + }); + + var expected = lodashStable.map(pairs, lodashStable.constant([true, false, false])); + + var actual = lodashStable.map(pairs, function(pair) { + return [_.isEqual(pair[0], pair[1]), _.isEqual(pair[0], pair[2]), _.isEqual(pair[2], pair[3])]; + }); + + assert.deepEqual(actual, expected); + }); + }); + QUnit.test('should compare date objects', function(assert) { assert.expect(4); @@ -9096,29 +9313,34 @@ }); QUnit.test('should compare maps', function(assert) { - assert.expect(4); + assert.expect(8); if (Map) { - var map1 = new Map, - map2 = new Map; + lodashStable.each([[map, new Map], [map, realm.map]], function(maps) { + var map1 = maps[0], + map2 = maps[1]; - map1.set('a', 1); - map2.set('b', 2); - assert.strictEqual(_.isEqual(map1, map2), false); + map1.set('a', 1); + map2.set('b', 2); + assert.strictEqual(_.isEqual(map1, map2), false); - map1.set('b', 2); - map2.set('a', 1); - assert.strictEqual(_.isEqual(map1, map2), true); + map1.set('b', 2); + map2.set('a', 1); + assert.strictEqual(_.isEqual(map1, map2), true); - map1['delete']('a'); - map1.set('a', 1); - assert.strictEqual(_.isEqual(map1, map2), true); + map1['delete']('a'); + map1.set('a', 1); + assert.strictEqual(_.isEqual(map1, map2), true); - map2['delete']('a'); - assert.strictEqual(_.isEqual(map1, map2), false); + map2['delete']('a'); + assert.strictEqual(_.isEqual(map1, map2), false); + + map1.clear(); + map2.clear(); + }); } else { - skipAssert(assert, 4); + skipAssert(assert, 8); } }); @@ -9142,6 +9364,23 @@ } }); + QUnit.test('should compare promises by reference', function(assert) { + assert.expect(4); + + if (promise) { + lodashStable.each([[promise, Promise.resolve(1)], [promise, realm.promise]], function(promises) { + var promise1 = promises[0], + promise2 = promises[1]; + + assert.strictEqual(_.isEqual(promise1, promise2), false); + assert.strictEqual(_.isEqual(promise1, promise1), true); + }); + } + else { + skipAssert(assert, 4); + } + }); + QUnit.test('should compare regexes', function(assert) { assert.expect(5); @@ -9153,29 +9392,34 @@ }); QUnit.test('should compare sets', function(assert) { - assert.expect(4); + assert.expect(8); if (Set) { - var set1 = new Set, - set2 = new Set; + lodashStable.each([[set, new Set], [set, realm.set]], function(sets) { + var set1 = sets[0], + set2 = sets[1]; - set1.add(1); - set2.add(2); - assert.strictEqual(_.isEqual(set1, set2), false); + set1.add(1); + set2.add(2); + assert.strictEqual(_.isEqual(set1, set2), false); - set1.add(2); - set2.add(1); - assert.strictEqual(_.isEqual(set1, set2), true); + set1.add(2); + set2.add(1); + assert.strictEqual(_.isEqual(set1, set2), true); - set1['delete'](1); - set1.add(1); - assert.strictEqual(_.isEqual(set1, set2), true); + set1['delete'](1); + set1.add(1); + assert.strictEqual(_.isEqual(set1, set2), true); - set2['delete'](1); - assert.strictEqual(_.isEqual(set1, set2), false); + set2['delete'](1); + assert.strictEqual(_.isEqual(set1, set2), false); + + set1.clear(); + set2.clear(); + }); } else { - skipAssert(assert, 4); + skipAssert(assert, 8); } }); @@ -9199,38 +9443,15 @@ } }); - QUnit.test('should compare typed arrays', function(assert) { + QUnit.test('should work as an iteratee for `_.every`', function(assert) { assert.expect(1); - var pairs = lodashStable.map(typedArrays, function(type, index) { - var otherType = typedArrays[(index + 1) % typedArrays.length], - CtorA = root[type] || function(n) { this.n = n; }, - CtorB = root[otherType] || function(n) { this.n = n; }, - bufferA = root[type] ? new ArrayBuffer(8) : 8, - bufferB = root[otherType] ? new ArrayBuffer(8) : 8, - bufferC = root[otherType] ? new ArrayBuffer(16) : 16; + var actual = lodashStable.every([1, 1, 1], lodashStable.partial(_.isEqual, 1)); + assert.ok(actual); + }); - return [new CtorA(bufferA), new CtorA(bufferA), new CtorB(bufferB), new CtorB(bufferC)]; - }); - - var expected = lodashStable.map(pairs, lodashStable.constant([true, false, false])); - - var actual = lodashStable.map(pairs, function(pair) { - return [_.isEqual(pair[0], pair[1]), _.isEqual(pair[0], pair[2]), _.isEqual(pair[2], pair[3])]; - }); - - assert.deepEqual(actual, expected); - }); - - QUnit.test('should work as an iteratee for `_.every`', function(assert) { - assert.expect(1); - - var actual = lodashStable.every([1, 1, 1], lodashStable.partial(_.isEqual, 1)); - assert.ok(actual); - }); - - QUnit.test('should return `true` for like-objects from different documents', function(assert) { - assert.expect(4); + QUnit.test('should return `true` for like-objects from different documents', function(assert) { + assert.expect(4); if (realm.object) { assert.strictEqual(_.isEqual([1], realm.array), true); @@ -9634,14 +9855,14 @@ assert.strictEqual(_.isFunction(generator), typeof generator == 'function'); }); - QUnit.test('should return `true` for typed array constructors', function(assert) { + QUnit.test('should return `true` for array view constructors', function(assert) { assert.expect(1); - var expected = lodashStable.map(typedArrays, function(type) { + var expected = lodashStable.map(arrayViews, function(type) { return objToString.call(root[type]) == funcTag; }); - var actual = lodashStable.map(typedArrays, function(type) { + var actual = lodashStable.map(arrayViews, function(type) { return _.isFunction(root[type]); }); @@ -9810,7 +10031,7 @@ } }); - QUnit.test('should return `false` for non maps', function(assert) { + QUnit.test('should return `false` for non-maps', function(assert) { assert.expect(14); var expected = lodashStable.map(falsey, alwaysFalse); @@ -9836,6 +10057,19 @@ assert.strictEqual(_.isMap(weakMap), false); }); + QUnit.test('should work for objects with a non-function `constructor` (test in IE 11)', function(assert) { + assert.expect(1); + + var values = [false, true], + expected = lodashStable.map(values, alwaysFalse); + + var actual = lodashStable.map(values, function(value) { + return _.isMap({ 'constructor': value }); + }); + + assert.deepEqual(actual, expected); + }); + QUnit.test('should work with maps from another realm', function(assert) { assert.expect(1); @@ -9866,10 +10100,12 @@ assert.strictEqual(_.isMatch(object, { 'a': { 'b': { 'c': 1 } } }), true); }); - QUnit.test('should match inherited `object` properties', function(assert) { + QUnit.test('should match inherited string keyed `object` properties', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; assert.strictEqual(_.isMatch({ 'a': new Foo }, { 'a': { 'b': 2 } }), true); @@ -9878,7 +10114,9 @@ QUnit.test('should not match by inherited `source` properties', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], @@ -10686,10 +10924,10 @@ // See https://code.google.com/p/v8/issues/detail?id=2291. var object = {}; - // 1: Useless comparison statement, this is half the trigger. + // First, have a comparison statement. object == object; - // 2: Initial check with object, this is the other half of the trigger. + // Then perform the check with `object`. _.isObject(object); assert.strictEqual(_.isObject('a'), false); @@ -10800,6 +11038,18 @@ } }); + QUnit.test('should return `false` for objects with a custom `[[Prototype]]`', function(assert) { + assert.expect(1); + + if (create) { + var object = create({ 'a': 1 }); + assert.strictEqual(_.isPlainObject(object), false); + } + else { + skipAssert(assert); + } + }); + QUnit.test('should return `false` for DOM elements', function(assert) { assert.expect(1); @@ -10914,7 +11164,7 @@ } }); - QUnit.test('should return `false` for non sets', function(assert) { + QUnit.test('should return `false` for non-sets', function(assert) { assert.expect(14); var expected = lodashStable.map(falsey, alwaysFalse); @@ -10940,6 +11190,19 @@ assert.strictEqual(_.isSet(weakSet), false); }); + QUnit.test('should work for objects with a non-function `constructor` (test in IE 11)', function(assert) { + assert.expect(1); + + var values = [false, true], + expected = lodashStable.map(values, alwaysFalse); + + var actual = lodashStable.map(values, function(value) { + return _.isSet({ 'constructor': value }); + }); + + assert.deepEqual(actual, expected); + }); + QUnit.test('should work with weak sets from another realm', function(assert) { assert.expect(1); @@ -11232,6 +11495,19 @@ assert.strictEqual(_.isWeakMap(symbol), false); }); + QUnit.test('should work for objects with a non-function `constructor` (test in IE 11)', function(assert) { + assert.expect(1); + + var values = [false, true], + expected = lodashStable.map(values, alwaysFalse); + + var actual = lodashStable.map(values, function(value) { + return _.isWeakMap({ 'constructor': value }); + }); + + assert.deepEqual(actual, expected); + }); + QUnit.test('should work with weak maps from another realm', function(assert) { assert.expect(1); @@ -11320,7 +11596,8 @@ var object = new Foo; if (objToString.call(object) == objectTag) { assert.strictEqual(_[methodName](object), false, '`_.' + methodName + '` returns `false`'); - } else { + } + else { skipAssert(assert); } }); @@ -11813,6 +12090,19 @@ } }); + QUnit.test('`_.meanBy` should use `_.iteratee` internally', function(assert) { + assert.expect(1); + + if (!isModularize) { + _.iteratee = getPropA; + assert.strictEqual(_.meanBy(objects), 2 / 3); + _.iteratee = iteratee; + } + else { + skipAssert(assert); + } + }); + QUnit.test('`_.minBy` should use `_.iteratee` internally', function(assert) { assert.expect(1); @@ -12207,16 +12497,37 @@ func = _[methodName], isKeys = methodName == 'keys'; - QUnit.test('`_.' + methodName + '` should return the keys of an object', function(assert) { + QUnit.test('`_.' + methodName + '` should return the string keyed property names of `object`', function(assert) { assert.expect(1); - assert.deepEqual(func({ 'a': 1, 'b': 1 }).sort(), ['a', 'b']); + var actual = func({ 'a': 1, 'b': 1 }).sort(); + + assert.deepEqual(actual, ['a', 'b']); + }); + + QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties', function(assert) { + assert.expect(1); + + function Foo() { + this.a = 1; + } + Foo.prototype.b = 2; + + var expected = isKeys ? ['a'] : ['a', 'b'], + actual = func(new Foo).sort(); + + assert.deepEqual(actual, expected); }); QUnit.test('`_.' + methodName + '` should coerce primitives to objects (test in IE 9)', function(assert) { assert.expect(2); - assert.deepEqual(func('abc').sort(), ['0', '1', '2']); + var expected = lodashStable.map(primitives, function(value) { + return typeof value == 'string' ? ['0'] : []; + }); + + var actual = lodashStable.map(primitives, func); + assert.deepEqual(actual, expected); // IE 9 doesn't box numbers in for-in loops. numberProto.a = 1; @@ -12230,7 +12541,9 @@ var array = [1]; array[2] = 3; - assert.deepEqual(func(array).sort(), ['0', '1', '2']); + var actual = func(array).sort(); + + assert.deepEqual(actual, ['0', '1', '2']); }); QUnit.test('`_.' + methodName + '` should not coerce nullish values to objects', function(assert) { @@ -12249,16 +12562,21 @@ var array = [1]; array.a = 1; - assert.deepEqual(func(array).sort(), ['0', 'a']); + var actual = func(array).sort(); + + assert.deepEqual(actual, ['0', 'a']); }); - QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited properties of arrays', function(assert) { + QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties of arrays', function(assert) { assert.expect(1); - var expected = isKeys ? ['0'] : ['0', 'a']; - arrayProto.a = 1; - assert.deepEqual(func([1]).sort(), expected); + + var expected = isKeys ? ['0'] : ['0', 'a'], + actual = func([1]).sort(); + + assert.deepEqual(actual, expected); + delete arrayProto.a; }); @@ -12266,8 +12584,11 @@ assert.expect(1); var values = [args, strictArgs], - expected = lodashStable.map(values, lodashStable.constant(['0', '1', '2'])), - actual = lodashStable.map(values, func); + expected = lodashStable.map(values, lodashStable.constant(['0', '1', '2'])); + + var actual = lodashStable.map(values, function(value) { + return func(value).sort(); + }); assert.deepEqual(actual, expected); }); @@ -12288,7 +12609,7 @@ assert.deepEqual(actual, expected); }); - QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited properties of `arguments` objects', function(assert) { + QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties of `arguments` objects', function(assert) { assert.expect(1); var values = [args, strictArgs], @@ -12307,7 +12628,9 @@ QUnit.test('`_.' + methodName + '` should work with string objects', function(assert) { assert.expect(1); - assert.deepEqual(func(Object('abc')).sort(), ['0', '1', '2']); + var actual = func(Object('abc')).sort(); + + assert.deepEqual(actual, ['0', '1', '2']); }); QUnit.test('`_.' + methodName + '` should return keys for custom properties on string objects', function(assert) { @@ -12316,16 +12639,21 @@ var object = Object('a'); object.a = 1; - assert.deepEqual(func(object).sort(), ['0', 'a']); + var actual = func(object).sort(); + + assert.deepEqual(actual, ['0', 'a']); }); - QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited properties of string objects', function(assert) { + QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited string keyed properties of string objects', function(assert) { assert.expect(1); - var expected = isKeys ? ['0'] : ['0', 'a']; - stringProto.a = 1; - assert.deepEqual(func(Object('a')).sort(), expected); + + var expected = isKeys ? ['0'] : ['0', 'a'], + actual = func(Object('a')).sort(); + + assert.deepEqual(actual, expected); + delete stringProto.a; }); @@ -12345,16 +12673,6 @@ Fake.prototype.constructor = Fake; assert.deepEqual(func(Fake.prototype), ['constructor']); }); - - QUnit.test('`_.' + methodName + '` should ' + (isKeys ? 'not ' : '') + 'include inherited properties', function(assert) { - assert.expect(1); - - function Foo() { this.a = 1; } - Foo.prototype.b = 2; - - var expected = isKeys ? ['a'] : ['a', 'b']; - assert.deepEqual(func(new Foo).sort(), expected); - }); }); /*--------------------------------------------------------------------------*/ @@ -12450,7 +12768,7 @@ QUnit.test('should lowercase as space-separated words', function(assert) { assert.expect(3); - assert.strictEqual(_.lowerCase('--Foo-Bar'), 'foo bar'); + assert.strictEqual(_.lowerCase('--Foo-Bar--'), 'foo bar'); assert.strictEqual(_.lowerCase('fooBar'), 'foo bar'); assert.strictEqual(_.lowerCase('__FOO_BAR__'), 'foo bar'); }); @@ -12638,7 +12956,7 @@ }); QUnit.test('`_.' + methodName + '` should match `NaN`', function(assert) { - assert.expect(4); + assert.expect(3); var array = isSorted ? [1, 2, NaN, NaN] @@ -12646,13 +12964,12 @@ if (isSorted) { assert.strictEqual(func(array, NaN, true), isIndexOf ? 2 : 3); - skipAssert(assert, 3); + skipAssert(assert, 2); } else { assert.strictEqual(func(array, NaN), isIndexOf ? 1 : 5); assert.strictEqual(func(array, NaN, 2), isIndexOf ? 3 : 1); assert.strictEqual(func(array, NaN, -2), isIndexOf ? 5 : 3); - skipAssert(assert); } }); @@ -12688,10 +13005,12 @@ assert.deepEqual(_.map(objects, 'a'), ['x', 'y']); }); - QUnit.test('should iterate over own properties of objects', function(assert) { + QUnit.test('should iterate over own string keyed properties of objects', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var actual = _.map(new Foo, identity); @@ -12699,32 +13018,39 @@ }); QUnit.test('should use `_.identity` when `iteratee` is nullish', function(assert) { - assert.expect(1); + assert.expect(2); - var values = [, null, undefined], + var object = { 'a': 1, 'b': 2 }, + values = [, null, undefined], expected = lodashStable.map(values, lodashStable.constant([1, 2])); - var actual = lodashStable.map(values, function(value, index) { - return index ? _.map(array, value) : _.map(array); - }); + lodashStable.each([array, object], function(collection) { + var actual = lodashStable.map(values, function(value, index) { + return index ? _.map(collection, value) : _.map(collection); + }); - assert.deepEqual(actual, expected); + assert.deepEqual(actual, expected); + }); }); - QUnit.test('should work on an object with no `iteratee`', function(assert) { + QUnit.test('should accept a falsey `collection` argument', function(assert) { assert.expect(1); - var actual = _.map({ 'a': 1, 'b': 2 }); - assert.deepEqual(actual, array); + var expected = lodashStable.map(falsey, alwaysEmptyArray); + + var actual = lodashStable.map(falsey, function(collection, index) { + try { + return index ? _.map(collection) : _.map(); + } catch (e) {} + }); + + assert.deepEqual(actual, expected); }); - QUnit.test('should handle object arguments with non-number length properties', function(assert) { + QUnit.test('should treat number values for `collection` as empty', function(assert) { assert.expect(1); - var value = { 'value': 'x' }, - object = { 'length': { 'value': 'x' } }; - - assert.deepEqual(_.map(object, identity), [value]); + assert.deepEqual(_.map(1), []); }); QUnit.test('should treat a nodelist as an array-like object', function(assert) { @@ -12742,24 +13068,13 @@ } }); - QUnit.test('should accept a falsey `collection` argument', function(assert) { + QUnit.test('should work with objects with non-number length properties', function(assert) { assert.expect(1); - var expected = lodashStable.map(falsey, alwaysEmptyArray); - - var actual = lodashStable.map(falsey, function(collection, index) { - try { - return index ? _.map(collection) : _.map(); - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); - - QUnit.test('should treat number values for `collection` as empty', function(assert) { - assert.expect(1); + var value = { 'value': 'x' }, + object = { 'length': { 'value': 'x' } }; - assert.deepEqual(_.map(1), []); + assert.deepEqual(_.map(object, identity), [value]); }); QUnit.test('should return a wrapped value when chaining', function(assert) { @@ -12850,11 +13165,18 @@ assert.deepEqual(actual, { 'c': { 'b': 'c' } }); }); - QUnit.test('should work on an object with no `iteratee`', function(assert) { + QUnit.test('should use `_.identity` when `iteratee` is nullish', function(assert) { assert.expect(1); - var actual = _.mapKeys({ 'a': 1, 'b': 2 }); - assert.deepEqual(actual, { '1': 1, '2': 2 }); + var object = { 'a': 1, 'b': 2 }, + values = [, null, undefined], + expected = lodashStable.map(values, lodashStable.constant({ '1': 1, '2': 2 })); + + var actual = lodashStable.map(values, function(value, index) { + return index ? _.mapKeys(object, value) : _.mapKeys(object); + }); + + assert.deepEqual(actual, expected); }); }()); @@ -12887,12 +13209,19 @@ assert.deepEqual(actual, { 'a': 1 }); }); - QUnit.test('should work on an object with no `iteratee`', function(assert) { - assert.expect(2); + QUnit.test('should use `_.identity` when `iteratee` is nullish', function(assert) { + assert.expect(1); - var actual = _.mapValues({ 'a': 1, 'b': 2 }); - assert.deepEqual(actual, object); - assert.notStrictEqual(actual, object); + var object = { 'a': 1, 'b': 2 }, + values = [, null, undefined], + expected = lodashStable.map(values, lodashStable.constant([true, false])); + + var actual = lodashStable.map(values, function(value, index) { + var result = index ? _.mapValues(object, value) : _.mapValues(object); + return [lodashStable.isEqual(result, object), result === object]; + }); + + assert.deepEqual(actual, expected); }); }()); @@ -12905,17 +13234,19 @@ func = _[methodName], object = { 'a': 1, 'b': 2 }; - QUnit.test('should iterate over own properties of objects', function(assert) { + QUnit.test('`_.' + methodName + '` should iterate over own string keyed properties of objects', function(assert) { assert.expect(1); - function Foo() { this.a = 'a'; } + function Foo() { + this.a = 'a'; + } Foo.prototype.b = 'b'; var actual = func(new Foo, function(value, key) { return key; }); assert.deepEqual(actual, { 'a': 'a' }); }); - QUnit.test('should accept a falsey `object` argument', function(assert) { + QUnit.test('`_.' + methodName + '` should accept a falsey `object` argument', function(assert) { assert.expect(1); var expected = lodashStable.map(falsey, alwaysEmptyObject); @@ -12929,7 +13260,7 @@ assert.deepEqual(actual, expected); }); - QUnit.test('should return a wrapped value when chaining', function(assert) { + QUnit.test('`_.' + methodName + '` should return a wrapped value when chaining', function(assert) { assert.expect(1); if (!isNpm) { @@ -12970,10 +13301,12 @@ assert.strictEqual(matches(object), true); }); - QUnit.test('should match inherited `object` properties', function(assert) { + QUnit.test('should match inherited string keyed `object` properties', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var object = { 'a': new Foo }, @@ -12985,7 +13318,9 @@ QUnit.test('should not match by inherited `source` properties', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], @@ -13363,7 +13698,7 @@ }); }); - QUnit.test('should work with non-string `path` arguments', function(assert) { + QUnit.test('should work with a non-string `path`', function(assert) { assert.expect(2); var array = [1, 2, 3]; @@ -13404,7 +13739,7 @@ }); }); - QUnit.test('should match inherited `srcValue` properties', function(assert) { + QUnit.test('should match inherited string keyed `srcValue` properties', function(assert) { assert.expect(2); function Foo() {} @@ -13421,7 +13756,9 @@ QUnit.test('should not match by inherited `srcValue` properties', function(assert) { assert.expect(2); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var objects = [{ 'a': { 'a': 1 } }, { 'a': { 'a': 1, 'b': 2 } }], @@ -13728,6 +14065,44 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.meanBy'); + + (function() { + var objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }]; + + QUnit.test('should work with an `iteratee` argument', function(assert) { + assert.expect(1); + + var actual = _.meanBy(objects, function(object) { + return object.a; + }); + + assert.deepEqual(actual, 2); + }); + + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + _.meanBy(objects, function() { + args || (args = slice.call(arguments)); + }); + + assert.deepEqual(args, [{ 'a': 2 }]); + }); + + QUnit.test('should work with "_.property" shorthands', function(assert) { + assert.expect(2); + + var arrays = [[2], [3], [1]]; + assert.strictEqual(_.meanBy(arrays, 0), 2); + assert.strictEqual(_.meanBy(objects, 'a'), 2); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.memoize'); (function() { @@ -13930,7 +14305,7 @@ QUnit.test('should implement a `Map` interface on the cache object', function(assert) { assert.expect(164); - var keys = [true, false, 1, -Infinity, NaN, {}, null, 'a', symbol || {} , undefined]; + var keys = [null, undefined, false, true, 1, -Infinity, NaN, {}, 'a', symbol || {}]; var pairs = lodashStable.map(keys, function(key, index) { var lastIndex = keys.length - 1; @@ -14084,25 +14459,12 @@ function Foo() {} var object = new Foo, - source = { 'a': 1 }, - actual = _.merge(object, source); + actual = _.merge(object, { 'a': 1 }); assert.strictEqual(actual, object); assert.strictEqual(object.a, 1); }); - QUnit.test('should pass thru primitive `object` values', function(assert) { - assert.expect(1); - - var values = [true, 1, '1']; - - var actual = lodashStable.map(values, function(value) { - return _.merge(value, { 'a': 1 }); - }); - - assert.deepEqual(actual, values); - }); - QUnit.test('should treat sparse array sources as dense', function(assert) { assert.expect(2); @@ -14377,7 +14739,7 @@ assert.deepEqual(actual, [undefined]); }); - QUnit.test('should defer to `customizer` when it returns a value other than `undefined`', function(assert) { + QUnit.test('should defer to `customizer` when it returns a non `undefined` value', function(assert) { assert.expect(1); var actual = _.mergeWith({ 'a': { 'b': [0, 1] } }, { 'a': { 'b': [2] } }, function(a, b) { @@ -14397,6 +14759,16 @@ assert.deepEqual(actual, { 'a': { 'b': ['c'] } }); }); + QUnit.test('should clone sources when `customizer` result is `undefined`', function(assert) { + assert.expect(1); + + var source1 = { 'a': { 'b': { 'c': 1 } } }, + source2 = { 'a': { 'b': { 'd': 2 } } }, + actual = _.mergeWith({}, source1, source2, alwaysUndefined); + + assert.deepEqual(source1.a.b, { 'c': 1 }); + }); + QUnit.test('should pop the stack of sources for each sibling property', function(assert) { assert.expect(1); @@ -14440,7 +14812,7 @@ }); }); - QUnit.test('should work with non-string `path` arguments', function(assert) { + QUnit.test('should work with a non-string `path`', function(assert) { assert.expect(2); var array = lodashStable.times(3, _.constant); @@ -14595,7 +14967,7 @@ }); }); - QUnit.test('should work with non-string `path` arguments', function(assert) { + QUnit.test('should work with a non-string `path`', function(assert) { assert.expect(2); var array = lodashStable.times(3, _.constant); @@ -15086,13 +15458,34 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.orderBy'); + QUnit.module('lodash.multiply'); (function() { - var objects = [ - { 'a': 'x', 'b': 3 }, - { 'a': 'y', 'b': 4 }, - { 'a': 'x', 'b': 1 }, + QUnit.test('should multiply two numbers', function(assert) { + assert.expect(3); + + assert.strictEqual(_.multiply(6, 4), 24); + assert.strictEqual(_.multiply(-6, 4), -24); + assert.strictEqual(_.multiply(-6, -4), 24); + }); + + QUnit.test('should coerce arguments to numbers', function(assert) { + assert.expect(2); + + assert.strictEqual(_.multiply('6', '4'), 24); + assert.deepEqual(_.multiply('x', 'y'), NaN); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('lodash.orderBy'); + + (function() { + var objects = [ + { 'a': 'x', 'b': 3 }, + { 'a': 'y', 'b': 4 }, + { 'a': 'x', 'b': 1 }, { 'a': 'y', 'b': 2 } ]; @@ -15432,31 +15825,85 @@ var expected = { 'b': 2, 'd': 4 }, func = _[methodName], object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, - prop = function(object, props) { return props; }; + prop = lodashStable.nthArg(1); if (methodName == 'omitBy') { prop = function(object, props) { - props = typeof props == 'string' ? [props] : props; + props = lodashStable.isArray(props) ? props : [props]; return function(value) { - return _.some(props, function(key) { return object[key] === value; }); + return lodashStable.some(props, function(key) { + return object[key] === value; + }); }; }; } - QUnit.test('`_.' + methodName + '` should create an object with omitted properties', function(assert) { + QUnit.test('`_.' + methodName + '` should create an object with omitted string keyed properties', function(assert) { assert.expect(2); assert.deepEqual(func(object, prop(object, 'a')), { 'b': 2, 'c': 3, 'd': 4 }); assert.deepEqual(func(object, prop(object, ['a', 'c'])), expected); }); - QUnit.test('`_.' + methodName + '` should iterate over inherited properties', function(assert) { + QUnit.test('`_.' + methodName + '` should include inherited string keyed properties', function(assert) { assert.expect(1); function Foo() {} Foo.prototype = object; - var foo = new Foo; - assert.deepEqual(func(foo, prop(object, ['a', 'c'])), expected); + assert.deepEqual(func(new Foo, prop(object, ['a', 'c'])), expected); + }); + + QUnit.test('`_.' + methodName + '` should include symbol properties', function(assert) { + assert.expect(2); + + function Foo() { + this.a = 0; + this[symbol] = 1; + } + + if (Symbol) { + var symbol2 = Symbol('b'); + Foo.prototype[symbol2] = 2; + + var foo = new Foo, + actual = func(foo, prop(foo, 'a')); + + assert.strictEqual(actual[symbol], 1); + assert.strictEqual(actual[symbol2], 2); + } + else { + skipAssert(assert, 2); + } + }); + + QUnit.test('`_.' + methodName + '` should create an object with omitted symbol properties', function(assert) { + assert.expect(6); + + function Foo() { + this.a = 0; + this[symbol] = 1; + } + + if (Symbol) { + var symbol2 = Symbol('b'); + Foo.prototype[symbol2] = 2; + + var foo = new Foo, + actual = func(foo, prop(foo, symbol)); + + assert.strictEqual(actual.a, 0); + assert.strictEqual(actual[symbol], undefined); + assert.strictEqual(actual[symbol2], 2); + + actual = func(foo, prop(foo, symbol2)); + + assert.strictEqual(actual.a, 0); + assert.strictEqual(actual[symbol], 1); + assert.strictEqual(actual[symbol2], undefined); + } + else { + skipAssert(assert, 6); + } }); QUnit.test('`_.' + methodName + '` should work with an array `object` argument', function(assert) { @@ -15770,24 +16217,39 @@ QUnit.module('lodash.pad'); (function() { + var string = 'abc'; + QUnit.test('should pad a string to a given length', function(assert) { assert.expect(1); - assert.strictEqual(_.pad('abc', 9), ' abc '); + var values = [, undefined], + expected = lodashStable.map(values, lodashStable.constant(' abc ')); + + var actual = lodashStable.map(values, function(value, index) { + return index ? _.pad(string, 6, value) : _.pad(string, 6); + }); + + assert.deepEqual(actual, expected); }); QUnit.test('should truncate pad characters to fit the pad length', function(assert) { assert.expect(2); - assert.strictEqual(_.pad('abc', 8), ' abc '); - assert.strictEqual(_.pad('abc', 8, '_-'), '_-abc_-_'); + assert.strictEqual(_.pad(string, 8), ' abc '); + assert.strictEqual(_.pad(string, 8, '_-'), '_-abc_-_'); }); QUnit.test('should coerce `string` to a string', function(assert) { - assert.expect(2); + assert.expect(1); + + var values = [Object(string), { 'toString': lodashStable.constant(string) }], + expected = lodashStable.map(values, alwaysTrue); + + var actual = lodashStable.map(values, function(value) { + return _.pad(value, 6) === ' abc '; + }); - assert.strictEqual(_.pad(Object('abc'), 4), 'abc '); - assert.strictEqual(_.pad({ 'toString': lodashStable.constant('abc') }, 5), ' abc '); + assert.deepEqual(actual, expected); }); }()); @@ -15796,23 +16258,38 @@ QUnit.module('lodash.padEnd'); (function() { + var string = 'abc'; + QUnit.test('should pad a string to a given length', function(assert) { assert.expect(1); - assert.strictEqual(_.padEnd('abc', 6), 'abc '); + var values = [, undefined], + expected = lodashStable.map(values, lodashStable.constant('abc ')); + + var actual = lodashStable.map(values, function(value, index) { + return index ? _.padEnd(string, 6, value) : _.padEnd(string, 6); + }); + + assert.deepEqual(actual, expected); }); QUnit.test('should truncate pad characters to fit the pad length', function(assert) { assert.expect(1); - assert.strictEqual(_.padEnd('abc', 6, '_-'), 'abc_-_'); + assert.strictEqual(_.padEnd(string, 6, '_-'), 'abc_-_'); }); QUnit.test('should coerce `string` to a string', function(assert) { - assert.expect(2); + assert.expect(1); + + var values = [Object(string), { 'toString': lodashStable.constant(string) }], + expected = lodashStable.map(values, alwaysTrue); - assert.strictEqual(_.padEnd(Object('abc'), 4), 'abc '); - assert.strictEqual(_.padEnd({ 'toString': lodashStable.constant('abc') }, 5), 'abc '); + var actual = lodashStable.map(values, function(value) { + return _.padEnd(value, 6) === 'abc '; + }); + + assert.deepEqual(actual, expected); }); }()); @@ -15821,23 +16298,38 @@ QUnit.module('lodash.padStart'); (function() { + var string = 'abc'; + QUnit.test('should pad a string to a given length', function(assert) { assert.expect(1); - assert.strictEqual(_.padStart('abc', 6), ' abc'); + var values = [, undefined], + expected = lodashStable.map(values, lodashStable.constant(' abc')); + + var actual = lodashStable.map(values, function(value, index) { + return index ? _.padStart(string, 6, value) : _.padStart(string, 6); + }); + + assert.deepEqual(actual, expected); }); QUnit.test('should truncate pad characters to fit the pad length', function(assert) { assert.expect(1); - assert.strictEqual(_.padStart('abc', 6, '_-'), '_-_abc'); + assert.strictEqual(_.padStart(string, 6, '_-'), '_-_abc'); }); QUnit.test('should coerce `string` to a string', function(assert) { - assert.expect(2); + assert.expect(1); + + var values = [Object(string), { 'toString': lodashStable.constant(string) }], + expected = lodashStable.map(values, alwaysTrue); + + var actual = lodashStable.map(values, function(value) { + return _.padStart(value, 6) === ' abc'; + }); - assert.strictEqual(_.padStart(Object('abc'), 4), ' abc'); - assert.strictEqual(_.padStart({ 'toString': lodashStable.constant('abc') }, 5), ' abc'); + assert.deepEqual(actual, expected); }); }()); @@ -15848,20 +16340,21 @@ lodashStable.each(['pad', 'padStart', 'padEnd'], function(methodName) { var func = _[methodName], isPad = methodName == 'pad', - isStart = methodName == 'padStart'; + isStart = methodName == 'padStart', + string = 'abc'; - QUnit.test('`_.' + methodName + '` should not pad is string is >= `length`', function(assert) { + QUnit.test('`_.' + methodName + '` should not pad if string is >= `length`', function(assert) { assert.expect(2); - assert.strictEqual(func('abc', 2), 'abc'); - assert.strictEqual(func('abc', 3), 'abc'); + assert.strictEqual(func(string, 2), string); + assert.strictEqual(func(string, 3), string); }); QUnit.test('`_.' + methodName + '` should treat negative `length` as `0`', function(assert) { assert.expect(2); lodashStable.each([0, -2], function(length) { - assert.strictEqual(func('abc', length), 'abc'); + assert.strictEqual(func(string, length), string); }); }); @@ -15869,8 +16362,8 @@ assert.expect(2); lodashStable.each(['', '4'], function(length) { - var actual = length ? (isStart ? ' abc' : 'abc ') : 'abc'; - assert.strictEqual(func('abc', length), actual); + var actual = length ? (isStart ? ' abc' : 'abc ') : string; + assert.strictEqual(func(string, length), actual); }); }); @@ -15885,12 +16378,17 @@ }); }); - QUnit.test('`_.' + methodName + '` should work with nullish or empty string values for `chars`', function(assert) { - assert.expect(3); + QUnit.test('`_.' + methodName + '` should return `string` when `chars` coerces to an empty string', function(assert) { + assert.expect(1); + + var values = ['', Object('')], + expected = lodashStable.map(values, lodashStable.constant(string)); + + var actual = lodashStable.map(values, function(value) { + return _.pad(string, 6, value); + }); - assert.notStrictEqual(func('abc', 6, null), 'abc'); - assert.notStrictEqual(func('abc', 6, undefined), 'abc'); - assert.strictEqual(func('abc', 6, ''), 'abc'); + assert.deepEqual(actual, expected); }); }); @@ -16483,24 +16981,26 @@ var expected = { 'a': 1, 'c': 3 }, func = _[methodName], object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, - prop = function(object, props) { return props; }; + prop = lodashStable.nthArg(1); if (methodName == 'pickBy') { prop = function(object, props) { - props = typeof props == 'string' ? [props] : props; + props = lodashStable.isArray(props) ? props : [props]; return function(value) { - return _.some(props, function(key) { return object[key] === value; }); + return lodashStable.some(props, function(key) { + return object[key] === value; + }); }; }; } - QUnit.test('`_.' + methodName + '` should create an object of picked properties', function(assert) { + QUnit.test('`_.' + methodName + '` should create an object of picked string keyed properties', function(assert) { assert.expect(2); assert.deepEqual(func(object, prop(object, 'a')), { 'a': 1 }); assert.deepEqual(func(object, prop(object, ['a', 'c'])), expected); }); - QUnit.test('`_.' + methodName + '` should iterate over inherited properties', function(assert) { + QUnit.test('`_.' + methodName + '` should pick inherited string keyed properties', function(assert) { assert.expect(1); function Foo() {} @@ -16510,6 +17010,28 @@ assert.deepEqual(func(foo, prop(foo, ['a', 'c'])), expected); }); + QUnit.test('`_.' + methodName + '` should pick symbol properties', function(assert) { + assert.expect(2); + + function Foo() { + this[symbol] = 1; + } + + if (Symbol) { + var symbol2 = Symbol('b'); + Foo.prototype[symbol2] = 2; + + var foo = new Foo, + actual = func(foo, prop(foo, [symbol, symbol2])); + + assert.strictEqual(actual[symbol], 1); + assert.strictEqual(actual[symbol2], 2); + } + else { + skipAssert(assert, 2); + } + }); + QUnit.test('`_.' + methodName + '` should work with an array `object` argument', function(assert) { assert.expect(1); @@ -16546,7 +17068,7 @@ }); }); - QUnit.test('should work with non-string `path` arguments', function(assert) { + QUnit.test('should work with a non-string `path`', function(assert) { assert.expect(2); var array = [1, 2, 3]; @@ -16675,7 +17197,7 @@ }); }); - QUnit.test('should work with non-string `path` arguments', function(assert) { + QUnit.test('should work with a non-string `path`', function(assert) { assert.expect(2); var array = [1, 2, 3], @@ -16710,7 +17232,9 @@ QUnit.test('should pluck inherited property values', function(assert) { assert.expect(2); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; var propOf = _.propertyOf(new Foo); @@ -17015,11 +17539,11 @@ QUnit.test('should return `0` or `1` when no arguments are given', function(assert) { assert.expect(1); - var actual = lodashStable.map(array, function() { + var actual = lodashStable.uniq(lodashStable.map(array, function() { return _.random(); - }); + })).sort(); - assert.deepEqual(_.uniq(actual).sort(), [0, 1]); + assert.deepEqual(actual, [0, 1]); }); QUnit.test('should support a `min` and `max` argument', function(assert) { @@ -17817,28 +18341,35 @@ QUnit.module('lodash.result'); (function() { - var object = { - 'a': 1, - 'b': function() { return this.a; } - }; + var object = { 'a': 1, 'b': alwaysB }; QUnit.test('should invoke function values', function(assert) { assert.expect(1); - assert.strictEqual(_.result(object, 'b'), 1); + assert.strictEqual(_.result(object, 'b'), 'b'); }); QUnit.test('should invoke default function values', function(assert) { assert.expect(1); var actual = _.result(object, 'c', object.b); - assert.strictEqual(actual, 1); + assert.strictEqual(actual, 'b'); + }); + + QUnit.test('should invoke nested function values', function(assert) { + assert.expect(2); + + var value = { 'a': lodashStable.constant({ 'b': alwaysB }) }; + + lodashStable.each(['a.b', ['a', 'b']], function(path) { + assert.strictEqual(_.result(value, path), 'b'); + }); }); QUnit.test('should invoke deep property methods with the correct `this` binding', function(assert) { assert.expect(2); - var value = { 'a': object }; + var value = { 'a': { 'b': function() { return this.c; }, 'c': 1 } }; lodashStable.each(['a.b', ['a', 'b']], function(path) { assert.strictEqual(_.result(value, path), 1); @@ -17853,7 +18384,7 @@ lodashStable.each(['get', 'result'], function(methodName) { var func = _[methodName]; - QUnit.test('`_.' + methodName + '` should get property values', function(assert) { + QUnit.test('`_.' + methodName + '` should get string keyed property values', function(assert) { assert.expect(2); var object = { 'a': 1 }; @@ -17863,6 +18394,20 @@ }); }); + QUnit.test('`_.' + methodName + '` should get symbol keyed property values', function(assert) { + assert.expect(1); + + if (Symbol) { + var object = {}; + object[symbol] = 1; + + assert.strictEqual(func(object, symbol), 1); + } + else { + skipAssert(assert); + } + }); + QUnit.test('`_.' + methodName + '` should get deep property values', function(assert) { assert.expect(2); @@ -17967,28 +18512,15 @@ }); QUnit.test('`_.' + methodName + '` should follow `path` over non-plain objects', function(assert) { - assert.expect(4); + assert.expect(2); - var object = { 'a': '' }, - paths = ['constructor.prototype.a', ['constructor', 'prototype', 'a']]; + var paths = ['a.b.c', ['a', 'b', 'c']]; lodashStable.each(paths, function(path) { - numberProto.a = 1; - - var actual = func(0, path); - assert.strictEqual(actual, 1); - + numberProto.a = { 'b': { 'c': 1 } }; + assert.strictEqual(func(0, path), 1); delete numberProto.a; }); - - lodashStable.each(['a.replace.b', ['a', 'replace', 'b']], function(path) { - stringProto.replace.b = 1; - - var actual = func(object, path); - assert.strictEqual(actual, 1); - - delete stringProto.replace.b; - }); }); QUnit.test('`_.' + methodName + '` should return the default value for `undefined` values', function(assert) { @@ -18012,6 +18544,12 @@ assert.deepEqual(actual, expected); }); + + QUnit.test('`_.' + methodName + '` should return the default value when `path` is empty', function(assert) { + assert.expect(1); + + assert.strictEqual(func({}, [], 'a'), 'a'); + }); }); /*--------------------------------------------------------------------------*/ @@ -18381,6 +18919,7 @@ assert.expect(2); var actual = _.sampleSize(array, 2); + assert.strictEqual(actual.length, 2); assert.deepEqual(lodashStable.difference(actual, array), []); }); @@ -18388,8 +18927,9 @@ QUnit.test('should contain elements of the collection', function(assert) { assert.expect(1); - var actual = _.sampleSize(array, array.length); - assert.deepEqual(actual.sort(), array); + var actual = _.sampleSize(array, array.length).sort(); + + assert.deepEqual(actual, array); }); QUnit.test('should treat falsey `n` values as `0`', function(assert) { @@ -18416,7 +18956,8 @@ assert.expect(4); lodashStable.each([3, 4, Math.pow(2, 32), Infinity], function(n) { - assert.deepEqual(_.sampleSize(array, n).sort(), array); + var actual = _.sampleSize(array, n).sort(); + assert.deepEqual(actual, array); }); }); @@ -18460,13 +19001,11 @@ QUnit.test('should work with a `customizer` callback', function(assert) { assert.expect(1); - var actual = _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, function(value) { - if (!lodashStable.isObject(value)) { - return {}; - } + var actual = _.setWith({ '0': {} }, '[0][1][2]', 3, function(value) { + return lodashStable.isObject(value) ? undefined : {}; }); - assert.deepEqual(actual, { '0': { '1': { '2': 3 }, 'length': 2 } }); + assert.deepEqual(actual, { '0': { '1': { '2': 3 } } }); }); QUnit.test('should work with a `customizer` that returns `undefined`', function(assert) { @@ -18736,7 +19275,7 @@ var args = arguments, array = [1, 2, 3]; - QUnit.test('should return the number of own enumerable properties of an object', function(assert) { + QUnit.test('should return the number of own enumerable string keyed properties of an object', function(assert) { assert.expect(1); assert.strictEqual(_.size({ 'one': 1, 'two': 2, 'three': 3 }), 3); @@ -18771,12 +19310,46 @@ QUnit.test('should work with jQuery/MooTools DOM query collections', function(assert) { assert.expect(1); - function Foo(elements) { push.apply(this, elements); } + function Foo(elements) { + push.apply(this, elements); + } Foo.prototype = { 'length': 0, 'splice': arrayProto.splice }; assert.strictEqual(_.size(new Foo(array)), 3); }); + QUnit.test('should work with maps', function(assert) { + assert.expect(2); + + if (Map) { + lodashStable.each([new Map, realm.map], function(map) { + map.set('a', 1); + map.set('b', 2); + assert.strictEqual(_.size(map), 2); + map.clear(); + }); + } + else { + skipAssert(assert, 2); + } + }); + + QUnit.test('should work with sets', function(assert) { + assert.expect(2); + + if (Set) { + lodashStable.each([new Set, realm.set], function(set) { + set.add(1); + set.add(2); + assert.strictEqual(_.size(set), 2); + set.clear(); + }); + } + else { + skipAssert(assert, 2); + } + }); + QUnit.test('should not treat objects with negative lengths as array-like', function(assert) { assert.expect(1); @@ -19501,6 +20074,20 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.startCase'); + + (function() { + QUnit.test('should uppercase only the first character of each word', function(assert) { + assert.expect(3); + + assert.strictEqual(_.startCase('--foo-bar--'), 'Foo Bar'); + assert.strictEqual(_.startCase('fooBar'), 'Foo Bar'); + assert.strictEqual(_.startCase('__FOO_BAR__'), 'FOO BAR'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.startsWith'); (function() { @@ -19615,49 +20202,75 @@ assert.strictEqual(_.subtract(-6, -4), -2); }); - QUnit.test('should return `0` when no arguments are given', function(assert) { - assert.expect(1); - - assert.strictEqual(_.subtract(), 0); - }); - - QUnit.test('should coerce arguments only numbers', function(assert) { + QUnit.test('should coerce arguments to numbers', function(assert) { assert.expect(2); assert.strictEqual(_.subtract('6', '4'), 2); assert.deepEqual(_.subtract('x', 'y'), NaN); }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('math operator methods'); + + lodashStable.each(['add', 'divide', 'multiply', 'subtract'], function(methodName) { + var func = _[methodName]; + + QUnit.test('`_.' + methodName + '` should return `0` when no arguments are given', function(assert) { + assert.expect(1); + + assert.strictEqual(func(), 0); + }); - QUnit.test('should work with only a `minuend` or `subtrahend`', function(assert) { + QUnit.test('`_.' + methodName + '` should work with only one defined argument', function(assert) { assert.expect(3); - assert.strictEqual(_.subtract(6), 6); - assert.strictEqual(_.subtract(6, undefined), 6); - assert.strictEqual(_.subtract(undefined, 4), 4); + assert.strictEqual(func(6), 6); + assert.strictEqual(func(6, undefined), 6); + assert.strictEqual(func(undefined, 4), 4); }); - QUnit.test('should return an unwrapped value when implicitly chaining', function(assert) { + QUnit.test('`_.' + methodName + '` should preserve sign of `0`', function(assert) { + assert.expect(2); + + var values = [0, '0', -0, '-0'], + expected = [[0, Infinity], ['0', Infinity], [-0, -Infinity], ['-0', -Infinity]]; + + lodashStable.times(2, function(index) { + var actual = lodashStable.map(values, function(value) { + var result = index ? func(undefined, value) : func(value); + return [result, 1 / result]; + }); + + assert.deepEqual(actual, expected); + }); + }); + + QUnit.test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', function(assert) { assert.expect(1); if (!isNpm) { - assert.strictEqual(_(1).subtract(2), -1); + var actual = _(1)[methodName](2); + assert.notOk(actual instanceof _); } else { skipAssert(assert); } }); - QUnit.test('should return a wrapped value when explicitly chaining', function(assert) { + QUnit.test('`_.' + methodName + '` should return a wrapped value when explicitly chaining', function(assert) { assert.expect(1); if (!isNpm) { - assert.ok(_(1).chain().subtract(2) instanceof _); + var actual = _(1).chain()[methodName](2); + assert.ok(actual instanceof _); } else { skipAssert(assert); } }); - }()); + }); /*--------------------------------------------------------------------------*/ @@ -21070,7 +21683,7 @@ }); QUnit.test('should trigger a second throttled call as soon as possible', function(assert) { - assert.expect(2); + assert.expect(3); var done = assert.async(); @@ -21087,10 +21700,14 @@ throttled(); }, 192); + setTimeout(function() { + assert.strictEqual(callCount, 1); + }, 254); + setTimeout(function() { assert.strictEqual(callCount, 2); done(); - }, 288); + }, 384); }); QUnit.test('should apply default options', function(assert) { @@ -21349,10 +21966,12 @@ assert.strictEqual(funced(), 1); funced.cancel(); + assert.strictEqual(funced(), 2); + funced(); setTimeout(function() { - assert.strictEqual(callCount, 2); + assert.strictEqual(callCount, 3); done(); }, 64); }); @@ -21369,28 +21988,47 @@ }, 32, { 'leading': false }); funced(); - var actual = funced.flush(); + assert.strictEqual(funced.flush(), 1); setTimeout(function() { - assert.strictEqual(actual, 1); assert.strictEqual(callCount, 1); done(); }, 64); }); - }); - - /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.times'); + QUnit.test('_.' + methodName + ' should noop `cancel` and `flush` when nothing is queued', function(assert) { + assert.expect(2); - (function() { - QUnit.test('should coerce non-finite `n` values to `0`', function(assert) { - assert.expect(3); + var done = assert.async(); - lodashStable.each([-Infinity, NaN, Infinity], function(n) { - assert.deepEqual(_.times(n), []); - }); - }); + var callCount = 0; + + var funced = func(function() { + callCount++; + }, 32); + + funced.cancel(); + assert.strictEqual(funced.flush(), undefined); + + setTimeout(function() { + assert.strictEqual(callCount, 0); + done(); + }, 64); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('lodash.times'); + + (function() { + QUnit.test('should coerce non-finite `n` values to `0`', function(assert) { + assert.expect(3); + + lodashStable.each([-Infinity, NaN, Infinity], function(n) { + assert.deepEqual(_.times(n), []); + }); + }); QUnit.test('should coerce `n` to an integer', function(assert) { assert.expect(1); @@ -21529,7 +22167,7 @@ QUnit.test('should convert whole string to lower case', function(assert) { assert.expect(3); - assert.deepEqual(_.toLower('--Foo-Bar'), '--foo-bar'); + assert.deepEqual(_.toLower('--Foo-Bar--'), '--foo-bar--'); assert.deepEqual(_.toLower('fooBar'), 'foobar'); assert.deepEqual(_.toLower('__FOO_BAR__'), '__foo_bar__'); }); @@ -21662,11 +22300,35 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.toInteger and lodash.toNumber'); + QUnit.module('number coercion methods'); + + lodashStable.each(['toInteger', 'toNumber', 'toSafeInteger'], function(methodName) { + var func = _[methodName]; - lodashStable.each(['toInteger', 'toNumber'], function(methodName) { + QUnit.test('`_.' + methodName + '` should preserve sign of `0`', function(assert) { + assert.expect(2); + + var values = [0, '0', -0, '-0'], + expected = [[0, Infinity], [0, Infinity], [-0, -Infinity], [-0, -Infinity]]; + + lodashStable.times(2, function(index) { + var others = lodashStable.map(values, index ? Object : identity); + + var actual = lodashStable.map(others, function(value) { + var result = func(value); + return [result, 1 / result]; + }); + + assert.deepEqual(actual, expected); + }); + }); + }); + + lodashStable.each(['toInteger', 'toLength', 'toNumber', 'toSafeInteger'], function(methodName) { var func = _[methodName], - isInt = methodName == 'toInteger'; + isToLength = methodName == 'toLength', + isToNumber = methodName == 'toNumber', + isToSafeInteger = methodName == 'toSafeInteger'; function negative(string) { return '-' + string; @@ -21680,32 +22342,16 @@ return '+' + string; } - QUnit.test('`_.' + methodName + '` should convert empty values to `0` or `NaN`', function(assert) { + QUnit.test('`_.' + methodName + '` should pass thru primitive number values', function(assert) { assert.expect(1); - var values = falsey.concat(whitespace); + var values = [0, 1, NaN]; var expected = lodashStable.map(values, function(value) { - return (isInt || (value === whitespace)) ? 0 : Number(value); - }); - - var actual = lodashStable.map(values, function(value, index) { - return index ? func(value) : func(); + return (!isToNumber && value !== value) ? 0 : value; }); - assert.deepEqual(actual, expected); - }); - - QUnit.test('`_.' + methodName + '` should preserve sign of `0`', function(assert) { - assert.expect(1); - - var values = [0, '0', -0, '-0'], - expected = [[0, Infinity], [0, Infinity], [-0, -Infinity], [-0, -Infinity]]; - - var actual = lodashStable.map(values, function(value) { - var result = func(value); - return [result, 1 / result]; - }); + var actual = lodashStable.map(values, func); assert.deepEqual(actual, expected); }); @@ -21716,7 +22362,7 @@ var values = [2, 1.2, MAX_SAFE_INTEGER, MAX_INTEGER, Infinity, NaN]; var expected = lodashStable.map(values, function(value) { - if (isInt) { + if (!isToNumber) { if (value == 1.2) { value = 1; } @@ -21726,20 +22372,16 @@ else if (value !== value) { value = 0; } + if (isToLength || isToSafeInteger) { + value = Math.min(value, isToLength ? MAX_ARRAY_LENGTH : MAX_SAFE_INTEGER); + } } - return [value, value, -value, -value]; + var neg = isToLength ? 0 : -value; + return [value, value, neg, neg]; }); var actual = lodashStable.map(values, function(value) { - return lodashStable.flattenDeep( - lodashStable.times(2, function(index) { - var other = index ? -value : value; - return [ - func(other), - func(Object(other)) - ]; - }) - ); + return [func(value), func(Object(value)), func(-value), func(Object(-value))]; }); assert.deepEqual(actual, expected); @@ -21759,7 +22401,7 @@ var expected = lodashStable.map(values, function(value) { var n = +value; - if (isInt) { + if (!isToNumber) { if (n == 1.234567890) { n = 1; } @@ -21769,25 +22411,24 @@ else if (n == Number.MIN_VALUE || n !== n) { n = 0; } + if (isToLength || isToSafeInteger) { + n = Math.min(n, isToLength ? MAX_ARRAY_LENGTH : MAX_SAFE_INTEGER); + } } - return [n, n, n, n, n, n, -n, -n]; + var neg = isToLength ? 0 : -n; + return [n, n, n, n, n, n, neg, neg]; }); var actual = lodashStable.map(values, function(value) { - return lodashStable.flattenDeep( - lodashStable.map(transforms, function(mod) { - return [ - func(mod(value)), - func(Object(mod(value))) - ]; - }) - ); + return lodashStable.flatMap(transforms, function(mod) { + return [func(mod(value)), func(Object(mod(value)))]; + }); }); assert.deepEqual(actual, expected); }); - QUnit.test('`_.' + methodName + '` should convert binary and octal strings to numbers', function(assert) { + QUnit.test('`_.' + methodName + '` should convert binary/octal strings to numbers', function(assert) { assert.expect(1); var numbers = [42, 5349, 1715004], @@ -21799,44 +22440,64 @@ }); var actual = lodashStable.map(values, function(value) { - return lodashStable.flattenDeep( - lodashStable.times(2, function(index) { - var other = index ? value.toUpperCase() : value; - return lodashStable.map(transforms, function(mod) { - return [ - func(mod(other)), - func(Object(mod(other))) - ]; - }); - }) - ); + var upper = value.toUpperCase(); + return lodashStable.flatMap(transforms, function(mod) { + return [func(mod(value)), func(Object(mod(value))), func(mod(upper)), func(Object(mod(upper)))]; + }); }); assert.deepEqual(actual, expected); }); - QUnit.test('`_.' + methodName + '` should convert invalid binary and octal strings to `NaN`', function(assert) { + QUnit.test('`_.' + methodName + '` should convert invalid binary/octal strings to `' + (isToNumber ? 'NaN' : '0') + '`', function(assert) { assert.expect(1); var transforms = [identity, pad, positive, negative], values = ['0b', '0o', '0x', '0b1010102', '0o123458', '0x1a2b3x']; var expected = lodashStable.map(values, function(n) { - return lodashStable.times(16, lodashStable.constant(isInt ? 0 : NaN)); + return lodashStable.times(8, lodashStable.constant(isToNumber ? NaN : 0)); }); var actual = lodashStable.map(values, function(value) { - return lodashStable.flattenDeep( - lodashStable.times(2, function(index) { - var other = index ? value.toUpperCase() : value; - return lodashStable.map(transforms, function(mod) { - return [ - func(mod(value)), - func(Object(mod(value))) - ]; - }); - }) - ); + return lodashStable.flatMap(transforms, function(mod) { + return [func(mod(value)), func(Object(mod(value)))]; + }); + }); + + assert.deepEqual(actual, expected); + }); + + QUnit.test('`_.' + methodName + '` should convert symbols to `' + (isToNumber ? 'NaN' : '0') + '`', function(assert) { + assert.expect(1); + + if (Symbol) { + var object1 = Object(symbol), + object2 = Object(symbol), + values = [symbol, object1, object2], + expected = lodashStable.map(values, lodashStable.constant(isToNumber ? NaN : 0)); + + object2.valueOf = undefined; + var actual = lodashStable.map(values, func); + + assert.deepEqual(actual, expected); + } + else { + skipAssert(assert); + } + }); + + QUnit.test('`_.' + methodName + '` should convert empty values to `0` or `NaN`', function(assert) { + assert.expect(1); + + var values = falsey.concat(whitespace); + + var expected = lodashStable.map(values, function(value) { + return (isToNumber && value !== whitespace) ? Number(value) : 0; + }); + + var actual = lodashStable.map(values, function(value, index) { + return index ? func(value) : func(); }); assert.deepEqual(actual, expected); @@ -21870,7 +22531,7 @@ 42, 42 ]; - if (isInt) { + if (!isToNumber) { expected = [ 0, 0, 1, 0, 0, 2, 1, 1, @@ -21890,28 +22551,74 @@ QUnit.module('lodash.toPairs'); (function() { - QUnit.test('should create a two dimensional array of key-value pairs', function(assert) { + QUnit.test('should be aliased', function(assert) { assert.expect(1); - var object = { 'a': 1, 'b': 2 }; - assert.deepEqual(_.toPairs(object), [['a', 1], ['b', 2]]); + assert.strictEqual(_.entries, _.toPairs); }); + }()); - QUnit.test('should work with an object that has a `length` property', function(assert) { + /*--------------------------------------------------------------------------*/ + + QUnit.module('lodash.toPairsIn'); + + (function() { + QUnit.test('should be aliased', function(assert) { assert.expect(1); - var object = { '0': 'a', '1': 'b', 'length': 2 }; - assert.deepEqual(_.toPairs(object), [['0', 'a'], ['1', 'b'], ['length', 2]]); + assert.strictEqual(_.entriesIn, _.toPairsIn); }); + }()); - QUnit.test('should work with strings', function(assert) { + /*--------------------------------------------------------------------------*/ + + QUnit.module('toPairs methods'); + + lodashStable.each(['toPairs', 'toPairsIn'], function(methodName) { + var func = _[methodName], + isToPairs = methodName == 'toPairs'; + + QUnit.test('`_.' + methodName + '` should create an array of string keyed-value pairs', function(assert) { + assert.expect(1); + + var object = { 'a': 1, 'b': 2 }, + actual = lodashStable.sortBy(func(object), 0); + + assert.deepEqual(actual, [['a', 1], ['b', 2]]); + }); + + QUnit.test('`_.' + methodName + '` should work with an object that has a `length` property', function(assert) { + assert.expect(1); + + var object = { '0': 'a', '1': 'b', 'length': 2 }, + actual = lodashStable.sortBy(func(object), 0); + + assert.deepEqual(actual, [['0', 'a'], ['1', 'b'], ['length', 2]]); + }); + + QUnit.test('`_.' + methodName + '` should ' + (isToPairs ? 'not ' : '') + 'include inherited string keyed property values', function(assert) { + assert.expect(1); + + function Foo() { + this.a = 1; + } + Foo.prototype.b = 2; + + var expected = isToPairs ? [['a', 1]] : [['a', 1], ['b', 2]], + actual = lodashStable.sortBy(func(new Foo), 0); + + assert.deepEqual(actual, expected); + }); + + QUnit.test('`_.' + methodName + '` should work with strings', function(assert) { assert.expect(2); lodashStable.each(['xo', Object('xo')], function(string) { - assert.deepEqual(_.toPairs(string), [['0', 'x'], ['1', 'o']]); + var actual = lodashStable.sortBy(func(string), 0); + assert.deepEqual(actual, [['0', 'x'], ['1', 'o']]); }); }); - }()); + }); /*--------------------------------------------------------------------------*/ @@ -21937,6 +22644,27 @@ }); }); + QUnit.test('should a new path array', function(assert) { + assert.expect(1); + + assert.notStrictEqual(_.toPath('a.b.c'), _.toPath('a.b.c')); + }); + + QUnit.test('should not coerce symbols to strings', function(assert) { + assert.expect(4); + + if (Symbol) { + var object = Object(symbol); + lodashStable.each([symbol, object, [symbol], [object]], function(value) { + var actual = _.toPath(value); + assert.ok(lodashStable.isSymbol(actual[0])); + }); + } + else { + skipAssert(assert, 4); + } + }); + QUnit.test('should handle complex paths', function(assert) { assert.expect(1); @@ -21964,10 +22692,12 @@ (function() { var args = arguments; - QUnit.test('should flatten inherited properties', function(assert) { + QUnit.test('should flatten inherited string keyed properties', function(assert) { assert.expect(1); - function Foo() { this.b = 2; } + function Foo() { + this.b = 2; + } Foo.prototype.c = 3; var actual = lodashStable.assign({ 'a': 1 }, _.toPlainObject(new Foo)); @@ -22064,8 +22794,8 @@ assert.expect(4); var accumulators = [, null, undefined], - expected = lodashStable.map(accumulators, alwaysTrue), - object = new Foo; + object = new Foo, + expected = lodashStable.map(accumulators, alwaysTrue); var iteratee = function(result, value, key) { result[key] = square(value); @@ -22173,7 +22903,7 @@ assert.expect(2); var Ctors = [Boolean, Boolean, Number, Number, Number, String, String], - values = [true, false, 0, 1, NaN, '', 'a'], + values = [false, true, 0, 1, NaN, '', 'a'], expected = lodashStable.map(values, alwaysEmptyObject); var results = lodashStable.map(values, function(value) { @@ -22847,7 +23577,7 @@ assert.expect(1); var largeArray = [], - expected = [false, true, null, undefined, NaN], + expected = [null, undefined, false, true, NaN], count = Math.ceil(LARGE_ARRAY_SIZE / expected.length); lodashStable.each(expected, function(value) { @@ -23110,6 +23840,29 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.updateWith'); + + (function() { + QUnit.test('should work with a `customizer` callback', function(assert) { + assert.expect(1); + + var actual = _.updateWith({ '0': {} }, '[0][1][2]', alwaysThree, function(value) { + return lodashStable.isObject(value) ? undefined : {}; + }); + + assert.deepEqual(actual, { '0': { '1': { '2': 3 } } }); + }); + + QUnit.test('should work with a `customizer` that returns `undefined`', function(assert) { + assert.expect(1); + + var actual = _.updateWith({}, 'a[0].b.c', alwaysFour, alwaysUndefined); + assert.deepEqual(actual, { 'a': [{ 'b': { 'c': 4 } }] }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('update methods'); lodashStable.each(['update', 'updateWith'], function(methodName) { @@ -23143,7 +23896,7 @@ QUnit.test('should uppercase as space-separated words', function(assert) { assert.expect(3); - assert.strictEqual(_.upperCase('--foo-bar'), 'FOO BAR'); + assert.strictEqual(_.upperCase('--foo-bar--'), 'FOO BAR'); assert.strictEqual(_.upperCase('fooBar'), 'FOO BAR'); assert.strictEqual(_.upperCase('__foo_bar__'), 'FOO BAR'); }); @@ -23172,28 +23925,36 @@ func = _[methodName], isValues = methodName == 'values'; - QUnit.test('`_.' + methodName + '` should get the values of an object', function(assert) { + QUnit.test('`_.' + methodName + '` should get string keyed values of `object`', function(assert) { assert.expect(1); - var object = { 'a': 1, 'b': 2 }; - assert.deepEqual(func(object), [1, 2]); + var object = { 'a': 1, 'b': 2 }, + actual = func(object).sort(); + + assert.deepEqual(actual, [1, 2]); }); QUnit.test('`_.' + methodName + '` should work with an object that has a `length` property', function(assert) { assert.expect(1); - var object = { '0': 'a', '1': 'b', 'length': 2 }; - assert.deepEqual(func(object), ['a', 'b', 2]); + var object = { '0': 'a', '1': 'b', 'length': 2 }, + actual = func(object).sort(); + + assert.deepEqual(actual, [2, 'a', 'b']); }); - QUnit.test('`_.' + methodName + '` should ' + (isValues ? 'not ' : '') + ' include inherited property values', function(assert) { + QUnit.test('`_.' + methodName + '` should ' + (isValues ? 'not ' : '') + 'include inherited string keyed property values', function(assert) { assert.expect(1); - function Foo() { this.a = 1; } + function Foo() { + this.a = 1; + } Foo.prototype.b = 2; - var expected = isValues ? [1] : [1, 2]; - assert.deepEqual(func(new Foo).sort(), expected); + var expected = isValues ? [1] : [1, 2], + actual = func(new Foo).sort(); + + assert.deepEqual(actual, expected); }); }); @@ -23267,17 +24028,20 @@ }); QUnit.test('should work with compound words', function(assert) { - assert.expect(9); + assert.expect(12); assert.deepEqual(_.words('12Feet'), ['12', 'Feet']); + assert.deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']); assert.deepEqual(_.words('enable 6h format'), ['enable', '6', 'h', 'format']); assert.deepEqual(_.words('enable 24H format'), ['enable', '24', 'H', 'format']); assert.deepEqual(_.words('isISO8601'), ['is', 'ISO', '8601']); + assert.deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']); assert.deepEqual(_.words('tooLegit2Quit'), ['too', 'Legit', '2', 'Quit']); assert.deepEqual(_.words('walk500Miles'), ['walk', '500', 'Miles']); assert.deepEqual(_.words('xhr2Request'), ['xhr', '2', 'Request']); - assert.deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']); - assert.deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']); + assert.deepEqual(_.words('XMLHttp'), ['XML', 'Http']); + assert.deepEqual(_.words('XmlHTTP'), ['Xml', 'HTTP']); + assert.deepEqual(_.words('XmlHttp'), ['Xml', 'Http']); }); QUnit.test('should work with compound words containing diacritical marks', function(assert) { @@ -23595,8 +24359,8 @@ [['barney', 36], ['fred', 40]] ], '3-tuples': [ - [['barney', 'fred'], [36, 40], [true, false]], - [['barney', 36, true], ['fred', 40, false]] + [['barney', 'fred'], [36, 40], [false, true]], + [['barney', 36, false], ['fred', 40, true]] ] }; @@ -23696,7 +24460,7 @@ QUnit.module('lodash(...).next'); - lodashStable.each([true, false], function(implict) { + lodashStable.each([false, true], function(implict) { function chain(value) { return implict ? _(value) : _.chain(value); } @@ -23872,6 +24636,26 @@ skipAssert(assert, 5); } }); + + QUnit.test('should accept falsey arguments', function(assert) { + assert.expect(1); + + if (!isNpm) { + var expected = lodashStable.map(falsey, alwaysTrue); + + var actual = lodashStable.map(falsey, function(value, index) { + try { + var result = index ? _(value).pop() : _().pop(); + return result === undefined; + } catch (e) {} + }); + + assert.deepEqual(actual, expected); + } + else { + skipAssert(assert); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -23894,6 +24678,26 @@ skipAssert(assert, 2); } }); + + QUnit.test('should accept falsey arguments', function(assert) { + assert.expect(1); + + if (!isNpm) { + var expected = lodashStable.map(falsey, alwaysTrue); + + var actual = lodashStable.map(falsey, function(value, index) { + try { + var result = index ? _(value).push(1).value() : _().push(1).value(); + return lodashStable.eq(result, value); + } catch (e) {} + }); + + assert.deepEqual(actual, expected); + } + else { + skipAssert(assert); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -23920,6 +24724,26 @@ skipAssert(assert, 5); } }); + + QUnit.test('should accept falsey arguments', function(assert) { + assert.expect(1); + + if (!isNpm) { + var expected = lodashStable.map(falsey, alwaysTrue); + + var actual = lodashStable.map(falsey, function(value, index) { + try { + var result = index ? _(value).shift() : _().shift(); + return result === undefined; + } catch (e) {} + }); + + assert.deepEqual(actual, expected); + } + else { + skipAssert(assert); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -23942,6 +24766,26 @@ skipAssert(assert, 2); } }); + + QUnit.test('should accept falsey arguments', function(assert) { + assert.expect(1); + + if (!isNpm) { + var expected = lodashStable.map(falsey, alwaysTrue); + + var actual = lodashStable.map(falsey, function(value, index) { + try { + var result = index ? _(value).sort().value() : _().sort().value(); + return lodashStable.eq(result, value); + } catch (e) {} + }); + + assert.deepEqual(actual, expected); + } + else { + skipAssert(assert); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -23968,6 +24812,26 @@ skipAssert(assert, 5); } }); + + QUnit.test('should accept falsey arguments', function(assert) { + assert.expect(1); + + if (!isNpm) { + var expected = lodashStable.map(falsey, alwaysTrue); + + var actual = lodashStable.map(falsey, function(value, index) { + try { + var result = index ? _(value).splice(0, 1).value() : _().splice(0, 1).value(); + return lodashStable.isEqual(result, []); + } catch (e) {} + }); + + assert.deepEqual(actual, expected); + } + else { + skipAssert(assert); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -23990,6 +24854,26 @@ skipAssert(assert, 2); } }); + + QUnit.test('should accept falsey arguments', function(assert) { + assert.expect(1); + + if (!isNpm) { + var expected = lodashStable.map(falsey, alwaysTrue); + + var actual = lodashStable.map(falsey, function(value, index) { + try { + var result = index ? _(value).unshift(1).value() : _().unshift(1).value(); + return lodashStable.eq(result, value); + } catch (e) {} + }); + + assert.deepEqual(actual, expected); + } + else { + skipAssert(assert); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -24128,11 +25012,13 @@ (function() { var funcs = [ + 'add', 'camelCase', 'capitalize', 'ceil', 'clone', 'deburr', + 'divide', 'endsWith', 'escape', 'escapeRegExp', @@ -24182,6 +25068,7 @@ 'maxBy', 'min', 'minBy', + 'multiply', 'pad', 'padEnd', 'padStart', @@ -24200,6 +25087,7 @@ 'some', 'startCase', 'startsWith', + 'subtract', 'sum', 'toInteger', 'toLower', @@ -24221,9 +25109,7 @@ assert.expect(1); if (!isNpm) { - var array = [1, 2, 3], - actual = _(array)[methodName](); - + var actual = _()[methodName](); assert.notOk(actual instanceof _); } else { @@ -24235,9 +25121,7 @@ assert.expect(1); if (!isNpm) { - var array = [1, 2, 3], - actual = _(array).chain()[methodName](); - + var actual = _().chain()[methodName](); assert.ok(actual instanceof _); } else { @@ -24451,6 +25335,7 @@ 'times', 'toArray', 'toPairs', + 'toPairsIn', 'union', 'uniq', 'values', @@ -24462,7 +25347,7 @@ var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey); QUnit.test('should accept falsey arguments', function(assert) { - assert.expect(300); + assert.expect(308); var emptyArrays = lodashStable.map(falsey, alwaysEmptyArray); @@ -24500,7 +25385,7 @@ }); QUnit.test('should return an array', function(assert) { - assert.expect(70); + assert.expect(72); var array = [1, 2, 3]; diff --git a/test/underscore.html b/test/underscore.html index 7300c21d72..cf3f4221e2 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -291,6 +291,9 @@ 'isMatch': [ 'doesnt falsey match constructor on undefined/null' ], + 'isSet': [ + 'Died on test #9' + ], 'findKey': [ 'called with context' ], @@ -381,7 +384,6 @@ // Only excuse in Sauce Labs. if (!ui.isSauceLabs) { - delete QUnit.config.excused.Functions['throttle repeatedly with results']; delete QUnit.config.excused.Functions['throttle does not trigger trailing call when trailing is set to false']; delete QUnit.config.excused.Utility.now; } diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index 18acf663d1..2ca5cd53be 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -1,4 +1,4 @@ -// Backbone.js 1.2.3 +// Backbone.js 1.3.2 // (c) 2010-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Backbone may be freely distributed under the MIT license. @@ -44,7 +44,7 @@ var slice = Array.prototype.slice; // Current version of the library. Keep in sync with `package.json`. - Backbone.VERSION = '1.2.3'; + Backbone.VERSION = '1.3.2'; // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns // the `$` variable. @@ -242,7 +242,6 @@ listening.obj.off(name, callback, this); } - if (_.isEmpty(listeningTo)) this._listeningTo = void 0; return this; }; @@ -299,7 +298,7 @@ delete events[name]; } } - if (_.size(events)) return events; + return events; }; // Bind an event to only be triggered a single time. After the first time @@ -309,7 +308,8 @@ Events.once = function(name, callback, context) { // Map the event into a `{event: once}` object. var events = eventsApi(onceMap, {}, name, callback, _.bind(this.off, this)); - return this.on(events, void 0, context); + if (typeof name === 'string' && context == null) callback = void 0; + return this.on(events, callback, context); }; // Inversion-of-control versions of `once`. @@ -398,7 +398,8 @@ this.attributes = {}; if (options.collection) this.collection = options.collection; if (options.parse) attrs = this.parse(attrs, options) || {}; - attrs = _.defaults({}, attrs, _.result(this, 'defaults')); + var defaults = _.result(this, 'defaults'); + attrs = _.defaults(_.extend({}, defaults, attrs), defaults); this.set(attrs, options); this.changed = {}; this.initialize.apply(this, arguments); @@ -714,7 +715,7 @@ // Check if the model is currently in a valid state. isValid: function(options) { - return this._validate({}, _.defaults({validate: true}, options)); + return this._validate({}, _.extend({}, options, {validate: true})); }, // Run validation against the next complete set of model attributes, @@ -824,7 +825,7 @@ set: function(models, options) { if (models == null) return; - options = _.defaults({}, options, setOptions); + options = _.extend({}, setOptions, options); if (options.parse && !this._isModel(models)) { models = this.parse(models, options) || []; } @@ -834,6 +835,7 @@ var at = options.at; if (at != null) at = +at; + if (at > this.length) at = this.length; if (at < 0) at += this.length + 1; var set = []; @@ -978,11 +980,13 @@ return slice.apply(this.models, arguments); }, - // Get a model from the set by id. + // Get a model from the set by id, cid, model object with id or cid + // properties, or an attributes object that is transformed through modelId. get: function(obj) { if (obj == null) return void 0; - var id = this.modelId(this._isModel(obj) ? obj.attributes : obj); - return this._byId[obj] || this._byId[id] || this._byId[obj.cid]; + return this._byId[obj] || + this._byId[this.modelId(obj.attributes || obj)] || + obj.cid && this._byId[obj.cid]; }, // Returns `true` if the model is in the collection. @@ -1913,5 +1917,4 @@ }; return Backbone; - }); diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index 40a08f15fe..a0f6bf662e 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -101,11 +101,6 @@ assert.equal(collection2.get(model.clone()), collection2.first()); }); - QUnit.test('get with "undefined" id', function(assert) { - var collection = new Backbone.Collection([{id: 1}, {id: 'undefined'}]); - assert.equal(collection.get(1).id, 1); - }); - QUnit.test('has', function(assert) { assert.expect(15); assert.ok(col.has(a)); @@ -1583,7 +1578,7 @@ }); QUnit.test('_addReference binds all collection events & adds to the lookup hashes', function(assert) { - assert.expect(9); + assert.expect(8); var calls = {add: 0, remove: 0}; @@ -1603,7 +1598,6 @@ assert.equal(this._byId[model.id], void 0); assert.equal(this._byId[model.cid], void 0); assert.equal(model.collection, void 0); - assert.equal(model._events, void 0); } }); @@ -1739,13 +1733,14 @@ assert.equal(c2.modelId(m.attributes), void 0); }); - QUnit.test('#3039: adding at index fires with correct at', function(assert) { - assert.expect(3); - var collection = new Backbone.Collection([{at: 0}, {at: 4}]); + QUnit.test('#3039 #3951: adding at index fires with correct at', function(assert) { + assert.expect(4); + var collection = new Backbone.Collection([{val: 0}, {val: 4}]); collection.on('add', function(model, coll, options) { - assert.equal(model.get('at'), options.index); + assert.equal(model.get('val'), options.index); }); - collection.add([{at: 1}, {at: 2}, {at: 3}], {at: 1}); + collection.add([{val: 1}, {val: 2}, {val: 3}], {at: 1}); + collection.add({val: 5}, {at: 10}); }); QUnit.test('#3039: index is not sent when at is not specified', function(assert) { diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index b9b5053feb..544b39a19a 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -417,6 +417,18 @@ assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.'); }); + QUnit.test('bind a callback with a default context when none supplied', function(assert) { + assert.expect(1); + var obj = _.extend({ + assertTrue: function() { + assert.equal(this, obj, '`this` was bound to the callback'); + } + }, Backbone.Events); + + obj.once('event', obj.assertTrue); + obj.trigger('event'); + }); + QUnit.test('bind a callback with a supplied context', function(assert) { assert.expect(1); var TestClass = function() { @@ -587,6 +599,19 @@ assert.equal(obj.counter, 3); }); + QUnit.test('bind a callback with a supplied context using once with object notation', function(assert) { + assert.expect(1); + var obj = {counter: 0}; + var context = {}; + _.extend(obj, Backbone.Events); + + obj.once({ + a: function() { + assert.strictEqual(this, context, 'defaults `context` to `callback` param'); + } + }, context).trigger('a'); + }); + QUnit.test('once with off only by context', function(assert) { assert.expect(0); var context = {}; diff --git a/vendor/backbone/test/model.js b/vendor/backbone/test/model.js index 5022a3957d..b73a1c794c 100644 --- a/vendor/backbone/test/model.js +++ b/vendor/backbone/test/model.js @@ -34,6 +34,12 @@ assert.equal(model.collection, collection); }); + QUnit.test('Object.prototype properties are overridden by attributes', function(assert) { + assert.expect(1); + var model = new Backbone.Model({hasOwnProperty: true}); + assert.equal(model.get('hasOwnProperty'), true); + }); + QUnit.test('initialize with attributes and options', function(assert) { assert.expect(1); var Model = Backbone.Model.extend({ @@ -57,19 +63,6 @@ assert.equal(model.get('value'), 2); }); - QUnit.test('initialize with defaults', function(assert) { - assert.expect(2); - var Model = Backbone.Model.extend({ - defaults: { - firstName: 'Unknown', - lastName: 'Unknown' - } - }); - var model = new Model({'firstName': 'John'}); - assert.equal(model.get('firstName'), 'John'); - assert.equal(model.get('lastName'), 'Unknown'); - }); - QUnit.test('parse can return null', function(assert) { assert.expect(1); var Model = Backbone.Model.extend({ @@ -428,7 +421,7 @@ }); QUnit.test('defaults', function(assert) { - assert.expect(4); + assert.expect(9); var Defaulted = Backbone.Model.extend({ defaults: { one: 1, @@ -438,6 +431,9 @@ var model = new Defaulted({two: undefined}); assert.equal(model.get('one'), 1); assert.equal(model.get('two'), 2); + model = new Defaulted({two: 3}); + assert.equal(model.get('one'), 1); + assert.equal(model.get('two'), 3); Defaulted = Backbone.Model.extend({ defaults: function() { return { @@ -449,6 +445,15 @@ model = new Defaulted({two: undefined}); assert.equal(model.get('one'), 3); assert.equal(model.get('two'), 4); + Defaulted = Backbone.Model.extend({ + defaults: {hasOwnProperty: true} + }); + model = new Defaulted(); + assert.equal(model.get('hasOwnProperty'), true); + model = new Defaulted({hasOwnProperty: undefined}); + assert.equal(model.get('hasOwnProperty'), true); + model = new Defaulted({hasOwnProperty: false}); + assert.equal(model.get('hasOwnProperty'), false); }); QUnit.test('change, hasChanged, changedAttributes, previous, previousAttributes', function(assert) { @@ -989,8 +994,8 @@ QUnit.test('`previous` for falsey keys', function(assert) { assert.expect(2); - var model = new Backbone.Model({0: true, '': true}); - model.set({0: false, '': false}, {silent: true}); + var model = new Backbone.Model({'0': true, '': true}); + model.set({'0': false, '': false}, {silent: true}); assert.equal(model.previous(0), true); assert.equal(model.previous(''), true); }); diff --git a/vendor/underscore/test/functions.js b/vendor/underscore/test/functions.js index 8d2b4dbb3e..f696bd648d 100644 --- a/vendor/underscore/test/functions.js +++ b/vendor/underscore/test/functions.js @@ -475,9 +475,9 @@ }); QUnit.test('debounce asap', function(assert) { - assert.expect(4); + assert.expect(6); var done = assert.async(); - var a, b; + var a, b, c; var counter = 0; var incr = function(){ return ++counter; }; var debouncedIncr = _.debounce(incr, 64, true); @@ -489,7 +489,13 @@ _.delay(debouncedIncr, 16); _.delay(debouncedIncr, 32); _.delay(debouncedIncr, 48); - _.delay(function(){ assert.equal(counter, 1, 'incr was debounced'); done(); }, 128); + _.delay(function(){ + assert.equal(counter, 1, 'incr was debounced'); + c = debouncedIncr(); + assert.equal(c, 2); + assert.equal(counter, 2, 'incr was called again'); + done(); + }, 128); }); QUnit.test('debounce asap cancel', function(assert) { diff --git a/vendor/underscore/test/objects.js b/vendor/underscore/test/objects.js index 614d1cd8f8..fa1d9e3e3e 100644 --- a/vendor/underscore/test/objects.js +++ b/vendor/underscore/test/objects.js @@ -565,6 +565,14 @@ assert.equal(_.isEqual({a: 0}, {a: -0}), false); assert.equal(_.isEqual([NaN], [NaN]), true); assert.equal(_.isEqual({a: NaN}, {a: NaN}), true); + + if (typeof Symbol !== 'undefined') { + var symbol = Symbol('x'); + assert.strictEqual(_.isEqual(symbol, symbol), true, 'A symbol is equal to itself'); + assert.strictEqual(_.isEqual(symbol, Object(symbol)), true, 'Even when wrapped in Object()'); + assert.strictEqual(_.isEqual(symbol, null), false, 'Different types are not equal'); + } + }); QUnit.test('isEmpty', function(assert) { @@ -673,6 +681,100 @@ assert.ok(_.isBoolean(false), 'and so is false'); }); + QUnit.test('isMap', function(assert) { + assert.ok(!_.isMap('string'), 'a string is not a map'); + assert.ok(!_.isMap(2), 'a number is not a map'); + assert.ok(!_.isMap({}), 'an object is not a map'); + assert.ok(!_.isMap(false), 'a boolean is not a map'); + assert.ok(!_.isMap(void 0), 'undefined is not a map'); + assert.ok(!_.isMap([1, 2, 3]), 'an array is not a map'); + if (typeof Set === 'function') { + assert.ok(!_.isMap(new Set()), 'a set is not a map'); + } + if (typeof WeakSet === 'function') { + assert.ok(!_.isMap(new WeakSet()), 'a weakset is not a map'); + } + if (typeof WeakMap === 'function') { + assert.ok(!_.isMap(new WeakMap()), 'a weakmap is not a map'); + } + if (typeof Map === 'function') { + var keyString = 'a string'; + var obj = new Map(); + obj.set(keyString, 'value'); + assert.ok(_.isMap(obj), 'but a map is'); + } + }); + + QUnit.test('isWeakMap', function(assert) { + assert.ok(!_.isWeakMap('string'), 'a string is not a weakmap'); + assert.ok(!_.isWeakMap(2), 'a number is not a weakmap'); + assert.ok(!_.isWeakMap({}), 'an object is not a weakmap'); + assert.ok(!_.isWeakMap(false), 'a boolean is not a weakmap'); + assert.ok(!_.isWeakMap(void 0), 'undefined is not a weakmap'); + assert.ok(!_.isWeakMap([1, 2, 3]), 'an array is not a weakmap'); + if (typeof Set === 'function') { + assert.ok(!_.isWeakMap(new Set()), 'a set is not a weakmap'); + } + if (typeof WeakSet === 'function') { + assert.ok(!_.isWeakMap(new WeakSet()), 'a weakset is not a weakmap'); + } + if (typeof Map === 'function') { + assert.ok(!_.isWeakMap(new Map()), 'a map is not a weakmap'); + } + if (typeof WeakMap === 'function') { + var keyObj = {}, obj = new WeakMap(); + obj.set(keyObj, 'value'); + assert.ok(_.isWeakMap(obj), 'but a weakmap is'); + } + }); + + QUnit.test('isSet', function(assert) { + assert.ok(!_.isSet('string'), 'a string is not a set'); + assert.ok(!_.isSet(2), 'a number is not a set'); + assert.ok(!_.isSet({}), 'an object is not a set'); + assert.ok(!_.isSet(false), 'a boolean is not a set'); + assert.ok(!_.isSet(void 0), 'undefined is not a set'); + assert.ok(!_.isSet([1, 2, 3]), 'an array is not a set'); + if (typeof Map === 'function') { + assert.ok(!_.isSet(new Map()), 'a map is not a set'); + } + if (typeof WeakMap === 'function') { + assert.ok(!_.isSet(new WeakMap()), 'a weakmap is not a set'); + } + if (typeof WeakSet === 'function') { + assert.ok(!_.isSet(new WeakSet()), 'a weakset is not a set'); + } + if (typeof Set === 'function') { + var obj = new Set(); + obj.add(1).add('string').add(false).add({}); + assert.ok(_.isSet(obj), 'but a set is'); + } + }); + + QUnit.test('isWeakSet', function(assert) { + + assert.ok(!_.isWeakSet('string'), 'a string is not a weakset'); + assert.ok(!_.isWeakSet(2), 'a number is not a weakset'); + assert.ok(!_.isWeakSet({}), 'an object is not a weakset'); + assert.ok(!_.isWeakSet(false), 'a boolean is not a weakset'); + assert.ok(!_.isWeakSet(void 0), 'undefined is not a weakset'); + assert.ok(!_.isWeakSet([1, 2, 3]), 'an array is not a weakset'); + if (typeof Map === 'function') { + assert.ok(!_.isWeakSet(new Map()), 'a map is not a weakset'); + } + if (typeof WeakMap === 'function') { + assert.ok(!_.isWeakSet(new WeakMap()), 'a weakmap is not a weakset'); + } + if (typeof Set === 'function') { + assert.ok(!_.isWeakSet(new Set()), 'a set is not a weakset'); + } + if (typeof WeakSet === 'function') { + var obj = new WeakSet(); + obj.add({x: 1}, {y: 'string'}).add({y: 'string'}).add({z: [1, 2, 3]}); + assert.ok(_.isWeakSet(obj), 'but a weakset is'); + } + }); + QUnit.test('isFunction', function(assert) { assert.ok(!_.isFunction(void 0), 'undefined vars are not functions'); assert.ok(!_.isFunction([1, 2, 3]), 'arrays are not functions'); diff --git a/vendor/underscore/underscore.js b/vendor/underscore/underscore.js index 78c709bd39..bddfdc9f12 100644 --- a/vendor/underscore/underscore.js +++ b/vendor/underscore/underscore.js @@ -20,6 +20,7 @@ // Save bytes in the minified (but not gzipped) version: var ArrayProto = Array.prototype, ObjProto = Object.prototype; + var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; // Create quick reference variables for speed access to core prototypes. var push = ArrayProto.push, @@ -218,12 +219,8 @@ // Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, predicate, context) { - var key; - if (isArrayLike(obj)) { - key = _.findIndex(obj, predicate, context); - } else { - key = _.findKey(obj, predicate, context); - } + var keyFinder = isArrayLike(obj) ? _.findIndex : _.findKey; + var key = keyFinder(obj, predicate, context); if (key !== void 0 && key !== -1) return obj[key]; }; @@ -442,7 +439,7 @@ // Keep surrogate pair characters together return obj.match(reStrSymbol); } - if (isArrayLike(obj)) return _.map(obj, _.identity); + if (isArrayLike(obj)) return _.map(obj); return _.values(obj); }; @@ -494,7 +491,7 @@ // Trim out all falsy values from an array. _.compact = function(array) { - return _.filter(array, _.identity); + return _.filter(array); }; // Internal implementation of a recursive `flatten` function. @@ -859,12 +856,12 @@ }; var debounced = restArgs(function(args) { - var callNow = immediate && !timeout; if (timeout) clearTimeout(timeout); - if (callNow) { + if (immediate) { + var callNow = !timeout; timeout = setTimeout(later, wait); - result = func.apply(this, args); - } else if (!immediate) { + if (callNow) result = func.apply(this, args); + } else { timeout = _.delay(later, wait, this, args); } @@ -1195,6 +1192,8 @@ // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. return +a === +b; + case '[object Symbol]': + return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); } var areArrays = className === '[object Array]'; @@ -1285,8 +1284,8 @@ return type === 'function' || type === 'object' && !!obj; }; - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. - _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol'], function(name) { + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError, isMap, isWeakMap, isSet, isWeakSet. + _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet'], function(name) { _['is' + name] = function(obj) { return toString.call(obj) === '[object ' + name + ']'; };