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