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