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