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