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