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.2';
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
1444 /**
1445 * Creates an array with all falsey values removed. The values `false`, `null`,
1446 * `0`, `""`, `undefined`, and `NaN` are falsey.
1447 *
1448 * @static
1449 * @memberOf _
1450 * @since 0.1.0
1451 * @category Array
1452 * @param {Array} array The array to compact.
1453 * @returns {Array} Returns the new array of filtered values.
1454 * @example
1455 *
1456 * _.compact([0, 1, false, 2, '', 3]);
1457 * // => [1, 2, 3]
1458 */
1459 function compact(array) {
1460 return baseFilter(array, Boolean);
1461 }
1462
1463 /**
1464 * Creates a new array concatenating `array` with any additional arrays
1465 * and/or values.
1466 *
1467 * @static
1468 * @memberOf _
1469 * @since 4.0.0
1470 * @category Array
1471 * @param {Array} array The array to concatenate.
1472 * @param {...*} [values] The values to concatenate.
1473 * @returns {Array} Returns the new concatenated array.
1474 * @example
1475 *
1476 * var array = [1];
1477 * var other = _.concat(array, 2, [3], [[4]]);
1478 *
1479 * console.log(other);
1480 * // => [1, 2, 3, [4]]
1481 *
1482 * console.log(array);
1483 * // => [1]
1484 */
1485 function concat() {
1486 var length = arguments.length;
1487 if (!length) {
1488 return [];
1489 }
1490 var args = Array(length - 1),
1491 array = arguments[0],
1492 index = length;
1493
1494 while (index--) {
1495 args[index - 1] = arguments[index];
1496 }
1497 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
1498 }
1499
1500 /**
1501 * This method is like `_.find` except that it returns the index of the first
1502 * element `predicate` returns truthy for instead of the element itself.
1503 *
1504 * @static
1505 * @memberOf _
1506 * @since 1.1.0
1507 * @category Array
1508 * @param {Array} array The array to inspect.
1509 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1510 * @param {number} [fromIndex=0] The index to search from.
1511 * @returns {number} Returns the index of the found element, else `-1`.
1512 * @example
1513 *
1514 * var users = [
1515 * { 'user': 'barney', 'active': false },
1516 * { 'user': 'fred', 'active': false },
1517 * { 'user': 'pebbles', 'active': true }
1518 * ];
1519 *
1520 * _.findIndex(users, function(o) { return o.user == 'barney'; });
1521 * // => 0
1522 *
1523 * // The `_.matches` iteratee shorthand.
1524 * _.findIndex(users, { 'user': 'fred', 'active': false });
1525 * // => 1
1526 *
1527 * // The `_.matchesProperty` iteratee shorthand.
1528 * _.findIndex(users, ['active', false]);
1529 * // => 0
1530 *
1531 * // The `_.property` iteratee shorthand.
1532 * _.findIndex(users, 'active');
1533 * // => 2
1534 */
1535 function findIndex(array, predicate, fromIndex) {
1536 var length = array == null ? 0 : array.length;
1537 if (!length) {
1538 return -1;
1539 }
1540 var index = fromIndex == null ? 0 : toInteger(fromIndex);
1541 if (index < 0) {
1542 index = nativeMax(length + index, 0);
1543 }
1544 return baseFindIndex(array, baseIteratee(predicate, 3), index);
1545 }
1546
1547 /**
1548 * Flattens `array` a single level deep.
1549 *
1550 * @static
1551 * @memberOf _
1552 * @since 0.1.0
1553 * @category Array
1554 * @param {Array} array The array to flatten.
1555 * @returns {Array} Returns the new flattened array.
1556 * @example
1557 *
1558 * _.flatten([1, [2, [3, [4]], 5]]);
1559 * // => [1, 2, [3, [4]], 5]
1560 */
1561 function flatten(array) {
1562 var length = array == null ? 0 : array.length;
1563 return length ? baseFlatten(array, 1) : [];
1564 }
1565
1566 /**
1567 * Recursively flattens `array`.
1568 *
1569 * @static
1570 * @memberOf _
1571 * @since 3.0.0
1572 * @category Array
1573 * @param {Array} array The array to flatten.
1574 * @returns {Array} Returns the new flattened array.
1575 * @example
1576 *
1577 * _.flattenDeep([1, [2, [3, [4]], 5]]);
1578 * // => [1, 2, 3, 4, 5]
1579 */
1580 function flattenDeep(array) {
1581 var length = array == null ? 0 : array.length;
1582 return length ? baseFlatten(array, INFINITY) : [];
1583 }
1584
1585 /**
1586 * Gets the first element of `array`.
1587 *
1588 * @static
1589 * @memberOf _
1590 * @since 0.1.0
1591 * @alias first
1592 * @category Array
1593 * @param {Array} array The array to query.
1594 * @returns {*} Returns the first element of `array`.
1595 * @example
1596 *
1597 * _.head([1, 2, 3]);
1598 * // => 1
1599 *
1600 * _.head([]);
1601 * // => undefined
1602 */
1603 function head(array) {
1604 return (array && array.length) ? array[0] : undefined;
1605 }
1606
1607 /**
1608 * Gets the index at which the first occurrence of `value` is found in `array`
1609 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1610 * for equality comparisons. If `fromIndex` is negative, it's used as the
1611 * offset from the end of `array`.
1612 *
1613 * @static
1614 * @memberOf _
1615 * @since 0.1.0
1616 * @category Array
1617 * @param {Array} array The array to inspect.
1618 * @param {*} value The value to search for.
1619 * @param {number} [fromIndex=0] The index to search from.
1620 * @returns {number} Returns the index of the matched value, else `-1`.
1621 * @example
1622 *
1623 * _.indexOf([1, 2, 1, 2], 2);
1624 * // => 1
1625 *
1626 * // Search from the `fromIndex`.
1627 * _.indexOf([1, 2, 1, 2], 2, 2);
1628 * // => 3
1629 */
1630 function indexOf(array, value, fromIndex) {
1631 var length = array == null ? 0 : array.length;
1632 if (typeof fromIndex == 'number') {
1633 fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
1634 } else {
1635 fromIndex = 0;
1636 }
1637 var index = (fromIndex || 0) - 1,
1638 isReflexive = value === value;
1639
1640 while (++index < length) {
1641 var other = array[index];
1642 if ((isReflexive ? other === value : other !== other)) {
1643 return index;
1644 }
1645 }
1646 return -1;
1647 }
1648
1649 /**
1650 * Gets the last element of `array`.
1651 *
1652 * @static
1653 * @memberOf _
1654 * @since 0.1.0
1655 * @category Array
1656 * @param {Array} array The array to query.
1657 * @returns {*} Returns the last element of `array`.
1658 * @example
1659 *
1660 * _.last([1, 2, 3]);
1661 * // => 3
1662 */
1663 function last(array) {
1664 var length = array == null ? 0 : array.length;
1665 return length ? array[length - 1] : undefined;
1666 }
1667
1668 /**
1669 * Creates a slice of `array` from `start` up to, but not including, `end`.
1670 *
1671 * **Note:** This method is used instead of
1672 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
1673 * returned.
1674 *
1675 * @static
1676 * @memberOf _
1677 * @since 3.0.0
1678 * @category Array
1679 * @param {Array} array The array to slice.
1680 * @param {number} [start=0] The start position.
1681 * @param {number} [end=array.length] The end position.
1682 * @returns {Array} Returns the slice of `array`.
1683 */
1684 function slice(array, start, end) {
1685 var length = array == null ? 0 : array.length;
1686 start = start == null ? 0 : +start;
1687 end = end === undefined ? length : +end;
1688 return length ? baseSlice(array, start, end) : [];
1689 }
1690
1691 /*------------------------------------------------------------------------*/
1692
1693 /**
1694 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
1695 * chain sequences enabled. The result of such sequences must be unwrapped
1696 * with `_#value`.
1697 *
1698 * @static
1699 * @memberOf _
1700 * @since 1.3.0
1701 * @category Seq
1702 * @param {*} value The value to wrap.
1703 * @returns {Object} Returns the new `lodash` wrapper instance.
1704 * @example
1705 *
1706 * var users = [
1707 * { 'user': 'barney', 'age': 36 },
1708 * { 'user': 'fred', 'age': 40 },
1709 * { 'user': 'pebbles', 'age': 1 }
1710 * ];
1711 *
1712 * var youngest = _
1713 * .chain(users)
1714 * .sortBy('age')
1715 * .map(function(o) {
1716 * return o.user + ' is ' + o.age;
1717 * })
1718 * .head()
1719 * .value();
1720 * // => 'pebbles is 1'
1721 */
1722 function chain(value) {
1723 var result = lodash(value);
1724 result.__chain__ = true;
1725 return result;
1726 }
1727
1728 /**
1729 * This method invokes `interceptor` and returns `value`. The interceptor
1730 * is invoked with one argument; (value). The purpose of this method is to
1731 * "tap into" a method chain sequence in order to modify intermediate results.
1732 *
1733 * @static
1734 * @memberOf _
1735 * @since 0.1.0
1736 * @category Seq
1737 * @param {*} value The value to provide to `interceptor`.
1738 * @param {Function} interceptor The function to invoke.
1739 * @returns {*} Returns `value`.
1740 * @example
1741 *
1742 * _([1, 2, 3])
1743 * .tap(function(array) {
1744 * // Mutate input array.
1745 * array.pop();
1746 * })
1747 * .reverse()
1748 * .value();
1749 * // => [2, 1]
1750 */
1751 function tap(value, interceptor) {
1752 interceptor(value);
1753 return value;
1754 }
1755
1756 /**
1757 * This method is like `_.tap` except that it returns the result of `interceptor`.
1758 * The purpose of this method is to "pass thru" values replacing intermediate
1759 * results in a method chain sequence.
1760 *
1761 * @static
1762 * @memberOf _
1763 * @since 3.0.0
1764 * @category Seq
1765 * @param {*} value The value to provide to `interceptor`.
1766 * @param {Function} interceptor The function to invoke.
1767 * @returns {*} Returns the result of `interceptor`.
1768 * @example
1769 *
1770 * _(' abc ')
1771 * .chain()
1772 * .trim()
1773 * .thru(function(value) {
1774 * return [value];
1775 * })
1776 * .value();
1777 * // => ['abc']
1778 */
1779 function thru(value, interceptor) {
1780 return interceptor(value);
1781 }
1782
1783 /**
1784 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
1785 *
1786 * @name chain
1787 * @memberOf _
1788 * @since 0.1.0
1789 * @category Seq
1790 * @returns {Object} Returns the new `lodash` wrapper instance.
1791 * @example
1792 *
1793 * var users = [
1794 * { 'user': 'barney', 'age': 36 },
1795 * { 'user': 'fred', 'age': 40 }
1796 * ];
1797 *
1798 * // A sequence without explicit chaining.
1799 * _(users).head();
1800 * // => { 'user': 'barney', 'age': 36 }
1801 *
1802 * // A sequence with explicit chaining.
1803 * _(users)
1804 * .chain()
1805 * .head()
1806 * .pick('user')
1807 * .value();
1808 * // => { 'user': 'barney' }
1809 */
1810 function wrapperChain() {
1811 return chain(this);
1812 }
1813
1814 /**
1815 * Executes the chain sequence to resolve the unwrapped value.
1816 *
1817 * @name value
1818 * @memberOf _
1819 * @since 0.1.0
1820 * @alias toJSON, valueOf
1821 * @category Seq
1822 * @returns {*} Returns the resolved unwrapped value.
1823 * @example
1824 *
1825 * _([1, 2, 3]).value();
1826 * // => [1, 2, 3]
1827 */
1828 function wrapperValue() {
1829 return baseWrapperValue(this.__wrapped__, this.__actions__);
1830 }
1831
1832 /*------------------------------------------------------------------------*/
1833
1834 /**
1835 * Checks if `predicate` returns truthy for **all** elements of `collection`.
1836 * Iteration is stopped once `predicate` returns falsey. The predicate is
1837 * invoked with three arguments: (value, index|key, collection).
1838 *
1839 * **Note:** This method returns `true` for
1840 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
1841 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
1842 * elements of empty collections.
1843 *
1844 * @static
1845 * @memberOf _
1846 * @since 0.1.0
1847 * @category Collection
1848 * @param {Array|Object} collection The collection to iterate over.
1849 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1850 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
1851 * @returns {boolean} Returns `true` if all elements pass the predicate check,
1852 * else `false`.
1853 * @example
1854 *
1855 * _.every([true, 1, null, 'yes'], Boolean);
1856 * // => false
1857 *
1858 * var users = [
1859 * { 'user': 'barney', 'age': 36, 'active': false },
1860 * { 'user': 'fred', 'age': 40, 'active': false }
1861 * ];
1862 *
1863 * // The `_.matches` iteratee shorthand.
1864 * _.every(users, { 'user': 'barney', 'active': false });
1865 * // => false
1866 *
1867 * // The `_.matchesProperty` iteratee shorthand.
1868 * _.every(users, ['active', false]);
1869 * // => true
1870 *
1871 * // The `_.property` iteratee shorthand.
1872 * _.every(users, 'active');
1873 * // => false
1874 */
1875 function every(collection, predicate, guard) {
1876 predicate = guard ? undefined : predicate;
1877 return baseEvery(collection, baseIteratee(predicate));
1878 }
1879
1880 /**
1881 * Iterates over elements of `collection`, returning an array of all elements
1882 * `predicate` returns truthy for. The predicate is invoked with three
1883 * arguments: (value, index|key, collection).
1884 *
1885 * **Note:** Unlike `_.remove`, this method returns a new array.
1886 *
1887 * @static
1888 * @memberOf _
1889 * @since 0.1.0
1890 * @category Collection
1891 * @param {Array|Object} collection The collection to iterate over.
1892 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1893 * @returns {Array} Returns the new filtered array.
1894 * @see _.reject
1895 * @example
1896 *
1897 * var users = [
1898 * { 'user': 'barney', 'age': 36, 'active': true },
1899 * { 'user': 'fred', 'age': 40, 'active': false }
1900 * ];
1901 *
1902 * _.filter(users, function(o) { return !o.active; });
1903 * // => objects for ['fred']
1904 *
1905 * // The `_.matches` iteratee shorthand.
1906 * _.filter(users, { 'age': 36, 'active': true });
1907 * // => objects for ['barney']
1908 *
1909 * // The `_.matchesProperty` iteratee shorthand.
1910 * _.filter(users, ['active', false]);
1911 * // => objects for ['fred']
1912 *
1913 * // The `_.property` iteratee shorthand.
1914 * _.filter(users, 'active');
1915 * // => objects for ['barney']
1916 */
1917 function filter(collection, predicate) {
1918 return baseFilter(collection, baseIteratee(predicate));
1919 }
1920
1921 /**
1922 * Iterates over elements of `collection`, returning the first element
1923 * `predicate` returns truthy for. The predicate is invoked with three
1924 * arguments: (value, index|key, collection).
1925 *
1926 * @static
1927 * @memberOf _
1928 * @since 0.1.0
1929 * @category Collection
1930 * @param {Array|Object} collection The collection to inspect.
1931 * @param {Function} [predicate=_.identity] The function invoked per iteration.
1932 * @param {number} [fromIndex=0] The index to search from.
1933 * @returns {*} Returns the matched element, else `undefined`.
1934 * @example
1935 *
1936 * var users = [
1937 * { 'user': 'barney', 'age': 36, 'active': true },
1938 * { 'user': 'fred', 'age': 40, 'active': false },
1939 * { 'user': 'pebbles', 'age': 1, 'active': true }
1940 * ];
1941 *
1942 * _.find(users, function(o) { return o.age < 40; });
1943 * // => object for 'barney'
1944 *
1945 * // The `_.matches` iteratee shorthand.
1946 * _.find(users, { 'age': 1, 'active': true });
1947 * // => object for 'pebbles'
1948 *
1949 * // The `_.matchesProperty` iteratee shorthand.
1950 * _.find(users, ['active', false]);
1951 * // => object for 'fred'
1952 *
1953 * // The `_.property` iteratee shorthand.
1954 * _.find(users, 'active');
1955 * // => object for 'barney'
1956 */
1957 var find = createFind(findIndex);
1958
1959 /**
1960 * Iterates over elements of `collection` and invokes `iteratee` for each element.
1961 * The iteratee is invoked with three arguments: (value, index|key, collection).
1962 * Iteratee functions may exit iteration early by explicitly returning `false`.
1963 *
1964 * **Note:** As with other "Collections" methods, objects with a "length"
1965 * property are iterated like arrays. To avoid this behavior use `_.forIn`
1966 * or `_.forOwn` for object iteration.
1967 *
1968 * @static
1969 * @memberOf _
1970 * @since 0.1.0
1971 * @alias each
1972 * @category Collection
1973 * @param {Array|Object} collection The collection to iterate over.
1974 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
1975 * @returns {Array|Object} Returns `collection`.
1976 * @see _.forEachRight
1977 * @example
1978 *
1979 * _.forEach([1, 2], function(value) {
1980 * console.log(value);
1981 * });
1982 * // => Logs `1` then `2`.
1983 *
1984 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
1985 * console.log(key);
1986 * });
1987 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
1988 */
1989 function forEach(collection, iteratee) {
1990 return baseEach(collection, baseIteratee(iteratee));
1991 }
1992
1993 /**
1994 * Creates an array of values by running each element in `collection` thru
1995 * `iteratee`. The iteratee is invoked with three arguments:
1996 * (value, index|key, collection).
1997 *
1998 * Many lodash methods are guarded to work as iteratees for methods like
1999 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
2000 *
2001 * The guarded methods are:
2002 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
2003 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
2004 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
2005 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
2006 *
2007 * @static
2008 * @memberOf _
2009 * @since 0.1.0
2010 * @category Collection
2011 * @param {Array|Object} collection The collection to iterate over.
2012 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2013 * @returns {Array} Returns the new mapped array.
2014 * @example
2015 *
2016 * function square(n) {
2017 * return n * n;
2018 * }
2019 *
2020 * _.map([4, 8], square);
2021 * // => [16, 64]
2022 *
2023 * _.map({ 'a': 4, 'b': 8 }, square);
2024 * // => [16, 64] (iteration order is not guaranteed)
2025 *
2026 * var users = [
2027 * { 'user': 'barney' },
2028 * { 'user': 'fred' }
2029 * ];
2030 *
2031 * // The `_.property` iteratee shorthand.
2032 * _.map(users, 'user');
2033 * // => ['barney', 'fred']
2034 */
2035 function map(collection, iteratee) {
2036 return baseMap(collection, baseIteratee(iteratee));
2037 }
2038
2039 /**
2040 * Reduces `collection` to a value which is the accumulated result of running
2041 * each element in `collection` thru `iteratee`, where each successive
2042 * invocation is supplied the return value of the previous. If `accumulator`
2043 * is not given, the first element of `collection` is used as the initial
2044 * value. The iteratee is invoked with four arguments:
2045 * (accumulator, value, index|key, collection).
2046 *
2047 * Many lodash methods are guarded to work as iteratees for methods like
2048 * `_.reduce`, `_.reduceRight`, and `_.transform`.
2049 *
2050 * The guarded methods are:
2051 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
2052 * and `sortBy`
2053 *
2054 * @static
2055 * @memberOf _
2056 * @since 0.1.0
2057 * @category Collection
2058 * @param {Array|Object} collection The collection to iterate over.
2059 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2060 * @param {*} [accumulator] The initial value.
2061 * @returns {*} Returns the accumulated value.
2062 * @see _.reduceRight
2063 * @example
2064 *
2065 * _.reduce([1, 2], function(sum, n) {
2066 * return sum + n;
2067 * }, 0);
2068 * // => 3
2069 *
2070 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
2071 * (result[value] || (result[value] = [])).push(key);
2072 * return result;
2073 * }, {});
2074 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
2075 */
2076 function reduce(collection, iteratee, accumulator) {
2077 return baseReduce(collection, baseIteratee(iteratee), accumulator, arguments.length < 3, baseEach);
2078 }
2079
2080 /**
2081 * Gets the size of `collection` by returning its length for array-like
2082 * values or the number of own enumerable string keyed properties for objects.
2083 *
2084 * @static
2085 * @memberOf _
2086 * @since 0.1.0
2087 * @category Collection
2088 * @param {Array|Object|string} collection The collection to inspect.
2089 * @returns {number} Returns the collection size.
2090 * @example
2091 *
2092 * _.size([1, 2, 3]);
2093 * // => 3
2094 *
2095 * _.size({ 'a': 1, 'b': 2 });
2096 * // => 2
2097 *
2098 * _.size('pebbles');
2099 * // => 7
2100 */
2101 function size(collection) {
2102 if (collection == null) {
2103 return 0;
2104 }
2105 collection = isArrayLike(collection) ? collection : nativeKeys(collection);
2106 return collection.length;
2107 }
2108
2109 /**
2110 * Checks if `predicate` returns truthy for **any** element of `collection`.
2111 * Iteration is stopped once `predicate` returns truthy. The predicate is
2112 * invoked with three arguments: (value, index|key, collection).
2113 *
2114 * @static
2115 * @memberOf _
2116 * @since 0.1.0
2117 * @category Collection
2118 * @param {Array|Object} collection The collection to iterate over.
2119 * @param {Function} [predicate=_.identity] The function invoked per iteration.
2120 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2121 * @returns {boolean} Returns `true` if any element passes the predicate check,
2122 * else `false`.
2123 * @example
2124 *
2125 * _.some([null, 0, 'yes', false], Boolean);
2126 * // => true
2127 *
2128 * var users = [
2129 * { 'user': 'barney', 'active': true },
2130 * { 'user': 'fred', 'active': false }
2131 * ];
2132 *
2133 * // The `_.matches` iteratee shorthand.
2134 * _.some(users, { 'user': 'barney', 'active': false });
2135 * // => false
2136 *
2137 * // The `_.matchesProperty` iteratee shorthand.
2138 * _.some(users, ['active', false]);
2139 * // => true
2140 *
2141 * // The `_.property` iteratee shorthand.
2142 * _.some(users, 'active');
2143 * // => true
2144 */
2145 function some(collection, predicate, guard) {
2146 predicate = guard ? undefined : predicate;
2147 return baseSome(collection, baseIteratee(predicate));
2148 }
2149
2150 /**
2151 * Creates an array of elements, sorted in ascending order by the results of
2152 * running each element in a collection thru each iteratee. This method
2153 * performs a stable sort, that is, it preserves the original sort order of
2154 * equal elements. The iteratees are invoked with one argument: (value).
2155 *
2156 * @static
2157 * @memberOf _
2158 * @since 0.1.0
2159 * @category Collection
2160 * @param {Array|Object} collection The collection to iterate over.
2161 * @param {...(Function|Function[])} [iteratees=[_.identity]]
2162 * The iteratees to sort by.
2163 * @returns {Array} Returns the new sorted array.
2164 * @example
2165 *
2166 * var users = [
2167 * { 'user': 'fred', 'age': 48 },
2168 * { 'user': 'barney', 'age': 36 },
2169 * { 'user': 'fred', 'age': 40 },
2170 * { 'user': 'barney', 'age': 34 }
2171 * ];
2172 *
2173 * _.sortBy(users, [function(o) { return o.user; }]);
2174 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
2175 *
2176 * _.sortBy(users, ['user', 'age']);
2177 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
2178 */
2179 function sortBy(collection, iteratee) {
2180 var index = 0;
2181 iteratee = baseIteratee(iteratee);
2182
2183 return baseMap(baseMap(collection, function(value, key, collection) {
2184 return { 'value': value, 'index': index++, 'criteria': iteratee(value, key, collection) };
2185 }).sort(function(object, other) {
2186 return compareAscending(object.criteria, other.criteria) || (object.index - other.index);
2187 }), baseProperty('value'));
2188 }
2189
2190 /*------------------------------------------------------------------------*/
2191
2192 /**
2193 * Creates a function that invokes `func`, with the `this` binding and arguments
2194 * of the created function, while it's called less than `n` times. Subsequent
2195 * calls to the created function return the result of the last `func` invocation.
2196 *
2197 * @static
2198 * @memberOf _
2199 * @since 3.0.0
2200 * @category Function
2201 * @param {number} n The number of calls at which `func` is no longer invoked.
2202 * @param {Function} func The function to restrict.
2203 * @returns {Function} Returns the new restricted function.
2204 * @example
2205 *
2206 * jQuery(element).on('click', _.before(5, addContactToList));
2207 * // => Allows adding up to 4 contacts to the list.
2208 */
2209 function before(n, func) {
2210 var result;
2211 if (typeof func != 'function') {
2212 throw new TypeError(FUNC_ERROR_TEXT);
2213 }
2214 n = toInteger(n);
2215 return function() {
2216 if (--n > 0) {
2217 result = func.apply(this, arguments);
2218 }
2219 if (n <= 1) {
2220 func = undefined;
2221 }
2222 return result;
2223 };
2224 }
2225
2226 /**
2227 * Creates a function that invokes `func` with the `this` binding of `thisArg`
2228 * and `partials` prepended to the arguments it receives.
2229 *
2230 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
2231 * may be used as a placeholder for partially applied arguments.
2232 *
2233 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
2234 * property of bound functions.
2235 *
2236 * @static
2237 * @memberOf _
2238 * @since 0.1.0
2239 * @category Function
2240 * @param {Function} func The function to bind.
2241 * @param {*} thisArg The `this` binding of `func`.
2242 * @param {...*} [partials] The arguments to be partially applied.
2243 * @returns {Function} Returns the new bound function.
2244 * @example
2245 *
2246 * function greet(greeting, punctuation) {
2247 * return greeting + ' ' + this.user + punctuation;
2248 * }
2249 *
2250 * var object = { 'user': 'fred' };
2251 *
2252 * var bound = _.bind(greet, object, 'hi');
2253 * bound('!');
2254 * // => 'hi fred!'
2255 *
2256 * // Bound with placeholders.
2257 * var bound = _.bind(greet, object, _, '!');
2258 * bound('hi');
2259 * // => 'hi fred!'
2260 */
2261 var bind = baseRest(function(func, thisArg, partials) {
2262 return createPartial(func, WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG, thisArg, partials);
2263 });
2264
2265 /**
2266 * Defers invoking the `func` until the current call stack has cleared. Any
2267 * additional arguments are provided to `func` when it's invoked.
2268 *
2269 * @static
2270 * @memberOf _
2271 * @since 0.1.0
2272 * @category Function
2273 * @param {Function} func The function to defer.
2274 * @param {...*} [args] The arguments to invoke `func` with.
2275 * @returns {number} Returns the timer id.
2276 * @example
2277 *
2278 * _.defer(function(text) {
2279 * console.log(text);
2280 * }, 'deferred');
2281 * // => Logs 'deferred' after one millisecond.
2282 */
2283 var defer = baseRest(function(func, args) {
2284 return baseDelay(func, 1, args);
2285 });
2286
2287 /**
2288 * Invokes `func` after `wait` milliseconds. Any additional arguments are
2289 * provided to `func` when it's invoked.
2290 *
2291 * @static
2292 * @memberOf _
2293 * @since 0.1.0
2294 * @category Function
2295 * @param {Function} func The function to delay.
2296 * @param {number} wait The number of milliseconds to delay invocation.
2297 * @param {...*} [args] The arguments to invoke `func` with.
2298 * @returns {number} Returns the timer id.
2299 * @example
2300 *
2301 * _.delay(function(text) {
2302 * console.log(text);
2303 * }, 1000, 'later');
2304 * // => Logs 'later' after one second.
2305 */
2306 var delay = baseRest(function(func, wait, args) {
2307 return baseDelay(func, toNumber(wait) || 0, args);
2308 });
2309
2310 /**
2311 * Creates a function that negates the result of the predicate `func`. The
2312 * `func` predicate is invoked with the `this` binding and arguments of the
2313 * created function.
2314 *
2315 * @static
2316 * @memberOf _
2317 * @since 3.0.0
2318 * @category Function
2319 * @param {Function} predicate The predicate to negate.
2320 * @returns {Function} Returns the new negated function.
2321 * @example
2322 *
2323 * function isEven(n) {
2324 * return n % 2 == 0;
2325 * }
2326 *
2327 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
2328 * // => [1, 3, 5]
2329 */
2330 function negate(predicate) {
2331 if (typeof predicate != 'function') {
2332 throw new TypeError(FUNC_ERROR_TEXT);
2333 }
2334 return function() {
2335 var args = arguments;
2336 return !predicate.apply(this, args);
2337 };
2338 }
2339
2340 /**
2341 * Creates a function that is restricted to invoking `func` once. Repeat calls
2342 * to the function return the value of the first invocation. The `func` is
2343 * invoked with the `this` binding and arguments of the created function.
2344 *
2345 * @static
2346 * @memberOf _
2347 * @since 0.1.0
2348 * @category Function
2349 * @param {Function} func The function to restrict.
2350 * @returns {Function} Returns the new restricted function.
2351 * @example
2352 *
2353 * var initialize = _.once(createApplication);
2354 * initialize();
2355 * initialize();
2356 * // => `createApplication` is invoked once
2357 */
2358 function once(func) {
2359 return before(2, func);
2360 }
2361
2362 /*------------------------------------------------------------------------*/
2363
2364 /**
2365 * Creates a shallow clone of `value`.
2366 *
2367 * **Note:** This method is loosely based on the
2368 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
2369 * and supports cloning arrays, array buffers, booleans, date objects, maps,
2370 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
2371 * arrays. The own enumerable properties of `arguments` objects are cloned
2372 * as plain objects. An empty object is returned for uncloneable values such
2373 * as error objects, functions, DOM nodes, and WeakMaps.
2374 *
2375 * @static
2376 * @memberOf _
2377 * @since 0.1.0
2378 * @category Lang
2379 * @param {*} value The value to clone.
2380 * @returns {*} Returns the cloned value.
2381 * @see _.cloneDeep
2382 * @example
2383 *
2384 * var objects = [{ 'a': 1 }, { 'b': 2 }];
2385 *
2386 * var shallow = _.clone(objects);
2387 * console.log(shallow[0] === objects[0]);
2388 * // => true
2389 */
2390 function clone(value) {
2391 if (!isObject(value)) {
2392 return value;
2393 }
2394 return isArray(value) ? copyArray(value) : copyObject(value, nativeKeys(value));
2395 }
2396
2397 /**
2398 * Performs a
2399 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2400 * comparison between two values to determine if they are equivalent.
2401 *
2402 * @static
2403 * @memberOf _
2404 * @since 4.0.0
2405 * @category Lang
2406 * @param {*} value The value to compare.
2407 * @param {*} other The other value to compare.
2408 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2409 * @example
2410 *
2411 * var object = { 'a': 1 };
2412 * var other = { 'a': 1 };
2413 *
2414 * _.eq(object, object);
2415 * // => true
2416 *
2417 * _.eq(object, other);
2418 * // => false
2419 *
2420 * _.eq('a', 'a');
2421 * // => true
2422 *
2423 * _.eq('a', Object('a'));
2424 * // => false
2425 *
2426 * _.eq(NaN, NaN);
2427 * // => true
2428 */
2429 function eq(value, other) {
2430 return value === other || (value !== value && other !== other);
2431 }
2432
2433 /**
2434 * Checks if `value` is likely an `arguments` object.
2435 *
2436 * @static
2437 * @memberOf _
2438 * @since 0.1.0
2439 * @category Lang
2440 * @param {*} value The value to check.
2441 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2442 * else `false`.
2443 * @example
2444 *
2445 * _.isArguments(function() { return arguments; }());
2446 * // => true
2447 *
2448 * _.isArguments([1, 2, 3]);
2449 * // => false
2450 */
2451 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
2452 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
2453 !propertyIsEnumerable.call(value, 'callee');
2454 };
2455
2456 /**
2457 * Checks if `value` is classified as an `Array` object.
2458 *
2459 * @static
2460 * @memberOf _
2461 * @since 0.1.0
2462 * @category Lang
2463 * @param {*} value The value to check.
2464 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2465 * @example
2466 *
2467 * _.isArray([1, 2, 3]);
2468 * // => true
2469 *
2470 * _.isArray(document.body.children);
2471 * // => false
2472 *
2473 * _.isArray('abc');
2474 * // => false
2475 *
2476 * _.isArray(_.noop);
2477 * // => false
2478 */
2479 var isArray = Array.isArray;
2480
2481 /**
2482 * Checks if `value` is array-like. A value is considered array-like if it's
2483 * not a function and has a `value.length` that's an integer greater than or
2484 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2485 *
2486 * @static
2487 * @memberOf _
2488 * @since 4.0.0
2489 * @category Lang
2490 * @param {*} value The value to check.
2491 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2492 * @example
2493 *
2494 * _.isArrayLike([1, 2, 3]);
2495 * // => true
2496 *
2497 * _.isArrayLike(document.body.children);
2498 * // => true
2499 *
2500 * _.isArrayLike('abc');
2501 * // => true
2502 *
2503 * _.isArrayLike(_.noop);
2504 * // => false
2505 */
2506 function isArrayLike(value) {
2507 return value != null && isLength(value.length) && !isFunction(value);
2508 }
2509
2510 /**
2511 * Checks if `value` is classified as a boolean primitive or object.
2512 *
2513 * @static
2514 * @memberOf _
2515 * @since 0.1.0
2516 * @category Lang
2517 * @param {*} value The value to check.
2518 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
2519 * @example
2520 *
2521 * _.isBoolean(false);
2522 * // => true
2523 *
2524 * _.isBoolean(null);
2525 * // => false
2526 */
2527 function isBoolean(value) {
2528 return value === true || value === false ||
2529 (isObjectLike(value) && baseGetTag(value) == boolTag);
2530 }
2531
2532 /**
2533 * Checks if `value` is classified as a `Date` object.
2534 *
2535 * @static
2536 * @memberOf _
2537 * @since 0.1.0
2538 * @category Lang
2539 * @param {*} value The value to check.
2540 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
2541 * @example
2542 *
2543 * _.isDate(new Date);
2544 * // => true
2545 *
2546 * _.isDate('Mon April 23 2012');
2547 * // => false
2548 */
2549 var isDate = baseIsDate;
2550
2551 /**
2552 * Checks if `value` is an empty object, collection, map, or set.
2553 *
2554 * Objects are considered empty if they have no own enumerable string keyed
2555 * properties.
2556 *
2557 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
2558 * jQuery-like collections are considered empty if they have a `length` of `0`.
2559 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
2560 *
2561 * @static
2562 * @memberOf _
2563 * @since 0.1.0
2564 * @category Lang
2565 * @param {*} value The value to check.
2566 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
2567 * @example
2568 *
2569 * _.isEmpty(null);
2570 * // => true
2571 *
2572 * _.isEmpty(true);
2573 * // => true
2574 *
2575 * _.isEmpty(1);
2576 * // => true
2577 *
2578 * _.isEmpty([1, 2, 3]);
2579 * // => false
2580 *
2581 * _.isEmpty({ 'a': 1 });
2582 * // => false
2583 */
2584 function isEmpty(value) {
2585 if (isArrayLike(value) &&
2586 (isArray(value) || isString(value) ||
2587 isFunction(value.splice) || isArguments(value))) {
2588 return !value.length;
2589 }
2590 return !nativeKeys(value).length;
2591 }
2592
2593 /**
2594 * Performs a deep comparison between two values to determine if they are
2595 * equivalent.
2596 *
2597 * **Note:** This method supports comparing arrays, array buffers, booleans,
2598 * date objects, error objects, maps, numbers, `Object` objects, regexes,
2599 * sets, strings, symbols, and typed arrays. `Object` objects are compared
2600 * by their own, not inherited, enumerable properties. Functions and DOM
2601 * nodes are **not** supported.
2602 *
2603 * @static
2604 * @memberOf _
2605 * @since 0.1.0
2606 * @category Lang
2607 * @param {*} value The value to compare.
2608 * @param {*} other The other value to compare.
2609 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2610 * @example
2611 *
2612 * var object = { 'a': 1 };
2613 * var other = { 'a': 1 };
2614 *
2615 * _.isEqual(object, other);
2616 * // => true
2617 *
2618 * object === other;
2619 * // => false
2620 */
2621 function isEqual(value, other) {
2622 return baseIsEqual(value, other);
2623 }
2624
2625 /**
2626 * Checks if `value` is a finite primitive number.
2627 *
2628 * **Note:** This method is based on
2629 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
2630 *
2631 * @static
2632 * @memberOf _
2633 * @since 0.1.0
2634 * @category Lang
2635 * @param {*} value The value to check.
2636 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
2637 * @example
2638 *
2639 * _.isFinite(3);
2640 * // => true
2641 *
2642 * _.isFinite(Number.MIN_VALUE);
2643 * // => true
2644 *
2645 * _.isFinite(Infinity);
2646 * // => false
2647 *
2648 * _.isFinite('3');
2649 * // => false
2650 */
2651 function isFinite(value) {
2652 return typeof value == 'number' && nativeIsFinite(value);
2653 }
2654
2655 /**
2656 * Checks if `value` is classified as a `Function` object.
2657 *
2658 * @static
2659 * @memberOf _
2660 * @since 0.1.0
2661 * @category Lang
2662 * @param {*} value The value to check.
2663 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2664 * @example
2665 *
2666 * _.isFunction(_);
2667 * // => true
2668 *
2669 * _.isFunction(/abc/);
2670 * // => false
2671 */
2672 function isFunction(value) {
2673 if (!isObject(value)) {
2674 return false;
2675 }
2676 // The use of `Object#toString` avoids issues with the `typeof` operator
2677 // in Safari 9 which returns 'object' for typed arrays and other constructors.
2678 var tag = baseGetTag(value);
2679 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
2680 }
2681
2682 /**
2683 * Checks if `value` is a valid array-like length.
2684 *
2685 * **Note:** This method is loosely based on
2686 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2687 *
2688 * @static
2689 * @memberOf _
2690 * @since 4.0.0
2691 * @category Lang
2692 * @param {*} value The value to check.
2693 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2694 * @example
2695 *
2696 * _.isLength(3);
2697 * // => true
2698 *
2699 * _.isLength(Number.MIN_VALUE);
2700 * // => false
2701 *
2702 * _.isLength(Infinity);
2703 * // => false
2704 *
2705 * _.isLength('3');
2706 * // => false
2707 */
2708 function isLength(value) {
2709 return typeof value == 'number' &&
2710 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2711 }
2712
2713 /**
2714 * Checks if `value` is the
2715 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2716 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2717 *
2718 * @static
2719 * @memberOf _
2720 * @since 0.1.0
2721 * @category Lang
2722 * @param {*} value The value to check.
2723 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2724 * @example
2725 *
2726 * _.isObject({});
2727 * // => true
2728 *
2729 * _.isObject([1, 2, 3]);
2730 * // => true
2731 *
2732 * _.isObject(_.noop);
2733 * // => true
2734 *
2735 * _.isObject(null);
2736 * // => false
2737 */
2738 function isObject(value) {
2739 var type = typeof value;
2740 return value != null && (type == 'object' || type == 'function');
2741 }
2742
2743 /**
2744 * Checks if `value` is object-like. A value is object-like if it's not `null`
2745 * and has a `typeof` result of "object".
2746 *
2747 * @static
2748 * @memberOf _
2749 * @since 4.0.0
2750 * @category Lang
2751 * @param {*} value The value to check.
2752 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2753 * @example
2754 *
2755 * _.isObjectLike({});
2756 * // => true
2757 *
2758 * _.isObjectLike([1, 2, 3]);
2759 * // => true
2760 *
2761 * _.isObjectLike(_.noop);
2762 * // => false
2763 *
2764 * _.isObjectLike(null);
2765 * // => false
2766 */
2767 function isObjectLike(value) {
2768 return value != null && typeof value == 'object';
2769 }
2770
2771 /**
2772 * Checks if `value` is `NaN`.
2773 *
2774 * **Note:** This method is based on
2775 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
2776 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
2777 * `undefined` and other non-number values.
2778 *
2779 * @static
2780 * @memberOf _
2781 * @since 0.1.0
2782 * @category Lang
2783 * @param {*} value The value to check.
2784 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
2785 * @example
2786 *
2787 * _.isNaN(NaN);
2788 * // => true
2789 *
2790 * _.isNaN(new Number(NaN));
2791 * // => true
2792 *
2793 * isNaN(undefined);
2794 * // => true
2795 *
2796 * _.isNaN(undefined);
2797 * // => false
2798 */
2799 function isNaN(value) {
2800 // An `NaN` primitive is the only value that is not equal to itself.
2801 // Perform the `toStringTag` check first to avoid errors with some
2802 // ActiveX objects in IE.
2803 return isNumber(value) && value != +value;
2804 }
2805
2806 /**
2807 * Checks if `value` is `null`.
2808 *
2809 * @static
2810 * @memberOf _
2811 * @since 0.1.0
2812 * @category Lang
2813 * @param {*} value The value to check.
2814 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
2815 * @example
2816 *
2817 * _.isNull(null);
2818 * // => true
2819 *
2820 * _.isNull(void 0);
2821 * // => false
2822 */
2823 function isNull(value) {
2824 return value === null;
2825 }
2826
2827 /**
2828 * Checks if `value` is classified as a `Number` primitive or object.
2829 *
2830 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
2831 * classified as numbers, use the `_.isFinite` method.
2832 *
2833 * @static
2834 * @memberOf _
2835 * @since 0.1.0
2836 * @category Lang
2837 * @param {*} value The value to check.
2838 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
2839 * @example
2840 *
2841 * _.isNumber(3);
2842 * // => true
2843 *
2844 * _.isNumber(Number.MIN_VALUE);
2845 * // => true
2846 *
2847 * _.isNumber(Infinity);
2848 * // => true
2849 *
2850 * _.isNumber('3');
2851 * // => false
2852 */
2853 function isNumber(value) {
2854 return typeof value == 'number' ||
2855 (isObjectLike(value) && baseGetTag(value) == numberTag);
2856 }
2857
2858 /**
2859 * Checks if `value` is classified as a `RegExp` object.
2860 *
2861 * @static
2862 * @memberOf _
2863 * @since 0.1.0
2864 * @category Lang
2865 * @param {*} value The value to check.
2866 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
2867 * @example
2868 *
2869 * _.isRegExp(/abc/);
2870 * // => true
2871 *
2872 * _.isRegExp('/abc/');
2873 * // => false
2874 */
2875 var isRegExp = baseIsRegExp;
2876
2877 /**
2878 * Checks if `value` is classified as a `String` primitive or object.
2879 *
2880 * @static
2881 * @since 0.1.0
2882 * @memberOf _
2883 * @category Lang
2884 * @param {*} value The value to check.
2885 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
2886 * @example
2887 *
2888 * _.isString('abc');
2889 * // => true
2890 *
2891 * _.isString(1);
2892 * // => false
2893 */
2894 function isString(value) {
2895 return typeof value == 'string' ||
2896 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
2897 }
2898
2899 /**
2900 * Checks if `value` is `undefined`.
2901 *
2902 * @static
2903 * @since 0.1.0
2904 * @memberOf _
2905 * @category Lang
2906 * @param {*} value The value to check.
2907 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
2908 * @example
2909 *
2910 * _.isUndefined(void 0);
2911 * // => true
2912 *
2913 * _.isUndefined(null);
2914 * // => false
2915 */
2916 function isUndefined(value) {
2917 return value === undefined;
2918 }
2919
2920 /**
2921 * Converts `value` to an array.
2922 *
2923 * @static
2924 * @since 0.1.0
2925 * @memberOf _
2926 * @category Lang
2927 * @param {*} value The value to convert.
2928 * @returns {Array} Returns the converted array.
2929 * @example
2930 *
2931 * _.toArray({ 'a': 1, 'b': 2 });
2932 * // => [1, 2]
2933 *
2934 * _.toArray('abc');
2935 * // => ['a', 'b', 'c']
2936 *
2937 * _.toArray(1);
2938 * // => []
2939 *
2940 * _.toArray(null);
2941 * // => []
2942 */
2943 function toArray(value) {
2944 if (!isArrayLike(value)) {
2945 return values(value);
2946 }
2947 return value.length ? copyArray(value) : [];
2948 }
2949
2950 /**
2951 * Converts `value` to an integer.
2952 *
2953 * **Note:** This method is loosely based on
2954 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
2955 *
2956 * @static
2957 * @memberOf _
2958 * @since 4.0.0
2959 * @category Lang
2960 * @param {*} value The value to convert.
2961 * @returns {number} Returns the converted integer.
2962 * @example
2963 *
2964 * _.toInteger(3.2);
2965 * // => 3
2966 *
2967 * _.toInteger(Number.MIN_VALUE);
2968 * // => 0
2969 *
2970 * _.toInteger(Infinity);
2971 * // => 1.7976931348623157e+308
2972 *
2973 * _.toInteger('3.2');
2974 * // => 3
2975 */
2976 var toInteger = Number;
2977
2978 /**
2979 * Converts `value` to a number.
2980 *
2981 * @static
2982 * @memberOf _
2983 * @since 4.0.0
2984 * @category Lang
2985 * @param {*} value The value to process.
2986 * @returns {number} Returns the number.
2987 * @example
2988 *
2989 * _.toNumber(3.2);
2990 * // => 3.2
2991 *
2992 * _.toNumber(Number.MIN_VALUE);
2993 * // => 5e-324
2994 *
2995 * _.toNumber(Infinity);
2996 * // => Infinity
2997 *
2998 * _.toNumber('3.2');
2999 * // => 3.2
3000 */
3001 var toNumber = Number;
3002
3003 /**
3004 * Converts `value` to a string. An empty string is returned for `null`
3005 * and `undefined` values. The sign of `-0` is preserved.
3006 *
3007 * @static
3008 * @memberOf _
3009 * @since 4.0.0
3010 * @category Lang
3011 * @param {*} value The value to convert.
3012 * @returns {string} Returns the converted string.
3013 * @example
3014 *
3015 * _.toString(null);
3016 * // => ''
3017 *
3018 * _.toString(-0);
3019 * // => '-0'
3020 *
3021 * _.toString([1, 2, 3]);
3022 * // => '1,2,3'
3023 */
3024 function toString(value) {
3025 if (typeof value == 'string') {
3026 return value;
3027 }
3028 return value == null ? '' : (value + '');
3029 }
3030
3031 /*------------------------------------------------------------------------*/
3032
3033 /**
3034 * Assigns own enumerable string keyed properties of source objects to the
3035 * destination object. Source objects are applied from left to right.
3036 * Subsequent sources overwrite property assignments of previous sources.
3037 *
3038 * **Note:** This method mutates `object` and is loosely based on
3039 * [`Object.assign`](https://mdn.io/Object/assign).
3040 *
3041 * @static
3042 * @memberOf _
3043 * @since 0.10.0
3044 * @category Object
3045 * @param {Object} object The destination object.
3046 * @param {...Object} [sources] The source objects.
3047 * @returns {Object} Returns `object`.
3048 * @see _.assignIn
3049 * @example
3050 *
3051 * function Foo() {
3052 * this.a = 1;
3053 * }
3054 *
3055 * function Bar() {
3056 * this.c = 3;
3057 * }
3058 *
3059 * Foo.prototype.b = 2;
3060 * Bar.prototype.d = 4;
3061 *
3062 * _.assign({ 'a': 0 }, new Foo, new Bar);
3063 * // => { 'a': 1, 'c': 3 }
3064 */
3065 var assign = createAssigner(function(object, source) {
3066 copyObject(source, nativeKeys(source), object);
3067 });
3068
3069 /**
3070 * This method is like `_.assign` except that it iterates over own and
3071 * inherited source properties.
3072 *
3073 * **Note:** This method mutates `object`.
3074 *
3075 * @static
3076 * @memberOf _
3077 * @since 4.0.0
3078 * @alias extend
3079 * @category Object
3080 * @param {Object} object The destination object.
3081 * @param {...Object} [sources] The source objects.
3082 * @returns {Object} Returns `object`.
3083 * @see _.assign
3084 * @example
3085 *
3086 * function Foo() {
3087 * this.a = 1;
3088 * }
3089 *
3090 * function Bar() {
3091 * this.c = 3;
3092 * }
3093 *
3094 * Foo.prototype.b = 2;
3095 * Bar.prototype.d = 4;
3096 *
3097 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
3098 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
3099 */
3100 var assignIn = createAssigner(function(object, source) {
3101 copyObject(source, nativeKeysIn(source), object);
3102 });
3103
3104 /**
3105 * This method is like `_.assignIn` except that it accepts `customizer`
3106 * which is invoked to produce the assigned values. If `customizer` returns
3107 * `undefined`, assignment is handled by the method instead. The `customizer`
3108 * is invoked with five arguments: (objValue, srcValue, key, object, source).
3109 *
3110 * **Note:** This method mutates `object`.
3111 *
3112 * @static
3113 * @memberOf _
3114 * @since 4.0.0
3115 * @alias extendWith
3116 * @category Object
3117 * @param {Object} object The destination object.
3118 * @param {...Object} sources The source objects.
3119 * @param {Function} [customizer] The function to customize assigned values.
3120 * @returns {Object} Returns `object`.
3121 * @see _.assignWith
3122 * @example
3123 *
3124 * function customizer(objValue, srcValue) {
3125 * return _.isUndefined(objValue) ? srcValue : objValue;
3126 * }
3127 *
3128 * var defaults = _.partialRight(_.assignInWith, customizer);
3129 *
3130 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3131 * // => { 'a': 1, 'b': 2 }
3132 */
3133 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
3134 copyObject(source, keysIn(source), object, customizer);
3135 });
3136
3137 /**
3138 * Creates an object that inherits from the `prototype` object. If a
3139 * `properties` object is given, its own enumerable string keyed properties
3140 * are assigned to the created object.
3141 *
3142 * @static
3143 * @memberOf _
3144 * @since 2.3.0
3145 * @category Object
3146 * @param {Object} prototype The object to inherit from.
3147 * @param {Object} [properties] The properties to assign to the object.
3148 * @returns {Object} Returns the new object.
3149 * @example
3150 *
3151 * function Shape() {
3152 * this.x = 0;
3153 * this.y = 0;
3154 * }
3155 *
3156 * function Circle() {
3157 * Shape.call(this);
3158 * }
3159 *
3160 * Circle.prototype = _.create(Shape.prototype, {
3161 * 'constructor': Circle
3162 * });
3163 *
3164 * var circle = new Circle;
3165 * circle instanceof Circle;
3166 * // => true
3167 *
3168 * circle instanceof Shape;
3169 * // => true
3170 */
3171 function create(prototype, properties) {
3172 var result = baseCreate(prototype);
3173 return properties == null ? result : assign(result, properties);
3174 }
3175
3176 /**
3177 * Assigns own and inherited enumerable string keyed properties of source
3178 * objects to the destination object for all destination properties that
3179 * resolve to `undefined`. Source objects are applied from left to right.
3180 * Once a property is set, additional values of the same property are ignored.
3181 *
3182 * **Note:** This method mutates `object`.
3183 *
3184 * @static
3185 * @since 0.1.0
3186 * @memberOf _
3187 * @category Object
3188 * @param {Object} object The destination object.
3189 * @param {...Object} [sources] The source objects.
3190 * @returns {Object} Returns `object`.
3191 * @see _.defaultsDeep
3192 * @example
3193 *
3194 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
3195 * // => { 'a': 1, 'b': 2 }
3196 */
3197 var defaults = baseRest(function(args) {
3198 args.push(undefined, assignInDefaults);
3199 return assignInWith.apply(undefined, args);
3200 });
3201
3202 /**
3203 * Checks if `path` is a direct property of `object`.
3204 *
3205 * @static
3206 * @since 0.1.0
3207 * @memberOf _
3208 * @category Object
3209 * @param {Object} object The object to query.
3210 * @param {Array|string} path The path to check.
3211 * @returns {boolean} Returns `true` if `path` exists, else `false`.
3212 * @example
3213 *
3214 * var object = { 'a': { 'b': 2 } };
3215 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
3216 *
3217 * _.has(object, 'a');
3218 * // => true
3219 *
3220 * _.has(object, 'a.b');
3221 * // => true
3222 *
3223 * _.has(object, ['a', 'b']);
3224 * // => true
3225 *
3226 * _.has(other, 'a');
3227 * // => false
3228 */
3229 function has(object, path) {
3230 return object != null && hasOwnProperty.call(object, path);
3231 }
3232
3233 /**
3234 * Creates an array of the own enumerable property names of `object`.
3235 *
3236 * **Note:** Non-object values are coerced to objects. See the
3237 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
3238 * for more details.
3239 *
3240 * @static
3241 * @since 0.1.0
3242 * @memberOf _
3243 * @category Object
3244 * @param {Object} object The object to query.
3245 * @returns {Array} Returns the array of property names.
3246 * @example
3247 *
3248 * function Foo() {
3249 * this.a = 1;
3250 * this.b = 2;
3251 * }
3252 *
3253 * Foo.prototype.c = 3;
3254 *
3255 * _.keys(new Foo);
3256 * // => ['a', 'b'] (iteration order is not guaranteed)
3257 *
3258 * _.keys('hi');
3259 * // => ['0', '1']
3260 */
3261 var keys = nativeKeys;
3262
3263 /**
3264 * Creates an array of the own and inherited enumerable property names of `object`.
3265 *
3266 * **Note:** Non-object values are coerced to objects.
3267 *
3268 * @static
3269 * @memberOf _
3270 * @since 3.0.0
3271 * @category Object
3272 * @param {Object} object The object to query.
3273 * @returns {Array} Returns the array of property names.
3274 * @example
3275 *
3276 * function Foo() {
3277 * this.a = 1;
3278 * this.b = 2;
3279 * }
3280 *
3281 * Foo.prototype.c = 3;
3282 *
3283 * _.keysIn(new Foo);
3284 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
3285 */
3286 var keysIn = nativeKeysIn;
3287
3288 /**
3289 * Creates an object composed of the picked `object` properties.
3290 *
3291 * @static
3292 * @since 0.1.0
3293 * @memberOf _
3294 * @category Object
3295 * @param {Object} object The source object.
3296 * @param {...(string|string[])} [paths] The property paths to pick.
3297 * @returns {Object} Returns the new object.
3298 * @example
3299 *
3300 * var object = { 'a': 1, 'b': '2', 'c': 3 };
3301 *
3302 * _.pick(object, ['a', 'c']);
3303 * // => { 'a': 1, 'c': 3 }
3304 */
3305 var pick = flatRest(function(object, paths) {
3306 return object == null ? {} : basePick(object, paths);
3307 });
3308
3309 /**
3310 * This method is like `_.get` except that if the resolved value is a
3311 * function it's invoked with the `this` binding of its parent object and
3312 * its result is returned.
3313 *
3314 * @static
3315 * @since 0.1.0
3316 * @memberOf _
3317 * @category Object
3318 * @param {Object} object The object to query.
3319 * @param {Array|string} path The path of the property to resolve.
3320 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
3321 * @returns {*} Returns the resolved value.
3322 * @example
3323 *
3324 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
3325 *
3326 * _.result(object, 'a[0].b.c1');
3327 * // => 3
3328 *
3329 * _.result(object, 'a[0].b.c2');
3330 * // => 4
3331 *
3332 * _.result(object, 'a[0].b.c3', 'default');
3333 * // => 'default'
3334 *
3335 * _.result(object, 'a[0].b.c3', _.constant('default'));
3336 * // => 'default'
3337 */
3338 function result(object, path, defaultValue) {
3339 var value = object == null ? undefined : object[path];
3340 if (value === undefined) {
3341 value = defaultValue;
3342 }
3343 return isFunction(value) ? value.call(object) : value;
3344 }
3345
3346 /**
3347 * Creates an array of the own enumerable string keyed property values of `object`.
3348 *
3349 * **Note:** Non-object values are coerced to objects.
3350 *
3351 * @static
3352 * @since 0.1.0
3353 * @memberOf _
3354 * @category Object
3355 * @param {Object} object The object to query.
3356 * @returns {Array} Returns the array of property values.
3357 * @example
3358 *
3359 * function Foo() {
3360 * this.a = 1;
3361 * this.b = 2;
3362 * }
3363 *
3364 * Foo.prototype.c = 3;
3365 *
3366 * _.values(new Foo);
3367 * // => [1, 2] (iteration order is not guaranteed)
3368 *
3369 * _.values('hi');
3370 * // => ['h', 'i']
3371 */
3372 function values(object) {
3373 return object == null ? [] : baseValues(object, keys(object));
3374 }
3375
3376 /*------------------------------------------------------------------------*/
3377
3378 /**
3379 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
3380 * corresponding HTML entities.
3381 *
3382 * **Note:** No other characters are escaped. To escape additional
3383 * characters use a third-party library like [_he_](https://mths.be/he).
3384 *
3385 * Though the ">" character is escaped for symmetry, characters like
3386 * ">" and "/" don't need escaping in HTML and have no special meaning
3387 * unless they're part of a tag or unquoted attribute value. See
3388 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
3389 * (under "semi-related fun fact") for more details.
3390 *
3391 * When working with HTML you should always
3392 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
3393 * XSS vectors.
3394 *
3395 * @static
3396 * @since 0.1.0
3397 * @memberOf _
3398 * @category String
3399 * @param {string} [string=''] The string to escape.
3400 * @returns {string} Returns the escaped string.
3401 * @example
3402 *
3403 * _.escape('fred, barney, & pebbles');
3404 * // => 'fred, barney, &amp; pebbles'
3405 */
3406 function escape(string) {
3407 string = toString(string);
3408 return (string && reHasUnescapedHtml.test(string))
3409 ? string.replace(reUnescapedHtml, escapeHtmlChar)
3410 : string;
3411 }
3412
3413 /*------------------------------------------------------------------------*/
3414
3415 /**
3416 * This method returns the first argument it receives.
3417 *
3418 * @static
3419 * @since 0.1.0
3420 * @memberOf _
3421 * @category Util
3422 * @param {*} value Any value.
3423 * @returns {*} Returns `value`.
3424 * @example
3425 *
3426 * var object = { 'a': 1 };
3427 *
3428 * console.log(_.identity(object) === object);
3429 * // => true
3430 */
3431 function identity(value) {
3432 return value;
3433 }
3434
3435 /**
3436 * Creates a function that invokes `func` with the arguments of the created
3437 * function. If `func` is a property name, the created function returns the
3438 * property value for a given element. If `func` is an array or object, the
3439 * created function returns `true` for elements that contain the equivalent
3440 * source properties, otherwise it returns `false`.
3441 *
3442 * @static
3443 * @since 4.0.0
3444 * @memberOf _
3445 * @category Util
3446 * @param {*} [func=_.identity] The value to convert to a callback.
3447 * @returns {Function} Returns the callback.
3448 * @example
3449 *
3450 * var users = [
3451 * { 'user': 'barney', 'age': 36, 'active': true },
3452 * { 'user': 'fred', 'age': 40, 'active': false }
3453 * ];
3454 *
3455 * // The `_.matches` iteratee shorthand.
3456 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
3457 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
3458 *
3459 * // The `_.matchesProperty` iteratee shorthand.
3460 * _.filter(users, _.iteratee(['user', 'fred']));
3461 * // => [{ 'user': 'fred', 'age': 40 }]
3462 *
3463 * // The `_.property` iteratee shorthand.
3464 * _.map(users, _.iteratee('user'));
3465 * // => ['barney', 'fred']
3466 *
3467 * // Create custom iteratee shorthands.
3468 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
3469 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
3470 * return func.test(string);
3471 * };
3472 * });
3473 *
3474 * _.filter(['abc', 'def'], /ef/);
3475 * // => ['def']
3476 */
3477 var iteratee = baseIteratee;
3478
3479 /**
3480 * Creates a function that performs a partial deep comparison between a given
3481 * object and `source`, returning `true` if the given object has equivalent
3482 * property values, else `false`.
3483 *
3484 * **Note:** The created function is equivalent to `_.isMatch` with `source`
3485 * partially applied.
3486 *
3487 * Partial comparisons will match empty array and empty object `source`
3488 * values against any array or object value, respectively. See `_.isEqual`
3489 * for a list of supported value comparisons.
3490 *
3491 * @static
3492 * @memberOf _
3493 * @since 3.0.0
3494 * @category Util
3495 * @param {Object} source The object of property values to match.
3496 * @returns {Function} Returns the new spec function.
3497 * @example
3498 *
3499 * var objects = [
3500 * { 'a': 1, 'b': 2, 'c': 3 },
3501 * { 'a': 4, 'b': 5, 'c': 6 }
3502 * ];
3503 *
3504 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
3505 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
3506 */
3507 function matches(source) {
3508 return baseMatches(assign({}, source));
3509 }
3510
3511 /**
3512 * Adds all own enumerable string keyed function properties of a source
3513 * object to the destination object. If `object` is a function, then methods
3514 * are added to its prototype as well.
3515 *
3516 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
3517 * avoid conflicts caused by modifying the original.
3518 *
3519 * @static
3520 * @since 0.1.0
3521 * @memberOf _
3522 * @category Util
3523 * @param {Function|Object} [object=lodash] The destination object.
3524 * @param {Object} source The object of functions to add.
3525 * @param {Object} [options={}] The options object.
3526 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
3527 * @returns {Function|Object} Returns `object`.
3528 * @example
3529 *
3530 * function vowels(string) {
3531 * return _.filter(string, function(v) {
3532 * return /[aeiou]/i.test(v);
3533 * });
3534 * }
3535 *
3536 * _.mixin({ 'vowels': vowels });
3537 * _.vowels('fred');
3538 * // => ['e']
3539 *
3540 * _('fred').vowels().value();
3541 * // => ['e']
3542 *
3543 * _.mixin({ 'vowels': vowels }, { 'chain': false });
3544 * _('fred').vowels();
3545 * // => ['e']
3546 */
3547 function mixin(object, source, options) {
3548 var props = keys(source),
3549 methodNames = baseFunctions(source, props);
3550
3551 if (options == null &&
3552 !(isObject(source) && (methodNames.length || !props.length))) {
3553 options = source;
3554 source = object;
3555 object = this;
3556 methodNames = baseFunctions(source, keys(source));
3557 }
3558 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
3559 isFunc = isFunction(object);
3560
3561 baseEach(methodNames, function(methodName) {
3562 var func = source[methodName];
3563 object[methodName] = func;
3564 if (isFunc) {
3565 object.prototype[methodName] = function() {
3566 var chainAll = this.__chain__;
3567 if (chain || chainAll) {
3568 var result = object(this.__wrapped__),
3569 actions = result.__actions__ = copyArray(this.__actions__);
3570
3571 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
3572 result.__chain__ = chainAll;
3573 return result;
3574 }
3575 return func.apply(object, arrayPush([this.value()], arguments));
3576 };
3577 }
3578 });
3579
3580 return object;
3581 }
3582
3583 /**
3584 * Reverts the `_` variable to its previous value and returns a reference to
3585 * the `lodash` function.
3586 *
3587 * @static
3588 * @since 0.1.0
3589 * @memberOf _
3590 * @category Util
3591 * @returns {Function} Returns the `lodash` function.
3592 * @example
3593 *
3594 * var lodash = _.noConflict();
3595 */
3596 function noConflict() {
3597 if (root._ === this) {
3598 root._ = oldDash;
3599 }
3600 return this;
3601 }
3602
3603 /**
3604 * This method returns `undefined`.
3605 *
3606 * @static
3607 * @memberOf _
3608 * @since 2.3.0
3609 * @category Util
3610 * @example
3611 *
3612 * _.times(2, _.noop);
3613 * // => [undefined, undefined]
3614 */
3615 function noop() {
3616 // No operation performed.
3617 }
3618
3619 /**
3620 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
3621 *
3622 * @static
3623 * @since 0.1.0
3624 * @memberOf _
3625 * @category Util
3626 * @param {string} [prefix=''] The value to prefix the ID with.
3627 * @returns {string} Returns the unique ID.
3628 * @example
3629 *
3630 * _.uniqueId('contact_');
3631 * // => 'contact_104'
3632 *
3633 * _.uniqueId();
3634 * // => '105'
3635 */
3636 function uniqueId(prefix) {
3637 var id = ++idCounter;
3638 return toString(prefix) + id;
3639 }
3640
3641 /*------------------------------------------------------------------------*/
3642
3643 /**
3644 * Computes the maximum value of `array`. If `array` is empty or falsey,
3645 * `undefined` is returned.
3646 *
3647 * @static
3648 * @since 0.1.0
3649 * @memberOf _
3650 * @category Math
3651 * @param {Array} array The array to iterate over.
3652 * @returns {*} Returns the maximum value.
3653 * @example
3654 *
3655 * _.max([4, 2, 8, 6]);
3656 * // => 8
3657 *
3658 * _.max([]);
3659 * // => undefined
3660 */
3661 function max(array) {
3662 return (array && array.length)
3663 ? baseExtremum(array, identity, baseGt)
3664 : undefined;
3665 }
3666
3667 /**
3668 * Computes the minimum value of `array`. If `array` is empty or falsey,
3669 * `undefined` is returned.
3670 *
3671 * @static
3672 * @since 0.1.0
3673 * @memberOf _
3674 * @category Math
3675 * @param {Array} array The array to iterate over.
3676 * @returns {*} Returns the minimum value.
3677 * @example
3678 *
3679 * _.min([4, 2, 8, 6]);
3680 * // => 2
3681 *
3682 * _.min([]);
3683 * // => undefined
3684 */
3685 function min(array) {
3686 return (array && array.length)
3687 ? baseExtremum(array, identity, baseLt)
3688 : undefined;
3689 }
3690
3691 /*------------------------------------------------------------------------*/
3692
3693 // Add methods that return wrapped values in chain sequences.
3694 lodash.assignIn = assignIn;
3695 lodash.before = before;
3696 lodash.bind = bind;
3697 lodash.chain = chain;
3698 lodash.compact = compact;
3699 lodash.concat = concat;
3700 lodash.create = create;
3701 lodash.defaults = defaults;
3702 lodash.defer = defer;
3703 lodash.delay = delay;
3704 lodash.filter = filter;
3705 lodash.flatten = flatten;
3706 lodash.flattenDeep = flattenDeep;
3707 lodash.iteratee = iteratee;
3708 lodash.keys = keys;
3709 lodash.map = map;
3710 lodash.matches = matches;
3711 lodash.mixin = mixin;
3712 lodash.negate = negate;
3713 lodash.once = once;
3714 lodash.pick = pick;
3715 lodash.slice = slice;
3716 lodash.sortBy = sortBy;
3717 lodash.tap = tap;
3718 lodash.thru = thru;
3719 lodash.toArray = toArray;
3720 lodash.values = values;
3721
3722 // Add aliases.
3723 lodash.extend = assignIn;
3724
3725 // Add methods to `lodash.prototype`.
3726 mixin(lodash, lodash);
3727
3728 /*------------------------------------------------------------------------*/
3729
3730 // Add methods that return unwrapped values in chain sequences.
3731 lodash.clone = clone;
3732 lodash.escape = escape;
3733 lodash.every = every;
3734 lodash.find = find;
3735 lodash.forEach = forEach;
3736 lodash.has = has;
3737 lodash.head = head;
3738 lodash.identity = identity;
3739 lodash.indexOf = indexOf;
3740 lodash.isArguments = isArguments;
3741 lodash.isArray = isArray;
3742 lodash.isBoolean = isBoolean;
3743 lodash.isDate = isDate;
3744 lodash.isEmpty = isEmpty;
3745 lodash.isEqual = isEqual;
3746 lodash.isFinite = isFinite;
3747 lodash.isFunction = isFunction;
3748 lodash.isNaN = isNaN;
3749 lodash.isNull = isNull;
3750 lodash.isNumber = isNumber;
3751 lodash.isObject = isObject;
3752 lodash.isRegExp = isRegExp;
3753 lodash.isString = isString;
3754 lodash.isUndefined = isUndefined;
3755 lodash.last = last;
3756 lodash.max = max;
3757 lodash.min = min;
3758 lodash.noConflict = noConflict;
3759 lodash.noop = noop;
3760 lodash.reduce = reduce;
3761 lodash.result = result;
3762 lodash.size = size;
3763 lodash.some = some;
3764 lodash.uniqueId = uniqueId;
3765
3766 // Add aliases.
3767 lodash.each = forEach;
3768 lodash.first = head;
3769
3770 mixin(lodash, (function() {
3771 var source = {};
3772 baseForOwn(lodash, function(func, methodName) {
3773 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
3774 source[methodName] = func;
3775 }
3776 });
3777 return source;
3778 }()), { 'chain': false });
3779
3780 /*------------------------------------------------------------------------*/
3781
3782 /**
3783 * The semantic version number.
3784 *
3785 * @static
3786 * @memberOf _
3787 * @type {string}
3788 */
3789 lodash.VERSION = VERSION;
3790
3791 // Add `Array` methods to `lodash.prototype`.
3792 baseEach(['pop', 'join', 'replace', 'reverse', 'split', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
3793 var func = (/^(?:replace|split)$/.test(methodName) ? String.prototype : arrayProto)[methodName],
3794 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
3795 retUnwrapped = /^(?:pop|join|replace|shift)$/.test(methodName);
3796
3797 lodash.prototype[methodName] = function() {
3798 var args = arguments;
3799 if (retUnwrapped && !this.__chain__) {
3800 var value = this.value();
3801 return func.apply(isArray(value) ? value : [], args);
3802 }
3803 return this[chainName](function(value) {
3804 return func.apply(isArray(value) ? value : [], args);
3805 });
3806 };
3807 });
3808
3809 // Add chain sequence methods to the `lodash` wrapper.
3810 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
3811
3812 /*--------------------------------------------------------------------------*/
3813
3814 // Some AMD build optimizers, like r.js, check for condition patterns like:
3815 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
3816 // Expose Lodash on the global object to prevent errors when Lodash is
3817 // loaded by a script tag in the presence of an AMD loader.
3818 // See http://requirejs.org/docs/errors.html#mismatch for more details.
3819 // Use `_.noConflict` to remove Lodash from the global object.
3820 root._ = lodash;
3821
3822 // Define as an anonymous module so, through path mapping, it can be
3823 // referenced as the "underscore" module.
3824 define(function() {
3825 return lodash;
3826 });
3827 }
3828 // Check for `exports` after `define` in case a build optimizer adds it.
3829 else if (freeModule) {
3830 // Export for Node.js.
3831 (freeModule.exports = lodash)._ = lodash;
3832 // Export for CommonJS support.
3833 freeExports._ = lodash;
3834 }
3835 else {
3836 // Export to the global object.
3837 root._ = lodash;
3838 }
3839}.call(this));