From e775a584966e827ad5b6be992c565702ab801672 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 10 Jan 2016 13:43:51 -0800 Subject: [PATCH] Rebuild lodash and docs. --- dist/lodash.core.js | 680 ++-- dist/lodash.core.min.js | 53 +- dist/lodash.fp.js | 106 +- dist/lodash.fp.min.js | 11 +- dist/lodash.js | 4713 ++++++++++++++++----------- dist/lodash.min.js | 119 +- dist/mapping.fp.js | 38 +- doc/README.md | 6793 ++++++++++++++++++++++++--------------- lodash.js | 5 +- 9 files changed, 7560 insertions(+), 4958 deletions(-) diff --git a/dist/lodash.core.js b/dist/lodash.core.js index de170519a..15d49a4ab 100644 --- a/dist/lodash.core.js +++ b/dist/lodash.core.js @@ -1,10 +1,10 @@ /** * @license - * lodash 4.0.0-pre (Custom Build) - * Build: `lodash core -o dist/lodash.core.js exports="amd,global"` - * Copyright 2012-2015 The Dojo Foundation + * lodash 4.0.0 (Custom Build) + * Build: `lodash core -o ./dist/lodash.core.js` + * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license */ ;(function() { @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.0.0-pre'; + var VERSION = '4.0.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -80,6 +80,9 @@ /** Detect free variable `window`. */ var freeWindow = checkGlobal(objectTypes[typeof window] && window); + /** Detect the popular CommonJS extension `module.exports`. */ + var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; + /** Detect `this` as the global object. */ var thisGlobal = checkGlobal(objectTypes[typeof this] && this); @@ -93,20 +96,6 @@ /*--------------------------------------------------------------------------*/ - /** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. - * - * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. - */ - function apply(func, thisArg, args) { - return func.apply(thisArg, args); - } - /** * Creates a new array concatenating `array` with `other`. * @@ -138,24 +127,6 @@ return array; } - /** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function assignValue(object, key, value) { - var oldValue = object[key]; - if ((value === value ? (value !== oldValue) : (oldValue === oldValue)) || - (value === undefined && !(key in object))) { - object[key] = value; - } - } - /** * The base implementation of methods like `_.max` and `_.min` which accepts a * `comparator` to determine the extremum value. @@ -187,7 +158,7 @@ /** * The base implementation of methods like `_.find` and `_.findKey`, without - * support for callback shorthands, which iterates over `collection` using + * support for iteratee shorthands, which iterates over `collection` using * the provided `eachFunc`. * * @private @@ -210,7 +181,7 @@ /** * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for callback shorthands, which iterates over `collection` using the provided + * for iteratee shorthands, which iterates over `collection` using the provided * `eachFunc`. * * @private @@ -231,7 +202,7 @@ } /** - * The base implementation of `_.times` without support for callback shorthands + * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. * * @private @@ -308,45 +279,6 @@ return 0; } - /** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. - * @param {Object} [object={}] The object to copy properties to. - * @returns {Object} Returns `object`. - */ - function copyObject(source, props, object) { - return copyObjectWith(source, props, object); - } - - /** - * This function is like `copyObject` except that it accepts a function to - * customize copied values. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ - function copyObjectWith(source, props, object, customizer) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index], - newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key]; - - assignValue(object, key, newValue); - } - return object; - } - /** * Used by `_.escape` to convert characters to HTML entities. * @@ -412,8 +344,7 @@ /** Used for built-in method references. */ var arrayProto = Array.prototype, - objectProto = Object.prototype, - stringProto = String.prototype; + objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; @@ -425,13 +356,15 @@ * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * of values. */ - var objToString = objectProto.toString; + var objectToString = objectProto.toString; /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = root._; /** Built-in value references. */ - var Reflect = root.Reflect, + var _Symbol = root.Symbol, + Reflect = root.Reflect, + Uint8Array = root.Uint8Array, enumerate = Reflect ? Reflect.enumerate : undefined, propertyIsEnumerable = objectProto.propertyIsEnumerable; @@ -453,17 +386,16 @@ * Explicit chaining, which must be unwrapped with `_#value` in all cases, * may be enabled using `_.chain`. * - * The execution of chained methods is lazy, that is, execution is deferred - * until `_#value` is implicitly or explicitly called. + * 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 strategy which merge iteratee calls; this can help - * to avoid the creation of intermediate data structures and greatly reduce the - * number of iteratee executions. Sections of a chain sequence may qualify for - * shortcut fusion if the section is applied to an array of at least two hundred - * elements and any iteratees or predicates accept only one argument. The - * heuristic for whether a section qualifies for shortcut fusion is subject - * to change. + * 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. @@ -484,26 +416,26 @@ * The chainable wrapper methods are: * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`, - * `compact`, `concat`, `conforms`, `conj`, `constant`, `countBy`, `create`, - * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, - * `difference`, `differenceBy`, `differenceWith`, `disj`, `drop`, `dropRight`, - * `dropRightWhile`, `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, - * `flip`, `flow`, `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, - * `forOwn`, `forOwnRight`, `functions`, `functionsIn`, `groupBy`, `initial`, - * `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invoke`, + * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, + * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, + * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, + * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`, + * `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, + * `forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, + * `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invokeMap`, * `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, * `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, - * `methodOf`, `mixin`, `modArgs`, `modArgsSet', `negate`, `nthArg`, `omit`, - * `omitBy`, `once`, `pairs`, `pairsIn`, `partial`, `partialRight`, `partition`, - * `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, - * `pullAllBy`, `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, - * `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, - * `sortBy`, `sortByOrder`, `splice`, `spread`, `tail`, `take`, `takeRight`, - * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, - * `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`, - * `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`, - * `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, - * `xorWith`, `zip`, `zipObject`, and `zipWith` + * `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, + * `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`, + * `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, + * `pullAll`, `pullAllBy`, `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`, `values`, `valuesIn`, `without`, + * `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, and `zipWith` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, @@ -511,25 +443,25 @@ * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`, * `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, - * `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, - * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, - * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`, - * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, - * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`, - * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, - * `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`, - * `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`, `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`, `toLower`, - * `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`, `toUpper`, - * `trim`, `trimLeft`, `trimRight`, `truncate`, `unescape`, `uniqueId`, + * `invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, + * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, + * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, + * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, + * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, + * `isString`, `isUndefined`, `isTypedArray`, `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`, + * `toLower`, `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`, + * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, * `upperCase`, `upperFirst`, `value`, and `words` * * @name _ * @constructor - * @category Chain + * @category Seq * @param {*} value The value to wrap in a `lodash` instance. * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -587,12 +519,34 @@ * @param {*} objValue The destination value. * @param {*} srcValue The source value. * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. * @returns {*} Returns the value to assign. */ - function assignInDefaults(objValue, srcValue, key) { - return (objValue === undefined || objValue === objectProto[key]) - ? srcValue - : objValue; + function assignInDefaults(objValue, srcValue, key, object) { + if (objValue === undefined || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { + return srcValue; + } + return objValue; + } + + /** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignValue(object, key, value) { + var objValue = object[key]; + if ((!eq(objValue, value) || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) || + (value === undefined && !(key in object))) { + object[key] = value; + } } /** @@ -633,7 +587,7 @@ } /** - * The base implementation of `_.forEach` without support for callback shorthands. + * The base implementation of `_.forEach` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -643,7 +597,7 @@ var baseEach = createBaseEach(baseForOwn); /** - * The base implementation of `_.every` without support for callback shorthands. + * The base implementation of `_.every` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -660,7 +614,7 @@ } /** - * The base implementation of `_.filter` without support for callback shorthands. + * The base implementation of `_.filter` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -725,7 +679,7 @@ var baseFor = createBaseFor(); /** - * The base implementation of `_.forOwn` without support for callback shorthands. + * The base implementation of `_.forOwn` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. @@ -763,7 +717,7 @@ * The bitmask may be composed of the following flags: * 1 - Unordered comparison * 2 - Partial comparison - * @param {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, customizer, bitmask, stack) { @@ -787,7 +741,7 @@ * @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 {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { @@ -797,13 +751,13 @@ othTag = arrayTag; if (!objIsArr) { - objTag = objToString.call(object); + objTag = objectToString.call(object); if (objTag == argsTag) { objTag = objectTag; } } if (!othIsArr) { - othTag = objToString.call(other); + othTag = objectToString.call(other); if (othTag == argsTag) { othTag = objectTag; } @@ -827,20 +781,15 @@ if (!isSameTag) { return false; } - // Assume cyclic values are equal. - // For more information on detecting circular references see https://es5.github.io/#JO. stack || (stack = []); var stacked = find(stack, function(entry) { return entry[0] === object; }); - stacked = stacked && stacked[1]; - if (stacked) { - return stacked == other; + if (stacked && stacked[1]) { + return stacked[1] == other; } stack.push([object, other]); - - var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); - + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); stack.pop(); return result; } @@ -901,7 +850,7 @@ } /** - * The base implementation of `_.map` without support for callback shorthands. + * The base implementation of `_.map` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -989,11 +938,10 @@ var index = -1, length = array.length; - start = start == null ? 0 : toInteger(start); if (start < 0) { start = -start > length ? 0 : (length + start); } - end = (end === undefined || end > length) ? length : toInteger(end); + end = end > length ? length : end; if (end < 0) { end += length; } @@ -1015,10 +963,12 @@ * @param {Array} [array=[]] The array to copy values to. * @returns {Array} Returns `array`. */ - var copyArray = baseSlice; + function copyArray(source) { + return baseSlice(source, 0, source.length); + } /** - * The base implementation of `_.some` without support for callback shorthands. + * The base implementation of `_.some` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -1042,7 +992,7 @@ * * @private * @param {*} value The unwrapped value. - * @param {Array} actions Actions to peform to resolve the unwrapped value. + * @param {Array} actions Actions to perform to resolve the unwrapped value. * @returns {*} Returns the resolved value. */ function baseWrapperValue(value, actions) { @@ -1052,6 +1002,43 @@ }, result); } + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property names to copy. + * @param {Object} [object={}] The object to copy properties to. + * @returns {Object} Returns `object`. + */ + var copyObject = copyObjectWith; + + /** + * This function is like `copyObject` except that it accepts a function to + * customize copied values. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property names to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ + function copyObjectWith(source, props, object, customizer) { + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index], + newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key]; + + assignValue(object, key, newValue); + } + return object; + } + /** * Creates a function like `_.assign`. * @@ -1062,7 +1049,7 @@ function createAssigner(assigner) { return rest(function(object, sources) { var index = -1, - length = object == null ? 0 : sources.length, + length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined; customizer = typeof customizer == 'function' ? (length--, customizer) : undefined; @@ -1115,13 +1102,13 @@ */ function createBaseFor(fromRight) { return function(object, iteratee, keysFunc) { - var iterable = Object(object), + var index = -1, + iterable = Object(object), props = keysFunc(object), - length = props.length, - index = fromRight ? length : -1; + length = props.length; - while ((fromRight ? index-- : ++index < length)) { - var key = props[index]; + while (length--) { + var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } @@ -1186,7 +1173,7 @@ while (argsLength--) { args[leftIndex++] = arguments[++argsIndex]; } - return apply(fn, isBind ? thisArg : this, args); + return fn.apply(isBind ? thisArg : this, args); } return wrapper; } @@ -1201,7 +1188,7 @@ * @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 {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { @@ -1214,30 +1201,35 @@ if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } + var result = true; + // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; - var result; - if (result !== undefined) { - if (result) { + var compared; + if (compared !== undefined) { + if (compared) { continue; } - return false; + result = false; + break; } // 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 false; + result = false; + break; } } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { - return false; + result = false; + break; } } - return true; + return result; } /** @@ -1258,6 +1250,7 @@ */ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) { switch (tag) { + case boolTag: case dateTag: // Coerce dates and booleans to numbers, dates to milliseconds and booleans @@ -1276,6 +1269,7 @@ // Coerce regexes to strings and treat strings primitives and string // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. return object == (other + ''); + } return false; } @@ -1290,7 +1284,7 @@ * @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 {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { @@ -1312,23 +1306,26 @@ return false; } } + var result = true; + var skipCtor = isPartial; while (++index < objLength) { key = objProps[index]; var objValue = object[key], othValue = other[key]; - var result; + var compared; // Recursively compare objects (susceptible to call stack limits). - if (!(result === undefined + if (!(compared === undefined ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack)) - : result + : compared )) { - return false; + result = false; + break; } skipCtor || (skipCtor = key == 'constructor'); } - if (!skipCtor) { + if (result && !skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; @@ -1337,10 +1334,10 @@ ('constructor' in object && 'constructor' in other) && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { - return false; + result = false; } } - return true; + return result; } /** @@ -1574,8 +1571,8 @@ /** * Creates a slice of `array` from `start` up to, but not including, `end`. * - * **Note:** This method is used instead of `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 _ @@ -1598,7 +1595,7 @@ * * @static * @memberOf _ - * @category Chain + * @category Seq * @param {*} value The value to wrap. * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -1633,7 +1630,7 @@ * * @static * @memberOf _ - * @category Chain + * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. * @returns {*} Returns `value`. @@ -1657,7 +1654,7 @@ * * @static * @memberOf _ - * @category Chain + * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. * @returns {*} Returns the result of `interceptor`. @@ -1681,7 +1678,7 @@ * * @name chain * @memberOf _ - * @category Chain + * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example * @@ -1712,7 +1709,7 @@ * @name value * @memberOf _ * @alias run, toJSON, valueOf - * @category Chain + * @category Seq * @returns {*} Returns the resolved unwrapped value. * @example * @@ -1747,15 +1744,15 @@ * { 'user': 'fred', 'active': false } * ]; * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.every(users, { 'user': 'barney', 'active': false }); * // => false * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.every(users, ['active', false]); * // => true * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.every(users, 'active'); * // => false */ @@ -1777,27 +1774,25 @@ * @returns {Array} Returns the new filtered array. * @example * - * var resolve = _.partial(_.map, _, 'user'); - * * var users = [ * { 'user': 'barney', 'age': 36, 'active': true }, * { 'user': 'fred', 'age': 40, 'active': false } * ]; * - * resolve( _.filter(users, function(o) { return !o.active; }) ); - * // => ['fred'] + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] * - * // using the `_.matches` callback shorthand - * resolve( _.filter(users, { 'age': 36, 'active': true }) ); - * // => ['barney'] + * // using the `_.matches` iteratee shorthand + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.filter(users, ['active', false]) ); - * // => ['fred'] + * // using the `_.matchesProperty` iteratee shorthand + * _.filter(users, ['active', false]); + * // => objects for ['fred'] * - * // using the `_.property` callback shorthand - * resolve( _.filter(users, 'active') ); - * // => ['barney'] + * // using the `_.property` iteratee shorthand + * _.filter(users, 'active'); + * // => objects for ['barney'] */ function filter(collection, predicate) { return baseFilter(collection, baseIteratee(predicate)); @@ -1816,28 +1811,26 @@ * @returns {*} Returns the matched element, else `undefined`. * @example * - * var resolve = _.partial(_.result, _, 'user'); - * * var users = [ * { 'user': 'barney', 'age': 36, 'active': true }, * { 'user': 'fred', 'age': 40, 'active': false }, * { 'user': 'pebbles', 'age': 1, 'active': true } * ]; * - * resolve( _.find(users, function(o) { return o.age < 40; }) ); - * // => 'barney' + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' * - * // using the `_.matches` callback shorthand - * resolve( _.find(users, { 'age': 1, 'active': true }) ); - * // => 'pebbles' + * // using the `_.matches` iteratee shorthand + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.find(users, ['active', false]) ); - * // => 'fred' + * // using the `_.matchesProperty` iteratee shorthand + * _.find(users, ['active', false]); + * // => object for 'fred' * - * // using the `_.property` callback shorthand - * resolve( _.find(users, 'active') ); - * // => 'barney' + * // using the `_.property` iteratee shorthand + * _.find(users, 'active'); + * // => object for 'barney' */ function find(collection, predicate) { return baseFind(collection, baseIteratee(predicate), baseEach); @@ -1887,17 +1880,17 @@ * @param {Array|Object} collection The collection to iterate over. * @param {Array|Function|string} path The path of the method to invoke or * the function invoked per iteration. - * @param {...*} [args] The arguments to invoke the method with. + * @param {...*} [args] The arguments to invoke each method with. * @returns {Array} Returns the array of results. * @example * - * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); + * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); * // => [[1, 5, 7], [1, 2, 3]] * - * _.invoke([123, 456], String.prototype.split, ''); + * _.invokeMap([123, 456], String.prototype.split, ''); * // => [['1', '2', '3'], ['4', '5', '6']] */ - var invoke = rest(function(collection, path, args) { + var invokeMap = rest(function(collection, path, args) { var isFunc = typeof path == 'function'; return baseMap(collection, function(value) { var func = isFunc ? path : value[path]; @@ -1914,9 +1907,9 @@ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. * * The guarded methods are: - * `ary`, `callback`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, - * `fill`, `invert`, `parseInt`, `random`, `range`, `slice`, `some`, `sortBy`, - * `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`, `uniq`, + * `ary`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, `fill`, + * `invert`, `parseInt`, `random`, `range`, `rangeRight`, `slice`, `some`, + * `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`, * and `words` * * @static @@ -1942,7 +1935,7 @@ * { 'user': 'fred' } * ]; * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.map(users, 'user'); * // => ['barney', 'fred'] */ @@ -1962,8 +1955,8 @@ * `_.reduce`, `_.reduceRight`, and `_.transform`. * * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortBy`, - * and `sortByOrder` + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` * * @static * @memberOf _ @@ -2039,15 +2032,15 @@ * { 'user': 'fred', 'active': false } * ]; * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.some(users, { 'user': 'barney', 'active': false }); * // => false * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.some(users, ['active', false]); * // => true * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.some(users, 'active'); * // => true */ @@ -2071,8 +2064,6 @@ * @returns {Array} Returns the new sorted array. * @example * - * var resolve = _.partial(_.map, _, _.values); - * * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, @@ -2080,16 +2071,16 @@ * { 'user': 'barney', 'age': 34 } * ]; * - * resolve( _.sortBy(users, function(o) { return o.user; }) ); - * // => // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * _.sortBy(users, function(o) { return o.user; }); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] * - * resolve( _.sortBy(users, ['user', 'age']) ); - * // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] * - * resolve( _.sortBy(users, 'user', function(o) { + * _.sortBy(users, 'user', function(o) { * return Math.floor(o.age / 10); - * }) ); - * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * }); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] */ function sortBy(collection, iteratee) { var index = 0; @@ -2137,7 +2128,7 @@ * @returns {Function} Returns the new restricted function. * @example * - * jQuery('#add').on('click', _.before(5, addContactToList)); + * jQuery(element).on('click', _.before(5, addContactToList)); * // => allows adding up to 4 contacts to the list */ function before(n, func) { @@ -2204,7 +2195,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to defer. - * @param {...*} [args] The arguments to invoke the function with. + * @param {...*} [args] The arguments to invoke `func` with. * @returns {number} Returns the timer id. * @example * @@ -2226,7 +2217,7 @@ * @category Function * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. - * @param {...*} [args] The arguments to invoke the function with. + * @param {...*} [args] The arguments to invoke `func` with. * @returns {number} Returns the timer id. * @example * @@ -2269,8 +2260,8 @@ /** * Creates a function that is restricted to invoking `func` once. Repeat calls - * to the function return the value of the first call. The `func` is invoked - * with the `this` binding and arguments of the created function. + * to the function return the value of the first invocation. The `func` is + * invoked with the `this` binding and arguments of the created function. * * @static * @memberOf _ @@ -2340,11 +2331,12 @@ * Creates a shallow clone of `value`. * * **Note:** This method is loosely based on the - * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). - * The enumerable properties of `arguments` objects and objects created by - * constructors other than `Object` are cloned to plain `Object` objects. An - * empty object is returned for uncloneable values such as functions, DOM nodes, - * Maps, Sets, and WeakMaps. + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * 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. * * @static * @memberOf _ @@ -2353,13 +2345,10 @@ * @returns {*} Returns the cloned value. * @example * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; + * var objects = [{ 'a': 1 }, { 'b': 2 }]; * - * var shallow = _.clone(users); - * console.log(shallow[0] === users[0]); + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); * // => true */ function clone(value) { @@ -2369,6 +2358,40 @@ return isArray(value) ? copyArray(value) : copyObject(value, keys(value)); } + /** + * 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 _ + * @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`. + * @example + * + * var object = { 'user': 'fred' }; + * var other = { 'user': 'fred' }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ + function eq(value, other) { + return value === other || (value !== value && other !== other); + } + /** * Checks if `value` is greater than `other`. * @@ -2412,7 +2435,7 @@ function isArguments(value) { // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objToString.call(value) == argsTag); + (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); } /** @@ -2516,7 +2539,7 @@ */ function isBoolean(value) { return value === true || value === false || - (isObjectLike(value) && objToString.call(value) == boolTag); + (isObjectLike(value) && objectToString.call(value) == boolTag); } /** @@ -2536,7 +2559,7 @@ * // => false */ function isDate(value) { - return isObjectLike(value) && objToString.call(value) == dateTag; + return isObjectLike(value) && objectToString.call(value) == dateTag; } /** @@ -2576,10 +2599,11 @@ * Performs a deep comparison between two values to determine if they are * equivalent. * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own, not inherited, enumerable properties. Functions and DOM nodes - * are **not** supported. + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are **not** supported. * * @static * @memberOf _ @@ -2605,7 +2629,7 @@ /** * Checks if `value` is a finite primitive number. * - * **Note:** This method is based on [`Number.isFinite`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite). + * **Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite). * * @static * @memberOf _ @@ -2650,7 +2674,7 @@ // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 8 which returns 'object' for typed array constructors, and // PhantomJS 1.9 which returns 'function' for `NodeList` instances. - var tag = isObject(value) ? objToString.call(value) : ''; + var tag = isObject(value) ? objectToString.call(value) : ''; return tag == funcTag || tag == genTag; } @@ -2790,29 +2814,6 @@ return value === null; } - /** - * Checks if `value` is `null` or `undefined`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is nullish, else `false`. - * @example - * - * _.isNil(null); - * // => true - * - * _.isNil(void 0); - * // => true - * - * _.isNil(NaN); - * // => false - */ - function isNil(value) { - return value == null; - } - /** * Checks if `value` is classified as a `Number` primitive or object. * @@ -2840,7 +2841,7 @@ */ function isNumber(value) { return typeof value == 'number' || - (isObjectLike(value) && objToString.call(value) == numberTag); + (isObjectLike(value) && objectToString.call(value) == numberTag); } /** @@ -2860,7 +2861,7 @@ * // => false */ function isRegExp(value) { - return isObject(value) && objToString.call(value) == regexpTag; + return isObject(value) && objectToString.call(value) == regexpTag; } /** @@ -2881,7 +2882,7 @@ */ function isString(value) { return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && objToString.call(value) == stringTag); + (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); } /** @@ -2938,10 +2939,17 @@ * @returns {Array} Returns the converted array. * @example * - * (function() { - * return _.toArray(arguments).slice(1); - * }(1, 2, 3)); - * // => [2, 3] + * _.toArray({ 'a': 1, 'b': 2 }); + * // => [1, 2] + * + * _.toArray('abc'); + * // => ['a', 'b', 'c'] + * + * _.toArray(1); + * // => [] + * + * _.toArray(null); + * // => [] */ function toArray(value) { if (!isArrayLike(value)) { @@ -3021,6 +3029,9 @@ * // => '1,2,3' */ function toString(value) { + if (typeof value == 'string') { + return value; + } return value == null ? '' : (value + ''); } @@ -3032,7 +3043,7 @@ * overwrite property assignments of previous sources. * * **Note:** This method mutates `object` and is loosely based on - * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). + * [`Object.assign`](https://mdn.io/Object/assign). * * @static * @memberOf _ @@ -3185,31 +3196,6 @@ return assignInWith.apply(undefined, args); }); - /** - * Creates an array of function property names from own enumerable properties - * of `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the new array of property names. - * @example - * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } - * - * Foo.prototype.c = _.constant('c'); - * - * _.functions(new Foo); - * // => ['a', 'b'] - */ - function functions(object) { - return object == null ? [] : baseFunctions(object, keys(object)); - } - /** * Checks if `path` is a direct property of `object`. * @@ -3341,10 +3327,10 @@ * @returns {Object} Returns the new object. * @example * - * var object = { 'user': 'fred', 'age': 40 }; + * var object = { 'a': 1, 'b': '2', 'c': 3 }; * - * _.pick(object, 'user'); - * // => { 'user': 'fred' } + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } */ var pick = rest(function(object, props) { return object == null ? {} : basePick(object, baseFlatten(props)); @@ -3372,10 +3358,10 @@ * _.result(object, 'a[0].b.c2'); * // => 4 * - * _.result(object, 'a.b.c', 'default'); + * _.result(object, 'a[0].b.c3', 'default'); * // => 'default' * - * _.result(object, 'a.b.c', _.constant('default')); + * _.result(object, 'a[0].b.c3', _.constant('default')); * // => 'default' */ function result(object, path, defaultValue) { @@ -3421,8 +3407,8 @@ * Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to * their corresponding HTML entities. * - * **Note:** No other characters are escaped. To escape additional characters - * use a third-party library like [_he_](https://mths.be/he). + * **Note:** No other characters are escaped. To escape additional + * characters use a third-party library like [_he_](https://mths.be/he). * * Though the ">" character is escaped for symmetry, characters like * ">" and "/" don't need escaping in HTML and have no special meaning @@ -3430,8 +3416,8 @@ * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. * - * Backticks are escaped because in Internet Explorer < 9, they can break out - * of attribute values or HTML comments. See [#59](https://html5sec.org/#59), + * 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. @@ -3463,7 +3449,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {*} value Any value. * @returns {*} Returns `value`. * @example @@ -3485,7 +3471,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {*} [func=_.identity] The value to convert to a callback. * @returns {Function} Returns the callback. * @example @@ -3495,20 +3481,15 @@ * { 'user': 'fred', 'age': 40 } * ]; * - * // wrap to create custom callback shorthands - * _.iteratee = _.wrap(_.iteratee, function(callback, func, thisArg) { - * var match = /^(.+?)__([gl]t)(.+)$/.exec(func); - * if (!match) { - * return callback(func, thisArg); - * } - * return function(object) { - * return match[2] == 'gt' - * ? object[match[1]] > match[3] - * : object[match[1]] < match[3]; + * // 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]); * }; * }); * - * _.filter(users, 'age__gt36'); + * _.filter(users, 'age > 36'); * // => [{ 'user': 'fred', 'age': 40 }] */ var iteratee = baseIteratee; @@ -3523,7 +3504,7 @@ * * @static * @memberOf _ - * @category Utility + * @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. @@ -3591,7 +3572,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @returns {Function} Returns the `lodash` function. * @example * @@ -3608,7 +3589,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @example * * var object = { 'user': 'fred' }; @@ -3625,7 +3606,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {string} [prefix] The value to prefix the ID with. * @returns {string} Returns the unique ID. * @example @@ -3708,8 +3689,7 @@ lodash.filter = filter; lodash.flatten = flatten; lodash.flattenDeep = flattenDeep; - lodash.functions = functions; - lodash.invoke = invoke; + lodash.invokeMap = invokeMap; lodash.iteratee = iteratee; lodash.keys = keys; lodash.map = map; @@ -3752,7 +3732,6 @@ lodash.isFinite = isFinite; lodash.isFunction = isFunction; lodash.isNaN = isNaN; - lodash.isNil = isNil; lodash.isNull = isNull; lodash.isNumber = isNumber; lodash.isObject = isObject; @@ -3796,8 +3775,8 @@ lodash.VERSION = VERSION; // Add `Array` and `String` methods to `lodash.prototype`. - baseEach(['pop', 'join', 'reverse', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) { - var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName], + 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', retUnwrapped = /^(?:pop|join|replace|shift)$/.test(methodName); @@ -3813,7 +3792,7 @@ }); // Add chaining functions to the `lodash` wrapper. - lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; + lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; /*--------------------------------------------------------------------------*/ @@ -3830,8 +3809,17 @@ return lodash; }); } + // Check for `exports` after `define` in case a build optimizer adds an `exports` object. + else if (freeExports && freeModule) { + // Export for Node.js. + if (moduleExports) { + (freeModule.exports = lodash)._ = lodash; + } + // Export for CommonJS support. + freeExports._ = lodash; + } else { - // Export for a browser or Rhino. + // Export to the global object. root._ = lodash; } }.call(this)); diff --git a/dist/lodash.core.min.js b/dist/lodash.core.min.js index 1942f21f0..062e55d49 100644 --- a/dist/lodash.core.min.js +++ b/dist/lodash.core.min.js @@ -1,30 +1,29 @@ /** * @license - * lodash 4.0.0-pre (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE - * Build: `lodash core -o dist/lodash.core.js exports="amd,global"` + * lodash 4.0.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 l(n){if(X(n)&&!Mn(n)){if(n instanceof p)return n;if(mn.call(n,"__wrapped__")){var t=new p(n.__wrapped__,n.__chain__);return t.__actions__=Rn(n.__actions__), -t}}return new p(n)}function p(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function s(n,t,r){return n===cn||n===jn[r]?t:n}function h(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function");return setTimeout(function(){n.apply(cn,r)},t)}function v(n,t){var r=true;return Bn(n,function(n,e,u){return r=!!t(n,e,u)}),r}function y(n,t){var r=[];return Bn(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;++ot&&(t=-t>u?0:u+t),r=r===cn||r>u?u:Pn(r),0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e1?r[u-1]:cn,o=typeof o=="function"?(u--,o):cn;for(t=Object(t);++ef))return false;for(;++iarguments.length,Bn)}function M(n){return null==n?0:(n=K(n)?n:tn(n),n.length)}function P(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function"); -return n=Pn(n),function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=cn),r}}function U(n){var t;if(typeof n!="function")throw new TypeError("Expected a function");return t=kn(t===cn?n.length-1:Pn(t),0),function(){for(var r=arguments,e=-1,u=kn(r.length-t,0),o=Array(u);++et}function H(n){return X(n)&&K(n)&&mn.call(n,"callee")&&(!Nn.call(n,"callee")||"[object Arguments]"==On.call(n)); -}function K(n){return null!=n&&!(typeof n=="function"&&L(n))&&Q(In(n))}function L(n){return n=W(n)?On.call(n):"","[object Function]"==n||"[object GeneratorFunction]"==n}function Q(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n}function W(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function X(n){return!!n&&typeof n=="object"}function Y(n){return typeof n=="number"||X(n)&&"[object Number]"==On.call(n)}function Z(n){return typeof n=="string"||!Mn(n)&&X(n)&&"[object String]"==On.call(n); -}function nn(n,t){return t>n}function tn(n){var t=q(n);if(!t&&!K(n))return Tn(Object(n));var r,e=$(n),u=!!e,e=e||[],o=e.length;for(r in n)!mn.call(n,r)||u&&("length"==r||a(r,o))||t&&"constructor"==r||e.push(r);return e}function rn(n){for(var t=-1,r=q(n),e=w(n),u=e.length,o=$(n),i=!!o,o=o||[],c=o.length;++t"'`]/g,an=RegExp(fn.source),ln=/^(?:0|[1-9]\d*)$/,pn={"&":"&","<":"<",">":">",'"':""", -"'":"'","`":"`"},sn={"function":true,object:true},hn=sn[typeof module]&&module&&!module.nodeType?module:null,vn=o(sn[typeof self]&&self),yn=o(sn[typeof window]&&window),_n=o(sn[typeof this]&&this),gn=o((sn[typeof exports]&&exports&&!exports.nodeType?exports:null)&&hn&&typeof global=="object"&&global)||yn!==(_n&&_n.window)&&yn||vn||_n||Function("return this")(),bn=Array.prototype,jn=Object.prototype,dn=String.prototype,mn=jn.hasOwnProperty,wn=0,On=jn.toString,En=gn._,xn=gn.f,An=xn?xn.g:cn,Nn=jn.propertyIsEnumerable,Sn=gn.isFinite,Tn=Object.keys,kn=Math.max,Fn=function(){ -function n(){}return function(t){if(W(t)){n.prototype=t;var r=new n;n.prototype=cn}return r||{}}}(),Bn=function(n,t){return function(r,e){if(null==r)return r;if(!K(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}),A("c"))},l.tap=function(n,t){return t(n),n},l.thru=function(n,t){return t(n)},l.toArray=function(n){return K(n)?n.length?Rn(n):[]:en(n)},l.values=en,l.each=G,l.extend=Hn,on(l,l),l.clone=function(n){if(W(n))if(Mn(n))n=Rn(n);else{var t=tn(n);n=i(n,t,void 0); -}return n},l.escape=function(n){return(n=null==n?"":n+"")&&an.test(n)?n.replace(fn,c):n},l.every=function(n,t,r){return t=r?cn:t,v(n,m(t))},l.find=C,l.forEach=G,l.has=function(n,t){return null!=n&&mn.call(n,t)},l.head=z,l.identity=un,l.indexOf=function(n,t,r){var e=n?n.length:0;r=typeof r=="number"?0>r?kn(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){if(Z(n)&&!Vn(n)){if(n instanceof l)return n;if(En.call(n,"__wrapped__")){var t=new l(n.__wrapped__,n.__chain__);return t.__actions__=k(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){return n===ln||H(n,xn[r])&&!En.call(e,r)?t:n; +}function s(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function");return setTimeout(function(){n.apply(ln,r)},t)}function h(n,t){var r=true;return $n(n,function(n,e,u){return r=!!t(n,e,u)}),r}function v(n,t){var r=[];return $n(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function y(t,r,e,u){u||(u=[]);for(var o=-1,i=t.length;++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);++e1?r[u-1]:ln,o=typeof o=="function"?(u--,o):ln;for(t=Object(t);++ef))return false;for(a=true;++iarguments.length,$n)}function P(n){return null==n?0:(n=Q(n)?n:un(n),n.length)}function U(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function"); +return n=Hn(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=Rn(t===ln?n.length-1:Hn(t),0),function(){for(var r=arguments,e=-1,u=Rn(r.length-t,0),o=Array(u);++et}function L(n){return Z(n)&&Q(n)&&En.call(n,"callee")&&(!Fn.call(n,"callee")||"[object Arguments]"==kn.call(n)); +}function Q(n){return null!=n&&!(typeof n=="function"&&W(n))&&X(Mn(n))}function W(n){return n=Y(n)?kn.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]"==kn.call(n)}function tn(n){return typeof n=="string"||!Vn(n)&&Z(n)&&"[object String]"==kn.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=M(n);if(!t&&!Q(n))return Dn(Object(n));var r,e=q(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=M(n),e=m(n),u=e.length,o=q(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:null,gn=yn[typeof module]&&module&&!module.nodeType?module:null,bn=o(yn[typeof self]&&self),jn=o(yn[typeof window]&&window),dn=gn&&gn.exports===_n?_n:null,mn=o(yn[typeof this]&&this),wn=o(_n&&gn&&typeof global=="object"&&global)||jn!==(mn&&mn.window)&&jn||bn||mn||Function("return this")(),On=Array.prototype,xn=Object.prototype,En=xn.hasOwnProperty,An=0,kn=xn.toString,Nn=wn._,Sn=wn.f,Tn=Sn?Sn.g:ln,Fn=xn.propertyIsEnumerable,Bn=wn.isFinite,Dn=Object.keys,Rn=Math.max,In=function(){ +function n(){}return function(t){if(Y(t)){n.prototype=t;var r=new n;n.prototype=ln}return r||{}}}(),$n=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--:++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 Q(n)?n.length?k(n):[]:cn(n)},a.values=cn,a.each=G,a.extend=Qn,an(a,a),a.clone=function(n){return Y(n)?Vn(n)?k(n):T(n,un(n)):n},a.escape=function(n){return(n=en(n))&&sn.test(n)?n.replace(pn,i):n},a.every=function(n,t,r){return t=r?ln:t,h(n,d(t))},a.find=C,a.forEach=G,a.has=function(n,t){ +return null!=n&&En.call(n,t)},a.head=z,a.identity=fn,a.indexOf=function(n,t,r){var e=n?n.length:0;r=typeof r=="number"?0>r?Rn(e+r,0):r:0,r=(r||0)-1;for(var u=t===t;++r 2 ? (arity - 2) : 1; func = iteratee(func); var length = func.length; - return length <= arity ? func : baseAry(func, arity); + return (length && length <= arity) ? func : baseAry(func, arity); }; }, 'mixin': function(mixin) { @@ -230,10 +223,13 @@ return /******/ (function(modules) { // webpackBootstrap return wrapper(func); } if (mutateMap.array[name]) { - func = immutArrayWrap(func); + func = immutWrap(func, cloneArray); } else if (mutateMap.object[name]) { - func = immutObjectWrap(func); + func = immutWrap(func, createCloner(func)); + } + else if (mutateMap.set[name]) { + func = immutWrap(func, cloneDeep); } var result; each(mapping.caps, function(cap) { @@ -299,8 +295,8 @@ return /******/ (function(modules) { // webpackBootstrap /** Used to map method names to their aliases. */ 'aliasMap': { 'ary': ['nAry'], - 'conj': ['allPass'], - 'disj': ['somePass'], + 'overEvery': ['allPass'], + 'overSome': ['somePass'], 'filter': ['whereEq'], 'flatten': ['unnest'], 'flow': ['pipe'], @@ -315,8 +311,7 @@ return /******/ (function(modules) { // webpackBootstrap 'isEqual': ['equals'], 'mapValues': ['mapObj'], 'matchesProperty': ['pathEq'], - 'modArgs': ['useWith'], - 'modArgsSet': ['converge'], + 'overArgs': ['useWith'], 'omit': ['dissoc', 'omitAll'], 'pick': ['pickAll'], 'property': ['prop'], @@ -370,28 +365,28 @@ return /******/ (function(modules) { // webpackBootstrap /** Used to map ary to method names. */ 'aryMethodMap': { 1: ( - 'attempt,ceil,create,curry,floor,fromPairs,iteratee,invert,over,overEvery,' + - 'overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,template,' + - 'trim,trimLeft,trimRight,uniqueId,words').split(','), + 'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,' + + 'overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,' + + 'runInContext,template,trim,trimLeft,trimRight,uniqueId,words').split(','), 2: ( 'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,' + - 'debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,' + - 'dropWhile,endsWith,every,extend,filter,find,find,findIndex,findKey,findLast,' + - 'findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,' + - 'forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,' + - 'invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,matchesProperty,' + - 'maxBy,mean,minBy,merge,modArgs,modArgsSet,omit,pad,padLeft,padRight,parseInt,' + - 'partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,' + - 'remove,repeat,result,sampleSize,set,some,sortBy,sortByOrder,sortedIndexBy,' + + 'curryRightN,debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,' + + 'dropRightWhile,dropWhile,endsWith,eq,every,extend,filter,find,find,findIndex,' + + 'findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,forEachRight,' + + 'forIn,forInRight,forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,' + + 'intersection,invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,' + + 'matchesProperty,maxBy,mean,minBy,merge,omit,orderBy,overArgs,pad,padLeft,' + + 'padRight,parseInt,partition,pick,pull,pullAll,pullAt,random,range,rangeRight,' + + 'rearg,reject,remove,repeat,result,sampleSize,some,sortBy,sortedIndexBy,' + 'sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,' + 'takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,' + 'xor,zip,zipObject').split(','), 3: ( 'assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,' + 'isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,' + - 'reduceRight,slice,transform,unionBy,xorBy,zipWith').split(','), + 'reduceRight,set,slice,transform,unionBy,xorBy,zipWith').split(','), 4: - ['fill'] + ['fill', 'setWith'] }, /** Used to map ary to rearg configs by method ary. */ @@ -406,6 +401,7 @@ return /******/ (function(modules) { // webpackBootstrap 'clamp': [2, 0, 1], 'reduce': [2, 0, 1], 'reduceRight': [2, 0, 1], + 'setWith': [3, 2, 1, 0], 'slice': [2, 0, 1], 'transform': [2, 0, 1] }, @@ -440,6 +436,10 @@ return /******/ (function(modules) { // webpackBootstrap 'extendWith': true, 'merge': true, 'mergeWith': true + }, + 'set': { + 'set': true, + 'setWith': true } }, diff --git a/dist/lodash.fp.min.js b/dist/lodash.fp.min.js index 747b41dc5..dae46c257 100644 --- a/dist/lodash.fp.min.js +++ b/dist/lodash.fp.min.js @@ -1 +1,10 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.fp=t():e.fp=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){function n(e){return i(e,e)}var i=r(1);e.exports=n},function(e,t,r){function n(e,t,r){if("function"!=typeof r&&(r=t,t=void 0),null==r)throw new TypeError;var o=void 0===t&&"string"==typeof r.VERSION,p=o?r:{ary:e.ary,curry:e.curry,forEach:e.forEach,isFunction:e.isFunction,iteratee:e.iteratee,keys:e.keys,rearg:e.rearg},u=p.ary,s=p.curry,c=p.forEach,f=p.isFunction,l=p.keys,d=p.rearg,h=function(e,t){return function(){var r=arguments,n=Math.min(r.length,t);switch(n){case 1:return e(r[0]);case 2:return e(r[0],r[1])}for(r=Array(n);n--;)r[n]=arguments[n];return e.apply(void 0,r)}},y=function(e){return function(){for(var t=-1,r=arguments.length,n=Array(r);r--;)n[r]=arguments[r];var i=n[0];for(r=i?i.length:0,n[0]=Array(r);++t2?r-2:1,t=e(t);var n=t.length;return r>=n?t:h(t,r)}},mixin:function(e){return function(t){var r=this;if(!f(r))return e(r,Object(t));var n=[],i=[];return c(l(t),function(e){var a=t[e];f(a)&&(i.push(e),n.push(r.prototype[e]))}),e(r,Object(t)),c(i,function(e,t){var i=n[t];f(i)?r.prototype[e]=i:delete r.prototype[e]}),r}},runInContext:function(t){return function(r){return n(e,t(r))}}},x=function(e,t){var r=v[e];if(r)return r(t);a.array[e]?t=y(t):a.object[e]&&(t=g(t));var n;return c(i.caps,function(r){return c(i.aryMethodMap[r],function(a){if(e==a){n=u(t,r),r>1&&!i.skipReargMap[e]&&(n=d(n,i.methodReargMap[e]||i.aryReargMap[r]));var p=!o&&i.aryIterateeMap[e];return p&&(n=m(n,p)),r>1&&(n=s(n,r)),!1}}),!n}),n||t};if(!o)return x(t,r);var R=[];return c(i.caps,function(e){c(i.aryMethodMap[e],function(e){var t=p[i.keyMap[e]||e];t&&R.push([e,x(e,t)])})}),c(R,function(e){p[e[0]]=e[1]}),c(l(p),function(e){c(i.aliasMap[e]||[],function(t){p[t]=p[e]})}),p}var i=r(2),a=i.mutateMap;e.exports=n},function(e,t){e.exports={aliasMap:{ary:["nAry"],conj:["allPass"],disj:["somePass"],filter:["whereEq"],flatten:["unnest"],flow:["pipe"],flowRight:["compose"],forEach:["each"],forEachRight:["eachRight"],get:["path"],getOr:["pathOr"],head:["first"],includes:["contains"],initial:["init"],isEqual:["equals"],mapValues:["mapObj"],matchesProperty:["pathEq"],modArgs:["useWith"],modArgsSet:["converge"],omit:["dissoc","omitAll"],pick:["pickAll"],property:["prop"],propertyOf:["propOf"],rest:["unapply"],some:["all"],spread:["apply"],zipObject:["zipObj"]},aryIterateeMap:{assignWith:2,cloneDeepWith:1,cloneWith:1,dropRightWhile:1,dropWhile:1,every:1,extendWith:2,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},aryMethodMap:{1:"attempt,ceil,create,curry,floor,fromPairs,iteratee,invert,over,overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,template,trim,trimLeft,trimRight,uniqueId,words".split(","),2:"add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,dropWhile,endsWith,every,extend,filter,find,find,findIndex,findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,matchesProperty,maxBy,mean,minBy,merge,modArgs,modArgsSet,omit,pad,padLeft,padRight,parseInt,partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,remove,repeat,result,sampleSize,set,some,sortBy,sortByOrder,sortedIndexBy,sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,xor,zip,zipObject".split(","),3:"assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,reduceRight,slice,transform,unionBy,xorBy,zipWith".split(","),4:["fill"]},aryReargMap:{2:[1,0],3:[2,1,0],4:[3,2,0,1]},methodReargMap:{clamp:[2,0,1],reduce:[2,0,1],reduceRight:[2,0,1],slice:[2,0,1],transform:[2,0,1]},caps:[1,2,3,4],keyMap:{curryN:"curry",curryRightN:"curryRight",getOr:"get"},mutateMap:{array:{fill:!0,pull:!0,pullAll:!0,pullAllBy:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignWith:!0,defaults:!0,defaultsDeep:!0,extend:!0,extendWith:!0,merge:!0,mergeWith:!0}},skipReargMap:{difference:!0,matchesProperty:!0,random:!0,range:!0,rangeRight:!0,zip:!0,zipObject:!0}}}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.fp=t():e.fp=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){function n(e){return i(e,e)}var i=r(1);e.exports=n},function(e,t,r){function n(e,t,r){ +if("function"!=typeof r&&(r=t,t=void 0),null==r)throw new TypeError;var o=void 0===t&&"string"==typeof r.VERSION,p=o?r:{ary:e.ary,cloneDeep:e.cloneDeep,curry:e.curry,forEach:e.forEach,isFunction:e.isFunction,iteratee:e.iteratee,keys:e.keys,rearg:e.rearg},u=p.ary,s=p.cloneDeep,c=p.curry,f=p.forEach,l=p.isFunction,h=p.keys,d=p.rearg,y=function(e,t){return function(){var r=arguments,n=Math.min(r.length,t);switch(n){case 1:return e(r[0]);case 2:return e(r[0],r[1])}for(r=Array(n);n--;)r[n]=arguments[n]; +return e.apply(void 0,r)}},g=function(e){for(var t=e?e.length:0,r=Array(t);t--;)r[t]=e[t];return r},m=function(e){return function(t){return e({},t)}},v=function(e,t){return x(e,t,!0)},R=function(e,t){return x(e,function(e){return y(e,t)})},x=function(e,t,r){return function(){for(var n=arguments.length,i=Array(n);n--;)i[n]=arguments[n];i[0]=t(i[0]);var a=e.apply(void 0,i);return r?i[0]:a}},W={iteratee:function(e){return function(t,r){r=r>2?r-2:1,t=e(t);var n=t.length;return n&&r>=n?t:y(t,r)}},mixin:function(e){ +return function(t){var r=this;if(!l(r))return e(r,Object(t));var n=[],i=[];return f(h(t),function(e){var a=t[e];l(a)&&(i.push(e),n.push(r.prototype[e]))}),e(r,Object(t)),f(i,function(e,t){var i=n[t];l(i)?r.prototype[e]=i:delete r.prototype[e]}),r}},runInContext:function(t){return function(r){return n(e,t(r))}}},M=function(e,t){var r=W[e];if(r)return r(t);a.array[e]?t=v(t,g):a.object[e]?t=v(t,m(t)):a.set[e]&&(t=v(t,s));var n;return f(i.caps,function(r){return f(i.aryMethodMap[r],function(a){if(e==a){ +n=u(t,r),r>1&&!i.skipReargMap[e]&&(n=d(n,i.methodReargMap[e]||i.aryReargMap[r]));var p=!o&&i.aryIterateeMap[e];return p&&(n=R(n,p)),r>1&&(n=c(n,r)),!1}}),!n}),n||t};if(!o)return M(t,r);var O=[];return f(i.caps,function(e){f(i.aryMethodMap[e],function(e){var t=p[i.keyMap[e]||e];t&&O.push([e,M(e,t)])})}),f(O,function(e){p[e[0]]=e[1]}),f(h(p),function(e){f(i.aliasMap[e]||[],function(t){p[t]=p[e]})}),p}var i=r(2),a=i.mutateMap;e.exports=n},function(e,t){e.exports={aliasMap:{ary:["nAry"],overEvery:["allPass"], +overSome:["somePass"],filter:["whereEq"],flatten:["unnest"],flow:["pipe"],flowRight:["compose"],forEach:["each"],forEachRight:["eachRight"],get:["path"],getOr:["pathOr"],head:["first"],includes:["contains"],initial:["init"],isEqual:["equals"],mapValues:["mapObj"],matchesProperty:["pathEq"],overArgs:["useWith"],omit:["dissoc","omitAll"],pick:["pickAll"],property:["prop"],propertyOf:["propOf"],rest:["unapply"],some:["all"],spread:["apply"],zipObject:["zipObj"]},aryIterateeMap:{assignWith:2,cloneDeepWith:1, +cloneWith:1,dropRightWhile:1,dropWhile:1,every:1,extendWith:2,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},aryMethodMap:{1:"attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,template,trim,trimLeft,trimRight,uniqueId,words".split(","), +2:"add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,curryRightN,debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,dropWhile,endsWith,eq,every,extend,filter,find,find,findIndex,findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,matchesProperty,maxBy,mean,minBy,merge,omit,orderBy,overArgs,pad,padLeft,padRight,parseInt,partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,remove,repeat,result,sampleSize,some,sortBy,sortedIndexBy,sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,xor,zip,zipObject".split(","), +3:"assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,reduceRight,set,slice,transform,unionBy,xorBy,zipWith".split(","),4:["fill","setWith"]},aryReargMap:{2:[1,0],3:[2,1,0],4:[3,2,0,1]},methodReargMap:{clamp:[2,0,1],reduce:[2,0,1],reduceRight:[2,0,1],setWith:[3,2,1,0],slice:[2,0,1],transform:[2,0,1]},caps:[1,2,3,4],keyMap:{curryN:"curry",curryRightN:"curryRight",getOr:"get"},mutateMap:{array:{fill:!0,pull:!0,pullAll:!0, +pullAllBy:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignWith:!0,defaults:!0,defaultsDeep:!0,extend:!0,extendWith:!0,merge:!0,mergeWith:!0},set:{set:!0,setWith:!0}},skipReargMap:{difference:!0,matchesProperty:!0,random:!0,range:!0,rangeRight:!0,zip:!0,zipObject:!0}}}])}); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 03dbd7d57..20f807b74 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1,9 +1,10 @@ /** * @license - * lodash 4.0.0-pre - * Copyright 2012-2015 The Dojo Foundation + * lodash 4.0.0 (Custom Build) + * Build: `lodash -o ./dist/lodash.js` + * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 - * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license */ ;(function() { @@ -12,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.0.0-pre'; + var VERSION = '4.0.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -30,11 +31,11 @@ var UNORDERED_COMPARE_FLAG = 1, PARTIAL_COMPARE_FLAG = 2; - /** Used as default options for `_.trunc`. */ + /** Used as default options for `_.truncate`. */ var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = '...'; - /** Used to detect when a function becomes hot. */ + /** Used to detect hot functions by number of calls within a span of milliseconds. */ var HOT_COUNT = 150, HOT_SPAN = 16; @@ -43,7 +44,8 @@ /** Used to indicate the type of lazy iteratees. */ var LAZY_FILTER_FLAG = 1, - LAZY_MAP_FLAG = 2; + LAZY_MAP_FLAG = 2, + LAZY_WHILE_FLAG = 3; /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; @@ -54,7 +56,8 @@ /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0, MAX_SAFE_INTEGER = 9007199254740991, - MAX_INTEGER = 1e308; + MAX_INTEGER = 1.7976931348623157e+308, + NAN = 0 / 0; /** Used as references for the maximum length and index of an array. */ var MAX_ARRAY_LENGTH = 4294967295, @@ -78,6 +81,7 @@ regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', + symbolTag = '[object Symbol]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', @@ -116,6 +120,11 @@ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source); + /** Used to match leading and trailing whitespace. */ + var reTrim = /^\s+|\s+$/g, + reTrimStart = /^\s+/, + reTrimEnd = /\s+$/; + /** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g; @@ -126,13 +135,22 @@ var reFlags = /\w*$/; /** Used to detect hexadecimal string values. */ - var reHasHexPrefix = /^0[xX]/; + var reHasHexPrefix = /^0x/i; + + /** Used to detect bad signed hexadecimal string values. */ + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + + /** Used to detect binary string values. */ + var reIsBinary = /^0b[01]+$/i; /** Used to detect host constructors (Safari > 5). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; + /** Used to detect octal string values. */ + var reIsOctal = /^0o[0-7]+$/i; + /** Used to detect unsigned integer values. */ - var reIsUint = /^\d+$/; + var reIsUint = /^(?:0|[1-9]\d*)$/; /** Used to match latin-1 supplementary letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; @@ -208,10 +226,10 @@ /** Used to assign default `context` object properties. */ var contextProps = [ 'Array', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', - 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Object', 'Reflect', - 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', + 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', + 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', '_', - 'clearTimeout', 'isFinite', 'parseFloat', 'parseInt', 'setTimeout' + 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' ]; /** Used to make template sourceURLs easier to identify. */ @@ -242,8 +260,9 @@ cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = - cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = - cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[symbolTag] = cloneableTags[uint8Tag] = + cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = + cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; @@ -304,6 +323,10 @@ '\u2029': 'u2029' }; + /** Built-in method references without a dependency on `root`. */ + var freeParseFloat = parseFloat, + freeParseInt = parseInt; + /** Detect free variable `exports`. */ var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; @@ -362,11 +385,32 @@ } /** - * Creates a new array joining `array` with `other`. + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. * * @private - * @param {Array} array The array to join. - * @param {Array} other The other array to join. + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ + function apply(func, thisArg, args) { + var length = args ? args.length : 0; + switch (length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); + } + + /** + * Creates a new array concatenating `array` with `other`. + * + * @private + * @param {Array} array The first array to concatenate. + * @param {Array} other The second array to concatenate. * @returns {Array} Returns the new concatenated array. */ function arrayConcat(array, other) { @@ -387,7 +431,7 @@ /** * A specialized version of `_.forEach` for arrays without support for - * callback shorthands. + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -408,7 +452,7 @@ /** * A specialized version of `_.forEachRight` for arrays without support for - * callback shorthands. + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -428,7 +472,7 @@ /** * A specialized version of `_.every` for arrays without support for - * callback shorthands. + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -449,7 +493,7 @@ /** * A specialized version of `_.filter` for arrays without support for - * callback shorthands. + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -472,7 +516,42 @@ } /** - * A specialized version of `_.map` for arrays without support for callback + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} array The array to search. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludes(array, value) { + return !!array.length && baseIndexOf(array, value, 0) > -1; + } + + /** + * A specialized version of `_.includesWith` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} array The array to search. + * @param {*} target The value to search for. + * @param {Function} comparator The comparator invoked per element. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludesWith(array, value, comparator) { + var index = -1, + length = array.length; + + while (++index < length) { + if (comparator(value, array[index])) { + return true; + } + } + return false; + } + + /** + * A specialized version of `_.map` for arrays without support for iteratee * shorthands. * * @private @@ -512,7 +591,7 @@ /** * A specialized version of `_.reduce` for arrays without support for - * callback shorthands. + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -536,7 +615,7 @@ /** * A specialized version of `_.reduceRight` for arrays without support for - * callback shorthands. + * iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -557,7 +636,7 @@ } /** - * A specialized version of `_.some` for arrays without support for callback + * A specialized version of `_.some` for arrays without support for iteratee * shorthands. * * @private @@ -577,50 +656,14 @@ return false; } - /** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function assignValue(object, key, value) { - var oldValue = object[key]; - if ((value === value ? (value !== oldValue) : (oldValue === oldValue)) || - (value === undefined && !(key in object))) { - object[key] = value; - } - } - - /** - * This function is like `assignValue` except that it doesn't assign `undefined` values. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function assignMergeValue(object, key, value) { - var oldValue = object[key]; - if ((value !== undefined && - (value === value ? (value !== oldValue) : (oldValue === oldValue))) || - (typeof key == 'number' && - value === undefined && !(key in object))) { - object[key] = value; - } - } - /** * The base implementation of methods like `_.max` and `_.min` which accepts a * `comparator` to determine the extremum value. * * @private * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} comparator The function used to compare values. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. * @returns {*} Returns the extremum value. */ function baseExtremum(array, iteratee, comparator) { @@ -643,8 +686,8 @@ } /** - * The base implementation of methods like `_.find` and `_.findKey` without - * support for callback shorthands, which iterates over `collection` using + * The base implementation of methods like `_.find` and `_.findKey`, without + * support for iteratee shorthands, which iterates over `collection` using * the provided `eachFunc`. * * @private @@ -667,7 +710,7 @@ /** * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for callback shorthands. + * support for iteratee shorthands. * * @private * @param {Array} array The array to search. @@ -712,8 +755,8 @@ } /** - * The base implementation of `_.reduce` and `_.reduceRight` without support - * for callback shorthands, which iterates over `collection` using the provided + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using the provided * `eachFunc`. * * @private @@ -754,7 +797,7 @@ } /** - * The base implementation of `_.sum` without support for callback shorthands. + * The base implementation of `_.sum` without support for iteratee shorthands. * * @private * @param {Array} array The array to iterate over. @@ -768,7 +811,7 @@ while (++index < length) { var current = iteratee(array[index]); - if (current === current && current != null) { + if (current !== undefined) { result = result === undefined ? current : (result + current); } } @@ -776,7 +819,7 @@ } /** - * The base implementation of `_.times` without support for callback shorthands + * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. * * @private @@ -794,6 +837,34 @@ return result; } + /** + * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array + * of key-value pairs for `object` corresponding to the property names of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the new array of key-value pairs. + */ + function baseToPairs(object, props) { + return arrayMap(props, function(key) { + return [key, object[key]]; + }); + } + + /** + * The base implementation of `_.unary` without support for storing wrapper metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new function. + */ + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + /** * The base implementation of `_.values` and `_.valuesIn` which creates an * array of `object` property values corresponding to the property names @@ -811,7 +882,7 @@ } /** - * Used by `_.trim` and `_.trimLeft` to get the index of the first string symbol + * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol * that is not found in the character symbols. * * @private @@ -819,7 +890,7 @@ * @param {Array} chrSymbols The character symbols to find. * @returns {number} Returns the index of the first unmatched string symbol. */ - function charsLeftIndex(strSymbols, chrSymbols) { + function charsStartIndex(strSymbols, chrSymbols) { var index = -1, length = strSymbols.length; @@ -828,7 +899,7 @@ } /** - * Used by `_.trim` and `_.trimRight` to get the index of the last string symbol + * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol * that is not found in the character symbols. * * @private @@ -836,7 +907,7 @@ * @param {Array} chrSymbols The character symbols to find. * @returns {number} Returns the index of the last unmatched string symbol. */ - function charsRightIndex(strSymbols, chrSymbols) { + function charsEndIndex(strSymbols, chrSymbols) { var index = strSymbols.length; while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} @@ -887,12 +958,12 @@ } /** - * Used by `_.sortByOrder` to compare multiple properties of a value to another + * Used by `_.orderBy` to compare multiple properties of a value to another * and stable sort them. * - * If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise, - * a value is sorted in ascending order if its corresponding order is "asc", and - * descending if "desc". + * 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. * * @private * @param {Object} object The object to compare. @@ -914,7 +985,7 @@ return result; } var order = orders[index]; - return result * (order === 'asc' ? 1 : -1); + return result * (order == 'desc' ? -1 : 1); } } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications @@ -927,64 +998,6 @@ return object.index - other.index; } - /** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ - function copyArray(source, array) { - var index = -1, - length = source.length; - - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; - } - - /** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. - * @param {Object} [object={}] The object to copy properties to. - * @returns {Object} Returns `object`. - */ - function copyObject(source, props, object) { - return copyObjectWith(source, props, object); - } - - /** - * This function is like `copyObject` except that it accepts a function to - * customize copied values. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ - function copyObjectWith(source, props, object, customizer) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index], - newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key]; - - assignValue(object, key, newValue); - } - return object; - } - /** * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. * @@ -1018,18 +1031,6 @@ return '\\' + stringEscapes[chr]; } - /** - * Used by `_.defaults` to customize its `_.assign` use. - * - * @private - * @param {*} objValue The destination object property value. - * @param {*} srcValue The source object property value. - * @returns {*} Returns the value to assign to the destination object. - */ - function extendDefaults(objValue, srcValue) { - return objValue === undefined ? srcValue : objValue; - } - /** * Gets the index at which the first occurrence of `NaN` is found in `array`. * @@ -1085,32 +1086,6 @@ return value > -1 && value % 1 == 0 && value < length; } - /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ - function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - - /** - * Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a - * character code is whitespace. - * - * @private - * @param {number} charCode The character code to inspect. - * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`. - */ - function isSpace(charCode) { - return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 || - (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279))); - } - /** * Converts `iterator` to an array. * @@ -1211,38 +1186,7 @@ * @returns {Array} Returns the converted array. */ function stringToArray(string) { - return string ? string.match(reComplexSymbol) : []; - } - - /** - * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace - * character of `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the index of the first non-whitespace character. - */ - function trimmedLeftIndex(string) { - var index = -1, - length = string.length; - - while (++index < length && isSpace(string.charCodeAt(index))) {} - return index; - } - - /** - * Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace - * character of `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the index of the last non-whitespace character. - */ - function trimmedRightIndex(string) { - var index = string.length; - - while (index-- && isSpace(string.charCodeAt(index))) {} - return index; + return string.match(reComplexSymbol); } /** @@ -1259,11 +1203,11 @@ /*--------------------------------------------------------------------------*/ /** - * Create a new pristine `lodash` function using the given `context` object. + * Create a new pristine `lodash` function using the `context` object. * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Object} [context=root] The context object. * @returns {Function} Returns a new `lodash` function. * @example @@ -1305,11 +1249,10 @@ /** Used for built-in method references. */ var arrayProto = context.Array.prototype, - objectProto = context.Object.prototype, - stringProto = context.String.prototype; + objectProto = context.Object.prototype; /** Used to resolve the decompiled source of functions. */ - var fnToString = context.Function.prototype.toString; + var funcToString = context.Function.prototype.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; @@ -1318,33 +1261,32 @@ var idCounter = 0; /** Used to infer the `Object` constructor. */ - var objCtorString = fnToString.call(Object); + var objectCtorString = funcToString.call(Object); /** * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * of values. */ - var objToString = objectProto.toString; + var objectToString = objectProto.toString; /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = root._; /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + - fnToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); /** Built-in value references. */ - var Reflect = context.Reflect, - Symbol = context.Symbol, + var _Symbol = context.Symbol, + Reflect = context.Reflect, Uint8Array = context.Uint8Array, clearTimeout = context.clearTimeout, enumerate = Reflect ? Reflect.enumerate : undefined, getPrototypeOf = Object.getPrototypeOf, - iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined, - parseFloat = context.parseFloat, - pow = Math.pow, + getOwnPropertySymbols = Object.getOwnPropertySymbols, + iteratorSymbol = typeof (iteratorSymbol = _Symbol && _Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined, propertyIsEnumerable = objectProto.propertyIsEnumerable, setTimeout = context.setTimeout, splice = arrayProto.splice; @@ -1353,6 +1295,7 @@ var nativeCeil = Math.ceil, nativeFloor = Math.floor, nativeIsFinite = context.isFinite, + nativeJoin = arrayProto.join, nativeKeys = Object.keys, nativeMax = Math.max, nativeMin = Math.min, @@ -1370,8 +1313,13 @@ var metaMap = WeakMap && new WeakMap; /** Used to detect maps and sets. */ - var mapCtorString = Map ? fnToString.call(Map) : '', - setCtorString = Set ? fnToString.call(Set) : ''; + var mapCtorString = Map ? funcToString.call(Map) : '', + setCtorString = Set ? funcToString.call(Set) : ''; + + /** Used to convert symbols to primitives and strings. */ + var symbolProto = _Symbol ? _Symbol.prototype : undefined, + symbolValueOf = _Symbol ? symbolProto.valueOf : undefined, + symbolToString = _Symbol ? symbolProto.toString : undefined; /** Used to lookup unminified function names. */ var realNames = {}; @@ -1389,13 +1337,16 @@ * Explicit chaining, which must be unwrapped with `_#value` in all cases, * may be enabled using `_.chain`. * - * The execution of chained methods is lazy, that is, execution is deferred - * until `_#value` is implicitly or explicitly called. + * 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 strategy which merge iteratee calls; this can help - * to avoid the creation of intermediate data structures and greatly reduce the - * number of iteratee executions. + * 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. @@ -1409,55 +1360,59 @@ * `replace` and `split` * * The wrapper methods that support shortcut fusion are: - * `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, `findLast`, - * `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, `tail`, - * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` + * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, + * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, + * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` * * The chainable wrapper methods are: - * `after`, `ary`, `assign`, `assignWith`, `at`, `before`, `bind`, `bindAll`, - * `bindKey`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, - * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, - * `delay`, `difference`, `differenceBy`, `drop`, `dropRight`, `dropRightWhile`, - * `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, `flatten`, `flattenDeep`, - * `flip`, `flow`, `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, - * `forOwn`, `forOwnRight`, `functions`, `groupBy`, `initial`, `intersection`, - * `intersectionBy`, `invert`, `invoke`, `iteratee`, `keyBy`, `keys`, `keysIn`, - * `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`, - * `merge`, `mergeWith` `method`, `methodOf`, `mixin`, `modArgs`, `modArgsSet', - * 'negate`, `omit`, `omitBy`, `once`, `pairs`, `partial`, `partialRight`, + * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, + * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`, + * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, + * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, + * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, + * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`, + * `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, + * `forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, + * `intersection`, `intersectionBy`, `intersectionWith`, invert`, `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`, `pullAt`, `push`, `range`, `rearg`, `reject`, - * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, - * `slice`, `sort`, `sortBy`, `sortByOrder`, `splice`, `spread`, `tail`, - * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, - * `thru`, `times`, `toArray`, `toPath`, `toPlainObject`, `transform`, `union`, - * `unionBy`, `uniq`, `uniqBy`, `unset`, `unshift`, `unzip`, `unzipWith`, - * `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `zip`, `zipObject`, - * and `zipWith` + * `pullAll`, `pullAllBy`, `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`, `values`, `valuesIn`, `without`, + * `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, and `zipWith` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`, - * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, - * `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`, `has`, `hasIn`, - * `head`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`, - * `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`, `isFunction`, - * `isInteger`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, - * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, - * `isSafeInteger`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, - * `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `min`, - * `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, - * `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, `runInContext`, - * `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, - * `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, `startsWith`, `sum`, - * `sumBy`, `template`, `toLower`, `toInteger`, `toSafeInteger`, `toString`, - * `toUpper`, `trim`, `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, + * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, + * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`, + * `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, + * `invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, + * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, + * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, + * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, + * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, + * `isString`, `isUndefined`, `isTypedArray`, `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`, + * `toLower`, `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`, + * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, * `upperCase`, `upperFirst`, `value`, and `words` * * @name _ * @constructor - * @category Chain + * @category Seq * @param {*} value The value to wrap in a `lodash` instance. * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -1766,13 +1721,24 @@ var index = -1, length = values ? values.length : 0; - this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash }; + this.clear(); while (++index < length) { var entry = values[index]; this.set(entry[0], entry[1]); } } + /** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ + function mapClear() { + this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash }; + } + /** * Removes `key` and its value from the map. * @@ -1866,23 +1832,22 @@ } /** - * Checks if `value` is in `cache` mimicking the return signature of - * `_.indexOf` by returning `0` if `value` is found, else `-1`. + * Checks if `value` is in `cache`. * * @private * @param {Object} cache The set cache to search. * @param {*} value The value to search for. - * @returns {number} Returns `0` if `value` is found, else `-1`. + * @returns {number} Returns `true` if `value` is found, else `false`. */ - function cacheIndexOf(cache, value) { + function cacheHas(cache, value) { var map = cache.__data__; if (isKeyable(value)) { var data = map.__data__, hash = typeof value == 'string' ? data.string : data.hash; - return hash[value] === HASH_UNDEFINED ? 0 : -1; + return hash[value] === HASH_UNDEFINED; } - return map.has(value) ? 0 : -1; + return map.has(value); } /** @@ -1918,13 +1883,24 @@ var index = -1, length = values ? values.length : 0; - this.__data__ = { 'array': [], 'map': null }; + this.clear(); while (++index < length) { var entry = values[index]; this.set(entry[0], entry[1]); } } + /** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ + function stackClear() { + this.__data__ = { 'array': [], 'map': null }; + } + /** * Removes `key` and its value from the stack. * @@ -2063,7 +2039,7 @@ function assocIndexOf(array, key) { var length = array.length; while (length--) { - if (array[length][0] === key) { + if (eq(array[length][0], key)) { return length; } } @@ -2089,6 +2065,58 @@ /*------------------------------------------------------------------------*/ + /** + * Used by `_.defaults` to customize its `_.assignIn` use. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. + * @returns {*} Returns the value to assign. + */ + function assignInDefaults(objValue, srcValue, key, object) { + if (objValue === undefined || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { + return srcValue; + } + return objValue; + } + + /** + * This function is like `assignValue` except that it doesn't assign `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || + (typeof key == 'number' && value === undefined && !(key in object))) { + object[key] = value; + } + } + + /** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignValue(object, key, value) { + var objValue = object[key]; + if ((!eq(objValue, value) || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) || + (value === undefined && !(key in object))) { + object[key] = value; + } + } + /** * The base implementation of `_.assign` without support for multiple sources * or `customizer` functions. @@ -2103,7 +2131,7 @@ } /** - * The base implementation of `_.at` without support for individual path arguments. + * The base implementation of `_.at` without support for individual paths. * * @private * @param {Object} object The object to iterate over. @@ -2122,6 +2150,27 @@ return result; } + /** + * The base implementation of `_.clamp` which doesn't coerce arguments to numbers. + * + * @private + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. + */ + function baseClamp(number, lower, upper) { + if (number === number) { + if (upper !== undefined) { + number = number <= upper ? number : upper; + } + if (lower !== undefined) { + number = number >= lower ? number : lower; + } + } + return number; + } + /** * The base implementation of `_.clone` and `_.cloneDeep` which tracks * traversed objects. @@ -2131,8 +2180,8 @@ * @param {boolean} [isDeep] Specify a deep clone. * @param {Function} [customizer] The function to customize cloning. * @param {string} [key] The key of `value`. - * @param {Object} [object] The object `value` belongs to. - * @param {Array} [stack] Tracks traversed sources and their clone counterparts. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. * @returns {*} Returns the cloned value. */ function baseClone(value, isDeep, customizer, key, object, stack) { @@ -2154,7 +2203,7 @@ } } else { var tag = getTag(value), - isFunc = tag == funcTag; + isFunc = tag == funcTag || tag == genTag; if (tag == objectTag || tag == argsTag || (isFunc && !object)) { if (isHostObject(value)) { @@ -2162,7 +2211,7 @@ } result = initCloneObject(isFunc ? {} : value); if (!isDeep) { - return baseAssign(result, value); + return copySymbols(value, baseAssign(result, value)); } } else { return cloneableTags[tag] @@ -2180,9 +2229,38 @@ // Recursively populate clone (susceptible to call stack limits). (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { - result[key] = baseClone(subValue, isDeep, customizer, key, value, stack); + assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack)); }); - return result; + return isArr ? result : copySymbols(value, result); + } + + /** + * The base implementation of `_.conforms` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new function. + */ + function baseConforms(source) { + var props = keys(source), + length = props.length; + + return function(object) { + if (object == null) { + return !length; + } + var index = length; + while (index--) { + var key = props[index], + predicate = source[key], + value = object[key]; + + if ((value === undefined && !(key in Object(object))) || !predicate(value)) { + return false; + } + } + return true; + }; } /** @@ -2223,31 +2301,19 @@ } /** - * The base implementation of `_.difference` without support for excluding - * multiple arrays of values. + * The base implementation of methods like `_.difference` without support for + * excluding multiple arrays or iteratee shorthands. * * @private * @param {Array} array The array to inspect. * @param {Array} values The values to exclude. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. * @returns {Array} Returns the new array of filtered values. */ - function baseDifference(array, values) { - return baseDifferenceBy(array, values); - } - - /** - * The base implementation of `_.differenceBy` without support for callback - * shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Array} values The values to exclude. - * @param {Function} [iteratee] The function invoked per element. - * @returns {Array} Returns the new array of filtered values. - */ - function baseDifferenceBy(array, values, iteratee) { + function baseDifference(array, values, iteratee, comparator) { var index = -1, - indexOf = baseIndexOf, + includes = arrayIncludes, isCommon = true, length = array.length, result = [], @@ -2257,10 +2323,14 @@ return result; } if (iteratee) { - values = arrayMap(values, function(value) { return iteratee(value); }); + values = arrayMap(values, baseUnary(iteratee)); } - if (values.length >= LARGE_ARRAY_SIZE) { - indexOf = cacheIndexOf; + if (comparator) { + includes = arrayIncludesWith; + isCommon = false; + } + else if (values.length >= LARGE_ARRAY_SIZE) { + includes = cacheHas; isCommon = false; values = new SetCache(values); } @@ -2278,7 +2348,7 @@ } result.push(value); } - else if (indexOf(values, computed, 0) < 0) { + else if (!includes(values, computed, comparator)) { result.push(value); } } @@ -2286,7 +2356,7 @@ } /** - * The base implementation of `_.forEach` without support for callback shorthands. + * The base implementation of `_.forEach` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -2296,7 +2366,7 @@ var baseEach = createBaseEach(baseForOwn); /** - * The base implementation of `_.forEachRight` without support for callback shorthands. + * The base implementation of `_.forEachRight` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -2306,7 +2376,7 @@ var baseEachRight = createBaseEach(baseForOwnRight, true); /** - * The base implementation of `_.every` without support for callback shorthands. + * The base implementation of `_.every` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -2335,7 +2405,7 @@ function baseFill(array, value, start, end) { var length = array.length; - start = start == null ? 0 : toInteger(start); + start = toInteger(start); if (start < 0) { start = -start > length ? 0 : (length + start); } @@ -2343,17 +2413,15 @@ if (end < 0) { end += length; } - length = start > end ? 0 : (end >>> 0); - start >>>= 0; - - while (start < length) { + end = start > end ? 0 : toLength(end); + while (start < end) { array[start++] = value; } return array; } /** - * The base implementation of `_.filter` without support for callback shorthands. + * The base implementation of `_.filter` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -2430,7 +2498,7 @@ var baseForRight = createBaseFor(true); /** - * The base implementation of `_.forIn` without support for callback shorthands. + * The base implementation of `_.forIn` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. @@ -2442,7 +2510,7 @@ } /** - * The base implementation of `_.forOwn` without support for callback shorthands. + * The base implementation of `_.forOwn` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. @@ -2454,7 +2522,7 @@ } /** - * The base implementation of `_.forOwnRight` without support for callback shorthands. + * The base implementation of `_.forOwnRight` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. @@ -2529,28 +2597,31 @@ } /** - * The base implementation of `_.intersection` that accepts an array of arrays - * to inspect. + * The base implementation of `_.inRange` which doesn't coerce arguments to numbers. * * @private - * @param {Array} arrays The arrays to inspect. - * @returns {Array} Returns the new array of shared values. + * @param {number} number The number to check. + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. */ - function baseIntersection(arrays) { - return baseIntersectionBy(arrays); + function baseInRange(number, start, end) { + return number >= nativeMin(start, end) && number < nativeMax(start, end); } /** - * The base implementation of `_.intersectionBy` without support for callback - * shorthands. + * The base implementation of methods like `_.intersection`, without support + * for iteratee shorthands, that accepts an array of arrays to inspect. * * @private * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The function invoked per element. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. * @returns {Array} Returns the new array of shared values. */ - function baseIntersectionBy(arrays, iteratee) { - var othLength = arrays.length, + function baseIntersection(arrays, iteratee, comparator) { + var includes = comparator ? arrayIncludesWith : arrayIncludes, + othLength = arrays.length, othIndex = othLength, caches = Array(othLength), result = []; @@ -2558,14 +2629,16 @@ while (othIndex--) { var array = arrays[othIndex]; if (othIndex && iteratee) { - array = arrayMap(array, function(value) { return iteratee(value); }); + array = arrayMap(array, baseUnary(iteratee)); } - caches[othIndex] = (iteratee || array.length >= 120) ? new SetCache(othIndex && array) : null; + caches[othIndex] = !comparator && (iteratee || array.length >= 120) + ? new SetCache(othIndex && array) + : undefined; } array = arrays[0]; var index = -1, - length = array ? array.length : 0, + length = array.length, seen = caches[0]; outer: @@ -2573,11 +2646,11 @@ var value = array[index], computed = iteratee ? iteratee(value) : value; - if ((seen ? cacheIndexOf(seen, computed) : baseIndexOf(result, computed, 0)) < 0) { + if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) { var othIndex = othLength; while (--othIndex) { var cache = caches[othIndex]; - if ((cache ? cacheIndexOf(cache, computed) : baseIndexOf(arrays[othIndex], computed, 0)) < 0) { + if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) { continue outer; } } @@ -2590,6 +2663,27 @@ return result; } + /** + * The base implementation of `_.invoke` without support for individual + * method arguments. + * + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + */ + function baseInvoke(object, path, args) { + if (!isKey(path, object)) { + path = baseToPath(path); + object = parent(object, path); + path = last(path); + } + var func = object == null ? object : object[path]; + return func == null ? undefined : apply(func, object, args); + } + /** * The base implementation of `_.isEqual` which supports partial comparisons * and tracks traversed objects. @@ -2602,7 +2696,7 @@ * The bitmask may be composed of the following flags: * 1 - Unordered comparison * 2 - Partial comparison - * @param {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, customizer, bitmask, stack) { @@ -2626,7 +2720,7 @@ * @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 {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { @@ -2670,23 +2764,12 @@ if (!isSameTag) { return false; } - // Assume cyclic values are equal. - // For more information on detecting circular references see https://es5.github.io/#JO. stack || (stack = new Stack); - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - stack.set(object, other); - - var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); - - stack['delete'](object); - return result; + return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); } /** - * The base implementation of `_.isMatch` without support for callback shorthands. + * The base implementation of `_.isMatch` without support for iteratee shorthands. * * @private * @param {Object} object The object to inspect. @@ -2797,7 +2880,7 @@ } /** - * The base implementation of `_.map` without support for callback shorthands. + * The base implementation of `_.map` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -2845,7 +2928,7 @@ * * @private * @param {string} path The path of the property to get. - * @param {*} srcValue The value to compare. + * @param {*} srcValue The value to match. * @returns {Function} Returns the new function. */ function baseMatchesProperty(path, srcValue) { @@ -2864,7 +2947,7 @@ * @param {Object} object The destination object. * @param {Object} source The source object. * @param {Function} [customizer] The function to customize merged values. - * @param {Array} [stack] Tracks traversed sources and their value counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged counterparts. */ function baseMerge(object, source, customizer, stack) { if (object === source) { @@ -2901,31 +2984,31 @@ * @param {string} key The key of the value to merge. * @param {Function} mergeFunc The function to merge values. * @param {Function} [customizer] The function to customize assigned values. - * @param {Array} [stack] Tracks traversed sources and their value counterparts. + * @param {Object} [stack] Tracks traversed source values and their merged counterparts. */ function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) { - var oldValue = object[key], + var objValue = object[key], srcValue = source[key], - stacked = stack.get(oldValue) || stack.get(srcValue); + stacked = stack.get(srcValue) || stack.get(objValue); if (stacked) { assignMergeValue(object, key, stacked); return; } - var newValue = customizer ? customizer(oldValue, srcValue, (key + ''), object, source, stack) : undefined, + var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined, isCommon = newValue === undefined; if (isCommon) { newValue = srcValue; if (isArray(srcValue) || isTypedArray(srcValue)) { - newValue = isArray(oldValue) - ? oldValue - : ((isArrayLikeObject(oldValue)) ? copyArray(oldValue) : baseClone(srcValue)); + newValue = isArray(objValue) + ? objValue + : ((isArrayLikeObject(objValue)) ? copyArray(objValue) : baseClone(srcValue)); } else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = isArguments(oldValue) - ? toPlainObject(oldValue) - : (isObject(oldValue) ? oldValue : baseClone(srcValue)); + newValue = isArguments(objValue) + ? toPlainObject(objValue) + : (isObject(objValue) ? objValue : baseClone(srcValue)); } else { isCommon = isFunction(srcValue); @@ -2940,6 +3023,35 @@ assignMergeValue(object, key, newValue); } + /** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ + function baseOrderBy(collection, iteratees, orders) { + var index = -1, + toIteratee = getIteratee(); + + iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) { + return toIteratee(iteratee); + }); + + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + /** * The base implementation of `_.pick` without support for individual * property names. @@ -2960,7 +3072,7 @@ } /** - * The base implementation of `_.pickBy` without support for callback shorthands. + * The base implementation of `_.pickBy` without support for iteratee shorthands. * * @private * @param {Object} object The source object. @@ -3016,13 +3128,13 @@ } /** - * The base implementation of `_.pullAllBy` without support for callback + * The base implementation of `_.pullAllBy` without support for iteratee * shorthands. * * @private * @param {Array} array The array to modify. * @param {Array} values The values to remove. - * @param {Function} [iteratee] The function invoked per element. + * @param {Function} [iteratee] The iteratee invoked per element. * @returns {Array} Returns `array`. */ function basePullAllBy(array, values, iteratee) { @@ -3050,7 +3162,7 @@ /** * The base implementation of `_.pullAt` without support for individual - * index arguments or capturing the removed elements. + * indexes or capturing the removed elements. * * @private * @param {Array} array The array to modify. @@ -3089,12 +3201,35 @@ * floating-point numbers. * * @private - * @param {number} min The minimum possible value. - * @param {number} max The maximum possible value. + * @param {number} lower The lower bound. + * @param {number} upper The upper bound. * @returns {number} Returns the random number. */ - function baseRandom(min, max) { - return min + nativeFloor(nativeRandom() * (max - min + 1)); + function baseRandom(lower, upper) { + return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); + } + + /** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments to numbers. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the new array of numbers. + */ + function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[fromRight ? length : ++index] = start; + start += step; + } + return result; } /** @@ -3120,10 +3255,10 @@ if (isObject(nested)) { var newValue = value; if (index != lastIndex) { - var oldValue = nested[key]; - newValue = customizer ? customizer(oldValue, key, nested) : undefined; + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; if (newValue === undefined) { - newValue = oldValue == null ? (isIndex(path[index + 1]) ? [] : {}) : oldValue; + newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue; } } assignValue(nested, key, newValue); @@ -3159,11 +3294,10 @@ var index = -1, length = array.length; - start = start == null ? 0 : toInteger(start); if (start < 0) { start = -start > length ? 0 : (length + start); } - end = (end === undefined || end > length) ? length : toInteger(end); + end = end > length ? length : end; if (end < 0) { end += length; } @@ -3178,7 +3312,7 @@ } /** - * The base implementation of `_.some` without support for callback shorthands. + * The base implementation of `_.some` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. @@ -3196,239 +3330,8 @@ } /** - * The base implementation of `_.sortByOrder` without param guards. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {string[]} orders The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. - */ - function baseSortByOrder(collection, iteratees, orders) { - var toIteratee = getIteratee(), - index = -1; - - iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) { - return toIteratee(iteratee); - }); - - var result = baseMap(collection, function(value, key, collection) { - var criteria = arrayMap(iteratees, function(iteratee) { - return iteratee(value); - }); - return { 'criteria': criteria, 'index': ++index, 'value': value }; - }); - - return baseSortBy(result, function(object, other) { - return compareMultiple(object, other, orders); - }); - } - - /** - * The base implementation of `_.sortedUniq`. - * - * @private - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - */ - function baseSortedUniq(array) { - return baseSortedUniqBy(array); - } - - /** - * The base implementation of `_.sortedUniqBy` without support for callback - * shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The function invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ - function baseSortedUniqBy(array, iteratee) { - var index = 0, - length = array.length, - value = array[0], - computed = iteratee ? iteratee(value) : value, - seen = computed, - resIndex = 0, - result = [value]; - - while (++index < length) { - value = array[index], - computed = iteratee ? iteratee(value) : value; - - if ((seen === seen ? (seen !== computed) : (computed === computed))) { - seen = computed; - result[++resIndex] = value; - } - } - return result; - } - - /** - * The base implementation of `_.toPath` which only converts `value` to a - * path if it's not one. - * - * @private - * @param {*} value The value to process. - * @returns {Array} Returns the property path array. - */ - function baseToPath(value) { - return isArray(value) ? value : stringToPath(value); - } - - /** - * The base implementation of `_.uniq`. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The function invoked per iteration. - * @returns {Array} Returns the new duplicate free array. - */ - function baseUniq(array) { - return baseUniqBy(array); - } - - /** - * The base implementation of `_.uniqBy` without support for callback shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The function invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ - function baseUniqBy(array, iteratee) { - var index = -1, - indexOf = baseIndexOf, - length = array.length, - isCommon = true, - seen = length >= LARGE_ARRAY_SIZE ? new SetCache : null, - result = []; - - if (seen) { - indexOf = cacheIndexOf; - isCommon = false; - } else { - seen = iteratee ? [] : result; - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; - - if (isCommon && computed === computed) { - var seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed) { - continue outer; - } - } - if (iteratee) { - seen.push(computed); - } - result.push(value); - } - else if (indexOf(seen, computed, 0) < 0) { - if (seen !== result) { - seen.push(computed); - } - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.unset`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. - */ - function baseUnset(object, path) { - path = isKey(path, object) ? [path + ''] : baseToPath(path); - object = parent(object, path); - var key = last(path); - return (object != null && has(object, key)) ? delete object[key] : true; - } - - /** - * The base implementation of methods like `_.dropWhile` and `_.takeWhile` - * without support for callback shorthands. - * - * @private - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [isDrop] Specify dropping elements instead of taking them. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the slice of `array`. - */ - function baseWhile(array, predicate, isDrop, fromRight) { - var length = array.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length) && - predicate(array[index], index, array)) {} - - return isDrop - ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) - : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); - } - - /** - * The base implementation of `wrapperValue` which returns the result of - * performing a sequence of actions on the unwrapped `value`, where each - * successive action is supplied the return value of the previous. - * - * @private - * @param {*} value The unwrapped value. - * @param {Array} actions Actions to peform to resolve the unwrapped value. - * @returns {*} Returns the resolved value. - */ - function baseWrapperValue(value, actions) { - var result = value; - if (result instanceof LazyWrapper) { - result = result.value(); - } - return arrayReduce(actions, function(result, action) { - return action.func.apply(action.thisArg, arrayPush([result], action.args)); - }, result); - } - - /** - * The base implementation of `_.xor` that accepts an array of arrays to inspect. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @returns {Array} Returns the new array of values. - */ - function baseXor(arrays) { - return baseXorBy(arrays); - } - - /** - * The base implementation of `_.xorBy` without support for callback shorthands. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The function invoked per element. - * @returns {Array} Returns the new array of values. - */ - function baseXorBy(arrays, iteratee) { - var index = -1, - length = arrays.length; - - while (++index < length) { - var result = result - ? arrayPush(baseDifferenceBy(result, arrays[index], iteratee), baseDifferenceBy(arrays[index], result, iteratee)) - : arrays[index]; - } - return (result && result.length) ? baseUniqBy(result, iteratee) : []; - } - - /** - * Performs a binary search of `array` to determine the index at which `value` + * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which + * performs a binary search of `array` to determine the index at which `value` * should be inserted into `array` in order to maintain its sort order. * * @private @@ -3438,7 +3341,7 @@ * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ - function binaryIndex(array, value, retHighest) { + function baseSortedIndex(array, value, retHighest) { var low = 0, high = array ? array.length : low; @@ -3455,22 +3358,22 @@ } return high; } - return binaryIndexBy(array, value, identity, retHighest); + return baseSortedIndexBy(array, value, identity, retHighest); } /** - * This function is like `binaryIndex` except that it invokes `iteratee` for - * `value` and each element of `array` to compute their sort ranking. The - * iteratee is invoked with one argument; (value). + * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` + * which invokes `iteratee` for `value` and each element of `array` to compute + * their sort ranking. The iteratee is invoked with one argument; (value). * * @private * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {Function} iteratee The function invoked per element. + * @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`. */ - function binaryIndexBy(array, value, iteratee, retHighest) { + function baseSortedIndexBy(array, value, iteratee, retHighest) { value = iteratee(value); var low = 0, @@ -3505,6 +3408,202 @@ return nativeMin(high, MAX_ARRAY_INDEX); } + /** + * The base implementation of `_.sortedUniq`. + * + * @private + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. + */ + function baseSortedUniq(array) { + return baseSortedUniqBy(array); + } + + /** + * The base implementation of `_.sortedUniqBy` without support for iteratee + * shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseSortedUniqBy(array, iteratee) { + var index = 0, + length = array.length, + value = array[0], + computed = iteratee ? iteratee(value) : value, + seen = computed, + resIndex = 0, + result = [value]; + + while (++index < length) { + value = array[index], + computed = iteratee ? iteratee(value) : value; + + if (!eq(computed, seen)) { + seen = computed; + result[++resIndex] = value; + } + } + return result; + } + + /** + * The base implementation of `_.toPath` which only converts `value` to a + * path if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Array} Returns the property path array. + */ + function baseToPath(value) { + return isArray(value) ? value : stringToPath(value); + } + + /** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; + + if (comparator) { + isCommon = false; + includes = arrayIncludesWith; + } + else if (length >= LARGE_ARRAY_SIZE) { + var set = iteratee ? null : createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = iteratee ? [] : result; + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.unset`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. + */ + function baseUnset(object, path) { + path = isKey(path, object) ? [path + ''] : baseToPath(path); + object = parent(object, path); + var key = last(path); + return (object != null && has(object, key)) ? delete object[key] : true; + } + + /** + * The base implementation of methods like `_.dropWhile` and `_.takeWhile` + * without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. + */ + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length) && + predicate(array[index], index, array)) {} + + return isDrop + ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) + : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); + } + + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to perform to resolve the unwrapped value. + * @returns {*} Returns the resolved value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + return arrayReduce(actions, function(result, action) { + return action.func.apply(action.thisArg, arrayPush([result], action.args)); + }, result); + } + + /** + * The base implementation of methods like `_.xor`, without support for + * iteratee shorthands, that accepts an array of arrays to inspect. + * + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of values. + */ + function baseXor(arrays, iteratee, comparator) { + var index = -1, + length = arrays.length; + + while (++index < length) { + var result = result + ? arrayPush( + baseDifference(result, arrays[index], iteratee, comparator), + baseDifference(arrays[index], result, iteratee, comparator) + ) + : arrays[index]; + } + return (result && result.length) ? baseUniq(result, iteratee, comparator) : []; + } + /** * Creates a clone of `buffer`. * @@ -3560,6 +3659,17 @@ return arrayReduce(setToArray(set), addSetEntry, new Ctor); } + /** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ + function cloneSymbol(symbol) { + return _Symbol ? Object(symbolValueOf.call(symbol)) : {}; + } + /** * Creates a clone of `typedArray`. * @@ -3637,6 +3747,76 @@ return result; } + /** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property names to copy. + * @param {Object} [object={}] The object to copy properties to. + * @returns {Object} Returns `object`. + */ + function copyObject(source, props, object) { + return copyObjectWith(source, props, object); + } + + /** + * This function is like `copyObject` except that it accepts a function to + * customize copied values. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property names to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ + function copyObjectWith(source, props, object, customizer) { + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index], + newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key]; + + assignValue(object, key, newValue); + } + return object; + } + + /** + * Copies own symbol properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); + } + /** * Creates a function like `_.groupBy`. * @@ -3677,7 +3857,7 @@ function createAssigner(assigner) { return rest(function(object, sources) { var index = -1, - length = object == null ? 0 : sources.length, + length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined; @@ -3735,13 +3915,13 @@ */ function createBaseFor(fromRight) { return function(object, iteratee, keysFunc) { - var iterable = Object(object), + var index = -1, + iterable = Object(object), props = keysFunc(object), - length = props.length, - index = fromRight ? length : -1; + length = props.length; - while ((fromRight ? index-- : ++index < length)) { - var key = props[index]; + while (length--) { + var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } @@ -3751,20 +3931,22 @@ } /** - * Creates a function that wraps `func` and invokes it with the `this` + * Creates a function that wraps `func` to invoke it with the optional `this` * binding of `thisArg`. * * @private - * @param {Function} func The function to bind. + * @param {Function} func The function to wrap. + * @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 bound function. + * @returns {Function} Returns the new wrapped function. */ - function createBindWrapper(func, thisArg) { - var Ctor = createCtorWrapper(func); + function createBaseWrapper(func, bitmask, thisArg) { + var isBind = bitmask & BIND_FLAG, + Ctor = createCtorWrapper(func); function wrapper() { var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return fn.apply(thisArg, arguments); + return fn.apply(isBind ? thisArg : this, arguments); } return wrapper; } @@ -3834,6 +4016,40 @@ }; } + /** + * Creates a function that wraps `func` to enable currying. + * + * @private + * @param {Function} func The function to wrap. + * @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. + */ + function createCurryWrapper(func, bitmask, arity) { + var Ctor = createCtorWrapper(func); + + function wrapper() { + var length = arguments.length, + index = length, + args = Array(length), + fn = (this && this !== root && this instanceof wrapper) ? Ctor : func, + placeholder = wrapper.placeholder; + + while (index--) { + args[index] = arguments[index]; + } + var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) + ? [] + : replaceHolders(args, placeholder); + + length -= holders.length; + return length < arity + ? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length) + : apply(fn, this, args); + } + return wrapper; + } + /** * Creates a `_.flow` or `_.flowRight` function. * @@ -3842,23 +4058,26 @@ * @returns {Function} Returns the new flow function. */ function createFlow(fromRight) { - return function() { - var wrapper, - length = arguments.length, - index = fromRight ? length : -1, - leftIndex = 0, - funcs = Array(length); + return rest(function(funcs) { + funcs = baseFlatten(funcs); - while ((fromRight ? index-- : ++index < length)) { - var func = funcs[leftIndex++] = arguments[index]; + var length = funcs.length, + index = length, + prereq = LodashWrapper.prototype.thru; + + if (fromRight) { + funcs.reverse(); + } + while (index--) { + var func = funcs[index]; if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') { - wrapper = new LodashWrapper([], true); + if (prereq && !wrapper && getFuncName(func) == 'wrapper') { + var wrapper = new LodashWrapper([], true); } } - index = wrapper ? -1 : length; + index = wrapper ? index : length; while (++index < length) { func = funcs[index]; @@ -3886,15 +4105,15 @@ } return result; }; - }; + }); } /** - * Creates a function that wraps `func` and invokes it with optional `this` - * binding of, partial application, and currying. + * Creates a function that wraps `func` to invoke it with optional `this` + * binding of `thisArg`, partial application, and currying. * * @private - * @param {Function|string} func The function or method name to reference. + * @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 {*} [thisArg] The `this` binding of `func`. * @param {Array} [partials] The arguments to prepend to those provided to the new function. @@ -3911,14 +4130,11 @@ isBind = bitmask & BIND_FLAG, isBindKey = bitmask & BIND_KEY_FLAG, isCurry = bitmask & CURRY_FLAG, - isCurryBound = bitmask & CURRY_BOUND_FLAG, isCurryRight = bitmask & CURRY_RIGHT_FLAG, isFlip = bitmask & FLIP_FLAG, Ctor = isBindKey ? undefined : createCtorWrapper(func); function wrapper() { - // Avoid `arguments` object use disqualifying optimizations by - // converting it to an array before providing it to other functions. var length = arguments.length, index = length, args = Array(length); @@ -3938,27 +4154,7 @@ length -= argsHolders.length; if (length < arity) { - var newArgPos = argPos ? copyArray(argPos) : undefined, - newArity = nativeMax(arity - length, 0), - newsHolders = isCurry ? argsHolders : undefined, - newHoldersRight = isCurry ? undefined : argsHolders, - newPartials = isCurry ? args : undefined, - newPartialsRight = isCurry ? undefined : args; - - bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); - bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); - - if (!isCurryBound) { - bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); - } - var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity], - result = createHybridWrapper.apply(undefined, newData); - - if (isLaziable(func)) { - setData(result, newData); - } - result.placeholder = placeholder; - return result; + return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length); } } var thisBinding = isBind ? thisArg : this, @@ -3973,7 +4169,7 @@ args.length = ary; } if (this && this !== root && this instanceof wrapper) { - fn = Ctor || createCtorWrapper(func); + fn = Ctor || createCtorWrapper(fn); } return fn.apply(thisBinding, args); } @@ -3981,53 +4177,27 @@ } /** - * Creates a function like `_.conj`. + * Creates a function like `_.over`. * * @private * @param {Function} arrayFunc The function to iterate over iteratees. * @returns {Function} Returns the new invoker function. */ - function createInvoker(arrayFunc) { + function createOver(arrayFunc) { return rest(function(iteratees) { iteratees = arrayMap(baseFlatten(iteratees), getIteratee()); return rest(function(args) { var thisArg = this; return arrayFunc(iteratees, function(iteratee) { - return iteratee.apply(thisArg, args); + return apply(iteratee, thisArg, args); }); }); }); } /** - * Creates a function like `_.modArgs`. - * - * @private - * @param {Function} resolver The function to resolve which invocation - * arguments are provided to each transform. - * @returns {Function} Returns the new arguments modifier function. - */ - function createModArgs(resolver) { - return rest(function(func, transforms) { - transforms = arrayMap(baseFlatten(transforms), getIteratee()); - - var funcsLength = transforms.length; - return rest(function(args) { - var index = -1, - length = nativeMin(args.length, funcsLength), - modded = copyArray(args); - - while (++index < length) { - modded[index] = transforms[index].apply(this, resolver(args[index], index, args)); - } - return func.apply(this, modded); - }); - }); - } - - /** - * Creates the padding for `string` based on the given `length`. The `chars` - * string is truncated if the number of characters exceeds `length`. + * Creates the padding for `string` based on `length`. The `chars` string + * is truncated if the number of characters exceeds `length`. * * @private * @param {string} string The string to create padding for. @@ -4052,29 +4222,28 @@ } /** - * Creates a function that wraps `func` and invokes it with the optional `this` + * Creates a function that wraps `func` to invoke it with the optional `this` * binding of `thisArg` and the `partials` prepended to those provided to * the wrapper. * * @private - * @param {Function} func The function to partially apply arguments to. + * @param {Function} func The function to wrap. * @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. - * @returns {Function} Returns the new bound function. + * @returns {Function} Returns the new wrapped function. */ function createPartialWrapper(func, bitmask, thisArg, partials) { var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); function wrapper() { - // Avoid `arguments` object use disqualifying optimizations by - // converting it to an array before providing it `func`. var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, - args = Array(leftLength + argsLength); + args = Array(leftLength + argsLength), + fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; while (++leftIndex < leftLength) { args[leftIndex] = partials[leftIndex]; @@ -4082,12 +4251,77 @@ while (argsLength--) { args[leftIndex++] = arguments[++argsIndex]; } - var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return fn.apply(isBind ? thisArg : this, args); + return apply(fn, isBind ? thisArg : this, args); } return wrapper; } + /** + * Creates a `_.range` or `_.rangeRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. + */ + function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toNumber(start); + start = start === start ? start : 0; + if (end === undefined) { + end = start; + start = 0; + } else { + end = toNumber(end) || 0; + } + step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0); + return baseRange(start, end, step, fromRight); + }; + } + + /** + * Creates a function that wraps `func` to continue currying. + * + * @private + * @param {Function} func The function to wrap. + * @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 to replace. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { + var isCurry = bitmask & CURRY_FLAG, + newArgPos = argPos ? copyArray(argPos) : undefined, + newsHolders = isCurry ? holders : undefined, + newHoldersRight = isCurry ? undefined : holders, + newPartials = isCurry ? partials : undefined, + newPartialsRight = isCurry ? undefined : partials; + + bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + + if (!(bitmask & CURRY_BOUND_FLAG)) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity], + result = wrapFunc.apply(undefined, newData); + + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return result; + } + /** * Creates a function like `_.round`. * @@ -4098,26 +4332,38 @@ function createRound(methodName) { var func = Math[methodName]; return function(number, precision) { - precision = precision ? toInteger(precision) : 0; + number = toNumber(number); + precision = toInteger(precision); if (precision) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details. - var pair = (+number + 'e').split('e'), + var pair = (toString(number) + 'e').split('e'), value = func(pair[0] + 'e' + (+pair[1] + precision)); - pair = (value + 'e').split('e'); - return +(pair[0] + 'e' + (pair[1] - precision)); + pair = (toString(value) + 'e').split('e'); + return +(pair[0] + 'e' + (+pair[1] - precision)); } return func(number); }; } + /** + * Creates a set of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ + var createSet = !(Set && new Set([1, 2]).size === 2) ? noop : function(values) { + return new Set(values); + }; + /** * Creates a function that either curries or invokes `func` with optional * `this` binding and partially applied arguments. * * @private - * @param {Function|string} func The function or method name to reference. + * @param {Function|string} func The function or method name to wrap. * @param {number} bitmask The bitmask of wrapper flags. * The bitmask may be composed of the following flags: * 1 - `_.bind` @@ -4147,32 +4393,40 @@ bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); partials = holders = undefined; } + ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); + arity = arity === undefined ? arity : toInteger(arity); length -= holders ? holders.length : 0; + if (bitmask & PARTIAL_RIGHT_FLAG) { var partialsRight = partials, holdersRight = holders; partials = holders = undefined; } - ary = ary == null ? ary : nativeMax(toInteger(ary), 0); - arity = arity == null ? arity : toInteger(arity); - var data = isBindKey ? undefined : getData(func), newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; if (data) { mergeData(newData, data); - bitmask = newData[1]; - arity = newData[9]; } - newData[9] = arity == null + func = newData[0]; + bitmask = newData[1]; + thisArg = newData[2]; + partials = newData[3]; + holders = newData[4]; + arity = newData[9] = newData[9] == null ? (isBindKey ? 0 : func.length) - : nativeMax(arity - length, 0); + : nativeMax(newData[9] - length, 0); - if (bitmask == BIND_FLAG) { - var result = createBindWrapper(newData[0], newData[2]); - } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { - result = createPartialWrapper.apply(undefined, newData); + if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) { + bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG); + } + if (!bitmask || bitmask == BIND_FLAG) { + var result = createBaseWrapper(func, bitmask, thisArg); + } else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) { + result = createCurryWrapper(func, bitmask, arity); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) { + result = createPartialWrapper(func, bitmask, thisArg, partials); } else { result = createHybridWrapper.apply(undefined, newData); } @@ -4190,7 +4444,7 @@ * @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 {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { @@ -4203,34 +4457,46 @@ if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked) { + return stacked == other; + } + var result = true; + stack.set(array, other); + // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; if (customizer) { - var result = isPartial + var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); } - if (result !== undefined) { - if (result) { + if (compared !== undefined) { + if (compared) { continue; } - return false; + result = false; + break; } // 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 false; + result = false; + break; } } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { - return false; + result = false; + break; } } - return true; + stack['delete'](array); + return result; } /** @@ -4251,6 +4517,13 @@ */ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) { switch (tag) { + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + case boolTag: case dateTag: // Coerce dates and booleans to numbers, dates to milliseconds and booleans @@ -4280,6 +4553,9 @@ // Recursively compare objects (susceptible to call stack limits). return (isPartial || object.size == other.size) && equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG); + + case symbolTag: + return !!_Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other)); } return false; } @@ -4294,7 +4570,7 @@ * @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 {Array} [stack] Tracks traversed `value` and `other` objects. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { @@ -4316,6 +4592,14 @@ return false; } } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + var result = true; + stack.set(object, other); + var skipCtor = isPartial; while (++index < objLength) { key = objProps[index]; @@ -4323,20 +4607,21 @@ othValue = other[key]; if (customizer) { - var result = isPartial + var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); } // Recursively compare objects (susceptible to call stack limits). - if (!(result === undefined + if (!(compared === undefined ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack)) - : result + : compared )) { - return false; + result = false; + break; } skipCtor || (skipCtor = key == 'constructor'); } - if (!skipCtor) { + if (result && !skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; @@ -4345,10 +4630,11 @@ ('constructor' in object && 'constructor' in other) && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { - return false; + result = false; } } - return true; + stack['delete'](object); + return result; } /** @@ -4421,7 +4707,7 @@ * @returns {Array} Returns the match data of `object`. */ function getMatchData(object) { - var result = pairs(object), + var result = toPairs(object), length = result.length; while (length--) { @@ -4443,6 +4729,17 @@ return isNative(value) ? value : undefined; } + /** + * Creates an array of the own symbol properties of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbols = getOwnPropertySymbols || function() { + return []; + }; + /** * Gets the `toStringTag` of `value`. * @@ -4451,19 +4748,25 @@ * @returns {string} Returns the `toStringTag`. */ function getTag(value) { - return objToString.call(value); + return objectToString.call(value); } // Fallback for IE 11 providing `toStringTag` values for maps and sets. if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag)) { getTag = function(value) { - var result = objToString.call(value), + var result = objectToString.call(value), Ctor = result == objectTag ? value.constructor : null, - ctorString = typeof Ctor == 'function' ? fnToString.call(Ctor) : ''; + ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : ''; - return ctorString == mapCtorString - ? mapTag - : (ctorString == setCtorString ? setTag : result); + if (ctorString) { + if (ctorString == mapCtorString) { + return mapTag; + } + if (ctorString == setCtorString) { + return setTag; + } + } + return result; }; } @@ -4530,9 +4833,9 @@ */ function initCloneArray(array) { var length = array.length, - result = new array.constructor(length); + result = array.constructor(length); - // Add array properties assigned by `RegExp#exec`. + // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; @@ -4549,7 +4852,7 @@ */ function initCloneObject(object) { var Ctor = object.constructor; - return (typeof Ctor == 'function' && Ctor instanceof Ctor) ? new Ctor : {}; + return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); } /** @@ -4586,48 +4889,30 @@ case stringTag: return new Ctor(object); + case regexpTag: + return cloneRegExp(object); + case setTag: return cloneSet(object); - case regexpTag: - return cloneRegExp(object); + case symbolTag: + return cloneSymbol(object); } } /** - * Initializes an array of property names based on `object`. If `object` is - * an array, `arguments` object, or `string` its index keys are returned, - * otherwise an empty array is returned. + * Creates an array of index keys for `object` values of arrays, + * `arguments` objects, and strings, otherwise `null` is returned. * * @private * @param {Object} object The object to query. - * @returns {Array} Returns the initialized array of property names. + * @returns {Array|null} Returns index keys, else `null`. */ - function initKeys(object) { - var length = object ? object.length : 0; - length = (length && isLength(length) && - (isArray(object) || isString(object) || isArguments(object)) && length) || 0; - - return baseTimes(length, String); - } - - /** - * Invokes the method at `path` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {Array} args The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - */ - function invokePath(object, path, args) { - if (!isKey(path, object)) { - path = baseToPath(path); - object = parent(object, path); - path = last(path); - } - var func = object == null ? object : object[path]; - return func == null ? undefined : func.apply(object, args); + function indexKeys(object) { + var length = object ? object.length : undefined; + return (isLength(length) && (isArray(object) || isString(object) || isArguments(object))) + ? baseTimes(length, String) + : null; } /** @@ -4647,8 +4932,7 @@ if (type == 'number' ? (isArrayLike(object) && isIndex(index, object.length)) : (type == 'string' && index in object)) { - var other = object[index]; - return value === value ? (value === other) : (other !== other); + return eq(object[index], value); } return false; } @@ -4738,7 +5022,7 @@ * 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 - * common case where curried functions have `_.ary` and or `_.rearg` applied. + * combined case where curried functions have `_.ary` and or `_.rearg` applied. * * @private * @param {Array} data The destination metadata. @@ -4749,7 +5033,7 @@ var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, - isCommon = newBitmask < ARY_FLAG; + isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG); var isCombo = (srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) || @@ -4804,12 +5088,16 @@ * Used by `_.defaultsDeep` to customize its `_.merge` use. * * @private - * @param {*} objValue The destination object property value. - * @param {*} srcValue The source object property value. - * @returns {*} Returns the value to assign to the destination object. + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @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. + * @returns {*} Returns the value to assign. */ function mergeDefaults(objValue, srcValue, key, object, source, stack) { - if (isObject(objValue)) { + if (isObject(objValue) && isObject(srcValue)) { stack.set(srcValue, objValue); baseMerge(objValue, srcValue, mergeDefaults, stack); } @@ -4942,7 +5230,7 @@ /** * Creates an array of elements split into groups the length of `size`. - * If `collection` can't be split evenly, the final chunk will be the remaining + * If `array` can't be split evenly, the final chunk will be the remaining * elements. * * @static @@ -5005,6 +5293,32 @@ return result; } + /** + * Creates a new array concatenating `array` with any additional arrays + * and/or values. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to concatenate. + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. + * @example + * + * var array = [1]; + * var other = _.concat(array, 2, [3], [[4]]); + * + * console.log(other); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] + */ + var concat = rest(function(array, values) { + values = baseFlatten(values); + return arrayConcat(isArray(array) ? array : [Object(array)], values); + }); + /** * Creates an array of unique `array` values not included in the other * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -5037,14 +5351,14 @@ * @category Array * @param {Array} array The array to inspect. * @param {...Array} [values] The values to exclude. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Array} Returns the new array of filtered values. * @example * * _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor); * // => [3.1, 1.3] * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); * // => [{ 'x': 2 }] */ @@ -5054,7 +5368,36 @@ iteratee = undefined; } return isArrayLikeObject(array) - ? baseDifferenceBy(array, baseFlatten(values, false, true), getIteratee(iteratee)) + ? baseDifference(array, baseFlatten(values, false, true), getIteratee(iteratee)) + : []; + }); + + /** + * This method is like `_.difference` except that it accepts `comparator` + * which is invoked to compare elements of `array` to `values`. The comparator + * is invoked with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * + * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); + * // => [{ 'x': 2, 'y': 1 }] + */ + var differenceWith = rest(function(array, values) { + var comparator = last(values); + if (isArrayLikeObject(comparator)) { + comparator = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, false, true), undefined, comparator) : []; }); @@ -5083,11 +5426,12 @@ * // => [1, 2, 3] */ function drop(array, n, guard) { - if (!(array && array.length)) { + var length = array ? array.length : 0; + if (!length) { return []; } - n = (guard || n === undefined) ? 1 : n; - return baseSlice(array, n < 0 ? 0 : n); + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, n < 0 ? 0 : n, length); } /** @@ -5137,28 +5481,26 @@ * @returns {Array} Returns the slice of `array`. * @example * - * var resolve = _.partial(_.map, _, 'user'); - * * var users = [ * { 'user': 'barney', 'active': true }, * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': false } * ]; * - * resolve( _.dropRightWhile(users, function(o) { return !o.active; }) ); - * // => ['barney'] + * _.dropRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney'] * - * // using the `_.matches` callback shorthand - * resolve( _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }) ); - * // => ['barney', 'fred'] + * // using the `_.matches` iteratee shorthand + * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['barney', 'fred'] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.dropRightWhile(users, ['active', false]) ); - * // => ['barney'] + * // using the `_.matchesProperty` iteratee shorthand + * _.dropRightWhile(users, ['active', false]); + * // => objects for ['barney'] * - * // using the `_.property` callback shorthand - * resolve( _.dropRightWhile(users, 'active') ); - * // => ['barney', 'fred', 'pebbles'] + * // using the `_.property` iteratee shorthand + * _.dropRightWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] */ function dropRightWhile(array, predicate) { return (array && array.length) @@ -5179,28 +5521,26 @@ * @returns {Array} Returns the slice of `array`. * @example * - * var resolve = _.partial(_.map, _, 'user'); - * * var users = [ * { 'user': 'barney', 'active': false }, * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': true } * ]; * - * resolve( _.dropWhile(users, function(o) { return !o.active; }) ); - * // => ['pebbles'] + * _.dropWhile(users, function(o) { return !o.active; }); + * // => objects for ['pebbles'] * - * // using the `_.matches` callback shorthand - * resolve( _.dropWhile(users, { 'user': 'barney', 'active': false }) ); - * // => ['fred', 'pebbles'] + * // using the `_.matches` iteratee shorthand + * _.dropWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['fred', 'pebbles'] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.dropWhile(users, ['active', false]) ); - * // => ['pebbles'] + * // using the `_.matchesProperty` iteratee shorthand + * _.dropWhile(users, ['active', false]); + * // => objects for ['pebbles'] * - * // using the `_.property` callback shorthand - * resolve( _.dropWhile(users, 'active') ); - * // => ['barney', 'fred', 'pebbles'] + * // using the `_.property` iteratee shorthand + * _.dropWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] */ function dropWhile(array, predicate) { return (array && array.length) @@ -5269,15 +5609,15 @@ * _.findIndex(users, function(o) { return o.user == 'barney'; }); * // => 0 * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.findIndex(users, { 'user': 'fred', 'active': false }); * // => 1 * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.findIndex(users, ['active', false]); * // => 0 * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.findIndex(users, 'active'); * // => 2 */ @@ -5308,15 +5648,15 @@ * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); * // => 2 * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.findLastIndex(users, { 'user': 'barney', 'active': true }); * // => 0 * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.findLastIndex(users, ['active', false]); * // => 2 * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.findLastIndex(users, 'active'); * // => 0 */ @@ -5326,6 +5666,31 @@ : -1; } + /** + * Creates an array of flattened values by running each element in `array` + * through `iteratee` and concating its result to the other mapped values. + * The iteratee is invoked with three arguments: (value, index|key, array). + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new array. + * @example + * + * function duplicate(n) { + * return [n, n]; + * } + * + * _.flatMap([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ + function flatMap(array, iteratee) { + var length = array ? array.length : 0; + return length ? baseFlatten(arrayMap(array, getIteratee(iteratee, 3))) : []; + } + /** * Flattens `array` a single level. * @@ -5362,6 +5727,32 @@ return length ? baseFlatten(array, true) : []; } + /** + * The inverse of `_.toPairs`; this method returns an object composed + * from key-value `pairs`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} pairs The key-value pairs. + * @returns {Object} Returns the new object. + * @example + * + * _.fromPairs([['fred', 30], ['barney', 40]]); + * // => { 'fred': 30, 'barney': 40 } + */ + function fromPairs(pairs) { + var index = -1, + length = pairs ? pairs.length : 0, + result = {}; + + while (++index < length) { + var pair = pairs[index]; + baseSet(result, pair[0], pair[1]); + } + return result; + } + /** * Gets the first element of `array`. * @@ -5411,7 +5802,7 @@ if (!length) { return -1; } - fromIndex = fromIndex ? toInteger(fromIndex) : 0; + fromIndex = toInteger(fromIndex); if (fromIndex < 0) { fromIndex = nativeMax(length + fromIndex, 0); } @@ -5465,14 +5856,14 @@ * @memberOf _ * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Array} Returns the new array of shared values. * @example * * _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); * // => [2.1] * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }] */ @@ -5486,10 +5877,61 @@ mapped.pop(); } return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersectionBy(mapped, getIteratee(iteratee)) + ? baseIntersection(mapped, getIteratee(iteratee)) : []; }); + /** + * This method is like `_.intersection` except that it accepts `comparator` + * which is invoked to compare elements of `arrays`. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of shared values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.intersectionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }] + */ + var intersectionWith = rest(function(arrays) { + var comparator = last(arrays), + mapped = arrayMap(arrays, toArrayLikeObject); + + if (comparator === last(mapped)) { + comparator = undefined; + } else { + mapped.pop(); + } + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped, undefined, comparator) + : []; + }); + + /** + * Converts all elements in `array` into a string separated by `separator`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to convert. + * @param {string} [separator=','] The element separator. + * @returns {string} Returns the joined string. + * @example + * + * _.join(['a', 'b', 'c'], '~'); + * // => 'a~b~c' + */ + function join(array, separator) { + return array ? nativeJoin.call(array, separator) : ''; + } + /** * Gets the last element of `array`. * @@ -5609,13 +6051,13 @@ * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Array} Returns `array`. * @example * * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; * - * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], function(o) { return o.x; }); + * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); * console.log(array); * // => [{ 'x': 2 }] */ @@ -5708,7 +6150,8 @@ * Reverses `array` so that the first element becomes the last, the second * element becomes the second to last, and so on. * - * **Note:** This method mutates `array`. + * **Note:** This method mutates `array` and is based on + * [`Array#reverse`](https://mdn.io/Array/reverse). * * @memberOf _ * @category Array @@ -5730,8 +6173,8 @@ /** * Creates a slice of `array` from `start` up to, but not including, `end`. * - * **Note:** This method is used instead of `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 _ @@ -5750,6 +6193,10 @@ start = 0; end = length; } + else { + start = start == null ? 0 : toInteger(start); + end = end === undefined ? length : toInteger(end); + } return baseSlice(array, start, end); } @@ -5772,7 +6219,7 @@ * // => 0 */ function sortedIndex(array, value) { - return binaryIndex(array, value); + return baseSortedIndex(array, value); } /** @@ -5785,7 +6232,7 @@ * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {number} Returns the index at which `value` should be inserted into `array`. * @example * @@ -5794,12 +6241,12 @@ * _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict)); * // => 1 * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); * // => 0 */ function sortedIndexBy(array, value, iteratee) { - return binaryIndexBy(array, value, getIteratee(iteratee)); + return baseSortedIndexBy(array, value, getIteratee(iteratee)); } /** @@ -5820,9 +6267,8 @@ function sortedIndexOf(array, value) { var length = array ? array.length : 0; if (length) { - var index = binaryIndex(array, value); - if (index < length && - (value === value ? (value === array[index]) : (array[index] !== array[index]))) { + var index = baseSortedIndex(array, value); + if (index < length && eq(array[index], value)) { return index; } } @@ -5846,7 +6292,7 @@ * // => 1 */ function sortedLastIndex(array, value) { - return binaryIndex(array, value, true); + return baseSortedIndex(array, value, true); } /** @@ -5859,16 +6305,16 @@ * @category Array * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {number} Returns the index at which `value` should be inserted into `array`. * @example * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); * // => 1 */ function sortedLastIndexBy(array, value, iteratee) { - return binaryIndexBy(array, value, getIteratee(iteratee), true); + return baseSortedIndexBy(array, value, getIteratee(iteratee), true); } /** @@ -5889,10 +6335,8 @@ function sortedLastIndexOf(array, value) { var length = array ? array.length : 0; if (length) { - var index = binaryIndex(array, value, true) - 1, - other = array[index]; - - if (value === value ? (value === other) : (other !== other)) { + var index = baseSortedIndex(array, value, true) - 1; + if (eq(array[index], value)) { return index; } } @@ -5927,7 +6371,7 @@ * @memberOf _ * @category Array * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The function invoked per element. + * @param {Function} [iteratee] The iteratee invoked per element. * @returns {Array} Returns the new duplicate free array. * @example * @@ -5985,7 +6429,7 @@ if (!(array && array.length)) { return []; } - n = (guard || n === undefined) ? 1 : n; + n = (guard || n === undefined) ? 1 : toInteger(n); return baseSlice(array, 0, n < 0 ? 0 : n); } @@ -6020,7 +6464,7 @@ } n = (guard || n === undefined) ? 1 : toInteger(n); n = length - n; - return baseSlice(array, n < 0 ? 0 : n); + return baseSlice(array, n < 0 ? 0 : n, length); } /** @@ -6036,27 +6480,25 @@ * @returns {Array} Returns the slice of `array`. * @example * - * var resolve = _.partial(_.map, _, 'user'); - * * var users = [ * { 'user': 'barney', 'active': true }, * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': false } * ]; * - * resolve( _.takeRightWhile(users, function(o) { return !o.active; }) ); - * // => ['fred', 'pebbles'] + * _.takeRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['fred', 'pebbles'] * - * // using the `_.matches` callback shorthand - * resolve( _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }) ); - * // => ['pebbles'] + * // using the `_.matches` iteratee shorthand + * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['pebbles'] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.takeRightWhile(users, ['active', false]) ); - * // => ['fred', 'pebbles'] + * // using the `_.matchesProperty` iteratee shorthand + * _.takeRightWhile(users, ['active', false]); + * // => objects for ['fred', 'pebbles'] * - * // using the `_.property` callback shorthand - * resolve( _.takeRightWhile(users, 'active') ); + * // using the `_.property` iteratee shorthand + * _.takeRightWhile(users, 'active'); * // => [] */ function takeRightWhile(array, predicate) { @@ -6078,27 +6520,25 @@ * @returns {Array} Returns the slice of `array`. * @example * - * var resolve = _.partial(_.map, _, 'user'); - * * var users = [ * { 'user': 'barney', 'active': false }, * { 'user': 'fred', 'active': false}, * { 'user': 'pebbles', 'active': true } * ]; * - * resolve( _.takeWhile(users, function(o) { return !o.active; }) ); - * // => ['barney', 'fred'] + * _.takeWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney', 'fred'] * - * // using the `_.matches` callback shorthand - * resolve( _.takeWhile(users, { 'user': 'barney', 'active': false }) ); - * // => ['barney'] + * // using the `_.matches` iteratee shorthand + * _.takeWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['barney'] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.takeWhile(users, ['active', false]) ); - * // => ['barney', 'fred'] + * // using the `_.matchesProperty` iteratee shorthand + * _.takeWhile(users, ['active', false]); + * // => objects for ['barney', 'fred'] * - * // using the `_.property` callback shorthand - * resolve( _.takeWhile(users, 'active') ); + * // using the `_.property` iteratee shorthand + * _.takeWhile(users, 'active'); * // => [] */ function takeWhile(array, predicate) { @@ -6135,14 +6575,14 @@ * @memberOf _ * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Array} Returns the new array of combined values. * @example * * _.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor); * // => [2.1, 1.2, 4.3] * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ @@ -6151,7 +6591,34 @@ if (isArrayLikeObject(iteratee)) { iteratee = undefined; } - return baseUniqBy(baseFlatten(arrays, false, true), getIteratee(iteratee)); + return baseUniq(baseFlatten(arrays, false, true), getIteratee(iteratee)); + }); + + /** + * 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). + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of combined values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.unionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ + var unionWith = rest(function(arrays) { + var comparator = last(arrays); + if (isArrayLikeObject(comparator)) { + comparator = undefined; + } + return baseUniq(baseFlatten(arrays, false, true), undefined, comparator); }); /** @@ -6185,20 +6652,44 @@ * @memberOf _ * @category Array * @param {Array} array The array to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Array} Returns the new duplicate free array. * @example * * _.uniqBy([2.1, 1.2, 2.3], Math.floor); * // => [2.1, 1.2] * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ function uniqBy(array, iteratee) { return (array && array.length) - ? baseUniqBy(array, getIteratee(iteratee)) + ? baseUniq(array, getIteratee(iteratee)) + : []; + } + + /** + * 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). + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.uniqWith(objects, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] + */ + function uniqWith(array, comparator) { + return (array && array.length) + ? baseUniq(array, undefined, comparator) : []; } @@ -6238,9 +6729,8 @@ /** * This method is like `_.unzip` except that it accepts `iteratee` to specify - * how regrouped values should be combined. The iteratee is invoked with four - * arguments: (accumulator, value, index, group). The first element of each - * group is used as the initial `accumulator` value. + * how regrouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). * * @static * @memberOf _ @@ -6265,7 +6755,7 @@ return result; } return arrayMap(result, function(group) { - return arrayReduce(group, iteratee, undefined, true); + return apply(iteratee, undefined, group); }); } @@ -6318,14 +6808,14 @@ * @memberOf _ * @category Array * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Array} Returns the new array of values. * @example * * _.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); * // => [1.2, 4.3] * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 2 }] */ @@ -6334,7 +6824,34 @@ if (isArrayLikeObject(iteratee)) { iteratee = undefined; } - return baseXorBy(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee)); + return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee)); + }); + + /** + * 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). + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.xorWith(objects, others, _.isEqual); + * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ + var xorWith = rest(function(arrays) { + var comparator = last(arrays); + if (isArrayLikeObject(comparator)) { + comparator = undefined; + } + return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); }); /** @@ -6355,49 +6872,36 @@ var zip = rest(unzip); /** - * The inverse of `_.pairs`; this method returns an object composed from arrays - * of property names and values. Provide either a single two dimensional array, - * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names - * and one of corresponding values. + * This method is like `_.fromPairs` except that it accepts two arrays, + * one of property names and one of corresponding values. * * @static * @memberOf _ * @category Array - * @param {Array} props The property names. + * @param {Array} [props=[]] The property names. * @param {Array} [values=[]] The property values. * @returns {Object} Returns the new object. * @example * - * _.zipObject([['fred', 30], ['barney', 40]]); - * // => { 'fred': 30, 'barney': 40 } - * * _.zipObject(['fred', 'barney'], [30, 40]); * // => { 'fred': 30, 'barney': 40 } */ function zipObject(props, values) { var index = -1, length = props ? props.length : 0, + valsLength = values ? values.length : 0, result = {}; - if (length && !values && !isArray(props[0])) { - values = []; - } while (++index < length) { - var key = props[index]; - if (values) { - result[key] = values[index]; - } else if (key) { - result[key[0]] = key[1]; - } + baseSet(result, props[index], index < valsLength ? values[index] : undefined); } return result; } /** * This method is like `_.zip` except that it accepts `iteratee` to specify - * how grouped values should be combined. The iteratee is invoked with four - * arguments: (accumulator, value, index, group). The first element of each - * group is used as the initial `accumulator` value. + * how grouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). * * @static * @memberOf _ @@ -6407,7 +6911,9 @@ * @returns {Array} Returns the new array of grouped elements. * @example * - * _.zipWith([1, 2], [10, 20], [100, 200], _.add); + * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { + * return a + b + c; + * }); * // => [111, 222] */ var zipWith = rest(function(arrays) { @@ -6426,7 +6932,7 @@ * * @static * @memberOf _ - * @category Chain + * @category Seq * @param {*} value The value to wrap. * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -6461,7 +6967,7 @@ * * @static * @memberOf _ - * @category Chain + * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. * @returns {*} Returns `value`. @@ -6485,7 +6991,7 @@ * * @static * @memberOf _ - * @category Chain + * @category Seq * @param {*} value The value to provide to `interceptor`. * @param {Function} interceptor The function to invoke. * @returns {*} Returns the result of `interceptor`. @@ -6504,12 +7010,51 @@ return interceptor(value); } + /** + * This method is the wrapper version of `_.at`. + * + * @name at + * @memberOf _ + * @category Seq + * @param {...(string|string[])} [paths] The property paths of elements to pick, + * specified individually or in arrays. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _(object).at(['a[0].b.c', 'a[1]']).value(); + * // => [3, 4] + * + * _(['a', 'b', 'c']).at(0, 2).value(); + * // => ['a', 'c'] + */ + var wrapperAt = rest(function(paths) { + paths = baseFlatten(paths); + var length = paths.length, + start = length ? paths[0] : 0, + value = this.__wrapped__, + interceptor = function(object) { return baseAt(object, paths); }; + + if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex(start)) { + return this.thru(interceptor); + } + value = value.slice(start, +start + (length ? 1 : 0)); + value.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); + return new LodashWrapper(value, this.__chain__).thru(function(array) { + if (length && !array.length) { + array.push(undefined); + } + return array; + }); + }); + /** * Enables explicit method chaining on the wrapper object. * * @name chain * @memberOf _ - * @category Chain + * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example * @@ -6539,7 +7084,7 @@ * * @name commit * @memberOf _ - * @category Chain + * @category Seq * @returns {Object} Returns the new `lodash` wrapper instance. * @example * @@ -6564,31 +7109,25 @@ } /** - * Creates a new array joining a wrapped array with any additional arrays - * and/or values. + * This method is the wrapper version of `_.flatMap`. * - * @name concat + * @static * @memberOf _ - * @category Chain - * @param {...*} [values] The values to concatenate. - * @returns {Array} Returns the new concatenated array. + * @category Seq + * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * var array = [1]; - * var wrapped = _(array).concat(2, [3], [[4]]); + * function duplicate(n) { + * return [n, n]; + * } * - * console.log(wrapped.value()); - * // => [1, 2, 3, [4]] - * - * console.log(array); - * // => [1] + * _([1, 2]).flatMap(duplicate).value(); + * // => [1, 1, 2, 2] */ - var wrapperConcat = rest(function(values) { - values = baseFlatten(values); - return this.thru(function(array) { - return arrayConcat(isArray(array) ? array : [Object(array)], values); - }); - }); + function wrapperFlatMap(iteratee) { + return this.map(iteratee).flatten(); + } /** * Gets the next value on a wrapped object following the @@ -6596,7 +7135,7 @@ * * @name next * @memberOf _ - * @category Chain + * @category Seq * @returns {Object} Returns the next iterator value. * @example * @@ -6626,7 +7165,7 @@ * * @name Symbol.iterator * @memberOf _ - * @category Chain + * @category Seq * @returns {Object} Returns the wrapper object. * @example * @@ -6647,7 +7186,7 @@ * * @name plant * @memberOf _ - * @category Chain + * @category Seq * @param {*} value The value to plant. * @returns {Object} Returns the new `lodash` wrapper instance. * @example @@ -6686,15 +7225,14 @@ } /** - * Reverses the wrapped array so that the first element becomes the last, - * the second element becomes the second to last, and so on. + * This method is the wrapper version of `_.reverse`. * * **Note:** This method mutates the wrapped array. * * @name reverse * @memberOf _ - * @category Chain - * @returns {Object} Returns the new reversed `lodash` wrapper instance. + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * * var array = [1, 2, 3]; @@ -6725,7 +7263,7 @@ * @name value * @memberOf _ * @alias run, toJSON, valueOf - * @category Chain + * @category Seq * @returns {*} Returns the resolved unwrapped value. * @example * @@ -6748,7 +7286,7 @@ * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Object} Returns the composed aggregate object. * @example * @@ -6784,15 +7322,15 @@ * { 'user': 'fred', 'active': false } * ]; * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.every(users, { 'user': 'barney', 'active': false }); * // => false * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.every(users, ['active', false]); * // => true * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.every(users, 'active'); * // => false */ @@ -6817,27 +7355,25 @@ * @returns {Array} Returns the new filtered array. * @example * - * var resolve = _.partial(_.map, _, 'user'); - * * var users = [ * { 'user': 'barney', 'age': 36, 'active': true }, * { 'user': 'fred', 'age': 40, 'active': false } * ]; * - * resolve( _.filter(users, function(o) { return !o.active; }) ); - * // => ['fred'] + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] * - * // using the `_.matches` callback shorthand - * resolve( _.filter(users, { 'age': 36, 'active': true }) ); - * // => ['barney'] + * // using the `_.matches` iteratee shorthand + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.filter(users, ['active', false]) ); - * // => ['fred'] + * // using the `_.matchesProperty` iteratee shorthand + * _.filter(users, ['active', false]); + * // => objects for ['fred'] * - * // using the `_.property` callback shorthand - * resolve( _.filter(users, 'active') ); - * // => ['barney'] + * // using the `_.property` iteratee shorthand + * _.filter(users, 'active'); + * // => objects for ['barney'] */ function filter(collection, predicate) { var func = isArray(collection) ? arrayFilter : baseFilter; @@ -6857,28 +7393,26 @@ * @returns {*} Returns the matched element, else `undefined`. * @example * - * var resolve = _.partial(_.result, _, 'user'); - * * var users = [ * { 'user': 'barney', 'age': 36, 'active': true }, * { 'user': 'fred', 'age': 40, 'active': false }, * { 'user': 'pebbles', 'age': 1, 'active': true } * ]; * - * resolve( _.find(users, function(o) { return o.age < 40; }) ); - * // => 'barney' + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' * - * // using the `_.matches` callback shorthand - * resolve( _.find(users, { 'age': 1, 'active': true }) ); - * // => 'pebbles' + * // using the `_.matches` iteratee shorthand + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.find(users, ['active', false]) ); - * // => 'fred' + * // using the `_.matchesProperty` iteratee shorthand + * _.find(users, ['active', false]); + * // => object for 'fred' * - * // using the `_.property` callback shorthand - * resolve( _.find(users, 'active') ); - * // => 'barney' + * // using the `_.property` iteratee shorthand + * _.find(users, 'active'); + * // => object for 'barney' */ function find(collection, predicate) { predicate = getIteratee(predicate, 3); @@ -6983,14 +7517,14 @@ * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Object} Returns the composed aggregate object. * @example * * _.groupBy([6.1, 4.2, 6.3], Math.floor); * // => { '4': [4.2], '6': [6.1, 6.3] } * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.groupBy(['one', 'two', 'three'], 'length'); * // => { '3': ['one', 'two'], '5': ['three'] } */ @@ -7003,19 +7537,19 @@ }); /** - * Checks if `target` is in `collection` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the offset - * from the end of `collection`. + * 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 _ * @category Collection * @param {Array|Object|string} collection The collection to search. - * @param {*} target The value to search for. + * @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`. - * @returns {boolean} Returns `true` if a matching element is found, else `false`. + * @returns {boolean} Returns `true` if `value` is found, else `false`. * @example * * _.includes([1, 2, 3], 1); @@ -7030,7 +7564,7 @@ * _.includes('pebbles', 'eb'); * // => true */ - function includes(collection, target, fromIndex, guard) { + function includes(collection, value, fromIndex, guard) { collection = isArrayLike(collection) ? collection : values(collection); fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; @@ -7039,8 +7573,8 @@ fromIndex = nativeMax(length + fromIndex, 0); } return isString(collection) - ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) - : (!!length && baseIndexOf(collection, target, fromIndex) > -1); + ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) + : (!!length && baseIndexOf(collection, value, fromIndex) > -1); } /** @@ -7055,17 +7589,17 @@ * @param {Array|Object} collection The collection to iterate over. * @param {Array|Function|string} path The path of the method to invoke or * the function invoked per iteration. - * @param {...*} [args] The arguments to invoke the method with. + * @param {...*} [args] The arguments to invoke each method with. * @returns {Array} Returns the array of results. * @example * - * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); + * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); * // => [[1, 5, 7], [1, 2, 3]] * - * _.invoke([123, 456], String.prototype.split, ''); + * _.invokeMap([123, 456], String.prototype.split, ''); * // => [['1', '2', '3'], ['4', '5', '6']] */ - var invoke = rest(function(collection, path, args) { + var invokeMap = rest(function(collection, path, args) { var index = -1, isFunc = typeof path == 'function', isProp = isKey(path), @@ -7073,7 +7607,7 @@ baseEach(collection, function(value) { var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined); - result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); + result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args); }); return result; }); @@ -7088,7 +7622,7 @@ * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7118,9 +7652,9 @@ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. * * The guarded methods are: - * `ary`, `callback`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, - * `fill`, `invert`, `parseInt`, `random`, `range`, `slice`, `some`, `sortBy`, - * `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`, `uniq`, + * `ary`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, `fill`, + * `invert`, `parseInt`, `random`, `range`, `rangeRight`, `slice`, `some`, + * `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`, * and `words` * * @static @@ -7146,7 +7680,7 @@ * { 'user': 'fred' } * ]; * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.map(users, 'user'); * // => ['barney', 'fred'] */ @@ -7155,6 +7689,47 @@ return func(collection, getIteratee(iteratee, 3)); } + /** + * 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. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {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`. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 34 }, + * { 'user': 'fred', 'age': 42 }, + * { 'user': 'barney', 'age': 36 } + * ]; + * + * // sort by `user` in ascending order and by `age` in descending order + * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + */ + function orderBy(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [iteratees]; + } + orders = guard ? undefined : orders; + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseOrderBy(collection, iteratees, orders); + } + /** * Creates an array of elements split into two groups, the first of which * contains elements `predicate` returns truthy for, while the second of which @@ -7169,30 +7744,26 @@ * @returns {Array} Returns the array of grouped elements. * @example * - * var resolve = function(result) { - * return _.map(result, function(array) { return _.map(array, 'user'); }); - * }; - * * var users = [ * { 'user': 'barney', 'age': 36, 'active': false }, * { 'user': 'fred', 'age': 40, 'active': true }, * { 'user': 'pebbles', 'age': 1, 'active': false } * ]; * - * resolve( _.partition(users, function(o) { return o.active; }) ); - * // => [['fred'], ['barney', 'pebbles']] + * _.partition(users, function(o) { return o.active; }); + * // => objects for [['fred'], ['barney', 'pebbles']] * - * // using the `_.matches` callback shorthand - * resolve( _.partition(users, { 'age': 1, 'active': false }) ); - * // => [['pebbles'], ['barney', 'fred']] + * // using the `_.matches` iteratee shorthand + * _.partition(users, { 'age': 1, 'active': false }); + * // => objects for [['pebbles'], ['barney', 'fred']] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.partition(users, ['active', false]) ); - * // => [['barney', 'pebbles'], ['fred']] + * // using the `_.matchesProperty` iteratee shorthand + * _.partition(users, ['active', false]); + * // => objects for [['barney', 'pebbles'], ['fred']] * - * // using the `_.property` callback shorthand - * resolve( _.partition(users, 'active') ); - * // => [['fred'], ['barney', 'pebbles']] + * // using the `_.property` iteratee shorthand + * _.partition(users, 'active'); + * // => objects for [['fred'], ['barney', 'pebbles']] */ var partition = createAggregator(function(result, value, key) { result[key ? 0 : 1].push(value); @@ -7210,8 +7781,8 @@ * `_.reduce`, `_.reduceRight`, and `_.transform`. * * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortBy`, - * and `sortByOrder` + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` * * @static * @memberOf _ @@ -7234,10 +7805,10 @@ * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) */ function reduce(collection, iteratee, accumulator) { - var initFromCollection = arguments.length < 3; - return (typeof iteratee == 'function' && isArray(collection)) - ? arrayReduce(collection, iteratee, accumulator, initFromCollection) - : baseReduce(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEach); + var func = isArray(collection) ? arrayReduce : baseReduce, + initFromCollection = arguments.length < 3; + + return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEach); } /** @@ -7261,10 +7832,10 @@ * // => [4, 5, 2, 3, 0, 1] */ function reduceRight(collection, iteratee, accumulator) { - var initFromCollection = arguments.length < 3; - return (typeof iteratee == 'function' && isArray(collection)) - ? arrayReduceRight(collection, iteratee, accumulator, initFromCollection) - : baseReduce(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEachRight); + var func = isArray(collection) ? arrayReduceRight : baseReduce, + initFromCollection = arguments.length < 3; + + return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEachRight); } /** @@ -7279,27 +7850,25 @@ * @returns {Array} Returns the new filtered array. * @example * - * var resolve = _.partial(_.map, _, 'user'); - * * var users = [ * { 'user': 'barney', 'age': 36, 'active': false }, * { 'user': 'fred', 'age': 40, 'active': true } * ]; * - * resolve( _.reject(users, function(o) { return !o.active; }) ); - * // => ['fred'] + * _.reject(users, function(o) { return !o.active; }); + * // => objects for ['fred'] * - * // using the `_.matches` callback shorthand - * resolve( _.reject(users, { 'age': 40, 'active': true }) ); - * // => ['barney'] + * // using the `_.matches` iteratee shorthand + * _.reject(users, { 'age': 40, 'active': true }); + * // => objects for ['barney'] * - * // using the `_.matchesProperty` callback shorthand - * resolve( _.reject(users, ['active', false]) ); - * // => ['fred'] + * // using the `_.matchesProperty` iteratee shorthand + * _.reject(users, ['active', false]); + * // => objects for ['fred'] * - * // using the `_.property` callback shorthand - * resolve( _.reject(users, 'active') ); - * // => ['barney'] + * // using the `_.property` iteratee shorthand + * _.reject(users, 'active'); + * // => objects for ['barney'] */ function reject(collection, predicate) { var func = isArray(collection) ? arrayFilter : baseFilter; @@ -7349,7 +7918,7 @@ length = result.length, lastIndex = length - 1; - n = clamp(toInteger(n), 0, length); + n = baseClamp(toInteger(n), 0, length); while (++index < n) { var rand = baseRandom(index, lastIndex), value = result[rand]; @@ -7432,15 +8001,15 @@ * { 'user': 'fred', 'active': false } * ]; * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.some(users, { 'user': 'barney', 'active': false }); * // => false * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.some(users, ['active', false]); * // => true * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.some(users, 'active'); * // => true */ @@ -7467,8 +8036,6 @@ * @returns {Array} Returns the new sorted array. * @example * - * var resolve = _.partial(_.map, _, _.values); - * * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, @@ -7476,16 +8043,16 @@ * { 'user': 'barney', 'age': 34 } * ]; * - * resolve( _.sortBy(users, function(o) { return o.user; }) ); - * // => // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * _.sortBy(users, function(o) { return o.user; }); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] * - * resolve( _.sortBy(users, ['user', 'age']) ); - * // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] * - * resolve( _.sortBy(users, 'user', function(o) { + * _.sortBy(users, 'user', function(o) { * return Math.floor(o.age / 10); - * }) ); - * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + * }); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] */ var sortBy = rest(function(collection, iteratees) { if (collection == null) { @@ -7497,52 +8064,9 @@ } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { iteratees.length = 1; } - return baseSortByOrder(collection, baseFlatten(iteratees), []); + return baseOrderBy(collection, baseFlatten(iteratees), []); }); - /** - * 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, a value is sorted in - * ascending order if its corresponding order is "asc", and descending if "desc". - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {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`. - * @returns {Array} Returns the new sorted array. - * @example - * - * var resolve = _.partial(_.map, _, _.values); - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 42 }, - * { 'user': 'barney', 'age': 36 } - * ]; - * - * // sort by `user` in ascending order and by `age` in descending order - * resolve( _.sortByOrder(users, ['user', 'age'], ['asc', 'desc']) ); - * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - */ - function sortByOrder(collection, iteratees, orders, guard) { - if (collection == null) { - return []; - } - if (!isArray(iteratees)) { - iteratees = iteratees == null ? [] : [iteratees]; - } - orders = guard ? undefined : orders; - if (!isArray(orders)) { - orders = orders == null ? [] : [orders]; - } - return baseSortByOrder(collection, iteratees, orders); - } - /*------------------------------------------------------------------------*/ /** @@ -7601,7 +8125,7 @@ } /** - * Creates a function that accepts up to `n` arguments ignoring any + * Creates a function that accepts up to `n` arguments, ignoring any * additional arguments. * * @static @@ -7635,7 +8159,7 @@ * @returns {Function} Returns the new restricted function. * @example * - * jQuery('#add').on('click', _.before(5, addContactToList)); + * jQuery(element).on('click', _.before(5, addContactToList)); * // => allows adding up to 4 contacts to the list */ function before(n, func) { @@ -7699,39 +8223,6 @@ return createWrapper(func, bitmask, thisArg, partials, holders); }); - /** - * Binds methods of an object to the object itself, overwriting the existing - * method. - * - * **Note:** This method doesn't set the "length" property of bound functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Object} object The object to bind and assign the bound methods to. - * @param {...(string|string[])} methodNames The object method names to bind, - * specified individually or in arrays. - * @returns {Object} Returns `object`. - * @example - * - * var view = { - * 'label': 'docs', - * 'onClick': function() { - * console.log('clicked ' + this.label); - * } - * }; - * - * _.bindAll(view, 'onClick'); - * jQuery('#docs').on('click', view.onClick); - * // => logs 'clicked docs' when the element is clicked - */ - var bindAll = rest(function(object, methodNames) { - arrayEach(baseFlatten(methodNames), function(key) { - object[key] = bind(object[key], object); - }); - return object; - }); - /** * Creates a function that invokes the method at `object[key]` and prepends * any additional `_.bindKey` arguments to those provided to the bound function. @@ -7747,7 +8238,7 @@ * @static * @memberOf _ * @category Function - * @param {Object} object The object the method belongs to. + * @param {Object} object The object to invoke the method on. * @param {string} key The key of the method. * @param {...*} [partials] The arguments to be partially applied. * @returns {Function} Returns the new bound function. @@ -7786,35 +8277,11 @@ }); /** - * Creates a function that checks if **all** of the `predicates` return - * truthy when invoked with the arguments provided to the created function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function[]} predicates The predicates to check. - * @returns {Function} Returns the new function. - * @example - * - * var conjed = _.conj(Boolean, isFinite); - * - * conjed('1'); - * // => true - * - * conjed(null); - * // => false - * - * conjed(NaN); - * // => false - */ - var conj = createInvoker(arrayEvery); - - /** - * Creates a function that accepts one or more arguments of `func` that when - * called either invokes `func` returning its result, if all `func` arguments - * have been provided, or returns a function that accepts one or more of the - * remaining `func` arguments, and so on. The arity of `func` may be specified - * if `func.length` is not sufficient. + * Creates a function that accepts arguments of `func` and either invokes + * `func` returning its result, if at least `arity` number of arguments have + * been provided, or returns a function that accepts the remaining `func` + * arguments, and so on. The arity of `func` may be specified if `func.length` + * is not sufficient. * * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, * may be used as a placeholder for provided arguments. @@ -7905,9 +8372,10 @@ * milliseconds have elapsed since the last time the debounced function was * invoked. The debounced function comes with a `cancel` method to cancel * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide an options object to indicate that `func` should be invoked on the - * leading and/or trailing edge of the `wait` timeout. Subsequent calls to the - * debounced function return the result of the last `func` invocation. + * Provide an options object to indicate whether `func` should be invoked on + * the leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent calls + * to the debounced function return the result of the last `func` invocation. * * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked * on the trailing edge of the timeout only if the the debounced function is @@ -7934,34 +8402,19 @@ * // avoid costly calculations while the window size is in flux * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); * - * // invoke `sendMail` when the click event is fired, debouncing subsequent calls - * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { + * // invoke `sendMail` when clicked, debouncing subsequent calls + * jQuery(element).on('click', _.debounce(sendMail, 300, { * 'leading': true, * 'trailing': false * })); * * // ensure `batchLog` is invoked once after 1 second of debounced calls + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); * var source = new EventSource('/stream'); - * jQuery(source).on('message', _.debounce(batchLog, 250, { - * 'maxWait': 1000 - * })); + * jQuery(source).on('message', debounced); * - * // cancel a debounced call - * var todoChanges = _.debounce(batchLog, 1000); - * Object.observe(models.todo, todoChanges); - * - * Object.observe(models, function(changes) { - * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) { - * todoChanges.cancel(); - * } - * }, ['delete']); - * - * // ...at some point `models.todo` is changed - * models.todo.completed = true; - * - * // ...before 1 second has passed `models.todo` is deleted - * // which cancels the debounced `todoChanges` call - * delete models.todo; + * // cancel a trailing debounced invocation + * jQuery(window).on('popstate', debounced.cancel); */ function debounce(func, wait, options) { var args, @@ -7979,10 +8432,10 @@ if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - wait = wait < 0 ? 0 : (+wait || 0); + wait = toNumber(wait) || 0; if (isObject(options)) { leading = !!options.leading; - maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait); + maxWait = 'maxWait' in options && nativeMax(toNumber(options.maxWait) || 0, wait); trailing = 'trailing' in options ? !!options.trailing : trailing; } @@ -8086,7 +8539,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to defer. - * @param {...*} [args] The arguments to invoke the function with. + * @param {...*} [args] The arguments to invoke `func` with. * @returns {number} Returns the timer id. * @example * @@ -8108,7 +8561,7 @@ * @category Function * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. - * @param {...*} [args] The arguments to invoke the function with. + * @param {...*} [args] The arguments to invoke `func` with. * @returns {number} Returns the timer id. * @example * @@ -8118,33 +8571,9 @@ * // => logs 'later' after one second */ var delay = rest(function(func, wait, args) { - return baseDelay(func, wait, args); + return baseDelay(func, toNumber(wait) || 0, args); }); - /** - * Creates a function that checks if **any** of the `predicates` return - * truthy when invoked with the arguments provided to the created function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function[]} predicates The predicates to check. - * @returns {Function} Returns the new function. - * @example - * - * var disjed = _.disj(Boolean, isFinite); - * - * disjed('1'); - * // => true - * - * disjed(null); - * // => true - * - * disjed(NaN); - * // => false - */ - var disj = createInvoker(arraySome); - /** * Creates a function that invokes `func` with arguments reversed. * @@ -8166,67 +8595,6 @@ return createWrapper(func, FLIP_FLAG); } - /** - * Creates a function that returns the result of invoking the provided - * functions with the `this` binding of the created function, where each - * successive invocation is supplied the return value of the previous. - * - * @static - * @memberOf _ - * @category Function - * @param {...Function} [funcs] Functions to invoke. - * @returns {Function} Returns the new function. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var addSquare = _.flow(_.add, square); - * addSquare(1, 2); - * // => 9 - */ - var flow = createFlow(); - - /** - * This method is like `_.flow` except that it creates a function that - * invokes the provided functions from right to left. - * - * @static - * @memberOf _ - * @category Function - * @param {...Function} [funcs] Functions to invoke. - * @returns {Function} Returns the new function. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var addSquare = _.flowRight(square, _.add); - * addSquare(1, 2); - * // => 9 - */ - var flowRight = createFlow(true); - - /** - * Creates a function that invokes `iteratees` with the arguments provided - * to the created function and returns their results. - * - * @static - * @memberOf _ - * @category Function - * @param {Function[]} iteratees The iteratees to invoke. - * @returns {Function} Returns the new function. - * @example - * - * var juxted = _.juxt(Math.max, Math.min); - * - * juxted(1, 2, 3, 4); - * // => [4, 1] - */ - var juxt = createInvoker(arrayMap); - /** * 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 @@ -8237,7 +8605,7 @@ * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) - * method interface of `get`, `has`, and `set`. + * method interface of `delete`, `get`, `has`, and `set`. * * @static * @memberOf _ @@ -8289,76 +8657,6 @@ return memoized; } - /** - * Creates a function that invokes `func` with arguments modified by - * corresponding `transforms`. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms] The functions to transform - * arguments, specified individually or in arrays. - * @returns {Function} Returns the new function. - * @example - * - * function doubled(n) { - * return n * 2; - * } - * - * function square(n) { - * return n * n; - * } - * - * var modded = _.modArgs(function(x, y) { - * return [x, y]; - * }, square, doubled); - * - * modded(9, 3); - * // => [81, 6] - * - * modded(10, 5); - * // => [100, 10] - */ - var modArgs = createModArgs(function(value) { - return [value]; - }); - - /** - * This method is like `_.modArgs` except that each of the `transforms` is - * provided all arguments the created function is invoked with. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms] The functions to transform - * arguments, specified individually or in arrays. - * @returns {Function} Returns the new function. - * @example - * - * function divide(x, y) { - * return x / y; - * } - * - * function multiply(x, y) { - * return x * y; - * } - * - * var modded = _.modArgsSet(function(x, y) { - * return [x, y]; - * }, multiply, divide); - * - * modded(9, 3); - * // => [27, 3] - * - * modded(10, 5); - * // => [50, 2] - */ - var modArgsSet = createModArgs(function(value, index, args) { - return args; - }); - /** * Creates a function that negates the result of the predicate `func`. The * `func` predicate is invoked with the `this` binding and arguments of the @@ -8389,8 +8687,8 @@ /** * Creates a function that is restricted to invoking `func` once. Repeat calls - * to the function return the value of the first call. The `func` is invoked - * with the `this` binding and arguments of the created function. + * to the function return the value of the first invocation. The `func` is + * invoked with the `this` binding and arguments of the created function. * * @static * @memberOf _ @@ -8408,6 +8706,52 @@ return before(2, func); } + /** + * Creates a function that invokes `func` with arguments transformed by + * corresponding `transforms`. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to wrap. + * @param {...(Function|Function[])} [transforms] The functions to transform + * arguments, specified individually or in arrays. + * @returns {Function} Returns the new function. + * @example + * + * function doubled(n) { + * return n * 2; + * } + * + * function square(n) { + * return n * n; + * } + * + * var func = _.overArgs(function(x, y) { + * return [x, y]; + * }, square, doubled); + * + * func(9, 3); + * // => [81, 6] + * + * func(10, 5); + * // => [100, 10] + */ + var overArgs = rest(function(func, transforms) { + transforms = arrayMap(baseFlatten(transforms), getIteratee()); + + var funcsLength = transforms.length; + return rest(function(args) { + var index = -1, + length = nativeMin(args.length, funcsLength); + + while (++index < length) { + args[index] = transforms[index].call(this, args[index]); + } + return apply(func, this, args); + }); + }); + /** * Creates a function that invokes `func` with `partial` arguments prepended * to those provided to the new function. This method is like `_.bind` except @@ -8554,7 +8898,7 @@ otherArgs[index] = args[index]; } otherArgs[start] = array; - return func.apply(this, otherArgs); + return apply(func, this, otherArgs); }; } @@ -8594,17 +8938,19 @@ throw new TypeError(FUNC_ERROR_TEXT); } return function(array) { - return func.apply(this, array); + return apply(func, this, array); }; } /** * Creates a throttled function that only invokes `func` at most once per * every `wait` milliseconds. The throttled function comes with a `cancel` - * method to cancel delayed invocations. Provide an options object to indicate - * that `func` should be invoked on the leading and/or trailing edge of the - * `wait` timeout. Subsequent calls to the throttled function return the - * result of the last `func` call. + * method to cancel delayed `func` invocations and a `flush` method to + * immediately invoke them. Provide an options object to indicate whether + * `func` should be invoked on the leading and/or trailing edge of the `wait` + * timeout. The `func` is invoked with the last arguments provided to the + * 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 the throttled function is @@ -8630,11 +8976,10 @@ * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); + * jQuery(element).on('click', throttled); * - * // cancel a trailing throttled call + * // cancel a trailing throttled invocation * jQuery(window).on('popstate', throttled.cancel); */ function throttle(func, wait, options) { @@ -8648,7 +8993,25 @@ leading = 'leading' in options ? !!options.leading : leading; trailing = 'trailing' in options ? !!options.trailing : trailing; } - return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing }); + return debounce(func, wait, { 'leading': leading, 'maxWait': wait, 'trailing': trailing }); + } + + /** + * Creates a function that accepts up to one argument, ignoring any + * additional arguments. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new function. + * @example + * + * _.map(['6', '8', '10'], _.unary(parseInt)); + * // => [6, 8, 10] + */ + function unary(func) { + return ary(func, 1); } /** @@ -8683,11 +9046,12 @@ * Creates a shallow clone of `value`. * * **Note:** This method is loosely based on the - * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). - * The enumerable properties of `arguments` objects and objects created by - * constructors other than `Object` are cloned to plain `Object` objects. An - * empty object is returned for uncloneable values such as functions, DOM nodes, - * Maps, Sets, and WeakMaps. + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * 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. * * @static * @memberOf _ @@ -8696,13 +9060,10 @@ * @returns {*} Returns the cloned value. * @example * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; + * var objects = [{ 'a': 1 }, { 'b': 2 }]; * - * var shallow = _.clone(users); - * console.log(shallow[0] === users[0]); + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); * // => true */ function clone(value) { @@ -8723,16 +9084,18 @@ * @returns {*} Returns the cloned value. * @example * - * var el = _.clone(document.body, function(value) { + * function customizer(value) { * if (_.isElement(value)) { * return value.cloneNode(false); * } - * }); + * } + * + * var el = _.clone(document.body, customizer); * * console.log(el === document.body); * // => false * console.log(el.nodeName); - * // => BODY + * // => 'BODY' * console.log(el.childNodes.length); * // => 0 */ @@ -8750,13 +9113,10 @@ * @returns {*} Returns the deep cloned value. * @example * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; + * var objects = [{ 'a': 1 }, { 'b': 2 }]; * - * var deep = _.cloneDeep(users); - * console.log(deep[0] === users[0]); + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); * // => false */ function cloneDeep(value) { @@ -8774,16 +9134,18 @@ * @returns {*} Returns the deep cloned value. * @example * - * var el = _.cloneDeep(document.body, function(value) { + * function customizer(value) { * if (_.isElement(value)) { * return value.cloneNode(true); * } - * }); + * } + * + * var el = _.cloneDeep(document.body, customizer); * * console.log(el === document.body); * // => false * console.log(el.nodeName); - * // => BODY + * // => 'BODY' * console.log(el.childNodes.length); * // => 20 */ @@ -8892,7 +9254,7 @@ function isArguments(value) { // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objToString.call(value) == argsTag); + (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); } /** @@ -8996,7 +9358,7 @@ */ function isBoolean(value) { return value === true || value === false || - (isObjectLike(value) && objToString.call(value) == boolTag); + (isObjectLike(value) && objectToString.call(value) == boolTag); } /** @@ -9016,7 +9378,7 @@ * // => false */ function isDate(value) { - return isObjectLike(value) && objToString.call(value) == dateTag; + return isObjectLike(value) && objectToString.call(value) == dateTag; } /** @@ -9076,10 +9438,11 @@ * Performs a deep comparison between two values to determine if they are * equivalent. * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own, not inherited, enumerable properties. Functions and DOM nodes - * are **not** supported. + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are **not** supported. * * @static * @memberOf _ @@ -9117,15 +9480,20 @@ * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, othValue) { + * if (isGreeting(objValue) && isGreeting(othValue)) { + * return true; + * } + * } + * * var array = ['hello', 'goodbye']; * var other = ['hi', 'goodbye']; * - * _.isEqualWith(array, other, function(value, other) { - * var reHello = /^h(?:i|ello)$/; - * if (reHello.test(value) && reHello.test(other)) { - * return true; - * } - * }); + * _.isEqualWith(array, other, customizer); * // => true */ function isEqualWith(value, other, customizer) { @@ -9153,13 +9521,13 @@ */ function isError(value) { return isObjectLike(value) && - typeof value.message == 'string' && objToString.call(value) == errorTag; + typeof value.message == 'string' && objectToString.call(value) == errorTag; } /** * Checks if `value` is a finite primitive number. * - * **Note:** This method is based on [`Number.isFinite`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite). + * **Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite). * * @static * @memberOf _ @@ -9204,14 +9572,14 @@ // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 8 which returns 'object' for typed array constructors, and // PhantomJS 1.9 which returns 'function' for `NodeList` instances. - var tag = isObject(value) ? objToString.call(value) : ''; + var tag = isObject(value) ? objectToString.call(value) : ''; return tag == funcTag || tag == genTag; } /** * Checks if `value` is an integer. * - * **Note:** This method is based on [`Number.isInteger`](http://ecma-international.org/ecma-262/6.0/#sec-number.isinteger). + * **Note:** This method is based on [`Number.isInteger`](https://mdn.io/Number/isInteger). * * @static * @memberOf _ @@ -9223,19 +9591,47 @@ * _.isInteger(3); * // => true * - * _.isInteger(Number.MAX_VALUE); - * // => true - * - * _.isInteger(3.14); + * _.isInteger(Number.MIN_VALUE); * // => false * * _.isInteger(Infinity); * // => false + * + * _.isInteger('3'); + * // => false */ function isInteger(value) { return typeof value == 'number' && value == toInteger(value); } + /** + * 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). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ + function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + /** * 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('')`) @@ -9297,10 +9693,7 @@ * Performs a deep comparison between `object` and `source` to determine if * `object` contains equivalent property values. * - * **Note:** This method supports comparing properties of arrays, booleans, - * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions - * and DOM nodes are **not** supported. Provide a customizer function to extend - * support for comparing other values. + * **Note:** This method supports comparing the same values as `_.isEqual`. * * @static * @memberOf _ @@ -9337,15 +9730,20 @@ * @returns {boolean} Returns `true` if `object` is a match, else `false`. * @example * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, srcValue) { + * if (isGreeting(objValue) && isGreeting(srcValue)) { + * return true; + * } + * } + * * var object = { 'greeting': 'hello' }; * var source = { 'greeting': 'hi' }; * - * _.isMatchWith(object, source, function(value, other) { - * var reHello = /^h(?:i|ello)$/; - * if (reHello.test(value) && reHello.test(other)) { - * return true; - * } - * }); + * _.isMatchWith(object, source, customizer); * // => true */ function isMatchWith(object, source, customizer) { @@ -9405,7 +9803,7 @@ return false; } if (isFunction(value)) { - return reIsNative.test(fnToString.call(value)); + return reIsNative.test(funcToString.call(value)); } return isObjectLike(value) && (isHostObject(value) ? reIsNative : reIsHostCtor).test(value); @@ -9467,18 +9865,21 @@ * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. * @example * - * _.isNumber(8.4); + * _.isNumber(3); * // => true * - * _.isNumber(NaN); + * _.isNumber(Number.MIN_VALUE); * // => true * - * _.isNumber('8.4'); + * _.isNumber(Infinity); + * // => true + * + * _.isNumber('3'); * // => false */ function isNumber(value) { return typeof value == 'number' || - (isObjectLike(value) && objToString.call(value) == numberTag); + (isObjectLike(value) && objectToString.call(value) == numberTag); } /** @@ -9509,7 +9910,7 @@ * // => true */ function isPlainObject(value) { - if (!isObjectLike(value) || objToString.call(value) != objectTag || isHostObject(value)) { + if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) { return false; } var proto = objectProto; @@ -9521,7 +9922,7 @@ } var Ctor = proto.constructor; return (typeof Ctor == 'function' && - Ctor instanceof Ctor && fnToString.call(Ctor) == objCtorString); + Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); } /** @@ -9541,14 +9942,14 @@ * // => false */ function isRegExp(value) { - return isObject(value) && objToString.call(value) == regexpTag; + return isObject(value) && objectToString.call(value) == regexpTag; } /** * 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`](http://ecma-international.org/ecma-262/6.0/#sec-number.issafeinteger). + * **Note:** This method is based on [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). * * @static * @memberOf _ @@ -9560,14 +9961,14 @@ * _.isSafeInteger(3); * // => true * - * _.isSafeInteger(Number.MAX_VALUE); - * // => false - * - * _.isSafeInteger(3.14); + * _.isSafeInteger(Number.MIN_VALUE); * // => false * * _.isSafeInteger(Infinity); * // => false + * + * _.isSafeInteger('3'); + * // => false */ function isSafeInteger(value) { return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; @@ -9591,7 +9992,28 @@ */ function isString(value) { return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && objToString.call(value) == stringTag); + (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); + } + + /** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ + function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && objectToString.call(value) == symbolTag); } /** @@ -9611,7 +10033,7 @@ * // => false */ function isTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; } /** @@ -9692,10 +10114,17 @@ * @returns {Array} Returns the converted array. * @example * - * (function() { - * return _.toArray(arguments).slice(1); - * }(1, 2, 3)); - * // => [2, 3] + * _.toArray({ 'a': 1, 'b': 2 }); + * // => [1, 2] + * + * _.toArray('abc'); + * // => ['a', 'b', 'c'] + * + * _.toArray(1); + * // => [] + * + * _.toArray(null); + * // => [] */ function toArray(value) { if (!value) { @@ -9725,24 +10154,97 @@ * @returns {number} Returns the converted integer. * @example * - * _.toInteger('3.14'); - * // => 3 + * _.toInteger(3); + * // => 3 * - * _.toInteger(NaN); + * _.toInteger(Number.MIN_VALUE); * // => 0 * - * _.toInteger(-Infinity) - * // => -1e308 + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3'); + * // => 3 */ function toInteger(value) { - if (value === INFINITY || value === -INFINITY) { - return (value < 0 ? -1 : 1) * MAX_INTEGER; + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = (value < 0 ? -1 : 1); + return sign * MAX_INTEGER; } - value = +value; var remainder = value % 1; return value === value ? (remainder ? value - remainder : value) : 0; } + /** + * 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). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @return {number} Returns the converted integer. + * @example + * + * _.toLength(3); + * // => 3 + * + * _.toLength(Number.MIN_VALUE); + * // => 0 + * + * _.toLength(Infinity); + * // => 4294967295 + * + * _.toLength('3'); + * // => 3 + */ + function toLength(value) { + return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; + } + + /** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3); + * // => 3 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3'); + * // => 3 + */ + function toNumber(value) { + 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; + } + value = value.replace(reTrim, ''); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); + } + /** * Converts `value` to a plain object flattening inherited enumerable * properties of `value` to own properties of the plain object. @@ -9781,38 +10283,55 @@ * @returns {number} Returns the converted integer. * @example * - * _.toSafeInteger('3.14'); - * // => 3 + * _.toSafeInteger(3); + * // => 3 * - * _.toSafeInteger(NaN); + * _.toSafeInteger(Number.MIN_VALUE); * // => 0 * - * _.toSafeInteger(Infinity) + * _.toSafeInteger(Infinity); * // => 9007199254740991 * - * _.toSafeInteger(-Infinity) - * // => -9007199254740991 + * _.toSafeInteger('3'); + * // => 3 */ function toSafeInteger(value) { - return clamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); + return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); } /** - * Converts `value` to a string if it's not one. - * An empty string is returned for `null` and `undefined` values. + * 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. * * @static * @memberOf _ * @category Lang * @param {*} value The value to process. * @returns {string} Returns the string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' */ function toString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } - return value == null ? '' : (value + ''); + if (value == null) { + return ''; + } + if (isSymbol(value)) { + return _Symbol ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } /*------------------------------------------------------------------------*/ @@ -9822,8 +10341,8 @@ * object. Source objects are applied from left to right. Subsequent sources * overwrite property assignments of previous sources. * - * **Note:** This method mutates `object` and is based on - * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). + * **Note:** This method mutates `object` and is loosely based on + * [`Object.assign`](https://mdn.io/Object/assign). * * @static * @memberOf _ @@ -9833,13 +10352,88 @@ * @returns {Object} Returns `object`. * @example * - * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); - * // => { 'user': 'fred', 'age': 40 } + * function Foo() { + * this.c = 3; + * } + * + * function Bar() { + * this.e = 5; + * } + * + * Foo.prototype.d = 4; + * Bar.prototype.f = 6; + * + * _.assign({ 'a': 1 }, new Foo, new Bar); + * // => { 'a': 1, 'c': 3, 'e': 5 } */ var assign = createAssigner(function(object, source) { copyObject(source, keys(source), object); }); + /** + * This method is like `_.assign` except that it iterates over own and + * inherited source properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @alias extend + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * function Bar() { + * this.d = 4; + * } + * + * Foo.prototype.c = 3; + * Bar.prototype.e = 5; + * + * _.assignIn({ 'a': 1 }, new Foo, new Bar); + * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 } + */ + var assignIn = createAssigner(function(object, source) { + copyObject(source, keysIn(source), object); + }); + + /** + * 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 _ + * @alias extendWith + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignInWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var assignInWith = createAssigner(function(object, source, customizer) { + copyObjectWith(source, keysIn(source), object, customizer); + }); + /** * This method is like `_.assign` except that it accepts `customizer` which * is invoked to produce the assigned values. If `customizer` returns `undefined` @@ -9857,12 +10451,14 @@ * @returns {Object} Returns `object`. * @example * - * var defaults = _.partialRight(_.assignWith, function(value, other) { - * return _.isUndefined(value) ? other : value; - * }); + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } * - * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); - * // => { 'user': 'barney', 'age': 36 } + * var defaults = _.partialRight(_.assignWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } */ var assignWith = createAssigner(function(object, source, customizer) { copyObjectWith(source, keys(source), object, customizer); @@ -9893,9 +10489,8 @@ }); /** - * Creates an object that inherits from the given `prototype` object. If a - * `properties` object is provided its own enumerable properties are assigned - * to the created object. + * Creates an object that inherits from the `prototype` object. If a `properties` + * object is provided its own enumerable properties are assigned to the created object. * * @static * @memberOf _ @@ -9950,8 +10545,8 @@ * // => { 'user': 'barney', 'age': 36 } */ var defaults = rest(function(args) { - args.push(undefined, extendDefaults); - return extendWith.apply(undefined, args); + args.push(undefined, assignInDefaults); + return apply(assignInWith, undefined, args); }); /** @@ -9974,50 +10569,7 @@ */ var defaultsDeep = rest(function(args) { args.push(undefined, mergeDefaults); - return mergeWith.apply(undefined, args); - }); - - /** - * This method is like `_.assign` except that it iterates over own and - * inherited source properties. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * _.extend({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); - * // => { 'user': 'fred', 'age': 40 } - */ - var extend = createAssigner(function(object, source) { - copyObject(source, keysIn(source), object); - }); - - /** - * This method is like `_.assignWith` except that it iterates over own and - * inherited source properties. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * var defaults = _.partialRight(_.extendWith, function(value, other) { - * return _.isUndefined(value) ? other : value; - * }); - * - * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); - * // => { 'user': 'barney', 'age': 36 } - */ - var extendWith = createAssigner(function(object, source, customizer) { - copyObjectWith(source, keysIn(source), object, customizer); + return apply(mergeWith, undefined, args); }); /** @@ -10041,15 +10593,15 @@ * _.findKey(users, function(o) { return o.age < 40; }); * // => 'barney' (iteration order is not guaranteed) * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.findKey(users, { 'age': 1, 'active': true }); * // => 'pebbles' * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.findKey(users, ['active', false]); * // => 'fred' * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.findKey(users, 'active'); * // => 'barney' */ @@ -10078,15 +10630,15 @@ * _.findLastKey(users, function(o) { return o.age < 40; }); * // => returns 'pebbles' assuming `_.findKey` returns 'barney' * - * // using the `_.matches` callback shorthand + * // using the `_.matches` iteratee shorthand * _.findLastKey(users, { 'age': 36, 'active': true }); * // => 'barney' * - * // using the `_.matchesProperty` callback shorthand + * // using the `_.matchesProperty` iteratee shorthand * _.findLastKey(users, ['active', false]); * // => 'fred' * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.findLastKey(users, 'active'); * // => 'pebbles' */ @@ -10211,8 +10763,8 @@ } /** - * Creates an array of function property names from all enumerable properties, - * own and inherited, of `object`. + * Creates an array of function property names from own enumerable properties + * of `object`. * * @static * @memberOf _ @@ -10221,10 +10773,42 @@ * @returns {Array} Returns the new array of property names. * @example * - * _.functions(_); - * // => ['after', 'ary', 'assign', ...] + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functions(new Foo); + * // => ['a', 'b'] */ function functions(object) { + return object == null ? [] : baseFunctions(object, keys(object)); + } + + /** + * Creates an array of function property names from own and inherited + * enumerable properties of `object`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the new array of property names. + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ + function functionsIn(object) { return object == null ? [] : baseFunctions(object, keysIn(object)); } @@ -10356,6 +10940,25 @@ }, {}); } + /** + * Invokes the method at `path` of `object`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + * @example + * + * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; + * + * _.invoke(object, 'a[0].b.c.slice', 1, 3); + * // => [2, 3] + */ + var invoke = rest(baseInvoke); + /** * Creates an array of the own enumerable property names of `object`. * @@ -10388,13 +10991,14 @@ if (!(isProto || isArrayLike(object))) { return baseKeys(object); } - var result = initKeys(object), - length = result.length, - skipIndexes = !!length; + var indexes = indexKeys(object), + skipIndexes = !!indexes, + result = indexes || [], + length = result.length; for (var key in object) { if (baseHas(object, key) && - !(skipIndexes && isIndex(key, length)) && + !(skipIndexes && (key == 'length' || isIndex(key, length))) && !(isProto && key == 'constructor')) { result.push(key); } @@ -10429,13 +11033,14 @@ isProto = isPrototype(object), props = baseKeysIn(object), propsLength = props.length, - result = initKeys(object), - length = result.length, - skipIndexes = !!length; + indexes = indexKeys(object), + skipIndexes = !!indexes, + result = indexes || [], + length = result.length; while (++index < propsLength) { var key = props[index]; - if (!(skipIndexes && isIndex(key, length)) && + if (!(skipIndexes && (key == 'length' || isIndex(key, length))) && !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { result.push(key); } @@ -10492,7 +11097,7 @@ * _.mapValues(users, function(o) { return o.age; }); * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) * - * // using the `_.property` callback shorthand + * // using the `_.property` iteratee shorthand * _.mapValues(users, 'age'); * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) */ @@ -10510,7 +11115,7 @@ * Recursively merges own and inherited enumerable properties of source * objects into the destination object, skipping source properties that resolve * to `undefined`. Array and plain object properties are merged recursively. - * Other objects and value types are overriden by assignment. Source objects + * 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. * @@ -10555,6 +11160,12 @@ * @returns {Object} Returns `object`. * @example * + * function customizer(objValue, srcValue) { + * if (_.isArray(objValue)) { + * return objValue.concat(srcValue); + * } + * } + * * var object = { * 'fruits': ['apple'], * 'vegetables': ['beet'] @@ -10565,11 +11176,7 @@ * 'vegetables': ['carrot'] * }; * - * _.mergeWith(object, other, function(a, b) { - * if (_.isArray(a)) { - * return a.concat(b); - * } - * }); + * _.mergeWith(object, other, customizer); * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } */ var mergeWith = createAssigner(function(object, source, customizer) { @@ -10584,15 +11191,15 @@ * @memberOf _ * @category Object * @param {Object} object The source object. - * @param {string|string[]} [props] The property names to omit, specified + * @param {...(string|string[])} [props] The property names to omit, specified * individually or in arrays.. * @returns {Object} Returns the new object. * @example * - * var object = { 'user': 'fred', 'age': 40 }; + * var object = { 'a': 1, 'b': '2', 'c': 3 }; * - * _.omit(object, 'user'); - * // => { 'age': 40 } + * _.omit(object, ['a', 'c']); + * // => { 'b': '2' } */ var omit = rest(function(object, props) { if (object == null) { @@ -10615,10 +11222,10 @@ * @returns {Object} Returns the new object. * @example * - * var object = { 'user': 'fred', 'age': 40 }; + * var object = { 'a': 1, 'b': '2', 'c': 3 }; * * _.omitBy(object, _.isNumber); - * // => { 'user': 'fred' } + * // => { 'b': '2' } */ function omitBy(object, predicate) { predicate = getIteratee(predicate); @@ -10627,26 +11234,6 @@ }); } - /** - * Creates an array of the key-value pairs for `object`, - * e.g. `[[key1, value1], [key2, value2]]`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the new array of key-value pairs. - * @example - * - * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) - */ - function pairs(object) { - return arrayMap(keys(object), function(key) { - return [key, object[key]]; - }); - } - /** * Creates an object composed of the picked `object` properties. * @@ -10654,15 +11241,15 @@ * @memberOf _ * @category Object * @param {Object} object The source object. - * @param {string|string[]} [props] The property names to pick, specified + * @param {...(string|string[])} [props] The property names to pick, specified * individually or in arrays. * @returns {Object} Returns the new object. * @example * - * var object = { 'user': 'fred', 'age': 40 }; + * var object = { 'a': 1, 'b': '2', 'c': 3 }; * - * _.pick(object, 'user'); - * // => { 'user': 'fred' } + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } */ var pick = rest(function(object, props) { return object == null ? {} : basePick(object, baseFlatten(props)); @@ -10680,10 +11267,10 @@ * @returns {Object} Returns the new object. * @example * - * var object = { 'user': 'fred', 'age': 40 }; + * var object = { 'a': 1, 'b': '2', 'c': 3 }; * * _.pickBy(object, _.isNumber); - * // => { 'age': 40 } + * // => { 'a': 1, 'c': 3 } */ function pickBy(object, predicate) { return object == null ? {} : basePickBy(object, getIteratee(predicate)); @@ -10711,10 +11298,10 @@ * _.result(object, 'a[0].b.c2'); * // => 4 * - * _.result(object, 'a.b.c', 'default'); + * _.result(object, 'a[0].b.c3', 'default'); * // => 'default' * - * _.result(object, 'a.b.c', _.constant('default')); + * _.result(object, 'a[0].b.c3', _.constant('default')); * // => 'default' */ function result(object, path, defaultValue) { @@ -10732,8 +11319,10 @@ } /** - * Sets the value at `path` of `object`. If a portion of `path` doesn't - * exist it's created. + * 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 + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. * * @static * @memberOf _ @@ -10774,11 +11363,7 @@ * @returns {Object} Returns `object`. * @example * - * _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, function(value) { - * if (!_.isObject(value)) { - * return {}; - * } - * }); + * _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, Object); * // => { '0': { '1': { '2': 3 }, 'length': 2 } } */ function setWith(object, path, value, customizer) { @@ -10786,6 +11371,54 @@ return object == null ? object : baseSet(object, path, value, customizer); } + /** + * Creates an array of own enumerable key-value pairs for `object`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the new array of key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairs(new Foo); + * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) + */ + function toPairs(object) { + return baseToPairs(object, keys(object)); + } + + /** + * Creates an array of own and inherited enumerable key-value pairs for `object`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the new array of key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairsIn(new Foo); + * // => [['a', 1], ['b', 2], ['c', 1]] (iteration order is not guaranteed) + */ + function toPairsIn(object) { + return baseToPairs(object, keysIn(object)); + } + /** * An alternative to `_.reduce`; this method transforms `object` to a new * `accumulator` object which is the result of running each of its own enumerable @@ -10894,8 +11527,7 @@ } /** - * Creates an array of the own and inherited enumerable property values - * of `object`. + * Creates an array of the own and inherited enumerable property values of `object`. * * **Note:** Non-object values are coerced to objects. * @@ -10923,16 +11555,15 @@ /*------------------------------------------------------------------------*/ /** - * Returns a number whose value is limited to the given range specified - * by `min` and `max`. + * Clamps `number` within the inclusive `lower` and `upper` bounds. * * @static * @memberOf _ * @category Number - * @param {number} number The number whose value is to be limited. - * @param {number} [min] The minimum possible value. - * @param {number} max The maximum possible value. - * @returns {number} A number in the range [min, max]. + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. * @example * * _.clamp(-10, -5, 5); @@ -10941,20 +11572,20 @@ * _.clamp(10, -5, 5); * // => 5 */ - function clamp(number, min, max) { - if (max === undefined) { - max = min; - min = undefined; + function clamp(number, lower, upper) { + if (upper === undefined) { + upper = lower; + lower = undefined; } - if (max !== undefined) { - max = +max; - number = nativeMin(number, max === max ? max : 0); + if (upper !== undefined) { + upper = toNumber(upper); + upper = upper === upper ? upper : 0; } - if (min !== undefined) { - min = +min; - number = nativeMax(number, min === min ? min : 0); + if (lower !== undefined) { + lower = toNumber(lower); + lower = lower === lower ? lower : 0; } - return number; + return baseClamp(toNumber(number), lower, upper); } /** @@ -10994,21 +11625,22 @@ * // => true */ function inRange(number, start, end) { - start = +start || 0; + start = toNumber(start) || 0; if (end === undefined) { end = start; start = 0; } else { - end = +end || 0; + end = toNumber(end) || 0; } - return number >= nativeMin(start, end) && number < nativeMax(start, end); + number = toNumber(number); + return baseInRange(number, start, end); } /** - * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number is returned. - * If `floating` is `true`, or either `min` or `max` are floats, a - * floating-point number is returned instead of an integer. + * 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. * * **Note:** JavaScript follows the IEEE-754 standard for resolving * floating-point values which can produce unexpected results. @@ -11016,8 +11648,8 @@ * @static * @memberOf _ * @category Number - * @param {number} [min=0] The minimum possible value. - * @param {number} [max=1] The maximum possible value. + * @param {number} [lower=0] The lower bound. + * @param {number} [upper=1] The upper bound. * @param {boolean} [floating] Specify returning a floating-point number. * @returns {number} Returns the random number. * @example @@ -11034,39 +11666,43 @@ * _.random(1.2, 5.2); * // => a floating-point number between 1.2 and 5.2 */ - function random(min, max, floating) { - if (floating && isIterateeCall(min, max, floating)) { - max = floating = undefined; + function random(lower, upper, floating) { + if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { + upper = floating = undefined; } - var noMin = min === undefined, - noMax = max === undefined; - if (floating === undefined) { - if (noMax && typeof min == 'boolean') { - floating = min; - min = 1; + if (typeof upper == 'boolean') { + floating = upper; + upper = undefined; } - else if (typeof max == 'boolean') { - floating = max; - noMax = true; + else if (typeof lower == 'boolean') { + floating = lower; + lower = undefined; } } - if (noMin && noMax) { - max = 1; - noMax = false; + if (lower === undefined && upper === undefined) { + lower = 0; + upper = 1; } - min = +min || 0; - if (noMax) { - max = min; - min = 0; - } else { - max = +max || 0; + else { + lower = toNumber(lower) || 0; + if (upper === undefined) { + upper = lower; + lower = 0; + } else { + upper = toNumber(upper) || 0; + } } - if (floating || min % 1 || max % 1) { + if (lower > upper) { + var temp = lower; + lower = upper; + upper = temp; + } + if (floating || lower % 1 || upper % 1) { var rand = nativeRandom(); - return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max); + return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); } - return baseRandom(min, max); + return baseRandom(lower, upper); } /*------------------------------------------------------------------------*/ @@ -11160,7 +11796,7 @@ var length = string.length; position = position === undefined ? length - : clamp(toInteger(position), 0, length); + : baseClamp(toInteger(position), 0, length); position -= target.length; return position >= 0 && string.indexOf(target, position) == position; @@ -11170,8 +11806,8 @@ * Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to * their corresponding HTML entities. * - * **Note:** No other characters are escaped. To escape additional characters - * use a third-party library like [_he_](https://mths.be/he). + * **Note:** No other characters are escaped. To escape additional + * characters use a third-party library like [_he_](https://mths.be/he). * * Though the ">" character is escaped for symmetry, characters like * ">" and "/" don't need escaping in HTML and have no special meaning @@ -11179,8 +11815,8 @@ * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. * - * Backticks are escaped because in Internet Explorer < 9, they can break out - * of attribute values or HTML comments. See [#59](https://html5sec.org/#59), + * 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. @@ -11345,33 +11981,6 @@ return createPadding('', leftLength, chars) + string + createPadding('', rightLength, chars); } - /** - * Pads `string` on the left side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * _.padLeft('abc', 6); - * // => ' abc' - * - * _.padLeft('abc', 6, '_-'); - * // => '_-_abc' - * - * _.padLeft('abc', 3); - * // => 'abc' - */ - function padLeft(string, length, chars) { - string = toString(string); - return createPadding(string, length, chars) + string; - } - /** * Pads `string` on the right side if it's shorter than `length`. Padding * characters are truncated if they exceed `length`. @@ -11385,20 +11994,47 @@ * @returns {string} Returns the padded string. * @example * - * _.padRight('abc', 6); + * _.padEnd('abc', 6); * // => 'abc ' * - * _.padRight('abc', 6, '_-'); + * _.padEnd('abc', 6, '_-'); * // => 'abc_-_' * - * _.padRight('abc', 3); + * _.padEnd('abc', 3); * // => 'abc' */ - function padRight(string, length, chars) { + function padEnd(string, length, chars) { string = toString(string); return string + createPadding(string, length, chars); } + /** + * Pads `string` on the left side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padStart('abc', 6); + * // => ' abc' + * + * _.padStart('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padStart('abc', 3); + * // => 'abc' + */ + function padStart(string, length, chars) { + string = toString(string); + return createPadding(string, length, chars) + 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, @@ -11430,7 +12066,7 @@ } else if (radix) { radix = +radix; } - string = trim(string); + string = toString(string).replace(reTrim, ''); return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); } @@ -11475,6 +12111,30 @@ return result; } + /** + * Replaces matches for `pattern` in `string` with `replacement`. + * + * **Note:** This method is based on [`String#replace`](https://mdn.io/String/replace). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to modify. + * @param {RegExp|string} pattern The pattern to replace. + * @param {Function|string} replacement The match replacement. + * @returns {string} Returns the modified string. + * @example + * + * _.replace('Hi Fred', 'Fred', 'Barney'); + * // => 'Hi Barney' + */ + function replace() { + var args = arguments, + string = toString(args[0]); + + return args.length < 3 ? string : string.replace(args[1], args[2]); + } + /** * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). * @@ -11498,6 +12158,27 @@ return result + (index ? '_' : '') + word.toLowerCase(); }); + /** + * Splits `string` by `separator`. + * + * **Note:** This method is based on [`String#split`](https://mdn.io/String/split). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to split. + * @param {RegExp|string} separator The separator pattern to split by. + * @param {number} [limit] The length to truncate results to. + * @returns {Array} Returns the new array of string segments. + * @example + * + * _.split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ + function split(string, separator, limit) { + return toString(string).split(separator, limit); + } + /** * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). * @@ -11544,7 +12225,7 @@ */ function startsWith(string, target, position) { string = toString(string); - position = clamp(toInteger(position), 0, string.length); + position = baseClamp(toInteger(position), 0, string.length); return string.lastIndexOf(target, position) == position; } @@ -11576,7 +12257,7 @@ * @param {RegExp} [options.interpolate] The "interpolate" delimiter. * @param {string} [options.sourceURL] The sourceURL of the template's compiled source. * @param {string} [options.variable] The data object variable name. - * @param- {Object} [otherOptions] Enables the legacy `options` param signature. + * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. * @returns {Function} Returns the compiled template function. * @example * @@ -11644,18 +12325,18 @@ * };\ * '); */ - function template(string, options, otherOptions) { + function template(string, options, guard) { // 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; - if (otherOptions && isIterateeCall(string, options, otherOptions)) { - options = otherOptions = undefined; + if (guard && isIterateeCall(string, options, guard)) { + options = undefined; } string = toString(string); - options = extendWith({}, otherOptions || options, settings, extendDefaults); + options = assignInWith({}, options, settings, assignInDefaults); - var imports = extendWith({}, options.imports, settings.imports, extendDefaults), + var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys); @@ -11823,7 +12504,7 @@ return string; } if (guard || chars === undefined) { - return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); + return string.replace(reTrim, ''); } chars = (chars + ''); if (!chars) { @@ -11832,41 +12513,7 @@ var strSymbols = stringToArray(string), chrSymbols = stringToArray(chars); - return strSymbols.slice(charsLeftIndex(strSymbols, chrSymbols), charsRightIndex(strSymbols, chrSymbols) + 1).join(''); - } - - /** - * Removes leading whitespace or specified characters from `string`. - * - * @static - * @memberOf _ - * @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`. - * @returns {string} Returns the trimmed string. - * @example - * - * _.trimLeft(' abc '); - * // => 'abc ' - * - * _.trimLeft('-_-abc-_-', '_-'); - * // => 'abc-_-' - */ - function trimLeft(string, chars, guard) { - string = toString(string); - if (!string) { - return string; - } - if (guard || chars === undefined) { - return string.slice(trimmedLeftIndex(string)); - } - chars = (chars + ''); - if (!chars) { - return string; - } - var strSymbols = stringToArray(string); - return strSymbols.slice(charsLeftIndex(strSymbols, stringToArray(chars))).join(''); + return strSymbols.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1).join(''); } /** @@ -11881,26 +12528,60 @@ * @returns {string} Returns the trimmed string. * @example * - * _.trimRight(' abc '); + * _.trimEnd(' abc '); * // => ' abc' * - * _.trimRight('-_-abc-_-', '_-'); + * _.trimEnd('-_-abc-_-', '_-'); * // => '-_-abc' */ - function trimRight(string, chars, guard) { + function trimEnd(string, chars, guard) { string = toString(string); if (!string) { return string; } if (guard || chars === undefined) { - return string.slice(0, trimmedRightIndex(string) + 1); + return string.replace(reTrimEnd, ''); } chars = (chars + ''); if (!chars) { return string; } var strSymbols = stringToArray(string); - return strSymbols.slice(0, charsRightIndex(strSymbols, stringToArray(chars)) + 1).join(''); + return strSymbols.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1).join(''); + } + + /** + * Removes leading whitespace or specified characters from `string`. + * + * @static + * @memberOf _ + * @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`. + * @returns {string} Returns the trimmed string. + * @example + * + * _.trimStart(' abc '); + * // => 'abc ' + * + * _.trimStart('-_-abc-_-', '_-'); + * // => 'abc-_-' + */ + function trimStart(string, chars, guard) { + string = toString(string); + if (!string) { + return string; + } + if (guard || chars === undefined) { + return string.replace(reTrimStart, ''); + } + chars = (chars + ''); + if (!chars) { + return string; + } + var strSymbols = stringToArray(string); + return strSymbols.slice(charsStartIndex(strSymbols, stringToArray(chars))).join(''); } /** @@ -11919,27 +12600,27 @@ * @returns {string} Returns the truncated string. * @example * - * _.trunc('hi-diddly-ho there, neighborino'); + * _.truncate('hi-diddly-ho there, neighborino'); * // => 'hi-diddly-ho there, neighbo...' * - * _.trunc('hi-diddly-ho there, neighborino', { + * _.truncate('hi-diddly-ho there, neighborino', { * 'length': 24, * 'separator': ' ' * }); * // => 'hi-diddly-ho there,...' * - * _.trunc('hi-diddly-ho there, neighborino', { + * _.truncate('hi-diddly-ho there, neighborino', { * 'length': 24, * 'separator': /,? +/ * }); * // => 'hi-diddly-ho there...' * - * _.trunc('hi-diddly-ho there, neighborino', { + * _.truncate('hi-diddly-ho there, neighborino', { * 'omission': ' [...]' * }); * // => 'hi-diddly-ho there, neig [...]' */ - function trunc(string, options) { + function truncate(string, options) { var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; @@ -12079,7 +12760,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Function} func The function to attempt. * @returns {*} Returns the `func` result or error object. * @example @@ -12095,18 +12776,125 @@ */ var attempt = rest(function(func, args) { try { - return func.apply(undefined, args); + return apply(func, undefined, args); } catch (e) { return isError(e) ? e : new Error(e); } }); + /** + * Binds methods of an object to the object itself, overwriting the existing + * method. + * + * **Note:** This method doesn't set the "length" property of bound functions. + * + * @static + * @memberOf _ + * @category Util + * @param {Object} object The object to bind and assign the bound methods to. + * @param {...(string|string[])} methodNames The object method names to bind, + * specified individually or in arrays. + * @returns {Object} Returns `object`. + * @example + * + * var view = { + * 'label': 'docs', + * 'onClick': function() { + * console.log('clicked ' + this.label); + * } + * }; + * + * _.bindAll(view, 'onClick'); + * jQuery(element).on('click', view.onClick); + * // => logs 'clicked docs' when clicked + */ + var bindAll = rest(function(object, methodNames) { + arrayEach(baseFlatten(methodNames), function(key) { + object[key] = bind(object[key], object); + }); + return object; + }); + + /** + * 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. + * + * @static + * @memberOf _ + * @category Util + * @param {Array} pairs The predicate-function pairs. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.cond([ + * [_.matches({ 'a': 1 }), _.constant('matches A')], + * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], + * [_.constant(true), _.constant('no match')] + * ]) + * + * func({ 'a': 1, 'b': 2 }); + * // => 'matches A' + * + * func({ 'a': 0, 'b': 1 }); + * // => 'matches B' + * + * func({ 'a': '1', 'b': '2' }); + * // => 'no match' + */ + function cond(pairs) { + var length = pairs ? pairs.length : 0, + toIteratee = getIteratee(); + + pairs = !length ? [] : arrayMap(pairs, function(pair) { + if (typeof pair[1] != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return [toIteratee(pair[0]), pair[1]]; + }); + + return rest(function(args) { + var index = -1; + while (++index < length) { + var pair = pairs[index]; + if (apply(pair[0], this, args)) { + return apply(pair[1], this, args); + } + } + }); + } + + /** + * 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`. + * + * @static + * @memberOf _ + * @category Util + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new function. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.filter(users, _.conforms({ 'age': _.partial(_.gt, _, 38) })); + * // => [{ 'user': 'fred', 'age': 40 }] + */ + function conforms(source) { + return baseConforms(baseClone(source, true)); + } + /** * Creates a function that returns `value`. * * @static * @memberOf _ - * @category Utility + * @category Util * @param {*} value The value to return from the new function. * @returns {Function} Returns the new function. * @example @@ -12123,12 +12911,55 @@ }; } + /** + * Creates a function that returns the result of invoking the provided + * functions with the `this` binding of the created function, where each + * successive invocation is supplied the return value of the previous. + * + * @static + * @memberOf _ + * @category Util + * @param {...(Function|Function[])} [funcs] Functions to invoke. + * @returns {Function} Returns the new function. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flow(_.add, square); + * addSquare(1, 2); + * // => 9 + */ + var flow = createFlow(); + + /** + * This method is like `_.flow` except that it creates a function that + * invokes the provided functions from right to left. + * + * @static + * @memberOf _ + * @category Util + * @param {...(Function|Function[])} [funcs] Functions to invoke. + * @returns {Function} Returns the new function. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flowRight(square, _.add); + * addSquare(1, 2); + * // => 9 + */ + var flowRight = createFlow(true); + /** * This method returns the first argument provided to it. * * @static * @memberOf _ - * @category Utility + * @category Util * @param {*} value Any value. * @returns {*} Returns `value`. * @example @@ -12150,7 +12981,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {*} [func=_.identity] The value to convert to a callback. * @returns {Function} Returns the callback. * @example @@ -12160,20 +12991,15 @@ * { 'user': 'fred', 'age': 40 } * ]; * - * // wrap to create custom callback shorthands - * _.iteratee = _.wrap(_.iteratee, function(callback, func, thisArg) { - * var match = /^(.+?)__([gl]t)(.+)$/.exec(func); - * if (!match) { - * return callback(func, thisArg); - * } - * return function(object) { - * return match[2] == 'gt' - * ? object[match[1]] > match[3] - * : object[match[1]] < match[3]; + * // 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]); * }; * }); * - * _.filter(users, 'age__gt36'); + * _.filter(users, 'age > 36'); * // => [{ 'user': 'fred', 'age': 40 }] */ function iteratee(func) { @@ -12183,18 +13009,15 @@ } /** - * Creates a function that performs a deep comparison between a given object - * and `source`, returning `true` if the given object has equivalent property - * values, else `false`. + * Creates a function that performs a deep partial comparison between a given + * object and `source`, returning `true` if the given object has equivalent + * property values, else `false`. * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. Objects are compared by - * their own and inherited enumerable properties. For comparing a single - * value see `_.matchesProperty`. + * **Note:** This method supports comparing the same values as `_.isEqual`. * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Object} source The object of property values to match. * @returns {Function} Returns the new function. * @example @@ -12212,15 +13035,15 @@ } /** - * Creates a function that compares the value at `path` of a given object - * to `srcValue`. + * Creates a function that performs a deep partial comparison between the + * value at `path` of a given object to `srcValue`, returning `true` if the + * object value is equivalent, else `false`. * - * **Note:** This method supports comparing arrays, booleans, `Date` objects, - * numbers, `Object` objects, regexes, and strings. + * **Note:** This method supports comparing the same values as `_.isEqual`. * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Array|string} path The path of the property to get. * @param {*} srcValue The value to match. * @returns {Function} Returns the new function. @@ -12244,7 +13067,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Array|string} path The path of the method to invoke. * @param {...*} [args] The arguments to invoke the method with. * @returns {Function} Returns the new function. @@ -12258,12 +13081,12 @@ * _.map(objects, _.method('a.b.c')); * // => [2, 1] * - * _.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); + * _.invokeMap(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); * // => [1, 2] */ var method = rest(function(path, args) { return function(object) { - return invokePath(object, path, args); + return baseInvoke(object, path, args); }; }); @@ -12274,7 +13097,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Object} object The object to query. * @param {...*} [args] The arguments to invoke the method with. * @returns {Function} Returns the new function. @@ -12291,7 +13114,7 @@ */ var methodOf = rest(function(object, args) { return function(path) { - return invokePath(object, path, args); + return baseInvoke(object, path, args); }; }); @@ -12305,7 +13128,7 @@ * * @static * @memberOf _ - * @category Utility + * @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. @@ -12373,7 +13196,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @returns {Function} Returns the `lodash` function. * @example * @@ -12390,7 +13213,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @example * * var object = { 'user': 'fred' }; @@ -12402,12 +13225,100 @@ // No operation performed. } + /** + * Creates a function that returns its nth argument. + * + * @static + * @memberOf _ + * @category Util + * @param {number} [n=0] The index of the argument to return. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.nthArg(1); + * + * func('a', 'b', 'c'); + * // => 'b' + */ + function nthArg(n) { + n = toInteger(n); + return function() { + return arguments[n]; + }; + } + + /** + * Creates a function that invokes `iteratees` with the arguments provided + * to the created function and returns their results. + * + * @static + * @memberOf _ + * @category Util + * @param {...(Function|Function[])} iteratees The iteratees to invoke. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.over(Math.max, Math.min); + * + * func(1, 2, 3, 4); + * // => [4, 1] + */ + var over = createOver(arrayMap); + + /** + * Creates a function that checks if **all** of the `predicates` return + * truthy when invoked with the arguments provided to the created function. + * + * @static + * @memberOf _ + * @category Util + * @param {...(Function|Function[])} predicates The predicates to check. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.overEvery(Boolean, isFinite); + * + * func('1'); + * // => true + * + * func(null); + * // => false + * + * func(NaN); + * // => false + */ + var overEvery = createOver(arrayEvery); + + /** + * Creates a function that checks if **any** of the `predicates` return + * truthy when invoked with the arguments provided to the created function. + * + * @static + * @memberOf _ + * @category Util + * @param {...(Function|Function[])} predicates The predicates to check. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.overSome(Boolean, isFinite); + * + * func('1'); + * // => true + * + * func(null); + * // => true + * + * func(NaN); + * // => false + */ + var overSome = createOver(arraySome); + /** * Creates a function that returns the value at `path` of a given object. * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new function. * @example @@ -12433,7 +13344,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {Object} object The object to query. * @returns {Function} Returns the new function. * @example @@ -12455,16 +13366,17 @@ /** * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to, but not including, `end`. If `end` is not specified it's - * set to `start` with `start` then set to `0`. If `end` is less than `start` - * a zero-length range is created unless a negative `step` is specified. + * `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`. If `end` is less than + * `start` a zero-length range is created unless a negative `step` is specified. * * **Note:** JavaScript follows the IEEE-754 standard for resolving * floating-point values which can produce unexpected results. * * @static * @memberOf _ - * @category Utility + * @category Util * @param {number} [start=0] The start of the range. * @param {number} end The end of the range. * @param {number} [step=1] The value to increment or decrement by. @@ -12474,6 +13386,9 @@ * _.range(4); * // => [0, 1, 2, 3] * + * _.range(-4); + * // => [0, -1, -2, -3] + * * _.range(1, 5); * // => [1, 2, 3, 4] * @@ -12489,25 +13404,43 @@ * _.range(0); * // => [] */ - function range(start, end, step) { - if (step && isIterateeCall(start, end, step)) { - end = step = undefined; - } - start = +start; - start = start === start ? start : 0; - step = step === undefined ? 1 : (+step || 0); + var range = createRange(); - if (end === undefined) { - end = start; - start = 0; - } else { - end = +end || 0; - } - var n = nativeMax(nativeCeil((end - start) / (step || 1)), 0); - return baseTimes(n, function(index) { - return index ? (start += step) : start; - }); - } + /** + * This method is like `_.range` except that it populates values in + * descending order. + * + * @static + * @memberOf _ + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the new array of numbers. + * @example + * + * _.rangeRight(4); + * // => [3, 2, 1, 0] + * + * _.rangeRight(-4); + * // => [-3, -2, -1, 0] + * + * _.rangeRight(1, 5); + * // => [4, 3, 2, 1] + * + * _.rangeRight(0, 20, 5); + * // => [15, 10, 5, 0] + * + * _.rangeRight(0, -4, -1); + * // => [-3, -2, -1, 0] + * + * _.rangeRight(1, 4, 0); + * // => [1, 1, 1] + * + * _.rangeRight(0); + * // => [] + */ + var rangeRight = createRange(true); /** * Invokes the iteratee function `n` times, returning an array of the results @@ -12515,19 +13448,17 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {number} n The number of times to invoke `iteratee`. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Array} Returns the array of results. * @example * - * var diceRolls = _.times(3, _.partial(_.random, 1, 6, false)); - * // => [3, 6, 4] + * _.times(3, String); + * // => ['0', '1', '2'] * - * _.times(3, function(n) { - * mage.castSpell(n); - * }); - * // => invokes `mage.castSpell` three times with `n` of `0`, `1`, and `2` + * _.times(4, _.constant(true)); + * // => [true, true, true, true] */ function times(n, iteratee) { n = toInteger(n); @@ -12552,7 +13483,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {*} value The value to convert. * @returns {Array} Returns the new property path array. * @example @@ -12581,7 +13512,7 @@ * * @static * @memberOf _ - * @category Utility + * @category Util * @param {string} [prefix] The value to prefix the ID with. * @returns {string} Returns the unique ID. * @example @@ -12605,9 +13536,9 @@ * @static * @memberOf _ * @category Math - * @param {number} augend The first number to add. - * @param {number} addend The second number to add. - * @returns {number} Returns the sum. + * @param {number} augend The first number in an addition. + * @param {number} addend The second number in an addition. + * @returns {number} Returns the total. * @example * * _.add(6, 4); @@ -12615,17 +13546,17 @@ */ function add(augend, addend) { var result; - if (augend === augend && augend != null) { + if (augend !== undefined) { result = augend; } - if (addend === addend && addend != null) { + if (addend !== undefined) { result = result === undefined ? addend : (result + addend); } return result; } /** - * Calculates `number` rounded up to `precision`. + * Computes `number` rounded up to `precision`. * * @static * @memberOf _ @@ -12647,7 +13578,7 @@ var ceil = createRound('ceil'); /** - * Calculates `number` rounded down to `precision`. + * Computes `number` rounded down to `precision`. * * @static * @memberOf _ @@ -12669,7 +13600,7 @@ var floor = createRound('floor'); /** - * Gets the maximum value of `array`. If `array` is empty or falsey + * Computes the maximum value of `array`. If `array` is empty or falsey * `undefined` is returned. * * @static @@ -12700,21 +13631,18 @@ * @memberOf _ * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {*} Returns the maximum value. * @example * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; + * var objects = [{ 'n': 1 }, { 'n': 2 }]; * - * _.maxBy(users, function(o) { return o.age; }); - * // => { 'user': 'fred', 'age': 40 } + * _.maxBy(objects, function(o) { return o.a; }); + * // => { 'n': 2 } * - * // using the `_.property` callback shorthand - * _.maxBy(users, 'age'); - * // => { 'user': 'fred', 'age': 40 } + * // using the `_.property` iteratee shorthand + * _.maxBy(objects, 'n'); + * // => { 'n': 2 } */ function maxBy(array, iteratee) { return (array && array.length) @@ -12723,7 +13651,24 @@ } /** - * Gets the minimum value of `array`. If `array` is empty or falsey + * Computes the mean of the values in `array`. + * + * @static + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {number} Returns the mean. + * @example + * + * _.mean([4, 2, 8, 6]); + * // => 5 + */ + function mean(array) { + return sum(array) / (array ? array.length : 0); + } + + /** + * Computes the minimum value of `array`. If `array` is empty or falsey * `undefined` is returned. * * @static @@ -12754,21 +13699,18 @@ * @memberOf _ * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {*} Returns the minimum value. * @example * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; + * var objects = [{ 'n': 1 }, { 'n': 2 }]; * - * _.minBy(users, function(o) { return o.age; }); - * // => { 'user': 'barney', 'age': 36 } + * _.minBy(objects, function(o) { return o.a; }); + * // => { 'n': 1 } * - * // using the `_.property` callback shorthand - * _.minBy(users, 'age'); - * // => { 'user': 'barney', 'age': 36 } + * // using the `_.property` iteratee shorthand + * _.minBy(objects, 'n'); + * // => { 'n': 1 } */ function minBy(array, iteratee) { return (array && array.length) @@ -12777,7 +13719,7 @@ } /** - * Calculates `number` rounded to `precision`. + * Computes `number` rounded to `precision`. * * @static * @memberOf _ @@ -12799,7 +13741,32 @@ var round = createRound('round'); /** - * Gets the sum of the values in `array`. + * Subtract two numbers. + * + * @static + * @memberOf _ + * @category Math + * @param {number} minuend The first number in a subtraction. + * @param {number} subtrahend The second number in a subtraction. + * @returns {number} Returns the difference. + * @example + * + * _.subtract(6, 4); + * // => 2 + */ + function subtract(minuend, subtrahend) { + var result; + if (minuend !== undefined) { + result = minuend; + } + if (subtrahend !== undefined) { + result = result === undefined ? subtrahend : (result - subtrahend); + } + return result; + } + + /** + * Computes the sum of the values in `array`. * * @static * @memberOf _ @@ -12808,8 +13775,8 @@ * @returns {number} Returns the sum. * @example * - * _.sum([4, 6]); - * // => 10 + * _.sum([4, 2, 8, 6]); + * // => 20 */ function sum(array) { return (array && array.length) @@ -12826,21 +13793,18 @@ * @memberOf _ * @category Math * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @returns {number} Returns the sum. * @example * - * var objects = [ - * { 'n': 4 }, - * { 'n': 6 } - * ]; + * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; * - * _.sum(objects, function(o) { return o.n; }); - * // => 10 + * _.sumBy(objects, function(o) { return o.n; }); + * // => 20 * - * // using the `_.property` callback shorthand - * _.sum(objects, 'n'); - * // => 10 + * // using the `_.property` iteratee shorthand + * _.sumBy(objects, 'n'); + * // => 20 */ function sumBy(array, iteratee) { return (array && array.length) @@ -12863,6 +13827,7 @@ 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; @@ -12872,6 +13837,7 @@ 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; @@ -12884,6 +13850,8 @@ lodash.after = after; lodash.ary = ary; lodash.assign = assign; + lodash.assignIn = assignIn; + lodash.assignInWith = assignInWith; lodash.assignWith = assignWith; lodash.at = at; lodash.before = before; @@ -12893,7 +13861,9 @@ lodash.chain = chain; lodash.chunk = chunk; lodash.compact = compact; - lodash.conj = conj; + lodash.concat = concat; + lodash.cond = cond; + lodash.conforms = conforms; lodash.constant = constant; lodash.countBy = countBy; lodash.create = create; @@ -12906,29 +13876,30 @@ lodash.delay = delay; lodash.difference = difference; lodash.differenceBy = differenceBy; - lodash.disj = disj; + lodash.differenceWith = differenceWith; lodash.drop = drop; lodash.dropRight = dropRight; lodash.dropRightWhile = dropRightWhile; lodash.dropWhile = dropWhile; - lodash.extend = extend; - lodash.extendWith = extendWith; lodash.fill = fill; lodash.filter = filter; + lodash.flatMap = flatMap; lodash.flatten = flatten; lodash.flattenDeep = flattenDeep; lodash.flip = flip; lodash.flow = flow; lodash.flowRight = flowRight; + lodash.fromPairs = fromPairs; lodash.functions = functions; + lodash.functionsIn = functionsIn; lodash.groupBy = groupBy; lodash.initial = initial; lodash.intersection = intersection; lodash.intersectionBy = intersectionBy; + lodash.intersectionWith = intersectionWith; lodash.invert = invert; - lodash.invoke = invoke; + lodash.invokeMap = invokeMap; lodash.iteratee = iteratee; - lodash.juxt = juxt; lodash.keyBy = keyBy; lodash.keys = keys; lodash.keysIn = keysIn; @@ -12943,13 +13914,16 @@ lodash.method = method; lodash.methodOf = methodOf; lodash.mixin = mixin; - lodash.modArgs = modArgs; - lodash.modArgsSet = modArgsSet; lodash.negate = negate; + lodash.nthArg = nthArg; lodash.omit = omit; lodash.omitBy = omitBy; lodash.once = once; - lodash.pairs = pairs; + lodash.orderBy = orderBy; + lodash.over = over; + lodash.overArgs = overArgs; + lodash.overEvery = overEvery; + lodash.overSome = overSome; lodash.partial = partial; lodash.partialRight = partialRight; lodash.partition = partition; @@ -12962,6 +13936,7 @@ lodash.pullAllBy = pullAllBy; lodash.pullAt = pullAt; lodash.range = range; + lodash.rangeRight = rangeRight; lodash.rearg = rearg; lodash.reject = reject; lodash.remove = remove; @@ -12973,9 +13948,9 @@ lodash.shuffle = shuffle; lodash.slice = slice; lodash.sortBy = sortBy; - lodash.sortByOrder = sortByOrder; lodash.sortedUniq = sortedUniq; lodash.sortedUniqBy = sortedUniqBy; + lodash.split = split; lodash.spread = spread; lodash.tail = tail; lodash.take = take; @@ -12985,15 +13960,19 @@ lodash.tap = tap; lodash.throttle = throttle; lodash.thru = thru; - lodash.times = times; lodash.toArray = toArray; + lodash.toPairs = toPairs; + lodash.toPairsIn = toPairsIn; lodash.toPath = toPath; lodash.toPlainObject = toPlainObject; lodash.transform = transform; + lodash.unary = unary; lodash.union = union; lodash.unionBy = unionBy; + lodash.unionWith = unionWith; lodash.uniq = uniq; lodash.uniqBy = uniqBy; + lodash.uniqWith = uniqWith; lodash.unset = unset; lodash.unzip = unzip; lodash.unzipWith = unzipWith; @@ -13004,6 +13983,7 @@ lodash.wrap = wrap; lodash.xor = xor; lodash.xorBy = xorBy; + lodash.xorWith = xorWith; lodash.zip = zip; lodash.zipObject = zipObject; lodash.zipWith = zipWith; @@ -13011,6 +13991,8 @@ // Add aliases. lodash.each = forEach; lodash.eachRight = forEachRight; + lodash.extend = assignIn; + lodash.extendWith = assignInWith; // Add functions to `lodash.prototype`. mixin(lodash, lodash); @@ -13057,6 +14039,7 @@ lodash.includes = includes; lodash.indexOf = indexOf; lodash.inRange = inRange; + lodash.invoke = invoke; lodash.isArguments = isArguments; lodash.isArray = isArray; lodash.isArrayLike = isArrayLike; @@ -13071,6 +14054,7 @@ lodash.isFinite = isFinite; lodash.isFunction = isFunction; lodash.isInteger = isInteger; + lodash.isLength = isLength; lodash.isMatch = isMatch; lodash.isMatchWith = isMatchWith; lodash.isNaN = isNaN; @@ -13084,8 +14068,10 @@ lodash.isRegExp = isRegExp; lodash.isSafeInteger = isSafeInteger; lodash.isString = isString; + lodash.isSymbol = isSymbol; lodash.isTypedArray = isTypedArray; lodash.isUndefined = isUndefined; + lodash.join = join; lodash.kebabCase = kebabCase; lodash.last = last; lodash.lastIndexOf = lastIndexOf; @@ -13095,19 +14081,21 @@ lodash.lte = lte; lodash.max = max; lodash.maxBy = maxBy; + lodash.mean = mean; lodash.min = min; lodash.minBy = minBy; lodash.noConflict = noConflict; lodash.noop = noop; lodash.now = now; lodash.pad = pad; - lodash.padLeft = padLeft; - lodash.padRight = padRight; + lodash.padEnd = padEnd; + lodash.padStart = padStart; lodash.parseInt = parseInt; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; lodash.repeat = repeat; + lodash.replace = replace; lodash.result = result; lodash.round = round; lodash.runInContext = runInContext; @@ -13123,18 +14111,22 @@ lodash.sortedLastIndexOf = sortedLastIndexOf; lodash.startCase = startCase; lodash.startsWith = startsWith; + lodash.subtract = subtract; lodash.sum = sum; lodash.sumBy = sumBy; lodash.template = template; + lodash.times = times; lodash.toInteger = toInteger; + lodash.toLength = toLength; lodash.toLower = toLower; + lodash.toNumber = toNumber; lodash.toSafeInteger = toSafeInteger; lodash.toString = toString; lodash.toUpper = toUpper; lodash.trim = trim; - lodash.trimLeft = trimLeft; - lodash.trimRight = trimRight; - lodash.trunc = trunc; + lodash.trimEnd = trimEnd; + lodash.trimStart = trimStart; + lodash.truncate = truncate; lodash.unescape = unescape; lodash.uniqueId = uniqueId; lodash.upperCase = upperCase; @@ -13195,7 +14187,7 @@ // Add `LazyWrapper` methods that accept an `iteratee` value. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { var type = index + 1, - isFilter = type != LAZY_MAP_FLAG; + isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; LazyWrapper.prototype[methodName] = function(iteratee) { var result = this.clone(); @@ -13235,6 +14227,15 @@ return this.reverse().find(predicate); }; + LazyWrapper.prototype.invokeMap = rest(function(path, args) { + if (typeof path == 'function') { + return new LazyWrapper(this); + } + return this.map(function(value) { + return baseInvoke(value, path, args); + }); + }); + LazyWrapper.prototype.reject = function(predicate) { predicate = getIteratee(predicate, 3); return this.filter(function(value) { @@ -13243,7 +14244,7 @@ }; LazyWrapper.prototype.slice = function(start, end) { - start = start ? toInteger(start) : 0; + start = toInteger(start); var result = this; if (result.__filtered__ && (start > 0 || end < 0)) { @@ -13273,15 +14274,15 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) { var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), - retUnwrapped = isTaker || /^find/.test(methodName), - lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName]; + lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], + retUnwrapped = isTaker || /^find/.test(methodName); if (!lodashFunc) { return; } lodash.prototype[methodName] = function() { - var args = isTaker ? [1] : arguments, - value = this.__wrapped__, + var value = this.__wrapped__, + args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee = args[0], useLazy = isLazy || isArray(value); @@ -13295,8 +14296,7 @@ // Avoid lazy use if the iteratee has a "length" value other than `1`. isLazy = useLazy = false; } - var action = { 'func': thru, 'args': [interceptor], 'thisArg': undefined }, - chainAll = this.__chain__, + var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid; @@ -13304,7 +14304,7 @@ if (!retUnwrapped && useLazy) { value = onlyLazy ? value : new LazyWrapper(this); var result = func.apply(value, args); - result.__actions__.push(action); + result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); return new LodashWrapper(result, chainAll); } if (isUnwrapped && onlyLazy) { @@ -13316,10 +14316,10 @@ }); // Add `Array` and `String` methods to `lodash.prototype`. - arrayEach(['join', 'pop', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) { - var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName], + arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { + var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', - retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName); + retUnwrapped = /^(?:pop|shift)$/.test(methodName); lodash.prototype[methodName] = function() { var args = arguments; @@ -13351,13 +14351,14 @@ LazyWrapper.prototype.value = lazyValue; // Add chaining functions to the `lodash` wrapper. + lodash.prototype.at = wrapperAt; lodash.prototype.chain = wrapperChain; lodash.prototype.commit = wrapperCommit; - lodash.prototype.concat = wrapperConcat; + lodash.prototype.flatMap = wrapperFlatMap; lodash.prototype.next = wrapperNext; lodash.prototype.plant = wrapperPlant; lodash.prototype.reverse = wrapperReverse; - lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; + lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; if (iteratorSymbol) { lodash.prototype[iteratorSymbol] = wrapperToIterator; @@ -13389,13 +14390,11 @@ if (moduleExports) { (freeModule.exports = _)._ = _; } - else { - // Export for Rhino with CommonJS support. - freeExports._ = _; - } + // Export for CommonJS support. + freeExports._ = _; } else { - // Export for a browser or Rhino. + // Export to the global object. root._ = _; } }.call(this)); diff --git a/dist/lodash.min.js b/dist/lodash.min.js index b410ac04a..00e69af1d 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -1,2 +1,117 @@ -(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){for(var r=-1,e=n.length,u=-1,i=t.length,o=Array(e+i);++r-1;);return r}function A(n,t){for(var r=n.length;r--&&y(t,n[r],0)>-1;);return r}function O(n){return n&&n.Object===Object?n:null}function R(n,t){if(n!==t){var r=null===n,e=n===X,u=n===n,i=null===t,o=t===X,a=t===t;if(n>t&&!i||!u||r&&!o&&a||e&&a)return 1;if(t>n&&!r||!a||i&&!e&&u||o&&u)return-1}return 0}function k(n,t,r){for(var e=-1,u=n.criteria,i=t.criteria,o=u.length,a=r.length;++e=a)return f;var c=r[e];return f*("asc"===c?1:-1)}}return n.index-t.index}function I(n,t){var r=-1,e=n.length;for(t||(t=Array(e));++r-1&&n%1==0&&t>n}function F(n){return"number"==typeof n&&n>-1&&n%1==0&&bn>=n}function q(n){return 160>=n&&n>=9&&13>=n||32==n||160==n||5760==n||6158==n||n>=8192&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function T(n){for(var t,r=[];!(t=n.next()).done;)r.push(t.value);return r}function N(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n]}),r}function D(n,t){for(var r=-1,e=n.length,u=-1,i=[];++rt,u=r?n.length:0,i=$e(0,u,this.__views__),o=i.start,a=i.end,f=a-o,c=e?a:o-1,l=this.__iteratees__,s=l.length,p=0,h=pf(f,this.__takeCount__);if(!r||vn>u||u==f&&h==f)return ne(n,this.__actions__);var _=[];n:for(;f--&&h>p;){c+=t;for(var v=-1,g=n[c];++vr)return!1;var e=n.length-1;return r==e?n.pop():of.call(n,r,1),!0}function Pt(n,t){var r=Kt(n,t);return 0>r?X:n[r][1]}function Zt(n,t){return Kt(n,t)>-1}function Kt(n,t){for(var r=n.length;r--;)if(n[r][0]===t)return r;return-1}function Vt(n,t,r){var e=Kt(n,t);0>e?n.push([t,r]):n[e][1]=r}function Gt(n,t){return n&&E(t,Co(t),n)}function Jt(n,t){for(var r=-1,e=null==n,u=t.length,i=Array(u);++r=vn&&(u=$t,i=!1,t=new Bt(t));n:for(;++er&&(r=-r>u?0:u+r),e=e===X||e>u?u:ho(e),0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;u>r;)n[r++]=t;return n}function sr(n,t){var r=[];return Of(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function pr(n,t,r,e){e||(e=[]);for(var u=-1,i=n.length;++ur;)n=n[t[r++]];return r&&r==e?n:X}function dr(n,t){return Ma.call(n,t)||"object"==typeof n&&t in n&&null===nf(n)}function mr(n,t){return t in Object(n)}function wr(n){return jr(n)}function jr(n,t){for(var r=n.length,e=r,u=Array(r),i=[];e--;){var o=n[e];e&&t&&(o=a(o,function(n){return t(n)})),u[e]=t||o.length>=120?new Bt(e&&o):null}o=n[0];var f=-1,c=o?o.length:0,l=u[0];n:for(;++f-1;)i!==n&&of.call(i,o,1),of.call(n,o,1);return n}function Nr(n,t){for(var r=n?t.length:0,e=r-1;r--;){var u=t[r];if(e==r||u!=i){var i=u;if(z(u))of.call(n,u,1);else if(Pe(u,n))delete n[u];else{var o=Jr(u),a=Ye(n,o);null!=a&&delete a[yu(o)]}}}return n}function Dr(n,t){return n+ff(_f()*(t-n+1))}function Mr(n,t,r,e){t=Pe(t,n)?[t+""]:Jr(t);for(var u=-1,i=t.length,o=i-1,a=n;null!=a&&++ut&&(t=-t>u?0:u+t),r=r===X||r>u?u:ho(r),0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(u);++e=vn?new Bt:null,a=[];o?(e=$t,i=!1):o=t?[]:a;n:for(;++r=u){for(;u>e;){var i=e+u>>>1,o=n[i];(r?t>=o:t>o)&&null!==o?e=i+1:u=i}return u}return ue(n,t,_a,r)}function ue(n,t,r,e){t=r(t);for(var u=0,i=n?n.length:0,o=t!==t,a=null===t,f=t===X;i>u;){var c=ff((u+i)/2),l=r(n[c]),s=l!==X,p=l===l;if(o)var h=p||e;else h=a?p&&s&&(e||null!=l):f?p&&(e||s):null==l?!1:e?t>=l:t>l;h?u=c+1:i=c}return pf(i,An)}function ie(n){var t=n.constructor,r=new t(n.byteLength),e=new Ya(r);return e.set(new Ya(n)),r}function oe(t){var r=t.constructor;return c(N(t),n,new r)}function ae(n){var t=n.constructor,r=new t(n.source,_t.exec(n));return r.lastIndex=n.lastIndex,r}function fe(n){var r=n.constructor;return c(M(n),t,new r)}function ce(n,t){var r=n.buffer,e=n.constructor;return new e(t?ie(r):r,n.byteOffset,n.length)}function le(n,t,r){for(var e=r.length,u=-1,i=sf(n.length-e,0),o=-1,a=t.length,f=Array(a+i);++o1?r[u-1]:X,o=u>2?r[2]:X;for(i="function"==typeof i?(u--,i):X,o&&Me(r[0],r[1],o)&&(i=3>u?X:i,u=1),t=Object(t);++e=vn)return t.plant(e).value();for(var u=0,o=r?i[u].apply(this,n):e;++um){var A=a?I(a):X,O=sf(c-m,0),R=_?j:X,k=_?X:j,E=_?b:X,C=_?X:b;t|=_?en:un,t&=~(_?un:en),v||(t&=~(H|Q));var S=[n,t,r,E,R,C,k,A,f,O],W=be.apply(X,S);return Ke(n)&&Wf(W,S),W.placeholder=x,W}}var L=p?r:this,U=h?L[n]:n;return a?b=He(b,a):y&&b.length>1&&b.reverse(),s&&f=t)return"";var u=t-e;r=r===X?" ":r+"";var i=ra(r,af(u/P(r)));return tr.test(r)?Z(i).slice(0,u).join(""):i.slice(0,u)}function Oe(n,t,r,e){function u(){for(var t=-1,a=arguments.length,f=-1,c=e.length,l=Array(c+a);++fc))return!1;for(;++ou,o=e==on&&r==tn||e==on&&r==an&&n[7].length<=t[8]||e==(on|an)&&t[7].length<=t[8]&&r==tn;if(!i&&!o)return n;e&H&&(n[2]=t[2],u|=r&H?0:nn);var a=t[3];if(a){var f=n[3];n[3]=f?le(f,a,t[4]):I(a),n[4]=f?D(n[3],Rn):I(t[4])}return a=t[5],a&&(f=n[5],n[5]=f?se(f,a,t[6]):I(a),n[6]=f?D(n[5],Rn):I(t[6])),a=t[7],a&&(n[7]=I(a)),e&on&&(n[8]=null==n[8]?t[8]:pf(n[8],t[8])),null==n[9]&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function Xe(n,t,r,e,u,i){return Ji(n)&&(i.set(t,n),Lr(n,t,Xe,i)),n===X?Xt(t):n}function Ye(n,t){return 1==t.length?n:Ro(n,Pr(t,0,-1))}function He(n,t){for(var r=n.length,e=pf(t.length,r),u=I(n);e--;){var i=t[e];n[e]=z(i,r)?u[i]:X}return n}function Qe(n){var t=[];return go(n).replace(ct,function(n,r,e,u){t.push(e?u.replace(pt,"$1"):r||n)}),t}function nu(n){return Fi(n)?n:[]}function tu(n){return"function"==typeof n?n:_a}function ru(n){if(n instanceof bt)return n.clone();var t=new yt(n.__wrapped__,n.__chain__);return t.__actions__=I(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function eu(n,t){t=sf(ho(t),0);var r=n?n.length:0;if(!r||1>t)return[];for(var e=0,u=-1,i=Array(af(r/t));r>e;)i[++u]=Pr(n,e,e+=t);return i}function uu(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++tt?0:t)):[]}function ou(n,t,r){var e=n?n.length:0;return e?(t=r||t===X?1:ho(t),t=e-t,Pr(n,0,0>t?0:t)):[]}function au(n,t){return n&&n.length?Qr(n,We(t,3),!0,!0):[]}function fu(n,t){return n&&n.length?Qr(n,We(t,3),!0):[]}function cu(n,t,r,e){var u=n?n.length:0;return u?(r&&"number"!=typeof r&&Me(n,t,r)&&(r=0,e=u),lr(n,t,r,e)):[]}function lu(n,t){return n&&n.length?g(n,We(t,3)):-1}function su(n,t){return n&&n.length?g(n,We(t,3),!0):-1}function pu(n){var t=n?n.length:0;return t?pr(n):[]}function hu(n){var t=n?n.length:0;return t?pr(n,!0):[]}function _u(n){return n?n[0]:X}function vu(n,t,r){var e=n?n.length:0;return e?(r=r?ho(r):0,0>r&&(r=sf(e+r,0)),y(n,t,r)):-1}function gu(n){return ou(n,1)}function yu(n){var t=n?n.length:0;return t?n[t-1]:X}function du(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(r!==X&&(u=ho(r),u=(0>u?sf(e+u,0):pf(u,e-1))+1),t!==t)return B(n,u,!0);for(;u--;)if(n[u]===t)return u;return-1}function mu(n,t){return n&&n.length&&t&&t.length?qr(n,t):n}function wu(n,t,r){return n&&n.length&&t&&t.length?Tr(n,t,We(r)):n}function bu(n,t){var r=[];if(!n||!n.length)return r;var e=-1,u=[],i=n.length;for(t=We(t,3);++ee&&(t===t?t===n[e]:n[e]!==n[e]))return e}return-1}function ku(n,t){return ee(n,t,!0)}function Iu(n,t,r){return ue(n,t,We(r),!0)}function Eu(n,t){var r=n?n.length:0;if(r){var e=ee(n,t,!0)-1,u=n[e];if(t===t?t===u:u!==u)return e}return-1}function Cu(n){return n&&n.length?Vr(n):[]}function Su(n,t){return n&&n.length?Gr(n,We(t)):[]}function Wu(n){return iu(n,1)}function Lu(n,t,r){return n&&n.length?(t=r||t===X?1:t,Pr(n,0,0>t?0:t)):[]}function Uu(n,t,r){var e=n?n.length:0;return e?(t=r||t===X?1:ho(t),t=e-t,Pr(n,0>t?0:t)):[]}function Bu(n,t){return n&&n.length?Qr(n,We(t,3),!1,!0):[]}function $u(n,t){return n&&n.length?Qr(n,We(t,3)):[]}function zu(n){return n&&n.length?Xr(n):[]}function Fu(n,t){return n&&n.length?Yr(n,We(t)):[]}function qu(n){if(!n||!n.length)return[];var t=0;return n=o(n,function(n){return Fi(n)?(t=sf(n.length,t),!0):void 0}),b(t,function(t){return a(n,zr(t))})}function Tu(n,t){if(!n||!n.length)return[];var r=qu(n);return null==t?r:a(r,function(n){return c(n,t,X,!0)})}function Nu(n,t){var r=-1,e=n?n.length:0,u={};for(!e||t||vc(n[0])||(t=[]);++r=this.__values__.length,t=n?X:this.__values__[this.__index__++];return{done:n,value:t}}function Gu(){return this}function Ju(n){for(var t,r=this;r instanceof Tn;){var e=ru(r);e.__index__=0,e.__values__=X,t?u.__wrapped__=e:t=e;var u=e;r=r.__wrapped__}return u.__wrapped__=n,t}function Xu(){var n=this.__wrapped__;if(n instanceof bt){var t=n;return this.__actions__.length&&(t=new bt(this)),t=t.reverse(),t.__actions__.push({func:Pu,args:[xu],thisArg:X}),new yt(t,this.__chain__)}return this.thru(xu)}function Yu(){return ne(this.__wrapped__,this.__actions__)}function Hu(n,t,r){var e=vc(n)?i:cr;return r&&Me(n,t,r)&&(t=X),e(n,We(t,3))}function Qu(n,t){var r=vc(n)?o:sr;return r(n,We(t,3))}function ni(n,t){if(t=We(t,3),vc(n)){var r=g(n,t);return r>-1?n[r]:X}return v(n,t,Of)}function ti(n,t){if(t=We(t,3),vc(n)){var r=g(n,t,!0);return r>-1?n[r]:X}return v(n,t,Rf)}function ri(n,t){return"function"==typeof t&&vc(n)?e(n,t):Of(n,tu(t))}function ei(n,t){return"function"==typeof t&&vc(n)?u(n,t):Rf(n,tu(t))}function ui(n,t,r,e){n=zi(n)?n:Do(n),r=r&&!e?ho(r):0;var u=n.length;return 0>r&&(r=sf(u+r,0)),ao(n)?u>=r&&n.indexOf(t,r)>-1:!!u&&y(n,t,r)>-1}function ii(n,t){var r=vc(n)?a:Cr;return r(n,We(t,3))}function oi(n,t,r){var e=arguments.length<3;return"function"==typeof t&&vc(n)?c(n,t,r,e):d(n,We(t,4),r,e,Of)}function ai(n,t,r){var e=arguments.length<3;return"function"==typeof t&&vc(n)?l(n,t,r,e):d(n,We(t,4),r,e,Rf)}function fi(n,t){var r=vc(n)?o:sr;return t=We(t,3),r(n,function(n,r,e){return!t(n,r,e)})}function ci(n){var t=zi(n)?n:Do(n),r=t.length;return r>0?t[Dr(0,r-1)]:X}function li(n,t){var r=-1,e=po(n),u=e.length,i=u-1;for(t=Po(ho(t),0,u);++r0&&(r=t.apply(this,arguments)),1>=n&&(t=X),r}}function di(n,t,r){t=r?X:t;var e=ke(n,tn,X,X,X,X,X,t);return e.placeholder=di.placeholder,e}function mi(n,t,r){t=r?X:t;var e=ke(n,rn,X,X,X,X,X,t);return e.placeholder=mi.placeholder,e}function wi(n,t,r){function e(){_&&Ha(_),l&&Ha(l),g=0,c=l=h=_=v=X}function u(t,r){r&&Ha(r),l=_=v=X,t&&(g=Qf(),s=n.apply(h,c),_||l||(c=h=X))}function i(){var n=t-(Qf()-p);0>=n||n>t?u(v,l):_=uf(i,n)}function o(){return(_&&v||l&&m)&&(s=n.apply(h,c)),e(),s}function a(){u(m,_)}function f(){if(c=arguments,p=Qf(),h=this,v=m&&(_||!y),d===!1)var r=y&&!_;else{l||y||(g=p);var e=d-(p-g),u=0>=e||e>d;u?(l&&(l=Ha(l)),g=p,s=n.apply(h,c)):l||(l=uf(a,e))}return u&&_?_=Ha(_):_||t===d||(_=uf(i,t)),r&&(u=!0,s=n.apply(h,c)),!u||_||l||(c=h=X),s}var c,l,s,p,h,_,v,g=0,y=!1,d=!1,m=!0;if("function"!=typeof n)throw new Fa(dn);return t=0>t?0:+t||0,Ji(r)&&(y=!!r.leading,d="maxWait"in r&&sf(+r.maxWait||0,t),m="trailing"in r?!!r.trailing:m),f.cancel=e,f.flush=o,f}function bi(n){return ke(n,fn)}function xi(n,t){if("function"!=typeof n||t&&"function"!=typeof t)throw new Fa(dn);var r=function(){var e=arguments,u=t?t.apply(this,e):e[0],i=r.cache;if(i.has(u))return i.get(u);var o=n.apply(this,e);return r.cache=i.set(u,o),o};return r.cache=new xi.Cache,r}function ji(n){if("function"!=typeof n)throw new Fa(dn);return function(){return!n.apply(this,arguments)}}function Ai(n){return yi(2,n)}function Oi(n,t){if("function"!=typeof n)throw new Fa(dn);return t=sf(t===X?n.length-1:ho(t),0),function(){for(var r=arguments,e=-1,u=sf(r.length-t,0),i=Array(u);++et}function Bi(n,t){return n>=t}function $i(n){return Fi(n)&&Ma.call(n,"callee")&&(!ef.call(n,"callee")||Ka.call(n)==kn)}function zi(n){return null!=n&&!("function"==typeof n&&Vi(n))&&F(Sf(n))}function Fi(n){return Xi(n)&&zi(n)}function qi(n){return n===!0||n===!1||Xi(n)&&Ka.call(n)==En}function Ti(n){return Xi(n)&&Ka.call(n)==Cn}function Ni(n){return!!n&&1===n.nodeType&&Xi(n)&&!uo(n)}function Di(n){return!Xi(n)||Vi(n.splice)?!pi(n):!Co(n).length}function Mi(n,t){return Ar(n,t)}function Pi(n,t,r){r="function"==typeof r?r:X;var e=r?r(n,t):X;return e===X?Ar(n,t,r):!!e}function Zi(n){return Xi(n)&&"string"==typeof n.message&&Ka.call(n)==Sn}function Ki(n){return"number"==typeof n&&cf(n)}function Vi(n){var t=Ji(n)?Ka.call(n):"";return t==Wn||t==Ln}function Gi(n){return"number"==typeof n&&n==ho(n)}function Ji(n){var t=typeof n;return!!n&&("object"==t||"function"==t); -}function Xi(n){return!!n&&"object"==typeof n}function Yi(n,t){return n===t||Rr(n,t,Le(t))}function Hi(n,t,r){return r="function"==typeof r?r:X,Rr(n,t,Le(t),r)}function Qi(n){return eo(n)&&n!=+n}function no(n){return null==n?!1:Vi(n)?Ga.test(Da.call(n)):Xi(n)&&($(n)?Ga:gt).test(n)}function to(n){return null===n}function ro(n){return null==n}function eo(n){return"number"==typeof n||Xi(n)&&Ka.call(n)==Bn}function uo(n){if(!Xi(n)||Ka.call(n)!=$n||$(n))return!1;var t=Ta;if("function"==typeof n.constructor&&(t=nf(n)),null===t)return!0;var r=t.constructor;return"function"==typeof r&&r instanceof r&&Da.call(r)==Za}function io(n){return Ji(n)&&Ka.call(n)==zn}function oo(n){return Gi(n)&&n>=-bn&&bn>=n}function ao(n){return"string"==typeof n||!vc(n)&&Xi(n)&&Ka.call(n)==qn}function fo(n){return Xi(n)&&F(n.length)&&!!ar[Ka.call(n)]}function co(n){return n===X}function lo(n,t){return t>n}function so(n,t){return t>=n}function po(n){if(!n)return[];if(zi(n))return ao(n)?Z(n):I(n);if(tf&&n[tf])return T(n[tf]());var t=Be(n),r=t==Un?N:t==Fn?M:Do;return r(n)}function ho(n){if(n===wn||n===-wn)return(0>n?-1:1)*xn;n=+n;var t=n%1;return n===n?t?n-t:n:0}function _o(n){return E(n,So(n))}function vo(n){return Po(ho(n),-bn,bn)}function go(n){return"string"==typeof n?n:null==n?"":n+""}function yo(n,t){var r=Af(n);return t?Gt(r,t):r}function mo(n,t){return v(n,We(t,3),_r,!0)}function wo(n,t){return v(n,We(t,3),vr,!0)}function bo(n,t){return null==n?n:kf(n,tu(t),So)}function xo(n,t){return null==n?n:If(n,tu(t),So)}function jo(n,t){return n&&_r(n,tu(t))}function Ao(n,t){return n&&vr(n,tu(t))}function Oo(n){return null==n?[]:gr(n,So(n))}function Ro(n,t,r){var e=null==n?X:yr(n,t);return e===X?r:e}function ko(n,t){return ze(n,t,dr)}function Io(n,t){return ze(n,t,mr)}function Eo(n,t,r){return c(Co(n),function(e,u){var i=n[u];return t&&!r?Ma.call(e,i)?e[i].push(u):e[i]=[u]:e[i]=u,e},{})}function Co(n){var t=Ve(n);if(!t&&!zi(n))return Ir(n);var r=Ne(n),e=r.length,u=!!e;for(var i in n)!dr(n,i)||u&&z(i,e)||t&&"constructor"==i||r.push(i);return r}function So(n){for(var t=-1,r=Ve(n),e=Er(n),u=e.length,i=Ne(n),o=i.length,a=!!o;++t=pf(t,r)&&n=0&&n.indexOf(t,r)==r}function Xo(n){return n=go(n),n&&et.test(n)?n.replace(tt,W):n}function Yo(n){return n=go(n),n&&st.test(n)?n.replace(lt,"\\$&"):n}function Ho(n,t,r){n=go(n),t=ho(t);var e=P(n);if(!t||e>=t)return n;var u=(t-e)/2,i=ff(u),o=af(u);return Ae("",i,r)+n+Ae("",o,r)}function Qo(n,t,r){return n=go(n),Ae(n,t,r)+n}function na(n,t,r){return n=go(n),n+Ae(n,t,r)}function ta(n,t,r){return r||null==t?t=0:t&&(t=+t),n=aa(n),hf(n,t||(vt.test(n)?16:10))}function ra(n,t){n=go(n),t=ho(t);var r="";if(!n||1>t||t>bn)return r;do t%2&&(r+=n),t=ff(t/2),n+=n;while(t);return r}function ea(n,t,r){return n=go(n),r=Po(ho(r),0,n.length),n.lastIndexOf(t,r)==r}function ua(n,t,r){var e=q.templateSettings;r&&Me(n,t,r)&&(t=r=X),n=go(n),t=xc({},r||t,e,U);var u,i,o=xc({},t.imports,e.imports,U),a=Co(o),f=x(o,a),c=0,l=t.interpolate||mt,s="__p += '",p=za((t.escape||mt).source+"|"+l.source+"|"+(l===ot?ht:mt).source+"|"+(t.evaluate||mt).source+"|$","g"),h="//# sourceURL="+("sourceURL"in t?t.sourceURL:"lodash.templateSources["+ ++or+"]")+"\n";n.replace(p,function(t,r,e,o,a,f){return e||(e=o),s+=n.slice(c,f).replace(wt,L),r&&(u=!0,s+="' +\n__e("+r+") +\n'"),a&&(i=!0,s+="';\n"+a+";\n__p += '"),e&&(s+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),c=f+t.length,t}),s+="';\n";var _=t.variable;_||(s="with (obj) {\n"+s+"\n}\n"),s=(i?s.replace(Yn,""):s).replace(Hn,"$1").replace(Qn,"$1;"),s="function("+(_||"obj")+") {\n"+(_?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(u?", __e = _.escape":"")+(i?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+s+"return __p\n}";var v=Bc(function(){return Function(a,h+"return "+s).apply(X,f)});if(v.source=s,Zi(v))throw v;return v}function ia(n){return go(n).toLowerCase()}function oa(n){return go(n).toUpperCase()}function aa(n,t,r){if(n=go(n),!n)return n;if(r||t===X)return n.slice(K(n),V(n)+1);if(t+="",!t)return n;var e=Z(n),u=Z(t);return e.slice(j(e,u),A(e,u)+1).join("")}function fa(n,t,r){if(n=go(n),!n)return n;if(r||t===X)return n.slice(K(n));if(t+="",!t)return n;var e=Z(n);return e.slice(j(e,Z(t))).join("")}function ca(n,t,r){if(n=go(n),!n)return n;if(r||t===X)return n.slice(0,V(n)+1);if(t+="",!t)return n;var e=Z(n);return e.slice(0,A(e,Z(t))+1).join("")}function la(n,t){var r=sn,e=pn;if(Ji(t)){var u="separator"in t?t.separator:u;r="length"in t?ho(t.length):r,e="omission"in t?go(t.omission):e}n=go(n);var i=n.length;if(tr.test(n)){var o=Z(n);i=o.length}if(r>=i)return n;var a=r-P(e);if(1>a)return e;var f=o?o.slice(0,a).join(""):n.slice(0,a);if(u===X)return f+e;if(o&&(a+=f.length-a),io(u)){if(n.slice(a).search(u)){var c,l=f;for(u.global||(u=za(u.source,go(_t.exec(u))+"g")),u.lastIndex=0;c=u.exec(l);)var s=c.index;f=f.slice(0,s===X?a:s)}}else if(n.indexOf(u,a)!=a){var p=f.lastIndexOf(u);p>-1&&(f=f.slice(0,p))}return f+e}function sa(n){return n=go(n),n&&rt.test(n)?n.replace(nt,G):n}function pa(n,t,r){return n=go(n),t=r?X:t,t===X&&(t=ur.test(n)?er:rr),n.match(t)||[]}function ha(n){return function(){return n}}function _a(n){return n}function va(n){return Xi(n)&&!vc(n)?ga(n):kr(n)}function ga(n){return Sr(Xt(n,!0))}function ya(n,t){return Wr(n,Xt(t,!0))}function da(n,t,r){var u=Co(t),i=gr(t,u);null!=r||Ji(t)&&(i.length||!u.length)||(r=t,t=n,n=this,i=gr(t,Co(t)));var o=Ji(r)&&"chain"in r?r.chain:!0,a=Vi(n);return e(i,function(r){var e=t[r];n[r]=e,a&&(n.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=n(this.__wrapped__),u=r.__actions__=I(this.__actions__);return u.push({func:e,args:arguments,thisArg:n}),r.__chain__=t,r}return e.apply(n,f([this.value()],arguments))})}),n}function ma(){return br._=Va,this}function wa(){}function ba(n){return Pe(n)?zr(n):Fr(n)}function xa(n){return function(t){return null==n?X:yr(n,t)}}function ja(n,t,r){r&&Me(n,t,r)&&(t=r=X),n=+n,n=n===n?n:0,r=r===X?1:+r||0,t===X?(t=n,n=0):t=+t||0;var e=sf(af((t-n)/(r||1)),0);return b(e,function(t){return t?n+=r:n})}function Aa(n,t){if(n=ho(n),1>n||n>bn)return[];var r=jn,e=pf(n,jn);t=tu(t),n-=jn;for(var u=b(e,t);++r0){if(++n>=hn)return r}else n=0;return Ef(r,e)}}(),Lf=Oi(function(n,t){return Fi(n)?Ht(n,pr(t,!1,!0)):[]}),Uf=Oi(function(n,t){var r=yu(t);return Fi(r)&&(r=X),Fi(n)?nr(n,pr(t,!1,!0),We(r)):[]}),Bf=Oi(function(n){var t=a(n,nu);return t.length&&t[0]===n[0]?wr(t):[]}),$f=Oi(function(n){var t=yu(n),r=a(n,nu);return t===yu(r)?t=X:r.pop(),r.length&&r[0]===n[0]?jr(r,We(t)):[]}),zf=Oi(mu),Ff=Oi(function(n,t){t=a(pr(t),String);var r=Jt(n,t);return Nr(n,t.sort(R)),r}),qf=Oi(function(n){return Xr(pr(n,!1,!0))}),Tf=Oi(function(n){var t=yu(n);return Fi(t)&&(t=X),Yr(pr(n,!1,!0),We(t))}),Nf=Oi(function(n,t){return Fi(n)?Ht(n,t):[]}),Df=Oi(function(n){return te(o(n,Fi))}),Mf=Oi(function(n){var t=yu(n);return Fi(t)&&(t=X),re(o(n,Fi),We(t))}),Pf=Oi(qu),Zf=Oi(function(n){var t=n.length,r=t>1?n[t-1]:X;return r="function"==typeof r?(n.pop(),r):X,Tu(n,r)}),Kf=Oi(function(n){return n=pr(n),this.thru(function(t){return r(vc(t)?t:[Object(t)],n)})}),Vf=pe(function(n,t,r){Ma.call(n,r)?++n[r]:n[r]=1}),Gf=pe(function(n,t,r){Ma.call(n,r)?n[r].push(t):n[r]=[t]}),Jf=Oi(function(n,t,r){var e=-1,u="function"==typeof t,i=Pe(t),o=zi(n)?Array(n.length):[];return Of(n,function(n){var a=u?t:i&&null!=n?n[t]:X;o[++e]=a?a.apply(n,r):De(n,t,r)}),o}),Xf=pe(function(n,t,r){n[r]=t}),Yf=pe(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Hf=Oi(function(n,t){if(null==n)return[];var r=t.length;return r>1&&Me(n,t[0],t[1])?t=[]:r>2&&Me(t[0],t[1],t[2])&&(t.length=1),Kr(n,pr(t),[])}),Qf=Ua.now,nc=Oi(function(n,t,r){var e=H;if(r.length){var u=D(r,nc.placeholder);e|=en}return ke(n,e,t,r,u)}),tc=Oi(function(n,t){return e(pr(t),function(t){n[t]=nc(n[t],n)}),n}),rc=Oi(function(n,t,r){var e=H|Q;if(r.length){var u=D(r,rc.placeholder);e|=en}return ke(t,e,n,r,u)}),ec=xe(i),uc=Oi(function(n,t){return Yt(n,1,t)}),ic=Oi(function(n,t,r){return Yt(n,t,r)}),oc=xe(s),ac=we(),fc=we(!0),cc=xe(a),lc=je(function(n){return[n]}),sc=je(function(n,t,r){return r}),pc=Oi(function(n,t){var r=D(t,pc.placeholder);return ke(n,en,X,t,r)}),hc=Oi(function(n,t){var r=D(t,hc.placeholder);return ke(n,un,X,t,r)}),_c=Oi(function(n,t){return ke(n,an,X,X,X,pr(t))}),vc=Array.isArray,gc=he(function(n,t){E(t,Co(t),n)}),yc=he(function(n,t,r){C(t,Co(t),n,r)}),dc=Oi(function(n,t){return Jt(n,pr(t))}),mc=Oi(function(n){return n.push(X,U),xc.apply(X,n)}),wc=Oi(function(n){return n.push(X,Xe),Ac.apply(X,n)}),bc=he(function(n,t){E(t,So(t),n)}),xc=he(function(n,t,r){C(t,So(t),n,r)}),jc=he(function(n,t){Lr(n,t)}),Ac=he(function(n,t,r){Lr(n,t,r)}),Oc=Oi(function(n,t){return null==n?{}:(t=a(pr(t),String),Br(n,Ht(So(n),t)))}),Rc=Oi(function(n,t){return null==n?{}:Br(n,pr(t))}),kc=de(function(n,t,r){return t=t.toLowerCase(),n+(r?Vo(t):t)}),Ic=de(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Ec=de(function(n,t,r){return n+(r?" ":"")+t.toLowerCase()}),Cc=ye("toLowerCase"),Sc=ye("toUpperCase"),Wc=de(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Lc=de(function(n,t,r){return n+(r?" ":"")+Vo(t)}),Uc=de(function(n,t,r){return n+(r?" ":"")+t.toUpperCase()}),Bc=Oi(function(n,t){try{return n.apply(X,t)}catch(r){return Zi(r)?r:new Ba(r)}}),$c=Oi(function(n,t){return function(r){return De(r,n,t)}}),zc=Oi(function(n,t){return function(r){return De(n,r,t)}}),Fc=Re("ceil"),qc=Re("floor"),Tc=Re("round");return q.prototype=Tn.prototype,yt.prototype=Af(Tn.prototype),yt.prototype.constructor=yt,bt.prototype=Af(Tn.prototype),bt.prototype.constructor=bt,Ot.prototype=mf?mf(null):Ta,Ct.prototype["delete"]=St,Ct.prototype.get=Wt,Ct.prototype.has=Lt,Ct.prototype.set=Ut,Bt.prototype.push=zt,Ft.prototype["delete"]=qt,Ft.prototype.get=Tt,Ft.prototype.has=Nt,Ft.prototype.set=Dt,xi.Cache=Ct,q.after=vi,q.ary=gi,q.assign=gc,q.assignWith=yc,q.at=dc,q.before=yi,q.bind=nc,q.bindAll=tc,q.bindKey=rc,q.chain=Du,q.chunk=eu,q.compact=uu,q.conj=ec,q.constant=ha,q.countBy=Vf,q.create=yo,q.curry=di,q.curryRight=mi,q.debounce=wi,q.defaults=mc,q.defaultsDeep=wc,q.defer=uc,q.delay=ic,q.difference=Lf,q.differenceBy=Uf,q.disj=oc,q.drop=iu,q.dropRight=ou,q.dropRightWhile=au,q.dropWhile=fu,q.extend=bc,q.extendWith=xc,q.fill=cu,q.filter=Qu,q.flatten=pu,q.flattenDeep=hu,q.flip=bi,q.flow=ac,q.flowRight=fc,q.functions=Oo,q.groupBy=Gf,q.initial=gu,q.intersection=Bf,q.intersectionBy=$f,q.invert=Eo,q.invoke=Jf,q.iteratee=va,q.juxt=cc,q.keyBy=Xf,q.keys=Co,q.keysIn=So,q.map=ii,q.mapKeys=Wo,q.mapValues=Lo,q.matches=ga,q.matchesProperty=ya,q.memoize=xi,q.merge=jc,q.mergeWith=Ac,q.method=$c,q.methodOf=zc,q.mixin=da,q.modArgs=lc,q.modArgsSet=sc,q.negate=ji,q.omit=Oc,q.omitBy=Uo,q.once=Ai,q.pairs=Bo,q.partial=pc,q.partialRight=hc,q.partition=Yf,q.pick=Rc,q.pickBy=$o,q.property=ba,q.propertyOf=xa,q.pull=zf,q.pullAll=mu,q.pullAllBy=wu,q.pullAt=Ff,q.range=ja,q.rearg=_c,q.reject=fi,q.remove=bu,q.rest=Oi,q.reverse=xu,q.sampleSize=li,q.set=Fo,q.setWith=qo,q.shuffle=si,q.slice=ju,q.sortBy=Hf,q.sortByOrder=_i,q.sortedUniq=Cu,q.sortedUniqBy=Su,q.spread=Ri,q.tail=Wu,q.take=Lu,q.takeRight=Uu,q.takeRightWhile=Bu,q.takeWhile=$u,q.tap=Mu,q.throttle=ki,q.thru=Pu,q.times=Aa,q.toArray=po,q.toPath=Oa,q.toPlainObject=_o,q.transform=To,q.union=qf,q.unionBy=Tf,q.uniq=zu,q.uniqBy=Fu,q.unset=No,q.unzip=qu,q.unzipWith=Tu,q.values=Do,q.valuesIn=Mo,q.without=Nf,q.words=pa,q.wrap=Ii,q.xor=Df,q.xorBy=Mf,q.zip=Pf,q.zipObject=Nu,q.zipWith=Zf,q.each=ri,q.eachRight=ei,da(q,q),q.add=ka,q.attempt=Bc,q.camelCase=kc,q.capitalize=Vo,q.ceil=Fc,q.clamp=Po,q.clone=Ei,q.cloneDeep=Si,q.cloneDeepWith=Wi,q.cloneWith=Ci,q.deburr=Go,q.endsWith=Jo,q.eq=Li,q.escape=Xo,q.escapeRegExp=Yo,q.every=Hu,q.find=ni,q.findIndex=lu,q.findKey=mo,q.findLast=ti,q.findLastIndex=su,q.findLastKey=wo,q.floor=qc,q.forEach=ri,q.forEachRight=ei,q.forIn=bo,q.forInRight=xo,q.forOwn=jo,q.forOwnRight=Ao,q.get=Ro,q.gt=Ui,q.gte=Bi,q.has=ko,q.hasIn=Io,q.head=_u,q.identity=_a,q.includes=ui,q.indexOf=vu,q.inRange=Zo,q.isArguments=$i,q.isArray=vc,q.isArrayLike=zi,q.isArrayLikeObject=Fi,q.isBoolean=qi,q.isDate=Ti,q.isElement=Ni,q.isEmpty=Di,q.isEqual=Mi,q.isEqualWith=Pi,q.isError=Zi,q.isFinite=Ki,q.isFunction=Vi,q.isInteger=Gi,q.isMatch=Yi,q.isMatchWith=Hi,q.isNaN=Qi,q.isNative=no,q.isNil=ro,q.isNull=to,q.isNumber=eo,q.isObject=Ji,q.isObjectLike=Xi,q.isPlainObject=uo,q.isRegExp=io,q.isSafeInteger=oo,q.isString=ao,q.isTypedArray=fo,q.isUndefined=co,q.kebabCase=Ic,q.last=yu,q.lastIndexOf=du,q.lowerCase=Ec,q.lowerFirst=Cc,q.lt=lo,q.lte=so,q.max=Ia,q.maxBy=Ea,q.min=Ca,q.minBy=Sa,q.noConflict=ma,q.noop=wa,q.now=Qf,q.pad=Ho,q.padLeft=Qo,q.padRight=na,q.parseInt=ta,q.random=Ko,q.reduce=oi,q.reduceRight=ai,q.repeat=ra,q.result=zo,q.round=Tc,q.runInContext=J,q.sample=ci,q.size=pi,q.snakeCase=Wc,q.some=hi,q.sortedIndex=Au,q.sortedIndexBy=Ou,q.sortedIndexOf=Ru,q.sortedLastIndex=ku,q.sortedLastIndexBy=Iu,q.sortedLastIndexOf=Eu,q.startCase=Lc,q.startsWith=ea,q.sum=Wa,q.sumBy=La,q.template=ua,q.toInteger=ho,q.toLower=ia,q.toSafeInteger=vo,q.toString=go,q.toUpper=oa,q.trim=aa,q.trimLeft=fa,q.trimRight=ca,q.trunc=la,q.unescape=sa,q.uniqueId=Ra,q.upperCase=Uc,q.upperFirst=Sc,q.first=_u,da(q,function(){var n={};return _r(q,function(t,r){Ma.call(q.prototype,r)||(n[r]=t)}),n}(),{chain:!1}),q.VERSION=Y,e(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){q[n].placeholder=q}),e(["drop","take"],function(n,t){bt.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new bt(this);r=r===X?1:sf(ho(r),0);var u=this.clone();return e?u.__takeCount__=pf(r,u.__takeCount__):u.__views__.push({size:pf(r,jn),type:n+(u.__dir__<0?"Right":"")}),u},bt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),e(["filter","map","takeWhile"],function(n,t){var r=t+1,e=r!=yn;bt.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({iteratee:We(n,3),type:r}),t.__filtered__=t.__filtered__||e,t}}),e(["head","last"],function(n,t){var r="take"+(t?"Right":"");bt.prototype[n]=function(){return this[r](1).value()[0]}}),e(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");bt.prototype[n]=function(){return this.__filtered__?new bt(this):this[r](1)}}),bt.prototype.compact=function(){return this.filter(_a)},bt.prototype.find=function(n){return this.filter(n).head()},bt.prototype.findLast=function(n){return this.reverse().find(n)},bt.prototype.reject=function(n){return n=We(n,3),this.filter(function(t){return!n(t)})},bt.prototype.slice=function(n,t){n=n?ho(n):0;var r=this;return r.__filtered__&&(n>0||0>t)?new bt(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==X&&(t=ho(t),r=0>t?r.dropRight(-t):r.take(t-n)),r)},bt.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},bt.prototype.toArray=function(){return this.take(jn)},_r(bt.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=e||/^find/.test(t),i=q[e?"take"+("last"==t?"Right":""):t];i&&(q.prototype[t]=function(){var t=e?[1]:arguments,o=this.__wrapped__,a=o instanceof bt,c=t[0],l=a||vc(o),s=function(n){var r=i.apply(q,f([n],t));return e&&h?r[0]:r};l&&r&&"function"==typeof c&&1!=c.length&&(a=l=!1);var p={func:Pu,args:[s],thisArg:X},h=this.__chain__,_=!!this.__actions__.length,v=u&&!h,g=a&&!_;if(!u&&l){o=g?o:new bt(this);var y=n.apply(o,t);return y.__actions__.push(p),new yt(y,h)}return v&&g?n.apply(this,t):(y=this.thru(s),v?e?y.value()[0]:y.value():y)})}),e(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(n){var t=(/^(?:replace|split)$/.test(n)?Na:qa)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);q.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),_r(bt.prototype,function(n,t){var r=q[t];if(r){var e=r.name+"",u=jf[e]||(jf[e]=[]);u.push({name:t,func:r})}}),jf[be(X,Q).name]=[{name:"wrapper",func:X}],bt.prototype.clone=xt,bt.prototype.reverse=jt,bt.prototype.value=At,q.prototype.chain=Zu,q.prototype.commit=Ku,q.prototype.concat=Kf,q.prototype.next=Vu,q.prototype.plant=Ju,q.prototype.reverse=Xu,q.prototype.run=q.prototype.toJSON=q.prototype.valueOf=q.prototype.value=Yu,tf&&(q.prototype[tf]=Gu),q}var X,Y="4.0.0-pre",H=1,Q=2,nn=4,tn=8,rn=16,en=32,un=64,on=128,an=256,fn=512,cn=1,ln=2,sn=30,pn="...",hn=150,_n=16,vn=200,gn=1,yn=2,dn="Expected a function",mn="__lodash_hash_undefined__",wn=1/0,bn=9007199254740991,xn=1e308,jn=4294967295,An=jn-1,On=jn>>>1,Rn="__lodash_placeholder__",kn="[object Arguments]",In="[object Array]",En="[object Boolean]",Cn="[object Date]",Sn="[object Error]",Wn="[object Function]",Ln="[object GeneratorFunction]",Un="[object Map]",Bn="[object Number]",$n="[object Object]",zn="[object RegExp]",Fn="[object Set]",qn="[object String]",Tn="[object WeakMap]",Nn="[object ArrayBuffer]",Dn="[object Float32Array]",Mn="[object Float64Array]",Pn="[object Int8Array]",Zn="[object Int16Array]",Kn="[object Int32Array]",Vn="[object Uint8Array]",Gn="[object Uint8ClampedArray]",Jn="[object Uint16Array]",Xn="[object Uint32Array]",Yn=/\b__p \+= '';/g,Hn=/\b(__p \+=) '' \+/g,Qn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,nt=/&(?:amp|lt|gt|quot|#39|#96);/g,tt=/[&<>"'`]/g,rt=RegExp(nt.source),et=RegExp(tt.source),ut=/<%-([\s\S]+?)%>/g,it=/<%([\s\S]+?)%>/g,ot=/<%=([\s\S]+?)%>/g,at=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ft=/^\w*$/,ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,lt=/[\\^$.*+?()[\]{}|]/g,st=RegExp(lt.source),pt=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,_t=/\w*$/,vt=/^0[xX]/,gt=/^\[object .+?Constructor\]$/,yt=/^\d+$/,dt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,mt=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,bt="\\ud800-\\udfff",xt="\\u0300-\\u036f\\ufe20-\\ufe23",jt="\\u2700-\\u27bf",At="a-z\\xdf-\\xf6\\xf8-\\xff",Ot="\\xac\\xb1\\xd7\\xf7",Rt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",kt="\\u2018\\u2019\\u201c\\u201d",It=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Et="A-Z\\xc0-\\xd6\\xd8-\\xde",Ct="\\ufe0e\\ufe0f",St=Ot+Rt+kt+It,Wt="["+bt+"]",Lt="["+St+"]",Ut="["+xt+"]",Bt="\\d+",$t="["+jt+"]",zt="["+At+"]",Ft="[^"+bt+St+Bt+jt+At+Et+"]",qt="(?:\\ud83c[\\udffb-\\udfff])",Tt="[^"+bt+"]",Nt="(?:\\ud83c[\\udde6-\\uddff]){2}",Dt="[\\ud800-\\udbff][\\udc00-\\udfff]",Mt="["+Et+"]",Pt="\\u200d",Zt="(?:"+zt+"|"+Ft+")",Kt="(?:"+Mt+"|"+Ft+")",Vt=qt+"?",Gt="["+Ct+"]?",Jt="(?:"+Pt+"(?:"+[Tt,Nt,Dt].join("|")+")"+Gt+Vt+")*",Xt=Gt+Vt+Jt,Yt="(?:"+[$t,Nt,Dt].join("|")+")"+Xt,Ht="(?:"+[Tt+Ut+"?",Ut,Nt,Dt,Wt].join("|")+")",Qt=RegExp(Ut,"g"),nr=RegExp(Ht+Xt,"g"),tr=RegExp("["+Pt+bt+xt+Ct+"]"),rr=/[a-zA-Z0-9]+/g,er=RegExp([Mt+"?"+zt+"+(?="+[Lt,Mt,"$"].join("|")+")",Kt+"+(?="+[Lt,Mt+Zt,"$"].join("|")+")",Mt+"?"+Zt+"+",Bt+"(?:"+Zt+"+)?",Yt].join("|"),"g"),ur=/[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ir=["Array","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Object","Reflect","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout"],or=-1,ar={};ar[Dn]=ar[Mn]=ar[Pn]=ar[Zn]=ar[Kn]=ar[Vn]=ar[Gn]=ar[Jn]=ar[Xn]=!0,ar[kn]=ar[In]=ar[Nn]=ar[En]=ar[Cn]=ar[Sn]=ar[Wn]=ar[Un]=ar[Bn]=ar[$n]=ar[zn]=ar[Fn]=ar[qn]=ar[Tn]=!1;var fr={};fr[kn]=fr[In]=fr[Nn]=fr[En]=fr[Cn]=fr[Dn]=fr[Mn]=fr[Pn]=fr[Zn]=fr[Kn]=fr[Un]=fr[Bn]=fr[$n]=fr[zn]=fr[Fn]=fr[qn]=fr[Vn]=fr[Gn]=fr[Jn]=fr[Xn]=!0,fr[Sn]=fr[Wn]=fr[Tn]=!1;var cr={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},lr={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},sr={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},pr={"function":!0,object:!0},hr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},_r=pr[typeof exports]&&exports&&!exports.nodeType?exports:null,vr=pr[typeof module]&&module&&!module.nodeType?module:null,gr=O(_r&&vr&&"object"==typeof global&&global),yr=O(pr[typeof self]&&self),dr=O(pr[typeof window]&&window),mr=vr&&vr.exports===_r?_r:null,wr=O(pr[typeof this]&&this),br=gr||dr!==(wr&&wr.window)&&dr||yr||wr||Function("return this")(),xr=J();(dr||yr||{})._=xr,"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return xr}):_r&&vr?mr?(vr.exports=xr)._=xr:_r._=xr:br._=xr}).call(this); \ No newline at end of file +/** + * @license + * lodash 4.0.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?r.length:0){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){for(var r=-1,e=n.length;++rt&&!o||!u||r&&!i&&f||e&&f)return 1;if(t>n&&!r||!f||o&&!e&&u||i&&u)return-1}return 0}function I(n){return Un[n]}function R(n){return zn[n]}function S(n){return"\\"+$n[n]}function W(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 z(n){for(var t,r=[];!(t=n.next()).done;)r.push(t.value);return r}function B(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n]}),r}function L(n,t){for(var r=-1,e=n.length,u=-1,o=[];++rr?false:(r==n.length-1?n.pop():du.call(n,r,1), +!0)}function Zn(n,t){var r=Dn(n,t);return 0>r?Z:n[r][1]}function Dn(n,t){for(var r=n.length;r--;)if(ue(n[r][0],t))return r;return-1}function qn(n,t,r){var e=Dn(n,t);0>e?n.push([t,r]):n[e][1]=r}function Pn(n,t,r,e){return n===Z||ue(n,Xe[r])&&!tu.call(e,r)?t:n}function Tn(n,t,r){(r!==Z&&!ue(n[t],r)||typeof t=="number"&&r===Z&&!(t in n))&&(n[t]=r)}function Vn(n,t,r){var e=n[t];(!ue(e,r)||ue(e,Xe[t])&&!tu.call(n,t)||r===Z&&!(t in n))&&(n[t]=r)}function Jn(n,t){return n&&Tt(t,Ce(t),n)}function Yn(n,t){ +for(var r=-1,e=null==n,u=t.length,o=Array(u);++rr?r:n),t!==Z&&(n=t>n?t:n)),n}function Qn(n,t,r,u,o,i){var f;if(r&&(f=o?r(n,u,o,i):r(n)),f!==Z)return f;if(!pe(n))return n;if(u=Wo(n)){if(f=mr(n),!t)return Pt(n,f)}else{var c=br(n),a="[object Function]"==c||"[object GeneratorFunction]"==c;if("[object Object]"!=c&&"[object Arguments]"!=c&&(!a||o))return Cn[c]?wr(n,c,t):o?n:{};if(C(n))return o?n:{};if(f=jr(a?{}:n),!t)return Gt(n,Jn(f,n)); +}return i||(i=new $n),(o=i.get(n))?o:(i.set(n,f),(u?e:it)(n,function(e,u){Vn(f,u,Qn(e,t,r,u,n,i))}),u?f:Gt(n,f))}function Xn(n){var t=Ce(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===Z&&!(o in Object(e))||!i(f))return false}return true}}function nt(n,t,r){if(typeof n!="function")throw new He("Expected a function");return vu(function(){n.apply(Z,r)},t)}function tt(n,t,r,e){var u=-1,o=i,a=true,l=n.length,s=[],h=t.length;if(!l)return s;r&&(t=c(t,j(r))), +e?(o=f,a=false):t.length>=200&&(o=Ln,a=false,t=new Bn(t));n:for(;++ur;)n=n[t[r++]];return r&&r==e?n:Z}function lt(n,t){return tu.call(n,t)||typeof n=="object"&&t in n&&null===hu(n)}function st(n,t){return t in Object(n)}function ht(n,t,r){for(var e=r?f:i,u=n.length,o=u,a=Array(u),l=[];o--;){var s=n[o];o&&t&&(s=c(s,j(t))),a[o]=r||!t&&120>s.length?Z:new Bn(o&&s); +}var s=n[0],h=-1,p=s.length,_=a[0];n:for(;++he?c*("desc"==r[e]?-1:1):c;break n}}e=n.b-t.b}return e})}function wt(n,t){return n=Object(n),l(t,function(t,r){return r in n&&(t[r]=n[r]), +t},{})}function At(n,t){var r={};return ot(n,function(n,e){t(n)&&(r[e]=n)}),r}function Ot(n){return function(t){return null==t?Z:t[n]}}function Et(n){return function(t){return at(t,n)}}function kt(n,t,r){var e=-1,u=t.length,o=n;for(r&&(o=c(n,function(n){return r(n)}));++et&&(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 zt(n,t,Ne,r)}function zt(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=null===t,c=t===Z;o>u;){var a=bu((u+o)/2),l=r(n[a]),s=l!==Z,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 Au(o,4294967294)}function Bt(n,t){for(var r=0,e=n.length,u=n[0],o=t?t(u):u,i=o,f=0,c=[u];++r1?r[u-1]:Z,i=u>2?r[2]:Z,o=typeof o=="function"?(u--,o):Z;for(i&&Or(r[0],r[1],i)&&(o=3>u?Z:o,u=1),t=Object(t);++ei&&c[0]!==l&&c[i-1]!==l?[]:L(c,l),i-=f.length,e>i?ar(n,t,ur,l,Z,c,f,Z,Z,e-i):r(a,this,c)}var o=tr(n);return u}function er(n){return ee(function(t){t=ut(t);var r=t.length,e=r,u=jn.prototype.thru;for(n&&t.reverse();e--;){var o=t[e];if(typeof o!="function")throw new He("Expected a function");if(u&&!i&&"wrapper"==gr(o))var i=new jn([],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;++uy)return ar(n,t,ur,b,r,x,m,f,c,a-y)}if(y=h?r:this,b=p?y[n]:n,f)for(var m=x.length,j=Au(f.length,m),w=Pt(x);j--;){var A=f[j]; +x[j]=U(A,m)?w[A]:Z}else v&&x.length>1&&x.reverse();return s&&x.length>c&&(x.length=c),this&&this!==Kn&&this instanceof l&&(b=d||tr(b)),b.apply(y,x)}var s=128&t,h=1&t,p=2&t,_=8&t,g=16&t,v=512&t,d=p?Z:tr(n);return l}function or(n){return ee(function(t){return t=c(ut(t),vr()),ee(function(e){var u=this;return n(t,function(n){return r(n,u,e)})})})}function ir(n,t,r){return t=Ae(t),n=F(n),t&&t>n?(t-=n,r=r===Z?" ":r+"",n=Fe(r,yu(t/F(r))),En.test(r)?n.match(On).slice(0,t).join(""):n.slice(0,t)):""}function fr(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!==Kn&&this instanceof o?f:n;++at?1:-1:Ee(e)||0;var u=-1;r=wu(yu((r-t)/(e||1)),0);for(var o=Array(r);r--;)o[n?r:++u]=t,t+=e;return o}}function ar(n,t,r,e,u,o,i,f,c,a){var l=8&t;f=f?Pt(f):Z; +var s=l?i:Z;i=l?Z:i;var h=l?o:Z;return o=l?Z: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(Z,t),Ir(n)&&Ju(r,t),r.placeholder=e,r}function lr(n){var t=Je[n];return function(n,r){if(n=Ee(n),r=Ae(r)){var e=(Ie(n)+"e").split("e"),e=t(e[0]+"e"+(+e[1]+r)),e=(Ie(e)+"e").split("e");return+(e[0]+"e"+(+e[1]-r))}return t(n)}}function sr(n,t,r,e,u,o,i,f){var c=2&t;if(!c&&typeof n!="function")throw new He("Expected a function");var a=e?e.length:0;if(a||(t&=-97,e=u=Z),i=i===Z?i:wu(Ae(i),0), +f=f===Z?f:Ae(f),a-=u?u.length:0,64&t){var l=e,s=u;e=u=Z}var h=c?Z:Ku(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?Dt(e,r,h[4]):Pt(r),o[4]=e?L(o[3],"__lodash_placeholder__"):Pt(h[4])),(r=h[5])&&(e=o[5],o[5]=e?qt(e,r,h[6]):Pt(r),o[6]=e?L(o[5],"__lodash_placeholder__"):Pt(h[6])),(r=h[7])&&(o[7]=Pt(r)),128&n&&(o[8]=null==o[8]?h[8]:Au(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:wu(o[9]-a,0),!f&&24&t&&(t&=-25),(h?Pu:Ju)(t&&1!=t?8==t||16==t?rr(n,t,f):32!=t&&33!=t||u.length?ur.apply(Z,o):fr(n,t,r,e):Qt(n,t,r),o)}function hr(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 $r(n,t,r){var e=n?n.length:0;return e?(t=r||t===Z?1:Ae(t),t=e-t,Wt(n,0,0>t?0:t)):[]}function Fr(n){return n?n[0]:Z; +}function Mr(n){var t=n?n.length:0;return t?n[t-1]:Z}function Nr(n,t){return n&&n.length&&t&&t.length?kt(n,t):n}function Zr(n){return n?ku.call(n):n}function Dr(n){if(!n||!n.length)return[];var t=0;return n=o(n,function(n){return ce(n)?(t=wu(n.length,t),true):void 0}),x(t,function(t){return c(n,Ot(t))})}function qr(n,t){if(!n||!n.length)return[];var e=Dr(n);return null==t?e:c(e,function(n){return r(t,Z,n)})}function Pr(n){return n=dn(n),n.__chain__=true,n}function Tr(n,t){return t(n)}function Kr(){return this; +}function Gr(n,t){return typeof t=="function"&&Wo(n)?e(n,t):Nu(n,zr(t))}function Vr(n,t){var r;if(typeof t=="function"&&Wo(n)){for(r=n.length;r--&&false!==t(n[r],r,n););r=n}else r=Zu(n,zr(t));return r}function Jr(n,t){var r=-1,e=we(n),u=e.length,o=u-1;for(t=Hn(Ae(t),0,u);++r=n&&(t=Z),r}}function Xr(n,t,r){return t=r?Z:t,n=sr(n,8,Z,Z,Z,Z,Z,t),n.placeholder=Xr.placeholder,n}function ne(n,t,r){return t=r?Z:t,n=sr(n,16,Z,Z,Z,Z,Z,t),n.placeholder=ne.placeholder,n}function te(n,t,r){function e(){p&&lu(p),a&&lu(a),g=0,c=a=h=p=_=Z}function u(t,r){r&&lu(r),a=p=_=Z,t&&(g=jo(),l=n.apply(h,c),p||a||(c=h=Z))}function o(){var n=t-(jo()-s); +0>=n||n>t?u(_,a):p=vu(o,n)}function i(){u(y,p)}function f(){if(c=arguments,s=jo(),h=this,_=y&&(p||!v),false===d)var r=v&&!p;else{a||v||(g=s);var e=d-(s-g),u=0>=e||e>d;u?(a&&(a=lu(a)),g=s,l=n.apply(h,c)):a||(a=vu(i,e))}return u&&p?p=lu(p):p||t===d||(p=vu(o,t)),r&&(u=true,l=n.apply(h,c)),!u||p||a||(c=h=Z),l}var c,a,l,s,h,p,_,g=0,v=false,d=false,y=true;if(typeof n!="function")throw new He("Expected a function");return t=Ee(t)||0,pe(r)&&(v=!!r.leading,d="maxWait"in r&&wu(Ee(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 re(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 He("Expected a function");return r.cache=new re.Cache,r}function ee(n,t){if(typeof n!="function")throw new He("Expected a function");return t=wu(t===Z?n.length-1:Ae(t),0),function(){for(var e=arguments,u=-1,o=wu(e.length-t,0),i=Array(o);++ut}function ie(n){return ce(n)&&tu.call(n,"callee")&&(!gu.call(n,"callee")||"[object Arguments]"==uu.call(n))}function fe(n){return null!=n&&!(typeof n=="function"&&le(n))&&he(Gu(n))}function ce(n){return _e(n)&&fe(n)}function ae(n){return _e(n)&&typeof n.message=="string"&&"[object Error]"==uu.call(n); +}function le(n){return n=pe(n)?uu.call(n):"","[object Function]"==n||"[object GeneratorFunction]"==n}function se(n){return typeof n=="number"&&n==Ae(n)}function he(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n}function pe(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function _e(n){return!!n&&typeof n=="object"}function ge(n){return null==n?false:le(n)?iu.test(nu.call(n)):_e(n)&&(C(n)?iu:gn).test(n)}function ve(n){return typeof n=="number"||_e(n)&&"[object Number]"==uu.call(n); +}function de(n){if(!_e(n)||"[object Object]"!=uu.call(n)||C(n))return false;var t=Xe;return typeof n.constructor=="function"&&(t=hu(n)),null===t?true:(n=t.constructor,typeof n=="function"&&n instanceof n&&nu.call(n)==eu)}function ye(n){return pe(n)&&"[object RegExp]"==uu.call(n)}function be(n){return typeof n=="string"||!Wo(n)&&_e(n)&&"[object String]"==uu.call(n)}function xe(n){return typeof n=="symbol"||_e(n)&&"[object Symbol]"==uu.call(n)}function me(n){return _e(n)&&he(n.length)&&!!Wn[uu.call(n)]}function je(n,t){ +return t>n}function we(n){if(!n)return[];if(fe(n))return be(n)?n.match(On):Pt(n);if(_u&&n[_u])return z(n[_u]());var t=br(n);return("[object Map]"==t?B:"[object Set]"==t?$:Be)(n)}function Ae(n){if(!n)return 0===n?n:0;if(n=Ee(n),n===D||n===-D)return 1.7976931348623157e308*(0>n?-1:1);var t=n%1;return n===n?t?n-t:n:0}function Oe(n){return n?Hn(Ae(n),0,4294967295):0}function Ee(n){if(pe(n)&&(n=le(n.valueOf)?n.valueOf():n,n=pe(n)?n+"":n),typeof n!="string")return 0===n?n:+n;n=n.replace(on,"");var t=_n.test(n); +return t||vn.test(n)?Mn(n.slice(2),t?2:8):pn.test(n)?q:+n}function ke(n){return Tt(n,Ue(n))}function Ie(n){if(typeof n=="string")return n;if(null==n)return"";if(xe(n))return fu?$u.call(n):"";var t=n+"";return"0"==t&&1/n==-D?"-0":t}function Re(n,t,r){return n=null==n?Z:at(n,t),n===Z?r:n}function Se(n,t){return xr(n,t,lt)}function We(n,t){return xr(n,t,st)}function Ce(n){var t=Rr(n);if(!t&&!fe(n))return ju(Object(n));var r,e=Ar(n),u=!!e,e=e||[],o=e.length;for(r in n)!lt(n,r)||u&&("length"==r||U(r,o))||t&&"constructor"==r||e.push(r); +return e}function Ue(n){for(var t=-1,r=Rr(n),e=dt(n),u=e.length,o=Ar(n),i=!!o,o=o||[],f=o.length;++tt||t>9007199254740991)return r;do t%2&&(r+=n),t=bu(t/2),n+=n;while(t);return r; +}function Me(n,t,r){return n=Ie(n),t=r?Z:t,t===Z&&(t=Rn.test(n)?In:kn),n.match(t)||[]}function Ne(n){return n}function Ze(n){return _e(n)&&!Wo(n)?De(n):vt(n)}function De(n){return bt(Qn(n,true))}function qe(n,t,r){var u=Ce(t),o=ct(t,u);null!=r||pe(t)&&(o.length||!u.length)||(r=t,t=n,n=this,o=ct(t,Ce(t)));var i=pe(r)&&"chain"in r?r.chain:true,f=le(n);return e(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__=Pt(this.__actions__)).push({ +func:e,args:arguments,thisArg:n}),r.__chain__=t,r}return e.apply(n,a([this.value()],arguments))})}),n}function Pe(){}function Te(n){return Er(n)?Ot(n):Et(n)}function Ke(n){return n&&n.length?b(n,Ne):Z}E=E?Gn.defaults({},E,Gn.pick(Kn,Sn)):Kn;var Ge=E.Date,Ve=E.Error,Je=E.Math,Ye=E.RegExp,He=E.TypeError,Qe=E.Array.prototype,Xe=E.Object.prototype,nu=E.Function.prototype.toString,tu=Xe.hasOwnProperty,ru=0,eu=nu.call(Object),uu=Xe.toString,ou=Kn._,iu=Ye("^"+nu.call(tu).replace(en,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),fu=E.Symbol,cu=E.f,au=E.Uint8Array,lu=E.clearTimeout,su=cu?cu.g:Z,hu=Object.getPrototypeOf,pu=Object.getOwnPropertySymbols,_u=typeof(_u=fu&&fu.iterator)=="symbol"?_u:Z,gu=Xe.propertyIsEnumerable,vu=E.setTimeout,du=Qe.splice,yu=Je.ceil,bu=Je.floor,xu=E.isFinite,mu=Qe.join,ju=Object.keys,wu=Je.max,Au=Je.min,Ou=E.parseInt,Eu=Je.random,ku=Qe.reverse,Iu=yr(E,"Map"),Ru=yr(E,"Set"),Su=yr(E,"WeakMap"),Wu=yr(Object,"create"),Cu=Su&&new Su,Uu=Iu?nu.call(Iu):"",zu=Ru?nu.call(Ru):"",Bu=fu?fu.prototype:Z,Lu=fu?Bu.valueOf:Z,$u=fu?Bu.toString:Z,Fu={}; +dn.templateSettings={escape:H,evaluate:Q,interpolate:X,variable:"",imports:{_:dn}};var Mu=function(){function n(){}return function(t){if(pe(t)){n.prototype=t;var r=new n;n.prototype=Z}return r||{}}}(),Nu=Yt(it),Zu=Yt(ft,true),Du=Ht(),qu=Ht(true);su&&!gu.call({valueOf:1},"valueOf")&&(dt=function(n){return z(su(n))});var Pu=Cu?function(n,t){return Cu.set(n,t),n}:Ne,Tu=Ru&&2===new Ru([1,2]).size?function(n){return new Ru(n)}:Pe,Ku=Cu?function(n){return Cu.get(n)}:Pe,Gu=Ot("length"),Vu=pu||function(){return[]; +};(Iu&&"[object Map]"!=br(new Iu)||Ru&&"[object Set]"!=br(new Ru))&&(br=function(n){var t=uu.call(n);if(n="[object Object]"==t?n.constructor:null,n=typeof n=="function"?nu.call(n):""){if(n==Uu)return"[object Map]";if(n==zu)return"[object Set]"}return t});var Ju=function(){var n=0,t=0;return function(r,e){var u=jo(),o=16-(u-t);if(t=u,o>0){if(150<=++n)return r}else n=0;return Pu(r,e)}}(),Yu=ee(function(n,t){t=ut(t);for(var r=Wo(n)?n:[Object(n)],e=t,u=-1,o=r.length,i=-1,f=e.length,c=Array(o+f);++u1?n[t-1]:Z,t=typeof t=="function"?(n.pop(),t):Z;return qr(n,t)}),_o=ee(function(n){function t(t){return Yn(t,n)}n=ut(n);var r=n.length,e=r?n[0]:0,u=this.__wrapped__;return 1>=r&&!this.__actions__.length&&u instanceof wn&&U(e)?(u=u.slice(e,+e+(r?1:0)),u.__actions__.push({func:Tr,args:[t],thisArg:Z}),new jn(u,this.__chain__).thru(function(n){return r&&!n.length&&n.push(Z),n})):this.thru(t)}),go=Vt(function(n,t,r){tu.call(n,r)?++n[r]:n[r]=1; +}),vo=Vt(function(n,t,r){tu.call(n,r)?n[r].push(t):n[r]=[t]}),yo=ee(function(n,t,e){var u=-1,o=typeof t=="function",i=Er(t),f=fe(n)?Array(n.length):[];return Nu(n,function(n){var c=o?t:i&&null!=n?n[t]:Z;f[++u]=c?r(c,n,e):pt(n,t,e)}),f}),bo=Vt(function(n,t,r){n[r]=t}),xo=Vt(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),mo=ee(function(n,t){if(null==n)return[];var r=t.length;return r>1&&Or(n,t[0],t[1])?t=[]:r>2&&Or(t[0],t[1],t[2])&&(t.length=1),jt(n,ut(t),[])}),jo=Ge.now,wo=ee(function(n,t,r){ +var e=1;if(r.length)var u=L(r,wo.placeholder),e=32|e;return sr(n,e,t,r,u)}),Ao=ee(function(n,t,r){var e=3;if(r.length)var u=L(r,Ao.placeholder),e=32|e;return sr(t,e,n,r,u)}),Oo=ee(function(n,t){return nt(n,1,t)}),Eo=ee(function(n,t,r){return nt(n,Ee(t)||0,r)}),ko=ee(function(n,t){t=c(ut(t),vr());var e=t.length;return ee(function(u){for(var o=-1,i=Au(u.length,e);++oe.length?qn(e,n,t):(r.array=null,r.map=new zn(e))),(r=r.map)&&r.set(n,t), +this},re.Cache=zn,dn.after=function(n,t){if(typeof t!="function")throw new He("Expected a function");return n=Ae(n),function(){return 1>--n?t.apply(this,arguments):void 0}},dn.ary=Hr,dn.assign=Co,dn.assignIn=Uo,dn.assignInWith=zo,dn.assignWith=Bo,dn.at=Lo,dn.before=Qr,dn.bind=wo,dn.bindAll=Xo,dn.bindKey=Ao,dn.chain=Pr,dn.chunk=function(n,t){t=wu(Ae(t),0);var r=n?n.length:0;if(!r||1>t)return[];for(var e=0,u=-1,o=Array(yu(r/t));r>e;)o[++u]=Wt(n,e,e+=t);return o},dn.compact=function(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++tr&&(r=-r>u?0:u+r),e=e===Z||e>u?u:Ae(e),0>e&&(e+=u),e=r>e?0:Oe(e);e>r;)n[r++]=t;return n}, +dn.filter=function(n,t){return(Wo(n)?o:et)(n,vr(t,3))},dn.flatMap=function(n,t){return n&&n.length?ut(c(n,vr(t,3))):[]},dn.flatten=function(n){return n&&n.length?ut(n):[]},dn.flattenDeep=function(n){return n&&n.length?ut(n,true):[]},dn.flip=function(n){return sr(n,512)},dn.flow=ni,dn.flowRight=ti,dn.fromPairs=function(n){for(var t=-1,r=n?n.length:0,e={};++tt?0:t)):[]},dn.takeRight=function(n,t,r){var e=n?n.length:0;return e?(t=r||t===Z?1:Ae(t),t=e-t,Wt(n,0>t?0:t,e)):[]},dn.takeRightWhile=function(n,t){return n&&n.length?Ft(n,vr(t,3),false,true):[]},dn.takeWhile=function(n,t){return n&&n.length?Ft(n,vr(t,3)):[]},dn.tap=function(n,t){return t(n),n},dn.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new He("Expected a function");return pe(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u), +te(n,t,{leading:e,maxWait:t,trailing:u})},dn.thru=Tr,dn.toArray=we,dn.toPairs=ze,dn.toPairsIn=function(n){return m(n,Ue(n))},dn.toPath=function(n){return Wo(n)?c(n,String):Cr(n)},dn.toPlainObject=ke,dn.transform=function(n,t,r){var u=Wo(n)||me(n);if(t=vr(t,4),null==r)if(u||pe(n)){var o=n.constructor;r=u?Wo(n)?new o:[]:Mu(le(o)?o.prototype:Z)}else r={};return(u?e:it)(n,function(n,e,u){return t(r,n,e,u)}),r},dn.unary=function(n){return Hr(n,1)},dn.union=oo,dn.unionBy=io,dn.unionWith=fo,dn.uniq=function(n){ +return n&&n.length?$t(n):[]},dn.uniqBy=function(n,t){return n&&n.length?$t(n,vr(t)):[]},dn.uniqWith=function(n,t){return n&&n.length?$t(n,Z,t):[]},dn.unset=function(n,t){var r;if(null==n)r=true;else{r=n;var e=t,e=Er(e,r)?[e+""]:Lt(e);r=Wr(r,e),e=Mr(e),r=null!=r&&Se(r,e)?delete r[e]:true}return r},dn.unzip=Dr,dn.unzipWith=qr,dn.values=Be,dn.valuesIn=function(n){return null==n?w(n,Ue(n)):[]},dn.without=co,dn.words=Me,dn.wrap=function(n,t){return t=null==t?Ne:t,Io(t,n)},dn.xor=ao,dn.xorBy=lo,dn.xorWith=so, +dn.zip=ho,dn.zipObject=function(n,t){for(var r=-1,e=n?n.length:0,u=t?t.length:0,o={};++rr?t[r]:Z);return o},dn.zipWith=po,dn.each=Gr,dn.eachRight=Vr,dn.extend=Uo,dn.extendWith=zo,qe(dn,dn),dn.add=function(n,t){var r;return n!==Z&&(r=n),t!==Z&&(r=r===Z?t:r+t),r},dn.attempt=Qo,dn.camelCase=Po,dn.capitalize=Le,dn.ceil=ai,dn.clamp=function(n,t,r){return r===Z&&(r=t,t=Z),r!==Z&&(r=Ee(r),r=r===r?r:0),t!==Z&&(t=Ee(t),t=t===t?t:0),Hn(Ee(n),t,r)},dn.clone=function(n){return Qn(n)},dn.cloneDeep=function(n){ +return Qn(n,true)},dn.cloneDeepWith=function(n,t){return Qn(n,true,t)},dn.cloneWith=function(n,t){return Qn(n,false,t)},dn.deburr=$e,dn.endsWith=function(n,t,r){n=Ie(n),t=typeof t=="string"?t:t+"";var e=n.length;return r=r===Z?e:Hn(Ae(r),0,e),r-=t.length,r>=0&&n.indexOf(t,r)==r},dn.eq=ue,dn.escape=function(n){return(n=Ie(n))&&Y.test(n)?n.replace(V,R):n},dn.escapeRegExp=function(n){return(n=Ie(n))&&un.test(n)?n.replace(en,"\\$&"):n},dn.every=function(n,t,r){var e=Wo(n)?u:rt;return r&&Or(n,t,r)&&(t=Z),e(n,vr(t,3)); +},dn.find=function(n,t){if(t=vr(t,3),Wo(n)){var r=g(n,t);return r>-1?n[r]:Z}return _(n,t,Nu)},dn.findIndex=function(n,t){return n&&n.length?g(n,vr(t,3)):-1},dn.findKey=function(n,t){return _(n,vr(t,3),it,true)},dn.findLast=function(n,t){if(t=vr(t,3),Wo(n)){var r=g(n,t,true);return r>-1?n[r]:Z}return _(n,t,Zu)},dn.findLastIndex=function(n,t){return n&&n.length?g(n,vr(t,3),true):-1},dn.findLastKey=function(n,t){return _(n,vr(t,3),ft,true)},dn.floor=li,dn.forEach=Gr,dn.forEachRight=Vr,dn.forIn=function(n,t){ +return null==n?n:Du(n,zr(t),Ue)},dn.forInRight=function(n,t){return null==n?n:qu(n,zr(t),Ue)},dn.forOwn=function(n,t){return n&&it(n,zr(t))},dn.forOwnRight=function(n,t){return n&&ft(n,zr(t))},dn.get=Re,dn.gt=oe,dn.gte=function(n,t){return n>=t},dn.has=Se,dn.hasIn=We,dn.head=Fr,dn.identity=Ne,dn.includes=function(n,t,r,e){return n=fe(n)?n:Be(n),r=r&&!e?Ae(r):0,e=n.length,0>r&&(r=wu(e+r,0)),be(n)?e>=r&&-1r&&(r=wu(e+r,0)),v(n,t,r)):-1},dn.inRange=function(n,t,r){return t=Ee(t)||0,r===Z?(r=t,t=0):r=Ee(r)||0,n=Ee(n),n>=Au(t,r)&&n=-9007199254740991&&9007199254740991>=n},dn.isString=be,dn.isSymbol=xe,dn.isTypedArray=me,dn.isUndefined=function(n){return n===Z},dn.join=function(n,t){return n?mu.call(n,t):""},dn.kebabCase=To,dn.last=Mr,dn.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(r!==Z&&(u=Ae(r),u=(0>u?wu(e+u,0):Au(u,e-1))+1),t!==t)return W(n,u,true);for(;u--;)if(n[u]===t)return u; +return-1},dn.lowerCase=Ko,dn.lowerFirst=Go,dn.lt=je,dn.lte=function(n,t){return t>=n},dn.max=function(n){return n&&n.length?p(n,Ne,oe):Z},dn.maxBy=function(n,t){return n&&n.length?p(n,vr(t),oe):Z},dn.mean=function(n){return Ke(n)/(n?n.length:0)},dn.min=function(n){return n&&n.length?p(n,Ne,je):Z},dn.minBy=function(n,t){return n&&n.length?p(n,vr(t),je):Z},dn.noConflict=function(){return Kn._=ou,this},dn.noop=Pe,dn.now=jo,dn.pad=function(n,t,r){n=Ie(n),t=Ae(t);var e=F(n);return t&&t>e?(e=(t-e)/2,t=bu(e), +e=yu(e),ir("",t,r)+n+ir("",e,r)):n},dn.padEnd=function(n,t,r){return n=Ie(n),n+ir(n,t,r)},dn.padStart=function(n,t,r){return n=Ie(n),ir(n,t,r)+n},dn.parseInt=function(n,t,r){return r||null==t?t=0:t&&(t=+t),n=Ie(n).replace(on,""),Ou(n,t||(hn.test(n)?16:10))},dn.random=function(n,t,r){if(r&&typeof r!="boolean"&&Or(n,t,r)&&(t=r=Z),r===Z&&(typeof t=="boolean"?(r=t,t=Z):typeof n=="boolean"&&(r=n,n=Z)),n===Z&&t===Z?(n=0,t=1):(n=Ee(n)||0,t===Z?(t=n,n=0):t=Ee(t)||0),n>t){var e=n;n=t,t=e}return r||n%1||t%1?(r=Eu(), +Au(n+r*(t-n+Fn("1e-"+((r+"").length-1))),t)):Rt(n,t)},dn.reduce=function(n,t,r){var e=Wo(n)?l:d,u=3>arguments.length;return e(n,vr(t,4),r,u,Nu)},dn.reduceRight=function(n,t,r){var e=Wo(n)?s:d,u=3>arguments.length;return e(n,vr(t,4),r,u,Zu)},dn.repeat=Fe,dn.replace=function(){var n=arguments,t=Ie(n[0]);return 3>n.length?t:t.replace(n[1],n[2])},dn.result=function(n,t,r){if(Er(t,n))e=null==n?Z:n[t];else{t=Lt(t);var e=Re(n,t);n=Wr(n,t)}return e===Z&&(e=r),le(e)?e.call(n):e},dn.round=si,dn.runInContext=N, +dn.sample=function(n){n=fe(n)?n:Be(n);var t=n.length;return t>0?n[Rt(0,t-1)]:Z},dn.size=Yr,dn.snakeCase=Jo,dn.some=function(n,t,r){var e=Wo(n)?h:Ct;return r&&Or(n,t,r)&&(t=Z),e(n,vr(t,3))},dn.sortedIndex=function(n,t){return Ut(n,t)},dn.sortedIndexBy=function(n,t,r){return zt(n,t,vr(r))},dn.sortedIndexOf=function(n,t){var r=n?n.length:0;if(r){var e=Ut(n,t);if(r>e&&ue(n[e],t))return e}return-1},dn.sortedLastIndex=function(n,t){return Ut(n,t,true)},dn.sortedLastIndexBy=function(n,t,r){return zt(n,t,vr(r),true); +},dn.sortedLastIndexOf=function(n,t){if(n&&n.length){var r=Ut(n,t,true)-1;if(ue(n[r],t))return r}return-1},dn.startCase=Yo,dn.startsWith=function(n,t,r){return n=Ie(n),r=Hn(Ae(r),0,n.length),n.lastIndexOf(t,r)==r},dn.subtract=function(n,t){var r;return n!==Z&&(r=n),t!==Z&&(r=r===Z?t:r-t),r},dn.sum=Ke,dn.sumBy=function(n,t){return n&&n.length?b(n,vr(t)):Z},dn.template=function(n,t,r){var e=dn.templateSettings;r&&Or(n,t,r)&&(t=Z),n=Ie(n),t=zo({},t,e,Pn),r=zo({},t.imports,e.imports,Pn);var u,o,i=Ce(r),f=w(r,i),c=0; +r=t.interpolate||bn;var a="__p+='";r=Ye((t.escape||bn).source+"|"+r.source+"|"+(r===X?ln:bn).source+"|"+(t.evaluate||bn).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(xn,S),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(P,""):a).replace(T,"$1").replace(K,"$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=Qo(function(){return Function(i,l+"return "+a).apply(Z,f)}),t.source=a,ae(t))throw t;return t},dn.times=function(n,t){if(n=Ae(n),1>n||n>9007199254740991)return[];var r=4294967295,e=Au(n,4294967295);for(t=zr(t),n-=4294967295,e=x(e,t);++r=o)return n;if(o=r-F(e),1>o)return e;if(r=i?i.slice(0,o).join(""):n.slice(0,o),u===Z)return r+e;if(i&&(o+=r.length-o),ye(u)){if(n.slice(o).search(u)){var f=r;for(u.global||(u=Ye(u.source,Ie(sn.exec(u))+"g")),u.lastIndex=0;i=u.exec(f);)var c=i.index; +r=r.slice(0,c===Z?o:c)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),u>-1&&(r=r.slice(0,u)));return r+e},dn.unescape=function(n){return(n=Ie(n))&&J.test(n)?n.replace(G,M):n},dn.uniqueId=function(n){var t=++ru;return Ie(n)+t},dn.upperCase=Ho,dn.upperFirst=Vo,dn.first=Fr,qe(dn,function(){var n={};return it(dn,function(t,r){tu.call(dn.prototype,r)||(n[r]=t)}),n}(),{chain:false}),dn.VERSION="4.0.0",e("bind bindKey curry curryRight partial partialRight".split(" "),function(n){dn[n].placeholder=dn}),e(["drop","take"],function(n,t){ +wn.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new wn(this);r=r===Z?1:wu(Ae(r),0);var u=this.clone();return e?u.__takeCount__=Au(r,u.__takeCount__):u.__views__.push({size:Au(r,4294967295),type:n+(0>u.__dir__?"Right":"")}),u},wn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),e(["filter","map","takeWhile"],function(n,t){var r=t+1,e=1==r||3==r;wn.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({iteratee:vr(n,3),type:r}),t.__filtered__=t.__filtered__||e, +t}}),e(["head","last"],function(n,t){var r="take"+(t?"Right":"");wn.prototype[n]=function(){return this[r](1).value()[0]}}),e(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");wn.prototype[n]=function(){return this.__filtered__?new wn(this):this[r](1)}}),wn.prototype.compact=function(){return this.filter(Ne)},wn.prototype.find=function(n){return this.filter(n).head()},wn.prototype.findLast=function(n){return this.reverse().find(n)},wn.prototype.invokeMap=ee(function(n,t){return typeof n=="function"?new wn(this):this.map(function(r){ +return pt(r,n,t)})}),wn.prototype.reject=function(n){return n=vr(n,3),this.filter(function(t){return!n(t)})},wn.prototype.slice=function(n,t){n=Ae(n);var r=this;return r.__filtered__&&(n>0||0>t)?new wn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==Z&&(t=Ae(t),r=0>t?r.dropRight(-t):r.take(t-n)),r)},wn.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},wn.prototype.toArray=function(){return this.take(4294967295)},it(wn.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=dn[e?"take"+("last"==t?"Right":""):t],o=e||/^find/.test(t); +u&&(dn.prototype[t]=function(){function t(n){return n=u.apply(dn,a([n],f)),e&&h?n[0]:n}var i=this.__wrapped__,f=e?[1]:arguments,c=i instanceof wn,l=f[0],s=c||Wo(i);s&&r&&typeof l=="function"&&1!=l.length&&(c=s=false);var h=this.__chain__,p=!!this.__actions__.length,l=o&&!h,c=c&&!p;return!o&&s?(i=c?i:new wn(this),i=n.apply(i,f),i.__actions__.push({func:Tr,args:[t],thisArg:Z}),new jn(i,h)):l&&c?n.apply(this,f):(i=this.thru(t),l?e?i.value()[0]:i.value():i)})}),e("pop push shift sort splice unshift".split(" "),function(n){ +var t=Qe[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/.test(n);dn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),it(wn.prototype,function(n,t){var r=dn[t];if(r){var e=r.name+"";(Fu[e]||(Fu[e]=[])).push({name:t,func:r})}}),Fu[ur(Z,2).name]=[{name:"wrapper",func:Z}],wn.prototype.clone=function(){var n=new wn(this.__wrapped__);return n.__actions__=Pt(this.__actions__),n.__dir__=this.__dir__, +n.__filtered__=this.__filtered__,n.__iteratees__=Pt(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Pt(this.__views__),n},wn.prototype.reverse=function(){if(this.__filtered__){var n=new wn(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},wn.prototype.value=function(){var n,t=this.__wrapped__.value(),r=this.__dir__,e=Wo(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 Mt(t,this.__actions__);e=[];n:for(;n--&&a>c;){for(u+=r,o=-1,l=t[u];++o=this.__values__.length,t=n?Z:this.__values__[this.__index__++];return{done:n,value:t}},dn.prototype.plant=function(n){for(var t,r=this;r instanceof mn;){var e=Br(r);e.__index__=0,e.__values__=Z,t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},dn.prototype.reverse=function(){ +var n=this.__wrapped__;return n instanceof wn?(this.__actions__.length&&(n=new wn(this)),n=n.reverse(),n.__actions__.push({func:Tr,args:[Zr],thisArg:Z}),new jn(n,this.__chain__)):this.thru(Zr)},dn.prototype.toJSON=dn.prototype.valueOf=dn.prototype.value=function(){return Mt(this.__wrapped__,this.__actions__)},_u&&(dn.prototype[_u]=Kr),dn}var Z,D=1/0,q=NaN,P=/\b__p\+='';/g,T=/\b(__p\+=)''\+/g,K=/(__e\(.*?\)|\b__t\))\+'';/g,G=/&(?:amp|lt|gt|quot|#39|#96);/g,V=/[&<>"'`]/g,J=RegExp(G.source),Y=RegExp(V.source),H=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,nn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tn=/^\w*$/,rn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,en=/[\\^$.*+?()[\]{}|]/g,un=RegExp(en.source),on=/^\s+|\s+$/g,fn=/^\s+/,cn=/\s+$/,an=/\\(\\)?/g,ln=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,sn=/\w*$/,hn=/^0x/i,pn=/^[-+]0x[0-9a-f]+$/i,_n=/^0b[01]+$/i,gn=/^\[object .+?Constructor\]$/,vn=/^0o[0-7]+$/i,dn=/^(?:0|[1-9]\d*)$/,yn=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,bn=/($^)/,xn=/['\n\r\u2028\u2029\\]/g,mn="[\\ufe0e\\ufe0f]?(?:\\ud83c[\\udffb-\\udfff])?(?:\\u200d(?:[^\\ud800-\\udfff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])[\\ufe0e\\ufe0f]?(?:\\ud83c[\\udffb-\\udfff])?)*",jn="(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])"+mn,wn="(?:[^\\ud800-\\udfff][\\u0300-\\u036f\\ufe20-\\ufe23]?|[\\u0300-\\u036f\\ufe20-\\ufe23]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\ud800-\\udfff])",An=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe23]","g"),On=RegExp(wn+mn,"g"),En=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\ufe0e\\ufe0f]"),kn=/[a-zA-Z0-9]+/g,In=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])+|\\d+(?:(?:[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])+)?",jn].join("|"),"g"),Rn=/[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Sn="Array 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(" "),Wn={}; +Wn["[object Float32Array]"]=Wn["[object Float64Array]"]=Wn["[object Int8Array]"]=Wn["[object Int16Array]"]=Wn["[object Int32Array]"]=Wn["[object Uint8Array]"]=Wn["[object Uint8ClampedArray]"]=Wn["[object Uint16Array]"]=Wn["[object Uint32Array]"]=true,Wn["[object Arguments]"]=Wn["[object Array]"]=Wn["[object ArrayBuffer]"]=Wn["[object Boolean]"]=Wn["[object Date]"]=Wn["[object Error]"]=Wn["[object Function]"]=Wn["[object Map]"]=Wn["[object Number]"]=Wn["[object Object]"]=Wn["[object RegExp]"]=Wn["[object Set]"]=Wn["[object String]"]=Wn["[object WeakMap]"]=false; +var Cn={};Cn["[object Arguments]"]=Cn["[object Array]"]=Cn["[object ArrayBuffer]"]=Cn["[object Boolean]"]=Cn["[object Date]"]=Cn["[object Float32Array]"]=Cn["[object Float64Array]"]=Cn["[object Int8Array]"]=Cn["[object Int16Array]"]=Cn["[object Int32Array]"]=Cn["[object Map]"]=Cn["[object Number]"]=Cn["[object Object]"]=Cn["[object RegExp]"]=Cn["[object Set]"]=Cn["[object String]"]=Cn["[object Symbol]"]=Cn["[object Uint8Array]"]=Cn["[object Uint8ClampedArray]"]=Cn["[object Uint16Array]"]=Cn["[object Uint32Array]"]=true, +Cn["[object Error]"]=Cn["[object Function]"]=Cn["[object WeakMap]"]=false;var Un={"\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"},zn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Bn={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ln={"function":true,object:true},$n={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029" +},Fn=parseFloat,Mn=parseInt,Nn=Ln[typeof exports]&&exports&&!exports.nodeType?exports:null,Zn=Ln[typeof module]&&module&&!module.nodeType?module:null,Dn=E(Ln[typeof self]&&self),qn=E(Ln[typeof window]&&window),Pn=Zn&&Zn.exports===Nn?Nn:null,Tn=E(Ln[typeof this]&&this),Kn=E(Nn&&Zn&&typeof global=="object"&&global)||qn!==(Tn&&Tn.window)&&qn||Dn||Tn||Function("return this")(),Gn=N();(qn||Dn||{})._=Gn,typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return Gn}):Nn&&Zn?(Pn&&((Zn.exports=Gn)._=Gn), +Nn._=Gn):Kn._=Gn}).call(this); \ No newline at end of file diff --git a/dist/mapping.fp.js b/dist/mapping.fp.js index a591a2bd6..fcf6e537c 100644 --- a/dist/mapping.fp.js +++ b/dist/mapping.fp.js @@ -59,8 +59,8 @@ return /******/ (function(modules) { // webpackBootstrap /** Used to map method names to their aliases. */ 'aliasMap': { 'ary': ['nAry'], - 'conj': ['allPass'], - 'disj': ['somePass'], + 'overEvery': ['allPass'], + 'overSome': ['somePass'], 'filter': ['whereEq'], 'flatten': ['unnest'], 'flow': ['pipe'], @@ -75,8 +75,7 @@ return /******/ (function(modules) { // webpackBootstrap 'isEqual': ['equals'], 'mapValues': ['mapObj'], 'matchesProperty': ['pathEq'], - 'modArgs': ['useWith'], - 'modArgsSet': ['converge'], + 'overArgs': ['useWith'], 'omit': ['dissoc', 'omitAll'], 'pick': ['pickAll'], 'property': ['prop'], @@ -130,28 +129,28 @@ return /******/ (function(modules) { // webpackBootstrap /** Used to map ary to method names. */ 'aryMethodMap': { 1: ( - 'attempt,ceil,create,curry,floor,fromPairs,iteratee,invert,over,overEvery,' + - 'overSome,memoize,method,methodOf,mixin,rest,reverse,round,runInContext,template,' + - 'trim,trimLeft,trimRight,uniqueId,words').split(','), + 'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,' + + 'overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,' + + 'runInContext,template,trim,trimLeft,trimRight,uniqueId,words').split(','), 2: ( 'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,' + - 'debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,dropRightWhile,' + - 'dropWhile,endsWith,every,extend,filter,find,find,findIndex,findKey,findLast,' + - 'findLastIndex,findLastKey,flatMap,forEach,forEachRight,forIn,forInRight,' + - 'forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,intersection,' + - 'invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,matchesProperty,' + - 'maxBy,mean,minBy,merge,modArgs,modArgsSet,omit,pad,padLeft,padRight,parseInt,' + - 'partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,' + - 'remove,repeat,result,sampleSize,set,some,sortBy,sortByOrder,sortedIndexBy,' + + 'curryRightN,debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,' + + 'dropRightWhile,dropWhile,endsWith,eq,every,extend,filter,find,find,findIndex,' + + 'findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,forEachRight,' + + 'forIn,forInRight,forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,' + + 'intersection,invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,' + + 'matchesProperty,maxBy,mean,minBy,merge,omit,orderBy,overArgs,pad,padLeft,' + + 'padRight,parseInt,partition,pick,pull,pullAll,pullAt,random,range,rangeRight,' + + 'rearg,reject,remove,repeat,result,sampleSize,some,sortBy,sortedIndexBy,' + 'sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,' + 'takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,' + 'xor,zip,zipObject').split(','), 3: ( 'assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,' + 'isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,' + - 'reduceRight,slice,transform,unionBy,xorBy,zipWith').split(','), + 'reduceRight,set,slice,transform,unionBy,xorBy,zipWith').split(','), 4: - ['fill'] + ['fill', 'setWith'] }, /** Used to map ary to rearg configs by method ary. */ @@ -166,6 +165,7 @@ return /******/ (function(modules) { // webpackBootstrap 'clamp': [2, 0, 1], 'reduce': [2, 0, 1], 'reduceRight': [2, 0, 1], + 'setWith': [3, 2, 1, 0], 'slice': [2, 0, 1], 'transform': [2, 0, 1] }, @@ -200,6 +200,10 @@ return /******/ (function(modules) { // webpackBootstrap 'extendWith': true, 'merge': true, 'mergeWith': true + }, + 'set': { + 'set': true, + 'setWith': true } }, diff --git a/doc/README.md b/doc/README.md index bbd430f0f..284661792 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,117 +1,103 @@ -# lodash v3.10.1 +# lodash v4.0.0 ## `Array` -* `_.chunk` +* `_.chunk` * `_.compact` +* `_.concat` * `_.difference` +* `_.differenceBy` +* `_.differenceWith` * `_.drop` * `_.dropRight` -* `_.dropRightWhile` -* `_.dropWhile` +* `_.dropRightWhile` +* `_.dropWhile` * `_.fill` -* `_.findIndex` -* `_.findLastIndex` -* `_.first` -* `_.flatten` +* `_.findIndex` +* `_.findLastIndex` +* `_.first` -> `head` +* `_.flatMap` +* `_.flatten` * `_.flattenDeep` -* `_.head` -> `first` +* `_.fromPairs` +* `_.head` * `_.indexOf` * `_.initial` * `_.intersection` +* `_.intersectionBy` +* `_.intersectionWith` +* `_.join` * `_.last` * `_.lastIndexOf` -* `_.object` -> `zipObject` * `_.pull` +* `_.pullAll` +* `_.pullAllBy` * `_.pullAt` -* `_.remove` -* `_.rest` +* `_.remove` * `_.slice` -* `_.sortedIndex` -* `_.sortedLastIndex` -* `_.tail` -> `rest` +* `_.sortedIndex` +* `_.sortedIndexBy` +* `_.sortedIndexOf` +* `_.sortedLastIndex` +* `_.sortedLastIndexBy` +* `_.sortedLastIndexOf` +* `_.sortedUniq` +* `_.sortedUniqBy` +* `_.tail` * `_.take` * `_.takeRight` -* `_.takeRightWhile` -* `_.takeWhile` +* `_.takeRightWhile` +* `_.takeWhile` * `_.union` -* `_.uniq` -* `_.unique` -> `uniq` +* `_.unionBy` +* `_.unionWith` +* `_.uniq` +* `_.uniqBy` +* `_.uniqWith` * `_.unzip` -* `_.unzipWith` +* `_.unzipWith` * `_.without` * `_.xor` +* `_.xorBy` +* `_.xorWith` * `_.zip` * `_.zipObject` -* `_.zipWith` - - - - - -## `Chain` -* `_` -* `_.chain` -* `_.tap` -* `_.thru` -* `_.prototype.chain` -* `_.prototype.commit` -* `_.prototype.concat` -* `_.prototype.plant` +* `_.zipWith` * `_.prototype.reverse` -* `_.prototype.run` -> `value` -* `_.prototype.toJSON` -> `value` -* `_.prototype.toString` -* `_.prototype.value` -* `_.prototype.valueOf` -> `value` ## `Collection` -* `_.all` -> `every` -* `_.any` -> `some` -* `_.at` -* `_.collect` -> `map` -* `_.contains` -> `includes` -* `_.countBy` -* `_.detect` -> `find` -* `_.each` -> `forEach` -* `_.eachRight` -> `forEachRight` -* `_.every` -* `_.filter` -* `_.find` -* `_.findLast` -* `_.findWhere` -* `_.foldl` -> `reduce` -* `_.foldr` -> `reduceRight` -* `_.forEach` -* `_.forEachRight` -* `_.groupBy` -* `_.include` -> `includes` -* `_.includes` -* `_.indexBy` -* `_.inject` -> `reduce` -* `_.invoke` -* `_.map` -* `_.partition` -* `_.pluck` -* `_.reduce` -* `_.reduceRight` -* `_.reject` -* `_.sample` -* `_.select` -> `filter` +* `_.countBy` +* `_.each` -> `forEach` +* `_.eachRight` -> `forEachRight` +* `_.every` +* `_.filter` +* `_.find` +* `_.findLast` +* `_.forEach` +* `_.forEachRight` +* `_.groupBy` +* `_.includes` +* `_.invokeMap` +* `_.keyBy` +* `_.map` +* `_.orderBy` +* `_.partition` +* `_.reduce` +* `_.reduceRight` +* `_.reject` +* `_.sample` +* `_.sampleSize` * `_.shuffle` * `_.size` -* `_.some` -* `_.sortBy` -* `_.sortByAll` -* `_.sortByOrder` -* `_.where` +* `_.some` +* `_.sortBy` @@ -127,29 +113,26 @@ ## `Function` * `_.after` * `_.ary` -* `_.backflow` -> `flowRight` * `_.before` * `_.bind` -* `_.bindAll` * `_.bindKey` -* `_.compose` -> `flowRight` * `_.curry` * `_.curryRight` * `_.debounce` * `_.defer` * `_.delay` -* `_.flow` -* `_.flowRight` +* `_.flip` * `_.memoize` -* `_.modArgs` * `_.negate` * `_.once` +* `_.overArgs` * `_.partial` * `_.partialRight` * `_.rearg` -* `_.restParam` +* `_.rest` * `_.spread` * `_.throttle` +* `_.unary` * `_.wrap` @@ -157,36 +140,53 @@ ## `Lang` -* `_.clone` -* `_.cloneDeep` -* `_.eq` -> `isEqual` +* `_.clone` +* `_.cloneDeep` +* `_.cloneDeepWith` +* `_.cloneWith` +* `_.eq` * `_.gt` * `_.gte` * `_.isArguments` * `_.isArray` +* `_.isArrayLike` +* `_.isArrayLikeObject` * `_.isBoolean` * `_.isDate` * `_.isElement` * `_.isEmpty` -* `_.isEqual` +* `_.isEqual` +* `_.isEqualWith` * `_.isError` * `_.isFinite` * `_.isFunction` -* `_.isMatch` +* `_.isInteger` +* `_.isLength` +* `_.isMatch` +* `_.isMatchWith` * `_.isNaN` * `_.isNative` +* `_.isNil` * `_.isNull` * `_.isNumber` * `_.isObject` +* `_.isObjectLike` * `_.isPlainObject` * `_.isRegExp` +* `_.isSafeInteger` * `_.isString` +* `_.isSymbol` * `_.isTypedArray` * `_.isUndefined` * `_.lt` * `_.lte` * `_.toArray` +* `_.toInteger` +* `_.toLength` +* `_.toNumber` * `_.toPlainObject` +* `_.toSafeInteger` +* `_.toString` @@ -194,53 +194,72 @@ ## `Math` * `_.add` -* `_.ceil` -* `_.floor` -* `_.max` -* `_.min` -* `_.round` -* `_.sum` +* `_.ceil` +* `_.floor` +* `_.max` +* `_.maxBy` +* `_.mean` +* `_.min` +* `_.minBy` +* `_.round` +* `_.subtract` +* `_.sum` +* `_.sumBy` ## `Number` -* `_.inRange` -* `_.random` +* `_.clamp` +* `_.inRange` +* `_.random` ## `Object` -* `_.assign` +* `_.assign` +* `_.assignIn` +* `_.assignInWith` +* `_.assignWith` +* `_.at` * `_.create` * `_.defaults` * `_.defaultsDeep` -* `_.extend` -> `assign` -* `_.findKey` -* `_.findLastKey` -* `_.forIn` -* `_.forInRight` -* `_.forOwn` -* `_.forOwnRight` +* `_.extend` -> `assignIn` +* `_.extendWith` -> `assignInWith` +* `_.findKey` +* `_.findLastKey` +* `_.forIn` +* `_.forInRight` +* `_.forOwn` +* `_.forOwnRight` * `_.functions` +* `_.functionsIn` * `_.get` * `_.has` -* `_.invert` +* `_.hasIn` +* `_.invert` +* `_.invoke` * `_.keys` * `_.keysIn` -* `_.mapKeys` -* `_.mapValues` -* `_.merge` -* `_.methods` -> `functions` -* `_.omit` -* `_.pairs` -* `_.pick` +* `_.mapKeys` +* `_.mapValues` +* `_.merge` +* `_.mergeWith` +* `_.omit` +* `_.omitBy` +* `_.pick` +* `_.pickBy` * `_.result` * `_.set` -* `_.transform` +* `_.setWith` +* `_.toPairs` +* `_.toPairsIn` +* `_.transform` +* `_.unset` * `_.values` * `_.valuesIn` @@ -248,6 +267,28 @@ +## `Seq` +* `_` +* `_.chain` +* `_.tap` +* `_.thru` +* `_.wrapperFlatMap` +* `_.prototype[Symbol.iterator]` +* `_.prototype.at` +* `_.prototype.chain` +* `_.prototype.commit` +* `_.prototype.next` +* `_.prototype.plant` +* `_.prototype.reverse` +* `_.prototype.run` -> `value` +* `_.prototype.toJSON` -> `value` +* `_.prototype.value` +* `_.prototype.valueOf` -> `value` + + + + + ## `String` * `_.camelCase` * `_.capitalize` @@ -256,32 +297,44 @@ * `_.escape` * `_.escapeRegExp` * `_.kebabCase` +* `_.lowerCase` +* `_.lowerFirst` * `_.pad` -* `_.padLeft` -* `_.padRight` +* `_.padEnd` +* `_.padStart` * `_.parseInt` * `_.repeat` +* `_.replace` * `_.snakeCase` +* `_.split` * `_.startCase` * `_.startsWith` * `_.template` +* `_.toLower` +* `_.toUpper` * `_.trim` -* `_.trimLeft` -* `_.trimRight` -* `_.trunc` +* `_.trimEnd` +* `_.trimStart` +* `_.truncate` * `_.unescape` +* `_.upperCase` +* `_.upperFirst` * `_.words` -## `Utility` +## `Util` * `_.attempt` -* `_.callback` +* `_.bindAll` +* `_.cond` +* `_.conforms` * `_.constant` +* `_.flow` +* `_.flowRight` * `_.identity` -* `_.iteratee` -> `callback` +* `_.iteratee` * `_.matches` * `_.matchesProperty` * `_.method` @@ -289,11 +342,17 @@ * `_.mixin` * `_.noConflict` * `_.noop` +* `_.nthArg` +* `_.over` +* `_.overEvery` +* `_.overSome` * `_.property` * `_.propertyOf` * `_.range` +* `_.rangeRight` * `_.runInContext` -* `_.times` +* `_.times` +* `_.toPath` * `_.uniqueId` @@ -302,6 +361,7 @@ ## `Methods` * `_.templateSettings.imports._` +* `stringSize` @@ -309,13 +369,6 @@ ## `Properties` * `_.VERSION` -* `_.support` -* `_.support.enumErrorProps` -* `_.support.enumPrototypes` -* `_.support.nonEnumShadows` -* `_.support.ownLast` -* `_.support.spliceObjects` -* `_.support.unindexedChars` * `_.templateSettings` * `_.templateSettings.escape` * `_.templateSettings.evaluate` @@ -335,16 +388,16 @@ -### `_.chunk(array, [size=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4624 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm package") +### `_.chunk(array, [size=0])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5250 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm package") Creates an array of elements split into groups the length of `size`. -If `collection` can't be split evenly, the final chunk will be the remaining +If `array` can't be split evenly, the final chunk will be the remaining elements. #### Arguments 1. `array` *(Array)*: The array to process. -2. `[size=1]` *(number)*: The length of each chunk. +2. `[size=0]` *(number)*: The length of each chunk. #### Returns *(Array)*: Returns the new array containing chunks. @@ -364,7 +417,7 @@ _.chunk(['a', 'b', 'c', 'd'], 3); ### `_.compact(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4655 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.compact "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5281 "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. @@ -386,8 +439,38 @@ _.compact([0, 1, false, 2, '', 3]); +### `_.concat(array, [values])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5317 "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. + +#### Arguments +1. `array` *(Array)*: The array to concatenate. +2. `[values]` *(...*)*: The values to concatenate. + +#### Returns +*(Array)*: Returns the new concatenated array. + +#### Example +```js +var array = [1]; +var other = _.concat(array, 2, [3], [[4]]); + +console.log(other); +// => [1, 2, 3, [4]] + +console.log(array); +// => [1] +``` +* * * + + + + + ### `_.difference(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4686 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5338 "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 provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -395,15 +478,73 @@ for equality comparisons. #### Arguments 1. `array` *(Array)*: The array to inspect. -2. `[values]` *(...Array)*: The arrays of values to exclude. +2. `[values]` *(...Array)*: The values to exclude. #### Returns *(Array)*: Returns the new array of filtered values. #### Example ```js -_.difference([1, 2, 3], [4, 2]); -// => [1, 3] +_.difference([3, 2, 1], [4, 2]); +// => [3, 1] +``` +* * * + + + + + +### `_.differenceBy(array, [values], [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5365 "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 uniqueness is computed. The iteratee is invoked with one argument: (value). + +#### 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. + +#### Returns +*(Array)*: Returns the new array of filtered values. + +#### Example +```js +_.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor); +// => [3.1, 1.3] + +// using the `_.property` iteratee shorthand +_.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); +// => [{ 'x': 2 }] +``` +* * * + + + + + +### `_.differenceWith(array, [values], [comparator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5394 "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`. The comparator +is invoked with two arguments: (arrVal, othVal). + +#### 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. + +#### Example +```js +var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + +_.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); +// => [{ 'x': 2, 'y': 1 }] ``` * * * @@ -412,7 +553,7 @@ _.difference([1, 2, 3], [4, 2]); ### `_.drop(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4716 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.drop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5428 "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. @@ -444,7 +585,7 @@ _.drop([1, 2, 3], 0); ### `_.dropRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4751 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5461 "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. @@ -475,59 +616,42 @@ _.dropRight([1, 2, 3], 0); -### `_.dropRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4812 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm package") +### `_.dropRightWhile(array, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5505 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm package") Creates a slice of `array` excluding elements dropped from the end. Elements are dropped until `predicate` returns falsey. The predicate is -bound to `thisArg` and invoked with three arguments: (value, index, array). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that match the properties of the given -object, else `false`. +invoked with three arguments: (value, index, array). #### Arguments 1. `array` *(Array)*: The array to query. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the slice of `array`. #### Example ```js -_.dropRightWhile([1, 2, 3], function(n) { - return n > 1; -}); -// => [1] - var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': false } ]; -// using the `_.matches` callback shorthand -_.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); -// => ['barney', 'fred'] +_.dropRightWhile(users, function(o) { return !o.active; }); +// => objects for ['barney'] -// using the `_.matchesProperty` callback shorthand -_.pluck(_.dropRightWhile(users, 'active', false), 'user'); -// => ['barney'] +// using the `_.matches` iteratee shorthand +_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); +// => objects for ['barney', 'fred'] -// using the `_.property` callback shorthand -_.pluck(_.dropRightWhile(users, 'active'), 'user'); -// => ['barney', 'fred', 'pebbles'] +// using the `_.matchesProperty` iteratee shorthand +_.dropRightWhile(users, ['active', false]); +// => objects for ['barney'] + +// using the `_.property` iteratee shorthand +_.dropRightWhile(users, 'active'); +// => objects for ['barney', 'fred', 'pebbles'] ``` * * * @@ -535,59 +659,42 @@ _.pluck(_.dropRightWhile(users, 'active'), 'user'); -### `_.dropWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4867 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") +### `_.dropWhile(array, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5545 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") Creates a slice of `array` excluding elements dropped from the beginning. Elements are dropped until `predicate` returns falsey. The predicate is -bound to `thisArg` and invoked with three arguments: (value, index, array). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +invoked with three arguments: (value, index, array). #### Arguments 1. `array` *(Array)*: The array to query. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the slice of `array`. #### Example ```js -_.dropWhile([1, 2, 3], function(n) { - return n < 3; -}); -// => [3] - var users = [ { 'user': 'barney', 'active': false }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': true } ]; -// using the `_.matches` callback shorthand -_.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user'); -// => ['fred', 'pebbles'] +_.dropWhile(users, function(o) { return !o.active; }); +// => objects for ['pebbles'] -// using the `_.matchesProperty` callback shorthand -_.pluck(_.dropWhile(users, 'active', false), 'user'); -// => ['pebbles'] +// using the `_.matches` iteratee shorthand +_.dropWhile(users, { 'user': 'barney', 'active': false }); +// => objects for ['fred', 'pebbles'] -// using the `_.property` callback shorthand -_.pluck(_.dropWhile(users, 'active'), 'user'); -// => ['barney', 'fred', 'pebbles'] +// using the `_.matchesProperty` iteratee shorthand +_.dropWhile(users, ['active', false]); +// => objects for ['pebbles'] + +// using the `_.property` iteratee shorthand +_.dropWhile(users, 'active'); +// => objects for ['barney', 'fred', 'pebbles'] ``` * * * @@ -596,7 +703,7 @@ _.pluck(_.dropWhile(users, 'active'), 'user'); ### `_.fill(array, value, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4901 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5579 "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`. @@ -624,8 +731,8 @@ console.log(array); _.fill(Array(3), 2); // => [2, 2, 2] -_.fill([4, 6, 8], '*', 1, 2); -// => [4, '*', 8] +_.fill([4, 6, 8, 10], '*', 1, 3); +// => [4, '*', '*', 10] ``` * * * @@ -633,30 +740,15 @@ _.fill([4, 6, 8], '*', 1, 2); -### `_.findIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L4961 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findindex "See the npm package") +### `_.findIndex(array, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5624 "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. -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. #### Arguments 1. `array` *(Array)*: The array to search. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(number)*: Returns the index of the found element, else `-1`. @@ -669,20 +761,18 @@ var users = [ { 'user': 'pebbles', 'active': true } ]; -_.findIndex(users, function(chr) { - return chr.user == 'barney'; -}); +_.findIndex(users, function(o) { return o.user == 'barney'; }); // => 0 -// using the `_.matches` callback shorthand +// using the `_.matches` iteratee shorthand _.findIndex(users, { 'user': 'fred', 'active': false }); // => 1 -// using the `_.matchesProperty` callback shorthand -_.findIndex(users, 'active', false); +// using the `_.matchesProperty` iteratee shorthand +_.findIndex(users, ['active', false]); // => 0 -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.findIndex(users, 'active'); // => 2 ``` @@ -692,30 +782,15 @@ _.findIndex(users, 'active'); -### `_.findLastIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5011 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See the npm package") +### `_.findLastIndex(array, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5663 "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. -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. #### Arguments 1. `array` *(Array)*: The array to search. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(number)*: Returns the index of the found element, else `-1`. @@ -728,20 +803,18 @@ var users = [ { 'user': 'pebbles', 'active': false } ]; -_.findLastIndex(users, function(chr) { - return chr.user == 'pebbles'; -}); +_.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); // => 2 -// using the `_.matches` callback shorthand +// using the `_.matches` iteratee shorthand _.findLastIndex(users, { 'user': 'barney', 'active': true }); // => 0 -// using the `_.matchesProperty` callback shorthand -_.findLastIndex(users, 'active', false); +// using the `_.matchesProperty` iteratee shorthand +_.findLastIndex(users, ['active', false]); // => 2 -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.findLastIndex(users, 'active'); // => 0 ``` @@ -751,27 +824,28 @@ _.findLastIndex(users, 'active'); -### `_.first(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5030 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.first "See the npm package") +### `_.flatMap(array, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5689 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatmap "See the npm package") -Gets the first element of `array`. - -#### Aliases -*_.head* +Creates an array of flattened values by running each element in `array` +through `iteratee` and concating its result to the other mapped values. +The iteratee is invoked with three arguments: (value, index|key, array). #### Arguments -1. `array` *(Array)*: The array to query. +1. `array` *(Array)*: The array to iterate over. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. #### Returns -*(*)*: Returns the first element of `array`. +*(Array)*: Returns the new array. #### Example ```js -_.first([1, 2, 3]); -// => 1 +function duplicate(n) { + return [n, n]; +} -_.first([]); -// => undefined +_.flatMap([1, 2], duplicate); +// => [1, 1, 2, 2] ``` * * * @@ -779,15 +853,13 @@ _.first([]); -### `_.flatten(array, [isDeep])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5054 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") +### `_.flatten(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5707 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") -Flattens a nested array. If `isDeep` is `true` the array is recursively -flattened, otherwise it's only flattened a single level. +Flattens `array` a single level. #### Arguments 1. `array` *(Array)*: The array to flatten. -2. `[isDeep]` *(boolean)*: Specify a deep flatten. #### Returns *(Array)*: Returns the new flattened array. @@ -796,10 +868,6 @@ flattened, otherwise it's only flattened a single level. ```js _.flatten([1, [2, 3, [4]]]); // => [1, 2, 3, [4]] - -// using `isDeep` -_.flatten([1, [2, 3, [4]]], true); -// => [1, 2, 3, 4] ``` * * * @@ -808,9 +876,9 @@ _.flatten([1, [2, 3, [4]]], true); ### `_.flattenDeep(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5075 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5725 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") -Recursively flattens a nested array. +This method is like `_.flatten` except that it recursively flattens `array`. #### Arguments 1. `array` *(Array)*: The array to recursively flatten. @@ -829,8 +897,59 @@ _.flattenDeep([1, [2, 3, [4]]]); +### `_.fromPairs(pairs)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5744 "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`. + +#### Arguments +1. `pairs` *(Array)*: The key-value pairs. + +#### Returns +*(Object)*: Returns the new object. + +#### Example +```js +_.fromPairs([['fred', 30], ['barney', 40]]); +// => { 'fred': 30, 'barney': 40 } +``` +* * * + + + + + +### `_.head(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5773 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.head "See the npm package") + +Gets the first element of `array`. + +#### Aliases +*_.first* + +#### Arguments +1. `array` *(Array)*: The array to query. + +#### Returns +*(*)*: Returns the first element of `array`. + +#### Example +```js +_.head([1, 2, 3]); +// => 1 + +_.head([]); +// => undefined +``` +* * * + + + + + ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5108 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5800 "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) @@ -841,7 +960,7 @@ performs a faster binary search. #### Arguments 1. `array` *(Array)*: The array to search. 2. `value` *(*)*: The value to search for. -3. `[fromIndex=0]` *(boolean|number)*: The index to search from or `true` to perform a binary search on a sorted array. +3. `[fromIndex=0]` *(number)*: The index to search from. #### Returns *(number)*: Returns the index of the matched value, else `-1`. @@ -854,10 +973,6 @@ _.indexOf([1, 2, 1, 2], 2); // using `fromIndex` _.indexOf([1, 2, 1, 2], 2, 2); // => 3 - -// performing a binary search -_.indexOf([1, 1, 2, 2], 2, true); -// => 2 ``` * * * @@ -866,7 +981,7 @@ _.indexOf([1, 1, 2, 2], 2, true); ### `_.initial(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5139 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5825 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") Gets all but the last element of `array`. @@ -888,7 +1003,7 @@ _.initial([1, 2, 3]); ### `_.intersection([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5157 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5843 "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 of the provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -902,7 +1017,7 @@ for equality comparisons. #### Example ```js -_.intersection([1, 2], [4, 2], [2, 1]); +_.intersection([2, 1], [4, 2], [1, 2]); // => [2] ``` * * * @@ -911,8 +1026,88 @@ _.intersection([1, 2], [4, 2], [2, 1]); +### `_.intersectionBy([arrays], [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5870 "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 uniqueness is computed. The iteratee is invoked with one argument: (value). + +#### Arguments +1. `[arrays]` *(...Array)*: The arrays to inspect. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. + +#### Returns +*(Array)*: Returns the new array of shared values. + +#### Example +```js +_.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); +// => [2.1] + +// using the `_.property` iteratee shorthand +_.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); +// => [{ 'x': 1 }] +``` +* * * + + + + + +### `_.intersectionWith([arrays], [comparator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5903 "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`. The comparator is invoked +with two arguments: (arrVal, othVal). + +#### Arguments +1. `[arrays]` *(...Array)*: The arrays to inspect. +2. `[comparator]` *(Function)*: The comparator invoked per element. + +#### Returns +*(Array)*: Returns the new array of shared values. + +#### Example +```js +var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; +var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + +_.intersectionWith(objects, others, _.isEqual); +// => [{ 'x': 1, 'y': 2 }] +``` +* * * + + + + + +### `_.join(array, [separator=','])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5931 "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`. + +#### Arguments +1. `array` *(Array)*: The array to convert. +2. `[separator=',']` *(string)*: The element separator. + +#### Returns +*(string)*: Returns the joined string. + +#### Example +```js +_.join(['a', 'b', 'c'], '~'); +// => 'a~b~c' +``` +* * * + + + + + ### `_.last(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5207 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5948 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") Gets the last element of `array`. @@ -934,7 +1129,7 @@ _.last([1, 2, 3]); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5237 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L5973 "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. @@ -942,7 +1137,7 @@ This method is like `_.indexOf` except that it iterates over elements of #### Arguments 1. `array` *(Array)*: The array to search. 2. `value` *(*)*: The value to search for. -3. `[fromIndex=array.length-1]` *(boolean|number)*: The index to search from or `true` to perform a binary search on a sorted array. +3. `[fromIndex=array.length-1]` *(number)*: The index to search from. #### Returns *(number)*: Returns the index of the matched value, else `-1`. @@ -955,10 +1150,6 @@ _.lastIndexOf([1, 2, 1, 2], 2); // using `fromIndex` _.lastIndexOf([1, 2, 1, 2], 2, 2); // => 1 - -// performing a binary search -_.lastIndexOf([1, 1, 2, 2], 2, true); -// => 3 ``` * * * @@ -967,7 +1158,7 @@ _.lastIndexOf([1, 1, 2, 2], 2, true); ### `_.pull(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5285 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6015 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") Removes all provided values from `array` using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -997,19 +1188,79 @@ console.log(array); -### `_.pullAt(array, [indexes])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5332 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm package") +### `_.pullAll(array, values)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6036 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullall "See the npm package") -Removes elements from `array` corresponding to the given indexes and returns -an array of the removed elements. Indexes may be specified as an array of -indexes or as individual arguments. +This method is like `_.pull` except that it accepts an array of values to remove. +
+
+**Note:** Unlike `_.difference`, this method mutates `array`. + +#### Arguments +1. `array` *(Array)*: The array to modify. +2. `values` *(Array)*: The values to remove. + +#### Returns +*(Array)*: Returns `array`. + +#### Example +```js +var array = [1, 2, 3, 1, 2, 3]; + +_.pull(array, [2, 3]); +console.log(array); +// => [1, 1] +``` +* * * + + + + + +### `_.pullAllBy(array, values, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6064 "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 to generate the criterion +by which uniqueness is computed. The iteratee is invoked with one argument: (value). +
+
+**Note:** Unlike `_.differenceBy`, this method mutates `array`. + +#### 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. + +#### Returns +*(Array)*: Returns `array`. + +#### Example +```js +var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; + +_.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); +console.log(array); +// => [{ 'x': 2 }] +``` +* * * + + + + + +### `_.pullAt(array, [indexes])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6094 "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.

**Note:** Unlike `_.at`, this method mutates `array`. #### Arguments 1. `array` *(Array)*: The array to modify. -2. `[indexes]` *(...(number|number[])*: The indexes of elements to remove, specified as individual indexes or arrays of indexes. +2. `[indexes]` *(...(number|number[])*: The indexes of elements to remove, specified individually or in arrays. #### Returns *(Array)*: Returns the new array of removed elements. @@ -1031,26 +1282,12 @@ console.log(evens); -### `_.remove(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5379 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm package") +### `_.remove(array, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6128 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm package") Removes all elements from `array` that `predicate` returns truthy for -and returns an array of the removed elements. The predicate is bound to -`thisArg` and invoked with three arguments: (value, index, array). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +and returns an array of the removed elements. The predicate is invoked with +three arguments: (value, index, array).

**Note:** Unlike `_.filter`, this method mutates `array`. @@ -1058,7 +1295,6 @@ object, else `false`. #### Arguments 1. `array` *(Array)*: The array to modify. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the new array of removed elements. @@ -1082,39 +1318,14 @@ console.log(evens); -### `_.rest(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5414 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") - -Gets all but the first element of `array`. - -#### Aliases -*_.tail* - -#### Arguments -1. `array` *(Array)*: The array to query. - -#### Returns -*(Array)*: Returns the slice of `array`. - -#### Example -```js -_.rest([1, 2, 3]); -// => [2, 3] -``` -* * * - - - - - ### `_.slice(array, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5432 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.slice "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6187 "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` to support node -lists in IE < 9 and 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. #### Arguments 1. `array` *(Array)*: The array to slice. @@ -1130,58 +1341,26 @@ lists in IE < 9 and to ensure dense arrays are returned. -### `_.sortedIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5492 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the npm package") +### `_.sortedIndex(array, value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6221 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the npm package") Uses a binary search to determine the lowest index at which `value` should -be inserted into `array` in order to maintain its sort order. If an iteratee -function is provided it's invoked for `value` and each element of `array` -to compute their sort ranking. The iteratee is bound to `thisArg` and -invoked with one argument; (value). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +be inserted into `array` in order to maintain its sort order. #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### 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 _.sortedIndex([30, 50], 40); // => 1 -_.sortedIndex([4, 4, 5, 5], 5); -// => 2 - -var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; - -// using an iteratee function -_.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { - return this.data[word]; -}, dict); -// => 1 - -// using the `_.property` callback shorthand -_.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); -// => 1 +_.sortedIndex([4, 5], 4); +// => 0 ``` * * * @@ -1189,8 +1368,64 @@ _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); -### `_.sortedLastIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5514 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindex "See the npm package") +### `_.sortedIndexBy(array, value, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6248 "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). + +#### 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. + +#### Returns +*(number)*: Returns the index at which `value` should be inserted into `array`. + +#### Example +```js +var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 }; + +_.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict)); +// => 1 + +// using the `_.property` iteratee shorthand +_.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); +// => 0 +``` +* * * + + + + + +### `_.sortedIndexOf(array, value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6267 "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`. + +#### 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`. + +#### Example +```js +_.sortedIndexOf([1, 1, 2, 2], 2); +// => 2 +``` +* * * + + + + + +### `_.sortedLastIndex(array, value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6294 "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 @@ -1199,17 +1434,134 @@ maintain its sort order. #### Arguments 1. `array` *(Array)*: The sorted array to inspect. 2. `value` *(*)*: The value to evaluate. -3. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### 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 -_.sortedLastIndex([4, 4, 5, 5], 5); -// => 4 +_.sortedLastIndex([4, 5], 4); +// => 1 +``` +* * * + + + + + +### `_.sortedLastIndexBy(array, value, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6316 "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). + +#### 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. + +#### Returns +*(number)*: Returns the index at which `value` should be inserted into `array`. + +#### Example +```js +// using the `_.property` iteratee shorthand +_.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); +// => 1 +``` +* * * + + + + + +### `_.sortedLastIndexOf(array, value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6335 "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`. + +#### 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`. + +#### Example +```js +_.sortedLastIndexOf([1, 1, 2, 2], 2); +// => 3 +``` +* * * + + + + + +### `_.sortedUniq(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6360 "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. + +#### Arguments +1. `array` *(Array)*: The array to inspect. + +#### Returns +*(Array)*: Returns the new duplicate free array. + +#### Example +```js +_.sortedUniq([1, 1, 2]); +// => [1, 2] +``` +* * * + + + + + +### `_.sortedUniqBy(array, [iteratee])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6381 "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. + +#### Arguments +1. `array` *(Array)*: The array to inspect. +2. `[iteratee]` *(Function)*: The iteratee invoked per element. + +#### Returns +*(Array)*: Returns the new duplicate free array. + +#### Example +```js +_.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); +// => [1.1, 2.2] +``` +* * * + + + + + +### `_.tail(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6400 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tail "See the npm package") + +Gets all but the first element of `array`. + +#### Arguments +1. `array` *(Array)*: The array to query. + +#### Returns +*(Array)*: Returns the slice of `array`. + +#### Example +```js +_.tail([1, 2, 3]); +// => [2, 3] ``` * * * @@ -1218,7 +1570,7 @@ _.sortedLastIndex([4, 4, 5, 5], 5); ### `_.take(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5540 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.take "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6428 "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. @@ -1250,7 +1602,7 @@ _.take([1, 2, 3], 0); ### `_.takeRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5575 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takeright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6460 "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. @@ -1281,58 +1633,41 @@ _.takeRight([1, 2, 3], 0); -### `_.takeRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5636 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package") +### `_.takeRightWhile(array, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6504 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package") Creates a slice of `array` with elements taken from the end. Elements are -taken until `predicate` returns falsey. The predicate is bound to `thisArg` -and invoked with three arguments: (value, index, array). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +taken until `predicate` returns falsey. The predicate is invoked with three +arguments: (value, index, array). #### Arguments 1. `array` *(Array)*: The array to query. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the slice of `array`. #### Example ```js -_.takeRightWhile([1, 2, 3], function(n) { - return n > 1; -}); -// => [2, 3] - var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': false } ]; -// using the `_.matches` callback shorthand -_.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); -// => ['pebbles'] +_.takeRightWhile(users, function(o) { return !o.active; }); +// => objects for ['fred', 'pebbles'] -// using the `_.matchesProperty` callback shorthand -_.pluck(_.takeRightWhile(users, 'active', false), 'user'); -// => ['fred', 'pebbles'] +// using the `_.matches` iteratee shorthand +_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); +// => objects for ['pebbles'] -// using the `_.property` callback shorthand -_.pluck(_.takeRightWhile(users, 'active'), 'user'); +// using the `_.matchesProperty` iteratee shorthand +_.takeRightWhile(users, ['active', false]); +// => objects for ['fred', 'pebbles'] + +// using the `_.property` iteratee shorthand +_.takeRightWhile(users, 'active'); // => [] ``` * * * @@ -1341,58 +1676,41 @@ _.pluck(_.takeRightWhile(users, 'active'), 'user'); -### `_.takeWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5691 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the npm package") +### `_.takeWhile(array, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6544 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the npm package") Creates a slice of `array` with elements taken from the beginning. Elements -are taken until `predicate` returns falsey. The predicate is bound to -`thisArg` and invoked with three arguments: (value, index, array). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +are taken until `predicate` returns falsey. The predicate is invoked with +three arguments: (value, index, array). #### Arguments 1. `array` *(Array)*: The array to query. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the slice of `array`. #### Example ```js -_.takeWhile([1, 2, 3], function(n) { - return n < 3; -}); -// => [1, 2] - var users = [ { 'user': 'barney', 'active': false }, { 'user': 'fred', 'active': false}, { 'user': 'pebbles', 'active': true } ]; -// using the `_.matches` callback shorthand -_.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user'); -// => ['barney'] +_.takeWhile(users, function(o) { return !o.active; }); +// => objects for ['barney', 'fred'] -// using the `_.matchesProperty` callback shorthand -_.pluck(_.takeWhile(users, 'active', false), 'user'); -// => ['barney', 'fred'] +// using the `_.matches` iteratee shorthand +_.takeWhile(users, { 'user': 'barney', 'active': false }); +// => objects for ['barney'] -// using the `_.property` callback shorthand -_.pluck(_.takeWhile(users, 'active'), 'user'); +// using the `_.matchesProperty` iteratee shorthand +_.takeWhile(users, ['active', false]); +// => objects for ['barney', 'fred'] + +// using the `_.property` iteratee shorthand +_.takeWhile(users, 'active'); // => [] ``` * * * @@ -1402,7 +1720,7 @@ _.pluck(_.takeWhile(users, 'active'), 'user'); ### `_.union([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5712 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6565 "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 of the provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -1416,8 +1734,8 @@ for equality comparisons. #### Example ```js -_.union([1, 2], [4, 2], [2, 1]); -// => [1, 2, 4] +_.union([2, 1], [4, 2], [1, 2]); +// => [2, 1, 4] ``` * * * @@ -1425,61 +1743,27 @@ _.union([1, 2], [4, 2], [2, 1]); -### `_.uniq(array, [isSorted], [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5765 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm package") +### `_.unionBy([arrays], [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6589 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unionby "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 occurence of each element -is kept. Providing `true` for `isSorted` performs a faster search algorithm -for sorted arrays. If an iteratee function is provided it's invoked for -each element in the array to generate the criterion by which uniqueness -is computed. The `iteratee` is bound to `thisArg` and invoked with three -arguments: (value, index, array). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Aliases -*_.unique* +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). #### Arguments -1. `array` *(Array)*: The array to inspect. -2. `[isSorted]` *(boolean)*: Specify the array is sorted. -3. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. -4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +1. `[arrays]` *(...Array)*: The arrays to inspect. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. #### Returns -*(Array)*: Returns the new duplicate-value-free array. +*(Array)*: Returns the new array of combined values. #### Example ```js -_.uniq([2, 1, 2]); -// => [2, 1] +_.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor); +// => [2.1, 1.2, 4.3] -// using `isSorted` -_.uniq([1, 1, 2], true); -// => [1, 2] - -// using an iteratee function -_.uniq([1, 2.5, 1.5, 2], function(n) { - return this.floor(n); -}, Math); -// => [1, 2.5] - -// using the `_.property` callback shorthand -_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +// using the `_.property` iteratee shorthand +_.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 1 }, { 'x': 2 }] ``` * * * @@ -1488,8 +1772,117 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +### `_.unionWith([arrays], [comparator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6616 "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). + +#### 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. + +#### Example +```js +var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; +var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + +_.unionWith(objects, others, _.isEqual); +// => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] +``` +* * * + + + + + +### `_.uniq(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6640 "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. + +#### Arguments +1. `array` *(Array)*: The array to inspect. + +#### Returns +*(Array)*: Returns the new duplicate free array. + +#### Example +```js +_.uniq([2, 1, 2]); +// => [2, 1] +``` +* * * + + + + + +### `_.uniqBy(array, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6666 "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). + +#### Arguments +1. `array` *(Array)*: The array to inspect. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. + +#### Returns +*(Array)*: Returns the new duplicate free array. + +#### Example +```js +_.uniqBy([2.1, 1.2, 2.3], Math.floor); +// => [2.1, 1.2] + +// using the `_.property` iteratee shorthand +_.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +// => [{ 'x': 1 }, { 'x': 2 }] +``` +* * * + + + + + +### `_.uniqWith(array, [comparator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6690 "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). + +#### Arguments +1. `array` *(Array)*: The array to inspect. +2. `[comparator]` *(Function)*: The comparator invoked per element. + +#### Returns +*(Array)*: Returns the new duplicate free array. + +#### Example +```js +var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; + +_.uniqWith(objects, _.isEqual); +// => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] +``` +* * * + + + + + ### `_.unzip(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5802 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6714 "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 @@ -1515,17 +1908,16 @@ _.unzip(zipped); -### `_.unzipWith(array, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5842 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzipwith "See the npm package") +### `_.unzipWith(array, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6749 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzipwith "See the npm package") -This method is like `_.unzip` except that it accepts an iteratee to specify -how regrouped values should be combined. The `iteratee` is bound to `thisArg` -and invoked with four arguments: (accumulator, value, index, group). +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). #### Arguments 1. `array` *(Array)*: The array of grouped elements to process. -2. `[iteratee]` *(Function)*: The function to combine regrouped values. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +2. `[iteratee=_.identity]` *(Function)*: The function to combine regrouped values. #### Returns *(Array)*: Returns the new array of regrouped elements. @@ -1545,7 +1937,7 @@ _.unzipWith(zipped, _.add); ### `_.without(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5873 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6778 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") Creates an array excluding all provided values using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -1570,7 +1962,7 @@ _.without([1, 2, 1, 3], 1, 2); ### `_.xor([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5893 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6798 "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) of the provided arrays. @@ -1583,7 +1975,7 @@ of the provided arrays. #### Example ```js -_.xor([1, 2], [4, 2]); +_.xor([2, 1], [4, 2]); // => [1, 4] ``` * * * @@ -1592,8 +1984,65 @@ _.xor([1, 2], [4, 2]); +### `_.xorBy([arrays], [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6822 "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 +uniqueness is computed. The iteratee is invoked with one argument: (value). + +#### Arguments +1. `[arrays]` *(...Array)*: The arrays to inspect. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. + +#### Returns +*(Array)*: Returns the new array of values. + +#### Example +```js +_.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); +// => [1.2, 4.3] + +// using the `_.property` iteratee shorthand +_.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); +// => [{ 'x': 2 }] +``` +* * * + + + + + +### `_.xorWith([arrays], [comparator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6849 "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). + +#### Arguments +1. `[arrays]` *(...Array)*: The arrays to inspect. +2. `[comparator]` *(Function)*: The comparator invoked per element. + +#### Returns +*(Array)*: Returns the new array of values. + +#### Example +```js +var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; +var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + +_.xorWith(objects, others, _.isEqual); +// => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] +``` +* * * + + + + + ### `_.zip([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5923 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6872 "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 @@ -1616,19 +2065,14 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]); -### `_.zipObject(props, [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5946 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") +### `_.zipObject([props=[]], [values=[]])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6889 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") -The inverse of `_.pairs`; this method returns an object composed from arrays -of property names and values. Provide either a single two dimensional array, -e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names -and one of corresponding values. - -#### Aliases -*_.object* +This method is like `_.fromPairs` except that it accepts two arrays, +one of property names and one of corresponding values. #### Arguments -1. `props` *(Array)*: The property names. +1. `[props=[]]` *(Array)*: The property names. 2. `[values=[]]` *(Array)*: The property values. #### Returns @@ -1636,9 +2080,6 @@ and one of corresponding values. #### Example ```js -_.zipObject([['fred', 30], ['barney', 40]]); -// => { 'fred': 30, 'barney': 40 } - _.zipObject(['fred', 'barney'], [30, 40]); // => { 'fred': 30, 'barney': 40 } ``` @@ -1648,389 +2089,51 @@ _.zipObject(['fred', 'barney'], [30, 40]); -### `_.zipWith([arrays], [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L5982 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipwith "See the npm package") +### `_.zipWith([arrays], [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6919 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipwith "See the npm package") -This method is like `_.zip` except that it accepts an iteratee to specify -how grouped values should be combined. The `iteratee` is bound to `thisArg` -and invoked with four arguments: (accumulator, value, index, group). +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). #### Arguments 1. `[arrays]` *(...Array)*: The arrays to process. -2. `[iteratee]` *(Function)*: The function to combine grouped values. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +2. `[iteratee=_.identity]` *(Function)*: The function to combine grouped values. #### Returns *(Array)*: Returns the new array of grouped elements. #### Example ```js -_.zipWith([1, 2], [10, 20], [100, 200], _.add); +_.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { + return a + b + c; +}); // => [111, 222] ``` * * * - - - - -## `“Chain” Methods` - - - -### `_(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L944 "View in source") [Ⓣ][1] - -Creates a `lodash` object which wraps `value` to enable implicit chaining. -Methods that operate on and return arrays, collections, and functions can -be chained together. Methods that retrieve a single value or may return a -primitive value will automatically end the chain returning the unwrapped -value. Explicit chaining may be enabled using `_.chain`. The execution of -chained methods is lazy, that is, execution is deferred until `_#value` -is implicitly or explicitly called. -
-
-Lazy evaluation allows several methods to support shortcut fusion. Shortcut -fusion is an optimization strategy which merge iteratee calls; this can help -to avoid the creation of intermediate data structures and greatly reduce the -number of iteratee executions. -
-
-Chaining is supported in custom builds as long as the `_#value` method is -directly or indirectly included in the build. -
-
-In addition to lodash methods, wrappers have `Array` and `String` methods. -
-
-The wrapper `Array` methods are:
-`concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, -`splice`, and `unshift` -
-
-The wrapper `String` methods are:
-`replace` and `split` -
-
-The wrapper methods that support shortcut fusion are:
-`compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, -`first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, -`slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, -and `where` -
-
-The chainable wrapper methods are:
-`after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, -`callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, -`countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, -`defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`, -`dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, -`forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, -`functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, -`invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, -`matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`, -`modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, -`partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, -`pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`, -`reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, -`sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`, -`takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, -`transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`, -`valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith` -
-
-The wrapper methods that are **not** chainable by default are:
-`add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`, -`deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, -`findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, -`floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, -`inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, -`isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`, -`isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, -`isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, -`last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, -`now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, -`reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`, -`snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, -`startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, -`unescape`, `uniqueId`, `value`, and `words` -
-
-The wrapper method `sample` will return a wrapped value when `n` is provided, -otherwise an unwrapped value is returned. - -#### Arguments -1. `value` *(*)*: The value to wrap in a `lodash` instance. - -#### Returns -*(Object)*: Returns the new `lodash` wrapper instance. - -#### Example -```js -var wrapped = _([1, 2, 3]); - -// returns an unwrapped value -wrapped.reduce(function(total, n) { - return total + n; -}); -// => 6 - -// returns a wrapped value -var squares = wrapped.map(function(n) { - return n * n; -}); - -_.isArray(squares); -// => false - -_.isArray(squares.value()); -// => true -``` -* * * - - - - - -### `_.chain(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6025 "View in source") [Ⓣ][1] - -Creates a `lodash` object that wraps `value` with explicit method -chaining enabled. - -#### Arguments -1. `value` *(*)*: The value to wrap. - -#### Returns -*(Object)*: Returns the new `lodash` wrapper instance. - -#### Example -```js -var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 }, - { 'user': 'pebbles', 'age': 1 } -]; - -var youngest = _.chain(users) - .sortBy('age') - .map(function(chr) { - return chr.user + ' is ' + chr.age; - }) - .first() - .value(); -// => 'pebbles is 1' -``` -* * * - - - - - -### `_.tap(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6054 "View in source") [Ⓣ][1] - -This method invokes `interceptor` and returns `value`. The interceptor is -bound to `thisArg` and invoked with one argument; (value). The purpose of -this method is to "tap into" a method chain in order to perform operations -on intermediate results within the chain. - -#### Arguments -1. `value` *(*)*: The value to provide to `interceptor`. -2. `interceptor` *(Function)*: The function to invoke. -3. `[thisArg]` *(*)*: The `this` binding of `interceptor`. - -#### Returns -*(*)*: Returns `value`. - -#### Example -```js -_([1, 2, 3]) - .tap(function(array) { - array.pop(); - }) - .reverse() - .value(); -// => [2, 1] -``` -* * * - - - - - -### `_.thru(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6080 "View in source") [Ⓣ][1] - -This method is like `_.tap` except that it returns the result of `interceptor`. - -#### Arguments -1. `value` *(*)*: The value to provide to `interceptor`. -2. `interceptor` *(Function)*: The function to invoke. -3. `[thisArg]` *(*)*: The `this` binding of `interceptor`. - -#### Returns -*(*)*: Returns the result of `interceptor`. - -#### Example -```js -_(' abc ') - .chain() - .trim() - .thru(function(value) { - return [value]; - }) - .value(); -// => ['abc'] -``` -* * * - - - - - -### `_.prototype.chain()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6109 "View in source") [Ⓣ][1] - -Enables explicit method chaining on the wrapper object. - -#### Returns -*(Object)*: Returns the new `lodash` wrapper instance. - -#### Example -```js -var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } -]; - -// without explicit chaining -_(users).first(); -// => { 'user': 'barney', 'age': 36 } - -// with explicit chaining -_(users).chain() - .first() - .pick('user') - .value(); -// => { 'user': 'barney' } -``` -* * * - - - - - -### `_.prototype.commit()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6138 "View in source") [Ⓣ][1] - -Executes the chained sequence and returns the wrapped result. - -#### Returns -*(Object)*: Returns the new `lodash` wrapper instance. - -#### Example -```js -var array = [1, 2]; -var wrapped = _(array).push(3); - -console.log(array); -// => [1, 2] - -wrapped = wrapped.commit(); -console.log(array); -// => [1, 2, 3] - -wrapped.last(); -// => 3 - -console.log(array); -// => [1, 2, 3] -``` -* * * - - - - - -### `_.prototype.concat([values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6162 "View in source") [Ⓣ][1] - -Creates a new array joining a wrapped array with any additional arrays -and/or values. - -#### Arguments -1. `[values]` *(...*)*: The values to concatenate. - -#### Returns -*(Array)*: Returns the new concatenated array. - -#### Example -```js -var array = [1]; -var wrapped = _(array).concat(2, [3], [[4]]); - -console.log(wrapped.value()); -// => [1, 2, 3, [4]] - -console.log(array); -// => [1] -``` -* * * - - - - - -### `_.prototype.plant()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6192 "View in source") [Ⓣ][1] - -Creates a clone of the chained sequence planting `value` as the wrapped value. - -#### Returns -*(Object)*: Returns the new `lodash` wrapper instance. - -#### Example -```js -var array = [1, 2]; -var wrapped = _(array).map(function(value) { - return Math.pow(value, 2); -}); - -var other = [3, 4]; -var otherWrapped = wrapped.plant(other); - -otherWrapped.value(); -// => [9, 16] - -wrapped.value(); -// => [1, 4] -``` -* * * - - - ### `_.prototype.reverse()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6230 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6169 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reverse "See the npm package") -Reverses the wrapped array so the first element becomes the last, the -second element becomes the second to last, and so on. +Reverses `array` so that the first element becomes the last, the second +element becomes the second to last, and so on.

-**Note:** This method mutates the wrapped array. +**Note:** This method mutates `array` and is based on +[`Array#reverse`](https://mdn.io/Array/reverse). #### Returns -*(Object)*: Returns the new reversed `lodash` wrapper instance. +*(Array)*: Returns `array`. #### Example ```js var array = [1, 2, 3]; -_(array).reverse().value() +_.reverse(array); // => [3, 2, 1] console.log(array); @@ -2040,47 +2143,6 @@ console.log(array); - - -### `_.prototype.toString()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6260 "View in source") [Ⓣ][1] - -Produces the result of coercing the unwrapped value to a string. - -#### Returns -*(string)*: Returns the coerced string value. - -#### Example -```js -_([1, 2, 3]).toString(); -// => '1,2,3' -``` -* * * - - - - - -### `_.prototype.value()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6277 "View in source") [Ⓣ][1] - -Executes the chained sequence to extract the unwrapped value. - -#### Aliases -*_.prototype.run, _.prototype.toJSON, _.prototype.valueOf* - -#### Returns -*(*)*: Returns the resolved unwrapped value. - -#### Example -```js -_([1, 2, 3]).value(); -// => [1, 2, 3] -``` -* * * - - - @@ -2089,75 +2151,24 @@ _([1, 2, 3]).value(); -### `_.at(collection, [props])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6303 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.at "See the npm package") - -Creates an array of elements corresponding to the given keys, or indexes, -of `collection`. Keys may be specified as individual arguments or as arrays -of keys. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[props]` *(...(number|number[]|string|string[])*: The property names or indexes of elements to pick, specified individually or in arrays. - -#### Returns -*(Array)*: Returns the new array of picked elements. - -#### Example -```js -_.at(['a', 'b', 'c'], [0, 2]); -// => ['a', 'c'] - -_.at(['barney', 'fred', 'pebbles'], 0, 2); -// => ['barney', 'pebbles'] -``` -* * * - - - - - -### `_.countBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6351 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm package") +### `_.countBy(collection, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7299 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm package") Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value of each key is the number of times the key was returned by `iteratee`. -The `iteratee` is bound to `thisArg` and invoked with three arguments:
-(value, index|key, collection). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +The iteratee is invoked with one argument: (value). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +1. `collection` *(Array|Object)*: The collection to iterate over. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. #### Returns *(Object)*: Returns the composed aggregate object. #### Example ```js -_.countBy([4.3, 6.1, 6.4], function(n) { - return Math.floor(n); -}); -// => { '4': 1, '6': 2 } - -_.countBy([4.3, 6.1, 6.4], function(n) { - return this.floor(n); -}, Math); +_.countBy([6.1, 4.2, 6.3], Math.floor); // => { '4': 1, '6': 2 } _.countBy(['one', 'two', 'three'], 'length'); @@ -2169,38 +2180,19 @@ _.countBy(['one', 'two', 'three'], 'length'); -### `_.every(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6403 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm package") +### `_.every(collection, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7337 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm package") Checks if `predicate` returns truthy for **all** elements of `collection`. -The predicate is bound to `thisArg` and invoked with three arguments:
-(value, index|key, collection). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Aliases -*_.all* +Iteration is stopped once `predicate` returns falsey. The predicate is +invoked with three arguments: (value, index|key, collection). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### 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 @@ -2212,15 +2204,15 @@ var users = [ { 'user': 'fred', 'active': false } ]; -// using the `_.matches` callback shorthand +// using the `_.matches` iteratee shorthand _.every(users, { 'user': 'barney', 'active': false }); // => false -// using the `_.matchesProperty` callback shorthand -_.every(users, 'active', false); +// using the `_.matchesProperty` iteratee shorthand +_.every(users, ['active', false]); // => true -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.every(users, 'active'); // => false ``` @@ -2230,61 +2222,41 @@ _.every(users, 'active'); -### `_.filter(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6463 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm package") +### `_.filter(collection, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7378 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm package") Iterates over elements of `collection`, returning an array of all elements -`predicate` returns truthy for. The predicate is bound to `thisArg` and -invoked with three arguments: (value, index|key, collection). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Aliases -*_.select* +`predicate` returns truthy for. The predicate is invoked with three arguments:
+(value, index|key, collection). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the new filtered array. #### Example ```js -_.filter([4, 5, 6], function(n) { - return n % 2 == 0; -}); -// => [4, 6] - var users = [ { 'user': 'barney', 'age': 36, 'active': true }, { 'user': 'fred', 'age': 40, 'active': false } ]; -// using the `_.matches` callback shorthand -_.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); -// => ['barney'] +_.filter(users, function(o) { return !o.active; }); +// => objects for ['fred'] -// using the `_.matchesProperty` callback shorthand -_.pluck(_.filter(users, 'active', false), 'user'); -// => ['fred'] +// using the `_.matches` iteratee shorthand +_.filter(users, { 'age': 36, 'active': true }); +// => objects for ['barney'] -// using the `_.property` callback shorthand -_.pluck(_.filter(users, 'active'), 'user'); -// => ['barney'] +// using the `_.matchesProperty` iteratee shorthand +_.filter(users, ['active', false]); +// => objects for ['fred'] + +// using the `_.property` iteratee shorthand +_.filter(users, 'active'); +// => objects for ['barney'] ``` * * * @@ -2292,34 +2264,16 @@ _.pluck(_.filter(users, 'active'), 'user'); -### `_.find(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6519 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm package") +### `_.find(collection, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7417 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm package") Iterates over elements of `collection`, returning the first element -`predicate` returns truthy for. The predicate is bound to `thisArg` and -invoked with three arguments: (value, index|key, collection). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Aliases -*_.detect* +`predicate` returns truthy for. The predicate is invoked with three arguments:
+(value, index|key, collection). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to search. +1. `collection` *(Array|Object)*: The collection to search. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(*)*: Returns the matched element, else `undefined`. @@ -2332,22 +2286,20 @@ var users = [ { 'user': 'pebbles', 'age': 1, 'active': true } ]; -_.result(_.find(users, function(chr) { - return chr.age < 40; -}), 'user'); -// => 'barney' +_.find(users, function(o) { return o.age < 40; }); +// => object for 'barney' -// using the `_.matches` callback shorthand -_.result(_.find(users, { 'age': 1, 'active': true }), 'user'); -// => 'pebbles' +// using the `_.matches` iteratee shorthand +_.find(users, { 'age': 1, 'active': true }); +// => object for 'pebbles' -// using the `_.matchesProperty` callback shorthand -_.result(_.find(users, 'active', false), 'user'); -// => 'fred' +// using the `_.matchesProperty` iteratee shorthand +_.find(users, ['active', false]); +// => object for 'fred' -// using the `_.property` callback shorthand -_.result(_.find(users, 'active'), 'user'); -// => 'barney' +// using the `_.property` iteratee shorthand +_.find(users, 'active'); +// => object for 'barney' ``` * * * @@ -2355,16 +2307,15 @@ _.result(_.find(users, 'active'), 'user'); -### `_.findLast(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6540 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm package") +### `_.findLast(collection, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7443 "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. #### Arguments -1. `collection` *(Array|Object|string)*: The collection to search. +1. `collection` *(Array|Object)*: The collection to search. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(*)*: Returns the matched element, else `undefined`. @@ -2382,80 +2333,39 @@ _.findLast([1, 2, 3, 4], function(n) { -### `_.findWhere(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6571 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findwhere "See the npm package") - -Performs a deep comparison between each element in `collection` and the -source object, returning the first element that has equivalent property -values. -
-
-**Note:** This method supports comparing arrays, booleans, `Date` objects, -numbers, `Object` objects, regexes, and strings. Objects are compared by -their own, not inherited, enumerable properties. For comparing a single -own or inherited property value see `_.matchesProperty`. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to search. -2. `source` *(Object)*: The object of property values to match. - -#### Returns -*(*)*: Returns the matched element, else `undefined`. - -#### Example -```js -var users = [ - { 'user': 'barney', 'age': 36, 'active': true }, - { 'user': 'fred', 'age': 40, 'active': false } -]; - -_.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user'); -// => 'barney' - -_.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); -// => 'fred' -``` -* * * - - - - - -### `_.forEach(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6605 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm package") +### `_.forEach(collection, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7480 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm package") Iterates over elements of `collection` invoking `iteratee` for each element. -The `iteratee` is bound to `thisArg` and invoked with three arguments:
-(value, index|key, collection). Iteratee functions may exit iteration early -by explicitly returning `false`. +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 `_.forIn` or `_.forOwn` -may be used for object iteration. +are iterated like arrays. To avoid this behavior use `_.forIn` or `_.forOwn` +for object iteration. #### Aliases *_.each* #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns -*(Array|Object|string)*: Returns `collection`. +*(Array|Object)*: Returns `collection`. #### Example ```js -_([1, 2]).forEach(function(n) { - console.log(n); -}).value(); -// => logs each value from left to right and returns the array - -_.forEach({ 'a': 1, 'b': 2 }, function(n, key) { - console.log(n, key); +_([1, 2]).forEach(function(value) { + console.log(value); }); -// => logs each value-key pair and returns the object (iteration order is not guaranteed) +// => logs `1` then `2` + +_.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + console.log(key); +}); +// => logs 'a' then 'b' (iteration order is not guaranteed) ``` * * * @@ -2463,8 +2373,8 @@ _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { -### `_.forEachRight(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6626 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the npm package") +### `_.forEachRight(collection, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7504 "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. @@ -2473,19 +2383,18 @@ This method is like `_.forEach` except that it iterates over elements of *_.eachRight* #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns -*(Array|Object|string)*: Returns `collection`. +*(Array|Object)*: Returns `collection`. #### Example ```js -_([1, 2]).forEachRight(function(n) { - console.log(n); -}).value(); -// => logs each value from right to left and returns the array +_.forEachRight([1, 2], function(value) { + console.log(value); +}); +// => logs `2` then `1` ``` * * * @@ -2493,50 +2402,27 @@ _([1, 2]).forEachRight(function(n) { -### `_.groupBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6670 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm package") +### `_.groupBy(collection, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7531 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm package") Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value of each key is an array of the elements responsible for generating the key. -The `iteratee` is bound to `thisArg` and invoked with three arguments:
-(value, index|key, collection). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +The iteratee is invoked with one argument: (value). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +1. `collection` *(Array|Object)*: The collection to iterate over. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. #### Returns *(Object)*: Returns the composed aggregate object. #### Example ```js -_.groupBy([4.2, 6.1, 6.4], function(n) { - return Math.floor(n); -}); -// => { '4': [4.2], '6': [6.1, 6.4] } +_.groupBy([6.1, 4.2, 6.3], Math.floor); +// => { '4': [4.2], '6': [6.1, 6.3] } -_.groupBy([4.2, 6.1, 6.4], function(n) { - return this.floor(n); -}, Math); -// => { '4': [4.2], '6': [6.1, 6.4] } - -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] } ``` @@ -2546,24 +2432,21 @@ _.groupBy(['one', 'two', 'three'], 'length'); -### `_.includes(collection, target, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6707 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") +### `_.includes(collection, value, [fromIndex=0])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7567 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") -Checks if `target` is in `collection` using -[`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) -for equality comparisons. If `fromIndex` is negative, it's used as the offset -from the end of `collection`. - -#### Aliases -*_.contains, _.include* +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`. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to search. -2. `target` *(*)*: The value to search for. +2. `value` *(*)*: The value to search for. 3. `[fromIndex=0]` *(number)*: The index to search from. #### Returns -*(boolean)*: Returns `true` if a matching element is found, else `false`. +*(boolean)*: Returns `true` if `value` is found, else `false`. #### Example ```js @@ -2585,33 +2468,47 @@ _.includes('pebbles', 'eb'); -### `_.indexBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6769 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexby "See the npm package") +### `_.invokeMap(collection, path, [args])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7602 "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`. + +#### 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. + +#### Example +```js +_.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); +// => [[1, 5, 7], [1, 2, 3]] + +_.invokeMap([123, 456], String.prototype.split, ''); +// => [['1', '2', '3'], ['4', '5', '6']] +``` +* * * + + + + + +### `_.keyBy(collection, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7642 "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 function is bound to `thisArg` and invoked with three arguments:
-(value, index|key, collection). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +iteratee is invoked with one argument: (value). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +1. `collection` *(Array|Object)*: The collection to iterate over. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. #### Returns *(Object)*: Returns the composed aggregate object. @@ -2623,18 +2520,13 @@ var keyData = [ { 'dir': 'right', 'code': 100 } ]; -_.indexBy(keyData, 'dir'); +_.keyBy(keyData, 'dir'); // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } -_.indexBy(keyData, function(object) { - return String.fromCharCode(object.code); +_.keyBy(keyData, function(o) { + return String.fromCharCode(o.code); }); // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - -_.indexBy(keyData, function(object) { - return this.fromCharCode(object.code); -}, String); -// => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } ``` * * * @@ -2642,56 +2534,12 @@ _.indexBy(keyData, function(object) { -### `_.invoke(collection, path, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6795 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "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`. - -#### Arguments -1. `collection` *(Array|Object|string)*: 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 the method with. - -#### Returns -*(Array)*: Returns the array of results. - -#### Example -```js -_.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); -// => [[1, 5, 7], [1, 2, 3]] - -_.invoke([123, 456], String.prototype.split, ''); -// => [['1', '2', '3'], ['4', '5', '6']] -``` -* * * - - - - - -### `_.map(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6864 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm package") +### `_.map(collection, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7687 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm package") Creates an array of values by running each element in `collection` through -`iteratee`. The `iteratee` is bound to `thisArg` and invoked with three -arguments: (value, index|key, collection). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +`iteratee`. The iteratee is invoked with three arguments:
+(value, index|key, collection).

Many lodash methods are guarded to work as iteratees for methods like @@ -2699,33 +2547,28 @@ Many lodash methods are guarded to work as iteratees for methods like

The guarded methods are:
-`ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, -`drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, -`parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, -`trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, -`sum`, `uniq`, and `words` - -#### Aliases -*_.collect* +`ary`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, `fill`, +`invert`, `parseInt`, `random`, `range`, `rangeRight`, `slice`, `some`, +`sortBy`, `take`, `takeRight`, `template`, `trim`, `trimEnd`, `trimStart`, +and `words` #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Array)*: Returns the new mapped array. #### Example ```js -function timesThree(n) { - return n * 3; +function square(n) { + return n * n; } -_.map([1, 2], timesThree); +_.map([1, 2], square); // => [3, 6] -_.map({ 'a': 1, 'b': 2 }, timesThree); +_.map({ 'a': 1, 'b': 2 }, square); // => [3, 6] (iteration order is not guaranteed) var users = [ @@ -2733,7 +2576,7 @@ var users = [ { 'user': 'fred' } ]; -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.map(users, 'user'); // => ['barney', 'fred'] ``` @@ -2743,69 +2586,78 @@ _.map(users, 'user'); -### `_.partition(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6929 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") +### `_.orderBy(collection, [iteratees=[_.identity]], [orders])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7719 "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. + +#### Arguments +1. `collection` *(Array|Object)*: The collection to iterate over. +2. `[iteratees=[_.identity]]` *(Function[]|Object[]|string[])*: The iteratees to sort by. +3. `[orders]` *(string[])*: The sort orders of `iteratees`. + +#### Returns +*(Array)*: Returns the new sorted array. + +#### Example +```js +var users = [ + { 'user': 'fred', 'age': 48 }, + { 'user': 'barney', 'age': 34 }, + { 'user': 'fred', 'age': 42 }, + { 'user': 'barney', 'age': 36 } +]; + +// sort by `user` in ascending order and by `age` in descending order +_.orderBy(users, ['user', 'age'], ['asc', 'desc']); +// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] +``` +* * * + + + + + +### `_.partition(collection, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7768 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") Creates an array of elements split into two groups, the first of which contains elements `predicate` returns truthy for, while the second of which -contains elements `predicate` returns falsey for. The predicate is bound -to `thisArg` and invoked with three arguments: (value, index|key, collection). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +contains elements `predicate` returns falsey for. The predicate is invoked +with three arguments: (value, index|key, collection). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the array of grouped elements. #### Example ```js -_.partition([1, 2, 3], function(n) { - return n % 2; -}); -// => [[1, 3], [2]] - -_.partition([1.2, 2.3, 3.4], function(n) { - return this.floor(n) % 2; -}, Math); -// => [[1.2, 3.4], [2.3]] - var users = [ { 'user': 'barney', 'age': 36, 'active': false }, { 'user': 'fred', 'age': 40, 'active': true }, { 'user': 'pebbles', 'age': 1, 'active': false } ]; -var mapper = function(array) { - return _.pluck(array, 'user'); -}; +_.partition(users, function(o) { return o.active; }); +// => objects for [['fred'], ['barney', 'pebbles']] -// using the `_.matches` callback shorthand -_.map(_.partition(users, { 'age': 1, 'active': false }), mapper); -// => [['pebbles'], ['barney', 'fred']] +// using the `_.matches` iteratee shorthand +_.partition(users, { 'age': 1, 'active': false }); +// => objects for [['pebbles'], ['barney', 'fred']] -// using the `_.matchesProperty` callback shorthand -_.map(_.partition(users, 'active', false), mapper); -// => [['barney', 'pebbles'], ['fred']] +// using the `_.matchesProperty` iteratee shorthand +_.partition(users, ['active', false]); +// => objects for [['barney', 'pebbles'], ['fred']] -// using the `_.property` callback shorthand -_.map(_.partition(users, 'active'), mapper); -// => [['fred'], ['barney', 'pebbles']] +// using the `_.property` iteratee shorthand +_.partition(users, 'active'); +// => objects for [['fred'], ['barney', 'pebbles']] ``` * * * @@ -2813,46 +2665,14 @@ _.map(_.partition(users, 'active'), mapper); -### `_.pluck(collection, path)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6956 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pluck "See the npm package") - -Gets the property value of `path` from all elements in `collection`. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `path` *(Array|string)*: The path of the property to pluck. - -#### Returns -*(Array)*: Returns the property values. - -#### Example -```js -var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } -]; - -_.pluck(users, 'user'); -// => ['barney', 'fred'] - -var userIndex = _.indexBy(users, 'user'); -_.pluck(userIndex, 'age'); -// => [36, 40] (iteration order is not guaranteed) -``` -* * * - - - - - -### `_.reduce(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L6997 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm package") +### `_.reduce(collection, [iteratee=_.identity], [accumulator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7807 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm package") Reduces `collection` to a value which is the accumulated result of running each element in `collection` through `iteratee`, where each successive invocation is supplied the return value of the previous. If `accumulator` is not provided the first element of `collection` is used as the initial -value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
+value. The iteratee is invoked with four arguments:
(accumulator, value, index|key, collection).

@@ -2861,33 +2681,29 @@ Many lodash methods are guarded to work as iteratees for methods like

The guarded methods are:
-`assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`, -and `sortByOrder` - -#### Aliases -*_.foldl, _.inject* +`assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, +and `sortBy` #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. 3. `[accumulator]` *(*)*: The initial value. -4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(*)*: Returns the accumulated value. #### Example ```js -_.reduce([1, 2], function(total, n) { - return total + n; +_.reduce([1, 2], function(sum, n) { + return sum + n; }); // => 3 -_.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { - result[key] = n * 3; +_.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + (result[value] || (result[value] = [])).push(key); return result; }, {}); -// => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) +// => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) ``` * * * @@ -2895,20 +2711,16 @@ _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { -### `_.reduceRight(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7021 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the npm package") +### `_.reduceRight(collection, [iteratee=_.identity], [accumulator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7834 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the npm package") This method is like `_.reduce` except that it iterates over elements of `collection` from right to left. -#### Aliases -*_.foldr* - #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. 3. `[accumulator]` *(*)*: The initial value. -4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(*)*: Returns the accumulated value. @@ -2928,43 +2740,40 @@ _.reduceRight(array, function(flattened, other) { -### `_.reject(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7059 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reject "See the npm package") +### `_.reject(collection, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7873 "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. #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(Array)*: Returns the new filtered array. #### Example ```js -_.reject([1, 2, 3, 4], function(n) { - return n % 2 == 0; -}); -// => [1, 3] - var users = [ { 'user': 'barney', 'age': 36, 'active': false }, { 'user': 'fred', 'age': 40, 'active': true } ]; -// using the `_.matches` callback shorthand -_.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user'); -// => ['barney'] +_.reject(users, function(o) { return !o.active; }); +// => objects for ['fred'] -// using the `_.matchesProperty` callback shorthand -_.pluck(_.reject(users, 'active', false), 'user'); -// => ['fred'] +// using the `_.matches` iteratee shorthand +_.reject(users, { 'age': 40, 'active': true }); +// => objects for ['barney'] -// using the `_.property` callback shorthand -_.pluck(_.reject(users, 'active'), 'user'); -// => ['barney'] +// using the `_.matchesProperty` iteratee shorthand +_.reject(users, ['active', false]); +// => objects for ['fred'] + +// using the `_.property` iteratee shorthand +_.reject(users, 'active'); +// => objects for ['barney'] ``` * * * @@ -2972,24 +2781,43 @@ _.pluck(_.reject(users, 'active'), 'user'); -### `_.sample(collection, [n])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7085 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") +### `_.sample(collection)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7894 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") -Gets a random element or `n` random elements from a collection. +Gets a random element from `collection`. #### Arguments -1. `collection` *(Array|Object|string)*: The collection to sample. -2. `[n]` *(number)*: The number of elements to sample. +1. `collection` *(Array|Object)*: The collection to sample. #### Returns -*(*)*: Returns the random sample(s). +*(*)*: Returns the random element. #### Example ```js _.sample([1, 2, 3, 4]); // => 2 +``` +* * * -_.sample([1, 2, 3, 4], 2); + + + + +### `_.sampleSize(collection, [n=0])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7915 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.samplesize "See the npm package") + +Gets `n` random elements from `collection`. + +#### 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. + +#### Example +```js +_.sampleSize([1, 2, 3, 4], 2); // => [3, 1] ``` * * * @@ -2999,13 +2827,13 @@ _.sample([1, 2, 3, 4], 2); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7122 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.shuffle "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7947 "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). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to shuffle. +1. `collection` *(Array|Object)*: The collection to shuffle. #### Returns *(Array)*: Returns the new shuffled array. @@ -3022,16 +2850,16 @@ _.shuffle([1, 2, 3, 4]); ### `_.size(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7146 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.size "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7971 "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. #### Arguments -1. `collection` *(Array|Object|string)*: The collection to inspect. +1. `collection` *(Array|Object)*: The collection to inspect. #### Returns -*(number)*: Returns the size of `collection`. +*(number)*: Returns the collection size. #### Example ```js @@ -3050,39 +2878,19 @@ _.size('pebbles'); -### `_.some(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7200 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm package") +### `_.some(collection, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8016 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm package") Checks if `predicate` returns truthy for **any** element of `collection`. -The function returns as soon as it finds a passing value and does not iterate -over the entire collection. The predicate is bound to `thisArg` and invoked -with three arguments: (value, index|key, collection). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Aliases -*_.any* +Iteration is stopped once `predicate` returns truthy. The predicate is +invoked with three arguments: (value, index|key, collection). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. +1. `collection` *(Array|Object)*: The collection to iterate over. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### 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 @@ -3094,15 +2902,15 @@ var users = [ { 'user': 'fred', 'active': false } ]; -// using the `_.matches` callback shorthand +// using the `_.matches` iteratee shorthand _.some(users, { 'user': 'barney', 'active': false }); // => false -// using the `_.matchesProperty` callback shorthand -_.some(users, 'active', false); +// using the `_.matchesProperty` iteratee shorthand +_.some(users, ['active', false]); // => true -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.some(users, 'active'); // => true ``` @@ -3112,83 +2920,17 @@ _.some(users, 'active'); -### `_.sortBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7259 "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.0.0/lodash.js#L8057 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortby "See the npm package") Creates an array of elements, sorted in ascending order by the results of -running each element in a collection through `iteratee`. This method performs -a stable sort, that is, it preserves the original sort order of equal elements. -The `iteratee` is bound to `thisArg` and invoked with three arguments:
-(value, index|key, collection). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +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). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. - -#### Returns -*(Array)*: Returns the new sorted array. - -#### Example -```js -_.sortBy([1, 2, 3], function(n) { - return Math.sin(n); -}); -// => [3, 1, 2] - -_.sortBy([1, 2, 3], function(n) { - return this.sin(n); -}, Math); -// => [3, 1, 2] - -var users = [ - { 'user': 'fred' }, - { 'user': 'pebbles' }, - { 'user': 'barney' } -]; - -// using the `_.property` callback shorthand -_.pluck(_.sortBy(users, 'user'), 'user'); -// => ['barney', 'fred', 'pebbles'] -``` -* * * - - - - - -### `_.sortByAll(collection, iteratees)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7310 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyall "See the npm package") - -This method is like `_.sortBy` except that it can sort by multiple iteratees -or property names. -
-
-If a property name is provided for an iteratee the created `_.property` -style callback returns the property value of the given element. -
-
-If an object is provided for an iteratee the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `iteratees` *(...(Function|Function[]|Object|Object[]|string|string[])*: The iteratees to sort by, specified as individual values or arrays of values. +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. #### Returns *(Array)*: Returns the new sorted array. @@ -3202,96 +2944,16 @@ var users = [ { 'user': 'barney', 'age': 34 } ]; -_.map(_.sortByAll(users, ['user', 'age']), _.values); -// => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] +_.sortBy(users, function(o) { return o.user; }); +// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] -_.map(_.sortByAll(users, 'user', function(chr) { - return Math.floor(chr.age / 10); -}), _.values); -// => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] -``` -* * * +_.sortBy(users, ['user', 'age']); +// => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] - - - - -### `_.sortByOrder(collection, iteratees, [orders])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7355 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyorder "See the npm package") - -This method is like `_.sortByAll` except that it allows specifying the -sort orders of the iteratees to sort by. If `orders` is unspecified, all -values are sorted in ascending order. Otherwise, a value is sorted in -ascending order if its corresponding order is "asc", and descending if "desc". -
-
-If a property name is provided for an iteratee the created `_.property` -style callback returns the property value of the given element. -
-
-If an object is provided for an iteratee the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `iteratees` *(Function[]|Object[]|string[])*: The iteratees to sort by. -3. `[orders]` *(boolean[])*: The sort orders of `iteratees`. - -#### Returns -*(Array)*: Returns the new sorted array. - -#### Example -```js -var users = [ - { 'user': 'fred', 'age': 48 }, - { 'user': 'barney', 'age': 34 }, - { 'user': 'fred', 'age': 42 }, - { 'user': 'barney', 'age': 36 } -]; - -// sort by `user` in ascending order and by `age` in descending order -_.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values); -// => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] -``` -* * * - - - - - -### `_.where(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7400 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.where "See the npm package") - -Performs a deep comparison between each element in `collection` and the -source object, returning an array of all elements that have equivalent -property values. -
-
-**Note:** This method supports comparing arrays, booleans, `Date` objects, -numbers, `Object` objects, regexes, and strings. Objects are compared by -their own, not inherited, enumerable properties. For comparing a single -own or inherited property value see `_.matchesProperty`. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to search. -2. `source` *(Object)*: The object of property values to match. - -#### Returns -*(Array)*: Returns the new filtered array. - -#### Example -```js -var users = [ - { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, - { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } -]; - -_.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); -// => ['barney'] - -_.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); -// => ['fred'] +_.sortBy(users, 'user', function(o) { + return Math.floor(o.age / 10); +}); +// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] ``` * * * @@ -3305,11 +2967,14 @@ _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); -### `_.now` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7420 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") +### `_.now()` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8088 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") -Gets the number of milliseconds that have elapsed since the Unix epoch -(1 January 1970 00:00:00 UTC). +Gets the timestamp of the number of milliseconds that have elapsed since +the Unix epoch (1 January 1970 00:00:00 UTC). + +#### Returns +*(number)*: Returns the timestamp. #### Example ```js @@ -3331,7 +2996,7 @@ _.defer(function(stamp) { ### `_.after(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7449 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.after "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8115 "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. @@ -3363,9 +3028,9 @@ _.forEach(saves, function(type) { ### `_.ary(func, [n=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7483 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ary "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8143 "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 +Creates a function that accepts up to `n` arguments, ignoring any additional arguments. #### Arguments @@ -3387,7 +3052,7 @@ _.map(['6', '8', '10'], _.ary(parseInt, 1)); ### `_.before(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7507 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.before "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8165 "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 @@ -3402,7 +3067,7 @@ calls to the created function return the result of the last `func` invocation. #### Example ```js -jQuery('#add').on('click', _.before(5, addContactToList)); +jQuery(element).on('click', _.before(5, addContactToList)); // => allows adding up to 4 contacts to the list ``` * * * @@ -3412,7 +3077,7 @@ jQuery('#add').on('click', _.before(5, addContactToList)); ### `_.bind(func, thisArg, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7564 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bind "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8217 "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 @@ -3423,7 +3088,7 @@ The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for partially applied arguments.

-**Note:** Unlike native `Function#bind` this method does not set the "length" +**Note:** Unlike native `Function#bind` this method doesn't set the "length" property of bound functions. #### Arguments @@ -3457,45 +3122,8 @@ bound('hi'); -### `_.bindAll(object, [methodNames])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7601 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindall "See the npm package") - -Binds methods of an object to the object itself, overwriting the existing -method. Method names may be specified as individual arguments or as arrays -of method names. If no method names are provided all enumerable function -properties, own and inherited, of `object` are bound. -
-
-**Note:** This method does not set the "length" property of bound functions. - -#### 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 as individual method names or arrays of method names. - -#### Returns -*(Object)*: Returns `object`. - -#### Example -```js -var view = { - 'label': 'docs', - 'onClick': function() { - console.log('clicked ' + this.label); - } -}; - -_.bindAll(view); -jQuery('#docs').on('click', view.onClick); -// => logs 'clicked docs' when the element is clicked -``` -* * * - - - - - ### `_.bindKey(object, key, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7658 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8270 "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. @@ -3511,7 +3139,7 @@ The `_.bindKey.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for partially applied arguments. #### Arguments -1. `object` *(Object)*: The object the method belongs to. +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. @@ -3550,20 +3178,20 @@ bound('hi'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7707 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8319 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") -Creates a function that accepts one or more arguments of `func` that when -called either invokes `func` returning its result, if all `func` arguments -have been provided, or returns a function that accepts one or more of the -remaining `func` arguments, and so on. The arity of `func` may be specified -if `func.length` is not sufficient. +Creates a function that accepts arguments of `func` and either invokes +`func` returning its result, if at least `arity` number of arguments have +been provided, or returns a function that accepts the remaining `func` +arguments, and so on. The arity of `func` may be specified if `func.length` +is not sufficient.

The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for provided arguments.

-**Note:** This method does not set the "length" property of curried functions. +**Note:** This method doesn't set the "length" property of curried functions. #### Arguments 1. `func` *(Function)*: The function to curry. @@ -3600,7 +3228,7 @@ curried(1)(_, 3)(2); ### `_.curryRight(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7746 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curryright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8363 "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`. @@ -3610,7 +3238,7 @@ The `_.curryRight.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for provided arguments.

-**Note:** This method does not set the "length" property of curried functions. +**Note:** This method doesn't set the "length" property of curried functions. #### Arguments 1. `func` *(Function)*: The function to curry. @@ -3647,15 +3275,16 @@ curried(3)(1, _)(2); ### `_.debounce(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7811 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8419 "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 invoked. The debounced function comes with a `cancel` method to cancel -delayed invocations. Provide an options object to indicate that `func` -should be invoked on the leading and/or trailing edge of the `wait` timeout. -Subsequent calls to the debounced function return the result of the last -`func` invocation. +delayed `func` invocations and a `flush` method to immediately invoke them. +Provide an options object to indicate whether `func` should be invoked on +the leading and/or trailing edge of the `wait` timeout. The `func` is invoked +with the last arguments provided to the debounced function. Subsequent calls +to the debounced function return the result of the last `func` invocation.

**Note:** If `leading` and `trailing` options are `true`, `func` is invoked @@ -3682,34 +3311,19 @@ for details over the differences between `_.debounce` and `_.throttle`. // avoid costly calculations while the window size is in flux jQuery(window).on('resize', _.debounce(calculateLayout, 150)); -// invoke `sendMail` when the click event is fired, debouncing subsequent calls -jQuery('#postbox').on('click', _.debounce(sendMail, 300, { +// invoke `sendMail` when clicked, debouncing subsequent calls +jQuery(element).on('click', _.debounce(sendMail, 300, { 'leading': true, 'trailing': false })); // ensure `batchLog` is invoked once after 1 second of debounced calls +var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); var source = new EventSource('/stream'); -jQuery(source).on('message', _.debounce(batchLog, 250, { - 'maxWait': 1000 -})); +jQuery(source).on('message', debounced); -// cancel a debounced call -var todoChanges = _.debounce(batchLog, 1000); -Object.observe(models.todo, todoChanges); - -Object.observe(models, function(changes) { - if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) { - todoChanges.cancel(); - } -}, ['delete']); - -// ...at some point `models.todo` is changed -models.todo.completed = true; - -// ...before 1 second has passed `models.todo` is deleted -// which cancels the debounced `todoChanges` call -delete models.todo; +// cancel a trailing debounced invocation +jQuery(window).on('popstate', debounced.cancel); ``` * * * @@ -3718,14 +3332,14 @@ delete models.todo; ### `_.defer(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7936 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defer "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8551 "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. #### Arguments 1. `func` *(Function)*: The function to defer. -2. `[args]` *(...*)*: The arguments to invoke the function with. +2. `[args]` *(...*)*: The arguments to invoke `func` with. #### Returns *(number)*: Returns the timer id. @@ -3744,7 +3358,7 @@ _.defer(function(text) { ### `_.delay(func, wait, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7958 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.delay "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8573 "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. @@ -3752,7 +3366,7 @@ provided to `func` when it's invoked. #### Arguments 1. `func` *(Function)*: The function to delay. 2. `wait` *(number)*: The number of milliseconds to delay invocation. -3. `[args]` *(...*)*: The arguments to invoke the function with. +3. `[args]` *(...*)*: The arguments to invoke `func` with. #### Returns *(number)*: Returns the timer id. @@ -3770,59 +3384,25 @@ _.delay(function(text) { -### `_.flow([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L7982 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flow "See the npm package") +### `_.flip(func)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8594 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flip "See the npm package") -Creates a function that returns the result of invoking the provided -functions with the `this` binding of the created function, where each -successive invocation is supplied the return value of the previous. +Creates a function that invokes `func` with arguments reversed. #### Arguments -1. `[funcs]` *(...Function)*: Functions to invoke. +1. `func` *(Function)*: The function to flip arguments for. #### Returns *(Function)*: Returns the new function. #### Example ```js -function square(n) { - return n * n; -} +var flipped = _.flip(function() { + return _.toArray(arguments); +}); -var addSquare = _.flow(_.add, square); -addSquare(1, 2); -// => 9 -``` -* * * - - - - - -### `_.flowRight([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8004 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flowright "See the npm package") - -This method is like `_.flow` except that it creates a function that -invokes the provided functions from right to left. - -#### Aliases -*_.backflow, _.compose* - -#### Arguments -1. `[funcs]` *(...Function)*: Functions to invoke. - -#### Returns -*(Function)*: Returns the new function. - -#### Example -```js -function square(n) { - return n * n; -} - -var addSquare = _.flowRight(square, _.add); -addSquare(1, 2); -// => 9 +flipped('a', 'b', 'c', 'd'); +// => ['d', 'c', 'b', 'a'] ``` * * * @@ -3831,20 +3411,19 @@ addSquare(1, 2); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8057 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.memoize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8640 "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 arguments provided to the memoized function. By default, the first argument -provided to the memoized function is coerced to a string and used as the -cache key. The `func` is invoked with the `this` binding of the memoized -function. +provided to the memoized function is used as the map cache key. The `func` +is invoked with the `this` binding of the memoized function.

**Note:** The cache is exposed as the `cache` property on the memoized function. Its creation may be customized by replacing the `_.memoize.Cache` constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) -method interface of `get`, `has`, and `set`. +method interface of `delete`, `get`, `has`, and `set`. #### Arguments 1. `func` *(Function)*: The function to have its output memoized. @@ -3855,74 +3434,27 @@ method interface of `get`, `has`, and `set`. #### Example ```js -var upperCase = _.memoize(function(string) { - return string.toUpperCase(); -}); +var object = { 'a': 1, 'b': 2 }; +var other = { 'c': 3, 'd': 4 }; -upperCase('fred'); -// => 'FRED' +var values = _.memoize(_.values); +values(object); +// => [1, 2] + +values(other); +// => [3, 4] + +object.a = 2; +values(object); +// => [1, 2] // modifying the result cache -upperCase.cache.set('fred', 'BARNEY'); -upperCase('fred'); -// => 'BARNEY' +values.cache.set(object, ['a', 'b']); +values(object); +// => ['a', 'b'] // replacing `_.memoize.Cache` -var object = { 'user': 'fred' }; -var other = { 'user': 'barney' }; -var identity = _.memoize(_.identity); - -identity(object); -// => { 'user': 'fred' } -identity(other); -// => { 'user': 'fred' } - _.memoize.Cache = WeakMap; -var identity = _.memoize(_.identity); - -identity(object); -// => { 'user': 'fred' } -identity(other); -// => { 'user': 'barney' } -``` -* * * - - - - - -### `_.modArgs(func, [transforms])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8108 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.modargs "See the npm package") - -Creates a function that runs each argument through a corresponding -transform function. - -#### Arguments -1. `func` *(Function)*: The function to wrap. -2. `[transforms]` *(...(Function|Function[])*: The functions to transform arguments, specified as individual functions or arrays of functions. - -#### Returns -*(Function)*: Returns the new function. - -#### Example -```js -function doubled(n) { - return n * 2; -} - -function square(n) { - return n * n; -} - -var modded = _.modArgs(function(x, y) { - return [x, y]; -}, square, doubled); - -modded(1, 2); -// => [1, 4] - -modded(5, 10); -// => [25, 20] ``` * * * @@ -3931,7 +3463,7 @@ modded(5, 10); ### `_.negate(predicate)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8142 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.negate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8679 "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 @@ -3959,11 +3491,11 @@ _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); ### `_.once(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8168 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8705 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm package") Creates a function that is restricted to invoking `func` once. Repeat calls -to the function return the value of the first call. The `func` is invoked -with the `this` binding and arguments of the created function. +to the function return the value of the first invocation. The `func` is +invoked with the `this` binding and arguments of the created function. #### Arguments 1. `func` *(Function)*: The function to restrict. @@ -3984,8 +3516,47 @@ initialize(); +### `_.overArgs(func, [transforms])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8740 "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`. + +#### Arguments +1. `func` *(Function)*: The function to wrap. +2. `[transforms]` *(...(Function|Function[])*: The functions to transform arguments, specified individually or in arrays. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +function doubled(n) { + return n * 2; +} + +function square(n) { + return n * n; +} + +var func = _.overArgs(function(x, y) { + return [x, y]; +}, square, doubled); + +func(9, 3); +// => [81, 6] + +func(10, 5); +// => [100, 10] +``` +* * * + + + + + ### `_.partial(func, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8204 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partial "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8787 "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 @@ -3996,7 +3567,7 @@ The `_.partial.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for partially applied arguments.

-**Note:** This method does not set the "length" property of partially +**Note:** This method doesn't set the "length" property of partially applied functions. #### Arguments @@ -4028,7 +3599,7 @@ greetFred('hi'); ### `_.partialRight(func, [partials])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8237 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partialright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8823 "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. @@ -4038,7 +3609,7 @@ The `_.partialRight.placeholder` value, which defaults to `_` in monolithic builds, may be used as a placeholder for partially applied arguments.

-**Note:** This method does not set the "length" property of partially +**Note:** This method doesn't set the "length" property of partially applied functions. #### Arguments @@ -4070,7 +3641,7 @@ sayHelloTo('fred'); ### `_.rearg(func, indexes)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8267 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rearg "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8850 "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 @@ -4079,7 +3650,7 @@ provided as the second argument, and so on. #### Arguments 1. `func` *(Function)*: The function to rearrange arguments for. -2. `indexes` *(...(number|number[])*: The arranged argument indexes, specified as individual indexes or arrays of indexes. +2. `indexes` *(...(number|number[])*: The arranged argument indexes, specified individually or in arrays. #### Returns *(Function)*: Returns the new function. @@ -4092,12 +3663,6 @@ var rearged = _.rearg(function(a, b, c) { rearged('b', 'c', 'a') // => ['a', 'b', 'c'] - -var map = _.rearg(_.map, [1, 0]); -map(function(n) { - return n * 3; -}, [1, 2, 3]); -// => [3, 6, 9] ``` * * * @@ -4105,14 +3670,14 @@ map(function(n) { -### `_.restParam(func, [start=func.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8293 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.restparam "See the npm package") +### `_.rest(func, [start=func.length-1])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8876 "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.

-**Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters). +**Note:** This method is based on the [rest parameter](https://mdn.io/rest_parameters). #### Arguments 1. `func` *(Function)*: The function to apply a rest parameter to. @@ -4123,7 +3688,7 @@ created function and arguments from `start` and beyond provided as an array. #### Example ```js -var say = _.restParam(function(what, names) { +var say = _.rest(function(what, names) { return what + ' ' + _.initial(names).join(', ') + (_.size(names) > 1 ? ', & ' : '') + _.last(names); }); @@ -4138,13 +3703,13 @@ say('hello', 'fred', 'barney', 'pebbles'); ### `_.spread(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8353 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.spread "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8936 "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).

-**Note:** This method is based on the [spread operator](https://developer.mozilla.org/Web/JavaScript/Reference/Operators/Spread_operator). +**Note:** This method is based on the [spread operator](https://mdn.io/spread_operator). #### Arguments 1. `func` *(Function)*: The function to spread arguments over. @@ -4179,14 +3744,16 @@ numbers.then(_.spread(function(x, y) { ### `_.throttle(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8401 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L8985 "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` -method to cancel delayed invocations. Provide an options object to indicate -that `func` should be invoked on the leading and/or trailing edge of the -`wait` timeout. Subsequent calls to the throttled function return the -result of the last `func` call. +method to cancel delayed `func` invocations and a `flush` method to +immediately invoke them. Provide an options object to indicate whether +`func` should be invoked on the leading and/or trailing edge of the `wait` +timeout. The `func` is invoked with the last arguments provided to the +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 @@ -4213,11 +3780,10 @@ for details over the differences between `_.throttle` and `_.debounce`. jQuery(window).on('scroll', _.throttle(updatePosition, 100)); // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes -jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - 'trailing': false -})); +var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); +jQuery(element).on('click', throttled); -// cancel a trailing throttled call +// cancel a trailing throttled invocation jQuery(window).on('popstate', throttled.cancel); ``` * * * @@ -4226,8 +3792,31 @@ jQuery(window).on('popstate', throttled.cancel); +### `_.unary(func)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9013 "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. + +#### Arguments +1. `func` *(Function)*: The function to cap arguments for. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +_.map(['6', '8', '10'], _.unary(parseInt)); +// => [6, 8, 10] +``` +* * * + + + + + ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8438 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.wrap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9038 "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 @@ -4262,60 +3851,33 @@ p('fred, barney, & pebbles'); -### `_.clone(value, [isDeep], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8496 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") +### `_.clone(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9069 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") -Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, -otherwise they are assigned by reference. If `customizer` is provided it's -invoked to produce the cloned values. If `customizer` returns `undefined` -cloning is handled by the method instead. The `customizer` is bound to -`thisArg` and invoked with up to three argument; (value [, index|key, object]). +Creates a shallow clone of `value`.

**Note:** This method is loosely based on the -[structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). -The enumerable properties of `arguments` objects and objects created by -constructors other than `Object` are cloned to plain `Object` objects. An -empty object is returned for uncloneable values such as functions, DOM nodes, -Maps, Sets, and WeakMaps. +[structured clone algorithm](https://mdn.io/Structured_clone_algorithm) +and supports cloning arrays, array buffers, booleans, date objects, maps, +numbers, `Object` objects, regexes, sets, strings, symbols, and typed +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. #### Arguments 1. `value` *(*)*: The value to clone. -2. `[isDeep]` *(boolean)*: Specify a deep clone. -3. `[customizer]` *(Function)*: The function to customize cloning values. -4. `[thisArg]` *(*)*: The `this` binding of `customizer`. #### Returns *(*)*: Returns the cloned value. #### Example ```js -var users = [ - { 'user': 'barney' }, - { 'user': 'fred' } -]; +var objects = [{ 'a': 1 }, { 'b': 2 }]; -var shallow = _.clone(users); -shallow[0] === users[0]; +var shallow = _.clone(objects); +console.log(shallow[0] === objects[0]); // => true - -var deep = _.clone(users, true); -deep[0] === users[0]; -// => false - -// using a customizer callback -var el = _.clone(document.body, function(value) { - if (_.isElement(value)) { - return value.cloneNode(false); - } -}); - -el === document.body -// => false -el.nodeName -// => BODY -el.childNodes.length; -// => 0 ``` * * * @@ -4323,53 +3885,58 @@ el.childNodes.length; -### `_.cloneDeep(value, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8555 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") +### `_.cloneDeep(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9122 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") -Creates a deep clone of `value`. If `customizer` is provided it's invoked -to produce the cloned values. If `customizer` returns `undefined` cloning -is handled by the method instead. The `customizer` is bound to `thisArg` -and invoked with up to three argument; (value [, index|key, object]). -
-
-**Note:** This method is loosely based on the -[structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). -The enumerable properties of `arguments` objects and objects created by -constructors other than `Object` are cloned to plain `Object` objects. An -empty object is returned for uncloneable values such as functions, DOM nodes, -Maps, Sets, and WeakMaps. +This method is like `_.clone` except that it recursively clones `value`. #### Arguments -1. `value` *(*)*: The value to deep clone. -2. `[customizer]` *(Function)*: The function to customize cloning values. -3. `[thisArg]` *(*)*: The `this` binding of `customizer`. +1. `value` *(*)*: The value to recursively clone. #### Returns *(*)*: Returns the deep cloned value. #### Example ```js -var users = [ - { 'user': 'barney' }, - { 'user': 'fred' } -]; +var objects = [{ 'a': 1 }, { 'b': 2 }]; -var deep = _.cloneDeep(users); -deep[0] === users[0]; +var deep = _.cloneDeep(objects); +console.log(deep[0] === objects[0]); // => false +``` +* * * -// using a customizer callback -var el = _.cloneDeep(document.body, function(value) { + + + + +### `_.cloneDeepWith(value, [customizer])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9152 "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`. + +#### Arguments +1. `value` *(*)*: The value to recursively clone. +2. `[customizer]` *(Function)*: The function to customize cloning. + +#### Returns +*(*)*: Returns the deep cloned value. + +#### Example +```js +function customizer(value) { if (_.isElement(value)) { return value.cloneNode(true); } -}); +} -el === document.body +var el = _.cloneDeep(document.body, customizer); + +console.log(el === document.body); // => false -el.nodeName -// => BODY -el.childNodes.length; +console.log(el.nodeName); +// => 'BODY' +console.log(el.childNodes.length); // => 20 ``` * * * @@ -4378,8 +3945,85 @@ el.childNodes.length; +### `_.cloneWith(value, [customizer])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9102 "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 five arguments; (value [, index|key, object, stack]). + +#### Arguments +1. `value` *(*)*: The value to clone. +2. `[customizer]` *(Function)*: The function to customize cloning. + +#### Returns +*(*)*: Returns the cloned value. + +#### Example +```js +function customizer(value) { + if (_.isElement(value)) { + return value.cloneNode(false); + } +} + +var el = _.clone(document.body, customizer); + +console.log(el === document.body); +// => false +console.log(el.nodeName); +// => 'BODY' +console.log(el.childNodes.length); +// => 0 +``` +* * * + + + + + +### `_.eq(value, other)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9186 "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) +comparison between two values to determine if they are equivalent. + +#### 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`. + +#### Example +```js +var object = { 'user': 'fred' }; +var other = { 'user': 'fred' }; + +_.eq(object, object); +// => true + +_.eq(object, other); +// => false + +_.eq('a', 'a'); +// => true + +_.eq('a', Object('a')); +// => false + +_.eq(NaN, NaN); +// => true +``` +* * * + + + + + ### `_.gt(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8581 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.gt "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9210 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.gt "See the npm package") Checks if `value` is greater than `other`. @@ -4408,7 +4052,7 @@ _.gt(1, 3); ### `_.gte(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8605 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.gte "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9234 "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`. @@ -4437,9 +4081,9 @@ _.gte(1, 3); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8625 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9254 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") -Checks if `value` is classified as an `arguments` object. +Checks if `value` is likely an `arguments` object. #### Arguments 1. `value` *(*)*: The value to check. @@ -4462,7 +4106,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8646 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9283 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") Checks if `value` is classified as an `Array` object. @@ -4477,7 +4121,78 @@ Checks if `value` is classified as an `Array` object. _.isArray([1, 2, 3]); // => true -_.isArray(function() { return arguments; }()); +_.isArray(document.body.children); +// => false + +_.isArray('abc'); +// => false + +_.isArray(_.noop); +// => false +``` +* * * + + + + + +### `_.isArrayLike(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9310 "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`. + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is array-like, else `false`. + +#### Example +```js +_.isArrayLike([1, 2, 3]); +// => true + +_.isArrayLike(document.body.children); +// => true + +_.isArrayLike('abc'); +// => true + +_.isArrayLike(_.noop); +// => false +``` +* * * + + + + + +### `_.isArrayLikeObject(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9339 "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. + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is an array-like object, else `false`. + +#### Example +```js +_.isArrayLikeObject([1, 2, 3]); +// => true + +_.isArrayLikeObject(document.body.children); +// => true + +_.isArrayLikeObject('abc'); +// => false + +_.isArrayLikeObject(_.noop); // => false ``` * * * @@ -4487,7 +4202,7 @@ _.isArray(function() { return arguments; }()); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8666 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isboolean "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9359 "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. @@ -4512,7 +4227,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8686 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9380 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") Checks if `value` is classified as a `Date` object. @@ -4537,9 +4252,9 @@ _.isDate('Mon April 23 2012'); ### `_.isElement(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8706 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9400 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") -Checks if `value` is a DOM element. +Checks if `value` is likely a DOM element. #### Arguments 1. `value` *(*)*: The value to check. @@ -4562,7 +4277,7 @@ _.isElement(''); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8737 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9431 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") Checks if `value` is empty. A value is considered empty unless it's an `arguments` object, array, string, or jQuery-like collection with a length @@ -4597,30 +4312,22 @@ _.isEmpty({ 'a': 1 }); -### `_.isEqual(value, other, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8792 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm package") +### `_.isEqual(value, other)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9464 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm package") Performs a deep comparison between two values to determine if they are -equivalent. If `customizer` is provided it's invoked to compare values. -If `customizer` returns `undefined` comparisons are handled by the method -instead. The `customizer` is bound to `thisArg` and invoked with up to -three arguments: (value, other [, index|key]). +equivalent.

-**Note:** This method supports comparing arrays, booleans, `Date` objects, -numbers, `Object` objects, regexes, and strings. Objects are compared by -their own, not inherited, enumerable properties. Functions and DOM nodes -are **not** supported. Provide a customizer function to extend support -for comparing other values. - -#### Aliases -*_.eq* +**Note:** This method supports comparing arrays, array buffers, booleans, +date objects, error objects, maps, numbers, `Object` objects, regexes, +sets, strings, symbols, and typed arrays. `Object` objects are compared +by their own, not inherited, enumerable properties. Functions and DOM +nodes are **not** supported. #### Arguments 1. `value` *(*)*: The value to compare. 2. `other` *(*)*: The other value to compare. -3. `[customizer]` *(Function)*: The function to customize value comparisons. -4. `[thisArg]` *(*)*: The `this` binding of `customizer`. #### Returns *(boolean)*: Returns `true` if the values are equivalent, else `false`. @@ -4630,21 +4337,50 @@ for comparing other values. var object = { 'user': 'fred' }; var other = { 'user': 'fred' }; -object == other; -// => false - _.isEqual(object, other); // => true -// using a customizer callback +object === other; +// => false +``` +* * * + + + + + +### `_.isEqualWith(value, other, [customizer])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9499 "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 seven arguments:
+(objValue, othValue [, index|key, object, other, stack]). + +#### 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`. + +#### Example +```js +function isGreeting(value) { + return /^h(?:i|ello)$/.test(value); +} + +function customizer(objValue, othValue) { + if (isGreeting(objValue) && isGreeting(othValue)) { + return true; + } +} + var array = ['hello', 'goodbye']; var other = ['hi', 'goodbye']; -_.isEqual(array, other, function(value, other) { - if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { - return true; - } -}); +_.isEqualWith(array, other, customizer); // => true ``` * * * @@ -4654,7 +4390,7 @@ _.isEqual(array, other, function(value, other) { ### `_.isError(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8815 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iserror "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9522 "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. @@ -4680,12 +4416,12 @@ _.isError(Error); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8846 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9551 "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`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite). +**Note:** This method is based on [`Number.isFinite`](https://mdn.io/Number/isFinite). #### Arguments 1. `value` *(*)*: The value to check. @@ -4695,17 +4431,14 @@ Checks if `value` is a finite primitive number. #### Example ```js -_.isFinite(10); +_.isFinite(3); // => true -_.isFinite('10'); -// => false +_.isFinite(Number.MAX_VALUE); +// => true -_.isFinite(true); -// => false - -_.isFinite(Object(10)); -// => false +_.isFinite(3.14); +// => true _.isFinite(Infinity); // => false @@ -4717,7 +4450,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8866 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9571 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") Checks if `value` is classified as a `Function` object. @@ -4741,26 +4474,86 @@ _.isFunction(/abc/); -### `_.isMatch(object, source, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8939 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") +### `_.isInteger(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9603 "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). + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is an integer, else `false`. + +#### Example +```js +_.isInteger(3); +// => true + +_.isInteger(Number.MIN_VALUE); +// => false + +_.isInteger(Infinity); +// => false + +_.isInteger('3'); +// => false +``` +* * * + + + + + +### `_.isLength(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9631 "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). + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is a valid length, else `false`. + +#### Example +```js +_.isLength(3); +// => true + +_.isLength(Number.MIN_VALUE); +// => false + +_.isLength(Infinity); +// => false + +_.isLength('3'); +// => false +``` +* * * + + + + + +### `_.isMatch(object, source)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9714 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") Performs a deep comparison between `object` and `source` to determine if -`object` contains equivalent property values. If `customizer` is provided -it's invoked to compare values. If `customizer` returns `undefined` -comparisons are handled by the method instead. The `customizer` is bound -to `thisArg` and invoked with three arguments: (value, other, index|key). +`object` contains equivalent property values.

-**Note:** This method supports comparing properties of arrays, booleans, -`Date` objects, numbers, `Object` objects, regexes, and strings. Functions -and DOM nodes are **not** supported. Provide a customizer function to extend -support for comparing other values. +**Note:** This method supports comparing the same values as `_.isEqual`. #### 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 value comparisons. -4. `[thisArg]` *(*)*: The `this` binding of `customizer`. #### Returns *(boolean)*: Returns `true` if `object` is a match, else `false`. @@ -4774,14 +4567,45 @@ _.isMatch(object, { 'age': 40 }); _.isMatch(object, { 'age': 36 }); // => false +``` +* * * + + + + + +### `_.isMatchWith(object, source, [customizer])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9749 "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 three +arguments: (objValue, srcValue, index|key, object, source). + +#### 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`. + +#### Example +```js +function isGreeting(value) { + return /^h(?:i|ello)$/.test(value); +} + +function customizer(objValue, srcValue) { + if (isGreeting(objValue) && isGreeting(srcValue)) { + return true; + } +} -// using a customizer callback var object = { 'greeting': 'hello' }; var source = { 'greeting': 'hi' }; -_.isMatch(object, source, function(value, other) { - return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; -}); +_.isMatchWith(object, source, customizer); // => true ``` * * * @@ -4791,7 +4615,7 @@ _.isMatch(object, source, function(value, other) { ### `_.isNaN(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8969 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9779 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") Checks if `value` is `NaN`.
@@ -4826,7 +4650,7 @@ _.isNaN(undefined); ### `_.isNative(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8991 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9801 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") Checks if `value` is a native function. @@ -4850,8 +4674,36 @@ _.isNative(_); +### `_.isNil(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9851 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnil "See the npm package") + +Checks if `value` is `null` or `undefined`. + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is nullish, else `false`. + +#### Example +```js +_.isNil(null); +// => true + +_.isNil(void 0); +// => true + +_.isNil(NaN); +// => false +``` +* * * + + + + + ### `_.isNull(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9017 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9828 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") Checks if `value` is `null`. @@ -4876,7 +4728,7 @@ _.isNull(void 0); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9043 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnumber "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9880 "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.
@@ -4892,13 +4744,16 @@ as numbers, use the `_.isFinite` method. #### Example ```js -_.isNumber(8.4); +_.isNumber(3); // => true -_.isNumber(NaN); +_.isNumber(Number.MIN_VALUE); // => true -_.isNumber('8.4'); +_.isNumber(Infinity); +// => true + +_.isNumber('3'); // => false ``` * * * @@ -4908,7 +4763,7 @@ _.isNumber('8.4'); ### `_.isObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L8893 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9658 "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('')`) @@ -4927,7 +4782,42 @@ _.isObject({}); _.isObject([1, 2, 3]); // => true -_.isObject(1); +_.isObject(_.noop); +// => true + +_.isObject(null); +// => false +``` +* * * + + + + + +### `_.isObjectLike(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9688 "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". + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is object-like, else `false`. + +#### Example +```js +_.isObjectLike({}); +// => true + +_.isObjectLike([1, 2, 3]); +// => true + +_.isObjectLike(_.noop); +// => false + +_.isObjectLike(null); // => false ``` * * * @@ -4937,14 +4827,10 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9077 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9912 "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`. -
-
-**Note:** This method assumes objects created by the `Object` constructor -have no inherited enumerable properties. #### Arguments 1. `value` *(*)*: The value to check. @@ -4977,7 +4863,7 @@ _.isPlainObject(Object.create(null)); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9121 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9944 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") Checks if `value` is classified as a `RegExp` object. @@ -5001,8 +4887,43 @@ _.isRegExp('/abc/'); +### `_.isSafeInteger(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9973 "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). + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is a safe integer, else `false`. + +#### Example +```js +_.isSafeInteger(3); +// => true + +_.isSafeInteger(Number.MIN_VALUE); +// => false + +_.isSafeInteger(Infinity); +// => false + +_.isSafeInteger('3'); +// => false +``` +* * * + + + + + ### `_.isString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9141 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isstring "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L9993 "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. @@ -5026,8 +4947,33 @@ _.isString(1); +### `_.isSymbol(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10014 "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. + +#### Arguments +1. `value` *(*)*: The value to check. + +#### Returns +*(boolean)*: Returns `true` if `value` is correctly classified, else `false`. + +#### Example +```js +_.isSymbol(Symbol.iterator); +// => true + +_.isSymbol('abc'); +// => false +``` +* * * + + + + + ### `_.isTypedArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9161 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10035 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") Checks if `value` is classified as a typed array. @@ -5052,7 +4998,7 @@ _.isTypedArray([]); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9181 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10055 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") Checks if `value` is `undefined`. @@ -5077,7 +5023,7 @@ _.isUndefined(null); ### `_.lt(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9205 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lt "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10079 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lt "See the npm package") Checks if `value` is less than `other`. @@ -5106,7 +5052,7 @@ _.lt(3, 1); ### `_.lte(value, other)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9229 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lte "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10103 "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`. @@ -5135,7 +5081,7 @@ _.lte(3, 1); ### `_.toArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9248 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10129 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") Converts `value` to an array. @@ -5147,10 +5093,114 @@ Converts `value` to an array. #### Example ```js -(function() { - return _.toArray(arguments).slice(1); -}(1, 2, 3)); -// => [2, 3] +_.toArray({ 'a': 1, 'b': 2 }); +// => [1, 2] + +_.toArray('abc'); +// => ['a', 'b', 'c'] + +_.toArray(1); +// => [] + +_.toArray(null); +// => [] +``` +* * * + + + + + +### `_.toInteger(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10169 "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). + +#### Arguments +1. `value` *(*)*: The value to convert. + +#### Returns +*(number)*: Returns the converted integer. + +#### Example +```js +_.toInteger(3); +// => 3 + +_.toInteger(Number.MIN_VALUE); +// => 0 + +_.toInteger(Infinity); +// => 1.7976931348623157e+308 + +_.toInteger('3'); +// => 3 +``` +* * * + + + + + +### `_.toLength(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10207 "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). + +#### Arguments +1. `value` *(*)*: The value to convert. + +#### Example +```js +_.toLength(3); +// => 3 + +_.toLength(Number.MIN_VALUE); +// => 0 + +_.toLength(Infinity); +// => 4294967295 + +_.toLength('3'); +// => 3 +``` +* * * + + + + + +### `_.toNumber(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10233 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tonumber "See the npm package") + +Converts `value` to a number. + +#### Arguments +1. `value` *(*)*: The value to process. + +#### Returns +*(number)*: Returns the number. + +#### Example +```js +_.toNumber(3); +// => 3 + +_.toNumber(Number.MIN_VALUE); +// => 5e-324 + +_.toNumber(Infinity); +// => Infinity + +_.toNumber('3'); +// => 3 ``` * * * @@ -5159,7 +5209,7 @@ Converts `value` to an array. ### `_.toPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9284 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10271 "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. @@ -5188,6 +5238,67 @@ _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + + +### `_.toSafeInteger(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10298 "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. + +#### Arguments +1. `value` *(*)*: The value to convert. + +#### Returns +*(number)*: Returns the converted integer. + +#### Example +```js +_.toSafeInteger(3); +// => 3 + +_.toSafeInteger(Number.MIN_VALUE); +// => 0 + +_.toSafeInteger(Infinity); +// => 9007199254740991 + +_.toSafeInteger('3'); +// => 3 +``` +* * * + + + + + +### `_.toString(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10322 "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. + +#### Arguments +1. `value` *(*)*: The value to process. + +#### Returns +*(string)*: Returns the string. + +#### Example +```js +_.toString(null); +// => '' + +_.toString(-0); +// => '-0' + +_.toString([1, 2, 3]); +// => '1,2,3' +``` +* * * + + + @@ -5197,16 +5308,16 @@ _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); ### `_.add(augend, addend)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11803 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13547 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm package") Adds two numbers. #### Arguments -1. `augend` *(number)*: The first number to add. -2. `addend` *(number)*: The second number to add. +1. `augend` *(number)*: The first number in an addition. +2. `addend` *(number)*: The second number in an addition. #### Returns -*(number)*: Returns the sum. +*(number)*: Returns the total. #### Example ```js @@ -5219,13 +5330,13 @@ _.add(6, 4); -### `_.ceil(n, [precision=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11827 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ceil "See the npm package") +### `_.ceil(number, [precision=0])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13578 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ceil "See the npm package") -Calculates `n` rounded up to `precision`. +Computes `number` rounded up to `precision`. #### Arguments -1. `n` *(number)*: The number to round up. +1. `number` *(number)*: The number to round up. 2. `[precision=0]` *(number)*: The precision to round up to. #### Returns @@ -5248,13 +5359,13 @@ _.ceil(6040, -2); -### `_.floor(n, [precision=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11849 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.floor "See the npm package") +### `_.floor(number, [precision=0])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13600 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.floor "See the npm package") -Calculates `n` rounded down to `precision`. +Computes `number` rounded down to `precision`. #### Arguments -1. `n` *(number)*: The number to round down. +1. `number` *(number)*: The number to round down. 2. `[precision=0]` *(number)*: The precision to round down to. #### Returns @@ -5277,33 +5388,14 @@ _.floor(4060, -2); -### `_.max(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11898 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm package") +### `_.max(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13619 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm package") -Gets the maximum value of `collection`. If `collection` is empty or falsey -`-Infinity` is returned. If an iteratee function is provided it's invoked -for each value in `collection` to generate the criterion by which the value -is ranked. The `iteratee` is bound to `thisArg` and invoked with three -arguments: (value, index, collection). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +Computes the maximum value of `array`. If `array` is empty or falsey +`undefined` is returned. #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +1. `array` *(Array)*: The array to iterate over. #### Returns *(*)*: Returns the maximum value. @@ -5314,21 +5406,7 @@ _.max([4, 2, 8, 6]); // => 8 _.max([]); -// => -Infinity - -var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } -]; - -_.max(users, function(chr) { - return chr.age; -}); -// => { 'user': 'fred', 'age': 40 } - -// using the `_.property` callback shorthand -_.max(users, 'age'); -// => { 'user': 'fred', 'age': 40 } +// => undefined ``` * * * @@ -5336,33 +5414,67 @@ _.max(users, 'age'); -### `_.min(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11947 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.min "See the npm package") +### `_.maxBy(array, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13647 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.maxby "See the npm package") -Gets the minimum value of `collection`. If `collection` is empty or falsey -`Infinity` is returned. If an iteratee function is provided it's invoked -for each value in `collection` to generate the criterion by which the value -is ranked. The `iteratee` is bound to `thisArg` and invoked with three -arguments: (value, index, collection). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +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). #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +1. `array` *(Array)*: The array to iterate over. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. + +#### Returns +*(*)*: Returns the maximum value. + +#### Example +```js +var objects = [{ 'n': 1 }, { 'n': 2 }]; + +_.maxBy(objects, function(o) { return o.a; }); +// => { 'n': 2 } + +// using the `_.property` iteratee shorthand +_.maxBy(objects, 'n'); +// => { 'n': 2 } +``` +* * * + + + + + +### `_.mean(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13666 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mean "See the npm package") + +Computes the mean of the values in `array`. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. + +#### Returns +*(number)*: Returns the mean. + +#### Example +```js +_.mean([4, 2, 8, 6]); +// => 5 +``` +* * * + + + + + +### `_.min(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13687 "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. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. #### Returns *(*)*: Returns the minimum value. @@ -5373,21 +5485,7 @@ _.min([4, 2, 8, 6]); // => 2 _.min([]); -// => Infinity - -var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } -]; - -_.min(users, function(chr) { - return chr.age; -}); -// => { 'user': 'barney', 'age': 36 } - -// using the `_.property` callback shorthand -_.min(users, 'age'); -// => { 'user': 'barney', 'age': 36 } +// => undefined ``` * * * @@ -5395,13 +5493,44 @@ _.min(users, 'age'); -### `_.round(n, [precision=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11969 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.round "See the npm package") +### `_.minBy(array, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13715 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.minby "See the npm package") -Calculates `n` rounded to `precision`. +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). #### Arguments -1. `n` *(number)*: The number to round. +1. `array` *(Array)*: The array to iterate over. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. + +#### Returns +*(*)*: Returns the minimum value. + +#### Example +```js +var objects = [{ 'n': 1 }, { 'n': 2 }]; + +_.minBy(objects, function(o) { return o.a; }); +// => { 'n': 1 } + +// using the `_.property` iteratee shorthand +_.minBy(objects, 'n'); +// => { 'n': 1 } +``` +* * * + + + + + +### `_.round(number, [precision=0])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13741 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.round "See the npm package") + +Computes `number` rounded to `precision`. + +#### Arguments +1. `number` *(number)*: The number to round. 2. `[precision=0]` *(number)*: The precision to round to. #### Returns @@ -5424,40 +5553,75 @@ _.round(4060, -2); -### `_.sum(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L12003 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sum "See the npm package") +### `_.subtract(minuend, subtrahend)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13757 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.subtract "See the npm package") -Gets the sum of the values in `collection`. +Subtract two numbers. #### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. +1. `minuend` *(number)*: The first number in a subtraction. +2. `subtrahend` *(number)*: The second number in a subtraction. + +#### Returns +*(number)*: Returns the difference. + +#### Example +```js +_.subtract(6, 4); +// => 2 +``` +* * * + + + + + +### `_.sum(array)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13781 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sum "See the npm package") + +Computes the sum of the values in `array`. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. #### Returns *(number)*: Returns the sum. #### Example ```js -_.sum([4, 6]); -// => 10 +_.sum([4, 2, 8, 6]); +// => 20 +``` +* * * -_.sum({ 'a': 4, 'b': 6 }); -// => 10 + -var objects = [ - { 'n': 4 }, - { 'n': 6 } -]; + -_.sum(objects, function(object) { - return object.n; -}); -// => 10 +### `_.sumBy(array, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13809 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sumby "See the npm package") -// using the `_.property` callback shorthand -_.sum(objects, 'n'); -// => 10 +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). + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `[iteratee=_.identity]` *(Function|Object|string)*: The iteratee invoked per element. + +#### Returns +*(number)*: Returns the sum. + +#### Example +```js +var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; + +_.sumBy(objects, function(o) { return o.n; }); +// => 20 + +// using the `_.property` iteratee shorthand +_.sumBy(objects, 'n'); +// => 20 ``` * * * @@ -5471,19 +5635,48 @@ _.sum(objects, 'n'); -### `_.inRange(n, [start=0], end)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10321 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.inrange "See the npm package") +### `_.clamp(number, [lower], upper)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11575 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clamp "See the npm package") + +Clamps `number` within the inclusive `lower` and `upper` bounds. + +#### 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. + +#### Example +```js +_.clamp(-10, -5, 5); +// => -5 + +_.clamp(10, -5, 5); +// => 5 +``` +* * * + + + + + +### `_.inRange(number, [start=0], end)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11627 "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. #### Arguments -1. `n` *(number)*: The number to check. +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 `n` is in the range, else `false`. +*(boolean)*: Returns `true` if `number` is in the range, else `false`. #### Example ```js @@ -5504,6 +5697,9 @@ _.inRange(1.2, 2); _.inRange(5.2, 4); // => false + +_.inRange(-3, -2, -6); +// => true ``` * * * @@ -5511,17 +5707,21 @@ _.inRange(5.2, 4); -### `_.random([min=0], [max=1], [floating])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10359 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") +### `_.random([lower=0], [upper=1], [floating])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11669 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") -Produces a random number between `min` and `max` (inclusive). If only one -argument is provided a number between `0` and the given number is returned. -If `floating` is `true`, or either `min` or `max` are floats, a floating-point -number is returned instead of an integer. +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. +
+
+**Note:** JavaScript follows the IEEE-754 standard for resolving +floating-point values which can produce unexpected results. #### Arguments -1. `[min=0]` *(number)*: The minimum possible value. -2. `[max=1]` *(number)*: The maximum possible value. +1. `[lower=0]` *(number)*: The lower bound. +2. `[upper=1]` *(number)*: The upper bound. 3. `[floating]` *(boolean)*: Specify returning a floating-point number. #### Returns @@ -5553,18 +5753,54 @@ _.random(1.2, 5.2); -### `_.assign(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9372 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") +### `_.assign(object, [sources])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10369 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") -Assigns own enumerable properties of source object(s) to the destination -object. Subsequent sources overwrite property assignments of previous sources. -If `customizer` is provided it's invoked to produce the assigned values. -The `customizer` is bound to `thisArg` and invoked with five arguments:
-(objectValue, sourceValue, key, object, source). +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.

-**Note:** This method mutates `object` and is based on -[`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). +**Note:** This method mutates `object` and is loosely based on +[`Object.assign`](https://mdn.io/Object/assign). + +#### Arguments +1. `object` *(Object)*: The destination object. +2. `[sources]` *(...Object)*: The source objects. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +function Foo() { + this.c = 3; +} + +function Bar() { + this.e = 5; +} + +Foo.prototype.d = 4; +Bar.prototype.f = 6; + +_.assign({ 'a': 1 }, new Foo, new Bar); +// => { 'a': 1, 'c': 3, 'e': 5 } +``` +* * * + + + + + +### `_.assignIn(object, [sources])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10402 "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. +
+
+**Note:** This method mutates `object`. #### Aliases *_.extend* @@ -5572,24 +5808,128 @@ The `customizer` is bound to `thisArg` and invoked with five arguments:
#### Arguments 1. `object` *(Object)*: The destination object. 2. `[sources]` *(...Object)*: The source objects. -3. `[customizer]` *(Function)*: The function to customize assigned values. -4. `[thisArg]` *(*)*: The `this` binding of `customizer`. #### Returns *(Object)*: Returns `object`. #### Example ```js -_.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); -// => { 'user': 'fred', 'age': 40 } +function Foo() { + this.b = 2; +} -// using a customizer callback -var defaults = _.partialRight(_.assign, function(value, other) { - return _.isUndefined(value) ? other : value; -}); +function Bar() { + this.d = 4; +} -defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); -// => { 'user': 'barney', 'age': 36 } +Foo.prototype.c = 3; +Bar.prototype.e = 5; + +_.assignIn({ 'a': 1 }, new Foo, new Bar); +// => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 } +``` +* * * + + + + + +### `_.assignInWith(object, sources, [customizer])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10433 "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). +
+
+**Note:** This method mutates `object`. + +#### Aliases +*_.extendWith* + +#### 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`. + +#### Example +```js +function customizer(objValue, srcValue) { + return _.isUndefined(objValue) ? srcValue : objValue; +} + +var defaults = _.partialRight(_.assignInWith, customizer); + +defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); +// => { 'a': 1, 'b': 2 } +``` +* * * + + + + + +### `_.assignWith(object, sources, [customizer])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10463 "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). +
+
+**Note:** This method mutates `object`. + +#### 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`. + +#### Example +```js +function customizer(objValue, srcValue) { + return _.isUndefined(objValue) ? srcValue : objValue; +} + +var defaults = _.partialRight(_.assignWith, customizer); + +defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); +// => { 'a': 1, 'b': 2 } +``` +* * * + + + + + +### `_.at(object, [paths])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10487 "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`. + +#### 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. + +#### Returns +*(Array)*: Returns the new array of picked elements. + +#### Example +```js +var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + +_.at(object, ['a[0].b.c', 'a[1]']); +// => [3, 4] + +_.at(['a', 'b', 'c'], 0, 2); +// => ['a', 'c'] ``` * * * @@ -5598,11 +5938,10 @@ defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.create(prototype, [properties])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9412 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10523 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") -Creates an object that inherits from the given `prototype` object. If a -`properties` object is provided its own enumerable properties are assigned -to the created object. +Creates an object that inherits from the `prototype` object. If a `properties` +object is provided its own enumerable properties are assigned to the created object. #### Arguments 1. `prototype` *(Object)*: The object to inherit from. @@ -5640,11 +5979,12 @@ circle instanceof Shape; ### `_.defaults(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9438 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10547 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") -Assigns own enumerable properties of source object(s) to the destination -object for all destination properties that resolve to `undefined`. Once a -property is set, additional values of the same property are ignored. +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.

**Note:** This method mutates `object`. @@ -5668,7 +6008,7 @@ _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.defaultsDeep(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9458 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaultsdeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10570 "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. @@ -5694,30 +6034,15 @@ _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'ag -### `_.findKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9508 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findkey "See the npm package") +### `_.findKey(object, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10608 "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. -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. #### Arguments 1. `object` *(Object)*: The object to search. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(string|undefined)*: Returns the key of the matched element, else `undefined`. @@ -5730,20 +6055,18 @@ var users = { 'pebbles': { 'age': 1, 'active': true } }; -_.findKey(users, function(chr) { - return chr.age < 40; -}); +_.findKey(users, function(o) { return o.age < 40; }); // => 'barney' (iteration order is not guaranteed) -// using the `_.matches` callback shorthand +// using the `_.matches` iteratee shorthand _.findKey(users, { 'age': 1, 'active': true }); // => 'pebbles' -// using the `_.matchesProperty` callback shorthand -_.findKey(users, 'active', false); +// using the `_.matchesProperty` iteratee shorthand +_.findKey(users, ['active', false]); // => 'fred' -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.findKey(users, 'active'); // => 'barney' ``` @@ -5753,30 +6076,15 @@ _.findKey(users, 'active'); -### `_.findLastKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9558 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastkey "See the npm package") +### `_.findLastKey(object, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10645 "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. -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. #### Arguments 1. `object` *(Object)*: The object to search. 2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. #### Returns *(string|undefined)*: Returns the key of the matched element, else `undefined`. @@ -5789,20 +6097,18 @@ var users = { 'pebbles': { 'age': 1, 'active': true } }; -_.findLastKey(users, function(chr) { - return chr.age < 40; -}); -// => returns `pebbles` assuming `_.findKey` returns `barney` +_.findLastKey(users, function(o) { return o.age < 40; }); +// => returns 'pebbles' assuming `_.findKey` returns 'barney' -// using the `_.matches` callback shorthand +// using the `_.matches` iteratee shorthand _.findLastKey(users, { 'age': 36, 'active': true }); // => 'barney' -// using the `_.matchesProperty` callback shorthand -_.findLastKey(users, 'active', false); +// using the `_.matchesProperty` iteratee shorthand +_.findLastKey(users, ['active', false]); // => 'fred' -// using the `_.property` callback shorthand +// using the `_.property` iteratee shorthand _.findLastKey(users, 'active'); // => 'pebbles' ``` @@ -5812,18 +6118,17 @@ _.findLastKey(users, 'active'); -### `_.forIn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9587 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forin "See the npm package") +### `_.forIn(object, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10675 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forin "See the npm package") Iterates over own and inherited enumerable properties of an object invoking -`iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked -with three arguments: (value, key, object). Iteratee functions may exit -iteration early by explicitly returning `false`. +`iteratee` for each property. The iteratee is invoked with three arguments:
+(value, key, object). Iteratee functions may exit iteration early by explicitly +returning `false`. #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Object)*: Returns `object`. @@ -5840,7 +6145,7 @@ Foo.prototype.c = 3; _.forIn(new Foo, function(value, key) { console.log(key); }); -// => logs 'a', 'b', and 'c' (iteration order is not guaranteed) +// => logs 'a', 'b', then 'c' (iteration order is not guaranteed) ``` * * * @@ -5848,8 +6153,8 @@ _.forIn(new Foo, function(value, key) { -### `_.forInRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9614 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forinright "See the npm package") +### `_.forInRight(object, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10703 "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. @@ -5857,7 +6162,6 @@ This method is like `_.forIn` except that it iterates over properties of #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Object)*: Returns `object`. @@ -5874,7 +6178,7 @@ Foo.prototype.c = 3; _.forInRight(new Foo, function(value, key) { console.log(key); }); -// => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c' +// => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c' ``` * * * @@ -5882,18 +6186,17 @@ _.forInRight(new Foo, function(value, key) { -### `_.forOwn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9643 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forown "See the npm package") +### `_.forOwn(object, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10733 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forown "See the npm package") Iterates over own enumerable properties of an object invoking `iteratee` -for each property. The `iteratee` is bound to `thisArg` and invoked with -three arguments: (value, key, object). Iteratee functions may exit iteration -early by explicitly returning `false`. +for each property. The iteratee is invoked with three arguments:
+(value, key, object). Iteratee functions may exit iteration early by +explicitly returning `false`. #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Object)*: Returns `object`. @@ -5910,7 +6213,7 @@ Foo.prototype.c = 3; _.forOwn(new Foo, function(value, key) { console.log(key); }); -// => logs 'a' and 'b' (iteration order is not guaranteed) +// => logs 'a' then 'b' (iteration order is not guaranteed) ``` * * * @@ -5918,8 +6221,8 @@ _.forOwn(new Foo, function(value, key) { -### `_.forOwnRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9670 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forownright "See the npm package") +### `_.forOwnRight(object, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10761 "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. @@ -5927,7 +6230,6 @@ This method is like `_.forOwn` except that it iterates over properties of #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Object)*: Returns `object`. @@ -5944,7 +6246,7 @@ Foo.prototype.c = 3; _.forOwnRight(new Foo, function(value, key) { console.log(key); }); -// => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' +// => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b' ``` * * * @@ -5953,13 +6255,10 @@ _.forOwnRight(new Foo, function(value, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9687 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10786 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") -Creates an array of function property names from all enumerable properties, -own and inherited, of `object`. - -#### Aliases -*_.methods* +Creates an array of function property names from own enumerable properties +of `object`. #### Arguments 1. `object` *(Object)*: The object to inspect. @@ -5969,8 +6268,45 @@ own and inherited, of `object`. #### Example ```js -_.functions(_); -// => ['after', 'ary', 'assign', ...] +function Foo() { + this.a = _.constant('a'); + this.b = _.constant('b'); +} + +Foo.prototype.c = _.constant('c'); + +_.functions(new Foo); +// => ['a', 'b'] +``` +* * * + + + + + +### `_.functionsIn(object)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10811 "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`. + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns the new array of property names. + +#### Example +```js +function Foo() { + this.a = _.constant('a'); + this.b = _.constant('b'); +} + +Foo.prototype.c = _.constant('c'); + +_.functionsIn(new Foo); +// => ['a', 'b', 'c'] ``` * * * @@ -5979,9 +6315,9 @@ _.functions(_); ### `_.get(object, path, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9715 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.get "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10839 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.get "See the npm package") -Gets the property value at `path` of `object`. If the resolved value is +Gets the value at `path` of `object`. If the resolved value is `undefined` the `defaultValue` is used in its place. #### Arguments @@ -6012,20 +6348,21 @@ _.get(object, 'a.b.c', 'default'); ### `_.has(object, path)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9742 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10870 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") -Checks if `path` is a direct property. +Checks if `path` is a direct property of `object`. #### Arguments 1. `object` *(Object)*: The object to query. 2. `path` *(Array|string)*: The path to check. #### Returns -*(boolean)*: Returns `true` if `path` is a direct property, else `false`. +*(boolean)*: Returns `true` if `path` exists, else `false`. #### Example ```js var object = { 'a': { 'b': { 'c': 3 } } }; +var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); _.has(object, 'a'); // => true @@ -6035,6 +6372,9 @@ _.has(object, 'a.b.c'); _.has(object, ['a', 'b', 'c']); // => true + +_.has(other, 'a'); +// => false ``` * * * @@ -6042,16 +6382,50 @@ _.has(object, ['a', 'b', 'c']); -### `_.invert(object, [multiValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9783 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invert "See the npm package") +### `_.hasIn(object, path)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10899 "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`. + +#### 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`. + +#### Example +```js +var object = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); + +_.hasIn(object, 'a'); +// => true + +_.hasIn(object, 'a.b.c'); +// => true + +_.hasIn(object, ['a', 'b', 'c']); +// => true + +_.hasIn(object, 'b'); +// => false +``` +* * * + + + + + +### `_.invert(object, [multiVal])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10926 "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 unless `multiValue` is `true`. +assignments of previous values unless `multiVal` is `true`. #### Arguments 1. `object` *(Object)*: The object to invert. -2. `[multiValue]` *(boolean)*: Allow multiple values per key. +2. `[multiVal]` *(boolean)*: Allow multiple values per key. #### Returns *(Object)*: Returns the new inverted object. @@ -6063,7 +6437,7 @@ var object = { 'a': 1, 'b': 2, 'c': 1 }; _.invert(object); // => { '1': 'c', '2': 'b' } -// with `multiValue` +// with `multiVal` _.invert(object, true); // => { '1': ['a', 'c'], '2': ['b'] } ``` @@ -6073,8 +6447,34 @@ _.invert(object, true); +### `_.invoke(object, path, [args])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10960 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "See the npm package") + +Invokes the method at `path` of `object`. + +#### 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. + +#### Example +```js +var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; + +_.invoke(object, 'a[0].b.c.slice', 1, 3); +// => [2, 3] +``` +* * * + + + + + ### `_.keys(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9837 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keys "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L10989 "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`.
@@ -6111,7 +6511,7 @@ _.keys('hi'); ### `_.keysIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9868 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keysin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11031 "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`.
@@ -6142,8 +6542,8 @@ _.keysIn(new Foo); -### `_.mapKeys(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9945 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapkeys "See the npm package") +### `_.mapKeys(object, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11069 "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 @@ -6152,7 +6552,6 @@ property of `object` through `iteratee`. #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Object)*: Returns the new mapped object. @@ -6170,49 +6569,31 @@ _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { -### `_.mapValues(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9988 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapvalues "See the npm package") +### `_.mapValues(object, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11104 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapvalues "See the npm package") Creates an object with the same keys as `object` and values generated by running each own enumerable property of `object` through `iteratee`. The -iteratee function is bound to `thisArg` and invoked with three arguments:
-(value, key, object). -
-
-If a property name is provided for `iteratee` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `iteratee` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. +iteratee function is invoked with three arguments: (value, key, object). #### Arguments 1. `object` *(Object)*: The object to iterate over. 2. `[iteratee=_.identity]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Object)*: Returns the new mapped object. #### Example ```js -_.mapValues({ 'a': 1, 'b': 2 }, function(n) { - return n * 3; -}); -// => { 'a': 3, 'b': 6 } - var users = { 'fred': { 'user': 'fred', 'age': 40 }, 'pebbles': { 'user': 'pebbles', 'age': 1 } }; -// using the `_.property` callback shorthand +_.mapValues(users, function(o) { return o.age; }); +// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + +// using the `_.property` iteratee shorthand _.mapValues(users, 'age'); // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) ``` @@ -6222,22 +6603,22 @@ _.mapValues(users, 'age'); -### `_.merge(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L9338 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") +### `_.merge(object, [sources])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11143 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") -Recursively merges own enumerable properties of the source object(s), that -don't resolve to `undefined` into the destination object. Subsequent sources -overwrite property assignments of previous sources. If `customizer` is -provided it's invoked to produce the merged values of the destination and -source properties. If `customizer` returns `undefined` merging is handled -by the method instead. The `customizer` is bound to `thisArg` and invoked -with five arguments: (objectValue, sourceValue, key, object, source). +Recursively merges own and inherited enumerable properties of source +objects into the destination object, skipping source properties that resolve +to `undefined`. 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`. #### Arguments 1. `object` *(Object)*: The destination object. 2. `[sources]` *(...Object)*: The source objects. -3. `[customizer]` *(Function)*: The function to customize assigned values. -4. `[thisArg]` *(*)*: The `this` binding of `customizer`. #### Returns *(Object)*: Returns `object`. @@ -6254,8 +6635,38 @@ var ages = { _.merge(users, ages); // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } +``` +* * * + + + + + +### `_.mergeWith(object, sources, customizer)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11182 "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). + +#### 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`. + +#### Example +```js +function customizer(objValue, srcValue) { + if (_.isArray(objValue)) { + return objValue.concat(srcValue); + } +} -// using a customizer callback var object = { 'fruits': ['apple'], 'vegetables': ['beet'] @@ -6266,11 +6677,7 @@ var other = { 'vegetables': ['carrot'] }; -_.merge(object, other, function(a, b) { - if (_.isArray(a)) { - return a.concat(b); - } -}); +_.mergeWith(object, other, customizer); // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } ``` * * * @@ -6279,29 +6686,25 @@ _.merge(object, other, function(a, b) { -### `_.omit(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10013 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omit "See the npm package") +### `_.omit(object, [props])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11204 "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. #### Arguments 1. `object` *(Object)*: The source object. -2. `[predicate]` *(Function|...(string|string[])*: The function invoked per iteration or property names to omit, specified as individual property names or arrays of property names. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. +2. `[props]` *(...(string|string[])*: The property names to omit, specified individually or in arrays.. #### Returns *(Object)*: Returns the new object. #### Example ```js -var object = { 'user': 'fred', 'age': 40 }; +var object = { 'a': 1, 'b': '2', 'c': 3 }; -_.omit(object, 'age'); -// => { 'user': 'fred' } - -_.omit(object, _.isNumber); -// => { 'user': 'fred' } +_.omit(object, ['a', 'c']); +// => { 'b': '2' } ``` * * * @@ -6309,55 +6712,77 @@ _.omit(object, _.isNumber); -### `_.pairs(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10041 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pairs "See the npm package") +### `_.omitBy(object, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11230 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omitby "See the npm package") -Creates a two dimensional array of the key-value pairs for `object`, -e.g. `[[key1, value1], [key2, value2]]`. - -#### Arguments -1. `object` *(Object)*: The object to query. - -#### Returns -*(Array)*: Returns the new array of key-value pairs. - -#### Example -```js -_.pairs({ 'barney': 36, 'fred': 40 }); -// => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) -``` -* * * - - - - - -### `_.pick(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10082 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") - -Creates an object composed of the picked `object` properties. Property -names may be specified as individual arguments or as arrays of property -names. If `predicate` is provided it's invoked for each property of `object` -picking the properties `predicate` returns truthy for. The predicate is -bound to `thisArg` and invoked with three arguments: (value, key, object). +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. #### Arguments 1. `object` *(Object)*: The source object. -2. `[predicate]` *(Function|...(string|string[])*: The function invoked per iteration or property names to pick, specified as individual property names or arrays of property names. -3. `[thisArg]` *(*)*: The `this` binding of `predicate`. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per property. #### Returns *(Object)*: Returns the new object. #### Example ```js -var object = { 'user': 'fred', 'age': 40 }; +var object = { 'a': 1, 'b': '2', 'c': 3 }; -_.pick(object, 'user'); -// => { 'user': 'fred' } +_.omitBy(object, _.isNumber); +// => { 'b': '2' } +``` +* * * -_.pick(object, _.isString); -// => { 'user': 'fred' } + + + + +### `_.pick(object, [props])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11254 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") + +Creates an object composed of the picked `object` properties. + +#### Arguments +1. `object` *(Object)*: The source object. +2. `[props]` *(...(string|string[])*: The property names to pick, specified individually or in arrays. + +#### Returns +*(Object)*: Returns the new object. + +#### Example +```js +var object = { 'a': 1, 'b': '2', 'c': 3 }; + +_.pick(object, ['a', 'c']); +// => { 'a': 1, 'c': 3 } +``` +* * * + + + + + +### `_.pickBy(object, [predicate=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11275 "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 one argument: (value). + +#### Arguments +1. `object` *(Object)*: The source object. +2. `[predicate=_.identity]` *(Function|Object|string)*: The function invoked per property. + +#### Returns +*(Object)*: Returns the new object. + +#### Example +```js +var object = { 'a': 1, 'b': '2', 'c': 3 }; + +_.pickBy(object, _.isNumber); +// => { 'a': 1, 'c': 3 } ``` * * * @@ -6366,7 +6791,7 @@ _.pick(object, _.isString); ### `_.result(object, path, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10119 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.result "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11307 "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 @@ -6390,10 +6815,10 @@ _.result(object, 'a[0].b.c1'); _.result(object, 'a[0].b.c2'); // => 4 -_.result(object, 'a.b.c', 'default'); +_.result(object, 'a[0].b.c3', 'default'); // => 'default' -_.result(object, 'a.b.c', _.constant('default')); +_.result(object, 'a[0].b.c3', _.constant('default')); // => 'default' ``` * * * @@ -6403,13 +6828,15 @@ _.result(object, 'a.b.c', _.constant('default')); ### `_.set(object, path, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10155 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.set "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11346 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.set "See the npm package") -Sets the property value of `path` on `object`. If a portion of `path` -does not exist it's created. +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 +are created for all other missing properties. Use `_.setWith` to customize +`path` creation. #### Arguments -1. `object` *(Object)*: The object to augment. +1. `object` *(Object)*: The object to modify. 2. `path` *(Array|string)*: The path of the property to set. 3. `value` *(*)*: The value to set. @@ -6434,21 +6861,106 @@ console.log(object.x[0].y.z); -### `_.transform(object, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10210 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.transform "See the npm package") +### `_.setWith(object, path, value, [customizer])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11369 "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). + +#### 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. +4. `[customizer]` *(Function)*: The function to customize assigned values. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +_.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, Object); +// => { '0': { '1': { '2': 3 }, 'length': 2 } } +``` +* * * + + + + + +### `_.toPairs(object)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11394 "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`. + +#### Arguments +1. `object` *(Object)*: The object to query. + +#### Returns +*(Array)*: Returns the new array of key-value pairs. + +#### Example +```js +function Foo() { + this.a = 1; + this.b = 2; +} + +Foo.prototype.c = 3; + +_.toPairs(new Foo); +// => [['a', 1], ['b', 2]] (iteration order is not guaranteed) +``` +* * * + + + + + +### `_.toPairsIn(object)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11418 "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`. + +#### Arguments +1. `object` *(Object)*: The object to query. + +#### Returns +*(Array)*: Returns the new array of key-value pairs. + +#### Example +```js +function Foo() { + this.a = 1; + this.b = 2; +} + +Foo.prototype.c = 3; + +_.toPairsIn(new Foo); +// => [['a', 1], ['b', 2], ['c', 1]] (iteration order is not guaranteed) +``` +* * * + + + + + +### `_.transform(object, [iteratee=_.identity], [accumulator])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11450 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.transform "See the npm package") An alternative to `_.reduce`; this method transforms `object` to a new `accumulator` object which is the result of running each of its own enumerable properties through `iteratee`, with each invocation potentially mutating -the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked -with four arguments: (accumulator, value, key, object). Iteratee functions -may exit iteration early by explicitly returning `false`. +the `accumulator` object. The iteratee is invoked with four arguments:
+(accumulator, value, key, object). Iteratee functions may exit iteration +early by explicitly returning `false`. #### 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. -4. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(*)*: Returns the accumulated value. @@ -6461,10 +6973,43 @@ _.transform([2, 3, 4], function(result, n) { }); // => [4, 9] -_.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { - result[key] = n * 3; +_.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + (result[value] || (result[value] = [])).push(key); }); -// => { 'a': 3, 'b': 6 } +// => { '1': ['a', 'c'], '2': ['b'] } +``` +* * * + + + + + +### `_.unset(object, path)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11496 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unset "See the npm package") + +Removes the property at `path` of `object`. + +#### 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`. + +#### Example +```js +var object = { 'a': [{ 'b': { 'c': 7 } }] }; +_.unset(object, 'a[0].b.c'); +// => true + +console.log(object); +// => { 'a': [{ 'b': {} }] }; + +_.unset(object, 'a[0].b.c'); +// => true + +console.log(object); +// => { 'a': [{ 'b': {} }] }; ``` * * * @@ -6473,7 +7018,7 @@ _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10257 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.values "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11525 "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`.
@@ -6508,10 +7053,9 @@ _.values('hi'); ### `_.valuesIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10284 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.valuesin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11551 "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 property values of `object`.

**Note:** Non-object values are coerced to objects. @@ -6542,12 +7086,494 @@ _.valuesIn(new Foo); +## `“Seq” Methods` + + + +### `_(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1439 "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`. +
+
+Explicit chaining, which must be unwrapped with `_#value` in all cases, +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. +
+
+Chaining is supported in custom builds as long as the `_#value` method is +directly or indirectly included in the build. +
+
+In addition to lodash methods, wrappers have `Array` and `String` methods. +
+
+The wrapper `Array` methods are:
+`concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` +
+
+The wrapper `String` methods are:
+`replace` and `split` +
+
+The wrapper methods that support shortcut fusion are:
+`at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, +`findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, +`tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` +
+
+The chainable wrapper methods are:
+`after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, +`at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`, +`compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, +`debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, +`differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, +`dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`, +`flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, +`forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, +`intersection`, `intersectionBy`, `intersectionWith`, invert`, `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`, `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`, `values`, `valuesIn`, `without`, +`wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, and `zipWith` +
+
+The wrapper methods that are **not** chainable by default are:
+`add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, +`cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`, +`escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, +`findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`, +`has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, +`invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, +`isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, +`isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, +`isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, +`isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, +`isString`, `isUndefined`, `isTypedArray`, `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`, +`toLower`, `toInteger`, `toLength`, `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. + +#### Example +```js +function square(n) { + return n * n; +} + +var wrapped = _([1, 2, 3]); + +// returns an unwrapped value +wrapped.reduce(_.add); +// => 6 + +// returns a wrapped value +var squares = wrapped.map(square); + +_.isArray(squares); +// => false + +_.isArray(squares.value()); +// => true +``` +* * * + + + + + +### `_.chain(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6956 "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`. + +#### Arguments +1. `value` *(*)*: The value to wrap. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +var users = [ + { 'user': 'barney', 'age': 36 }, + { 'user': 'fred', 'age': 40 }, + { 'user': 'pebbles', 'age': 1 } +]; + +var youngest = _ + .chain(users) + .sortBy('age') + .map(function(o) { + return o.user + ' is ' + o.age; + }) + .head() + .value(); +// => 'pebbles is 1' +``` +* * * + + + + + +### `_.tap(value, interceptor)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L6984 "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 perform operations on intermediate results within +the chain. + +#### Arguments +1. `value` *(*)*: The value to provide to `interceptor`. +2. `interceptor` *(Function)*: The function to invoke. + +#### Returns +*(*)*: Returns `value`. + +#### Example +```js +_([1, 2, 3]) + .tap(function(array) { + array.pop(); + }) + .reverse() + .value(); +// => [2, 1] +``` +* * * + + + + + +### `_.thru(value, interceptor)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7009 "View in source") [Ⓣ][1] + +This method is like `_.tap` except that it returns the result of `interceptor`. + +#### Arguments +1. `value` *(*)*: The value to provide to `interceptor`. +2. `interceptor` *(Function)*: The function to invoke. + +#### Returns +*(*)*: Returns the result of `interceptor`. + +#### Example +```js +_(' abc ') + .chain() + .trim() + .thru(function(value) { + return [value]; + }) + .value(); +// => ['abc'] +``` +* * * + + + + + +### `_.wrapperFlatMap([iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7128 "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[Symbol.iterator]()` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7180 "View in source") [Ⓣ][1] + +Enables the wrapper to be iterable. + +#### Returns +*(Object)*: Returns the wrapper object. + +#### Example +```js +var wrapped = _([1, 2]); + +wrapped[Symbol.iterator]() === wrapped; +// => true + +Array.from(wrapped); +// => [1, 2] +``` +* * * + + + + + +### `_.prototype.at([paths])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7032 "View in source") [Ⓣ][1] + +This method is the wrapper version of `_.at`. + +#### Arguments +1. `[paths]` *(...(string|string[])*: The property paths of elements to pick, specified individually or in arrays. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + +_(object).at(['a[0].b.c', 'a[1]']).value(); +// => [3, 4] + +_(['a', 'b', 'c']).at(0, 2).value(); +// => ['a', 'c'] +``` +* * * + + + + + +### `_.prototype.chain()` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7078 "View in source") [Ⓣ][1] + +Enables explicit method chaining on the wrapper object. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +var users = [ + { 'user': 'barney', 'age': 36 }, + { 'user': 'fred', 'age': 40 } +]; + +// without explicit chaining +_(users).head(); +// => { 'user': 'barney', 'age': 36 } + +// with explicit chaining +_(users) + .chain() + .head() + .pick('user') + .value(); +// => { 'user': 'barney' } +``` +* * * + + + + + +### `_.prototype.commit()` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7107 "View in source") [Ⓣ][1] + +Executes the chained sequence and returns the wrapped result. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +var array = [1, 2]; +var wrapped = _(array).push(3); + +console.log(array); +// => [1, 2] + +wrapped = wrapped.commit(); +console.log(array); +// => [1, 2, 3] + +wrapped.last(); +// => 3 + +console.log(array); +// => [1, 2, 3] +``` +* * * + + + + + +### `_.prototype.next()` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7153 "View in source") [Ⓣ][1] + +Gets the next value on a wrapped object following the +[iterator protocol](https://mdn.io/iteration_protocols#iterator). + +#### Returns +*(Object)*: Returns the next iterator value. + +#### Example +```js +var wrapped = _([1, 2]); + +wrapped.next(); +// => { 'done': false, 'value': 1 } + +wrapped.next(); +// => { 'done': false, 'value': 2 } + +wrapped.next(); +// => { 'done': true, 'value': undefined } +``` +* * * + + + + + +### `_.prototype.plant(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7207 "View in source") [Ⓣ][1] + +Creates a clone of the chained sequence planting `value` as the wrapped value. + +#### Arguments +1. `value` *(*)*: The value to plant. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +function square(n) { + return n * n; +} + +var wrapped = _([1, 2]).map(square); +var other = wrapped.plant([3, 4]); + +other.value(); +// => [9, 16] + +wrapped.value(); +// => [1, 4] +``` +* * * + + + + + +### `_.prototype.reverse()` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7246 "View in source") [Ⓣ][1] + +This method is the wrapper version of `_.reverse`. +
+
+**Note:** This method mutates the wrapped array. + +#### Returns +*(Object)*: Returns the new `lodash` wrapper instance. + +#### Example +```js +var array = [1, 2, 3]; + +_(array).reverse().value() +// => [3, 2, 1] + +console.log(array); +// => [3, 2, 1] +``` +* * * + + + + + +### `_.prototype.value()` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L7273 "View in source") [Ⓣ][1] + +Executes the chained sequence to extract the unwrapped value. + +#### Aliases +*_.prototype.run, _.prototype.toJSON, _.prototype.valueOf* + +#### Returns +*(*)*: Returns the resolved unwrapped value. + +#### Example +```js +_([1, 2, 3]).value(); +// => [1, 2, 3] +``` +* * * + + + + + + + ## `“String” Methods` ### `_.camelCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10415 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.camelcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11729 "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). @@ -6575,9 +7601,10 @@ _.camelCase('__foo_bar__'); ### `_.capitalize([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10433 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11748 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") -Capitalizes the first character of `string`. +Converts the first character of `string` to upper case and the remaining +to lower case. #### Arguments 1. `[string='']` *(string)*: The string to capitalize. @@ -6587,7 +7614,7 @@ Capitalizes the first character of `string`. #### Example ```js -_.capitalize('fred'); +_.capitalize('FRED'); // => 'Fred' ``` * * * @@ -6597,7 +7624,7 @@ _.capitalize('fred'); ### `_.deburr([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10452 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.deburr "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11766 "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). @@ -6620,7 +7647,7 @@ _.deburr('déjà vu'); ### `_.endsWith([string=''], [target], [position=string.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10478 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11792 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") Checks if `string` ends with the given target string. @@ -6650,14 +7677,14 @@ _.endsWith('abc', 'b', 2); ### `_.escape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10523 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11837 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") -Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to +Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to their corresponding HTML entities.

-**Note:** No other characters are escaped. To escape additional characters -use a third-party library like [_he_](https://mths.be/he). +**Note:** No other characters are escaped. To escape additional +characters use a third-party library like [_he_](https://mths.be/he).

Though the ">" character is escaped for symmetry, characters like @@ -6667,8 +7694,8 @@ See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersan (under "semi-related fun fact") for more details.

-Backticks are escaped because in Internet Explorer < 9, they can break out -of attribute values or HTML comments. See [#59](https://html5sec.org/#59), +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. @@ -6695,10 +7722,10 @@ _.escape('fred, barney, & pebbles'); ### `_.escapeRegExp([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10545 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11858 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") -Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?", -"*", "+", "(", ")", "[", "]", "{" and "}" in `string`. +Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", +"?", "(", ")", "[", "]", "{", "}", and "|" in `string`. #### Arguments 1. `[string='']` *(string)*: The string to escape. @@ -6709,7 +7736,7 @@ Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?", #### Example ```js _.escapeRegExp('[lodash](https://lodash.com/)'); -// => '\[lodash\]\(https:\/\/lodash\.com\/\)' +// => '\[lodash\]\(https://lodash\.com/\)' ``` * * * @@ -6718,7 +7745,7 @@ _.escapeRegExp('[lodash](https://lodash.com/)'); ### `_.kebabCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10571 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11884 "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). @@ -6745,8 +7772,61 @@ _.kebabCase('__foo_bar__'); +### `_.lowerCase([string=''])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11907 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lowercase "See the npm package") + +Converts `string`, as space separated words, to lower case. + +#### Arguments +1. `[string='']` *(string)*: The string to convert. + +#### Returns +*(string)*: Returns the lower cased string. + +#### Example +```js +_.lowerCase('--Foo-Bar'); +// => 'foo bar' + +_.lowerCase('fooBar'); +// => 'foo bar' + +_.lowerCase('__FOO_BAR__'); +// => 'foo bar' +``` +* * * + + + + + +### `_.lowerFirst([string=''])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11927 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lowerfirst "See the npm package") + +Converts the first character of `string` to lower case. + +#### Arguments +1. `[string='']` *(string)*: The string to convert. + +#### Returns +*(string)*: Returns the converted string. + +#### Example +```js +_.lowerFirst('Fred'); +// => 'fred' + +_.lowerFirst('FRED'); +// => 'fRED' +``` +* * * + + + + + ### `_.pad([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10597 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pad "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11969 "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`. @@ -6776,39 +7856,8 @@ _.pad('abc', 3); -### `_.padLeft([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10635 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padleft "See the npm package") - -Pads `string` on the left side if it's shorter than `length`. Padding -characters are truncated if they exceed `length`. - -#### 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. - -#### Example -```js -_.padLeft('abc', 6); -// => ' abc' - -_.padLeft('abc', 6, '_-'); -// => '_-_abc' - -_.padLeft('abc', 3); -// => 'abc' -``` -* * * - - - - - -### `_.padRight([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10659 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padright "See the npm package") +### `_.padEnd([string=''], [length=0], [chars=' '])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12006 "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`. @@ -6823,13 +7872,44 @@ characters are truncated if they exceed `length`. #### Example ```js -_.padRight('abc', 6); +_.padEnd('abc', 6); // => 'abc ' -_.padRight('abc', 6, '_-'); +_.padEnd('abc', 6, '_-'); // => 'abc_-_' -_.padRight('abc', 3); +_.padEnd('abc', 3); +// => 'abc' +``` +* * * + + + + + +### `_.padStart([string=''], [length=0], [chars=' '])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12033 "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`. + +#### 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. + +#### Example +```js +_.padStart('abc', 6); +// => ' abc' + +_.padStart('abc', 6, '_-'); +// => '_-_abc' + +_.padStart('abc', 3); // => 'abc' ``` * * * @@ -6839,7 +7919,7 @@ _.padRight('abc', 3); ### `_.parseInt(string, [radix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10684 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.parseint "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12061 "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, @@ -6871,7 +7951,7 @@ _.map(['6', '08', '10'], _.parseInt); ### `_.repeat([string=''], [n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10717 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12093 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") Repeats the given string `n` times. @@ -6899,8 +7979,35 @@ _.repeat('abc', 0); +### `_.replace([string=''], pattern, replacement)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12131 "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). + +#### 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. + +#### Example +```js +_.replace('Hi Fred', 'Fred', 'Barney'); +// => 'Hi Barney' +``` +* * * + + + + + ### `_.snakeCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10756 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.snakecase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12157 "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). @@ -6927,8 +8034,35 @@ _.snakeCase('--foo-bar'); +### `_.split([string=''], separator, [limit])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12178 "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). + +#### 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. + +#### Example +```js +_.split('a-b-c', '-', 2); +// => ['a', 'b'] +``` +* * * + + + + + ### `_.startCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10779 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12201 "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). @@ -6956,7 +8090,7 @@ _.startCase('__foo_bar__'); ### `_.startsWith([string=''], [target], [position=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10804 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12226 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") Checks if `string` starts with the given target string. @@ -6986,7 +8120,7 @@ _.startsWith('abc', 'b', 1); ### `_.template([string=''], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L10909 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.template "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12328 "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 @@ -7092,8 +8226,64 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ +### `_.toLower([string=''])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12453 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.tolower "See the npm package") + +Converts `string`, as a whole, to lower case. + +#### Arguments +1. `[string='']` *(string)*: The string to convert. + +#### Returns +*(string)*: Returns the lower cased string. + +#### Example +```js +_.toLower('--Foo-Bar'); +// => '--foo-bar' + +_.toLower('fooBar'); +// => 'foobar' + +_.toLower('__FOO_BAR__'); +// => '__foo_bar__' +``` +* * * + + + + + +### `_.toUpper([string=''])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12476 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toupper "See the npm package") + +Converts `string`, as a whole, to upper case. + +#### Arguments +1. `[string='']` *(string)*: The string to convert. + +#### Returns +*(string)*: Returns the upper cased string. + +#### Example +```js +_.toUpper('--foo-bar'); +// => '--FOO-BAR' + +_.toUpper('fooBar'); +// => 'FOOBAR' + +_.toUpper('__foo_bar__'); +// => '__FOO_BAR__' +``` +* * * + + + + + ### `_.trim([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11036 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trim "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12501 "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`. @@ -7121,34 +8311,8 @@ _.map([' foo ', ' bar '], _.trim); -### `_.trimLeft([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11067 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimleft "See the npm package") - -Removes leading whitespace or specified characters from `string`. - -#### Arguments -1. `[string='']` *(string)*: The string to trim. -2. `[chars=whitespace]` *(string)*: The characters to trim. - -#### Returns -*(string)*: Returns the trimmed string. - -#### Example -```js -_.trimLeft(' abc '); -// => 'abc ' - -_.trimLeft('-_-abc-_-', '_-'); -// => 'abc-_-' -``` -* * * - - - - - -### `_.trimRight([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11097 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimright "See the npm package") +### `_.trimEnd([string=''], [chars=whitespace])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12537 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimend "See the npm package") Removes trailing whitespace or specified characters from `string`. @@ -7161,10 +8325,10 @@ Removes trailing whitespace or specified characters from `string`. #### Example ```js -_.trimRight(' abc '); +_.trimEnd(' abc '); // => ' abc' -_.trimRight('-_-abc-_-', '_-'); +_.trimEnd('-_-abc-_-', '_-'); // => '-_-abc' ``` * * * @@ -7173,8 +8337,34 @@ _.trimRight('-_-abc-_-', '_-'); -### `_.trunc([string=''], [options], [options.length=30], [options.omission='...'], [options.separator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11149 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trunc "See the npm package") +### `_.trimStart([string=''], [chars=whitespace])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12571 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimstart "See the npm package") + +Removes leading whitespace or specified characters from `string`. + +#### Arguments +1. `[string='']` *(string)*: The string to trim. +2. `[chars=whitespace]` *(string)*: The characters to trim. + +#### Returns +*(string)*: Returns the trimmed string. + +#### Example +```js +_.trimStart(' abc '); +// => 'abc ' + +_.trimStart('-_-abc-_-', '_-'); +// => 'abc-_-' +``` +* * * + + + + + +### `_.truncate([string=''], [options])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12623 "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 @@ -7182,7 +8372,7 @@ string which defaults to "...". #### Arguments 1. `[string='']` *(string)*: The string to truncate. -2. `[options]` *(Object|number)*: The options object or maximum string length. +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. @@ -7192,25 +8382,22 @@ string which defaults to "...". #### Example ```js -_.trunc('hi-diddly-ho there, neighborino'); +_.truncate('hi-diddly-ho there, neighborino'); // => 'hi-diddly-ho there, neighbo...' -_.trunc('hi-diddly-ho there, neighborino', 24); -// => 'hi-diddly-ho there, n...' - -_.trunc('hi-diddly-ho there, neighborino', { +_.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); // => 'hi-diddly-ho there,...' -_.trunc('hi-diddly-ho there, neighborino', { +_.truncate('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); // => 'hi-diddly-ho there...' -_.trunc('hi-diddly-ho there, neighborino', { +_.truncate('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); // => 'hi-diddly-ho there, neig [...]' @@ -7222,7 +8409,7 @@ _.trunc('hi-diddly-ho there, neighborino', { ### `_.unescape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11219 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unescape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12697 "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 @@ -7249,8 +8436,61 @@ _.unescape('fred, barney, & pebbles'); +### `_.upperCase([string=''])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12723 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uppercase "See the npm package") + +Converts `string`, as space separated words, to upper case. + +#### Arguments +1. `[string='']` *(string)*: The string to convert. + +#### Returns +*(string)*: Returns the upper cased string. + +#### Example +```js +_.upperCase('--foo-bar'); +// => 'FOO BAR' + +_.upperCase('fooBar'); +// => 'FOO BAR' + +_.upperCase('__foo_bar__'); +// => 'FOO BAR' +``` +* * * + + + + + +### `_.upperFirst([string=''])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L11945 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.upperfirst "See the npm package") + +Converts the first character of `string` to upper case. + +#### Arguments +1. `[string='']` *(string)*: The string to convert. + +#### Returns +*(string)*: Returns the converted string. + +#### Example +```js +_.upperFirst('fred'); +// => 'Fred' + +_.upperFirst('FRED'); +// => 'FRED' +``` +* * * + + + + + ### `_.words([string=''], [pattern])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11244 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12745 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") Splits `string` into an array of its words. @@ -7277,12 +8517,12 @@ _.words('fred, barney, & pebbles', /[^, ]+/g); -## `“Utility” Methods` +## `“Util” Methods` ### `_.attempt(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11274 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.attempt "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12777 "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. @@ -7310,24 +8550,90 @@ if (_.isError(elements)) { -### `_.callback([func=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11320 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.callback "See the npm package") +### `_.bindAll(object, methodNames)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12811 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindall "See the npm package") -Creates a function that invokes `func` with the `this` binding of `thisArg` -and arguments of the created function. If `func` is a property name the -created callback returns the property value for a given element. If `func` -is an object the created callback returns `true` for elements that contain -the equivalent object properties, otherwise it returns `false`. - -#### Aliases -*_.iteratee* +Binds methods of an object to the object itself, overwriting the existing +method. +
+
+**Note:** This method doesn't set the "length" property of bound functions. #### Arguments -1. `[func=_.identity]` *(*)*: The value to convert to a callback. -2. `[thisArg]` *(*)*: The `this` binding of `func`. +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. #### Returns -*(Function)*: Returns the callback. +*(Object)*: Returns `object`. + +#### Example +```js +var view = { + 'label': 'docs', + 'onClick': function() { + console.log('clicked ' + this.label); + } +}; + +_.bindAll(view, 'onClick'); +jQuery(element).on('click', view.onClick); +// => logs 'clicked docs' when clicked +``` +* * * + + + + + +### `_.cond(pairs)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12846 "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. + +#### Arguments +1. `pairs` *(Array)*: The predicate-function pairs. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var func = _.cond([ + [_.matches({ 'a': 1 }), _.constant('matches A')], + [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], + [_.constant(true), _.constant('no match')] +]) + +func({ 'a': 1, 'b': 2 }); +// => 'matches A' + +func({ 'a': 0, 'b': 1 }); +// => 'matches B' + +func({ 'a': '1', 'b': '2' }); +// => 'no match' +``` +* * * + + + + + +### `_.conforms(source)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12888 "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`. + +#### Arguments +1. `source` *(Object)*: The object of property predicates to conform to. + +#### Returns +*(Function)*: Returns the new function. #### Example ```js @@ -7336,20 +8642,7 @@ var users = [ { 'user': 'fred', 'age': 40 } ]; -// wrap to create custom callback shorthands -_.callback = _.wrap(_.callback, function(callback, func, thisArg) { - var match = /^(.+?)__([gl]t)(.+)$/.exec(func); - if (!match) { - return callback(func, thisArg); - } - return function(object) { - return match[2] == 'gt' - ? object[match[1]] > match[3] - : object[match[1]] < match[3]; - }; -}); - -_.filter(users, 'age__gt36'); +_.filter(users, _.conforms({ 'age': _.partial(_.gt, _, 38) })); // => [{ 'user': 'fred', 'age': 40 }] ``` * * * @@ -7359,7 +8652,7 @@ _.filter(users, 'age__gt36'); ### `_.constant(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11345 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12908 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") Creates a function that returns `value`. @@ -7383,8 +8676,65 @@ getter() === object; +### `_.flow([funcs])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12934 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flow "See the npm package") + +Creates a function that returns the result of invoking the provided +functions with the `this` binding of the created function, where each +successive invocation is supplied the return value of the previous. + +#### Arguments +1. `[funcs]` *(...(Function|Function[])*: Functions to invoke. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +function square(n) { + return n * n; +} + +var addSquare = _.flow(_.add, square); +addSquare(1, 2); +// => 9 +``` +* * * + + + + + +### `_.flowRight([funcs])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12955 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flowright "See the npm package") + +This method is like `_.flow` except that it creates a function that +invokes the provided functions from right to left. + +#### Arguments +1. `[funcs]` *(...(Function|Function[])*: Functions to invoke. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +function square(n) { + return n * n; +} + +var addSquare = _.flowRight(square, _.add); +addSquare(1, 2); +// => 9 +``` +* * * + + + + + ### `_.identity(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11366 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L12972 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") This method returns the first argument provided to it. @@ -7407,18 +8757,53 @@ _.identity(object) === object; -### `_.matches(source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11395 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") +### `_.iteratee([func=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13005 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iteratee "See the npm package") -Creates a function that performs a deep comparison between a given object -and `source`, returning `true` if the given object has equivalent property -values, else `false`. +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`. + +#### Arguments +1. `[func=_.identity]` *(*)*: The value to convert to a callback. + +#### Returns +*(Function)*: Returns the callback. + +#### Example +```js +var users = [ + { 'user': 'barney', 'age': 36 }, + { 'user': 'fred', 'age': 40 } +]; + +// 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]); + }; +}); + +_.filter(users, 'age > 36'); +// => [{ 'user': 'fred', 'age': 40 }] +``` +* * * + + + + + +### `_.matches(source)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13033 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") + +Creates a function that performs a deep partial comparison between a given +object and `source`, returning `true` if the given object has equivalent +property values, else `false`.

-**Note:** This method supports comparing arrays, booleans, `Date` objects, -numbers, `Object` objects, regexes, and strings. Objects are compared by -their own, not inherited, enumerable properties. For comparing a single -own or inherited property value see `_.matchesProperty`. +**Note:** This method supports comparing the same values as `_.isEqual`. #### Arguments 1. `source` *(Object)*: The object of property values to match. @@ -7443,15 +8828,14 @@ _.filter(users, _.matches({ 'age': 40, 'active': false })); ### `_.matchesProperty(path, srcValue)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11423 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13060 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") -Creates a function that compares the property value of `path` on a given -object to `value`. +Creates a function that performs a deep partial comparison between the +value at `path` of a given object to `srcValue`, returning `true` if the +object value is equivalent, else `false`.

-**Note:** This method supports comparing arrays, booleans, `Date` objects, -numbers, `Object` objects, regexes, and strings. Objects are compared by -their own, not inherited, enumerable properties. +**Note:** This method supports comparing the same values as `_.isEqual`. #### Arguments 1. `path` *(Array|string)*: The path of the property to get. @@ -7477,9 +8861,9 @@ _.find(users, _.matchesProperty('user', 'fred')); ### `_.method(path, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11450 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.method "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13087 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.method "See the npm package") -Creates a function that invokes the method at `path` on a given object. +Creates a function that invokes the method at `path` of a given object. Any additional arguments are provided to the invoked method. #### Arguments @@ -7499,7 +8883,7 @@ var objects = [ _.map(objects, _.method('a.b.c')); // => [2, 1] -_.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); +_.invokeMap(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); // => [1, 2] ``` * * * @@ -7509,10 +8893,10 @@ _.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); ### `_.methodOf(object, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11478 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.methodof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13115 "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 on `object`. Any additional arguments are +the method at a given path of `object`. Any additional arguments are provided to the invoked method. #### Arguments @@ -7540,7 +8924,7 @@ _.map([['a', '2'], ['c', '0']], _.methodOf(object)); ### `_.mixin([object=lodash], source, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11520 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mixin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13157 "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 @@ -7585,7 +8969,7 @@ _('fred').vowels(); ### `_.noConflict()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11583 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noconflict "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13205 "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. @@ -7604,7 +8988,7 @@ var lodash = _.noConflict(); ### `_.noop()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11602 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13224 "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. @@ -7622,11 +9006,121 @@ _.noop(object) === undefined; -### `_.property(path)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11628 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.property "See the npm package") +### `_.nthArg([n=0])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13243 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ntharg "See the npm package") -Creates a function that returns the property value at `path` on a -given object. +Creates a function that returns its nth argument. + +#### Arguments +1. `[n=0]` *(number)*: The index of the argument to return. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var func = _.nthArg(1); + +func('a', 'b', 'c'); +// => 'b' +``` +* * * + + + + + +### `_.over(iteratees)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13266 "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. + +#### Arguments +1. `iteratees` *(...(Function|Function[])*: The iteratees to invoke. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var func = _.over(Math.max, Math.min); + +func(1, 2, 3, 4); +// => [4, 1] +``` +* * * + + + + + +### `_.overEvery(predicates)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13290 "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. + +#### Arguments +1. `predicates` *(...(Function|Function[])*: The predicates to check. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var func = _.overEvery(Boolean, isFinite); + +func('1'); +// => true + +func(null); +// => false + +func(NaN); +// => false +``` +* * * + + + + + +### `_.overSome(predicates)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13314 "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. + +#### Arguments +1. `predicates` *(...(Function|Function[])*: The predicates to check. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var func = _.overSome(Boolean, isFinite); + +func('1'); +// => true + +func(null); +// => true + +func(NaN); +// => false +``` +* * * + + + + + +### `_.property(path)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13337 "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. #### Arguments 1. `path` *(Array|string)*: The path of the property to get. @@ -7644,7 +9138,7 @@ var objects = [ _.map(objects, _.property('a.b.c')); // => [2, 1] -_.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); +_.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); // => [1, 2] ``` * * * @@ -7654,10 +9148,10 @@ _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); ### `_.propertyOf(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11652 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.propertyof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13361 "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 property value at a given path on `object`. +the value at a given path of `object`. #### Arguments 1. `object` *(Object)*: The object to query. @@ -7683,12 +9177,17 @@ _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11691 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.range "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13407 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.range "See the npm package") Creates an array of numbers (positive and/or negative) progressing from -`start` up to, but not including, `end`. If `end` is not specified it's -set to `start` with `start` then set to `0`. If `end` is less than `start` -a zero-length range is created unless a negative `step` is specified. +`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`. If `end` is less than +`start` a zero-length range is created unless a negative `step` is specified. +
+
+**Note:** JavaScript follows the IEEE-754 standard for resolving +floating-point values which can produce unexpected results. #### Arguments 1. `[start=0]` *(number)*: The start of the range. @@ -7703,6 +9202,9 @@ a zero-length range is created unless a negative `step` is specified. _.range(4); // => [0, 1, 2, 3] +_.range(-4); +// => [0, -1, -2, -3] + _.range(1, 5); // => [1, 2, 3, 4] @@ -7724,10 +9226,53 @@ _.range(0); -### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L723 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.runincontext "See the npm package") +### `_.rangeRight([start=0], end, [step=1])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13443 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rangeright "See the npm package") -Create a new pristine `lodash` function using the given `context` object. +This method is like `_.range` except that it populates values in +descending order. + +#### 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. + +#### Example +```js +_.rangeRight(4); +// => [3, 2, 1, 0] + +_.rangeRight(-4); +// => [-3, -2, -1, 0] + +_.rangeRight(1, 5); +// => [4, 3, 2, 1] + +_.rangeRight(0, 20, 5); +// => [15, 10, 5, 0] + +_.rangeRight(0, -4, -1); +// => [-3, -2, -1, 0] + +_.rangeRight(1, 4, 0); +// => [1, 1, 1] + +_.rangeRight(0); +// => [] +``` +* * * + + + + + +### `_.runInContext([context=root])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1240 "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. #### Arguments 1. `[context=root]` *(Object)*: The context object. @@ -7768,35 +9313,60 @@ var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; -### `_.times(n, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11744 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") +### `_.times(n, [iteratee=_.identity])` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13463 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") Invokes the iteratee function `n` times, returning an array of the results -of each invocation. The `iteratee` is bound to `thisArg` and invoked with -one argument; (index). +of each invocation. The iteratee is invoked with one argument; (index). #### Arguments 1. `n` *(number)*: The number of times to invoke `iteratee`. 2. `[iteratee=_.identity]` *(Function)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. #### Returns *(Array)*: Returns the array of results. #### Example ```js -var diceRolls = _.times(3, _.partial(_.random, 1, 6, false)); -// => [3, 6, 4] +_.times(3, String); +// => ['0', '1', '2'] -_.times(3, function(n) { - mage.castSpell(n); -}); -// => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` + _.times(4, _.constant(true)); +// => [true, true, true, true] +``` +* * * -_.times(3, function(n) { - this.cast(n); -}, mage); -// => also invokes `mage.castSpell(n)` three times + + + + +### `_.toPath(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13506 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.topath "See the npm package") + +Converts `value` to a property path array. + +#### Arguments +1. `value` *(*)*: The value to convert. + +#### Returns +*(Array)*: Returns the new property path array. + +#### Example +```js +_.toPath('a.b.c'); +// => ['a', 'b', 'c'] + +_.toPath('a[0].b.c'); +// => ['a', '0', 'b', 'c'] + +var path = ['a', 'b', 'c'], + newPath = _.toPath(path); + +console.log(newPath); +// => ['a', 'b', 'c'] + +console.log(path === newPath); +// => false ``` * * * @@ -7805,7 +9375,7 @@ _.times(3, function(n) { ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L11782 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L13526 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") Generates a unique ID. If `prefix` is provided the ID is appended to it. @@ -7836,7 +9406,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1122 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1532 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -7844,6 +9414,23 @@ A reference to the `lodash` function. + + +### `stringSize(string)` +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1170 "View in source") [Ⓣ][1] + +Gets the number of symbols in `string`. + +#### Arguments +1. `string` *(string)*: The string to inspect. + +#### Returns +*(number)*: Returns the string size. + +* * * + + + @@ -7853,7 +9440,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L12300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L14157 "View in source") [Ⓣ][1] (string): The semantic version number. @@ -7863,108 +9450,8 @@ A reference to the `lodash` function. -### `_.support` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L986 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.support "See the npm package") - -(Object): An object environment feature flags. - -* * * - - - - - -### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1003 "View in source") [Ⓣ][1] - -(boolean): Detect if `name` or `message` properties of `Error.prototype` are -enumerable by default (IE < 9, Safari < 5.1). - -* * * - - - - - -### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1017 "View in source") [Ⓣ][1] - -(boolean): Detect if `prototype` properties are enumerable by default. -
-
-Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 -(if the prototype or a property on the prototype has been set) -incorrectly set the `[[Enumerable]]` value of a function's `prototype` -property to `true`. - -* * * - - - - - -### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1028 "View in source") [Ⓣ][1] - -(boolean): Detect if properties shadowing those on `Object.prototype` are non-enumerable. -
-
-In IE < 9 an object's own properties, shadowing non-enumerable ones, -are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). - -* * * - - - - - -### `_.support.ownLast` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1036 "View in source") [Ⓣ][1] - -(boolean): Detect if own properties are iterated after inherited properties (IE < 9). - -* * * - - - - - -### `_.support.spliceObjects` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1051 "View in source") [Ⓣ][1] - -(boolean): Detect if `Array#shift` and `Array#splice` augment array-like objects -correctly. -
-
-Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array -`shift()` and `splice()` functions that fail to remove the last element, -`value[0]`, of array-like objects even though the "length" property is -set to `0`. The `shift()` method is buggy in compatibility modes of IE 8, -while `splice()` is buggy regardless of mode in IE < 9. - -* * * - - - - - -### `_.support.unindexedChars` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1062 "View in source") [Ⓣ][1] - -(boolean): Detect lack of support for accessing string characters by index. -
-
-IE < 8 can't access characters by index. IE 8 can only access characters -by index on string literals, not string objects. - -* * * - - - - - ### `_.templateSettings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1074 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.templatesettings "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1484 "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 @@ -7977,7 +9464,7 @@ alternative delimiters. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1082 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1492 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to be HTML-escaped. @@ -7988,7 +9475,7 @@ alternative delimiters. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1500 "View in source") [Ⓣ][1] (RegExp): Used to detect code to be evaluated. @@ -7999,7 +9486,7 @@ alternative delimiters. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1114 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1524 "View in source") [Ⓣ][1] (Object): Used to import variables into the compiled template. @@ -8010,7 +9497,7 @@ alternative delimiters. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1098 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1508 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to inject. @@ -8021,7 +9508,7 @@ alternative delimiters. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1106 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/4.0.0/lodash.js#L1516 "View in source") [Ⓣ][1] (string): Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index 039eda348..e20df3884 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,7 @@ /** * @license - * lodash 4.0.0-pre + * lodash 4.0.0 (Custom Build) + * Build: `lodash -d -o ./lodash.js` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -12,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.0.0-pre'; + var VERSION = '4.0.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1,