3 * Lodash (Custom Build) <https://lodash.com/>
4 * Build: `lodash core -o ./dist/lodash.core.js`
5 * Copyright JS Foundation and other contributors <https://js.foundation/>
6 * Released under MIT license <https://lodash.com/license>
7 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
8 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12 /** Used as a safe reference for `undefined` in pre-ES5 environments. */
15 /** Used as the semantic version number. */
16 var VERSION = '4.17.4';
18 /** Error message constants. */
19 var FUNC_ERROR_TEXT = 'Expected a function';
21 /** Used to compose bitmasks for value comparisons. */
22 var COMPARE_PARTIAL_FLAG = 1,
23 COMPARE_UNORDERED_FLAG = 2;
25 /** Used to compose bitmasks for function metadata. */
26 var WRAP_BIND_FLAG = 1,
27 WRAP_PARTIAL_FLAG = 32;
29 /** Used as references for various `Number` constants. */
31 MAX_SAFE_INTEGER = 9007199254740991;
33 /** `Object#toString` result references. */
34 var argsTag = '[object Arguments]',
35 arrayTag = '[object Array]',
36 asyncTag = '[object AsyncFunction]',
37 boolTag = '[object Boolean]',
38 dateTag = '[object Date]',
39 errorTag = '[object Error]',
40 funcTag = '[object Function]',
41 genTag = '[object GeneratorFunction]',
42 numberTag = '[object Number]',
43 objectTag = '[object Object]',
44 proxyTag = '[object Proxy]',
45 regexpTag = '[object RegExp]',
46 stringTag = '[object String]';
48 /** Used to match HTML entities and HTML characters. */
49 var reUnescapedHtml = /[&<>"']/g,
50 reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
52 /** Used to map characters to HTML entities. */
61 /** Detect free variable `global` from Node.js. */
62 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
64 /** Detect free variable `self`. */
65 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
67 /** Used as a reference to the global object. */
68 var root = freeGlobal || freeSelf || Function('return this')();
70 /** Detect free variable `exports`. */
71 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
73 /** Detect free variable `module`. */
74 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
76 /*--------------------------------------------------------------------------*/
79 * Appends the elements of `values` to `array`.
82 * @param {Array} array The array to modify.
83 * @param {Array} values The values to append.
84 * @returns {Array} Returns `array`.
86 function arrayPush(array, values) {
87 array.push.apply(array, values);
92 * The base implementation of `_.findIndex` and `_.findLastIndex` without
93 * support for iteratee shorthands.
96 * @param {Array} array The array to inspect.
97 * @param {Function} predicate The function invoked per iteration.
98 * @param {number} fromIndex The index to search from.
99 * @param {boolean} [fromRight] Specify iterating from right to left.
100 * @returns {number} Returns the index of the matched value, else `-1`.
102 function baseFindIndex(array, predicate, fromIndex, fromRight) {
103 var length = array.length,
104 index = fromIndex + (fromRight ? 1 : -1);
106 while ((fromRight ? index-- : ++index < length)) {
107 if (predicate(array[index], index, array)) {
115 * The base implementation of `_.property` without support for deep paths.
118 * @param {string} key The key of the property to get.
119 * @returns {Function} Returns the new accessor function.
121 function baseProperty(key) {
122 return function(object) {
123 return object == null ? undefined : object[key];
128 * The base implementation of `_.propertyOf` without support for deep paths.
131 * @param {Object} object The object to query.
132 * @returns {Function} Returns the new accessor function.
134 function basePropertyOf(object) {
135 return function(key) {
136 return object == null ? undefined : object[key];
141 * The base implementation of `_.reduce` and `_.reduceRight`, without support
142 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
145 * @param {Array|Object} collection The collection to iterate over.
146 * @param {Function} iteratee The function invoked per iteration.
147 * @param {*} accumulator The initial value.
148 * @param {boolean} initAccum Specify using the first or last element of
149 * `collection` as the initial value.
150 * @param {Function} eachFunc The function to iterate over `collection`.
151 * @returns {*} Returns the accumulated value.
153 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
154 eachFunc(collection, function(value, index, collection) {
155 accumulator = initAccum
156 ? (initAccum = false, value)
157 : iteratee(accumulator, value, index, collection);
163 * The base implementation of `_.values` and `_.valuesIn` which creates an
164 * array of `object` property values corresponding to the property names
168 * @param {Object} object The object to query.
169 * @param {Array} props The property names to get values for.
170 * @returns {Object} Returns the array of property values.
172 function baseValues(object, props) {
173 return baseMap(props, function(key) {
179 * Used by `_.escape` to convert characters to HTML entities.
182 * @param {string} chr The matched character to escape.
183 * @returns {string} Returns the escaped character.
185 var escapeHtmlChar = basePropertyOf(htmlEscapes);
188 * Creates a unary function that invokes `func` with its argument transformed.
191 * @param {Function} func The function to wrap.
192 * @param {Function} transform The argument transform.
193 * @returns {Function} Returns the new function.
195 function overArg(func, transform) {
196 return function(arg) {
197 return func(transform(arg));
201 /*--------------------------------------------------------------------------*/
203 /** Used for built-in method references. */
204 var arrayProto = Array.prototype,
205 objectProto = Object.prototype;
207 /** Used to check objects for own properties. */
208 var hasOwnProperty = objectProto.hasOwnProperty;
210 /** Used to generate unique IDs. */
214 * Used to resolve the
215 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
218 var nativeObjectToString = objectProto.toString;
220 /** Used to restore the original `_` reference in `_.noConflict`. */
221 var oldDash = root._;
223 /** Built-in value references. */
224 var objectCreate = Object.create,
225 propertyIsEnumerable = objectProto.propertyIsEnumerable;
227 /* Built-in method references for those with the same name as other `lodash` methods. */
228 var nativeIsFinite = root.isFinite,
229 nativeKeys = overArg(Object.keys, Object),
230 nativeMax = Math.max;
232 /*------------------------------------------------------------------------*/
235 * Creates a `lodash` object which wraps `value` to enable implicit method
236 * chain sequences. Methods that operate on and return arrays, collections,
237 * and functions can be chained together. Methods that retrieve a single value
238 * or may return a primitive value will automatically end the chain sequence
239 * and return the unwrapped value. Otherwise, the value must be unwrapped
242 * Explicit chain sequences, which must be unwrapped with `_#value`, may be
243 * enabled using `_.chain`.
245 * The execution of chained methods is lazy, that is, it's deferred until
246 * `_#value` is implicitly or explicitly called.
248 * Lazy evaluation allows several methods to support shortcut fusion.
249 * Shortcut fusion is an optimization to merge iteratee calls; this avoids
250 * the creation of intermediate arrays and can greatly reduce the number of
251 * iteratee executions. Sections of a chain sequence qualify for shortcut
252 * fusion if the section is applied to an array and iteratees accept only
253 * one argument. The heuristic for whether a section qualifies for shortcut
254 * fusion is subject to change.
256 * Chaining is supported in custom builds as long as the `_#value` method is
257 * directly or indirectly included in the build.
259 * In addition to lodash methods, wrappers have `Array` and `String` methods.
261 * The wrapper `Array` methods are:
262 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
264 * The wrapper `String` methods are:
265 * `replace` and `split`
267 * The wrapper methods that support shortcut fusion are:
268 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
269 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
270 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
272 * The chainable wrapper methods are:
273 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
274 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
275 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
276 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
277 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
278 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
279 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
280 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
281 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
282 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
283 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
284 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
285 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
286 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
287 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
288 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
289 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
290 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
291 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
292 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
293 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
294 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
295 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
296 * `zipObject`, `zipObjectDeep`, and `zipWith`
298 * The wrapper methods that are **not** chainable by default are:
299 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
300 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
301 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
302 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
303 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
304 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
305 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
306 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
307 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
308 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
309 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
310 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
311 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
312 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
313 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
314 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
315 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
316 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
317 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
318 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
319 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
320 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
321 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
322 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
323 * `upperFirst`, `value`, and `words`
328 * @param {*} value The value to wrap in a `lodash` instance.
329 * @returns {Object} Returns the new `lodash` wrapper instance.
332 * function square(n) {
336 * var wrapped = _([1, 2, 3]);
338 * // Returns an unwrapped value.
339 * wrapped.reduce(_.add);
342 * // Returns a wrapped value.
343 * var squares = wrapped.map(square);
345 * _.isArray(squares);
348 * _.isArray(squares.value());
351 function lodash(value) {
352 return value instanceof LodashWrapper
354 : new LodashWrapper(value);
358 * The base implementation of `_.create` without support for assigning
359 * properties to the created object.
362 * @param {Object} proto The object to inherit from.
363 * @returns {Object} Returns the new object.
365 var baseCreate = (function() {
367 return function(proto) {
368 if (!isObject(proto)) {
372 return objectCreate(proto);
374 object.prototype = proto;
375 var result = new object;
376 object.prototype = undefined;
382 * The base constructor for creating `lodash` wrapper objects.
385 * @param {*} value The value to wrap.
386 * @param {boolean} [chainAll] Enable explicit method chain sequences.
388 function LodashWrapper(value, chainAll) {
389 this.__wrapped__ = value;
390 this.__actions__ = [];
391 this.__chain__ = !!chainAll;
394 LodashWrapper.prototype = baseCreate(lodash.prototype);
395 LodashWrapper.prototype.constructor = LodashWrapper;
397 /*------------------------------------------------------------------------*/
400 * Assigns `value` to `key` of `object` if the existing value is not equivalent
401 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
402 * for equality comparisons.
405 * @param {Object} object The object to modify.
406 * @param {string} key The key of the property to assign.
407 * @param {*} value The value to assign.
409 function assignValue(object, key, value) {
410 var objValue = object[key];
411 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
412 (value === undefined && !(key in object))) {
413 baseAssignValue(object, key, value);
418 * The base implementation of `assignValue` and `assignMergeValue` without
422 * @param {Object} object The object to modify.
423 * @param {string} key The key of the property to assign.
424 * @param {*} value The value to assign.
426 function baseAssignValue(object, key, value) {
431 * The base implementation of `_.delay` and `_.defer` which accepts `args`
432 * to provide to `func`.
435 * @param {Function} func The function to delay.
436 * @param {number} wait The number of milliseconds to delay invocation.
437 * @param {Array} args The arguments to provide to `func`.
438 * @returns {number|Object} Returns the timer id or timeout object.
440 function baseDelay(func, wait, args) {
441 if (typeof func != 'function') {
442 throw new TypeError(FUNC_ERROR_TEXT);
444 return setTimeout(function() { func.apply(undefined, args); }, wait);
448 * The base implementation of `_.forEach` without support for iteratee shorthands.
451 * @param {Array|Object} collection The collection to iterate over.
452 * @param {Function} iteratee The function invoked per iteration.
453 * @returns {Array|Object} Returns `collection`.
455 var baseEach = createBaseEach(baseForOwn);
458 * The base implementation of `_.every` without support for iteratee shorthands.
461 * @param {Array|Object} collection The collection to iterate over.
462 * @param {Function} predicate The function invoked per iteration.
463 * @returns {boolean} Returns `true` if all elements pass the predicate check,
466 function baseEvery(collection, predicate) {
468 baseEach(collection, function(value, index, collection) {
469 result = !!predicate(value, index, collection);
476 * The base implementation of methods like `_.max` and `_.min` which accepts a
477 * `comparator` to determine the extremum value.
480 * @param {Array} array The array to iterate over.
481 * @param {Function} iteratee The iteratee invoked per iteration.
482 * @param {Function} comparator The comparator used to compare values.
483 * @returns {*} Returns the extremum value.
485 function baseExtremum(array, iteratee, comparator) {
487 length = array.length;
489 while (++index < length) {
490 var value = array[index],
491 current = iteratee(value);
493 if (current != null && (computed === undefined
494 ? (current === current && !false)
495 : comparator(current, computed)
497 var computed = current,
505 * The base implementation of `_.filter` without support for iteratee shorthands.
508 * @param {Array|Object} collection The collection to iterate over.
509 * @param {Function} predicate The function invoked per iteration.
510 * @returns {Array} Returns the new filtered array.
512 function baseFilter(collection, predicate) {
514 baseEach(collection, function(value, index, collection) {
515 if (predicate(value, index, collection)) {
523 * The base implementation of `_.flatten` with support for restricting flattening.
526 * @param {Array} array The array to flatten.
527 * @param {number} depth The maximum recursion depth.
528 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
529 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
530 * @param {Array} [result=[]] The initial result value.
531 * @returns {Array} Returns the new flattened array.
533 function baseFlatten(array, depth, predicate, isStrict, result) {
535 length = array.length;
537 predicate || (predicate = isFlattenable);
538 result || (result = []);
540 while (++index < length) {
541 var value = array[index];
542 if (depth > 0 && predicate(value)) {
544 // Recursively flatten arrays (susceptible to call stack limits).
545 baseFlatten(value, depth - 1, predicate, isStrict, result);
547 arrayPush(result, value);
549 } else if (!isStrict) {
550 result[result.length] = value;
557 * The base implementation of `baseForOwn` which iterates over `object`
558 * properties returned by `keysFunc` and invokes `iteratee` for each property.
559 * Iteratee functions may exit iteration early by explicitly returning `false`.
562 * @param {Object} object The object to iterate over.
563 * @param {Function} iteratee The function invoked per iteration.
564 * @param {Function} keysFunc The function to get the keys of `object`.
565 * @returns {Object} Returns `object`.
567 var baseFor = createBaseFor();
570 * The base implementation of `_.forOwn` without support for iteratee shorthands.
573 * @param {Object} object The object to iterate over.
574 * @param {Function} iteratee The function invoked per iteration.
575 * @returns {Object} Returns `object`.
577 function baseForOwn(object, iteratee) {
578 return object && baseFor(object, iteratee, keys);
582 * The base implementation of `_.functions` which creates an array of
583 * `object` function property names filtered from `props`.
586 * @param {Object} object The object to inspect.
587 * @param {Array} props The property names to filter.
588 * @returns {Array} Returns the function names.
590 function baseFunctions(object, props) {
591 return baseFilter(props, function(key) {
592 return isFunction(object[key]);
597 * The base implementation of `getTag` without fallbacks for buggy environments.
600 * @param {*} value The value to query.
601 * @returns {string} Returns the `toStringTag`.
603 function baseGetTag(value) {
604 return objectToString(value);
608 * The base implementation of `_.gt` which doesn't coerce arguments.
611 * @param {*} value The value to compare.
612 * @param {*} other The other value to compare.
613 * @returns {boolean} Returns `true` if `value` is greater than `other`,
616 function baseGt(value, other) {
617 return value > other;
621 * The base implementation of `_.isArguments`.
624 * @param {*} value The value to check.
625 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
627 var baseIsArguments = noop;
630 * The base implementation of `_.isDate` without Node.js optimizations.
633 * @param {*} value The value to check.
634 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
636 function baseIsDate(value) {
637 return isObjectLike(value) && baseGetTag(value) == dateTag;
641 * The base implementation of `_.isEqual` which supports partial comparisons
642 * and tracks traversed objects.
645 * @param {*} value The value to compare.
646 * @param {*} other The other value to compare.
647 * @param {boolean} bitmask The bitmask flags.
648 * 1 - Unordered comparison
649 * 2 - Partial comparison
650 * @param {Function} [customizer] The function to customize comparisons.
651 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
652 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
654 function baseIsEqual(value, other, bitmask, customizer, stack) {
655 if (value === other) {
658 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
659 return value !== value && other !== other;
661 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
665 * A specialized version of `baseIsEqual` for arrays and objects which performs
666 * deep comparisons and tracks traversed objects enabling objects with circular
667 * references to be compared.
670 * @param {Object} object The object to compare.
671 * @param {Object} other The other object to compare.
672 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
673 * @param {Function} customizer The function to customize comparisons.
674 * @param {Function} equalFunc The function to determine equivalents of values.
675 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
676 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
678 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
679 var objIsArr = isArray(object),
680 othIsArr = isArray(other),
681 objTag = objIsArr ? arrayTag : baseGetTag(object),
682 othTag = othIsArr ? arrayTag : baseGetTag(other);
684 objTag = objTag == argsTag ? objectTag : objTag;
685 othTag = othTag == argsTag ? objectTag : othTag;
687 var objIsObj = objTag == objectTag,
688 othIsObj = othTag == objectTag,
689 isSameTag = objTag == othTag;
691 stack || (stack = []);
692 var objStack = find(stack, function(entry) {
693 return entry[0] == object;
695 var othStack = find(stack, function(entry) {
696 return entry[0] == other;
698 if (objStack && othStack) {
699 return objStack[1] == other;
701 stack.push([object, other]);
702 stack.push([other, object]);
703 if (isSameTag && !objIsObj) {
704 var result = (objIsArr)
705 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
706 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
710 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
711 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
712 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
714 if (objIsWrapped || othIsWrapped) {
715 var objUnwrapped = objIsWrapped ? object.value() : object,
716 othUnwrapped = othIsWrapped ? other.value() : other;
718 var result = equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
726 var result = equalObjects(object, other, bitmask, customizer, equalFunc, stack);
732 * The base implementation of `_.isRegExp` without Node.js optimizations.
735 * @param {*} value The value to check.
736 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
738 function baseIsRegExp(value) {
739 return isObjectLike(value) && baseGetTag(value) == regexpTag;
743 * The base implementation of `_.iteratee`.
746 * @param {*} [value=_.identity] The value to convert to an iteratee.
747 * @returns {Function} Returns the iteratee.
749 function baseIteratee(func) {
750 if (typeof func == 'function') {
756 return (typeof func == 'object' ? baseMatches : baseProperty)(func);
760 * The base implementation of `_.lt` which doesn't coerce arguments.
763 * @param {*} value The value to compare.
764 * @param {*} other The other value to compare.
765 * @returns {boolean} Returns `true` if `value` is less than `other`,
768 function baseLt(value, other) {
769 return value < other;
773 * The base implementation of `_.map` without support for iteratee shorthands.
776 * @param {Array|Object} collection The collection to iterate over.
777 * @param {Function} iteratee The function invoked per iteration.
778 * @returns {Array} Returns the new mapped array.
780 function baseMap(collection, iteratee) {
782 result = isArrayLike(collection) ? Array(collection.length) : [];
784 baseEach(collection, function(value, key, collection) {
785 result[++index] = iteratee(value, key, collection);
791 * The base implementation of `_.matches` which doesn't clone `source`.
794 * @param {Object} source The object of property values to match.
795 * @returns {Function} Returns the new spec function.
797 function baseMatches(source) {
798 var props = nativeKeys(source);
799 return function(object) {
800 var length = props.length;
801 if (object == null) {
804 object = Object(object);
806 var key = props[length];
807 if (!(key in object &&
808 baseIsEqual(source[key], object[key], COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG)
818 * The base implementation of `_.pick` without support for individual
819 * property identifiers.
822 * @param {Object} object The source object.
823 * @param {string[]} paths The property paths to pick.
824 * @returns {Object} Returns the new object.
826 function basePick(object, props) {
827 object = Object(object);
828 return reduce(props, function(result, key) {
830 result[key] = object[key];
837 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
840 * @param {Function} func The function to apply a rest parameter to.
841 * @param {number} [start=func.length-1] The start position of the rest parameter.
842 * @returns {Function} Returns the new function.
844 function baseRest(func, start) {
845 return setToString(overRest(func, start, identity), func + '');
849 * The base implementation of `_.slice` without an iteratee call guard.
852 * @param {Array} array The array to slice.
853 * @param {number} [start=0] The start position.
854 * @param {number} [end=array.length] The end position.
855 * @returns {Array} Returns the slice of `array`.
857 function baseSlice(array, start, end) {
859 length = array.length;
862 start = -start > length ? 0 : (length + start);
864 end = end > length ? length : end;
868 length = start > end ? 0 : ((end - start) >>> 0);
871 var result = Array(length);
872 while (++index < length) {
873 result[index] = array[index + start];
879 * Copies the values of `source` to `array`.
882 * @param {Array} source The array to copy values from.
883 * @param {Array} [array=[]] The array to copy values to.
884 * @returns {Array} Returns `array`.
886 function copyArray(source) {
887 return baseSlice(source, 0, source.length);
891 * The base implementation of `_.some` without support for iteratee shorthands.
894 * @param {Array|Object} collection The collection to iterate over.
895 * @param {Function} predicate The function invoked per iteration.
896 * @returns {boolean} Returns `true` if any element passes the predicate check,
899 function baseSome(collection, predicate) {
902 baseEach(collection, function(value, index, collection) {
903 result = predicate(value, index, collection);
910 * The base implementation of `wrapperValue` which returns the result of
911 * performing a sequence of actions on the unwrapped `value`, where each
912 * successive action is supplied the return value of the previous.
915 * @param {*} value The unwrapped value.
916 * @param {Array} actions Actions to perform to resolve the unwrapped value.
917 * @returns {*} Returns the resolved value.
919 function baseWrapperValue(value, actions) {
921 return reduce(actions, function(result, action) {
922 return action.func.apply(action.thisArg, arrayPush([result], action.args));
927 * Compares values to sort them in ascending order.
930 * @param {*} value The value to compare.
931 * @param {*} other The other value to compare.
932 * @returns {number} Returns the sort order indicator for `value`.
934 function compareAscending(value, other) {
935 if (value !== other) {
936 var valIsDefined = value !== undefined,
937 valIsNull = value === null,
938 valIsReflexive = value === value,
941 var othIsDefined = other !== undefined,
942 othIsNull = other === null,
943 othIsReflexive = other === other,
946 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
947 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
948 (valIsNull && othIsDefined && othIsReflexive) ||
949 (!valIsDefined && othIsReflexive) ||
953 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
954 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
955 (othIsNull && valIsDefined && valIsReflexive) ||
956 (!othIsDefined && valIsReflexive) ||
965 * Copies properties of `source` to `object`.
968 * @param {Object} source The object to copy properties from.
969 * @param {Array} props The property identifiers to copy.
970 * @param {Object} [object={}] The object to copy properties to.
971 * @param {Function} [customizer] The function to customize copied values.
972 * @returns {Object} Returns `object`.
974 function copyObject(source, props, object, customizer) {
976 object || (object = {});
979 length = props.length;
981 while (++index < length) {
982 var key = props[index];
984 var newValue = customizer
985 ? customizer(object[key], source[key], key, object, source)
988 if (newValue === undefined) {
989 newValue = source[key];
992 baseAssignValue(object, key, newValue);
994 assignValue(object, key, newValue);
1001 * Creates a function like `_.assign`.
1004 * @param {Function} assigner The function to assign values.
1005 * @returns {Function} Returns the new assigner function.
1007 function createAssigner(assigner) {
1008 return baseRest(function(object, sources) {
1010 length = sources.length,
1011 customizer = length > 1 ? sources[length - 1] : undefined;
1013 customizer = (assigner.length > 3 && typeof customizer == 'function')
1014 ? (length--, customizer)
1017 object = Object(object);
1018 while (++index < length) {
1019 var source = sources[index];
1021 assigner(object, source, index, customizer);
1029 * Creates a `baseEach` or `baseEachRight` function.
1032 * @param {Function} eachFunc The function to iterate over a collection.
1033 * @param {boolean} [fromRight] Specify iterating from right to left.
1034 * @returns {Function} Returns the new base function.
1036 function createBaseEach(eachFunc, fromRight) {
1037 return function(collection, iteratee) {
1038 if (collection == null) {
1041 if (!isArrayLike(collection)) {
1042 return eachFunc(collection, iteratee);
1044 var length = collection.length,
1045 index = fromRight ? length : -1,
1046 iterable = Object(collection);
1048 while ((fromRight ? index-- : ++index < length)) {
1049 if (iteratee(iterable[index], index, iterable) === false) {
1058 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1061 * @param {boolean} [fromRight] Specify iterating from right to left.
1062 * @returns {Function} Returns the new base function.
1064 function createBaseFor(fromRight) {
1065 return function(object, iteratee, keysFunc) {
1067 iterable = Object(object),
1068 props = keysFunc(object),
1069 length = props.length;
1072 var key = props[fromRight ? length : ++index];
1073 if (iteratee(iterable[key], key, iterable) === false) {
1082 * Creates a function that produces an instance of `Ctor` regardless of
1083 * whether it was invoked as part of a `new` expression or by `call` or `apply`.
1086 * @param {Function} Ctor The constructor to wrap.
1087 * @returns {Function} Returns the new wrapped function.
1089 function createCtor(Ctor) {
1091 // Use a `switch` statement to work with class constructors. See
1092 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
1093 // for more details.
1094 var args = arguments;
1095 var thisBinding = baseCreate(Ctor.prototype),
1096 result = Ctor.apply(thisBinding, args);
1098 // Mimic the constructor's `return` behavior.
1099 // See https://es5.github.io/#x13.2.2 for more details.
1100 return isObject(result) ? result : thisBinding;
1105 * Creates a `_.find` or `_.findLast` function.
1108 * @param {Function} findIndexFunc The function to find the collection index.
1109 * @returns {Function} Returns the new find function.
1111 function createFind(findIndexFunc) {
1112 return function(collection, predicate, fromIndex) {
1113 var iterable = Object(collection);
1114 if (!isArrayLike(collection)) {
1115 var iteratee = baseIteratee(predicate, 3);
1116 collection = keys(collection);
1117 predicate = function(key) { return iteratee(iterable[key], key, iterable); };
1119 var index = findIndexFunc(collection, predicate, fromIndex);
1120 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
1125 * Creates a function that wraps `func` to invoke it with the `this` binding
1126 * of `thisArg` and `partials` prepended to the arguments it receives.
1129 * @param {Function} func The function to wrap.
1130 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
1131 * @param {*} thisArg The `this` binding of `func`.
1132 * @param {Array} partials The arguments to prepend to those provided to
1134 * @returns {Function} Returns the new wrapped function.
1136 function createPartial(func, bitmask, thisArg, partials) {
1137 if (typeof func != 'function') {
1138 throw new TypeError(FUNC_ERROR_TEXT);
1140 var isBind = bitmask & WRAP_BIND_FLAG,
1141 Ctor = createCtor(func);
1143 function wrapper() {
1145 argsLength = arguments.length,
1147 leftLength = partials.length,
1148 args = Array(leftLength + argsLength),
1149 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
1151 while (++leftIndex < leftLength) {
1152 args[leftIndex] = partials[leftIndex];
1154 while (argsLength--) {
1155 args[leftIndex++] = arguments[++argsIndex];
1157 return fn.apply(isBind ? thisArg : this, args);
1163 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
1164 * of source objects to the destination object for all destination properties
1165 * that resolve to `undefined`.
1168 * @param {*} objValue The destination value.
1169 * @param {*} srcValue The source value.
1170 * @param {string} key The key of the property to assign.
1171 * @param {Object} object The parent object of `objValue`.
1172 * @returns {*} Returns the value to assign.
1174 function customDefaultsAssignIn(objValue, srcValue, key, object) {
1175 if (objValue === undefined ||
1176 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
1183 * A specialized version of `baseIsEqualDeep` for arrays with support for
1184 * partial deep comparisons.
1187 * @param {Array} array The array to compare.
1188 * @param {Array} other The other array to compare.
1189 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1190 * @param {Function} customizer The function to customize comparisons.
1191 * @param {Function} equalFunc The function to determine equivalents of values.
1192 * @param {Object} stack Tracks traversed `array` and `other` objects.
1193 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1195 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1196 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1197 arrLength = array.length,
1198 othLength = other.length;
1200 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1205 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? [] : undefined;
1207 // Ignore non-index properties.
1208 while (++index < arrLength) {
1209 var arrValue = array[index],
1210 othValue = other[index];
1213 if (compared !== undefined) {
1220 // Recursively compare arrays (susceptible to call stack limits).
1222 if (!baseSome(other, function(othValue, othIndex) {
1223 if (!indexOf(seen, othIndex) &&
1224 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1225 return seen.push(othIndex);
1232 arrValue === othValue ||
1233 equalFunc(arrValue, othValue, bitmask, customizer, stack)
1243 * A specialized version of `baseIsEqualDeep` for comparing objects of
1244 * the same `toStringTag`.
1246 * **Note:** This function only supports comparing values with tags of
1247 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1250 * @param {Object} object The object to compare.
1251 * @param {Object} other The other object to compare.
1252 * @param {string} tag The `toStringTag` of the objects to compare.
1253 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1254 * @param {Function} customizer The function to customize comparisons.
1255 * @param {Function} equalFunc The function to determine equivalents of values.
1256 * @param {Object} stack Tracks traversed `object` and `other` objects.
1257 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1259 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1265 // Coerce booleans to `1` or `0` and dates to milliseconds.
1266 // Invalid dates are coerced to `NaN`.
1267 return eq(+object, +other);
1270 return object.name == other.name && object.message == other.message;
1274 // Coerce regexes to strings and treat strings, primitives and objects,
1275 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1276 // for more details.
1277 return object == (other + '');
1284 * A specialized version of `baseIsEqualDeep` for objects with support for
1285 * partial deep comparisons.
1288 * @param {Object} object The object to compare.
1289 * @param {Object} other The other object to compare.
1290 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1291 * @param {Function} customizer The function to customize comparisons.
1292 * @param {Function} equalFunc The function to determine equivalents of values.
1293 * @param {Object} stack Tracks traversed `object` and `other` objects.
1294 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1296 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1297 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1298 objProps = keys(object),
1299 objLength = objProps.length,
1300 othProps = keys(other),
1301 othLength = othProps.length;
1303 if (objLength != othLength && !isPartial) {
1306 var index = objLength;
1308 var key = objProps[index];
1309 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1315 var skipCtor = isPartial;
1316 while (++index < objLength) {
1317 key = objProps[index];
1318 var objValue = object[key],
1319 othValue = other[key];
1322 // Recursively compare objects (susceptible to call stack limits).
1323 if (!(compared === undefined
1324 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
1330 skipCtor || (skipCtor = key == 'constructor');
1332 if (result && !skipCtor) {
1333 var objCtor = object.constructor,
1334 othCtor = other.constructor;
1336 // Non `Object` object instances with different constructors are not equal.
1337 if (objCtor != othCtor &&
1338 ('constructor' in object && 'constructor' in other) &&
1339 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1340 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1348 * A specialized version of `baseRest` which flattens the rest array.
1351 * @param {Function} func The function to apply a rest parameter to.
1352 * @returns {Function} Returns the new function.
1354 function flatRest(func) {
1355 return setToString(overRest(func, undefined, flatten), func + '');
1359 * Checks if `value` is a flattenable `arguments` object or array.
1362 * @param {*} value The value to check.
1363 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
1365 function isFlattenable(value) {
1366 return isArray(value) || isArguments(value);
1370 * This function is like
1371 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1372 * except that it includes inherited enumerable properties.
1375 * @param {Object} object The object to query.
1376 * @returns {Array} Returns the array of property names.
1378 function nativeKeysIn(object) {
1380 if (object != null) {
1381 for (var key in Object(object)) {
1389 * Converts `value` to a string using `Object.prototype.toString`.
1392 * @param {*} value The value to convert.
1393 * @returns {string} Returns the converted string.
1395 function objectToString(value) {
1396 return nativeObjectToString.call(value);
1400 * A specialized version of `baseRest` which transforms the rest array.
1403 * @param {Function} func The function to apply a rest parameter to.
1404 * @param {number} [start=func.length-1] The start position of the rest parameter.
1405 * @param {Function} transform The rest array transform.
1406 * @returns {Function} Returns the new function.
1408 function overRest(func, start, transform) {
1409 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1411 var args = arguments,
1413 length = nativeMax(args.length - start, 0),
1414 array = Array(length);
1416 while (++index < length) {
1417 array[index] = args[start + index];
1420 var otherArgs = Array(start + 1);
1421 while (++index < start) {
1422 otherArgs[index] = args[index];
1424 otherArgs[start] = transform(array);
1425 return func.apply(this, otherArgs);
1430 * Sets the `toString` method of `func` to return `string`.
1433 * @param {Function} func The function to modify.
1434 * @param {Function} string The `toString` result.
1435 * @returns {Function} Returns `func`.
1437 var setToString = identity;
1439 /*------------------------------------------------------------------------*/
1442 * Creates an array with all falsey values removed. The values `false`, `null`,
1443 * `0`, `""`, `undefined`, and `NaN` are falsey.
1449 * @param {Array} array The array to compact.
1450 * @returns {Array} Returns the new array of filtered values.
1453 * _.compact([0, 1, false, 2, '', 3]);
1456 function compact(array) {
1457 return baseFilter(array, Boolean);
1461 * Creates a new array concatenating `array` with any additional arrays
1468 * @param {Array} array The array to concatenate.
1469 * @param {...*} [values] The values to concatenate.
1470 * @returns {Array} Returns the new concatenated array.
1474 * var other = _.concat(array, 2, [3], [[4]]);
1476 * console.log(other);
1477 * // => [1, 2, 3, [4]]
1479 * console.log(array);
1483 var length = arguments.length;
1487 var args = Array(length - 1),
1488 array = arguments[0],
1492 args[index - 1] = arguments[index];
1494 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
1498 * This method is like `_.find` except that it returns the index of the first
1499 * element `predicate` returns truthy for instead of the element itself.
1505 * @param {Array} array The array to inspect.
1506 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1507 * @param {number} [fromIndex=0] The index to search from.
1508 * @returns {number} Returns the index of the found element, else `-1`.
1512 * { 'user': 'barney', 'active': false },
1513 * { 'user': 'fred', 'active': false },
1514 * { 'user': 'pebbles', 'active': true }
1517 * _.findIndex(users, function(o) { return o.user == 'barney'; });
1520 * // The `_.matches` iteratee shorthand.
1521 * _.findIndex(users, { 'user': 'fred', 'active': false });
1524 * // The `_.matchesProperty` iteratee shorthand.
1525 * _.findIndex(users, ['active', false]);
1528 * // The `_.property` iteratee shorthand.
1529 * _.findIndex(users, 'active');
1532 function findIndex(array, predicate, fromIndex) {
1533 var length = array == null ? 0 : array.length;
1537 var index = fromIndex == null ? 0 : toInteger(fromIndex);
1539 index = nativeMax(length + index, 0);
1541 return baseFindIndex(array, baseIteratee(predicate, 3), index);
1545 * Flattens `array` a single level deep.
1551 * @param {Array} array The array to flatten.
1552 * @returns {Array} Returns the new flattened array.
1555 * _.flatten([1, [2, [3, [4]], 5]]);
1556 * // => [1, 2, [3, [4]], 5]
1558 function flatten(array) {
1559 var length = array == null ? 0 : array.length;
1560 return length ? baseFlatten(array, 1) : [];
1564 * Recursively flattens `array`.
1570 * @param {Array} array The array to flatten.
1571 * @returns {Array} Returns the new flattened array.
1574 * _.flattenDeep([1, [2, [3, [4]], 5]]);
1575 * // => [1, 2, 3, 4, 5]
1577 function flattenDeep(array) {
1578 var length = array == null ? 0 : array.length;
1579 return length ? baseFlatten(array, INFINITY) : [];
1583 * Gets the first element of `array`.
1590 * @param {Array} array The array to query.
1591 * @returns {*} Returns the first element of `array`.
1594 * _.head([1, 2, 3]);
1600 function head(array) {
1601 return (array && array.length) ? array[0] : undefined;
1605 * Gets the index at which the first occurrence of `value` is found in `array`
1606 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1607 * for equality comparisons. If `fromIndex` is negative, it's used as the
1608 * offset from the end of `array`.
1614 * @param {Array} array The array to inspect.
1615 * @param {*} value The value to search for.
1616 * @param {number} [fromIndex=0] The index to search from.
1617 * @returns {number} Returns the index of the matched value, else `-1`.
1620 * _.indexOf([1, 2, 1, 2], 2);
1623 * // Search from the `fromIndex`.
1624 * _.indexOf([1, 2, 1, 2], 2, 2);
1627 function indexOf(array, value, fromIndex) {
1628 var length = array == null ? 0 : array.length;
1629 if (typeof fromIndex == 'number') {
1630 fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
1634 var index = (fromIndex || 0) - 1,
1635 isReflexive = value === value;
1637 while (++index < length) {
1638 var other = array[index];
1639 if ((isReflexive ? other === value : other !== other)) {
1647 * Gets the last element of `array`.
1653 * @param {Array} array The array to query.
1654 * @returns {*} Returns the last element of `array`.
1657 * _.last([1, 2, 3]);
1660 function last(array) {
1661 var length = array == null ? 0 : array.length;
1662 return length ? array[length - 1] : undefined;
1666 * Creates a slice of `array` from `start` up to, but not including, `end`.
1668 * **Note:** This method is used instead of
1669 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
1676 * @param {Array} array The array to slice.
1677 * @param {number} [start=0] The start position.
1678 * @param {number} [end=array.length] The end position.
1679 * @returns {Array} Returns the slice of `array`.
1681 function slice(array, start, end) {
1682 var length = array == null ? 0 : array.length;
1683 start = start == null ? 0 : +start;
1684 end = end === undefined ? length : +end;
1685 return length ? baseSlice(array, start, end) : [];
1688 /*------------------------------------------------------------------------*/
1691 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
1692 * chain sequences enabled. The result of such sequences must be unwrapped
1699 * @param {*} value The value to wrap.
1700 * @returns {Object} Returns the new `lodash` wrapper instance.
1704 * { 'user': 'barney', 'age': 36 },
1705 * { 'user': 'fred', 'age': 40 },
1706 * { 'user': 'pebbles', 'age': 1 }
1712 * .map(function(o) {
1713 * return o.user + ' is ' + o.age;
1717 * // => 'pebbles is 1'
1719 function chain(value) {
1720 var result = lodash(value);
1721 result.__chain__ = true;
1726 * This method invokes `interceptor` and returns `value`. The interceptor
1727 * is invoked with one argument; (value). The purpose of this method is to
1728 * "tap into" a method chain sequence in order to modify intermediate results.
1734 * @param {*} value The value to provide to `interceptor`.
1735 * @param {Function} interceptor The function to invoke.
1736 * @returns {*} Returns `value`.
1740 * .tap(function(array) {
1741 * // Mutate input array.
1748 function tap(value, interceptor) {
1754 * This method is like `_.tap` except that it returns the result of `interceptor`.
1755 * The purpose of this method is to "pass thru" values replacing intermediate
1756 * results in a method chain sequence.
1762 * @param {*} value The value to provide to `interceptor`.
1763 * @param {Function} interceptor The function to invoke.
1764 * @returns {*} Returns the result of `interceptor`.
1770 * .thru(function(value) {
1776 function thru(value, interceptor) {
1777 return interceptor(value);
1781 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
1787 * @returns {Object} Returns the new `lodash` wrapper instance.
1791 * { 'user': 'barney', 'age': 36 },
1792 * { 'user': 'fred', 'age': 40 }
1795 * // A sequence without explicit chaining.
1797 * // => { 'user': 'barney', 'age': 36 }
1799 * // A sequence with explicit chaining.
1805 * // => { 'user': 'barney' }
1807 function wrapperChain() {
1812 * Executes the chain sequence to resolve the unwrapped value.
1817 * @alias toJSON, valueOf
1819 * @returns {*} Returns the resolved unwrapped value.
1822 * _([1, 2, 3]).value();
1825 function wrapperValue() {
1826 return baseWrapperValue(this.__wrapped__, this.__actions__);
1829 /*------------------------------------------------------------------------*/
1832 * Checks if `predicate` returns truthy for **all** elements of `collection`.
1833 * Iteration is stopped once `predicate` returns falsey. The predicate is
1834 * invoked with three arguments: (value, index|key, collection).
1836 * **Note:** This method returns `true` for
1837 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
1838 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
1839 * elements of empty collections.
1844 * @category Collection
1845 * @param {Array|Object} collection The collection to iterate over.
1846 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1847 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
1848 * @returns {boolean} Returns `true` if all elements pass the predicate check,
1852 * _.every([true, 1, null, 'yes'], Boolean);
1856 * { 'user': 'barney', 'age': 36, 'active': false },
1857 * { 'user': 'fred', 'age': 40, 'active': false }
1860 * // The `_.matches` iteratee shorthand.
1861 * _.every(users, { 'user': 'barney', 'active': false });
1864 * // The `_.matchesProperty` iteratee shorthand.
1865 * _.every(users, ['active', false]);
1868 * // The `_.property` iteratee shorthand.
1869 * _.every(users, 'active');
1872 function every(collection, predicate, guard) {
1873 predicate = guard ? undefined : predicate;
1874 return baseEvery(collection, baseIteratee(predicate));
1878 * Iterates over elements of `collection`, returning an array of all elements
1879 * `predicate` returns truthy for. The predicate is invoked with three
1880 * arguments: (value, index|key, collection).
1882 * **Note:** Unlike `_.remove`, this method returns a new array.
1887 * @category Collection
1888 * @param {Array|Object} collection The collection to iterate over.
1889 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1890 * @returns {Array} Returns the new filtered array.
1895 * { 'user': 'barney', 'age': 36, 'active': true },
1896 * { 'user': 'fred', 'age': 40, 'active': false }
1899 * _.filter(users, function(o) { return !o.active; });
1900 * // => objects for ['fred']
1902 * // The `_.matches` iteratee shorthand.
1903 * _.filter(users, { 'age': 36, 'active': true });
1904 * // => objects for ['barney']
1906 * // The `_.matchesProperty` iteratee shorthand.
1907 * _.filter(users, ['active', false]);
1908 * // => objects for ['fred']
1910 * // The `_.property` iteratee shorthand.
1911 * _.filter(users, 'active');
1912 * // => objects for ['barney']
1914 function filter(collection, predicate) {
1915 return baseFilter(collection, baseIteratee(predicate));
1919 * Iterates over elements of `collection`, returning the first element
1920 * `predicate` returns truthy for. The predicate is invoked with three
1921 * arguments: (value, index|key, collection).
1926 * @category Collection
1927 * @param {Array|Object} collection The collection to inspect.
1928 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1929 * @param {number} [fromIndex=0] The index to search from.
1930 * @returns {*} Returns the matched element, else `undefined`.
1934 * { 'user': 'barney', 'age': 36, 'active': true },
1935 * { 'user': 'fred', 'age': 40, 'active': false },
1936 * { 'user': 'pebbles', 'age': 1, 'active': true }
1939 * _.find(users, function(o) { return o.age < 40; });
1940 * // => object for 'barney'
1942 * // The `_.matches` iteratee shorthand.
1943 * _.find(users, { 'age': 1, 'active': true });
1944 * // => object for 'pebbles'
1946 * // The `_.matchesProperty` iteratee shorthand.
1947 * _.find(users, ['active', false]);
1948 * // => object for 'fred'
1950 * // The `_.property` iteratee shorthand.
1951 * _.find(users, 'active');
1952 * // => object for 'barney'
1954 var find = createFind(findIndex);
1957 * Iterates over elements of `collection` and invokes `iteratee` for each element.
1958 * The iteratee is invoked with three arguments: (value, index|key, collection).
1959 * Iteratee functions may exit iteration early by explicitly returning `false`.
1961 * **Note:** As with other "Collections" methods, objects with a "length"
1962 * property are iterated like arrays. To avoid this behavior use `_.forIn`
1963 * or `_.forOwn` for object iteration.
1969 * @category Collection
1970 * @param {Array|Object} collection The collection to iterate over.
1971 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
1972 * @returns {Array|Object} Returns `collection`.
1973 * @see _.forEachRight
1976 * _.forEach([1, 2], function(value) {
1977 * console.log(value);
1979 * // => Logs `1` then `2`.
1981 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
1984 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
1986 function forEach(collection, iteratee) {
1987 return baseEach(collection, baseIteratee(iteratee));
1991 * Creates an array of values by running each element in `collection` thru
1992 * `iteratee`. The iteratee is invoked with three arguments:
1993 * (value, index|key, collection).
1995 * Many lodash methods are guarded to work as iteratees for methods like
1996 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
1998 * The guarded methods are:
1999 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
2000 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
2001 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
2002 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
2007 * @category Collection
2008 * @param {Array|Object} collection The collection to iterate over.
2009 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2010 * @returns {Array} Returns the new mapped array.
2013 * function square(n) {
2017 * _.map([4, 8], square);
2020 * _.map({ 'a': 4, 'b': 8 }, square);
2021 * // => [16, 64] (iteration order is not guaranteed)
2024 * { 'user': 'barney' },
2025 * { 'user': 'fred' }
2028 * // The `_.property` iteratee shorthand.
2029 * _.map(users, 'user');
2030 * // => ['barney', 'fred']
2032 function map(collection, iteratee) {
2033 return baseMap(collection, baseIteratee(iteratee));
2037 * Reduces `collection` to a value which is the accumulated result of running
2038 * each element in `collection` thru `iteratee`, where each successive
2039 * invocation is supplied the return value of the previous. If `accumulator`
2040 * is not given, the first element of `collection` is used as the initial
2041 * value. The iteratee is invoked with four arguments:
2042 * (accumulator, value, index|key, collection).
2044 * Many lodash methods are guarded to work as iteratees for methods like
2045 * `_.reduce`, `_.reduceRight`, and `_.transform`.
2047 * The guarded methods are:
2048 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
2054 * @category Collection
2055 * @param {Array|Object} collection The collection to iterate over.
2056 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2057 * @param {*} [accumulator] The initial value.
2058 * @returns {*} Returns the accumulated value.
2059 * @see _.reduceRight
2062 * _.reduce([1, 2], function(sum, n) {
2067 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
2068 * (result[value] || (result[value] = [])).push(key);
2071 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
2073 function reduce(collection, iteratee, accumulator) {
2074 return baseReduce(collection, baseIteratee(iteratee), accumulator, arguments.length < 3, baseEach);
2078 * Gets the size of `collection` by returning its length for array-like
2079 * values or the number of own enumerable string keyed properties for objects.
2084 * @category Collection
2085 * @param {Array|Object|string} collection The collection to inspect.
2086 * @returns {number} Returns the collection size.
2089 * _.size([1, 2, 3]);
2092 * _.size({ 'a': 1, 'b': 2 });
2095 * _.size('pebbles');
2098 function size(collection) {
2099 if (collection == null) {
2102 collection = isArrayLike(collection) ? collection : nativeKeys(collection);
2103 return collection.length;
2107 * Checks if `predicate` returns truthy for **any** element of `collection`.
2108 * Iteration is stopped once `predicate` returns truthy. The predicate is
2109 * invoked with three arguments: (value, index|key, collection).
2114 * @category Collection
2115 * @param {Array|Object} collection The collection to iterate over.
2116 * @param {Function} [predicate=_.identity] The function invoked per iteration.
2117 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2118 * @returns {boolean} Returns `true` if any element passes the predicate check,
2122 * _.some([null, 0, 'yes', false], Boolean);
2126 * { 'user': 'barney', 'active': true },
2127 * { 'user': 'fred', 'active': false }
2130 * // The `_.matches` iteratee shorthand.
2131 * _.some(users, { 'user': 'barney', 'active': false });
2134 * // The `_.matchesProperty` iteratee shorthand.
2135 * _.some(users, ['active', false]);
2138 * // The `_.property` iteratee shorthand.
2139 * _.some(users, 'active');
2142 function some(collection, predicate, guard) {
2143 predicate = guard ? undefined : predicate;
2144 return baseSome(collection, baseIteratee(predicate));
2148 * Creates an array of elements, sorted in ascending order by the results of
2149 * running each element in a collection thru each iteratee. This method
2150 * performs a stable sort, that is, it preserves the original sort order of
2151 * equal elements. The iteratees are invoked with one argument: (value).
2156 * @category Collection
2157 * @param {Array|Object} collection The collection to iterate over.
2158 * @param {...(Function|Function[])} [iteratees=[_.identity]]
2159 * The iteratees to sort by.
2160 * @returns {Array} Returns the new sorted array.
2164 * { 'user': 'fred', 'age': 48 },
2165 * { 'user': 'barney', 'age': 36 },
2166 * { 'user': 'fred', 'age': 40 },
2167 * { 'user': 'barney', 'age': 34 }
2170 * _.sortBy(users, [function(o) { return o.user; }]);
2171 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
2173 * _.sortBy(users, ['user', 'age']);
2174 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
2176 function sortBy(collection, iteratee) {
2178 iteratee = baseIteratee(iteratee);
2180 return baseMap(baseMap(collection, function(value, key, collection) {
2181 return { 'value': value, 'index': index++, 'criteria': iteratee(value, key, collection) };
2182 }).sort(function(object, other) {
2183 return compareAscending(object.criteria, other.criteria) || (object.index - other.index);
2184 }), baseProperty('value'));
2187 /*------------------------------------------------------------------------*/
2190 * Creates a function that invokes `func`, with the `this` binding and arguments
2191 * of the created function, while it's called less than `n` times. Subsequent
2192 * calls to the created function return the result of the last `func` invocation.
2197 * @category Function
2198 * @param {number} n The number of calls at which `func` is no longer invoked.
2199 * @param {Function} func The function to restrict.
2200 * @returns {Function} Returns the new restricted function.
2203 * jQuery(element).on('click', _.before(5, addContactToList));
2204 * // => Allows adding up to 4 contacts to the list.
2206 function before(n, func) {
2208 if (typeof func != 'function') {
2209 throw new TypeError(FUNC_ERROR_TEXT);
2214 result = func.apply(this, arguments);
2224 * Creates a function that invokes `func` with the `this` binding of `thisArg`
2225 * and `partials` prepended to the arguments it receives.
2227 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
2228 * may be used as a placeholder for partially applied arguments.
2230 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
2231 * property of bound functions.
2236 * @category Function
2237 * @param {Function} func The function to bind.
2238 * @param {*} thisArg The `this` binding of `func`.
2239 * @param {...*} [partials] The arguments to be partially applied.
2240 * @returns {Function} Returns the new bound function.
2243 * function greet(greeting, punctuation) {
2244 * return greeting + ' ' + this.user + punctuation;
2247 * var object = { 'user': 'fred' };
2249 * var bound = _.bind(greet, object, 'hi');
2253 * // Bound with placeholders.
2254 * var bound = _.bind(greet, object, _, '!');
2258 var bind = baseRest(function(func, thisArg, partials) {
2259 return createPartial(func, WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG, thisArg, partials);
2263 * Defers invoking the `func` until the current call stack has cleared. Any
2264 * additional arguments are provided to `func` when it's invoked.
2269 * @category Function
2270 * @param {Function} func The function to defer.
2271 * @param {...*} [args] The arguments to invoke `func` with.
2272 * @returns {number} Returns the timer id.
2275 * _.defer(function(text) {
2276 * console.log(text);
2278 * // => Logs 'deferred' after one millisecond.
2280 var defer = baseRest(function(func, args) {
2281 return baseDelay(func, 1, args);
2285 * Invokes `func` after `wait` milliseconds. Any additional arguments are
2286 * provided to `func` when it's invoked.
2291 * @category Function
2292 * @param {Function} func The function to delay.
2293 * @param {number} wait The number of milliseconds to delay invocation.
2294 * @param {...*} [args] The arguments to invoke `func` with.
2295 * @returns {number} Returns the timer id.
2298 * _.delay(function(text) {
2299 * console.log(text);
2300 * }, 1000, 'later');
2301 * // => Logs 'later' after one second.
2303 var delay = baseRest(function(func, wait, args) {
2304 return baseDelay(func, toNumber(wait) || 0, args);
2308 * Creates a function that negates the result of the predicate `func`. The
2309 * `func` predicate is invoked with the `this` binding and arguments of the
2315 * @category Function
2316 * @param {Function} predicate The predicate to negate.
2317 * @returns {Function} Returns the new negated function.
2320 * function isEven(n) {
2321 * return n % 2 == 0;
2324 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
2327 function negate(predicate) {
2328 if (typeof predicate != 'function') {
2329 throw new TypeError(FUNC_ERROR_TEXT);
2332 var args = arguments;
2333 return !predicate.apply(this, args);
2338 * Creates a function that is restricted to invoking `func` once. Repeat calls
2339 * to the function return the value of the first invocation. The `func` is
2340 * invoked with the `this` binding and arguments of the created function.
2345 * @category Function
2346 * @param {Function} func The function to restrict.
2347 * @returns {Function} Returns the new restricted function.
2350 * var initialize = _.once(createApplication);
2353 * // => `createApplication` is invoked once
2355 function once(func) {
2356 return before(2, func);
2359 /*------------------------------------------------------------------------*/
2362 * Creates a shallow clone of `value`.
2364 * **Note:** This method is loosely based on the
2365 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
2366 * and supports cloning arrays, array buffers, booleans, date objects, maps,
2367 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
2368 * arrays. The own enumerable properties of `arguments` objects are cloned
2369 * as plain objects. An empty object is returned for uncloneable values such
2370 * as error objects, functions, DOM nodes, and WeakMaps.
2376 * @param {*} value The value to clone.
2377 * @returns {*} Returns the cloned value.
2381 * var objects = [{ 'a': 1 }, { 'b': 2 }];
2383 * var shallow = _.clone(objects);
2384 * console.log(shallow[0] === objects[0]);
2387 function clone(value) {
2388 if (!isObject(value)) {
2391 return isArray(value) ? copyArray(value) : copyObject(value, nativeKeys(value));
2396 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2397 * comparison between two values to determine if they are equivalent.
2403 * @param {*} value The value to compare.
2404 * @param {*} other The other value to compare.
2405 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2408 * var object = { 'a': 1 };
2409 * var other = { 'a': 1 };
2411 * _.eq(object, object);
2414 * _.eq(object, other);
2420 * _.eq('a', Object('a'));
2426 function eq(value, other) {
2427 return value === other || (value !== value && other !== other);
2431 * Checks if `value` is likely an `arguments` object.
2437 * @param {*} value The value to check.
2438 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2442 * _.isArguments(function() { return arguments; }());
2445 * _.isArguments([1, 2, 3]);
2448 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
2449 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
2450 !propertyIsEnumerable.call(value, 'callee');
2454 * Checks if `value` is classified as an `Array` object.
2460 * @param {*} value The value to check.
2461 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2464 * _.isArray([1, 2, 3]);
2467 * _.isArray(document.body.children);
2473 * _.isArray(_.noop);
2476 var isArray = Array.isArray;
2479 * Checks if `value` is array-like. A value is considered array-like if it's
2480 * not a function and has a `value.length` that's an integer greater than or
2481 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2487 * @param {*} value The value to check.
2488 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2491 * _.isArrayLike([1, 2, 3]);
2494 * _.isArrayLike(document.body.children);
2497 * _.isArrayLike('abc');
2500 * _.isArrayLike(_.noop);
2503 function isArrayLike(value) {
2504 return value != null && isLength(value.length) && !isFunction(value);
2508 * Checks if `value` is classified as a boolean primitive or object.
2514 * @param {*} value The value to check.
2515 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
2518 * _.isBoolean(false);
2521 * _.isBoolean(null);
2524 function isBoolean(value) {
2525 return value === true || value === false ||
2526 (isObjectLike(value) && baseGetTag(value) == boolTag);
2530 * Checks if `value` is classified as a `Date` object.
2536 * @param {*} value The value to check.
2537 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
2540 * _.isDate(new Date);
2543 * _.isDate('Mon April 23 2012');
2546 var isDate = baseIsDate;
2549 * Checks if `value` is an empty object, collection, map, or set.
2551 * Objects are considered empty if they have no own enumerable string keyed
2554 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
2555 * jQuery-like collections are considered empty if they have a `length` of `0`.
2556 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
2562 * @param {*} value The value to check.
2563 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
2575 * _.isEmpty([1, 2, 3]);
2578 * _.isEmpty({ 'a': 1 });
2581 function isEmpty(value) {
2582 if (isArrayLike(value) &&
2583 (isArray(value) || isString(value) ||
2584 isFunction(value.splice) || isArguments(value))) {
2585 return !value.length;
2587 return !nativeKeys(value).length;
2591 * Performs a deep comparison between two values to determine if they are
2594 * **Note:** This method supports comparing arrays, array buffers, booleans,
2595 * date objects, error objects, maps, numbers, `Object` objects, regexes,
2596 * sets, strings, symbols, and typed arrays. `Object` objects are compared
2597 * by their own, not inherited, enumerable properties. Functions and DOM
2598 * nodes are compared by strict equality, i.e. `===`.
2604 * @param {*} value The value to compare.
2605 * @param {*} other The other value to compare.
2606 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2609 * var object = { 'a': 1 };
2610 * var other = { 'a': 1 };
2612 * _.isEqual(object, other);
2618 function isEqual(value, other) {
2619 return baseIsEqual(value, other);
2623 * Checks if `value` is a finite primitive number.
2625 * **Note:** This method is based on
2626 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
2632 * @param {*} value The value to check.
2633 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
2639 * _.isFinite(Number.MIN_VALUE);
2642 * _.isFinite(Infinity);
2648 function isFinite(value) {
2649 return typeof value == 'number' && nativeIsFinite(value);
2653 * Checks if `value` is classified as a `Function` object.
2659 * @param {*} value The value to check.
2660 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2666 * _.isFunction(/abc/);
2669 function isFunction(value) {
2670 if (!isObject(value)) {
2673 // The use of `Object#toString` avoids issues with the `typeof` operator
2674 // in Safari 9 which returns 'object' for typed arrays and other constructors.
2675 var tag = baseGetTag(value);
2676 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
2680 * Checks if `value` is a valid array-like length.
2682 * **Note:** This method is loosely based on
2683 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2689 * @param {*} value The value to check.
2690 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2696 * _.isLength(Number.MIN_VALUE);
2699 * _.isLength(Infinity);
2705 function isLength(value) {
2706 return typeof value == 'number' &&
2707 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2711 * Checks if `value` is the
2712 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2713 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2719 * @param {*} value The value to check.
2720 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2726 * _.isObject([1, 2, 3]);
2729 * _.isObject(_.noop);
2735 function isObject(value) {
2736 var type = typeof value;
2737 return value != null && (type == 'object' || type == 'function');
2741 * Checks if `value` is object-like. A value is object-like if it's not `null`
2742 * and has a `typeof` result of "object".
2748 * @param {*} value The value to check.
2749 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2752 * _.isObjectLike({});
2755 * _.isObjectLike([1, 2, 3]);
2758 * _.isObjectLike(_.noop);
2761 * _.isObjectLike(null);
2764 function isObjectLike(value) {
2765 return value != null && typeof value == 'object';
2769 * Checks if `value` is `NaN`.
2771 * **Note:** This method is based on
2772 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
2773 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
2774 * `undefined` and other non-number values.
2780 * @param {*} value The value to check.
2781 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
2787 * _.isNaN(new Number(NaN));
2793 * _.isNaN(undefined);
2796 function isNaN(value) {
2797 // An `NaN` primitive is the only value that is not equal to itself.
2798 // Perform the `toStringTag` check first to avoid errors with some
2799 // ActiveX objects in IE.
2800 return isNumber(value) && value != +value;
2804 * Checks if `value` is `null`.
2810 * @param {*} value The value to check.
2811 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
2820 function isNull(value) {
2821 return value === null;
2825 * Checks if `value` is classified as a `Number` primitive or object.
2827 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
2828 * classified as numbers, use the `_.isFinite` method.
2834 * @param {*} value The value to check.
2835 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
2841 * _.isNumber(Number.MIN_VALUE);
2844 * _.isNumber(Infinity);
2850 function isNumber(value) {
2851 return typeof value == 'number' ||
2852 (isObjectLike(value) && baseGetTag(value) == numberTag);
2856 * Checks if `value` is classified as a `RegExp` object.
2862 * @param {*} value The value to check.
2863 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
2866 * _.isRegExp(/abc/);
2869 * _.isRegExp('/abc/');
2872 var isRegExp = baseIsRegExp;
2875 * Checks if `value` is classified as a `String` primitive or object.
2881 * @param {*} value The value to check.
2882 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
2885 * _.isString('abc');
2891 function isString(value) {
2892 return typeof value == 'string' ||
2893 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
2897 * Checks if `value` is `undefined`.
2903 * @param {*} value The value to check.
2904 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
2907 * _.isUndefined(void 0);
2910 * _.isUndefined(null);
2913 function isUndefined(value) {
2914 return value === undefined;
2918 * Converts `value` to an array.
2924 * @param {*} value The value to convert.
2925 * @returns {Array} Returns the converted array.
2928 * _.toArray({ 'a': 1, 'b': 2 });
2932 * // => ['a', 'b', 'c']
2940 function toArray(value) {
2941 if (!isArrayLike(value)) {
2942 return values(value);
2944 return value.length ? copyArray(value) : [];
2948 * Converts `value` to an integer.
2950 * **Note:** This method is loosely based on
2951 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
2957 * @param {*} value The value to convert.
2958 * @returns {number} Returns the converted integer.
2964 * _.toInteger(Number.MIN_VALUE);
2967 * _.toInteger(Infinity);
2968 * // => 1.7976931348623157e+308
2970 * _.toInteger('3.2');
2973 var toInteger = Number;
2976 * Converts `value` to a number.
2982 * @param {*} value The value to process.
2983 * @returns {number} Returns the number.
2989 * _.toNumber(Number.MIN_VALUE);
2992 * _.toNumber(Infinity);
2995 * _.toNumber('3.2');
2998 var toNumber = Number;
3001 * Converts `value` to a string. An empty string is returned for `null`
3002 * and `undefined` values. The sign of `-0` is preserved.
3008 * @param {*} value The value to convert.
3009 * @returns {string} Returns the converted string.
3018 * _.toString([1, 2, 3]);
3021 function toString(value) {
3022 if (typeof value == 'string') {
3025 return value == null ? '' : (value + '');
3028 /*------------------------------------------------------------------------*/
3031 * Assigns own enumerable string keyed properties of source objects to the
3032 * destination object. Source objects are applied from left to right.
3033 * Subsequent sources overwrite property assignments of previous sources.
3035 * **Note:** This method mutates `object` and is loosely based on
3036 * [`Object.assign`](https://mdn.io/Object/assign).
3042 * @param {Object} object The destination object.
3043 * @param {...Object} [sources] The source objects.
3044 * @returns {Object} Returns `object`.
3056 * Foo.prototype.b = 2;
3057 * Bar.prototype.d = 4;
3059 * _.assign({ 'a': 0 }, new Foo, new Bar);
3060 * // => { 'a': 1, 'c': 3 }
3062 var assign = createAssigner(function(object, source) {
3063 copyObject(source, nativeKeys(source), object);
3067 * This method is like `_.assign` except that it iterates over own and
3068 * inherited source properties.
3070 * **Note:** This method mutates `object`.
3077 * @param {Object} object The destination object.
3078 * @param {...Object} [sources] The source objects.
3079 * @returns {Object} Returns `object`.
3091 * Foo.prototype.b = 2;
3092 * Bar.prototype.d = 4;
3094 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
3095 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
3097 var assignIn = createAssigner(function(object, source) {
3098 copyObject(source, nativeKeysIn(source), object);
3102 * This method is like `_.assignIn` except that it accepts `customizer`
3103 * which is invoked to produce the assigned values. If `customizer` returns
3104 * `undefined`, assignment is handled by the method instead. The `customizer`
3105 * is invoked with five arguments: (objValue, srcValue, key, object, source).
3107 * **Note:** This method mutates `object`.
3114 * @param {Object} object The destination object.
3115 * @param {...Object} sources The source objects.
3116 * @param {Function} [customizer] The function to customize assigned values.
3117 * @returns {Object} Returns `object`.
3121 * function customizer(objValue, srcValue) {
3122 * return _.isUndefined(objValue) ? srcValue : objValue;
3125 * var defaults = _.partialRight(_.assignInWith, customizer);
3127 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3128 * // => { 'a': 1, 'b': 2 }
3130 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
3131 copyObject(source, keysIn(source), object, customizer);
3135 * Creates an object that inherits from the `prototype` object. If a
3136 * `properties` object is given, its own enumerable string keyed properties
3137 * are assigned to the created object.
3143 * @param {Object} prototype The object to inherit from.
3144 * @param {Object} [properties] The properties to assign to the object.
3145 * @returns {Object} Returns the new object.
3148 * function Shape() {
3153 * function Circle() {
3157 * Circle.prototype = _.create(Shape.prototype, {
3158 * 'constructor': Circle
3161 * var circle = new Circle;
3162 * circle instanceof Circle;
3165 * circle instanceof Shape;
3168 function create(prototype, properties) {
3169 var result = baseCreate(prototype);
3170 return properties == null ? result : assign(result, properties);
3174 * Assigns own and inherited enumerable string keyed properties of source
3175 * objects to the destination object for all destination properties that
3176 * resolve to `undefined`. Source objects are applied from left to right.
3177 * Once a property is set, additional values of the same property are ignored.
3179 * **Note:** This method mutates `object`.
3185 * @param {Object} object The destination object.
3186 * @param {...Object} [sources] The source objects.
3187 * @returns {Object} Returns `object`.
3188 * @see _.defaultsDeep
3191 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3192 * // => { 'a': 1, 'b': 2 }
3194 var defaults = baseRest(function(args) {
3195 args.push(undefined, customDefaultsAssignIn);
3196 return assignInWith.apply(undefined, args);
3200 * Checks if `path` is a direct property of `object`.
3206 * @param {Object} object The object to query.
3207 * @param {Array|string} path The path to check.
3208 * @returns {boolean} Returns `true` if `path` exists, else `false`.
3211 * var object = { 'a': { 'b': 2 } };
3212 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
3214 * _.has(object, 'a');
3217 * _.has(object, 'a.b');
3220 * _.has(object, ['a', 'b']);
3223 * _.has(other, 'a');
3226 function has(object, path) {
3227 return object != null && hasOwnProperty.call(object, path);
3231 * Creates an array of the own enumerable property names of `object`.
3233 * **Note:** Non-object values are coerced to objects. See the
3234 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
3241 * @param {Object} object The object to query.
3242 * @returns {Array} Returns the array of property names.
3250 * Foo.prototype.c = 3;
3253 * // => ['a', 'b'] (iteration order is not guaranteed)
3258 var keys = nativeKeys;
3261 * Creates an array of the own and inherited enumerable property names of `object`.
3263 * **Note:** Non-object values are coerced to objects.
3269 * @param {Object} object The object to query.
3270 * @returns {Array} Returns the array of property names.
3278 * Foo.prototype.c = 3;
3280 * _.keysIn(new Foo);
3281 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
3283 var keysIn = nativeKeysIn;
3286 * Creates an object composed of the picked `object` properties.
3292 * @param {Object} object The source object.
3293 * @param {...(string|string[])} [paths] The property paths to pick.
3294 * @returns {Object} Returns the new object.
3297 * var object = { 'a': 1, 'b': '2', 'c': 3 };
3299 * _.pick(object, ['a', 'c']);
3300 * // => { 'a': 1, 'c': 3 }
3302 var pick = flatRest(function(object, paths) {
3303 return object == null ? {} : basePick(object, paths);
3307 * This method is like `_.get` except that if the resolved value is a
3308 * function it's invoked with the `this` binding of its parent object and
3309 * its result is returned.
3315 * @param {Object} object The object to query.
3316 * @param {Array|string} path The path of the property to resolve.
3317 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
3318 * @returns {*} Returns the resolved value.
3321 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
3323 * _.result(object, 'a[0].b.c1');
3326 * _.result(object, 'a[0].b.c2');
3329 * _.result(object, 'a[0].b.c3', 'default');
3332 * _.result(object, 'a[0].b.c3', _.constant('default'));
3335 function result(object, path, defaultValue) {
3336 var value = object == null ? undefined : object[path];
3337 if (value === undefined) {
3338 value = defaultValue;
3340 return isFunction(value) ? value.call(object) : value;
3344 * Creates an array of the own enumerable string keyed property values of `object`.
3346 * **Note:** Non-object values are coerced to objects.
3352 * @param {Object} object The object to query.
3353 * @returns {Array} Returns the array of property values.
3361 * Foo.prototype.c = 3;
3363 * _.values(new Foo);
3364 * // => [1, 2] (iteration order is not guaranteed)
3369 function values(object) {
3370 return object == null ? [] : baseValues(object, keys(object));
3373 /*------------------------------------------------------------------------*/
3376 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
3377 * corresponding HTML entities.
3379 * **Note:** No other characters are escaped. To escape additional
3380 * characters use a third-party library like [_he_](https://mths.be/he).
3382 * Though the ">" character is escaped for symmetry, characters like
3383 * ">" and "/" don't need escaping in HTML and have no special meaning
3384 * unless they're part of a tag or unquoted attribute value. See
3385 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
3386 * (under "semi-related fun fact") for more details.
3388 * When working with HTML you should always
3389 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
3396 * @param {string} [string=''] The string to escape.
3397 * @returns {string} Returns the escaped string.
3400 * _.escape('fred, barney, & pebbles');
3401 * // => 'fred, barney, & pebbles'
3403 function escape(string) {
3404 string = toString(string);
3405 return (string && reHasUnescapedHtml.test(string))
3406 ? string.replace(reUnescapedHtml, escapeHtmlChar)
3410 /*------------------------------------------------------------------------*/
3413 * This method returns the first argument it receives.
3419 * @param {*} value Any value.
3420 * @returns {*} Returns `value`.
3423 * var object = { 'a': 1 };
3425 * console.log(_.identity(object) === object);
3428 function identity(value) {
3433 * Creates a function that invokes `func` with the arguments of the created
3434 * function. If `func` is a property name, the created function returns the
3435 * property value for a given element. If `func` is an array or object, the
3436 * created function returns `true` for elements that contain the equivalent
3437 * source properties, otherwise it returns `false`.
3443 * @param {*} [func=_.identity] The value to convert to a callback.
3444 * @returns {Function} Returns the callback.
3448 * { 'user': 'barney', 'age': 36, 'active': true },
3449 * { 'user': 'fred', 'age': 40, 'active': false }
3452 * // The `_.matches` iteratee shorthand.
3453 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
3454 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
3456 * // The `_.matchesProperty` iteratee shorthand.
3457 * _.filter(users, _.iteratee(['user', 'fred']));
3458 * // => [{ 'user': 'fred', 'age': 40 }]
3460 * // The `_.property` iteratee shorthand.
3461 * _.map(users, _.iteratee('user'));
3462 * // => ['barney', 'fred']
3464 * // Create custom iteratee shorthands.
3465 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
3466 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
3467 * return func.test(string);
3471 * _.filter(['abc', 'def'], /ef/);
3474 var iteratee = baseIteratee;
3477 * Creates a function that performs a partial deep comparison between a given
3478 * object and `source`, returning `true` if the given object has equivalent
3479 * property values, else `false`.
3481 * **Note:** The created function is equivalent to `_.isMatch` with `source`
3482 * partially applied.
3484 * Partial comparisons will match empty array and empty object `source`
3485 * values against any array or object value, respectively. See `_.isEqual`
3486 * for a list of supported value comparisons.
3492 * @param {Object} source The object of property values to match.
3493 * @returns {Function} Returns the new spec function.
3497 * { 'a': 1, 'b': 2, 'c': 3 },
3498 * { 'a': 4, 'b': 5, 'c': 6 }
3501 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
3502 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
3504 function matches(source) {
3505 return baseMatches(assign({}, source));
3509 * Adds all own enumerable string keyed function properties of a source
3510 * object to the destination object. If `object` is a function, then methods
3511 * are added to its prototype as well.
3513 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
3514 * avoid conflicts caused by modifying the original.
3520 * @param {Function|Object} [object=lodash] The destination object.
3521 * @param {Object} source The object of functions to add.
3522 * @param {Object} [options={}] The options object.
3523 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
3524 * @returns {Function|Object} Returns `object`.
3527 * function vowels(string) {
3528 * return _.filter(string, function(v) {
3529 * return /[aeiou]/i.test(v);
3533 * _.mixin({ 'vowels': vowels });
3537 * _('fred').vowels().value();
3540 * _.mixin({ 'vowels': vowels }, { 'chain': false });
3541 * _('fred').vowels();
3544 function mixin(object, source, options) {
3545 var props = keys(source),
3546 methodNames = baseFunctions(source, props);
3548 if (options == null &&
3549 !(isObject(source) && (methodNames.length || !props.length))) {
3553 methodNames = baseFunctions(source, keys(source));
3555 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
3556 isFunc = isFunction(object);
3558 baseEach(methodNames, function(methodName) {
3559 var func = source[methodName];
3560 object[methodName] = func;
3562 object.prototype[methodName] = function() {
3563 var chainAll = this.__chain__;
3564 if (chain || chainAll) {
3565 var result = object(this.__wrapped__),
3566 actions = result.__actions__ = copyArray(this.__actions__);
3568 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
3569 result.__chain__ = chainAll;
3572 return func.apply(object, arrayPush([this.value()], arguments));
3581 * Reverts the `_` variable to its previous value and returns a reference to
3582 * the `lodash` function.
3588 * @returns {Function} Returns the `lodash` function.
3591 * var lodash = _.noConflict();
3593 function noConflict() {
3594 if (root._ === this) {
3601 * This method returns `undefined`.
3609 * _.times(2, _.noop);
3610 * // => [undefined, undefined]
3613 // No operation performed.
3617 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
3623 * @param {string} [prefix=''] The value to prefix the ID with.
3624 * @returns {string} Returns the unique ID.
3627 * _.uniqueId('contact_');
3628 * // => 'contact_104'
3633 function uniqueId(prefix) {
3634 var id = ++idCounter;
3635 return toString(prefix) + id;
3638 /*------------------------------------------------------------------------*/
3641 * Computes the maximum value of `array`. If `array` is empty or falsey,
3642 * `undefined` is returned.
3648 * @param {Array} array The array to iterate over.
3649 * @returns {*} Returns the maximum value.
3652 * _.max([4, 2, 8, 6]);
3658 function max(array) {
3659 return (array && array.length)
3660 ? baseExtremum(array, identity, baseGt)
3665 * Computes the minimum value of `array`. If `array` is empty or falsey,
3666 * `undefined` is returned.
3672 * @param {Array} array The array to iterate over.
3673 * @returns {*} Returns the minimum value.
3676 * _.min([4, 2, 8, 6]);
3682 function min(array) {
3683 return (array && array.length)
3684 ? baseExtremum(array, identity, baseLt)
3688 /*------------------------------------------------------------------------*/
3690 // Add methods that return wrapped values in chain sequences.
3691 lodash.assignIn = assignIn;
3692 lodash.before = before;
3694 lodash.chain = chain;
3695 lodash.compact = compact;
3696 lodash.concat = concat;
3697 lodash.create = create;
3698 lodash.defaults = defaults;
3699 lodash.defer = defer;
3700 lodash.delay = delay;
3701 lodash.filter = filter;
3702 lodash.flatten = flatten;
3703 lodash.flattenDeep = flattenDeep;
3704 lodash.iteratee = iteratee;
3707 lodash.matches = matches;
3708 lodash.mixin = mixin;
3709 lodash.negate = negate;
3712 lodash.slice = slice;
3713 lodash.sortBy = sortBy;
3716 lodash.toArray = toArray;
3717 lodash.values = values;
3720 lodash.extend = assignIn;
3722 // Add methods to `lodash.prototype`.
3723 mixin(lodash, lodash);
3725 /*------------------------------------------------------------------------*/
3727 // Add methods that return unwrapped values in chain sequences.
3728 lodash.clone = clone;
3729 lodash.escape = escape;
3730 lodash.every = every;
3732 lodash.forEach = forEach;
3735 lodash.identity = identity;
3736 lodash.indexOf = indexOf;
3737 lodash.isArguments = isArguments;
3738 lodash.isArray = isArray;
3739 lodash.isBoolean = isBoolean;
3740 lodash.isDate = isDate;
3741 lodash.isEmpty = isEmpty;
3742 lodash.isEqual = isEqual;
3743 lodash.isFinite = isFinite;
3744 lodash.isFunction = isFunction;
3745 lodash.isNaN = isNaN;
3746 lodash.isNull = isNull;
3747 lodash.isNumber = isNumber;
3748 lodash.isObject = isObject;
3749 lodash.isRegExp = isRegExp;
3750 lodash.isString = isString;
3751 lodash.isUndefined = isUndefined;
3755 lodash.noConflict = noConflict;
3757 lodash.reduce = reduce;
3758 lodash.result = result;
3761 lodash.uniqueId = uniqueId;
3764 lodash.each = forEach;
3765 lodash.first = head;
3767 mixin(lodash, (function() {
3769 baseForOwn(lodash, function(func, methodName) {
3770 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
3771 source[methodName] = func;
3775 }()), { 'chain': false });
3777 /*------------------------------------------------------------------------*/
3780 * The semantic version number.
3786 lodash.VERSION = VERSION;
3788 // Add `Array` methods to `lodash.prototype`.
3789 baseEach(['pop', 'join', 'replace', 'reverse', 'split', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
3790 var func = (/^(?:replace|split)$/.test(methodName) ? String.prototype : arrayProto)[methodName],
3791 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
3792 retUnwrapped = /^(?:pop|join|replace|shift)$/.test(methodName);
3794 lodash.prototype[methodName] = function() {
3795 var args = arguments;
3796 if (retUnwrapped && !this.__chain__) {
3797 var value = this.value();
3798 return func.apply(isArray(value) ? value : [], args);
3800 return this[chainName](function(value) {
3801 return func.apply(isArray(value) ? value : [], args);
3806 // Add chain sequence methods to the `lodash` wrapper.
3807 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
3809 /*--------------------------------------------------------------------------*/
3811 // Some AMD build optimizers, like r.js, check for condition patterns like:
3812 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
3813 // Expose Lodash on the global object to prevent errors when Lodash is
3814 // loaded by a script tag in the presence of an AMD loader.
3815 // See http://requirejs.org/docs/errors.html#mismatch for more details.
3816 // Use `_.noConflict` to remove Lodash from the global object.
3819 // Define as an anonymous module so, through path mapping, it can be
3820 // referenced as the "underscore" module.
3825 // Check for `exports` after `define` in case a build optimizer adds it.
3826 else if (freeModule) {
3827 // Export for Node.js.
3828 (freeModule.exports = lodash)._ = lodash;
3829 // Export for CommonJS support.
3830 freeExports._ = lodash;
3833 // Export to the global object.