UNPKG

115 kBJavaScriptView Raw
1/**
2 * @license
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
9 */
10;(function() {
11
12 /** Used as a safe reference for `undefined` in pre-ES5 environments. */
13 var undefined;
14
15 /** Used as the semantic version number. */
16 var VERSION = '4.17.0';
17
18 /** Error message constants. */
19 var FUNC_ERROR_TEXT = 'Expected a function';
20
21 /** Used to compose bitmasks for value comparisons. */
22 var COMPARE_PARTIAL_FLAG = 1,
23 COMPARE_UNORDERED_FLAG = 2;
24
25 /** Used to compose bitmasks for function metadata. */
26 var WRAP_BIND_FLAG = 1,
27 WRAP_PARTIAL_FLAG = 32;
28
29 /** Used as references for various `Number` constants. */
30 var INFINITY = 1 / 0,
31 MAX_SAFE_INTEGER = 9007199254740991;
32
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]';
47
48 /** Used to match HTML entities and HTML characters. */
49 var reUnescapedHtml = /[&<>"']/g,
50 reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
51
52 /** Used to map characters to HTML entities. */
53 var htmlEscapes = {
54 '&': '&amp;',
55 '<': '&lt;',
56 '>': '&gt;',
57 '"': '&quot;',
58 "'": '&#39;'
59 };
60
61 /** Detect free variable `global` from Node.js. */
62 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
63
64 /** Detect free variable `self`. */
65 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
66
67 /** Used as a reference to the global object. */
68 var root = freeGlobal || freeSelf || Function('return this')();
69
70 /** Detect free variable `exports`. */
71 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
72
73 /** Detect free variable `module`. */
74 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
75
76 /*--------------------------------------------------------------------------*/
77
78 /**
79 * Appends the elements of `values` to `array`.
80 *
81 * @private
82 * @param {Array} array The array to modify.
83 * @param {Array} values The values to append.
84 * @returns {Array} Returns `array`.
85 */
86 function arrayPush(array, values) {
87 array.push.apply(array, values);
88 return array;
89 }
90
91 /**
92 * The base implementation of `_.findIndex` and `_.findLastIndex` without
93 * support for iteratee shorthands.
94 *
95 * @private
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`.
101 */
102 function baseFindIndex(array, predicate, fromIndex, fromRight) {
103 var length = array.length,
104 index = fromIndex + (fromRight ? 1 : -1);
105
106 while ((fromRight ? index-- : ++index < length)) {
107 if (predicate(array[index], index, array)) {
108 return index;
109 }
110 }
111 return -1;
112 }
113
114 /**
115 * The base implementation of `_.property` without support for deep paths.
116 *
117 * @private
118 * @param {string} key The key of the property to get.
119 * @returns {Function} Returns the new accessor function.
120 */
121 function baseProperty(key) {
122 return function(object) {
123 return object == null ? undefined : object[key];
124 };
125 }
126
127 /**
128 * The base implementation of `_.propertyOf` without support for deep paths.
129 *
130 * @private
131 * @param {Object} object The object to query.
132 * @returns {Function} Returns the new accessor function.
133 */
134 function basePropertyOf(object) {
135 return function(key) {
136 return object == null ? undefined : object[key];
137 };
138 }
139
140 /**
141 * The base implementation of `_.reduce` and `_.reduceRight`, without support
142 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
143 *
144 * @private
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.
152 */
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);
158 });
159 return accumulator;
160 }
161
162 /**
163 * The base implementation of `_.values` and `_.valuesIn` which creates an
164 * array of `object` property values corresponding to the property names
165 * of `props`.
166 *
167 * @private
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.
171 */
172 function baseValues(object, props) {
173 return baseMap(props, function(key) {
174 return object[key];
175 });
176 }
177
178 /**
179 * Used by `_.escape` to convert characters to HTML entities.
180 *
181 * @private
182 * @param {string} chr The matched character to escape.
183 * @returns {string} Returns the escaped character.
184 */
185 var escapeHtmlChar = basePropertyOf(htmlEscapes);
186
187 /**
188 * Creates a unary function that invokes `func` with its argument transformed.
189 *
190 * @private
191 * @param {Function} func The function to wrap.
192 * @param {Function} transform The argument transform.
193 * @returns {Function} Returns the new function.
194 */
195 function overArg(func, transform) {
196 return function(arg) {
197 return func(transform(arg));
198 };
199 }
200
201 /*--------------------------------------------------------------------------*/
202
203 /** Used for built-in method references. */
204 var arrayProto = Array.prototype,
205 objectProto = Object.prototype;
206
207 /** Used to check objects for own properties. */
208 var hasOwnProperty = objectProto.hasOwnProperty;
209
210 /** Used to generate unique IDs. */
211 var idCounter = 0;
212
213 /**
214 * Used to resolve the
215 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
216 * of values.
217 */
218 var nativeObjectToString = objectProto.toString;
219
220 /** Used to restore the original `_` reference in `_.noConflict`. */
221 var oldDash = root._;
222
223 /** Built-in value references. */
224 var objectCreate = Object.create,
225 propertyIsEnumerable = objectProto.propertyIsEnumerable;
226
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;
231
232 /*------------------------------------------------------------------------*/
233
234 /**
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
240 * with `_#value`.
241 *
242 * Explicit chain sequences, which must be unwrapped with `_#value`, may be
243 * enabled using `_.chain`.
244 *
245 * The execution of chained methods is lazy, that is, it's deferred until
246 * `_#value` is implicitly or explicitly called.
247 *
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.
255 *
256 * Chaining is supported in custom builds as long as the `_#value` method is
257 * directly or indirectly included in the build.
258 *
259 * In addition to lodash methods, wrappers have `Array` and `String` methods.
260 *
261 * The wrapper `Array` methods are:
262 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
263 *
264 * The wrapper `String` methods are:
265 * `replace` and `split`
266 *
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`
271 *
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`
297 *
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`
324 *
325 * @name _
326 * @constructor
327 * @category Seq
328 * @param {*} value The value to wrap in a `lodash` instance.
329 * @returns {Object} Returns the new `lodash` wrapper instance.
330 * @example
331 *
332 * function square(n) {
333 * return n * n;
334 * }
335 *
336 * var wrapped = _([1, 2, 3]);
337 *
338 * // Returns an unwrapped value.
339 * wrapped.reduce(_.add);
340 * // => 6
341 *
342 * // Returns a wrapped value.
343 * var squares = wrapped.map(square);
344 *
345 * _.isArray(squares);
346 * // => false
347 *
348 * _.isArray(squares.value());
349 * // => true
350 */
351 function lodash(value) {
352 return value instanceof LodashWrapper
353 ? value
354 : new LodashWrapper(value);
355 }
356
357 /**
358 * The base implementation of `_.create` without support for assigning
359 * properties to the created object.
360 *
361 * @private
362 * @param {Object} proto The object to inherit from.
363 * @returns {Object} Returns the new object.
364 */
365 var baseCreate = (function() {
366 function object() {}
367 return function(proto) {
368 if (!isObject(proto)) {
369 return {};
370 }
371 if (objectCreate) {
372 return objectCreate(proto);
373 }
374 object.prototype = proto;
375 var result = new object;
376 object.prototype = undefined;
377 return result;
378 };
379 }());
380
381 /**
382 * The base constructor for creating `lodash` wrapper objects.
383 *
384 * @private
385 * @param {*} value The value to wrap.
386 * @param {boolean} [chainAll] Enable explicit method chain sequences.
387 */
388 function LodashWrapper(value, chainAll) {
389 this.__wrapped__ = value;
390 this.__actions__ = [];
391 this.__chain__ = !!chainAll;
392 }
393
394 LodashWrapper.prototype = baseCreate(lodash.prototype);
395 LodashWrapper.prototype.constructor = LodashWrapper;
396
397 /*------------------------------------------------------------------------*/
398
399 /**
400 * Used by `_.defaults` to customize its `_.assignIn` use.
401 *
402 * @private
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.
408 */
409 function assignInDefaults(objValue, srcValue, key, object) {
410 if (objValue === undefined ||
411 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
412 return srcValue;
413 }
414 return objValue;
415 }
416
417 /**
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.
421 *
422 * @private
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.
426 */
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);
432 }
433 }
434
435 /**
436 * The base implementation of `assignValue` and `assignMergeValue` without
437 * value checks.
438 *
439 * @private
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.
443 */
444 function baseAssignValue(object, key, value) {
445 object[key] = value;
446 }
447
448 /**
449 * The base implementation of `_.delay` and `_.defer` which accepts `args`
450 * to provide to `func`.
451 *
452 * @private
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.
457 */
458 function baseDelay(func, wait, args) {
459 if (typeof func != 'function') {
460 throw new TypeError(FUNC_ERROR_TEXT);
461 }
462 return setTimeout(function() { func.apply(undefined, args); }, wait);
463 }
464
465 /**
466 * The base implementation of `_.forEach` without support for iteratee shorthands.
467 *
468 * @private
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`.
472 */
473 var baseEach = createBaseEach(baseForOwn);
474
475 /**
476 * The base implementation of `_.every` without support for iteratee shorthands.
477 *
478 * @private
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,
482 * else `false`
483 */
484 function baseEvery(collection, predicate) {
485 var result = true;
486 baseEach(collection, function(value, index, collection) {
487 result = !!predicate(value, index, collection);
488 return result;
489 });
490 return result;
491 }
492
493 /**
494 * The base implementation of methods like `_.max` and `_.min` which accepts a
495 * `comparator` to determine the extremum value.
496 *
497 * @private
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.
502 */
503 function baseExtremum(array, iteratee, comparator) {
504 var index = -1,
505 length = array.length;
506
507 while (++index < length) {
508 var value = array[index],
509 current = iteratee(value);
510
511 if (current != null && (computed === undefined
512 ? (current === current && !false)
513 : comparator(current, computed)
514 )) {
515 var computed = current,
516 result = value;
517 }
518 }
519 return result;
520 }
521
522 /**
523 * The base implementation of `_.filter` without support for iteratee shorthands.
524 *
525 * @private
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.
529 */
530 function baseFilter(collection, predicate) {
531 var result = [];
532 baseEach(collection, function(value, index, collection) {
533 if (predicate(value, index, collection)) {
534 result.push(value);
535 }
536 });
537 return result;
538 }
539
540 /**
541 * The base implementation of `_.flatten` with support for restricting flattening.
542 *
543 * @private
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.
550 */
551 function baseFlatten(array, depth, predicate, isStrict, result) {
552 var index = -1,
553 length = array.length;
554
555 predicate || (predicate = isFlattenable);
556 result || (result = []);
557
558 while (++index < length) {
559 var value = array[index];
560 if (depth > 0 && predicate(value)) {
561 if (depth > 1) {
562 // Recursively flatten arrays (susceptible to call stack limits).
563 baseFlatten(value, depth - 1, predicate, isStrict, result);
564 } else {
565 arrayPush(result, value);
566 }
567 } else if (!isStrict) {
568 result[result.length] = value;
569 }
570 }
571 return result;
572 }
573
574 /**
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`.
578 *
579 * @private
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`.
584 */
585 var baseFor = createBaseFor();
586
587 /**
588 * The base implementation of `_.forOwn` without support for iteratee shorthands.
589 *
590 * @private
591 * @param {Object} object The object to iterate over.
592 * @param {Function} iteratee The function invoked per iteration.
593 * @returns {Object} Returns `object`.
594 */
595 function baseForOwn(object, iteratee) {
596 return object && baseFor(object, iteratee, keys);
597 }
598
599 /**
600 * The base implementation of `_.functions` which creates an array of
601 * `object` function property names filtered from `props`.
602 *
603 * @private
604 * @param {Object} object The object to inspect.
605 * @param {Array} props The property names to filter.
606 * @returns {Array} Returns the function names.
607 */
608 function baseFunctions(object, props) {
609 return baseFilter(props, function(key) {
610 return isFunction(object[key]);
611 });
612 }
613
614 /**
615 * The base implementation of `getTag` without fallbacks for buggy environments.
616 *
617 * @private
618 * @param {*} value The value to query.
619 * @returns {string} Returns the `toStringTag`.
620 */
621 function baseGetTag(value) {
622 return objectToString(value);
623 }
624
625 /**
626 * The base implementation of `_.gt` which doesn't coerce arguments.
627 *
628 * @private
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`,
632 * else `false`.
633 */
634 function baseGt(value, other) {
635 return value > other;
636 }
637
638 /**
639 * The base implementation of `_.isArguments`.
640 *
641 * @private
642 * @param {*} value The value to check.
643 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
644 */
645 var baseIsArguments = noop;
646
647 /**
648 * The base implementation of `_.isDate` without Node.js optimizations.
649 *
650 * @private
651 * @param {*} value The value to check.
652 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
653 */
654 function baseIsDate(value) {
655 return isObjectLike(value) && baseGetTag(value) == dateTag;
656 }
657
658 /**
659 * The base implementation of `_.isEqual` which supports partial comparisons
660 * and tracks traversed objects.
661 *
662 * @private
663 * @param {*} value The value to compare.
664 * @param {*} other The other value to compare.
665 * @param {boolean} bitmask The bitmask flags.
666 * 1 - Unordered comparison
667 * 2 - Partial comparison
668 * @param {Function} [customizer] The function to customize comparisons.
669 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
670 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
671 */
672 function baseIsEqual(value, other, bitmask, customizer, stack) {
673 if (value === other) {
674 return true;
675 }
676 if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
677 return value !== value && other !== other;
678 }
679 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
680 }
681
682 /**
683 * A specialized version of `baseIsEqual` for arrays and objects which performs
684 * deep comparisons and tracks traversed objects enabling objects with circular
685 * references to be compared.
686 *
687 * @private
688 * @param {Object} object The object to compare.
689 * @param {Object} other The other object to compare.
690 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
691 * @param {Function} customizer The function to customize comparisons.
692 * @param {Function} equalFunc The function to determine equivalents of values.
693 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
694 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
695 */
696 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
697 var objIsArr = isArray(object),
698 othIsArr = isArray(other),
699 objTag = arrayTag,
700 othTag = arrayTag;
701
702 if (!objIsArr) {
703 objTag = baseGetTag(object);
704 objTag = objTag == argsTag ? objectTag : objTag;
705 }
706 if (!othIsArr) {
707 othTag = baseGetTag(other);
708 othTag = othTag == argsTag ? objectTag : othTag;
709 }
710 var objIsObj = objTag == objectTag,
711 othIsObj = othTag == objectTag,
712 isSameTag = objTag == othTag;
713
714 stack || (stack = []);
715 var objStack = find(stack, function(entry) {
716 return entry[0] == object;
717 });
718 var othStack = find(stack, function(entry) {
719 return entry[0] == other;
720 });
721 if (objStack && othStack) {
722 return objStack[1] == other;
723 }
724 stack.push([object, other]);
725 stack.push([other, object]);
726 if (isSameTag && !objIsObj) {
727 var result = (objIsArr)
728 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
729 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
730 stack.pop();
731 return result;
732 }
733 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
734 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
735 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
736
737 if (objIsWrapped || othIsWrapped) {
738 var objUnwrapped = objIsWrapped ? object.value() : object,
739 othUnwrapped = othIsWrapped ? other.value() : other;
740
741 var result = equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
742 stack.pop();
743 return result;
744 }
745 }
746 if (!isSameTag) {
747 return false;
748 }
749 var result = equalObjects(object, other, bitmask, customizer, equalFunc, stack);
750 stack.pop();
751 return result;
752 }
753
754 /**
755 * The base implementation of `_.isRegExp` without Node.js optimizations.
756 *
757 * @private
758 * @param {*} value The value to check.
759 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
760 */
761 function baseIsRegExp(value) {
762 return isObjectLike(value) && baseGetTag(value) == regexpTag;
763 }
764
765 /**
766 * The base implementation of `_.iteratee`.
767 *
768 * @private
769 * @param {*} [value=_.identity] The value to convert to an iteratee.
770 * @returns {Function} Returns the iteratee.
771 */
772 function baseIteratee(func) {
773 if (typeof func == 'function') {
774 return func;
775 }
776 if (func == null) {
777 return identity;
778 }
779 return (typeof func == 'object' ? baseMatches : baseProperty)(func);
780 }
781
782 /**
783 * The base implementation of `_.lt` which doesn't coerce arguments.
784 *
785 * @private
786 * @param {*} value The value to compare.
787 * @param {*} other The other value to compare.
788 * @returns {boolean} Returns `true` if `value` is less than `other`,
789 * else `false`.
790 */
791 function baseLt(value, other) {
792 return value < other;
793 }
794
795 /**
796 * The base implementation of `_.map` without support for iteratee shorthands.
797 *
798 * @private
799 * @param {Array|Object} collection The collection to iterate over.
800 * @param {Function} iteratee The function invoked per iteration.
801 * @returns {Array} Returns the new mapped array.
802 */
803 function baseMap(collection, iteratee) {
804 var index = -1,
805 result = isArrayLike(collection) ? Array(collection.length) : [];
806
807 baseEach(collection, function(value, key, collection) {
808 result[++index] = iteratee(value, key, collection);
809 });
810 return result;
811 }
812
813 /**
814 * The base implementation of `_.matches` which doesn't clone `source`.
815 *
816 * @private
817 * @param {Object} source The object of property values to match.
818 * @returns {Function} Returns the new spec function.
819 */
820 function baseMatches(source) {
821 var props = nativeKeys(source);
822 return function(object) {
823 var length = props.length;
824 if (object == null) {
825 return !length;
826 }
827 object = Object(object);
828 while (length--) {
829 var key = props[length];
830 if (!(key in object &&
831 baseIsEqual(source[key], object[key], COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG)
832 )) {
833 return false;
834 }
835 }
836 return true;
837 };
838 }
839
840 /**
841 * The base implementation of `_.pick` without support for individual
842 * property identifiers.
843 *
844 * @private
845 * @param {Object} object The source object.
846 * @param {string[]} paths The property paths to pick.
847 * @returns {Object} Returns the new object.
848 */
849 function basePick(object, props) {
850 object = Object(object);
851 return reduce(props, function(result, key) {
852 if (key in object) {
853 result[key] = object[key];
854 }
855 return result;
856 }, {});
857 }
858
859 /**
860 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
861 *
862 * @private
863 * @param {Function} func The function to apply a rest parameter to.
864 * @param {number} [start=func.length-1] The start position of the rest parameter.
865 * @returns {Function} Returns the new function.
866 */
867 function baseRest(func, start) {
868 return setToString(overRest(func, start, identity), func + '');
869 }
870
871 /**
872 * The base implementation of `_.slice` without an iteratee call guard.
873 *
874 * @private
875 * @param {Array} array The array to slice.
876 * @param {number} [start=0] The start position.
877 * @param {number} [end=array.length] The end position.
878 * @returns {Array} Returns the slice of `array`.
879 */
880 function baseSlice(array, start, end) {
881 var index = -1,
882 length = array.length;
883
884 if (start < 0) {
885 start = -start > length ? 0 : (length + start);
886 }
887 end = end > length ? length : end;
888 if (end < 0) {
889 end += length;
890 }
891 length = start > end ? 0 : ((end - start) >>> 0);
892 start >>>= 0;
893
894 var result = Array(length);
895 while (++index < length) {
896 result[index] = array[index + start];
897 }
898 return result;
899 }
900
901 /**
902 * Copies the values of `source` to `array`.
903 *
904 * @private
905 * @param {Array} source The array to copy values from.
906 * @param {Array} [array=[]] The array to copy values to.
907 * @returns {Array} Returns `array`.
908 */
909 function copyArray(source) {
910 return baseSlice(source, 0, source.length);
911 }
912
913 /**
914 * The base implementation of `_.some` without support for iteratee shorthands.
915 *
916 * @private
917 * @param {Array|Object} collection The collection to iterate over.
918 * @param {Function} predicate The function invoked per iteration.
919 * @returns {boolean} Returns `true` if any element passes the predicate check,
920 * else `false`.
921 */
922 function baseSome(collection, predicate) {
923 var result;
924
925 baseEach(collection, function(value, index, collection) {
926 result = predicate(value, index, collection);
927 return !result;
928 });
929 return !!result;
930 }
931
932 /**
933 * The base implementation of `wrapperValue` which returns the result of
934 * performing a sequence of actions on the unwrapped `value`, where each
935 * successive action is supplied the return value of the previous.
936 *
937 * @private
938 * @param {*} value The unwrapped value.
939 * @param {Array} actions Actions to perform to resolve the unwrapped value.
940 * @returns {*} Returns the resolved value.
941 */
942 function baseWrapperValue(value, actions) {
943 var result = value;
944 return reduce(actions, function(result, action) {
945 return action.func.apply(action.thisArg, arrayPush([result], action.args));
946 }, result);
947 }
948
949 /**
950 * Compares values to sort them in ascending order.
951 *
952 * @private
953 * @param {*} value The value to compare.
954 * @param {*} other The other value to compare.
955 * @returns {number} Returns the sort order indicator for `value`.
956 */
957 function compareAscending(value, other) {
958 if (value !== other) {
959 var valIsDefined = value !== undefined,
960 valIsNull = value === null,
961 valIsReflexive = value === value,
962 valIsSymbol = false;
963
964 var othIsDefined = other !== undefined,
965 othIsNull = other === null,
966 othIsReflexive = other === other,
967 othIsSymbol = false;
968
969 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
970 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
971 (valIsNull && othIsDefined && othIsReflexive) ||
972 (!valIsDefined && othIsReflexive) ||
973 !valIsReflexive) {
974 return 1;
975 }
976 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
977 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
978 (othIsNull && valIsDefined && valIsReflexive) ||
979 (!othIsDefined && valIsReflexive) ||
980 !othIsReflexive) {
981 return -1;
982 }
983 }
984 return 0;
985 }
986
987 /**
988 * Copies properties of `source` to `object`.
989 *
990 * @private
991 * @param {Object} source The object to copy properties from.
992 * @param {Array} props The property identifiers to copy.
993 * @param {Object} [object={}] The object to copy properties to.
994 * @param {Function} [customizer] The function to customize copied values.
995 * @returns {Object} Returns `object`.
996 */
997 function copyObject(source, props, object, customizer) {
998 var isNew = !object;
999 object || (object = {});
1000
1001 var index = -1,
1002 length = props.length;
1003
1004 while (++index < length) {
1005 var key = props[index];
1006
1007 var newValue = customizer
1008 ? customizer(object[key], source[key], key, object, source)
1009 : undefined;
1010
1011 if (newValue === undefined) {
1012 newValue = source[key];
1013 }
1014 if (isNew) {
1015 baseAssignValue(object, key, newValue);
1016 } else {
1017 assignValue(object, key, newValue);
1018 }
1019 }
1020 return object;
1021 }
1022
1023 /**
1024 * Creates a function like `_.assign`.
1025 *
1026 * @private
1027 * @param {Function} assigner The function to assign values.
1028 * @returns {Function} Returns the new assigner function.
1029 */
1030 function createAssigner(assigner) {
1031 return baseRest(function(object, sources) {
1032 var index = -1,
1033 length = sources.length,
1034 customizer = length > 1 ? sources[length - 1] : undefined;
1035
1036 customizer = (assigner.length > 3 && typeof customizer == 'function')
1037 ? (length--, customizer)
1038 : undefined;
1039
1040 object = Object(object);
1041 while (++index < length) {
1042 var source = sources[index];
1043 if (source) {
1044 assigner(object, source, index, customizer);
1045 }
1046 }
1047 return object;
1048 });
1049 }
1050
1051 /**
1052 * Creates a `baseEach` or `baseEachRight` function.
1053 *
1054 * @private
1055 * @param {Function} eachFunc The function to iterate over a collection.
1056 * @param {boolean} [fromRight] Specify iterating from right to left.
1057 * @returns {Function} Returns the new base function.
1058 */
1059 function createBaseEach(eachFunc, fromRight) {
1060 return function(collection, iteratee) {
1061 if (collection == null) {
1062 return collection;
1063 }
1064 if (!isArrayLike(collection)) {
1065 return eachFunc(collection, iteratee);
1066 }
1067 var length = collection.length,
1068 index = fromRight ? length : -1,
1069 iterable = Object(collection);
1070
1071 while ((fromRight ? index-- : ++index < length)) {
1072 if (iteratee(iterable[index], index, iterable) === false) {
1073 break;
1074 }
1075 }
1076 return collection;
1077 };
1078 }
1079
1080 /**
1081 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1082 *
1083 * @private
1084 * @param {boolean} [fromRight] Specify iterating from right to left.
1085 * @returns {Function} Returns the new base function.
1086 */
1087 function createBaseFor(fromRight) {
1088 return function(object, iteratee, keysFunc) {
1089 var index = -1,
1090 iterable = Object(object),
1091 props = keysFunc(object),
1092 length = props.length;
1093
1094 while (length--) {
1095 var key = props[fromRight ? length : ++index];
1096 if (iteratee(iterable[key], key, iterable) === false) {
1097 break;
1098 }
1099 }
1100 return object;
1101 };
1102 }
1103
1104 /**
1105 * Creates a function that produces an instance of `Ctor` regardless of
1106 * whether it was invoked as part of a `new` expression or by `call` or `apply`.
1107 *
1108 * @private
1109 * @param {Function} Ctor The constructor to wrap.
1110 * @returns {Function} Returns the new wrapped function.
1111 */
1112 function createCtor(Ctor) {
1113 return function() {
1114 // Use a `switch` statement to work with class constructors. See
1115 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
1116 // for more details.
1117 var args = arguments;
1118 var thisBinding = baseCreate(Ctor.prototype),
1119 result = Ctor.apply(thisBinding, args);
1120
1121 // Mimic the constructor's `return` behavior.
1122 // See https://es5.github.io/#x13.2.2 for more details.
1123 return isObject(result) ? result : thisBinding;
1124 };
1125 }
1126
1127 /**
1128 * Creates a `_.find` or `_.findLast` function.
1129 *
1130 * @private
1131 * @param {Function} findIndexFunc The function to find the collection index.
1132 * @returns {Function} Returns the new find function.
1133 */
1134 function createFind(findIndexFunc) {
1135 return function(collection, predicate, fromIndex) {
1136 var iterable = Object(collection);
1137 if (!isArrayLike(collection)) {
1138 var iteratee = baseIteratee(predicate, 3);
1139 collection = keys(collection);
1140 predicate = function(key) { return iteratee(iterable[key], key, iterable); };
1141 }
1142 var index = findIndexFunc(collection, predicate, fromIndex);
1143 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
1144 };
1145 }
1146
1147 /**
1148 * Creates a function that wraps `func` to invoke it with the `this` binding
1149 * of `thisArg` and `partials` prepended to the arguments it receives.
1150 *
1151 * @private
1152 * @param {Function} func The function to wrap.
1153 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
1154 * @param {*} thisArg The `this` binding of `func`.
1155 * @param {Array} partials The arguments to prepend to those provided to
1156 * the new function.
1157 * @returns {Function} Returns the new wrapped function.
1158 */
1159 function createPartial(func, bitmask, thisArg, partials) {
1160 if (typeof func != 'function') {
1161 throw new TypeError(FUNC_ERROR_TEXT);
1162 }
1163 var isBind = bitmask & WRAP_BIND_FLAG,
1164 Ctor = createCtor(func);
1165
1166 function wrapper() {
1167 var argsIndex = -1,
1168 argsLength = arguments.length,
1169 leftIndex = -1,
1170 leftLength = partials.length,
1171 args = Array(leftLength + argsLength),
1172 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
1173
1174 while (++leftIndex < leftLength) {
1175 args[leftIndex] = partials[leftIndex];
1176 }
1177 while (argsLength--) {
1178 args[leftIndex++] = arguments[++argsIndex];
1179 }
1180 return fn.apply(isBind ? thisArg : this, args);
1181 }
1182 return wrapper;
1183 }
1184
1185 /**
1186 * A specialized version of `baseIsEqualDeep` for arrays with support for
1187 * partial deep comparisons.
1188 *
1189 * @private
1190 * @param {Array} array The array to compare.
1191 * @param {Array} other The other array to compare.
1192 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1193 * @param {Function} customizer The function to customize comparisons.
1194 * @param {Function} equalFunc The function to determine equivalents of values.
1195 * @param {Object} stack Tracks traversed `array` and `other` objects.
1196 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1197 */
1198 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1199 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1200 arrLength = array.length,
1201 othLength = other.length;
1202
1203 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1204 return false;
1205 }
1206 var index = -1,
1207 result = true,
1208 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? [] : undefined;
1209
1210 // Ignore non-index properties.
1211 while (++index < arrLength) {
1212 var arrValue = array[index],
1213 othValue = other[index];
1214
1215 var compared;
1216 if (compared !== undefined) {
1217 if (compared) {
1218 continue;
1219 }
1220 result = false;
1221 break;
1222 }
1223 // Recursively compare arrays (susceptible to call stack limits).
1224 if (seen) {
1225 if (!baseSome(other, function(othValue, othIndex) {
1226 if (!indexOf(seen, othIndex) &&
1227 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1228 return seen.push(othIndex);
1229 }
1230 })) {
1231 result = false;
1232 break;
1233 }
1234 } else if (!(
1235 arrValue === othValue ||
1236 equalFunc(arrValue, othValue, bitmask, customizer, stack)
1237 )) {
1238 result = false;
1239 break;
1240 }
1241 }
1242 return result;
1243 }
1244
1245 /**
1246 * A specialized version of `baseIsEqualDeep` for comparing objects of
1247 * the same `toStringTag`.
1248 *
1249 * **Note:** This function only supports comparing values with tags of
1250 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1251 *
1252 * @private
1253 * @param {Object} object The object to compare.
1254 * @param {Object} other The other object to compare.
1255 * @param {string} tag The `toStringTag` of the objects to compare.
1256 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1257 * @param {Function} customizer The function to customize comparisons.
1258 * @param {Function} equalFunc The function to determine equivalents of values.
1259 * @param {Object} stack Tracks traversed `object` and `other` objects.
1260 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1261 */
1262 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1263 switch (tag) {
1264
1265 case boolTag:
1266 case dateTag:
1267 case numberTag:
1268 // Coerce booleans to `1` or `0` and dates to milliseconds.
1269 // Invalid dates are coerced to `NaN`.
1270 return eq(+object, +other);
1271
1272 case errorTag:
1273 return object.name == other.name && object.message == other.message;
1274
1275 case regexpTag:
1276 case stringTag:
1277 // Coerce regexes to strings and treat strings, primitives and objects,
1278 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1279 // for more details.
1280 return object == (other + '');
1281
1282 }
1283 return false;
1284 }
1285
1286 /**
1287 * A specialized version of `baseIsEqualDeep` for objects with support for
1288 * partial deep comparisons.
1289 *
1290 * @private
1291 * @param {Object} object The object to compare.
1292 * @param {Object} other The other object to compare.
1293 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1294 * @param {Function} customizer The function to customize comparisons.
1295 * @param {Function} equalFunc The function to determine equivalents of values.
1296 * @param {Object} stack Tracks traversed `object` and `other` objects.
1297 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1298 */
1299 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1300 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1301 objProps = keys(object),
1302 objLength = objProps.length,
1303 othProps = keys(other),
1304 othLength = othProps.length;
1305
1306 if (objLength != othLength && !isPartial) {
1307 return false;
1308 }
1309 var index = objLength;
1310 while (index--) {
1311 var key = objProps[index];
1312 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1313 return false;
1314 }
1315 }
1316 var result = true;
1317
1318 var skipCtor = isPartial;
1319 while (++index < objLength) {
1320 key = objProps[index];
1321 var objValue = object[key],
1322 othValue = other[key];
1323
1324 var compared;
1325 // Recursively compare objects (susceptible to call stack limits).
1326 if (!(compared === undefined
1327 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
1328 : compared
1329 )) {
1330 result = false;
1331 break;
1332 }
1333 skipCtor || (skipCtor = key == 'constructor');
1334 }
1335 if (result && !skipCtor) {
1336 var objCtor = object.constructor,
1337 othCtor = other.constructor;
1338
1339 // Non `Object` object instances with different constructors are not equal.
1340 if (objCtor != othCtor &&
1341 ('constructor' in object && 'constructor' in other) &&
1342 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1343 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1344 result = false;
1345 }
1346 }
1347 return result;
1348 }
1349
1350 /**
1351 * A specialized version of `baseRest` which flattens the rest array.
1352 *
1353 * @private
1354 * @param {Function} func The function to apply a rest parameter to.
1355 * @returns {Function} Returns the new function.
1356 */
1357 function flatRest(func) {
1358 return setToString(overRest(func, undefined, flatten), func + '');
1359 }
1360
1361 /**
1362 * Checks if `value` is a flattenable `arguments` object or array.
1363 *
1364 * @private
1365 * @param {*} value The value to check.
1366 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
1367 */
1368 function isFlattenable(value) {
1369 return isArray(value) || isArguments(value);
1370 }
1371
1372 /**
1373 * This function is like
1374 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1375 * except that it includes inherited enumerable properties.
1376 *
1377 * @private
1378 * @param {Object} object The object to query.
1379 * @returns {Array} Returns the array of property names.
1380 */
1381 function nativeKeysIn(object) {
1382 var result = [];
1383 if (object != null) {
1384 for (var key in Object(object)) {
1385 result.push(key);
1386 }
1387 }
1388 return result;
1389 }
1390
1391 /**
1392 * Converts `value` to a string using `Object.prototype.toString`.
1393 *
1394 * @private
1395 * @param {*} value The value to convert.
1396 * @returns {string} Returns the converted string.
1397 */
1398 function objectToString(value) {
1399 return nativeObjectToString.call(value);
1400 }
1401
1402 /**
1403 * A specialized version of `baseRest` which transforms the rest array.
1404 *
1405 * @private
1406 * @param {Function} func The function to apply a rest parameter to.
1407 * @param {number} [start=func.length-1] The start position of the rest parameter.
1408 * @param {Function} transform The rest array transform.
1409 * @returns {Function} Returns the new function.
1410 */
1411 function overRest(func, start, transform) {
1412 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1413 return function() {
1414 var args = arguments,
1415 index = -1,
1416 length = nativeMax(args.length - start, 0),
1417 array = Array(length);
1418
1419 while (++index < length) {
1420 array[index] = args[start + index];
1421 }
1422 index = -1;
1423 var otherArgs = Array(start + 1);
1424 while (++index < start) {
1425 otherArgs[index] = args[index];
1426 }
1427 otherArgs[start] = transform(array);
1428 return func.apply(this, otherArgs);
1429 };
1430 }
1431
1432 /**
1433 * Sets the `toString` method of `func` to return `string`.
1434 *
1435 * @private
1436 * @param {Function} func The function to modify.
1437 * @param {Function} string The `toString` result.
1438 * @returns {Function} Returns `func`.
1439 */
1440 var setToString = identity;
1441
1442 /**
1443 * Converts `value` to a string key if it's not a string or symbol.
1444 *
1445 * @private
1446 * @param {*} value The value to inspect.
1447 * @returns {string|symbol} Returns the key.
1448 */
1449 var toKey = String;
1450
1451 /*------------------------------------------------------------------------*/
1452
1453 /**
1454 * Creates an array with all falsey values removed. The values `false`, `null`,
1455 * `0`, `""`, `undefined`, and `NaN` are falsey.
1456 *
1457 * @static
1458 * @memberOf _
1459 * @since 0.1.0
1460 * @category Array
1461 * @param {Array} array The array to compact.
1462 * @returns {Array} Returns the new array of filtered values.
1463 * @example
1464 *
1465 * _.compact([0, 1, false, 2, '', 3]);
1466 * // => [1, 2, 3]
1467 */
1468 function compact(array) {
1469 return baseFilter(array, Boolean);
1470 }
1471
1472 /**
1473 * Creates a new array concatenating `array` with any additional arrays
1474 * and/or values.
1475 *
1476 * @static
1477 * @memberOf _
1478 * @since 4.0.0
1479 * @category Array
1480 * @param {Array} array The array to concatenate.
1481 * @param {...*} [values] The values to concatenate.
1482 * @returns {Array} Returns the new concatenated array.
1483 * @example
1484 *
1485 * var array = [1];
1486 * var other = _.concat(array, 2, [3], [[4]]);
1487 *
1488 * console.log(other);
1489 * // => [1, 2, 3, [4]]
1490 *
1491 * console.log(array);
1492 * // => [1]
1493 */
1494 function concat() {
1495 var length = arguments.length;
1496 if (!length) {
1497 return [];
1498 }
1499 var args = Array(length - 1),
1500 array = arguments[0],
1501 index = length;
1502
1503 while (index--) {
1504 args[index - 1] = arguments[index];
1505 }
1506 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
1507 }
1508
1509 /**
1510 * This method is like `_.find` except that it returns the index of the first
1511 * element `predicate` returns truthy for instead of the element itself.
1512 *
1513 * @static
1514 * @memberOf _
1515 * @since 1.1.0
1516 * @category Array
1517 * @param {Array} array The array to inspect.
1518 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1519 * @param {number} [fromIndex=0] The index to search from.
1520 * @returns {number} Returns the index of the found element, else `-1`.
1521 * @example
1522 *
1523 * var users = [
1524 * { 'user': 'barney', 'active': false },
1525 * { 'user': 'fred', 'active': false },
1526 * { 'user': 'pebbles', 'active': true }
1527 * ];
1528 *
1529 * _.findIndex(users, function(o) { return o.user == 'barney'; });
1530 * // => 0
1531 *
1532 * // The `_.matches` iteratee shorthand.
1533 * _.findIndex(users, { 'user': 'fred', 'active': false });
1534 * // => 1
1535 *
1536 * // The `_.matchesProperty` iteratee shorthand.
1537 * _.findIndex(users, ['active', false]);
1538 * // => 0
1539 *
1540 * // The `_.property` iteratee shorthand.
1541 * _.findIndex(users, 'active');
1542 * // => 2
1543 */
1544 function findIndex(array, predicate, fromIndex) {
1545 var length = array == null ? 0 : array.length;
1546 if (!length) {
1547 return -1;
1548 }
1549 var index = fromIndex == null ? 0 : toInteger(fromIndex);
1550 if (index < 0) {
1551 index = nativeMax(length + index, 0);
1552 }
1553 return baseFindIndex(array, baseIteratee(predicate, 3), index);
1554 }
1555
1556 /**
1557 * Flattens `array` a single level deep.
1558 *
1559 * @static
1560 * @memberOf _
1561 * @since 0.1.0
1562 * @category Array
1563 * @param {Array} array The array to flatten.
1564 * @returns {Array} Returns the new flattened array.
1565 * @example
1566 *
1567 * _.flatten([1, [2, [3, [4]], 5]]);
1568 * // => [1, 2, [3, [4]], 5]
1569 */
1570 function flatten(array) {
1571 var length = array == null ? 0 : array.length;
1572 return length ? baseFlatten(array, 1) : [];
1573 }
1574
1575 /**
1576 * Recursively flattens `array`.
1577 *
1578 * @static
1579 * @memberOf _
1580 * @since 3.0.0
1581 * @category Array
1582 * @param {Array} array The array to flatten.
1583 * @returns {Array} Returns the new flattened array.
1584 * @example
1585 *
1586 * _.flattenDeep([1, [2, [3, [4]], 5]]);
1587 * // => [1, 2, 3, 4, 5]
1588 */
1589 function flattenDeep(array) {
1590 var length = array == null ? 0 : array.length;
1591 return length ? baseFlatten(array, INFINITY) : [];
1592 }
1593
1594 /**
1595 * Gets the first element of `array`.
1596 *
1597 * @static
1598 * @memberOf _
1599 * @since 0.1.0
1600 * @alias first
1601 * @category Array
1602 * @param {Array} array The array to query.
1603 * @returns {*} Returns the first element of `array`.
1604 * @example
1605 *
1606 * _.head([1, 2, 3]);
1607 * // => 1
1608 *
1609 * _.head([]);
1610 * // => undefined
1611 */
1612 function head(array) {
1613 return (array && array.length) ? array[0] : undefined;
1614 }
1615
1616 /**
1617 * Gets the index at which the first occurrence of `value` is found in `array`
1618 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1619 * for equality comparisons. If `fromIndex` is negative, it's used as the
1620 * offset from the end of `array`.
1621 *
1622 * @static
1623 * @memberOf _
1624 * @since 0.1.0
1625 * @category Array
1626 * @param {Array} array The array to inspect.
1627 * @param {*} value The value to search for.
1628 * @param {number} [fromIndex=0] The index to search from.
1629 * @returns {number} Returns the index of the matched value, else `-1`.
1630 * @example
1631 *
1632 * _.indexOf([1, 2, 1, 2], 2);
1633 * // => 1
1634 *
1635 * // Search from the `fromIndex`.
1636 * _.indexOf([1, 2, 1, 2], 2, 2);
1637 * // => 3
1638 */
1639 function indexOf(array, value, fromIndex) {
1640 var length = array == null ? 0 : array.length;
1641 if (typeof fromIndex == 'number') {
1642 fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
1643 } else {
1644 fromIndex = 0;
1645 }
1646 var index = (fromIndex || 0) - 1,
1647 isReflexive = value === value;
1648
1649 while (++index < length) {
1650 var other = array[index];
1651 if ((isReflexive ? other === value : other !== other)) {
1652 return index;
1653 }
1654 }
1655 return -1;
1656 }
1657
1658 /**
1659 * Gets the last element of `array`.
1660 *
1661 * @static
1662 * @memberOf _
1663 * @since 0.1.0
1664 * @category Array
1665 * @param {Array} array The array to query.
1666 * @returns {*} Returns the last element of `array`.
1667 * @example
1668 *
1669 * _.last([1, 2, 3]);
1670 * // => 3
1671 */
1672 function last(array) {
1673 var length = array == null ? 0 : array.length;
1674 return length ? array[length - 1] : undefined;
1675 }
1676
1677 /**
1678 * Creates a slice of `array` from `start` up to, but not including, `end`.
1679 *
1680 * **Note:** This method is used instead of
1681 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
1682 * returned.
1683 *
1684 * @static
1685 * @memberOf _
1686 * @since 3.0.0
1687 * @category Array
1688 * @param {Array} array The array to slice.
1689 * @param {number} [start=0] The start position.
1690 * @param {number} [end=array.length] The end position.
1691 * @returns {Array} Returns the slice of `array`.
1692 */
1693 function slice(array, start, end) {
1694 var length = array == null ? 0 : array.length;
1695 start = start == null ? 0 : +start;
1696 end = end === undefined ? length : +end;
1697 return length ? baseSlice(array, start, end) : [];
1698 }
1699
1700 /*------------------------------------------------------------------------*/
1701
1702 /**
1703 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
1704 * chain sequences enabled. The result of such sequences must be unwrapped
1705 * with `_#value`.
1706 *
1707 * @static
1708 * @memberOf _
1709 * @since 1.3.0
1710 * @category Seq
1711 * @param {*} value The value to wrap.
1712 * @returns {Object} Returns the new `lodash` wrapper instance.
1713 * @example
1714 *
1715 * var users = [
1716 * { 'user': 'barney', 'age': 36 },
1717 * { 'user': 'fred', 'age': 40 },
1718 * { 'user': 'pebbles', 'age': 1 }
1719 * ];
1720 *
1721 * var youngest = _
1722 * .chain(users)
1723 * .sortBy('age')
1724 * .map(function(o) {
1725 * return o.user + ' is ' + o.age;
1726 * })
1727 * .head()
1728 * .value();
1729 * // => 'pebbles is 1'
1730 */
1731 function chain(value) {
1732 var result = lodash(value);
1733 result.__chain__ = true;
1734 return result;
1735 }
1736
1737 /**
1738 * This method invokes `interceptor` and returns `value`. The interceptor
1739 * is invoked with one argument; (value). The purpose of this method is to
1740 * "tap into" a method chain sequence in order to modify intermediate results.
1741 *
1742 * @static
1743 * @memberOf _
1744 * @since 0.1.0
1745 * @category Seq
1746 * @param {*} value The value to provide to `interceptor`.
1747 * @param {Function} interceptor The function to invoke.
1748 * @returns {*} Returns `value`.
1749 * @example
1750 *
1751 * _([1, 2, 3])
1752 * .tap(function(array) {
1753 * // Mutate input array.
1754 * array.pop();
1755 * })
1756 * .reverse()
1757 * .value();
1758 * // => [2, 1]
1759 */
1760 function tap(value, interceptor) {
1761 interceptor(value);
1762 return value;
1763 }
1764
1765 /**
1766 * This method is like `_.tap` except that it returns the result of `interceptor`.
1767 * The purpose of this method is to "pass thru" values replacing intermediate
1768 * results in a method chain sequence.
1769 *
1770 * @static
1771 * @memberOf _
1772 * @since 3.0.0
1773 * @category Seq
1774 * @param {*} value The value to provide to `interceptor`.
1775 * @param {Function} interceptor The function to invoke.
1776 * @returns {*} Returns the result of `interceptor`.
1777 * @example
1778 *
1779 * _(' abc ')
1780 * .chain()
1781 * .trim()
1782 * .thru(function(value) {
1783 * return [value];
1784 * })
1785 * .value();
1786 * // => ['abc']
1787 */
1788 function thru(value, interceptor) {
1789 return interceptor(value);
1790 }
1791
1792 /**
1793 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
1794 *
1795 * @name chain
1796 * @memberOf _
1797 * @since 0.1.0
1798 * @category Seq
1799 * @returns {Object} Returns the new `lodash` wrapper instance.
1800 * @example
1801 *
1802 * var users = [
1803 * { 'user': 'barney', 'age': 36 },
1804 * { 'user': 'fred', 'age': 40 }
1805 * ];
1806 *
1807 * // A sequence without explicit chaining.
1808 * _(users).head();
1809 * // => { 'user': 'barney', 'age': 36 }
1810 *
1811 * // A sequence with explicit chaining.
1812 * _(users)
1813 * .chain()
1814 * .head()
1815 * .pick('user')
1816 * .value();
1817 * // => { 'user': 'barney' }
1818 */
1819 function wrapperChain() {
1820 return chain(this);
1821 }
1822
1823 /**
1824 * Executes the chain sequence to resolve the unwrapped value.
1825 *
1826 * @name value
1827 * @memberOf _
1828 * @since 0.1.0
1829 * @alias toJSON, valueOf
1830 * @category Seq
1831 * @returns {*} Returns the resolved unwrapped value.
1832 * @example
1833 *
1834 * _([1, 2, 3]).value();
1835 * // => [1, 2, 3]
1836 */
1837 function wrapperValue() {
1838 return baseWrapperValue(this.__wrapped__, this.__actions__);
1839 }
1840
1841 /*------------------------------------------------------------------------*/
1842
1843 /**
1844 * Checks if `predicate` returns truthy for **all** elements of `collection`.
1845 * Iteration is stopped once `predicate` returns falsey. The predicate is
1846 * invoked with three arguments: (value, index|key, collection).
1847 *
1848 * **Note:** This method returns `true` for
1849 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
1850 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
1851 * elements of empty collections.
1852 *
1853 * @static
1854 * @memberOf _
1855 * @since 0.1.0
1856 * @category Collection
1857 * @param {Array|Object} collection The collection to iterate over.
1858 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1859 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
1860 * @returns {boolean} Returns `true` if all elements pass the predicate check,
1861 * else `false`.
1862 * @example
1863 *
1864 * _.every([true, 1, null, 'yes'], Boolean);
1865 * // => false
1866 *
1867 * var users = [
1868 * { 'user': 'barney', 'age': 36, 'active': false },
1869 * { 'user': 'fred', 'age': 40, 'active': false }
1870 * ];
1871 *
1872 * // The `_.matches` iteratee shorthand.
1873 * _.every(users, { 'user': 'barney', 'active': false });
1874 * // => false
1875 *
1876 * // The `_.matchesProperty` iteratee shorthand.
1877 * _.every(users, ['active', false]);
1878 * // => true
1879 *
1880 * // The `_.property` iteratee shorthand.
1881 * _.every(users, 'active');
1882 * // => false
1883 */
1884 function every(collection, predicate, guard) {
1885 predicate = guard ? undefined : predicate;
1886 return baseEvery(collection, baseIteratee(predicate));
1887 }
1888
1889 /**
1890 * Iterates over elements of `collection`, returning an array of all elements
1891 * `predicate` returns truthy for. The predicate is invoked with three
1892 * arguments: (value, index|key, collection).
1893 *
1894 * **Note:** Unlike `_.remove`, this method returns a new array.
1895 *
1896 * @static
1897 * @memberOf _
1898 * @since 0.1.0
1899 * @category Collection
1900 * @param {Array|Object} collection The collection to iterate over.
1901 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1902 * @returns {Array} Returns the new filtered array.
1903 * @see _.reject
1904 * @example
1905 *
1906 * var users = [
1907 * { 'user': 'barney', 'age': 36, 'active': true },
1908 * { 'user': 'fred', 'age': 40, 'active': false }
1909 * ];
1910 *
1911 * _.filter(users, function(o) { return !o.active; });
1912 * // => objects for ['fred']
1913 *
1914 * // The `_.matches` iteratee shorthand.
1915 * _.filter(users, { 'age': 36, 'active': true });
1916 * // => objects for ['barney']
1917 *
1918 * // The `_.matchesProperty` iteratee shorthand.
1919 * _.filter(users, ['active', false]);
1920 * // => objects for ['fred']
1921 *
1922 * // The `_.property` iteratee shorthand.
1923 * _.filter(users, 'active');
1924 * // => objects for ['barney']
1925 */
1926 function filter(collection, predicate) {
1927 return baseFilter(collection, baseIteratee(predicate));
1928 }
1929
1930 /**
1931 * Iterates over elements of `collection`, returning the first element
1932 * `predicate` returns truthy for. The predicate is invoked with three
1933 * arguments: (value, index|key, collection).
1934 *
1935 * @static
1936 * @memberOf _
1937 * @since 0.1.0
1938 * @category Collection
1939 * @param {Array|Object} collection The collection to inspect.
1940 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1941 * @param {number} [fromIndex=0] The index to search from.
1942 * @returns {*} Returns the matched element, else `undefined`.
1943 * @example
1944 *
1945 * var users = [
1946 * { 'user': 'barney', 'age': 36, 'active': true },
1947 * { 'user': 'fred', 'age': 40, 'active': false },
1948 * { 'user': 'pebbles', 'age': 1, 'active': true }
1949 * ];
1950 *
1951 * _.find(users, function(o) { return o.age < 40; });
1952 * // => object for 'barney'
1953 *
1954 * // The `_.matches` iteratee shorthand.
1955 * _.find(users, { 'age': 1, 'active': true });
1956 * // => object for 'pebbles'
1957 *
1958 * // The `_.matchesProperty` iteratee shorthand.
1959 * _.find(users, ['active', false]);
1960 * // => object for 'fred'
1961 *
1962 * // The `_.property` iteratee shorthand.
1963 * _.find(users, 'active');
1964 * // => object for 'barney'
1965 */
1966 var find = createFind(findIndex);
1967
1968 /**
1969 * Iterates over elements of `collection` and invokes `iteratee` for each element.
1970 * The iteratee is invoked with three arguments: (value, index|key, collection).
1971 * Iteratee functions may exit iteration early by explicitly returning `false`.
1972 *
1973 * **Note:** As with other "Collections" methods, objects with a "length"
1974 * property are iterated like arrays. To avoid this behavior use `_.forIn`
1975 * or `_.forOwn` for object iteration.
1976 *
1977 * @static
1978 * @memberOf _
1979 * @since 0.1.0
1980 * @alias each
1981 * @category Collection
1982 * @param {Array|Object} collection The collection to iterate over.
1983 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
1984 * @returns {Array|Object} Returns `collection`.
1985 * @see _.forEachRight
1986 * @example
1987 *
1988 * _.forEach([1, 2], function(value) {
1989 * console.log(value);
1990 * });
1991 * // => Logs `1` then `2`.
1992 *
1993 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
1994 * console.log(key);
1995 * });
1996 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
1997 */
1998 function forEach(collection, iteratee) {
1999 return baseEach(collection, baseIteratee(iteratee));
2000 }
2001
2002 /**
2003 * Creates an array of values by running each element in `collection` thru
2004 * `iteratee`. The iteratee is invoked with three arguments:
2005 * (value, index|key, collection).
2006 *
2007 * Many lodash methods are guarded to work as iteratees for methods like
2008 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
2009 *
2010 * The guarded methods are:
2011 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
2012 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
2013 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
2014 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
2015 *
2016 * @static
2017 * @memberOf _
2018 * @since 0.1.0
2019 * @category Collection
2020 * @param {Array|Object} collection The collection to iterate over.
2021 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2022 * @returns {Array} Returns the new mapped array.
2023 * @example
2024 *
2025 * function square(n) {
2026 * return n * n;
2027 * }
2028 *
2029 * _.map([4, 8], square);
2030 * // => [16, 64]
2031 *
2032 * _.map({ 'a': 4, 'b': 8 }, square);
2033 * // => [16, 64] (iteration order is not guaranteed)
2034 *
2035 * var users = [
2036 * { 'user': 'barney' },
2037 * { 'user': 'fred' }
2038 * ];
2039 *
2040 * // The `_.property` iteratee shorthand.
2041 * _.map(users, 'user');
2042 * // => ['barney', 'fred']
2043 */
2044 function map(collection, iteratee) {
2045 return baseMap(collection, baseIteratee(iteratee));
2046 }
2047
2048 /**
2049 * Reduces `collection` to a value which is the accumulated result of running
2050 * each element in `collection` thru `iteratee`, where each successive
2051 * invocation is supplied the return value of the previous. If `accumulator`
2052 * is not given, the first element of `collection` is used as the initial
2053 * value. The iteratee is invoked with four arguments:
2054 * (accumulator, value, index|key, collection).
2055 *
2056 * Many lodash methods are guarded to work as iteratees for methods like
2057 * `_.reduce`, `_.reduceRight`, and `_.transform`.
2058 *
2059 * The guarded methods are:
2060 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
2061 * and `sortBy`
2062 *
2063 * @static
2064 * @memberOf _
2065 * @since 0.1.0
2066 * @category Collection
2067 * @param {Array|Object} collection The collection to iterate over.
2068 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2069 * @param {*} [accumulator] The initial value.
2070 * @returns {*} Returns the accumulated value.
2071 * @see _.reduceRight
2072 * @example
2073 *
2074 * _.reduce([1, 2], function(sum, n) {
2075 * return sum + n;
2076 * }, 0);
2077 * // => 3
2078 *
2079 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
2080 * (result[value] || (result[value] = [])).push(key);
2081 * return result;
2082 * }, {});
2083 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
2084 */
2085 function reduce(collection, iteratee, accumulator) {
2086 return baseReduce(collection, baseIteratee(iteratee), accumulator, arguments.length < 3, baseEach);
2087 }
2088
2089 /**
2090 * Gets the size of `collection` by returning its length for array-like
2091 * values or the number of own enumerable string keyed properties for objects.
2092 *
2093 * @static
2094 * @memberOf _
2095 * @since 0.1.0
2096 * @category Collection
2097 * @param {Array|Object|string} collection The collection to inspect.
2098 * @returns {number} Returns the collection size.
2099 * @example
2100 *
2101 * _.size([1, 2, 3]);
2102 * // => 3
2103 *
2104 * _.size({ 'a': 1, 'b': 2 });
2105 * // => 2
2106 *
2107 * _.size('pebbles');
2108 * // => 7
2109 */
2110 function size(collection) {
2111 if (collection == null) {
2112 return 0;
2113 }
2114 collection = isArrayLike(collection) ? collection : nativeKeys(collection);
2115 return collection.length;
2116 }
2117
2118 /**
2119 * Checks if `predicate` returns truthy for **any** element of `collection`.
2120 * Iteration is stopped once `predicate` returns truthy. The predicate is
2121 * invoked with three arguments: (value, index|key, collection).
2122 *
2123 * @static
2124 * @memberOf _
2125 * @since 0.1.0
2126 * @category Collection
2127 * @param {Array|Object} collection The collection to iterate over.
2128 * @param {Function} [predicate=_.identity] The function invoked per iteration.
2129 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2130 * @returns {boolean} Returns `true` if any element passes the predicate check,
2131 * else `false`.
2132 * @example
2133 *
2134 * _.some([null, 0, 'yes', false], Boolean);
2135 * // => true
2136 *
2137 * var users = [
2138 * { 'user': 'barney', 'active': true },
2139 * { 'user': 'fred', 'active': false }
2140 * ];
2141 *
2142 * // The `_.matches` iteratee shorthand.
2143 * _.some(users, { 'user': 'barney', 'active': false });
2144 * // => false
2145 *
2146 * // The `_.matchesProperty` iteratee shorthand.
2147 * _.some(users, ['active', false]);
2148 * // => true
2149 *
2150 * // The `_.property` iteratee shorthand.
2151 * _.some(users, 'active');
2152 * // => true
2153 */
2154 function some(collection, predicate, guard) {
2155 predicate = guard ? undefined : predicate;
2156 return baseSome(collection, baseIteratee(predicate));
2157 }
2158
2159 /**
2160 * Creates an array of elements, sorted in ascending order by the results of
2161 * running each element in a collection thru each iteratee. This method
2162 * performs a stable sort, that is, it preserves the original sort order of
2163 * equal elements. The iteratees are invoked with one argument: (value).
2164 *
2165 * @static
2166 * @memberOf _
2167 * @since 0.1.0
2168 * @category Collection
2169 * @param {Array|Object} collection The collection to iterate over.
2170 * @param {...(Function|Function[])} [iteratees=[_.identity]]
2171 * The iteratees to sort by.
2172 * @returns {Array} Returns the new sorted array.
2173 * @example
2174 *
2175 * var users = [
2176 * { 'user': 'fred', 'age': 48 },
2177 * { 'user': 'barney', 'age': 36 },
2178 * { 'user': 'fred', 'age': 40 },
2179 * { 'user': 'barney', 'age': 34 }
2180 * ];
2181 *
2182 * _.sortBy(users, [function(o) { return o.user; }]);
2183 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
2184 *
2185 * _.sortBy(users, ['user', 'age']);
2186 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
2187 */
2188 function sortBy(collection, iteratee) {
2189 var index = 0;
2190 iteratee = baseIteratee(iteratee);
2191
2192 return baseMap(baseMap(collection, function(value, key, collection) {
2193 return { 'value': value, 'index': index++, 'criteria': iteratee(value, key, collection) };
2194 }).sort(function(object, other) {
2195 return compareAscending(object.criteria, other.criteria) || (object.index - other.index);
2196 }), baseProperty('value'));
2197 }
2198
2199 /*------------------------------------------------------------------------*/
2200
2201 /**
2202 * Creates a function that invokes `func`, with the `this` binding and arguments
2203 * of the created function, while it's called less than `n` times. Subsequent
2204 * calls to the created function return the result of the last `func` invocation.
2205 *
2206 * @static
2207 * @memberOf _
2208 * @since 3.0.0
2209 * @category Function
2210 * @param {number} n The number of calls at which `func` is no longer invoked.
2211 * @param {Function} func The function to restrict.
2212 * @returns {Function} Returns the new restricted function.
2213 * @example
2214 *
2215 * jQuery(element).on('click', _.before(5, addContactToList));
2216 * // => Allows adding up to 4 contacts to the list.
2217 */
2218 function before(n, func) {
2219 var result;
2220 if (typeof func != 'function') {
2221 throw new TypeError(FUNC_ERROR_TEXT);
2222 }
2223 n = toInteger(n);
2224 return function() {
2225 if (--n > 0) {
2226 result = func.apply(this, arguments);
2227 }
2228 if (n <= 1) {
2229 func = undefined;
2230 }
2231 return result;
2232 };
2233 }
2234
2235 /**
2236 * Creates a function that invokes `func` with the `this` binding of `thisArg`
2237 * and `partials` prepended to the arguments it receives.
2238 *
2239 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
2240 * may be used as a placeholder for partially applied arguments.
2241 *
2242 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
2243 * property of bound functions.
2244 *
2245 * @static
2246 * @memberOf _
2247 * @since 0.1.0
2248 * @category Function
2249 * @param {Function} func The function to bind.
2250 * @param {*} thisArg The `this` binding of `func`.
2251 * @param {...*} [partials] The arguments to be partially applied.
2252 * @returns {Function} Returns the new bound function.
2253 * @example
2254 *
2255 * function greet(greeting, punctuation) {
2256 * return greeting + ' ' + this.user + punctuation;
2257 * }
2258 *
2259 * var object = { 'user': 'fred' };
2260 *
2261 * var bound = _.bind(greet, object, 'hi');
2262 * bound('!');
2263 * // => 'hi fred!'
2264 *
2265 * // Bound with placeholders.
2266 * var bound = _.bind(greet, object, _, '!');
2267 * bound('hi');
2268 * // => 'hi fred!'
2269 */
2270 var bind = baseRest(function(func, thisArg, partials) {
2271 return createPartial(func, WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG, thisArg, partials);
2272 });
2273
2274 /**
2275 * Defers invoking the `func` until the current call stack has cleared. Any
2276 * additional arguments are provided to `func` when it's invoked.
2277 *
2278 * @static
2279 * @memberOf _
2280 * @since 0.1.0
2281 * @category Function
2282 * @param {Function} func The function to defer.
2283 * @param {...*} [args] The arguments to invoke `func` with.
2284 * @returns {number} Returns the timer id.
2285 * @example
2286 *
2287 * _.defer(function(text) {
2288 * console.log(text);
2289 * }, 'deferred');
2290 * // => Logs 'deferred' after one millisecond.
2291 */
2292 var defer = baseRest(function(func, args) {
2293 return baseDelay(func, 1, args);
2294 });
2295
2296 /**
2297 * Invokes `func` after `wait` milliseconds. Any additional arguments are
2298 * provided to `func` when it's invoked.
2299 *
2300 * @static
2301 * @memberOf _
2302 * @since 0.1.0
2303 * @category Function
2304 * @param {Function} func The function to delay.
2305 * @param {number} wait The number of milliseconds to delay invocation.
2306 * @param {...*} [args] The arguments to invoke `func` with.
2307 * @returns {number} Returns the timer id.
2308 * @example
2309 *
2310 * _.delay(function(text) {
2311 * console.log(text);
2312 * }, 1000, 'later');
2313 * // => Logs 'later' after one second.
2314 */
2315 var delay = baseRest(function(func, wait, args) {
2316 return baseDelay(func, toNumber(wait) || 0, args);
2317 });
2318
2319 /**
2320 * Creates a function that negates the result of the predicate `func`. The
2321 * `func` predicate is invoked with the `this` binding and arguments of the
2322 * created function.
2323 *
2324 * @static
2325 * @memberOf _
2326 * @since 3.0.0
2327 * @category Function
2328 * @param {Function} predicate The predicate to negate.
2329 * @returns {Function} Returns the new negated function.
2330 * @example
2331 *
2332 * function isEven(n) {
2333 * return n % 2 == 0;
2334 * }
2335 *
2336 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
2337 * // => [1, 3, 5]
2338 */
2339 function negate(predicate) {
2340 if (typeof predicate != 'function') {
2341 throw new TypeError(FUNC_ERROR_TEXT);
2342 }
2343 return function() {
2344 var args = arguments;
2345 return !predicate.apply(this, args);
2346 };
2347 }
2348
2349 /**
2350 * Creates a function that is restricted to invoking `func` once. Repeat calls
2351 * to the function return the value of the first invocation. The `func` is
2352 * invoked with the `this` binding and arguments of the created function.
2353 *
2354 * @static
2355 * @memberOf _
2356 * @since 0.1.0
2357 * @category Function
2358 * @param {Function} func The function to restrict.
2359 * @returns {Function} Returns the new restricted function.
2360 * @example
2361 *
2362 * var initialize = _.once(createApplication);
2363 * initialize();
2364 * initialize();
2365 * // => `createApplication` is invoked once
2366 */
2367 function once(func) {
2368 return before(2, func);
2369 }
2370
2371 /*------------------------------------------------------------------------*/
2372
2373 /**
2374 * Creates a shallow clone of `value`.
2375 *
2376 * **Note:** This method is loosely based on the
2377 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
2378 * and supports cloning arrays, array buffers, booleans, date objects, maps,
2379 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
2380 * arrays. The own enumerable properties of `arguments` objects are cloned
2381 * as plain objects. An empty object is returned for uncloneable values such
2382 * as error objects, functions, DOM nodes, and WeakMaps.
2383 *
2384 * @static
2385 * @memberOf _
2386 * @since 0.1.0
2387 * @category Lang
2388 * @param {*} value The value to clone.
2389 * @returns {*} Returns the cloned value.
2390 * @see _.cloneDeep
2391 * @example
2392 *
2393 * var objects = [{ 'a': 1 }, { 'b': 2 }];
2394 *
2395 * var shallow = _.clone(objects);
2396 * console.log(shallow[0] === objects[0]);
2397 * // => true
2398 */
2399 function clone(value) {
2400 if (!isObject(value)) {
2401 return value;
2402 }
2403 return isArray(value) ? copyArray(value) : copyObject(value, nativeKeys(value));
2404 }
2405
2406 /**
2407 * Performs a
2408 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2409 * comparison between two values to determine if they are equivalent.
2410 *
2411 * @static
2412 * @memberOf _
2413 * @since 4.0.0
2414 * @category Lang
2415 * @param {*} value The value to compare.
2416 * @param {*} other The other value to compare.
2417 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2418 * @example
2419 *
2420 * var object = { 'a': 1 };
2421 * var other = { 'a': 1 };
2422 *
2423 * _.eq(object, object);
2424 * // => true
2425 *
2426 * _.eq(object, other);
2427 * // => false
2428 *
2429 * _.eq('a', 'a');
2430 * // => true
2431 *
2432 * _.eq('a', Object('a'));
2433 * // => false
2434 *
2435 * _.eq(NaN, NaN);
2436 * // => true
2437 */
2438 function eq(value, other) {
2439 return value === other || (value !== value && other !== other);
2440 }
2441
2442 /**
2443 * Checks if `value` is likely an `arguments` object.
2444 *
2445 * @static
2446 * @memberOf _
2447 * @since 0.1.0
2448 * @category Lang
2449 * @param {*} value The value to check.
2450 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2451 * else `false`.
2452 * @example
2453 *
2454 * _.isArguments(function() { return arguments; }());
2455 * // => true
2456 *
2457 * _.isArguments([1, 2, 3]);
2458 * // => false
2459 */
2460 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
2461 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
2462 !propertyIsEnumerable.call(value, 'callee');
2463 };
2464
2465 /**
2466 * Checks if `value` is classified as an `Array` object.
2467 *
2468 * @static
2469 * @memberOf _
2470 * @since 0.1.0
2471 * @category Lang
2472 * @param {*} value The value to check.
2473 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2474 * @example
2475 *
2476 * _.isArray([1, 2, 3]);
2477 * // => true
2478 *
2479 * _.isArray(document.body.children);
2480 * // => false
2481 *
2482 * _.isArray('abc');
2483 * // => false
2484 *
2485 * _.isArray(_.noop);
2486 * // => false
2487 */
2488 var isArray = Array.isArray;
2489
2490 /**
2491 * Checks if `value` is array-like. A value is considered array-like if it's
2492 * not a function and has a `value.length` that's an integer greater than or
2493 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2494 *
2495 * @static
2496 * @memberOf _
2497 * @since 4.0.0
2498 * @category Lang
2499 * @param {*} value The value to check.
2500 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2501 * @example
2502 *
2503 * _.isArrayLike([1, 2, 3]);
2504 * // => true
2505 *
2506 * _.isArrayLike(document.body.children);
2507 * // => true
2508 *
2509 * _.isArrayLike('abc');
2510 * // => true
2511 *
2512 * _.isArrayLike(_.noop);
2513 * // => false
2514 */
2515 function isArrayLike(value) {
2516 return value != null && isLength(value.length) && !isFunction(value);
2517 }
2518
2519 /**
2520 * Checks if `value` is classified as a boolean primitive or object.
2521 *
2522 * @static
2523 * @memberOf _
2524 * @since 0.1.0
2525 * @category Lang
2526 * @param {*} value The value to check.
2527 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
2528 * @example
2529 *
2530 * _.isBoolean(false);
2531 * // => true
2532 *
2533 * _.isBoolean(null);
2534 * // => false
2535 */
2536 function isBoolean(value) {
2537 return value === true || value === false ||
2538 (isObjectLike(value) && baseGetTag(value) == boolTag);
2539 }
2540
2541 /**
2542 * Checks if `value` is classified as a `Date` object.
2543 *
2544 * @static
2545 * @memberOf _
2546 * @since 0.1.0
2547 * @category Lang
2548 * @param {*} value The value to check.
2549 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
2550 * @example
2551 *
2552 * _.isDate(new Date);
2553 * // => true
2554 *
2555 * _.isDate('Mon April 23 2012');
2556 * // => false
2557 */
2558 var isDate = baseIsDate;
2559
2560 /**
2561 * Checks if `value` is an empty object, collection, map, or set.
2562 *
2563 * Objects are considered empty if they have no own enumerable string keyed
2564 * properties.
2565 *
2566 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
2567 * jQuery-like collections are considered empty if they have a `length` of `0`.
2568 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
2569 *
2570 * @static
2571 * @memberOf _
2572 * @since 0.1.0
2573 * @category Lang
2574 * @param {*} value The value to check.
2575 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
2576 * @example
2577 *
2578 * _.isEmpty(null);
2579 * // => true
2580 *
2581 * _.isEmpty(true);
2582 * // => true
2583 *
2584 * _.isEmpty(1);
2585 * // => true
2586 *
2587 * _.isEmpty([1, 2, 3]);
2588 * // => false
2589 *
2590 * _.isEmpty({ 'a': 1 });
2591 * // => false
2592 */
2593 function isEmpty(value) {
2594 if (isArrayLike(value) &&
2595 (isArray(value) || isString(value) ||
2596 isFunction(value.splice) || isArguments(value))) {
2597 return !value.length;
2598 }
2599 return !nativeKeys(value).length;
2600 }
2601
2602 /**
2603 * Performs a deep comparison between two values to determine if they are
2604 * equivalent.
2605 *
2606 * **Note:** This method supports comparing arrays, array buffers, booleans,
2607 * date objects, error objects, maps, numbers, `Object` objects, regexes,
2608 * sets, strings, symbols, and typed arrays. `Object` objects are compared
2609 * by their own, not inherited, enumerable properties. Functions and DOM
2610 * nodes are **not** supported.
2611 *
2612 * @static
2613 * @memberOf _
2614 * @since 0.1.0
2615 * @category Lang
2616 * @param {*} value The value to compare.
2617 * @param {*} other The other value to compare.
2618 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2619 * @example
2620 *
2621 * var object = { 'a': 1 };
2622 * var other = { 'a': 1 };
2623 *
2624 * _.isEqual(object, other);
2625 * // => true
2626 *
2627 * object === other;
2628 * // => false
2629 */
2630 function isEqual(value, other) {
2631 return baseIsEqual(value, other);
2632 }
2633
2634 /**
2635 * Checks if `value` is a finite primitive number.
2636 *
2637 * **Note:** This method is based on
2638 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
2639 *
2640 * @static
2641 * @memberOf _
2642 * @since 0.1.0
2643 * @category Lang
2644 * @param {*} value The value to check.
2645 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
2646 * @example
2647 *
2648 * _.isFinite(3);
2649 * // => true
2650 *
2651 * _.isFinite(Number.MIN_VALUE);
2652 * // => true
2653 *
2654 * _.isFinite(Infinity);
2655 * // => false
2656 *
2657 * _.isFinite('3');
2658 * // => false
2659 */
2660 function isFinite(value) {
2661 return typeof value == 'number' && nativeIsFinite(value);
2662 }
2663
2664 /**
2665 * Checks if `value` is classified as a `Function` object.
2666 *
2667 * @static
2668 * @memberOf _
2669 * @since 0.1.0
2670 * @category Lang
2671 * @param {*} value The value to check.
2672 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2673 * @example
2674 *
2675 * _.isFunction(_);
2676 * // => true
2677 *
2678 * _.isFunction(/abc/);
2679 * // => false
2680 */
2681 function isFunction(value) {
2682 if (!isObject(value)) {
2683 return false;
2684 }
2685 // The use of `Object#toString` avoids issues with the `typeof` operator
2686 // in Safari 9 which returns 'object' for typed arrays and other constructors.
2687 var tag = baseGetTag(value);
2688 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
2689 }
2690
2691 /**
2692 * Checks if `value` is a valid array-like length.
2693 *
2694 * **Note:** This method is loosely based on
2695 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2696 *
2697 * @static
2698 * @memberOf _
2699 * @since 4.0.0
2700 * @category Lang
2701 * @param {*} value The value to check.
2702 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2703 * @example
2704 *
2705 * _.isLength(3);
2706 * // => true
2707 *
2708 * _.isLength(Number.MIN_VALUE);
2709 * // => false
2710 *
2711 * _.isLength(Infinity);
2712 * // => false
2713 *
2714 * _.isLength('3');
2715 * // => false
2716 */
2717 function isLength(value) {
2718 return typeof value == 'number' &&
2719 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2720 }
2721
2722 /**
2723 * Checks if `value` is the
2724 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2725 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2726 *
2727 * @static
2728 * @memberOf _
2729 * @since 0.1.0
2730 * @category Lang
2731 * @param {*} value The value to check.
2732 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2733 * @example
2734 *
2735 * _.isObject({});
2736 * // => true
2737 *
2738 * _.isObject([1, 2, 3]);
2739 * // => true
2740 *
2741 * _.isObject(_.noop);
2742 * // => true
2743 *
2744 * _.isObject(null);
2745 * // => false
2746 */
2747 function isObject(value) {
2748 var type = typeof value;
2749 return value != null && (type == 'object' || type == 'function');
2750 }
2751
2752 /**
2753 * Checks if `value` is object-like. A value is object-like if it's not `null`
2754 * and has a `typeof` result of "object".
2755 *
2756 * @static
2757 * @memberOf _
2758 * @since 4.0.0
2759 * @category Lang
2760 * @param {*} value The value to check.
2761 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2762 * @example
2763 *
2764 * _.isObjectLike({});
2765 * // => true
2766 *
2767 * _.isObjectLike([1, 2, 3]);
2768 * // => true
2769 *
2770 * _.isObjectLike(_.noop);
2771 * // => false
2772 *
2773 * _.isObjectLike(null);
2774 * // => false
2775 */
2776 function isObjectLike(value) {
2777 return value != null && typeof value == 'object';
2778 }
2779
2780 /**
2781 * Checks if `value` is `NaN`.
2782 *
2783 * **Note:** This method is based on
2784 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
2785 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
2786 * `undefined` and other non-number values.
2787 *
2788 * @static
2789 * @memberOf _
2790 * @since 0.1.0
2791 * @category Lang
2792 * @param {*} value The value to check.
2793 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
2794 * @example
2795 *
2796 * _.isNaN(NaN);
2797 * // => true
2798 *
2799 * _.isNaN(new Number(NaN));
2800 * // => true
2801 *
2802 * isNaN(undefined);
2803 * // => true
2804 *
2805 * _.isNaN(undefined);
2806 * // => false
2807 */
2808 function isNaN(value) {
2809 // An `NaN` primitive is the only value that is not equal to itself.
2810 // Perform the `toStringTag` check first to avoid errors with some
2811 // ActiveX objects in IE.
2812 return isNumber(value) && value != +value;
2813 }
2814
2815 /**
2816 * Checks if `value` is `null`.
2817 *
2818 * @static
2819 * @memberOf _
2820 * @since 0.1.0
2821 * @category Lang
2822 * @param {*} value The value to check.
2823 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
2824 * @example
2825 *
2826 * _.isNull(null);
2827 * // => true
2828 *
2829 * _.isNull(void 0);
2830 * // => false
2831 */
2832 function isNull(value) {
2833 return value === null;
2834 }
2835
2836 /**
2837 * Checks if `value` is classified as a `Number` primitive or object.
2838 *
2839 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
2840 * classified as numbers, use the `_.isFinite` method.
2841 *
2842 * @static
2843 * @memberOf _
2844 * @since 0.1.0
2845 * @category Lang
2846 * @param {*} value The value to check.
2847 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
2848 * @example
2849 *
2850 * _.isNumber(3);
2851 * // => true
2852 *
2853 * _.isNumber(Number.MIN_VALUE);
2854 * // => true
2855 *
2856 * _.isNumber(Infinity);
2857 * // => true
2858 *
2859 * _.isNumber('3');
2860 * // => false
2861 */
2862 function isNumber(value) {
2863 return typeof value == 'number' ||
2864 (isObjectLike(value) && baseGetTag(value) == numberTag);
2865 }
2866
2867 /**
2868 * Checks if `value` is classified as a `RegExp` object.
2869 *
2870 * @static
2871 * @memberOf _
2872 * @since 0.1.0
2873 * @category Lang
2874 * @param {*} value The value to check.
2875 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
2876 * @example
2877 *
2878 * _.isRegExp(/abc/);
2879 * // => true
2880 *
2881 * _.isRegExp('/abc/');
2882 * // => false
2883 */
2884 var isRegExp = baseIsRegExp;
2885
2886 /**
2887 * Checks if `value` is classified as a `String` primitive or object.
2888 *
2889 * @static
2890 * @since 0.1.0
2891 * @memberOf _
2892 * @category Lang
2893 * @param {*} value The value to check.
2894 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
2895 * @example
2896 *
2897 * _.isString('abc');
2898 * // => true
2899 *
2900 * _.isString(1);
2901 * // => false
2902 */
2903 function isString(value) {
2904 return typeof value == 'string' ||
2905 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
2906 }
2907
2908 /**
2909 * Checks if `value` is `undefined`.
2910 *
2911 * @static
2912 * @since 0.1.0
2913 * @memberOf _
2914 * @category Lang
2915 * @param {*} value The value to check.
2916 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
2917 * @example
2918 *
2919 * _.isUndefined(void 0);
2920 * // => true
2921 *
2922 * _.isUndefined(null);
2923 * // => false
2924 */
2925 function isUndefined(value) {
2926 return value === undefined;
2927 }
2928
2929 /**
2930 * Converts `value` to an array.
2931 *
2932 * @static
2933 * @since 0.1.0
2934 * @memberOf _
2935 * @category Lang
2936 * @param {*} value The value to convert.
2937 * @returns {Array} Returns the converted array.
2938 * @example
2939 *
2940 * _.toArray({ 'a': 1, 'b': 2 });
2941 * // => [1, 2]
2942 *
2943 * _.toArray('abc');
2944 * // => ['a', 'b', 'c']
2945 *
2946 * _.toArray(1);
2947 * // => []
2948 *
2949 * _.toArray(null);
2950 * // => []
2951 */
2952 function toArray(value) {
2953 if (!isArrayLike(value)) {
2954 return values(value);
2955 }
2956 return value.length ? copyArray(value) : [];
2957 }
2958
2959 /**
2960 * Converts `value` to an integer.
2961 *
2962 * **Note:** This method is loosely based on
2963 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
2964 *
2965 * @static
2966 * @memberOf _
2967 * @since 4.0.0
2968 * @category Lang
2969 * @param {*} value The value to convert.
2970 * @returns {number} Returns the converted integer.
2971 * @example
2972 *
2973 * _.toInteger(3.2);
2974 * // => 3
2975 *
2976 * _.toInteger(Number.MIN_VALUE);
2977 * // => 0
2978 *
2979 * _.toInteger(Infinity);
2980 * // => 1.7976931348623157e+308
2981 *
2982 * _.toInteger('3.2');
2983 * // => 3
2984 */
2985 var toInteger = Number;
2986
2987 /**
2988 * Converts `value` to a number.
2989 *
2990 * @static
2991 * @memberOf _
2992 * @since 4.0.0
2993 * @category Lang
2994 * @param {*} value The value to process.
2995 * @returns {number} Returns the number.
2996 * @example
2997 *
2998 * _.toNumber(3.2);
2999 * // => 3.2
3000 *
3001 * _.toNumber(Number.MIN_VALUE);
3002 * // => 5e-324
3003 *
3004 * _.toNumber(Infinity);
3005 * // => Infinity
3006 *
3007 * _.toNumber('3.2');
3008 * // => 3.2
3009 */
3010 var toNumber = Number;
3011
3012 /**
3013 * Converts `value` to a string. An empty string is returned for `null`
3014 * and `undefined` values. The sign of `-0` is preserved.
3015 *
3016 * @static
3017 * @memberOf _
3018 * @since 4.0.0
3019 * @category Lang
3020 * @param {*} value The value to convert.
3021 * @returns {string} Returns the converted string.
3022 * @example
3023 *
3024 * _.toString(null);
3025 * // => ''
3026 *
3027 * _.toString(-0);
3028 * // => '-0'
3029 *
3030 * _.toString([1, 2, 3]);
3031 * // => '1,2,3'
3032 */
3033 function toString(value) {
3034 if (typeof value == 'string') {
3035 return value;
3036 }
3037 return value == null ? '' : (value + '');
3038 }
3039
3040 /*------------------------------------------------------------------------*/
3041
3042 /**
3043 * Assigns own enumerable string keyed properties of source objects to the
3044 * destination object. Source objects are applied from left to right.
3045 * Subsequent sources overwrite property assignments of previous sources.
3046 *
3047 * **Note:** This method mutates `object` and is loosely based on
3048 * [`Object.assign`](https://mdn.io/Object/assign).
3049 *
3050 * @static
3051 * @memberOf _
3052 * @since 0.10.0
3053 * @category Object
3054 * @param {Object} object The destination object.
3055 * @param {...Object} [sources] The source objects.
3056 * @returns {Object} Returns `object`.
3057 * @see _.assignIn
3058 * @example
3059 *
3060 * function Foo() {
3061 * this.a = 1;
3062 * }
3063 *
3064 * function Bar() {
3065 * this.c = 3;
3066 * }
3067 *
3068 * Foo.prototype.b = 2;
3069 * Bar.prototype.d = 4;
3070 *
3071 * _.assign({ 'a': 0 }, new Foo, new Bar);
3072 * // => { 'a': 1, 'c': 3 }
3073 */
3074 var assign = createAssigner(function(object, source) {
3075 copyObject(source, nativeKeys(source), object);
3076 });
3077
3078 /**
3079 * This method is like `_.assign` except that it iterates over own and
3080 * inherited source properties.
3081 *
3082 * **Note:** This method mutates `object`.
3083 *
3084 * @static
3085 * @memberOf _
3086 * @since 4.0.0
3087 * @alias extend
3088 * @category Object
3089 * @param {Object} object The destination object.
3090 * @param {...Object} [sources] The source objects.
3091 * @returns {Object} Returns `object`.
3092 * @see _.assign
3093 * @example
3094 *
3095 * function Foo() {
3096 * this.a = 1;
3097 * }
3098 *
3099 * function Bar() {
3100 * this.c = 3;
3101 * }
3102 *
3103 * Foo.prototype.b = 2;
3104 * Bar.prototype.d = 4;
3105 *
3106 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
3107 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
3108 */
3109 var assignIn = createAssigner(function(object, source) {
3110 copyObject(source, nativeKeysIn(source), object);
3111 });
3112
3113 /**
3114 * This method is like `_.assignIn` except that it accepts `customizer`
3115 * which is invoked to produce the assigned values. If `customizer` returns
3116 * `undefined`, assignment is handled by the method instead. The `customizer`
3117 * is invoked with five arguments: (objValue, srcValue, key, object, source).
3118 *
3119 * **Note:** This method mutates `object`.
3120 *
3121 * @static
3122 * @memberOf _
3123 * @since 4.0.0
3124 * @alias extendWith
3125 * @category Object
3126 * @param {Object} object The destination object.
3127 * @param {...Object} sources The source objects.
3128 * @param {Function} [customizer] The function to customize assigned values.
3129 * @returns {Object} Returns `object`.
3130 * @see _.assignWith
3131 * @example
3132 *
3133 * function customizer(objValue, srcValue) {
3134 * return _.isUndefined(objValue) ? srcValue : objValue;
3135 * }
3136 *
3137 * var defaults = _.partialRight(_.assignInWith, customizer);
3138 *
3139 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3140 * // => { 'a': 1, 'b': 2 }
3141 */
3142 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
3143 copyObject(source, keysIn(source), object, customizer);
3144 });
3145
3146 /**
3147 * Creates an object that inherits from the `prototype` object. If a
3148 * `properties` object is given, its own enumerable string keyed properties
3149 * are assigned to the created object.
3150 *
3151 * @static
3152 * @memberOf _
3153 * @since 2.3.0
3154 * @category Object
3155 * @param {Object} prototype The object to inherit from.
3156 * @param {Object} [properties] The properties to assign to the object.
3157 * @returns {Object} Returns the new object.
3158 * @example
3159 *
3160 * function Shape() {
3161 * this.x = 0;
3162 * this.y = 0;
3163 * }
3164 *
3165 * function Circle() {
3166 * Shape.call(this);
3167 * }
3168 *
3169 * Circle.prototype = _.create(Shape.prototype, {
3170 * 'constructor': Circle
3171 * });
3172 *
3173 * var circle = new Circle;
3174 * circle instanceof Circle;
3175 * // => true
3176 *
3177 * circle instanceof Shape;
3178 * // => true
3179 */
3180 function create(prototype, properties) {
3181 var result = baseCreate(prototype);
3182 return properties == null ? result : assign(result, properties);
3183 }
3184
3185 /**
3186 * Assigns own and inherited enumerable string keyed properties of source
3187 * objects to the destination object for all destination properties that
3188 * resolve to `undefined`. Source objects are applied from left to right.
3189 * Once a property is set, additional values of the same property are ignored.
3190 *
3191 * **Note:** This method mutates `object`.
3192 *
3193 * @static
3194 * @since 0.1.0
3195 * @memberOf _
3196 * @category Object
3197 * @param {Object} object The destination object.
3198 * @param {...Object} [sources] The source objects.
3199 * @returns {Object} Returns `object`.
3200 * @see _.defaultsDeep
3201 * @example
3202 *
3203 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3204 * // => { 'a': 1, 'b': 2 }
3205 */
3206 var defaults = baseRest(function(args) {
3207 args.push(undefined, assignInDefaults);
3208 return assignInWith.apply(undefined, args);
3209 });
3210
3211 /**
3212 * Checks if `path` is a direct property of `object`.
3213 *
3214 * @static
3215 * @since 0.1.0
3216 * @memberOf _
3217 * @category Object
3218 * @param {Object} object The object to query.
3219 * @param {Array|string} path The path to check.
3220 * @returns {boolean} Returns `true` if `path` exists, else `false`.
3221 * @example
3222 *
3223 * var object = { 'a': { 'b': 2 } };
3224 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
3225 *
3226 * _.has(object, 'a');
3227 * // => true
3228 *
3229 * _.has(object, 'a.b');
3230 * // => true
3231 *
3232 * _.has(object, ['a', 'b']);
3233 * // => true
3234 *
3235 * _.has(other, 'a');
3236 * // => false
3237 */
3238 function has(object, path) {
3239 return object != null && hasOwnProperty.call(object, path);
3240 }
3241
3242 /**
3243 * Creates an array of the own enumerable property names of `object`.
3244 *
3245 * **Note:** Non-object values are coerced to objects. See the
3246 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
3247 * for more details.
3248 *
3249 * @static
3250 * @since 0.1.0
3251 * @memberOf _
3252 * @category Object
3253 * @param {Object} object The object to query.
3254 * @returns {Array} Returns the array of property names.
3255 * @example
3256 *
3257 * function Foo() {
3258 * this.a = 1;
3259 * this.b = 2;
3260 * }
3261 *
3262 * Foo.prototype.c = 3;
3263 *
3264 * _.keys(new Foo);
3265 * // => ['a', 'b'] (iteration order is not guaranteed)
3266 *
3267 * _.keys('hi');
3268 * // => ['0', '1']
3269 */
3270 var keys = nativeKeys;
3271
3272 /**
3273 * Creates an array of the own and inherited enumerable property names of `object`.
3274 *
3275 * **Note:** Non-object values are coerced to objects.
3276 *
3277 * @static
3278 * @memberOf _
3279 * @since 3.0.0
3280 * @category Object
3281 * @param {Object} object The object to query.
3282 * @returns {Array} Returns the array of property names.
3283 * @example
3284 *
3285 * function Foo() {
3286 * this.a = 1;
3287 * this.b = 2;
3288 * }
3289 *
3290 * Foo.prototype.c = 3;
3291 *
3292 * _.keysIn(new Foo);
3293 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
3294 */
3295 var keysIn = nativeKeysIn;
3296
3297 /**
3298 * Creates an object composed of the picked `object` properties.
3299 *
3300 * @static
3301 * @since 0.1.0
3302 * @memberOf _
3303 * @category Object
3304 * @param {Object} object The source object.
3305 * @param {...(string|string[])} [paths] The property paths to pick.
3306 * @returns {Object} Returns the new object.
3307 * @example
3308 *
3309 * var object = { 'a': 1, 'b': '2', 'c': 3 };
3310 *
3311 * _.pick(object, ['a', 'c']);
3312 * // => { 'a': 1, 'c': 3 }
3313 */
3314 var pick = flatRest(function(object, paths) {
3315 return object == null ? {} : basePick(object, baseMap(paths, toKey));
3316 });
3317
3318 /**
3319 * This method is like `_.get` except that if the resolved value is a
3320 * function it's invoked with the `this` binding of its parent object and
3321 * its result is returned.
3322 *
3323 * @static
3324 * @since 0.1.0
3325 * @memberOf _
3326 * @category Object
3327 * @param {Object} object The object to query.
3328 * @param {Array|string} path The path of the property to resolve.
3329 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
3330 * @returns {*} Returns the resolved value.
3331 * @example
3332 *
3333 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
3334 *
3335 * _.result(object, 'a[0].b.c1');
3336 * // => 3
3337 *
3338 * _.result(object, 'a[0].b.c2');
3339 * // => 4
3340 *
3341 * _.result(object, 'a[0].b.c3', 'default');
3342 * // => 'default'
3343 *
3344 * _.result(object, 'a[0].b.c3', _.constant('default'));
3345 * // => 'default'
3346 */
3347 function result(object, path, defaultValue) {
3348 var value = object == null ? undefined : object[path];
3349 if (value === undefined) {
3350 value = defaultValue;
3351 }
3352 return isFunction(value) ? value.call(object) : value;
3353 }
3354
3355 /**
3356 * Creates an array of the own enumerable string keyed property values of `object`.
3357 *
3358 * **Note:** Non-object values are coerced to objects.
3359 *
3360 * @static
3361 * @since 0.1.0
3362 * @memberOf _
3363 * @category Object
3364 * @param {Object} object The object to query.
3365 * @returns {Array} Returns the array of property values.
3366 * @example
3367 *
3368 * function Foo() {
3369 * this.a = 1;
3370 * this.b = 2;
3371 * }
3372 *
3373 * Foo.prototype.c = 3;
3374 *
3375 * _.values(new Foo);
3376 * // => [1, 2] (iteration order is not guaranteed)
3377 *
3378 * _.values('hi');
3379 * // => ['h', 'i']
3380 */
3381 function values(object) {
3382 return object == null ? [] : baseValues(object, keys(object));
3383 }
3384
3385 /*------------------------------------------------------------------------*/
3386
3387 /**
3388 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
3389 * corresponding HTML entities.
3390 *
3391 * **Note:** No other characters are escaped. To escape additional
3392 * characters use a third-party library like [_he_](https://mths.be/he).
3393 *
3394 * Though the ">" character is escaped for symmetry, characters like
3395 * ">" and "/" don't need escaping in HTML and have no special meaning
3396 * unless they're part of a tag or unquoted attribute value. See
3397 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
3398 * (under "semi-related fun fact") for more details.
3399 *
3400 * When working with HTML you should always
3401 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
3402 * XSS vectors.
3403 *
3404 * @static
3405 * @since 0.1.0
3406 * @memberOf _
3407 * @category String
3408 * @param {string} [string=''] The string to escape.
3409 * @returns {string} Returns the escaped string.
3410 * @example
3411 *
3412 * _.escape('fred, barney, & pebbles');
3413 * // => 'fred, barney, &amp; pebbles'
3414 */
3415 function escape(string) {
3416 string = toString(string);
3417 return (string && reHasUnescapedHtml.test(string))
3418 ? string.replace(reUnescapedHtml, escapeHtmlChar)
3419 : string;
3420 }
3421
3422 /*------------------------------------------------------------------------*/
3423
3424 /**
3425 * This method returns the first argument it receives.
3426 *
3427 * @static
3428 * @since 0.1.0
3429 * @memberOf _
3430 * @category Util
3431 * @param {*} value Any value.
3432 * @returns {*} Returns `value`.
3433 * @example
3434 *
3435 * var object = { 'a': 1 };
3436 *
3437 * console.log(_.identity(object) === object);
3438 * // => true
3439 */
3440 function identity(value) {
3441 return value;
3442 }
3443
3444 /**
3445 * Creates a function that invokes `func` with the arguments of the created
3446 * function. If `func` is a property name, the created function returns the
3447 * property value for a given element. If `func` is an array or object, the
3448 * created function returns `true` for elements that contain the equivalent
3449 * source properties, otherwise it returns `false`.
3450 *
3451 * @static
3452 * @since 4.0.0
3453 * @memberOf _
3454 * @category Util
3455 * @param {*} [func=_.identity] The value to convert to a callback.
3456 * @returns {Function} Returns the callback.
3457 * @example
3458 *
3459 * var users = [
3460 * { 'user': 'barney', 'age': 36, 'active': true },
3461 * { 'user': 'fred', 'age': 40, 'active': false }
3462 * ];
3463 *
3464 * // The `_.matches` iteratee shorthand.
3465 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
3466 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
3467 *
3468 * // The `_.matchesProperty` iteratee shorthand.
3469 * _.filter(users, _.iteratee(['user', 'fred']));
3470 * // => [{ 'user': 'fred', 'age': 40 }]
3471 *
3472 * // The `_.property` iteratee shorthand.
3473 * _.map(users, _.iteratee('user'));
3474 * // => ['barney', 'fred']
3475 *
3476 * // Create custom iteratee shorthands.
3477 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
3478 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
3479 * return func.test(string);
3480 * };
3481 * });
3482 *
3483 * _.filter(['abc', 'def'], /ef/);
3484 * // => ['def']
3485 */
3486 var iteratee = baseIteratee;
3487
3488 /**
3489 * Creates a function that performs a partial deep comparison between a given
3490 * object and `source`, returning `true` if the given object has equivalent
3491 * property values, else `false`.
3492 *
3493 * **Note:** The created function is equivalent to `_.isMatch` with `source`
3494 * partially applied.
3495 *
3496 * Partial comparisons will match empty array and empty object `source`
3497 * values against any array or object value, respectively. See `_.isEqual`
3498 * for a list of supported value comparisons.
3499 *
3500 * @static
3501 * @memberOf _
3502 * @since 3.0.0
3503 * @category Util
3504 * @param {Object} source The object of property values to match.
3505 * @returns {Function} Returns the new spec function.
3506 * @example
3507 *
3508 * var objects = [
3509 * { 'a': 1, 'b': 2, 'c': 3 },
3510 * { 'a': 4, 'b': 5, 'c': 6 }
3511 * ];
3512 *
3513 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
3514 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
3515 */
3516 function matches(source) {
3517 return baseMatches(assign({}, source));
3518 }
3519
3520 /**
3521 * Adds all own enumerable string keyed function properties of a source
3522 * object to the destination object. If `object` is a function, then methods
3523 * are added to its prototype as well.
3524 *
3525 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
3526 * avoid conflicts caused by modifying the original.
3527 *
3528 * @static
3529 * @since 0.1.0
3530 * @memberOf _
3531 * @category Util
3532 * @param {Function|Object} [object=lodash] The destination object.
3533 * @param {Object} source The object of functions to add.
3534 * @param {Object} [options={}] The options object.
3535 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
3536 * @returns {Function|Object} Returns `object`.
3537 * @example
3538 *
3539 * function vowels(string) {
3540 * return _.filter(string, function(v) {
3541 * return /[aeiou]/i.test(v);
3542 * });
3543 * }
3544 *
3545 * _.mixin({ 'vowels': vowels });
3546 * _.vowels('fred');
3547 * // => ['e']
3548 *
3549 * _('fred').vowels().value();
3550 * // => ['e']
3551 *
3552 * _.mixin({ 'vowels': vowels }, { 'chain': false });
3553 * _('fred').vowels();
3554 * // => ['e']
3555 */
3556 function mixin(object, source, options) {
3557 var props = keys(source),
3558 methodNames = baseFunctions(source, props);
3559
3560 if (options == null &&
3561 !(isObject(source) && (methodNames.length || !props.length))) {
3562 options = source;
3563 source = object;
3564 object = this;
3565 methodNames = baseFunctions(source, keys(source));
3566 }
3567 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
3568 isFunc = isFunction(object);
3569
3570 baseEach(methodNames, function(methodName) {
3571 var func = source[methodName];
3572 object[methodName] = func;
3573 if (isFunc) {
3574 object.prototype[methodName] = function() {
3575 var chainAll = this.__chain__;
3576 if (chain || chainAll) {
3577 var result = object(this.__wrapped__),
3578 actions = result.__actions__ = copyArray(this.__actions__);
3579
3580 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
3581 result.__chain__ = chainAll;
3582 return result;
3583 }
3584 return func.apply(object, arrayPush([this.value()], arguments));
3585 };
3586 }
3587 });
3588
3589 return object;
3590 }
3591
3592 /**
3593 * Reverts the `_` variable to its previous value and returns a reference to
3594 * the `lodash` function.
3595 *
3596 * @static
3597 * @since 0.1.0
3598 * @memberOf _
3599 * @category Util
3600 * @returns {Function} Returns the `lodash` function.
3601 * @example
3602 *
3603 * var lodash = _.noConflict();
3604 */
3605 function noConflict() {
3606 if (root._ === this) {
3607 root._ = oldDash;
3608 }
3609 return this;
3610 }
3611
3612 /**
3613 * This method returns `undefined`.
3614 *
3615 * @static
3616 * @memberOf _
3617 * @since 2.3.0
3618 * @category Util
3619 * @example
3620 *
3621 * _.times(2, _.noop);
3622 * // => [undefined, undefined]
3623 */
3624 function noop() {
3625 // No operation performed.
3626 }
3627
3628 /**
3629 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
3630 *
3631 * @static
3632 * @since 0.1.0
3633 * @memberOf _
3634 * @category Util
3635 * @param {string} [prefix=''] The value to prefix the ID with.
3636 * @returns {string} Returns the unique ID.
3637 * @example
3638 *
3639 * _.uniqueId('contact_');
3640 * // => 'contact_104'
3641 *
3642 * _.uniqueId();
3643 * // => '105'
3644 */
3645 function uniqueId(prefix) {
3646 var id = ++idCounter;
3647 return toString(prefix) + id;
3648 }
3649
3650 /*------------------------------------------------------------------------*/
3651
3652 /**
3653 * Computes the maximum value of `array`. If `array` is empty or falsey,
3654 * `undefined` is returned.
3655 *
3656 * @static
3657 * @since 0.1.0
3658 * @memberOf _
3659 * @category Math
3660 * @param {Array} array The array to iterate over.
3661 * @returns {*} Returns the maximum value.
3662 * @example
3663 *
3664 * _.max([4, 2, 8, 6]);
3665 * // => 8
3666 *
3667 * _.max([]);
3668 * // => undefined
3669 */
3670 function max(array) {
3671 return (array && array.length)
3672 ? baseExtremum(array, identity, baseGt)
3673 : undefined;
3674 }
3675
3676 /**
3677 * Computes the minimum value of `array`. If `array` is empty or falsey,
3678 * `undefined` is returned.
3679 *
3680 * @static
3681 * @since 0.1.0
3682 * @memberOf _
3683 * @category Math
3684 * @param {Array} array The array to iterate over.
3685 * @returns {*} Returns the minimum value.
3686 * @example
3687 *
3688 * _.min([4, 2, 8, 6]);
3689 * // => 2
3690 *
3691 * _.min([]);
3692 * // => undefined
3693 */
3694 function min(array) {
3695 return (array && array.length)
3696 ? baseExtremum(array, identity, baseLt)
3697 : undefined;
3698 }
3699
3700 /*------------------------------------------------------------------------*/
3701
3702 // Add methods that return wrapped values in chain sequences.
3703 lodash.assignIn = assignIn;
3704 lodash.before = before;
3705 lodash.bind = bind;
3706 lodash.chain = chain;
3707 lodash.compact = compact;
3708 lodash.concat = concat;
3709 lodash.create = create;
3710 lodash.defaults = defaults;
3711 lodash.defer = defer;
3712 lodash.delay = delay;
3713 lodash.filter = filter;
3714 lodash.flatten = flatten;
3715 lodash.flattenDeep = flattenDeep;
3716 lodash.iteratee = iteratee;
3717 lodash.keys = keys;
3718 lodash.map = map;
3719 lodash.matches = matches;
3720 lodash.mixin = mixin;
3721 lodash.negate = negate;
3722 lodash.once = once;
3723 lodash.pick = pick;
3724 lodash.slice = slice;
3725 lodash.sortBy = sortBy;
3726 lodash.tap = tap;
3727 lodash.thru = thru;
3728 lodash.toArray = toArray;
3729 lodash.values = values;
3730
3731 // Add aliases.
3732 lodash.extend = assignIn;
3733
3734 // Add methods to `lodash.prototype`.
3735 mixin(lodash, lodash);
3736
3737 /*------------------------------------------------------------------------*/
3738
3739 // Add methods that return unwrapped values in chain sequences.
3740 lodash.clone = clone;
3741 lodash.escape = escape;
3742 lodash.every = every;
3743 lodash.find = find;
3744 lodash.forEach = forEach;
3745 lodash.has = has;
3746 lodash.head = head;
3747 lodash.identity = identity;
3748 lodash.indexOf = indexOf;
3749 lodash.isArguments = isArguments;
3750 lodash.isArray = isArray;
3751 lodash.isBoolean = isBoolean;
3752 lodash.isDate = isDate;
3753 lodash.isEmpty = isEmpty;
3754 lodash.isEqual = isEqual;
3755 lodash.isFinite = isFinite;
3756 lodash.isFunction = isFunction;
3757 lodash.isNaN = isNaN;
3758 lodash.isNull = isNull;
3759 lodash.isNumber = isNumber;
3760 lodash.isObject = isObject;
3761 lodash.isRegExp = isRegExp;
3762 lodash.isString = isString;
3763 lodash.isUndefined = isUndefined;
3764 lodash.last = last;
3765 lodash.max = max;
3766 lodash.min = min;
3767 lodash.noConflict = noConflict;
3768 lodash.noop = noop;
3769 lodash.reduce = reduce;
3770 lodash.result = result;
3771 lodash.size = size;
3772 lodash.some = some;
3773 lodash.uniqueId = uniqueId;
3774
3775 // Add aliases.
3776 lodash.each = forEach;
3777 lodash.first = head;
3778
3779 mixin(lodash, (function() {
3780 var source = {};
3781 baseForOwn(lodash, function(func, methodName) {
3782 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
3783 source[methodName] = func;
3784 }
3785 });
3786 return source;
3787 }()), { 'chain': false });
3788
3789 /*------------------------------------------------------------------------*/
3790
3791 /**
3792 * The semantic version number.
3793 *
3794 * @static
3795 * @memberOf _
3796 * @type {string}
3797 */
3798 lodash.VERSION = VERSION;
3799
3800 // Add `Array` methods to `lodash.prototype`.
3801 baseEach(['pop', 'join', 'replace', 'reverse', 'split', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
3802 var func = (/^(?:replace|split)$/.test(methodName) ? String.prototype : arrayProto)[methodName],
3803 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
3804 retUnwrapped = /^(?:pop|join|replace|shift)$/.test(methodName);
3805
3806 lodash.prototype[methodName] = function() {
3807 var args = arguments;
3808 if (retUnwrapped && !this.__chain__) {
3809 var value = this.value();
3810 return func.apply(isArray(value) ? value : [], args);
3811 }
3812 return this[chainName](function(value) {
3813 return func.apply(isArray(value) ? value : [], args);
3814 });
3815 };
3816 });
3817
3818 // Add chain sequence methods to the `lodash` wrapper.
3819 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
3820
3821 /*--------------------------------------------------------------------------*/
3822
3823 // Some AMD build optimizers, like r.js, check for condition patterns like:
3824 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
3825 // Expose Lodash on the global object to prevent errors when Lodash is
3826 // loaded by a script tag in the presence of an AMD loader.
3827 // See http://requirejs.org/docs/errors.html#mismatch for more details.
3828 // Use `_.noConflict` to remove Lodash from the global object.
3829 root._ = lodash;
3830
3831 // Define as an anonymous module so, through path mapping, it can be
3832 // referenced as the "underscore" module.
3833 define(function() {
3834 return lodash;
3835 });
3836 }
3837 // Check for `exports` after `define` in case a build optimizer adds it.
3838 else if (freeModule) {
3839 // Export for Node.js.
3840 (freeModule.exports = lodash)._ = lodash;
3841 // Export for CommonJS support.
3842 freeExports._ = lodash;
3843 }
3844 else {
3845 // Export to the global object.
3846 root._ = lodash;
3847 }
3848}.call(this));