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.16.6';
18 /** Error message constants. */
19 var FUNC_ERROR_TEXT = 'Expected a function';
21 /** Used to compose bitmasks for function metadata. */
25 /** Used to compose bitmasks for comparison styles. */
26 var UNORDERED_COMPARE_FLAG = 1,
27 PARTIAL_COMPARE_FLAG = 2;
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 of at least `200` elements
253 * and any iteratees accept only one argument. The heuristic for whether a
254 * section qualifies for shortcut 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 * Used by `_.defaults` to customize its `_.assignIn` use.
403 * @param {*} objValue The destination value.
404 * @param {*} srcValue The source value.
405 * @param {string} key The key of the property to assign.
406 * @param {Object} object The parent object of `objValue`.
407 * @returns {*} Returns the value to assign.
409 function assignInDefaults(objValue, srcValue, key, object) {
410 if (objValue === undefined ||
411 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
418 * Assigns `value` to `key` of `object` if the existing value is not equivalent
419 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
420 * for equality comparisons.
423 * @param {Object} object The object to modify.
424 * @param {string} key The key of the property to assign.
425 * @param {*} value The value to assign.
427 function assignValue(object, key, value) {
428 var objValue = object[key];
429 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
430 (value === undefined && !(key in object))) {
431 baseAssignValue(object, key, value);
436 * The base implementation of `assignValue` and `assignMergeValue` without
440 * @param {Object} object The object to modify.
441 * @param {string} key The key of the property to assign.
442 * @param {*} value The value to assign.
444 function baseAssignValue(object, key, value) {
449 * The base implementation of `_.delay` and `_.defer` which accepts `args`
450 * to provide to `func`.
453 * @param {Function} func The function to delay.
454 * @param {number} wait The number of milliseconds to delay invocation.
455 * @param {Array} args The arguments to provide to `func`.
456 * @returns {number|Object} Returns the timer id or timeout object.
458 function baseDelay(func, wait, args) {
459 if (typeof func != 'function') {
460 throw new TypeError(FUNC_ERROR_TEXT);
462 return setTimeout(function() { func.apply(undefined, args); }, wait);
466 * The base implementation of `_.forEach` without support for iteratee shorthands.
469 * @param {Array|Object} collection The collection to iterate over.
470 * @param {Function} iteratee The function invoked per iteration.
471 * @returns {Array|Object} Returns `collection`.
473 var baseEach = createBaseEach(baseForOwn);
476 * The base implementation of `_.every` without support for iteratee shorthands.
479 * @param {Array|Object} collection The collection to iterate over.
480 * @param {Function} predicate The function invoked per iteration.
481 * @returns {boolean} Returns `true` if all elements pass the predicate check,
484 function baseEvery(collection, predicate) {
486 baseEach(collection, function(value, index, collection) {
487 result = !!predicate(value, index, collection);
494 * The base implementation of methods like `_.max` and `_.min` which accepts a
495 * `comparator` to determine the extremum value.
498 * @param {Array} array The array to iterate over.
499 * @param {Function} iteratee The iteratee invoked per iteration.
500 * @param {Function} comparator The comparator used to compare values.
501 * @returns {*} Returns the extremum value.
503 function baseExtremum(array, iteratee, comparator) {
505 length = array.length;
507 while (++index < length) {
508 var value = array[index],
509 current = iteratee(value);
511 if (current != null && (computed === undefined
512 ? (current === current && !false)
513 : comparator(current, computed)
515 var computed = current,
523 * The base implementation of `_.filter` without support for iteratee shorthands.
526 * @param {Array|Object} collection The collection to iterate over.
527 * @param {Function} predicate The function invoked per iteration.
528 * @returns {Array} Returns the new filtered array.
530 function baseFilter(collection, predicate) {
532 baseEach(collection, function(value, index, collection) {
533 if (predicate(value, index, collection)) {
541 * The base implementation of `_.flatten` with support for restricting flattening.
544 * @param {Array} array The array to flatten.
545 * @param {number} depth The maximum recursion depth.
546 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
547 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
548 * @param {Array} [result=[]] The initial result value.
549 * @returns {Array} Returns the new flattened array.
551 function baseFlatten(array, depth, predicate, isStrict, result) {
553 length = array.length;
555 predicate || (predicate = isFlattenable);
556 result || (result = []);
558 while (++index < length) {
559 var value = array[index];
560 if (depth > 0 && predicate(value)) {
562 // Recursively flatten arrays (susceptible to call stack limits).
563 baseFlatten(value, depth - 1, predicate, isStrict, result);
565 arrayPush(result, value);
567 } else if (!isStrict) {
568 result[result.length] = value;
575 * The base implementation of `baseForOwn` which iterates over `object`
576 * properties returned by `keysFunc` and invokes `iteratee` for each property.
577 * Iteratee functions may exit iteration early by explicitly returning `false`.
580 * @param {Object} object The object to iterate over.
581 * @param {Function} iteratee The function invoked per iteration.
582 * @param {Function} keysFunc The function to get the keys of `object`.
583 * @returns {Object} Returns `object`.
585 var baseFor = createBaseFor();
588 * The base implementation of `_.forOwn` without support for iteratee shorthands.
591 * @param {Object} object The object to iterate over.
592 * @param {Function} iteratee The function invoked per iteration.
593 * @returns {Object} Returns `object`.
595 function baseForOwn(object, iteratee) {
596 return object && baseFor(object, iteratee, keys);
600 * The base implementation of `_.functions` which creates an array of
601 * `object` function property names filtered from `props`.
604 * @param {Object} object The object to inspect.
605 * @param {Array} props The property names to filter.
606 * @returns {Array} Returns the function names.
608 function baseFunctions(object, props) {
609 return baseFilter(props, function(key) {
610 return isFunction(object[key]);
615 * The base implementation of `getTag` without fallbacks for buggy environments.
618 * @param {*} value The value to query.
619 * @returns {string} Returns the `toStringTag`.
621 function baseGetTag(value) {
622 return objectToString(value);
626 * The base implementation of `_.gt` which doesn't coerce arguments.
629 * @param {*} value The value to compare.
630 * @param {*} other The other value to compare.
631 * @returns {boolean} Returns `true` if `value` is greater than `other`,
634 function baseGt(value, other) {
635 return value > other;
639 * The base implementation of `_.isArguments`.
642 * @param {*} value The value to check.
643 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
645 var baseIsArguments = noop;
648 * The base implementation of `_.isDate` without Node.js optimizations.
651 * @param {*} value The value to check.
652 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
654 function baseIsDate(value) {
655 return isObjectLike(value) && baseGetTag(value) == dateTag;
659 * The base implementation of `_.isEqual` which supports partial comparisons
660 * and tracks traversed objects.
663 * @param {*} value The value to compare.
664 * @param {*} other The other value to compare.
665 * @param {Function} [customizer] The function to customize comparisons.
666 * @param {boolean} [bitmask] The bitmask of comparison flags.
667 * The bitmask may be composed of the following flags:
668 * 1 - Unordered comparison
669 * 2 - Partial comparison
670 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
671 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
673 function baseIsEqual(value, other, customizer, bitmask, stack) {
674 if (value === other) {
677 if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
678 return value !== value && other !== other;
680 return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
684 * A specialized version of `baseIsEqual` for arrays and objects which performs
685 * deep comparisons and tracks traversed objects enabling objects with circular
686 * references to be compared.
689 * @param {Object} object The object to compare.
690 * @param {Object} other The other object to compare.
691 * @param {Function} equalFunc The function to determine equivalents of values.
692 * @param {Function} [customizer] The function to customize comparisons.
693 * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
695 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
696 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
698 function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
699 var objIsArr = isArray(object),
700 othIsArr = isArray(other),
705 objTag = baseGetTag(object);
706 objTag = objTag == argsTag ? objectTag : objTag;
709 othTag = baseGetTag(other);
710 othTag = othTag == argsTag ? objectTag : othTag;
712 var objIsObj = objTag == objectTag,
713 othIsObj = othTag == objectTag,
714 isSameTag = objTag == othTag;
716 stack || (stack = []);
717 var objStack = find(stack, function(entry) {
718 return entry[0] == object;
720 var othStack = find(stack, function(entry) {
721 return entry[0] == other;
723 if (objStack && othStack) {
724 return objStack[1] == other;
726 stack.push([object, other]);
727 stack.push([other, object]);
728 if (isSameTag && !objIsObj) {
729 var result = (objIsArr)
730 ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
731 : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
735 if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
736 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
737 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
739 if (objIsWrapped || othIsWrapped) {
740 var objUnwrapped = objIsWrapped ? object.value() : object,
741 othUnwrapped = othIsWrapped ? other.value() : other;
743 var result = equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
751 var result = equalObjects(object, other, equalFunc, customizer, bitmask, stack);
757 * The base implementation of `_.isRegExp` without Node.js optimizations.
760 * @param {*} value The value to check.
761 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
763 function baseIsRegExp(value) {
764 return isObjectLike(value) && baseGetTag(value) == regexpTag;
768 * The base implementation of `_.iteratee`.
771 * @param {*} [value=_.identity] The value to convert to an iteratee.
772 * @returns {Function} Returns the iteratee.
774 function baseIteratee(func) {
775 if (typeof func == 'function') {
781 return (typeof func == 'object' ? baseMatches : baseProperty)(func);
785 * The base implementation of `_.lt` which doesn't coerce arguments.
788 * @param {*} value The value to compare.
789 * @param {*} other The other value to compare.
790 * @returns {boolean} Returns `true` if `value` is less than `other`,
793 function baseLt(value, other) {
794 return value < other;
798 * The base implementation of `_.map` without support for iteratee shorthands.
801 * @param {Array|Object} collection The collection to iterate over.
802 * @param {Function} iteratee The function invoked per iteration.
803 * @returns {Array} Returns the new mapped array.
805 function baseMap(collection, iteratee) {
807 result = isArrayLike(collection) ? Array(collection.length) : [];
809 baseEach(collection, function(value, key, collection) {
810 result[++index] = iteratee(value, key, collection);
816 * The base implementation of `_.matches` which doesn't clone `source`.
819 * @param {Object} source The object of property values to match.
820 * @returns {Function} Returns the new spec function.
822 function baseMatches(source) {
823 var props = nativeKeys(source);
824 return function(object) {
825 var length = props.length;
826 if (object == null) {
829 object = Object(object);
831 var key = props[length];
832 if (!(key in object &&
833 baseIsEqual(source[key], object[key], undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG)
843 * The base implementation of `_.pick` without support for individual
844 * property identifiers.
847 * @param {Object} object The source object.
848 * @param {string[]} props The property identifiers to pick.
849 * @returns {Object} Returns the new object.
851 function basePick(object, props) {
852 object = Object(object);
853 return reduce(props, function(result, key) {
855 result[key] = object[key];
862 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
865 * @param {Function} func The function to apply a rest parameter to.
866 * @param {number} [start=func.length-1] The start position of the rest parameter.
867 * @returns {Function} Returns the new function.
869 function baseRest(func, start) {
870 return setToString(overRest(func, start, identity), func + '');
874 * The base implementation of `_.slice` without an iteratee call guard.
877 * @param {Array} array The array to slice.
878 * @param {number} [start=0] The start position.
879 * @param {number} [end=array.length] The end position.
880 * @returns {Array} Returns the slice of `array`.
882 function baseSlice(array, start, end) {
884 length = array.length;
887 start = -start > length ? 0 : (length + start);
889 end = end > length ? length : end;
893 length = start > end ? 0 : ((end - start) >>> 0);
896 var result = Array(length);
897 while (++index < length) {
898 result[index] = array[index + start];
904 * Copies the values of `source` to `array`.
907 * @param {Array} source The array to copy values from.
908 * @param {Array} [array=[]] The array to copy values to.
909 * @returns {Array} Returns `array`.
911 function copyArray(source) {
912 return baseSlice(source, 0, source.length);
916 * The base implementation of `_.some` without support for iteratee shorthands.
919 * @param {Array|Object} collection The collection to iterate over.
920 * @param {Function} predicate The function invoked per iteration.
921 * @returns {boolean} Returns `true` if any element passes the predicate check,
924 function baseSome(collection, predicate) {
927 baseEach(collection, function(value, index, collection) {
928 result = predicate(value, index, collection);
935 * The base implementation of `wrapperValue` which returns the result of
936 * performing a sequence of actions on the unwrapped `value`, where each
937 * successive action is supplied the return value of the previous.
940 * @param {*} value The unwrapped value.
941 * @param {Array} actions Actions to perform to resolve the unwrapped value.
942 * @returns {*} Returns the resolved value.
944 function baseWrapperValue(value, actions) {
946 return reduce(actions, function(result, action) {
947 return action.func.apply(action.thisArg, arrayPush([result], action.args));
952 * Compares values to sort them in ascending order.
955 * @param {*} value The value to compare.
956 * @param {*} other The other value to compare.
957 * @returns {number} Returns the sort order indicator for `value`.
959 function compareAscending(value, other) {
960 if (value !== other) {
961 var valIsDefined = value !== undefined,
962 valIsNull = value === null,
963 valIsReflexive = value === value,
966 var othIsDefined = other !== undefined,
967 othIsNull = other === null,
968 othIsReflexive = other === other,
971 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
972 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
973 (valIsNull && othIsDefined && othIsReflexive) ||
974 (!valIsDefined && othIsReflexive) ||
978 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
979 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
980 (othIsNull && valIsDefined && valIsReflexive) ||
981 (!othIsDefined && valIsReflexive) ||
990 * Copies properties of `source` to `object`.
993 * @param {Object} source The object to copy properties from.
994 * @param {Array} props The property identifiers to copy.
995 * @param {Object} [object={}] The object to copy properties to.
996 * @param {Function} [customizer] The function to customize copied values.
997 * @returns {Object} Returns `object`.
999 function copyObject(source, props, object, customizer) {
1000 var isNew = !object;
1001 object || (object = {});
1004 length = props.length;
1006 while (++index < length) {
1007 var key = props[index];
1009 var newValue = customizer
1010 ? customizer(object[key], source[key], key, object, source)
1013 if (newValue === undefined) {
1014 newValue = source[key];
1017 baseAssignValue(object, key, newValue);
1019 assignValue(object, key, newValue);
1026 * Creates a function like `_.assign`.
1029 * @param {Function} assigner The function to assign values.
1030 * @returns {Function} Returns the new assigner function.
1032 function createAssigner(assigner) {
1033 return baseRest(function(object, sources) {
1035 length = sources.length,
1036 customizer = length > 1 ? sources[length - 1] : undefined;
1038 customizer = (assigner.length > 3 && typeof customizer == 'function')
1039 ? (length--, customizer)
1042 object = Object(object);
1043 while (++index < length) {
1044 var source = sources[index];
1046 assigner(object, source, index, customizer);
1054 * Creates a `baseEach` or `baseEachRight` function.
1057 * @param {Function} eachFunc The function to iterate over a collection.
1058 * @param {boolean} [fromRight] Specify iterating from right to left.
1059 * @returns {Function} Returns the new base function.
1061 function createBaseEach(eachFunc, fromRight) {
1062 return function(collection, iteratee) {
1063 if (collection == null) {
1066 if (!isArrayLike(collection)) {
1067 return eachFunc(collection, iteratee);
1069 var length = collection.length,
1070 index = fromRight ? length : -1,
1071 iterable = Object(collection);
1073 while ((fromRight ? index-- : ++index < length)) {
1074 if (iteratee(iterable[index], index, iterable) === false) {
1083 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1086 * @param {boolean} [fromRight] Specify iterating from right to left.
1087 * @returns {Function} Returns the new base function.
1089 function createBaseFor(fromRight) {
1090 return function(object, iteratee, keysFunc) {
1092 iterable = Object(object),
1093 props = keysFunc(object),
1094 length = props.length;
1097 var key = props[fromRight ? length : ++index];
1098 if (iteratee(iterable[key], key, iterable) === false) {
1107 * Creates a function that produces an instance of `Ctor` regardless of
1108 * whether it was invoked as part of a `new` expression or by `call` or `apply`.
1111 * @param {Function} Ctor The constructor to wrap.
1112 * @returns {Function} Returns the new wrapped function.
1114 function createCtor(Ctor) {
1116 // Use a `switch` statement to work with class constructors. See
1117 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
1118 // for more details.
1119 var args = arguments;
1120 var thisBinding = baseCreate(Ctor.prototype),
1121 result = Ctor.apply(thisBinding, args);
1123 // Mimic the constructor's `return` behavior.
1124 // See https://es5.github.io/#x13.2.2 for more details.
1125 return isObject(result) ? result : thisBinding;
1130 * Creates a `_.find` or `_.findLast` function.
1133 * @param {Function} findIndexFunc The function to find the collection index.
1134 * @returns {Function} Returns the new find function.
1136 function createFind(findIndexFunc) {
1137 return function(collection, predicate, fromIndex) {
1138 var iterable = Object(collection);
1139 if (!isArrayLike(collection)) {
1140 var iteratee = baseIteratee(predicate, 3);
1141 collection = keys(collection);
1142 predicate = function(key) { return iteratee(iterable[key], key, iterable); };
1144 var index = findIndexFunc(collection, predicate, fromIndex);
1145 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
1150 * Creates a function that wraps `func` to invoke it with the `this` binding
1151 * of `thisArg` and `partials` prepended to the arguments it receives.
1154 * @param {Function} func The function to wrap.
1155 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
1156 * @param {*} thisArg The `this` binding of `func`.
1157 * @param {Array} partials The arguments to prepend to those provided to
1159 * @returns {Function} Returns the new wrapped function.
1161 function createPartial(func, bitmask, thisArg, partials) {
1162 if (typeof func != 'function') {
1163 throw new TypeError(FUNC_ERROR_TEXT);
1165 var isBind = bitmask & BIND_FLAG,
1166 Ctor = createCtor(func);
1168 function wrapper() {
1170 argsLength = arguments.length,
1172 leftLength = partials.length,
1173 args = Array(leftLength + argsLength),
1174 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
1176 while (++leftIndex < leftLength) {
1177 args[leftIndex] = partials[leftIndex];
1179 while (argsLength--) {
1180 args[leftIndex++] = arguments[++argsIndex];
1182 return fn.apply(isBind ? thisArg : this, args);
1188 * A specialized version of `baseIsEqualDeep` for arrays with support for
1189 * partial deep comparisons.
1192 * @param {Array} array The array to compare.
1193 * @param {Array} other The other array to compare.
1194 * @param {Function} equalFunc The function to determine equivalents of values.
1195 * @param {Function} customizer The function to customize comparisons.
1196 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1198 * @param {Object} stack Tracks traversed `array` and `other` objects.
1199 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1201 function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
1202 var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
1203 arrLength = array.length,
1204 othLength = other.length;
1206 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1211 seen = (bitmask & UNORDERED_COMPARE_FLAG) ? [] : undefined;
1213 // Ignore non-index properties.
1214 while (++index < arrLength) {
1215 var arrValue = array[index],
1216 othValue = other[index];
1219 if (compared !== undefined) {
1226 // Recursively compare arrays (susceptible to call stack limits).
1228 if (!baseSome(other, function(othValue, othIndex) {
1229 if (!indexOf(seen, othIndex) &&
1230 (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
1231 return seen.push(othIndex);
1238 arrValue === othValue ||
1239 equalFunc(arrValue, othValue, customizer, bitmask, stack)
1249 * A specialized version of `baseIsEqualDeep` for comparing objects of
1250 * the same `toStringTag`.
1252 * **Note:** This function only supports comparing values with tags of
1253 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1256 * @param {Object} object The object to compare.
1257 * @param {Object} other The other object to compare.
1258 * @param {string} tag The `toStringTag` of the objects to compare.
1259 * @param {Function} equalFunc The function to determine equivalents of values.
1260 * @param {Function} customizer The function to customize comparisons.
1261 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1263 * @param {Object} stack Tracks traversed `object` and `other` objects.
1264 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1266 function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
1272 // Coerce booleans to `1` or `0` and dates to milliseconds.
1273 // Invalid dates are coerced to `NaN`.
1274 return eq(+object, +other);
1277 return object.name == other.name && object.message == other.message;
1281 // Coerce regexes to strings and treat strings, primitives and objects,
1282 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1283 // for more details.
1284 return object == (other + '');
1291 * A specialized version of `baseIsEqualDeep` for objects with support for
1292 * partial deep comparisons.
1295 * @param {Object} object The object to compare.
1296 * @param {Object} other The other object to compare.
1297 * @param {Function} equalFunc The function to determine equivalents of values.
1298 * @param {Function} customizer The function to customize comparisons.
1299 * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
1301 * @param {Object} stack Tracks traversed `object` and `other` objects.
1302 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1304 function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
1305 var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
1306 objProps = keys(object),
1307 objLength = objProps.length,
1308 othProps = keys(other),
1309 othLength = othProps.length;
1311 if (objLength != othLength && !isPartial) {
1314 var index = objLength;
1316 var key = objProps[index];
1317 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1323 var skipCtor = isPartial;
1324 while (++index < objLength) {
1325 key = objProps[index];
1326 var objValue = object[key],
1327 othValue = other[key];
1330 // Recursively compare objects (susceptible to call stack limits).
1331 if (!(compared === undefined
1332 ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
1338 skipCtor || (skipCtor = key == 'constructor');
1340 if (result && !skipCtor) {
1341 var objCtor = object.constructor,
1342 othCtor = other.constructor;
1344 // Non `Object` object instances with different constructors are not equal.
1345 if (objCtor != othCtor &&
1346 ('constructor' in object && 'constructor' in other) &&
1347 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1348 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1356 * A specialized version of `baseRest` which flattens the rest array.
1359 * @param {Function} func The function to apply a rest parameter to.
1360 * @returns {Function} Returns the new function.
1362 function flatRest(func) {
1363 return setToString(overRest(func, undefined, flatten), func + '');
1367 * Checks if `value` is a flattenable `arguments` object or array.
1370 * @param {*} value The value to check.
1371 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
1373 function isFlattenable(value) {
1374 return isArray(value) || isArguments(value);
1378 * This function is like
1379 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1380 * except that it includes inherited enumerable properties.
1383 * @param {Object} object The object to query.
1384 * @returns {Array} Returns the array of property names.
1386 function nativeKeysIn(object) {
1388 if (object != null) {
1389 for (var key in Object(object)) {
1397 * Converts `value` to a string using `Object.prototype.toString`.
1400 * @param {*} value The value to convert.
1401 * @returns {string} Returns the converted string.
1403 function objectToString(value) {
1404 return nativeObjectToString.call(value);
1408 * A specialized version of `baseRest` which transforms the rest array.
1411 * @param {Function} func The function to apply a rest parameter to.
1412 * @param {number} [start=func.length-1] The start position of the rest parameter.
1413 * @param {Function} transform The rest array transform.
1414 * @returns {Function} Returns the new function.
1416 function overRest(func, start, transform) {
1417 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1419 var args = arguments,
1421 length = nativeMax(args.length - start, 0),
1422 array = Array(length);
1424 while (++index < length) {
1425 array[index] = args[start + index];
1428 var otherArgs = Array(start + 1);
1429 while (++index < start) {
1430 otherArgs[index] = args[index];
1432 otherArgs[start] = transform(array);
1433 return func.apply(this, otherArgs);
1438 * Sets the `toString` method of `func` to return `string`.
1441 * @param {Function} func The function to modify.
1442 * @param {Function} string The `toString` result.
1443 * @returns {Function} Returns `func`.
1445 var setToString = identity;
1448 * Converts `value` to a string key if it's not a string or symbol.
1451 * @param {*} value The value to inspect.
1452 * @returns {string|symbol} Returns the key.
1456 /*------------------------------------------------------------------------*/
1459 * Creates an array with all falsey values removed. The values `false`, `null`,
1460 * `0`, `""`, `undefined`, and `NaN` are falsey.
1466 * @param {Array} array The array to compact.
1467 * @returns {Array} Returns the new array of filtered values.
1470 * _.compact([0, 1, false, 2, '', 3]);
1473 function compact(array) {
1474 return baseFilter(array, Boolean);
1478 * Creates a new array concatenating `array` with any additional arrays
1485 * @param {Array} array The array to concatenate.
1486 * @param {...*} [values] The values to concatenate.
1487 * @returns {Array} Returns the new concatenated array.
1491 * var other = _.concat(array, 2, [3], [[4]]);
1493 * console.log(other);
1494 * // => [1, 2, 3, [4]]
1496 * console.log(array);
1500 var length = arguments.length;
1504 var args = Array(length - 1),
1505 array = arguments[0],
1509 args[index - 1] = arguments[index];
1511 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
1515 * This method is like `_.find` except that it returns the index of the first
1516 * element `predicate` returns truthy for instead of the element itself.
1522 * @param {Array} array The array to inspect.
1523 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1524 * @param {number} [fromIndex=0] The index to search from.
1525 * @returns {number} Returns the index of the found element, else `-1`.
1529 * { 'user': 'barney', 'active': false },
1530 * { 'user': 'fred', 'active': false },
1531 * { 'user': 'pebbles', 'active': true }
1534 * _.findIndex(users, function(o) { return o.user == 'barney'; });
1537 * // The `_.matches` iteratee shorthand.
1538 * _.findIndex(users, { 'user': 'fred', 'active': false });
1541 * // The `_.matchesProperty` iteratee shorthand.
1542 * _.findIndex(users, ['active', false]);
1545 * // The `_.property` iteratee shorthand.
1546 * _.findIndex(users, 'active');
1549 function findIndex(array, predicate, fromIndex) {
1550 var length = array == null ? 0 : array.length;
1554 var index = fromIndex == null ? 0 : toInteger(fromIndex);
1556 index = nativeMax(length + index, 0);
1558 return baseFindIndex(array, baseIteratee(predicate, 3), index);
1562 * Flattens `array` a single level deep.
1568 * @param {Array} array The array to flatten.
1569 * @returns {Array} Returns the new flattened array.
1572 * _.flatten([1, [2, [3, [4]], 5]]);
1573 * // => [1, 2, [3, [4]], 5]
1575 function flatten(array) {
1576 var length = array == null ? 0 : array.length;
1577 return length ? baseFlatten(array, 1) : [];
1581 * Recursively flattens `array`.
1587 * @param {Array} array The array to flatten.
1588 * @returns {Array} Returns the new flattened array.
1591 * _.flattenDeep([1, [2, [3, [4]], 5]]);
1592 * // => [1, 2, 3, 4, 5]
1594 function flattenDeep(array) {
1595 var length = array == null ? 0 : array.length;
1596 return length ? baseFlatten(array, INFINITY) : [];
1600 * Gets the first element of `array`.
1607 * @param {Array} array The array to query.
1608 * @returns {*} Returns the first element of `array`.
1611 * _.head([1, 2, 3]);
1617 function head(array) {
1618 return (array && array.length) ? array[0] : undefined;
1622 * Gets the index at which the first occurrence of `value` is found in `array`
1623 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1624 * for equality comparisons. If `fromIndex` is negative, it's used as the
1625 * offset from the end of `array`.
1631 * @param {Array} array The array to inspect.
1632 * @param {*} value The value to search for.
1633 * @param {number} [fromIndex=0] The index to search from.
1634 * @returns {number} Returns the index of the matched value, else `-1`.
1637 * _.indexOf([1, 2, 1, 2], 2);
1640 * // Search from the `fromIndex`.
1641 * _.indexOf([1, 2, 1, 2], 2, 2);
1644 function indexOf(array, value, fromIndex) {
1645 var length = array == null ? 0 : array.length;
1646 if (typeof fromIndex == 'number') {
1647 fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
1651 var index = (fromIndex || 0) - 1,
1652 isReflexive = value === value;
1654 while (++index < length) {
1655 var other = array[index];
1656 if ((isReflexive ? other === value : other !== other)) {
1664 * Gets the last element of `array`.
1670 * @param {Array} array The array to query.
1671 * @returns {*} Returns the last element of `array`.
1674 * _.last([1, 2, 3]);
1677 function last(array) {
1678 var length = array == null ? 0 : array.length;
1679 return length ? array[length - 1] : undefined;
1683 * Creates a slice of `array` from `start` up to, but not including, `end`.
1685 * **Note:** This method is used instead of
1686 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
1693 * @param {Array} array The array to slice.
1694 * @param {number} [start=0] The start position.
1695 * @param {number} [end=array.length] The end position.
1696 * @returns {Array} Returns the slice of `array`.
1698 function slice(array, start, end) {
1699 var length = array == null ? 0 : array.length;
1700 start = start == null ? 0 : +start;
1701 end = end === undefined ? length : +end;
1702 return length ? baseSlice(array, start, end) : [];
1705 /*------------------------------------------------------------------------*/
1708 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
1709 * chain sequences enabled. The result of such sequences must be unwrapped
1716 * @param {*} value The value to wrap.
1717 * @returns {Object} Returns the new `lodash` wrapper instance.
1721 * { 'user': 'barney', 'age': 36 },
1722 * { 'user': 'fred', 'age': 40 },
1723 * { 'user': 'pebbles', 'age': 1 }
1729 * .map(function(o) {
1730 * return o.user + ' is ' + o.age;
1734 * // => 'pebbles is 1'
1736 function chain(value) {
1737 var result = lodash(value);
1738 result.__chain__ = true;
1743 * This method invokes `interceptor` and returns `value`. The interceptor
1744 * is invoked with one argument; (value). The purpose of this method is to
1745 * "tap into" a method chain sequence in order to modify intermediate results.
1751 * @param {*} value The value to provide to `interceptor`.
1752 * @param {Function} interceptor The function to invoke.
1753 * @returns {*} Returns `value`.
1757 * .tap(function(array) {
1758 * // Mutate input array.
1765 function tap(value, interceptor) {
1771 * This method is like `_.tap` except that it returns the result of `interceptor`.
1772 * The purpose of this method is to "pass thru" values replacing intermediate
1773 * results in a method chain sequence.
1779 * @param {*} value The value to provide to `interceptor`.
1780 * @param {Function} interceptor The function to invoke.
1781 * @returns {*} Returns the result of `interceptor`.
1787 * .thru(function(value) {
1793 function thru(value, interceptor) {
1794 return interceptor(value);
1798 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
1804 * @returns {Object} Returns the new `lodash` wrapper instance.
1808 * { 'user': 'barney', 'age': 36 },
1809 * { 'user': 'fred', 'age': 40 }
1812 * // A sequence without explicit chaining.
1814 * // => { 'user': 'barney', 'age': 36 }
1816 * // A sequence with explicit chaining.
1822 * // => { 'user': 'barney' }
1824 function wrapperChain() {
1829 * Executes the chain sequence to resolve the unwrapped value.
1834 * @alias toJSON, valueOf
1836 * @returns {*} Returns the resolved unwrapped value.
1839 * _([1, 2, 3]).value();
1842 function wrapperValue() {
1843 return baseWrapperValue(this.__wrapped__, this.__actions__);
1846 /*------------------------------------------------------------------------*/
1849 * Checks if `predicate` returns truthy for **all** elements of `collection`.
1850 * Iteration is stopped once `predicate` returns falsey. The predicate is
1851 * invoked with three arguments: (value, index|key, collection).
1853 * **Note:** This method returns `true` for
1854 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
1855 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
1856 * elements of empty collections.
1861 * @category Collection
1862 * @param {Array|Object} collection The collection to iterate over.
1863 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1864 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
1865 * @returns {boolean} Returns `true` if all elements pass the predicate check,
1869 * _.every([true, 1, null, 'yes'], Boolean);
1873 * { 'user': 'barney', 'age': 36, 'active': false },
1874 * { 'user': 'fred', 'age': 40, 'active': false }
1877 * // The `_.matches` iteratee shorthand.
1878 * _.every(users, { 'user': 'barney', 'active': false });
1881 * // The `_.matchesProperty` iteratee shorthand.
1882 * _.every(users, ['active', false]);
1885 * // The `_.property` iteratee shorthand.
1886 * _.every(users, 'active');
1889 function every(collection, predicate, guard) {
1890 predicate = guard ? undefined : predicate;
1891 return baseEvery(collection, baseIteratee(predicate));
1895 * Iterates over elements of `collection`, returning an array of all elements
1896 * `predicate` returns truthy for. The predicate is invoked with three
1897 * arguments: (value, index|key, collection).
1899 * **Note:** Unlike `_.remove`, this method returns a new array.
1904 * @category Collection
1905 * @param {Array|Object} collection The collection to iterate over.
1906 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1907 * @returns {Array} Returns the new filtered array.
1912 * { 'user': 'barney', 'age': 36, 'active': true },
1913 * { 'user': 'fred', 'age': 40, 'active': false }
1916 * _.filter(users, function(o) { return !o.active; });
1917 * // => objects for ['fred']
1919 * // The `_.matches` iteratee shorthand.
1920 * _.filter(users, { 'age': 36, 'active': true });
1921 * // => objects for ['barney']
1923 * // The `_.matchesProperty` iteratee shorthand.
1924 * _.filter(users, ['active', false]);
1925 * // => objects for ['fred']
1927 * // The `_.property` iteratee shorthand.
1928 * _.filter(users, 'active');
1929 * // => objects for ['barney']
1931 function filter(collection, predicate) {
1932 return baseFilter(collection, baseIteratee(predicate));
1936 * Iterates over elements of `collection`, returning the first element
1937 * `predicate` returns truthy for. The predicate is invoked with three
1938 * arguments: (value, index|key, collection).
1943 * @category Collection
1944 * @param {Array|Object} collection The collection to inspect.
1945 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1946 * @param {number} [fromIndex=0] The index to search from.
1947 * @returns {*} Returns the matched element, else `undefined`.
1951 * { 'user': 'barney', 'age': 36, 'active': true },
1952 * { 'user': 'fred', 'age': 40, 'active': false },
1953 * { 'user': 'pebbles', 'age': 1, 'active': true }
1956 * _.find(users, function(o) { return o.age < 40; });
1957 * // => object for 'barney'
1959 * // The `_.matches` iteratee shorthand.
1960 * _.find(users, { 'age': 1, 'active': true });
1961 * // => object for 'pebbles'
1963 * // The `_.matchesProperty` iteratee shorthand.
1964 * _.find(users, ['active', false]);
1965 * // => object for 'fred'
1967 * // The `_.property` iteratee shorthand.
1968 * _.find(users, 'active');
1969 * // => object for 'barney'
1971 var find = createFind(findIndex);
1974 * Iterates over elements of `collection` and invokes `iteratee` for each element.
1975 * The iteratee is invoked with three arguments: (value, index|key, collection).
1976 * Iteratee functions may exit iteration early by explicitly returning `false`.
1978 * **Note:** As with other "Collections" methods, objects with a "length"
1979 * property are iterated like arrays. To avoid this behavior use `_.forIn`
1980 * or `_.forOwn` for object iteration.
1986 * @category Collection
1987 * @param {Array|Object} collection The collection to iterate over.
1988 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
1989 * @returns {Array|Object} Returns `collection`.
1990 * @see _.forEachRight
1993 * _.forEach([1, 2], function(value) {
1994 * console.log(value);
1996 * // => Logs `1` then `2`.
1998 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
2001 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
2003 function forEach(collection, iteratee) {
2004 return baseEach(collection, baseIteratee(iteratee));
2008 * Creates an array of values by running each element in `collection` thru
2009 * `iteratee`. The iteratee is invoked with three arguments:
2010 * (value, index|key, collection).
2012 * Many lodash methods are guarded to work as iteratees for methods like
2013 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
2015 * The guarded methods are:
2016 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
2017 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
2018 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
2019 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
2024 * @category Collection
2025 * @param {Array|Object} collection The collection to iterate over.
2026 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2027 * @returns {Array} Returns the new mapped array.
2030 * function square(n) {
2034 * _.map([4, 8], square);
2037 * _.map({ 'a': 4, 'b': 8 }, square);
2038 * // => [16, 64] (iteration order is not guaranteed)
2041 * { 'user': 'barney' },
2042 * { 'user': 'fred' }
2045 * // The `_.property` iteratee shorthand.
2046 * _.map(users, 'user');
2047 * // => ['barney', 'fred']
2049 function map(collection, iteratee) {
2050 return baseMap(collection, baseIteratee(iteratee));
2054 * Reduces `collection` to a value which is the accumulated result of running
2055 * each element in `collection` thru `iteratee`, where each successive
2056 * invocation is supplied the return value of the previous. If `accumulator`
2057 * is not given, the first element of `collection` is used as the initial
2058 * value. The iteratee is invoked with four arguments:
2059 * (accumulator, value, index|key, collection).
2061 * Many lodash methods are guarded to work as iteratees for methods like
2062 * `_.reduce`, `_.reduceRight`, and `_.transform`.
2064 * The guarded methods are:
2065 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
2071 * @category Collection
2072 * @param {Array|Object} collection The collection to iterate over.
2073 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2074 * @param {*} [accumulator] The initial value.
2075 * @returns {*} Returns the accumulated value.
2076 * @see _.reduceRight
2079 * _.reduce([1, 2], function(sum, n) {
2084 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
2085 * (result[value] || (result[value] = [])).push(key);
2088 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
2090 function reduce(collection, iteratee, accumulator) {
2091 return baseReduce(collection, baseIteratee(iteratee), accumulator, arguments.length < 3, baseEach);
2095 * Gets the size of `collection` by returning its length for array-like
2096 * values or the number of own enumerable string keyed properties for objects.
2101 * @category Collection
2102 * @param {Array|Object|string} collection The collection to inspect.
2103 * @returns {number} Returns the collection size.
2106 * _.size([1, 2, 3]);
2109 * _.size({ 'a': 1, 'b': 2 });
2112 * _.size('pebbles');
2115 function size(collection) {
2116 if (collection == null) {
2119 collection = isArrayLike(collection) ? collection : nativeKeys(collection);
2120 return collection.length;
2124 * Checks if `predicate` returns truthy for **any** element of `collection`.
2125 * Iteration is stopped once `predicate` returns truthy. The predicate is
2126 * invoked with three arguments: (value, index|key, collection).
2131 * @category Collection
2132 * @param {Array|Object} collection The collection to iterate over.
2133 * @param {Function} [predicate=_.identity] The function invoked per iteration.
2134 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2135 * @returns {boolean} Returns `true` if any element passes the predicate check,
2139 * _.some([null, 0, 'yes', false], Boolean);
2143 * { 'user': 'barney', 'active': true },
2144 * { 'user': 'fred', 'active': false }
2147 * // The `_.matches` iteratee shorthand.
2148 * _.some(users, { 'user': 'barney', 'active': false });
2151 * // The `_.matchesProperty` iteratee shorthand.
2152 * _.some(users, ['active', false]);
2155 * // The `_.property` iteratee shorthand.
2156 * _.some(users, 'active');
2159 function some(collection, predicate, guard) {
2160 predicate = guard ? undefined : predicate;
2161 return baseSome(collection, baseIteratee(predicate));
2165 * Creates an array of elements, sorted in ascending order by the results of
2166 * running each element in a collection thru each iteratee. This method
2167 * performs a stable sort, that is, it preserves the original sort order of
2168 * equal elements. The iteratees are invoked with one argument: (value).
2173 * @category Collection
2174 * @param {Array|Object} collection The collection to iterate over.
2175 * @param {...(Function|Function[])} [iteratees=[_.identity]]
2176 * The iteratees to sort by.
2177 * @returns {Array} Returns the new sorted array.
2181 * { 'user': 'fred', 'age': 48 },
2182 * { 'user': 'barney', 'age': 36 },
2183 * { 'user': 'fred', 'age': 40 },
2184 * { 'user': 'barney', 'age': 34 }
2187 * _.sortBy(users, [function(o) { return o.user; }]);
2188 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
2190 * _.sortBy(users, ['user', 'age']);
2191 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
2193 function sortBy(collection, iteratee) {
2195 iteratee = baseIteratee(iteratee);
2197 return baseMap(baseMap(collection, function(value, key, collection) {
2198 return { 'value': value, 'index': index++, 'criteria': iteratee(value, key, collection) };
2199 }).sort(function(object, other) {
2200 return compareAscending(object.criteria, other.criteria) || (object.index - other.index);
2201 }), baseProperty('value'));
2204 /*------------------------------------------------------------------------*/
2207 * Creates a function that invokes `func`, with the `this` binding and arguments
2208 * of the created function, while it's called less than `n` times. Subsequent
2209 * calls to the created function return the result of the last `func` invocation.
2214 * @category Function
2215 * @param {number} n The number of calls at which `func` is no longer invoked.
2216 * @param {Function} func The function to restrict.
2217 * @returns {Function} Returns the new restricted function.
2220 * jQuery(element).on('click', _.before(5, addContactToList));
2221 * // => Allows adding up to 4 contacts to the list.
2223 function before(n, func) {
2225 if (typeof func != 'function') {
2226 throw new TypeError(FUNC_ERROR_TEXT);
2231 result = func.apply(this, arguments);
2241 * Creates a function that invokes `func` with the `this` binding of `thisArg`
2242 * and `partials` prepended to the arguments it receives.
2244 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
2245 * may be used as a placeholder for partially applied arguments.
2247 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
2248 * property of bound functions.
2253 * @category Function
2254 * @param {Function} func The function to bind.
2255 * @param {*} thisArg The `this` binding of `func`.
2256 * @param {...*} [partials] The arguments to be partially applied.
2257 * @returns {Function} Returns the new bound function.
2260 * function greet(greeting, punctuation) {
2261 * return greeting + ' ' + this.user + punctuation;
2264 * var object = { 'user': 'fred' };
2266 * var bound = _.bind(greet, object, 'hi');
2270 * // Bound with placeholders.
2271 * var bound = _.bind(greet, object, _, '!');
2275 var bind = baseRest(function(func, thisArg, partials) {
2276 return createPartial(func, BIND_FLAG | PARTIAL_FLAG, thisArg, partials);
2280 * Defers invoking the `func` until the current call stack has cleared. Any
2281 * additional arguments are provided to `func` when it's invoked.
2286 * @category Function
2287 * @param {Function} func The function to defer.
2288 * @param {...*} [args] The arguments to invoke `func` with.
2289 * @returns {number} Returns the timer id.
2292 * _.defer(function(text) {
2293 * console.log(text);
2295 * // => Logs 'deferred' after one millisecond.
2297 var defer = baseRest(function(func, args) {
2298 return baseDelay(func, 1, args);
2302 * Invokes `func` after `wait` milliseconds. Any additional arguments are
2303 * provided to `func` when it's invoked.
2308 * @category Function
2309 * @param {Function} func The function to delay.
2310 * @param {number} wait The number of milliseconds to delay invocation.
2311 * @param {...*} [args] The arguments to invoke `func` with.
2312 * @returns {number} Returns the timer id.
2315 * _.delay(function(text) {
2316 * console.log(text);
2317 * }, 1000, 'later');
2318 * // => Logs 'later' after one second.
2320 var delay = baseRest(function(func, wait, args) {
2321 return baseDelay(func, toNumber(wait) || 0, args);
2325 * Creates a function that negates the result of the predicate `func`. The
2326 * `func` predicate is invoked with the `this` binding and arguments of the
2332 * @category Function
2333 * @param {Function} predicate The predicate to negate.
2334 * @returns {Function} Returns the new negated function.
2337 * function isEven(n) {
2338 * return n % 2 == 0;
2341 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
2344 function negate(predicate) {
2345 if (typeof predicate != 'function') {
2346 throw new TypeError(FUNC_ERROR_TEXT);
2349 var args = arguments;
2350 return !predicate.apply(this, args);
2355 * Creates a function that is restricted to invoking `func` once. Repeat calls
2356 * to the function return the value of the first invocation. The `func` is
2357 * invoked with the `this` binding and arguments of the created function.
2362 * @category Function
2363 * @param {Function} func The function to restrict.
2364 * @returns {Function} Returns the new restricted function.
2367 * var initialize = _.once(createApplication);
2370 * // => `createApplication` is invoked once
2372 function once(func) {
2373 return before(2, func);
2376 /*------------------------------------------------------------------------*/
2379 * Creates a shallow clone of `value`.
2381 * **Note:** This method is loosely based on the
2382 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
2383 * and supports cloning arrays, array buffers, booleans, date objects, maps,
2384 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
2385 * arrays. The own enumerable properties of `arguments` objects are cloned
2386 * as plain objects. An empty object is returned for uncloneable values such
2387 * as error objects, functions, DOM nodes, and WeakMaps.
2393 * @param {*} value The value to clone.
2394 * @returns {*} Returns the cloned value.
2398 * var objects = [{ 'a': 1 }, { 'b': 2 }];
2400 * var shallow = _.clone(objects);
2401 * console.log(shallow[0] === objects[0]);
2404 function clone(value) {
2405 if (!isObject(value)) {
2408 return isArray(value) ? copyArray(value) : copyObject(value, nativeKeys(value));
2413 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2414 * comparison between two values to determine if they are equivalent.
2420 * @param {*} value The value to compare.
2421 * @param {*} other The other value to compare.
2422 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2425 * var object = { 'a': 1 };
2426 * var other = { 'a': 1 };
2428 * _.eq(object, object);
2431 * _.eq(object, other);
2437 * _.eq('a', Object('a'));
2443 function eq(value, other) {
2444 return value === other || (value !== value && other !== other);
2448 * Checks if `value` is likely an `arguments` object.
2454 * @param {*} value The value to check.
2455 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2459 * _.isArguments(function() { return arguments; }());
2462 * _.isArguments([1, 2, 3]);
2465 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
2466 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
2467 !propertyIsEnumerable.call(value, 'callee');
2471 * Checks if `value` is classified as an `Array` object.
2477 * @param {*} value The value to check.
2478 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2481 * _.isArray([1, 2, 3]);
2484 * _.isArray(document.body.children);
2490 * _.isArray(_.noop);
2493 var isArray = Array.isArray;
2496 * Checks if `value` is array-like. A value is considered array-like if it's
2497 * not a function and has a `value.length` that's an integer greater than or
2498 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2504 * @param {*} value The value to check.
2505 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2508 * _.isArrayLike([1, 2, 3]);
2511 * _.isArrayLike(document.body.children);
2514 * _.isArrayLike('abc');
2517 * _.isArrayLike(_.noop);
2520 function isArrayLike(value) {
2521 return value != null && isLength(value.length) && !isFunction(value);
2525 * Checks if `value` is classified as a boolean primitive or object.
2531 * @param {*} value The value to check.
2532 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
2535 * _.isBoolean(false);
2538 * _.isBoolean(null);
2541 function isBoolean(value) {
2542 return value === true || value === false ||
2543 (isObjectLike(value) && baseGetTag(value) == boolTag);
2547 * Checks if `value` is classified as a `Date` object.
2553 * @param {*} value The value to check.
2554 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
2557 * _.isDate(new Date);
2560 * _.isDate('Mon April 23 2012');
2563 var isDate = baseIsDate;
2566 * Checks if `value` is an empty object, collection, map, or set.
2568 * Objects are considered empty if they have no own enumerable string keyed
2571 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
2572 * jQuery-like collections are considered empty if they have a `length` of `0`.
2573 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
2579 * @param {*} value The value to check.
2580 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
2592 * _.isEmpty([1, 2, 3]);
2595 * _.isEmpty({ 'a': 1 });
2598 function isEmpty(value) {
2599 if (isArrayLike(value) &&
2600 (isArray(value) || isString(value) ||
2601 isFunction(value.splice) || isArguments(value))) {
2602 return !value.length;
2604 return !nativeKeys(value).length;
2608 * Performs a deep comparison between two values to determine if they are
2611 * **Note:** This method supports comparing arrays, array buffers, booleans,
2612 * date objects, error objects, maps, numbers, `Object` objects, regexes,
2613 * sets, strings, symbols, and typed arrays. `Object` objects are compared
2614 * by their own, not inherited, enumerable properties. Functions and DOM
2615 * nodes are **not** supported.
2621 * @param {*} value The value to compare.
2622 * @param {*} other The other value to compare.
2623 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2626 * var object = { 'a': 1 };
2627 * var other = { 'a': 1 };
2629 * _.isEqual(object, other);
2635 function isEqual(value, other) {
2636 return baseIsEqual(value, other);
2640 * Checks if `value` is a finite primitive number.
2642 * **Note:** This method is based on
2643 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
2649 * @param {*} value The value to check.
2650 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
2656 * _.isFinite(Number.MIN_VALUE);
2659 * _.isFinite(Infinity);
2665 function isFinite(value) {
2666 return typeof value == 'number' && nativeIsFinite(value);
2670 * Checks if `value` is classified as a `Function` object.
2676 * @param {*} value The value to check.
2677 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2683 * _.isFunction(/abc/);
2686 function isFunction(value) {
2687 if (!isObject(value)) {
2690 // The use of `Object#toString` avoids issues with the `typeof` operator
2691 // in Safari 9 which returns 'object' for typed arrays and other constructors.
2692 var tag = baseGetTag(value);
2693 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
2697 * Checks if `value` is a valid array-like length.
2699 * **Note:** This method is loosely based on
2700 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2706 * @param {*} value The value to check.
2707 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2713 * _.isLength(Number.MIN_VALUE);
2716 * _.isLength(Infinity);
2722 function isLength(value) {
2723 return typeof value == 'number' &&
2724 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2728 * Checks if `value` is the
2729 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2730 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2736 * @param {*} value The value to check.
2737 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2743 * _.isObject([1, 2, 3]);
2746 * _.isObject(_.noop);
2752 function isObject(value) {
2753 var type = typeof value;
2754 return value != null && (type == 'object' || type == 'function');
2758 * Checks if `value` is object-like. A value is object-like if it's not `null`
2759 * and has a `typeof` result of "object".
2765 * @param {*} value The value to check.
2766 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2769 * _.isObjectLike({});
2772 * _.isObjectLike([1, 2, 3]);
2775 * _.isObjectLike(_.noop);
2778 * _.isObjectLike(null);
2781 function isObjectLike(value) {
2782 return value != null && typeof value == 'object';
2786 * Checks if `value` is `NaN`.
2788 * **Note:** This method is based on
2789 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
2790 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
2791 * `undefined` and other non-number values.
2797 * @param {*} value The value to check.
2798 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
2804 * _.isNaN(new Number(NaN));
2810 * _.isNaN(undefined);
2813 function isNaN(value) {
2814 // An `NaN` primitive is the only value that is not equal to itself.
2815 // Perform the `toStringTag` check first to avoid errors with some
2816 // ActiveX objects in IE.
2817 return isNumber(value) && value != +value;
2821 * Checks if `value` is `null`.
2827 * @param {*} value The value to check.
2828 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
2837 function isNull(value) {
2838 return value === null;
2842 * Checks if `value` is classified as a `Number` primitive or object.
2844 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
2845 * classified as numbers, use the `_.isFinite` method.
2851 * @param {*} value The value to check.
2852 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
2858 * _.isNumber(Number.MIN_VALUE);
2861 * _.isNumber(Infinity);
2867 function isNumber(value) {
2868 return typeof value == 'number' ||
2869 (isObjectLike(value) && baseGetTag(value) == numberTag);
2873 * Checks if `value` is classified as a `RegExp` object.
2879 * @param {*} value The value to check.
2880 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
2883 * _.isRegExp(/abc/);
2886 * _.isRegExp('/abc/');
2889 var isRegExp = baseIsRegExp;
2892 * Checks if `value` is classified as a `String` primitive or object.
2898 * @param {*} value The value to check.
2899 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
2902 * _.isString('abc');
2908 function isString(value) {
2909 return typeof value == 'string' ||
2910 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
2914 * Checks if `value` is `undefined`.
2920 * @param {*} value The value to check.
2921 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
2924 * _.isUndefined(void 0);
2927 * _.isUndefined(null);
2930 function isUndefined(value) {
2931 return value === undefined;
2935 * Converts `value` to an array.
2941 * @param {*} value The value to convert.
2942 * @returns {Array} Returns the converted array.
2945 * _.toArray({ 'a': 1, 'b': 2 });
2949 * // => ['a', 'b', 'c']
2957 function toArray(value) {
2958 if (!isArrayLike(value)) {
2959 return values(value);
2961 return value.length ? copyArray(value) : [];
2965 * Converts `value` to an integer.
2967 * **Note:** This method is loosely based on
2968 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
2974 * @param {*} value The value to convert.
2975 * @returns {number} Returns the converted integer.
2981 * _.toInteger(Number.MIN_VALUE);
2984 * _.toInteger(Infinity);
2985 * // => 1.7976931348623157e+308
2987 * _.toInteger('3.2');
2990 var toInteger = Number;
2993 * Converts `value` to a number.
2999 * @param {*} value The value to process.
3000 * @returns {number} Returns the number.
3006 * _.toNumber(Number.MIN_VALUE);
3009 * _.toNumber(Infinity);
3012 * _.toNumber('3.2');
3015 var toNumber = Number;
3018 * Converts `value` to a string. An empty string is returned for `null`
3019 * and `undefined` values. The sign of `-0` is preserved.
3025 * @param {*} value The value to convert.
3026 * @returns {string} Returns the converted string.
3035 * _.toString([1, 2, 3]);
3038 function toString(value) {
3039 if (typeof value == 'string') {
3042 return value == null ? '' : (value + '');
3045 /*------------------------------------------------------------------------*/
3048 * Assigns own enumerable string keyed properties of source objects to the
3049 * destination object. Source objects are applied from left to right.
3050 * Subsequent sources overwrite property assignments of previous sources.
3052 * **Note:** This method mutates `object` and is loosely based on
3053 * [`Object.assign`](https://mdn.io/Object/assign).
3059 * @param {Object} object The destination object.
3060 * @param {...Object} [sources] The source objects.
3061 * @returns {Object} Returns `object`.
3073 * Foo.prototype.b = 2;
3074 * Bar.prototype.d = 4;
3076 * _.assign({ 'a': 0 }, new Foo, new Bar);
3077 * // => { 'a': 1, 'c': 3 }
3079 var assign = createAssigner(function(object, source) {
3080 copyObject(source, nativeKeys(source), object);
3084 * This method is like `_.assign` except that it iterates over own and
3085 * inherited source properties.
3087 * **Note:** This method mutates `object`.
3094 * @param {Object} object The destination object.
3095 * @param {...Object} [sources] The source objects.
3096 * @returns {Object} Returns `object`.
3108 * Foo.prototype.b = 2;
3109 * Bar.prototype.d = 4;
3111 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
3112 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
3114 var assignIn = createAssigner(function(object, source) {
3115 copyObject(source, nativeKeysIn(source), object);
3119 * This method is like `_.assignIn` except that it accepts `customizer`
3120 * which is invoked to produce the assigned values. If `customizer` returns
3121 * `undefined`, assignment is handled by the method instead. The `customizer`
3122 * is invoked with five arguments: (objValue, srcValue, key, object, source).
3124 * **Note:** This method mutates `object`.
3131 * @param {Object} object The destination object.
3132 * @param {...Object} sources The source objects.
3133 * @param {Function} [customizer] The function to customize assigned values.
3134 * @returns {Object} Returns `object`.
3138 * function customizer(objValue, srcValue) {
3139 * return _.isUndefined(objValue) ? srcValue : objValue;
3142 * var defaults = _.partialRight(_.assignInWith, customizer);
3144 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3145 * // => { 'a': 1, 'b': 2 }
3147 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
3148 copyObject(source, keysIn(source), object, customizer);
3152 * Creates an object that inherits from the `prototype` object. If a
3153 * `properties` object is given, its own enumerable string keyed properties
3154 * are assigned to the created object.
3160 * @param {Object} prototype The object to inherit from.
3161 * @param {Object} [properties] The properties to assign to the object.
3162 * @returns {Object} Returns the new object.
3165 * function Shape() {
3170 * function Circle() {
3174 * Circle.prototype = _.create(Shape.prototype, {
3175 * 'constructor': Circle
3178 * var circle = new Circle;
3179 * circle instanceof Circle;
3182 * circle instanceof Shape;
3185 function create(prototype, properties) {
3186 var result = baseCreate(prototype);
3187 return properties == null ? result : assign(result, properties);
3191 * Assigns own and inherited enumerable string keyed properties of source
3192 * objects to the destination object for all destination properties that
3193 * resolve to `undefined`. Source objects are applied from left to right.
3194 * Once a property is set, additional values of the same property are ignored.
3196 * **Note:** This method mutates `object`.
3202 * @param {Object} object The destination object.
3203 * @param {...Object} [sources] The source objects.
3204 * @returns {Object} Returns `object`.
3205 * @see _.defaultsDeep
3208 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3209 * // => { 'a': 1, 'b': 2 }
3211 var defaults = baseRest(function(args) {
3212 args.push(undefined, assignInDefaults);
3213 return assignInWith.apply(undefined, args);
3217 * Checks if `path` is a direct property of `object`.
3223 * @param {Object} object The object to query.
3224 * @param {Array|string} path The path to check.
3225 * @returns {boolean} Returns `true` if `path` exists, else `false`.
3228 * var object = { 'a': { 'b': 2 } };
3229 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
3231 * _.has(object, 'a');
3234 * _.has(object, 'a.b');
3237 * _.has(object, ['a', 'b']);
3240 * _.has(other, 'a');
3243 function has(object, path) {
3244 return object != null && hasOwnProperty.call(object, path);
3248 * Creates an array of the own enumerable property names of `object`.
3250 * **Note:** Non-object values are coerced to objects. See the
3251 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
3258 * @param {Object} object The object to query.
3259 * @returns {Array} Returns the array of property names.
3267 * Foo.prototype.c = 3;
3270 * // => ['a', 'b'] (iteration order is not guaranteed)
3275 var keys = nativeKeys;
3278 * Creates an array of the own and inherited enumerable property names of `object`.
3280 * **Note:** Non-object values are coerced to objects.
3286 * @param {Object} object The object to query.
3287 * @returns {Array} Returns the array of property names.
3295 * Foo.prototype.c = 3;
3297 * _.keysIn(new Foo);
3298 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
3300 var keysIn = nativeKeysIn;
3303 * Creates an object composed of the picked `object` properties.
3309 * @param {Object} object The source object.
3310 * @param {...(string|string[])} [props] The property identifiers to pick.
3311 * @returns {Object} Returns the new object.
3314 * var object = { 'a': 1, 'b': '2', 'c': 3 };
3316 * _.pick(object, ['a', 'c']);
3317 * // => { 'a': 1, 'c': 3 }
3319 var pick = flatRest(function(object, props) {
3320 return object == null ? {} : basePick(object, baseMap(props, toKey));
3324 * This method is like `_.get` except that if the resolved value is a
3325 * function it's invoked with the `this` binding of its parent object and
3326 * its result is returned.
3332 * @param {Object} object The object to query.
3333 * @param {Array|string} path The path of the property to resolve.
3334 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
3335 * @returns {*} Returns the resolved value.
3338 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
3340 * _.result(object, 'a[0].b.c1');
3343 * _.result(object, 'a[0].b.c2');
3346 * _.result(object, 'a[0].b.c3', 'default');
3349 * _.result(object, 'a[0].b.c3', _.constant('default'));
3352 function result(object, path, defaultValue) {
3353 var value = object == null ? undefined : object[path];
3354 if (value === undefined) {
3355 value = defaultValue;
3357 return isFunction(value) ? value.call(object) : value;
3361 * Creates an array of the own enumerable string keyed property values of `object`.
3363 * **Note:** Non-object values are coerced to objects.
3369 * @param {Object} object The object to query.
3370 * @returns {Array} Returns the array of property values.
3378 * Foo.prototype.c = 3;
3380 * _.values(new Foo);
3381 * // => [1, 2] (iteration order is not guaranteed)
3386 function values(object) {
3387 return object == null ? [] : baseValues(object, keys(object));
3390 /*------------------------------------------------------------------------*/
3393 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
3394 * corresponding HTML entities.
3396 * **Note:** No other characters are escaped. To escape additional
3397 * characters use a third-party library like [_he_](https://mths.be/he).
3399 * Though the ">" character is escaped for symmetry, characters like
3400 * ">" and "/" don't need escaping in HTML and have no special meaning
3401 * unless they're part of a tag or unquoted attribute value. See
3402 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
3403 * (under "semi-related fun fact") for more details.
3405 * When working with HTML you should always
3406 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
3413 * @param {string} [string=''] The string to escape.
3414 * @returns {string} Returns the escaped string.
3417 * _.escape('fred, barney, & pebbles');
3418 * // => 'fred, barney, & pebbles'
3420 function escape(string) {
3421 string = toString(string);
3422 return (string && reHasUnescapedHtml.test(string))
3423 ? string.replace(reUnescapedHtml, escapeHtmlChar)
3427 /*------------------------------------------------------------------------*/
3430 * This method returns the first argument it receives.
3436 * @param {*} value Any value.
3437 * @returns {*} Returns `value`.
3440 * var object = { 'a': 1 };
3442 * console.log(_.identity(object) === object);
3445 function identity(value) {
3450 * Creates a function that invokes `func` with the arguments of the created
3451 * function. If `func` is a property name, the created function returns the
3452 * property value for a given element. If `func` is an array or object, the
3453 * created function returns `true` for elements that contain the equivalent
3454 * source properties, otherwise it returns `false`.
3460 * @param {*} [func=_.identity] The value to convert to a callback.
3461 * @returns {Function} Returns the callback.
3465 * { 'user': 'barney', 'age': 36, 'active': true },
3466 * { 'user': 'fred', 'age': 40, 'active': false }
3469 * // The `_.matches` iteratee shorthand.
3470 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
3471 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
3473 * // The `_.matchesProperty` iteratee shorthand.
3474 * _.filter(users, _.iteratee(['user', 'fred']));
3475 * // => [{ 'user': 'fred', 'age': 40 }]
3477 * // The `_.property` iteratee shorthand.
3478 * _.map(users, _.iteratee('user'));
3479 * // => ['barney', 'fred']
3481 * // Create custom iteratee shorthands.
3482 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
3483 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
3484 * return func.test(string);
3488 * _.filter(['abc', 'def'], /ef/);
3491 var iteratee = baseIteratee;
3494 * Creates a function that performs a partial deep comparison between a given
3495 * object and `source`, returning `true` if the given object has equivalent
3496 * property values, else `false`.
3498 * **Note:** The created function is equivalent to `_.isMatch` with `source`
3499 * partially applied.
3501 * Partial comparisons will match empty array and empty object `source`
3502 * values against any array or object value, respectively. See `_.isEqual`
3503 * for a list of supported value comparisons.
3509 * @param {Object} source The object of property values to match.
3510 * @returns {Function} Returns the new spec function.
3514 * { 'a': 1, 'b': 2, 'c': 3 },
3515 * { 'a': 4, 'b': 5, 'c': 6 }
3518 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
3519 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
3521 function matches(source) {
3522 return baseMatches(assign({}, source));
3526 * Adds all own enumerable string keyed function properties of a source
3527 * object to the destination object. If `object` is a function, then methods
3528 * are added to its prototype as well.
3530 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
3531 * avoid conflicts caused by modifying the original.
3537 * @param {Function|Object} [object=lodash] The destination object.
3538 * @param {Object} source The object of functions to add.
3539 * @param {Object} [options={}] The options object.
3540 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
3541 * @returns {Function|Object} Returns `object`.
3544 * function vowels(string) {
3545 * return _.filter(string, function(v) {
3546 * return /[aeiou]/i.test(v);
3550 * _.mixin({ 'vowels': vowels });
3554 * _('fred').vowels().value();
3557 * _.mixin({ 'vowels': vowels }, { 'chain': false });
3558 * _('fred').vowels();
3561 function mixin(object, source, options) {
3562 var props = keys(source),
3563 methodNames = baseFunctions(source, props);
3565 if (options == null &&
3566 !(isObject(source) && (methodNames.length || !props.length))) {
3570 methodNames = baseFunctions(source, keys(source));
3572 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
3573 isFunc = isFunction(object);
3575 baseEach(methodNames, function(methodName) {
3576 var func = source[methodName];
3577 object[methodName] = func;
3579 object.prototype[methodName] = function() {
3580 var chainAll = this.__chain__;
3581 if (chain || chainAll) {
3582 var result = object(this.__wrapped__),
3583 actions = result.__actions__ = copyArray(this.__actions__);
3585 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
3586 result.__chain__ = chainAll;
3589 return func.apply(object, arrayPush([this.value()], arguments));
3598 * Reverts the `_` variable to its previous value and returns a reference to
3599 * the `lodash` function.
3605 * @returns {Function} Returns the `lodash` function.
3608 * var lodash = _.noConflict();
3610 function noConflict() {
3611 if (root._ === this) {
3618 * This method returns `undefined`.
3626 * _.times(2, _.noop);
3627 * // => [undefined, undefined]
3630 // No operation performed.
3634 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
3640 * @param {string} [prefix=''] The value to prefix the ID with.
3641 * @returns {string} Returns the unique ID.
3644 * _.uniqueId('contact_');
3645 * // => 'contact_104'
3650 function uniqueId(prefix) {
3651 var id = ++idCounter;
3652 return toString(prefix) + id;
3655 /*------------------------------------------------------------------------*/
3658 * Computes the maximum value of `array`. If `array` is empty or falsey,
3659 * `undefined` is returned.
3665 * @param {Array} array The array to iterate over.
3666 * @returns {*} Returns the maximum value.
3669 * _.max([4, 2, 8, 6]);
3675 function max(array) {
3676 return (array && array.length)
3677 ? baseExtremum(array, identity, baseGt)
3682 * Computes the minimum value of `array`. If `array` is empty or falsey,
3683 * `undefined` is returned.
3689 * @param {Array} array The array to iterate over.
3690 * @returns {*} Returns the minimum value.
3693 * _.min([4, 2, 8, 6]);
3699 function min(array) {
3700 return (array && array.length)
3701 ? baseExtremum(array, identity, baseLt)
3705 /*------------------------------------------------------------------------*/
3707 // Add methods that return wrapped values in chain sequences.
3708 lodash.assignIn = assignIn;
3709 lodash.before = before;
3711 lodash.chain = chain;
3712 lodash.compact = compact;
3713 lodash.concat = concat;
3714 lodash.create = create;
3715 lodash.defaults = defaults;
3716 lodash.defer = defer;
3717 lodash.delay = delay;
3718 lodash.filter = filter;
3719 lodash.flatten = flatten;
3720 lodash.flattenDeep = flattenDeep;
3721 lodash.iteratee = iteratee;
3724 lodash.matches = matches;
3725 lodash.mixin = mixin;
3726 lodash.negate = negate;
3729 lodash.slice = slice;
3730 lodash.sortBy = sortBy;
3733 lodash.toArray = toArray;
3734 lodash.values = values;
3737 lodash.extend = assignIn;
3739 // Add methods to `lodash.prototype`.
3740 mixin(lodash, lodash);
3742 /*------------------------------------------------------------------------*/
3744 // Add methods that return unwrapped values in chain sequences.
3745 lodash.clone = clone;
3746 lodash.escape = escape;
3747 lodash.every = every;
3749 lodash.forEach = forEach;
3752 lodash.identity = identity;
3753 lodash.indexOf = indexOf;
3754 lodash.isArguments = isArguments;
3755 lodash.isArray = isArray;
3756 lodash.isBoolean = isBoolean;
3757 lodash.isDate = isDate;
3758 lodash.isEmpty = isEmpty;
3759 lodash.isEqual = isEqual;
3760 lodash.isFinite = isFinite;
3761 lodash.isFunction = isFunction;
3762 lodash.isNaN = isNaN;
3763 lodash.isNull = isNull;
3764 lodash.isNumber = isNumber;
3765 lodash.isObject = isObject;
3766 lodash.isRegExp = isRegExp;
3767 lodash.isString = isString;
3768 lodash.isUndefined = isUndefined;
3772 lodash.noConflict = noConflict;
3774 lodash.reduce = reduce;
3775 lodash.result = result;
3778 lodash.uniqueId = uniqueId;
3781 lodash.each = forEach;
3782 lodash.first = head;
3784 mixin(lodash, (function() {
3786 baseForOwn(lodash, function(func, methodName) {
3787 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
3788 source[methodName] = func;
3792 }()), { 'chain': false });
3794 /*------------------------------------------------------------------------*/
3797 * The semantic version number.
3803 lodash.VERSION = VERSION;
3805 // Add `Array` methods to `lodash.prototype`.
3806 baseEach(['pop', 'join', 'replace', 'reverse', 'split', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
3807 var func = (/^(?:replace|split)$/.test(methodName) ? String.prototype : arrayProto)[methodName],
3808 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
3809 retUnwrapped = /^(?:pop|join|replace|shift)$/.test(methodName);
3811 lodash.prototype[methodName] = function() {
3812 var args = arguments;
3813 if (retUnwrapped && !this.__chain__) {
3814 var value = this.value();
3815 return func.apply(isArray(value) ? value : [], args);
3817 return this[chainName](function(value) {
3818 return func.apply(isArray(value) ? value : [], args);
3823 // Add chain sequence methods to the `lodash` wrapper.
3824 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
3826 /*--------------------------------------------------------------------------*/
3828 // Some AMD build optimizers, like r.js, check for condition patterns like:
3829 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
3830 // Expose Lodash on the global object to prevent errors when Lodash is
3831 // loaded by a script tag in the presence of an AMD loader.
3832 // See http://requirejs.org/docs/errors.html#mismatch for more details.
3833 // Use `_.noConflict` to remove Lodash from the global object.
3836 // Define as an anonymous module so, through path mapping, it can be
3837 // referenced as the "underscore" module.
3842 // Check for `exports` after `define` in case a build optimizer adds it.
3843 else if (freeModule) {
3844 // Export for Node.js.
3845 (freeModule.exports = lodash)._ = lodash;
3846 // Export for CommonJS support.
3847 freeExports._ = lodash;
3850 // Export to the global object.