Built motion from commit 54a160d.|0.0.140
[motion.git] / public / bower_components / lodash / dist / lodash.js
1 /**
2  * @license
3  * lodash 4.11.2 (Custom Build) <https://lodash.com/>
4  * Build: `lodash -o ./dist/lodash.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 size to enable large array optimizations. */
19   var LARGE_ARRAY_SIZE = 200;
20
21   /** Used as the `TypeError` message for "Functions" methods. */
22   var FUNC_ERROR_TEXT = 'Expected a function';
23
24   /** Used to stand-in for `undefined` hash values. */
25   var HASH_UNDEFINED = '__lodash_hash_undefined__';
26
27   /** Used as the internal argument placeholder. */
28   var PLACEHOLDER = '__lodash_placeholder__';
29
30   /** Used to compose bitmasks for wrapper metadata. */
31   var BIND_FLAG = 1,
32       BIND_KEY_FLAG = 2,
33       CURRY_BOUND_FLAG = 4,
34       CURRY_FLAG = 8,
35       CURRY_RIGHT_FLAG = 16,
36       PARTIAL_FLAG = 32,
37       PARTIAL_RIGHT_FLAG = 64,
38       ARY_FLAG = 128,
39       REARG_FLAG = 256,
40       FLIP_FLAG = 512;
41
42   /** Used to compose bitmasks for comparison styles. */
43   var UNORDERED_COMPARE_FLAG = 1,
44       PARTIAL_COMPARE_FLAG = 2;
45
46   /** Used as default options for `_.truncate`. */
47   var DEFAULT_TRUNC_LENGTH = 30,
48       DEFAULT_TRUNC_OMISSION = '...';
49
50   /** Used to detect hot functions by number of calls within a span of milliseconds. */
51   var HOT_COUNT = 150,
52       HOT_SPAN = 16;
53
54   /** Used to indicate the type of lazy iteratees. */
55   var LAZY_FILTER_FLAG = 1,
56       LAZY_MAP_FLAG = 2,
57       LAZY_WHILE_FLAG = 3;
58
59   /** Used as references for various `Number` constants. */
60   var INFINITY = 1 / 0,
61       MAX_SAFE_INTEGER = 9007199254740991,
62       MAX_INTEGER = 1.7976931348623157e+308,
63       NAN = 0 / 0;
64
65   /** Used as references for the maximum length and index of an array. */
66   var MAX_ARRAY_LENGTH = 4294967295,
67       MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
68       HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
69
70   /** `Object#toString` result references. */
71   var argsTag = '[object Arguments]',
72       arrayTag = '[object Array]',
73       boolTag = '[object Boolean]',
74       dateTag = '[object Date]',
75       errorTag = '[object Error]',
76       funcTag = '[object Function]',
77       genTag = '[object GeneratorFunction]',
78       mapTag = '[object Map]',
79       numberTag = '[object Number]',
80       objectTag = '[object Object]',
81       promiseTag = '[object Promise]',
82       regexpTag = '[object RegExp]',
83       setTag = '[object Set]',
84       stringTag = '[object String]',
85       symbolTag = '[object Symbol]',
86       weakMapTag = '[object WeakMap]',
87       weakSetTag = '[object WeakSet]';
88
89   var arrayBufferTag = '[object ArrayBuffer]',
90       dataViewTag = '[object DataView]',
91       float32Tag = '[object Float32Array]',
92       float64Tag = '[object Float64Array]',
93       int8Tag = '[object Int8Array]',
94       int16Tag = '[object Int16Array]',
95       int32Tag = '[object Int32Array]',
96       uint8Tag = '[object Uint8Array]',
97       uint8ClampedTag = '[object Uint8ClampedArray]',
98       uint16Tag = '[object Uint16Array]',
99       uint32Tag = '[object Uint32Array]';
100
101   /** Used to match empty string literals in compiled template source. */
102   var reEmptyStringLeading = /\b__p \+= '';/g,
103       reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
104       reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
105
106   /** Used to match HTML entities and HTML characters. */
107   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
108       reUnescapedHtml = /[&<>"'`]/g,
109       reHasEscapedHtml = RegExp(reEscapedHtml.source),
110       reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
111
112   /** Used to match template delimiters. */
113   var reEscape = /<%-([\s\S]+?)%>/g,
114       reEvaluate = /<%([\s\S]+?)%>/g,
115       reInterpolate = /<%=([\s\S]+?)%>/g;
116
117   /** Used to match property names within property paths. */
118   var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
119       reIsPlainProp = /^\w*$/,
120       rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
121
122   /**
123    * Used to match `RegExp`
124    * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
125    */
126   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
127       reHasRegExpChar = RegExp(reRegExpChar.source);
128
129   /** Used to match leading and trailing whitespace. */
130   var reTrim = /^\s+|\s+$/g,
131       reTrimStart = /^\s+/,
132       reTrimEnd = /\s+$/;
133
134   /** Used to match non-compound words composed of alphanumeric characters. */
135   var reBasicWord = /[a-zA-Z0-9]+/g;
136
137   /** Used to match backslashes in property paths. */
138   var reEscapeChar = /\\(\\)?/g;
139
140   /**
141    * Used to match
142    * [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components).
143    */
144   var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
145
146   /** Used to match `RegExp` flags from their coerced string values. */
147   var reFlags = /\w*$/;
148
149   /** Used to detect hexadecimal string values. */
150   var reHasHexPrefix = /^0x/i;
151
152   /** Used to detect bad signed hexadecimal string values. */
153   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
154
155   /** Used to detect binary string values. */
156   var reIsBinary = /^0b[01]+$/i;
157
158   /** Used to detect host constructors (Safari). */
159   var reIsHostCtor = /^\[object .+?Constructor\]$/;
160
161   /** Used to detect octal string values. */
162   var reIsOctal = /^0o[0-7]+$/i;
163
164   /** Used to detect unsigned integer values. */
165   var reIsUint = /^(?:0|[1-9]\d*)$/;
166
167   /** Used to match latin-1 supplementary letters (excluding mathematical operators). */
168   var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
169
170   /** Used to ensure capturing order of template delimiters. */
171   var reNoMatch = /($^)/;
172
173   /** Used to match unescaped characters in compiled string literals. */
174   var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
175
176   /** Used to compose unicode character classes. */
177   var rsAstralRange = '\\ud800-\\udfff',
178       rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
179       rsComboSymbolsRange = '\\u20d0-\\u20f0',
180       rsDingbatRange = '\\u2700-\\u27bf',
181       rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
182       rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
183       rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
184       rsPunctuationRange = '\\u2000-\\u206f',
185       rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
186       rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
187       rsVarRange = '\\ufe0e\\ufe0f',
188       rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
189
190   /** Used to compose unicode capture groups. */
191   var rsApos = "['\u2019]",
192       rsAstral = '[' + rsAstralRange + ']',
193       rsBreak = '[' + rsBreakRange + ']',
194       rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
195       rsDigits = '\\d+',
196       rsDingbat = '[' + rsDingbatRange + ']',
197       rsLower = '[' + rsLowerRange + ']',
198       rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
199       rsFitz = '\\ud83c[\\udffb-\\udfff]',
200       rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
201       rsNonAstral = '[^' + rsAstralRange + ']',
202       rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
203       rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
204       rsUpper = '[' + rsUpperRange + ']',
205       rsZWJ = '\\u200d';
206
207   /** Used to compose unicode regexes. */
208   var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
209       rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
210       rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
211       rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
212       reOptMod = rsModifier + '?',
213       rsOptVar = '[' + rsVarRange + ']?',
214       rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
215       rsSeq = rsOptVar + reOptMod + rsOptJoin,
216       rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
217       rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
218
219   /** Used to match apostrophes. */
220   var reApos = RegExp(rsApos, 'g');
221
222   /**
223    * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
224    * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
225    */
226   var reComboMark = RegExp(rsCombo, 'g');
227
228   /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
229   var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
230
231   /** Used to match complex or compound words. */
232   var reComplexWord = RegExp([
233     rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
234     rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
235     rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
236     rsUpper + '+' + rsOptUpperContr,
237     rsDigits,
238     rsEmoji
239   ].join('|'), 'g');
240
241   /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
242   var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange  + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
243
244   /** Used to detect strings that need a more robust regexp to match words. */
245   var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
246
247   /** Used to assign default `context` object properties. */
248   var contextProps = [
249     'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
250     'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
251     'Promise', 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError',
252     'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
253     '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
254   ];
255
256   /** Used to make template sourceURLs easier to identify. */
257   var templateCounter = -1;
258
259   /** Used to identify `toStringTag` values of typed arrays. */
260   var typedArrayTags = {};
261   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
262   typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
263   typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
264   typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
265   typedArrayTags[uint32Tag] = true;
266   typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
267   typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
268   typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
269   typedArrayTags[errorTag] = typedArrayTags[funcTag] =
270   typedArrayTags[mapTag] = typedArrayTags[numberTag] =
271   typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
272   typedArrayTags[setTag] = typedArrayTags[stringTag] =
273   typedArrayTags[weakMapTag] = false;
274
275   /** Used to identify `toStringTag` values supported by `_.clone`. */
276   var cloneableTags = {};
277   cloneableTags[argsTag] = cloneableTags[arrayTag] =
278   cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
279   cloneableTags[boolTag] = cloneableTags[dateTag] =
280   cloneableTags[float32Tag] = cloneableTags[float64Tag] =
281   cloneableTags[int8Tag] = cloneableTags[int16Tag] =
282   cloneableTags[int32Tag] = cloneableTags[mapTag] =
283   cloneableTags[numberTag] = cloneableTags[objectTag] =
284   cloneableTags[regexpTag] = cloneableTags[setTag] =
285   cloneableTags[stringTag] = cloneableTags[symbolTag] =
286   cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
287   cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
288   cloneableTags[errorTag] = cloneableTags[funcTag] =
289   cloneableTags[weakMapTag] = false;
290
291   /** Used to map latin-1 supplementary letters to basic latin letters. */
292   var deburredLetters = {
293     '\xc0': 'A',  '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
294     '\xe0': 'a',  '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
295     '\xc7': 'C',  '\xe7': 'c',
296     '\xd0': 'D',  '\xf0': 'd',
297     '\xc8': 'E',  '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
298     '\xe8': 'e',  '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
299     '\xcC': 'I',  '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
300     '\xeC': 'i',  '\xed': 'i', '\xee': 'i', '\xef': 'i',
301     '\xd1': 'N',  '\xf1': 'n',
302     '\xd2': 'O',  '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
303     '\xf2': 'o',  '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
304     '\xd9': 'U',  '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
305     '\xf9': 'u',  '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
306     '\xdd': 'Y',  '\xfd': 'y', '\xff': 'y',
307     '\xc6': 'Ae', '\xe6': 'ae',
308     '\xde': 'Th', '\xfe': 'th',
309     '\xdf': 'ss'
310   };
311
312   /** Used to map characters to HTML entities. */
313   var htmlEscapes = {
314     '&': '&amp;',
315     '<': '&lt;',
316     '>': '&gt;',
317     '"': '&quot;',
318     "'": '&#39;',
319     '`': '&#96;'
320   };
321
322   /** Used to map HTML entities to characters. */
323   var htmlUnescapes = {
324     '&amp;': '&',
325     '&lt;': '<',
326     '&gt;': '>',
327     '&quot;': '"',
328     '&#39;': "'",
329     '&#96;': '`'
330   };
331
332   /** Used to determine if values are of the language type `Object`. */
333   var objectTypes = {
334     'function': true,
335     'object': true
336   };
337
338   /** Used to escape characters for inclusion in compiled string literals. */
339   var stringEscapes = {
340     '\\': '\\',
341     "'": "'",
342     '\n': 'n',
343     '\r': 'r',
344     '\u2028': 'u2028',
345     '\u2029': 'u2029'
346   };
347
348   /** Built-in method references without a dependency on `root`. */
349   var freeParseFloat = parseFloat,
350       freeParseInt = parseInt;
351
352   /** Detect free variable `exports`. */
353   var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
354     ? exports
355     : undefined;
356
357   /** Detect free variable `module`. */
358   var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
359     ? module
360     : undefined;
361
362   /** Detect the popular CommonJS extension `module.exports`. */
363   var moduleExports = (freeModule && freeModule.exports === freeExports)
364     ? freeExports
365     : undefined;
366
367   /** Detect free variable `global` from Node.js. */
368   var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
369
370   /** Detect free variable `self`. */
371   var freeSelf = checkGlobal(objectTypes[typeof self] && self);
372
373   /** Detect free variable `window`. */
374   var freeWindow = checkGlobal(objectTypes[typeof window] && window);
375
376   /** Detect `this` as the global object. */
377   var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
378
379   /**
380    * Used as a reference to the global object.
381    *
382    * The `this` value is used if it's the global object to avoid Greasemonkey's
383    * restricted `window` object, otherwise the `window` object is used.
384    */
385   var root = freeGlobal ||
386     ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
387       freeSelf || thisGlobal || Function('return this')();
388
389   /*--------------------------------------------------------------------------*/
390
391   /**
392    * Adds the key-value `pair` to `map`.
393    *
394    * @private
395    * @param {Object} map The map to modify.
396    * @param {Array} pair The key-value pair to add.
397    * @returns {Object} Returns `map`.
398    */
399   function addMapEntry(map, pair) {
400     // Don't return `Map#set` because it doesn't return the map instance in IE 11.
401     map.set(pair[0], pair[1]);
402     return map;
403   }
404
405   /**
406    * Adds `value` to `set`.
407    *
408    * @private
409    * @param {Object} set The set to modify.
410    * @param {*} value The value to add.
411    * @returns {Object} Returns `set`.
412    */
413   function addSetEntry(set, value) {
414     set.add(value);
415     return set;
416   }
417
418   /**
419    * A faster alternative to `Function#apply`, this function invokes `func`
420    * with the `this` binding of `thisArg` and the arguments of `args`.
421    *
422    * @private
423    * @param {Function} func The function to invoke.
424    * @param {*} thisArg The `this` binding of `func`.
425    * @param {Array} args The arguments to invoke `func` with.
426    * @returns {*} Returns the result of `func`.
427    */
428   function apply(func, thisArg, args) {
429     var length = args.length;
430     switch (length) {
431       case 0: return func.call(thisArg);
432       case 1: return func.call(thisArg, args[0]);
433       case 2: return func.call(thisArg, args[0], args[1]);
434       case 3: return func.call(thisArg, args[0], args[1], args[2]);
435     }
436     return func.apply(thisArg, args);
437   }
438
439   /**
440    * A specialized version of `baseAggregator` for arrays.
441    *
442    * @private
443    * @param {Array} array The array to iterate over.
444    * @param {Function} setter The function to set `accumulator` values.
445    * @param {Function} iteratee The iteratee to transform keys.
446    * @param {Object} accumulator The initial aggregated object.
447    * @returns {Function} Returns `accumulator`.
448    */
449   function arrayAggregator(array, setter, iteratee, accumulator) {
450     var index = -1,
451         length = array.length;
452
453     while (++index < length) {
454       var value = array[index];
455       setter(accumulator, value, iteratee(value), array);
456     }
457     return accumulator;
458   }
459
460   /**
461    * Creates a new array concatenating `array` with `other`.
462    *
463    * @private
464    * @param {Array} array The first array to concatenate.
465    * @param {Array} other The second array to concatenate.
466    * @returns {Array} Returns the new concatenated array.
467    */
468   function arrayConcat(array, other) {
469     var index = -1,
470         length = array.length,
471         othIndex = -1,
472         othLength = other.length,
473         result = Array(length + othLength);
474
475     while (++index < length) {
476       result[index] = array[index];
477     }
478     while (++othIndex < othLength) {
479       result[index++] = other[othIndex];
480     }
481     return result;
482   }
483
484   /**
485    * A specialized version of `_.forEach` for arrays without support for
486    * iteratee shorthands.
487    *
488    * @private
489    * @param {Array} array The array to iterate over.
490    * @param {Function} iteratee The function invoked per iteration.
491    * @returns {Array} Returns `array`.
492    */
493   function arrayEach(array, iteratee) {
494     var index = -1,
495         length = array.length;
496
497     while (++index < length) {
498       if (iteratee(array[index], index, array) === false) {
499         break;
500       }
501     }
502     return array;
503   }
504
505   /**
506    * A specialized version of `_.forEachRight` for arrays without support for
507    * iteratee shorthands.
508    *
509    * @private
510    * @param {Array} array The array to iterate over.
511    * @param {Function} iteratee The function invoked per iteration.
512    * @returns {Array} Returns `array`.
513    */
514   function arrayEachRight(array, iteratee) {
515     var length = array.length;
516
517     while (length--) {
518       if (iteratee(array[length], length, array) === false) {
519         break;
520       }
521     }
522     return array;
523   }
524
525   /**
526    * A specialized version of `_.every` for arrays without support for
527    * iteratee shorthands.
528    *
529    * @private
530    * @param {Array} array The array to iterate over.
531    * @param {Function} predicate The function invoked per iteration.
532    * @returns {boolean} Returns `true` if all elements pass the predicate check,
533    *  else `false`.
534    */
535   function arrayEvery(array, predicate) {
536     var index = -1,
537         length = array.length;
538
539     while (++index < length) {
540       if (!predicate(array[index], index, array)) {
541         return false;
542       }
543     }
544     return true;
545   }
546
547   /**
548    * A specialized version of `_.filter` for arrays without support for
549    * iteratee shorthands.
550    *
551    * @private
552    * @param {Array} array The array to iterate over.
553    * @param {Function} predicate The function invoked per iteration.
554    * @returns {Array} Returns the new filtered array.
555    */
556   function arrayFilter(array, predicate) {
557     var index = -1,
558         length = array.length,
559         resIndex = 0,
560         result = [];
561
562     while (++index < length) {
563       var value = array[index];
564       if (predicate(value, index, array)) {
565         result[resIndex++] = value;
566       }
567     }
568     return result;
569   }
570
571   /**
572    * A specialized version of `_.includes` for arrays without support for
573    * specifying an index to search from.
574    *
575    * @private
576    * @param {Array} array The array to search.
577    * @param {*} target The value to search for.
578    * @returns {boolean} Returns `true` if `target` is found, else `false`.
579    */
580   function arrayIncludes(array, value) {
581     return !!array.length && baseIndexOf(array, value, 0) > -1;
582   }
583
584   /**
585    * This function is like `arrayIncludes` except that it accepts a comparator.
586    *
587    * @private
588    * @param {Array} array The array to search.
589    * @param {*} target The value to search for.
590    * @param {Function} comparator The comparator invoked per element.
591    * @returns {boolean} Returns `true` if `target` is found, else `false`.
592    */
593   function arrayIncludesWith(array, value, comparator) {
594     var index = -1,
595         length = array.length;
596
597     while (++index < length) {
598       if (comparator(value, array[index])) {
599         return true;
600       }
601     }
602     return false;
603   }
604
605   /**
606    * A specialized version of `_.map` for arrays without support for iteratee
607    * shorthands.
608    *
609    * @private
610    * @param {Array} array The array to iterate over.
611    * @param {Function} iteratee The function invoked per iteration.
612    * @returns {Array} Returns the new mapped array.
613    */
614   function arrayMap(array, iteratee) {
615     var index = -1,
616         length = array.length,
617         result = Array(length);
618
619     while (++index < length) {
620       result[index] = iteratee(array[index], index, array);
621     }
622     return result;
623   }
624
625   /**
626    * Appends the elements of `values` to `array`.
627    *
628    * @private
629    * @param {Array} array The array to modify.
630    * @param {Array} values The values to append.
631    * @returns {Array} Returns `array`.
632    */
633   function arrayPush(array, values) {
634     var index = -1,
635         length = values.length,
636         offset = array.length;
637
638     while (++index < length) {
639       array[offset + index] = values[index];
640     }
641     return array;
642   }
643
644   /**
645    * A specialized version of `_.reduce` for arrays without support for
646    * iteratee shorthands.
647    *
648    * @private
649    * @param {Array} array The array to iterate over.
650    * @param {Function} iteratee The function invoked per iteration.
651    * @param {*} [accumulator] The initial value.
652    * @param {boolean} [initAccum] Specify using the first element of `array` as
653    *  the initial value.
654    * @returns {*} Returns the accumulated value.
655    */
656   function arrayReduce(array, iteratee, accumulator, initAccum) {
657     var index = -1,
658         length = array.length;
659
660     if (initAccum && length) {
661       accumulator = array[++index];
662     }
663     while (++index < length) {
664       accumulator = iteratee(accumulator, array[index], index, array);
665     }
666     return accumulator;
667   }
668
669   /**
670    * A specialized version of `_.reduceRight` for arrays without support for
671    * iteratee shorthands.
672    *
673    * @private
674    * @param {Array} array The array to iterate over.
675    * @param {Function} iteratee The function invoked per iteration.
676    * @param {*} [accumulator] The initial value.
677    * @param {boolean} [initAccum] Specify using the last element of `array` as
678    *  the initial value.
679    * @returns {*} Returns the accumulated value.
680    */
681   function arrayReduceRight(array, iteratee, accumulator, initAccum) {
682     var length = array.length;
683     if (initAccum && length) {
684       accumulator = array[--length];
685     }
686     while (length--) {
687       accumulator = iteratee(accumulator, array[length], length, array);
688     }
689     return accumulator;
690   }
691
692   /**
693    * A specialized version of `_.some` for arrays without support for iteratee
694    * shorthands.
695    *
696    * @private
697    * @param {Array} array The array to iterate over.
698    * @param {Function} predicate The function invoked per iteration.
699    * @returns {boolean} Returns `true` if any element passes the predicate check,
700    *  else `false`.
701    */
702   function arraySome(array, predicate) {
703     var index = -1,
704         length = array.length;
705
706     while (++index < length) {
707       if (predicate(array[index], index, array)) {
708         return true;
709       }
710     }
711     return false;
712   }
713
714   /**
715    * The base implementation of methods like `_.find` and `_.findKey`, without
716    * support for iteratee shorthands, which iterates over `collection` using
717    * `eachFunc`.
718    *
719    * @private
720    * @param {Array|Object} collection The collection to search.
721    * @param {Function} predicate The function invoked per iteration.
722    * @param {Function} eachFunc The function to iterate over `collection`.
723    * @param {boolean} [retKey] Specify returning the key of the found element
724    *  instead of the element itself.
725    * @returns {*} Returns the found element or its key, else `undefined`.
726    */
727   function baseFind(collection, predicate, eachFunc, retKey) {
728     var result;
729     eachFunc(collection, function(value, key, collection) {
730       if (predicate(value, key, collection)) {
731         result = retKey ? key : value;
732         return false;
733       }
734     });
735     return result;
736   }
737
738   /**
739    * The base implementation of `_.findIndex` and `_.findLastIndex` without
740    * support for iteratee shorthands.
741    *
742    * @private
743    * @param {Array} array The array to search.
744    * @param {Function} predicate The function invoked per iteration.
745    * @param {boolean} [fromRight] Specify iterating from right to left.
746    * @returns {number} Returns the index of the matched value, else `-1`.
747    */
748   function baseFindIndex(array, predicate, fromRight) {
749     var length = array.length,
750         index = fromRight ? length : -1;
751
752     while ((fromRight ? index-- : ++index < length)) {
753       if (predicate(array[index], index, array)) {
754         return index;
755       }
756     }
757     return -1;
758   }
759
760   /**
761    * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
762    *
763    * @private
764    * @param {Array} array The array to search.
765    * @param {*} value The value to search for.
766    * @param {number} fromIndex The index to search from.
767    * @returns {number} Returns the index of the matched value, else `-1`.
768    */
769   function baseIndexOf(array, value, fromIndex) {
770     if (value !== value) {
771       return indexOfNaN(array, fromIndex);
772     }
773     var index = fromIndex - 1,
774         length = array.length;
775
776     while (++index < length) {
777       if (array[index] === value) {
778         return index;
779       }
780     }
781     return -1;
782   }
783
784   /**
785    * This function is like `baseIndexOf` except that it accepts a comparator.
786    *
787    * @private
788    * @param {Array} array The array to search.
789    * @param {*} value The value to search for.
790    * @param {number} fromIndex The index to search from.
791    * @param {Function} comparator The comparator invoked per element.
792    * @returns {number} Returns the index of the matched value, else `-1`.
793    */
794   function baseIndexOfWith(array, value, fromIndex, comparator) {
795     var index = fromIndex - 1,
796         length = array.length;
797
798     while (++index < length) {
799       if (comparator(array[index], value)) {
800         return index;
801       }
802     }
803     return -1;
804   }
805
806   /**
807    * The base implementation of `_.mean` and `_.meanBy` without support for
808    * iteratee shorthands.
809    *
810    * @private
811    * @param {Array} array The array to iterate over.
812    * @param {Function} iteratee The function invoked per iteration.
813    * @returns {number} Returns the mean.
814    */
815   function baseMean(array, iteratee) {
816     var length = array ? array.length : 0;
817     return length ? (baseSum(array, iteratee) / length) : NAN;
818   }
819
820   /**
821    * The base implementation of `_.reduce` and `_.reduceRight`, without support
822    * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
823    *
824    * @private
825    * @param {Array|Object} collection The collection to iterate over.
826    * @param {Function} iteratee The function invoked per iteration.
827    * @param {*} accumulator The initial value.
828    * @param {boolean} initAccum Specify using the first or last element of
829    *  `collection` as the initial value.
830    * @param {Function} eachFunc The function to iterate over `collection`.
831    * @returns {*} Returns the accumulated value.
832    */
833   function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
834     eachFunc(collection, function(value, index, collection) {
835       accumulator = initAccum
836         ? (initAccum = false, value)
837         : iteratee(accumulator, value, index, collection);
838     });
839     return accumulator;
840   }
841
842   /**
843    * The base implementation of `_.sortBy` which uses `comparer` to define the
844    * sort order of `array` and replaces criteria objects with their corresponding
845    * values.
846    *
847    * @private
848    * @param {Array} array The array to sort.
849    * @param {Function} comparer The function to define sort order.
850    * @returns {Array} Returns `array`.
851    */
852   function baseSortBy(array, comparer) {
853     var length = array.length;
854
855     array.sort(comparer);
856     while (length--) {
857       array[length] = array[length].value;
858     }
859     return array;
860   }
861
862   /**
863    * The base implementation of `_.sum` and `_.sumBy` without support for
864    * iteratee shorthands.
865    *
866    * @private
867    * @param {Array} array The array to iterate over.
868    * @param {Function} iteratee The function invoked per iteration.
869    * @returns {number} Returns the sum.
870    */
871   function baseSum(array, iteratee) {
872     var result,
873         index = -1,
874         length = array.length;
875
876     while (++index < length) {
877       var current = iteratee(array[index]);
878       if (current !== undefined) {
879         result = result === undefined ? current : (result + current);
880       }
881     }
882     return result;
883   }
884
885   /**
886    * The base implementation of `_.times` without support for iteratee shorthands
887    * or max array length checks.
888    *
889    * @private
890    * @param {number} n The number of times to invoke `iteratee`.
891    * @param {Function} iteratee The function invoked per iteration.
892    * @returns {Array} Returns the array of results.
893    */
894   function baseTimes(n, iteratee) {
895     var index = -1,
896         result = Array(n);
897
898     while (++index < n) {
899       result[index] = iteratee(index);
900     }
901     return result;
902   }
903
904   /**
905    * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
906    * of key-value pairs for `object` corresponding to the property names of `props`.
907    *
908    * @private
909    * @param {Object} object The object to query.
910    * @param {Array} props The property names to get values for.
911    * @returns {Object} Returns the new array of key-value pairs.
912    */
913   function baseToPairs(object, props) {
914     return arrayMap(props, function(key) {
915       return [key, object[key]];
916     });
917   }
918
919   /**
920    * The base implementation of `_.unary` without support for storing wrapper metadata.
921    *
922    * @private
923    * @param {Function} func The function to cap arguments for.
924    * @returns {Function} Returns the new function.
925    */
926   function baseUnary(func) {
927     return function(value) {
928       return func(value);
929     };
930   }
931
932   /**
933    * The base implementation of `_.values` and `_.valuesIn` which creates an
934    * array of `object` property values corresponding to the property names
935    * of `props`.
936    *
937    * @private
938    * @param {Object} object The object to query.
939    * @param {Array} props The property names to get values for.
940    * @returns {Object} Returns the array of property values.
941    */
942   function baseValues(object, props) {
943     return arrayMap(props, function(key) {
944       return object[key];
945     });
946   }
947
948   /**
949    * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
950    * that is not found in the character symbols.
951    *
952    * @private
953    * @param {Array} strSymbols The string symbols to inspect.
954    * @param {Array} chrSymbols The character symbols to find.
955    * @returns {number} Returns the index of the first unmatched string symbol.
956    */
957   function charsStartIndex(strSymbols, chrSymbols) {
958     var index = -1,
959         length = strSymbols.length;
960
961     while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
962     return index;
963   }
964
965   /**
966    * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
967    * that is not found in the character symbols.
968    *
969    * @private
970    * @param {Array} strSymbols The string symbols to inspect.
971    * @param {Array} chrSymbols The character symbols to find.
972    * @returns {number} Returns the index of the last unmatched string symbol.
973    */
974   function charsEndIndex(strSymbols, chrSymbols) {
975     var index = strSymbols.length;
976
977     while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
978     return index;
979   }
980
981   /**
982    * Checks if `value` is a global object.
983    *
984    * @private
985    * @param {*} value The value to check.
986    * @returns {null|Object} Returns `value` if it's a global object, else `null`.
987    */
988   function checkGlobal(value) {
989     return (value && value.Object === Object) ? value : null;
990   }
991
992   /**
993    * Gets the number of `placeholder` occurrences in `array`.
994    *
995    * @private
996    * @param {Array} array The array to inspect.
997    * @param {*} placeholder The placeholder to search for.
998    * @returns {number} Returns the placeholder count.
999    */
1000   function countHolders(array, placeholder) {
1001     var length = array.length,
1002         result = 0;
1003
1004     while (length--) {
1005       if (array[length] === placeholder) {
1006         result++;
1007       }
1008     }
1009     return result;
1010   }
1011
1012   /**
1013    * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.
1014    *
1015    * @private
1016    * @param {string} letter The matched letter to deburr.
1017    * @returns {string} Returns the deburred letter.
1018    */
1019   function deburrLetter(letter) {
1020     return deburredLetters[letter];
1021   }
1022
1023   /**
1024    * Used by `_.escape` to convert characters to HTML entities.
1025    *
1026    * @private
1027    * @param {string} chr The matched character to escape.
1028    * @returns {string} Returns the escaped character.
1029    */
1030   function escapeHtmlChar(chr) {
1031     return htmlEscapes[chr];
1032   }
1033
1034   /**
1035    * Used by `_.template` to escape characters for inclusion in compiled string literals.
1036    *
1037    * @private
1038    * @param {string} chr The matched character to escape.
1039    * @returns {string} Returns the escaped character.
1040    */
1041   function escapeStringChar(chr) {
1042     return '\\' + stringEscapes[chr];
1043   }
1044
1045   /**
1046    * Gets the index at which the first occurrence of `NaN` is found in `array`.
1047    *
1048    * @private
1049    * @param {Array} array The array to search.
1050    * @param {number} fromIndex The index to search from.
1051    * @param {boolean} [fromRight] Specify iterating from right to left.
1052    * @returns {number} Returns the index of the matched `NaN`, else `-1`.
1053    */
1054   function indexOfNaN(array, fromIndex, fromRight) {
1055     var length = array.length,
1056         index = fromIndex + (fromRight ? 0 : -1);
1057
1058     while ((fromRight ? index-- : ++index < length)) {
1059       var other = array[index];
1060       if (other !== other) {
1061         return index;
1062       }
1063     }
1064     return -1;
1065   }
1066
1067   /**
1068    * Checks if `value` is a host object in IE < 9.
1069    *
1070    * @private
1071    * @param {*} value The value to check.
1072    * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
1073    */
1074   function isHostObject(value) {
1075     // Many host objects are `Object` objects that can coerce to strings
1076     // despite having improperly defined `toString` methods.
1077     var result = false;
1078     if (value != null && typeof value.toString != 'function') {
1079       try {
1080         result = !!(value + '');
1081       } catch (e) {}
1082     }
1083     return result;
1084   }
1085
1086   /**
1087    * Converts `iterator` to an array.
1088    *
1089    * @private
1090    * @param {Object} iterator The iterator to convert.
1091    * @returns {Array} Returns the converted array.
1092    */
1093   function iteratorToArray(iterator) {
1094     var data,
1095         result = [];
1096
1097     while (!(data = iterator.next()).done) {
1098       result.push(data.value);
1099     }
1100     return result;
1101   }
1102
1103   /**
1104    * Converts `map` to an array.
1105    *
1106    * @private
1107    * @param {Object} map The map to convert.
1108    * @returns {Array} Returns the converted array.
1109    */
1110   function mapToArray(map) {
1111     var index = -1,
1112         result = Array(map.size);
1113
1114     map.forEach(function(value, key) {
1115       result[++index] = [key, value];
1116     });
1117     return result;
1118   }
1119
1120   /**
1121    * Replaces all `placeholder` elements in `array` with an internal placeholder
1122    * and returns an array of their indexes.
1123    *
1124    * @private
1125    * @param {Array} array The array to modify.
1126    * @param {*} placeholder The placeholder to replace.
1127    * @returns {Array} Returns the new array of placeholder indexes.
1128    */
1129   function replaceHolders(array, placeholder) {
1130     var index = -1,
1131         length = array.length,
1132         resIndex = 0,
1133         result = [];
1134
1135     while (++index < length) {
1136       var value = array[index];
1137       if (value === placeholder || value === PLACEHOLDER) {
1138         array[index] = PLACEHOLDER;
1139         result[resIndex++] = index;
1140       }
1141     }
1142     return result;
1143   }
1144
1145   /**
1146    * Converts `set` to an array.
1147    *
1148    * @private
1149    * @param {Object} set The set to convert.
1150    * @returns {Array} Returns the converted array.
1151    */
1152   function setToArray(set) {
1153     var index = -1,
1154         result = Array(set.size);
1155
1156     set.forEach(function(value) {
1157       result[++index] = value;
1158     });
1159     return result;
1160   }
1161
1162   /**
1163    * Gets the number of symbols in `string`.
1164    *
1165    * @private
1166    * @param {string} string The string to inspect.
1167    * @returns {number} Returns the string size.
1168    */
1169   function stringSize(string) {
1170     if (!(string && reHasComplexSymbol.test(string))) {
1171       return string.length;
1172     }
1173     var result = reComplexSymbol.lastIndex = 0;
1174     while (reComplexSymbol.test(string)) {
1175       result++;
1176     }
1177     return result;
1178   }
1179
1180   /**
1181    * Converts `string` to an array.
1182    *
1183    * @private
1184    * @param {string} string The string to convert.
1185    * @returns {Array} Returns the converted array.
1186    */
1187   function stringToArray(string) {
1188     return string.match(reComplexSymbol);
1189   }
1190
1191   /**
1192    * Used by `_.unescape` to convert HTML entities to characters.
1193    *
1194    * @private
1195    * @param {string} chr The matched character to unescape.
1196    * @returns {string} Returns the unescaped character.
1197    */
1198   function unescapeHtmlChar(chr) {
1199     return htmlUnescapes[chr];
1200   }
1201
1202   /*--------------------------------------------------------------------------*/
1203
1204   /**
1205    * Create a new pristine `lodash` function using the `context` object.
1206    *
1207    * @static
1208    * @memberOf _
1209    * @since 1.1.0
1210    * @category Util
1211    * @param {Object} [context=root] The context object.
1212    * @returns {Function} Returns a new `lodash` function.
1213    * @example
1214    *
1215    * _.mixin({ 'foo': _.constant('foo') });
1216    *
1217    * var lodash = _.runInContext();
1218    * lodash.mixin({ 'bar': lodash.constant('bar') });
1219    *
1220    * _.isFunction(_.foo);
1221    * // => true
1222    * _.isFunction(_.bar);
1223    * // => false
1224    *
1225    * lodash.isFunction(lodash.foo);
1226    * // => false
1227    * lodash.isFunction(lodash.bar);
1228    * // => true
1229    *
1230    * // Use `context` to mock `Date#getTime` use in `_.now`.
1231    * var mock = _.runInContext({
1232    *   'Date': function() {
1233    *     return { 'getTime': getTimeMock };
1234    *   }
1235    * });
1236    *
1237    * // Create a suped-up `defer` in Node.js.
1238    * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1239    */
1240   function runInContext(context) {
1241     context = context ? _.defaults({}, context, _.pick(root, contextProps)) : root;
1242
1243     /** Built-in constructor references. */
1244     var Date = context.Date,
1245         Error = context.Error,
1246         Math = context.Math,
1247         RegExp = context.RegExp,
1248         TypeError = context.TypeError;
1249
1250     /** Used for built-in method references. */
1251     var arrayProto = context.Array.prototype,
1252         objectProto = context.Object.prototype,
1253         stringProto = context.String.prototype;
1254
1255     /** Used to resolve the decompiled source of functions. */
1256     var funcToString = context.Function.prototype.toString;
1257
1258     /** Used to check objects for own properties. */
1259     var hasOwnProperty = objectProto.hasOwnProperty;
1260
1261     /** Used to generate unique IDs. */
1262     var idCounter = 0;
1263
1264     /** Used to infer the `Object` constructor. */
1265     var objectCtorString = funcToString.call(Object);
1266
1267     /**
1268      * Used to resolve the
1269      * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
1270      * of values.
1271      */
1272     var objectToString = objectProto.toString;
1273
1274     /** Used to restore the original `_` reference in `_.noConflict`. */
1275     var oldDash = root._;
1276
1277     /** Used to detect if a method is native. */
1278     var reIsNative = RegExp('^' +
1279       funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1280       .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1281     );
1282
1283     /** Built-in value references. */
1284     var Buffer = moduleExports ? context.Buffer : undefined,
1285         Reflect = context.Reflect,
1286         Symbol = context.Symbol,
1287         Uint8Array = context.Uint8Array,
1288         clearTimeout = context.clearTimeout,
1289         enumerate = Reflect ? Reflect.enumerate : undefined,
1290         getOwnPropertySymbols = Object.getOwnPropertySymbols,
1291         iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
1292         objectCreate = Object.create,
1293         propertyIsEnumerable = objectProto.propertyIsEnumerable,
1294         setTimeout = context.setTimeout,
1295         splice = arrayProto.splice;
1296
1297     /* Built-in method references for those with the same name as other `lodash` methods. */
1298     var nativeCeil = Math.ceil,
1299         nativeFloor = Math.floor,
1300         nativeGetPrototype = Object.getPrototypeOf,
1301         nativeIsFinite = context.isFinite,
1302         nativeJoin = arrayProto.join,
1303         nativeKeys = Object.keys,
1304         nativeMax = Math.max,
1305         nativeMin = Math.min,
1306         nativeParseInt = context.parseInt,
1307         nativeRandom = Math.random,
1308         nativeReplace = stringProto.replace,
1309         nativeReverse = arrayProto.reverse,
1310         nativeSplit = stringProto.split;
1311
1312     /* Built-in method references that are verified to be native. */
1313     var DataView = getNative(context, 'DataView'),
1314         Map = getNative(context, 'Map'),
1315         Promise = getNative(context, 'Promise'),
1316         Set = getNative(context, 'Set'),
1317         WeakMap = getNative(context, 'WeakMap'),
1318         nativeCreate = getNative(Object, 'create');
1319
1320     /** Used to store function metadata. */
1321     var metaMap = WeakMap && new WeakMap;
1322
1323     /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
1324     var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
1325
1326     /** Used to lookup unminified function names. */
1327     var realNames = {};
1328
1329     /** Used to detect maps, sets, and weakmaps. */
1330     var dataViewCtorString = toSource(DataView),
1331         mapCtorString = toSource(Map),
1332         promiseCtorString = toSource(Promise),
1333         setCtorString = toSource(Set),
1334         weakMapCtorString = toSource(WeakMap);
1335
1336     /** Used to convert symbols to primitives and strings. */
1337     var symbolProto = Symbol ? Symbol.prototype : undefined,
1338         symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
1339         symbolToString = symbolProto ? symbolProto.toString : undefined;
1340
1341     /*------------------------------------------------------------------------*/
1342
1343     /**
1344      * Creates a `lodash` object which wraps `value` to enable implicit method
1345      * chain sequences. Methods that operate on and return arrays, collections,
1346      * and functions can be chained together. Methods that retrieve a single value
1347      * or may return a primitive value will automatically end the chain sequence
1348      * and return the unwrapped value. Otherwise, the value must be unwrapped
1349      * with `_#value`.
1350      *
1351      * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1352      * enabled using `_.chain`.
1353      *
1354      * The execution of chained methods is lazy, that is, it's deferred until
1355      * `_#value` is implicitly or explicitly called.
1356      *
1357      * Lazy evaluation allows several methods to support shortcut fusion.
1358      * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1359      * the creation of intermediate arrays and can greatly reduce the number of
1360      * iteratee executions. Sections of a chain sequence qualify for shortcut
1361      * fusion if the section is applied to an array of at least `200` elements
1362      * and any iteratees accept only one argument. The heuristic for whether a
1363      * section qualifies for shortcut fusion is subject to change.
1364      *
1365      * Chaining is supported in custom builds as long as the `_#value` method is
1366      * directly or indirectly included in the build.
1367      *
1368      * In addition to lodash methods, wrappers have `Array` and `String` methods.
1369      *
1370      * The wrapper `Array` methods are:
1371      * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1372      *
1373      * The wrapper `String` methods are:
1374      * `replace` and `split`
1375      *
1376      * The wrapper methods that support shortcut fusion are:
1377      * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1378      * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1379      * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1380      *
1381      * The chainable wrapper methods are:
1382      * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1383      * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1384      * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1385      * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1386      * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1387      * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1388      * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1389      * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1390      * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1391      * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1392      * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1393      * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1394      * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1395      * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1396      * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1397      * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1398      * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1399      * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1400      * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1401      * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1402      * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1403      * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1404      * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1405      * `zipObject`, `zipObjectDeep`, and `zipWith`
1406      *
1407      * The wrapper methods that are **not** chainable by default are:
1408      * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1409      * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`,
1410      * `eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`,
1411      * `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`,
1412      * `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
1413      * `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`,
1414      * `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`,
1415      * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`,
1416      * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`,
1417      * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`,
1418      * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
1419      * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`,
1420      * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
1421      * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
1422      * `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`,
1423      * `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, `padStart`, `parseInt`,
1424      * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
1425      * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
1426      * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
1427      * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toInteger`,
1428      * `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, `toString`,
1429      * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`,
1430      * `uniqueId`, `upperCase`, `upperFirst`, `value`, and `words`
1431      *
1432      * @name _
1433      * @constructor
1434      * @category Seq
1435      * @param {*} value The value to wrap in a `lodash` instance.
1436      * @returns {Object} Returns the new `lodash` wrapper instance.
1437      * @example
1438      *
1439      * function square(n) {
1440      *   return n * n;
1441      * }
1442      *
1443      * var wrapped = _([1, 2, 3]);
1444      *
1445      * // Returns an unwrapped value.
1446      * wrapped.reduce(_.add);
1447      * // => 6
1448      *
1449      * // Returns a wrapped value.
1450      * var squares = wrapped.map(square);
1451      *
1452      * _.isArray(squares);
1453      * // => false
1454      *
1455      * _.isArray(squares.value());
1456      * // => true
1457      */
1458     function lodash(value) {
1459       if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1460         if (value instanceof LodashWrapper) {
1461           return value;
1462         }
1463         if (hasOwnProperty.call(value, '__wrapped__')) {
1464           return wrapperClone(value);
1465         }
1466       }
1467       return new LodashWrapper(value);
1468     }
1469
1470     /**
1471      * The function whose prototype chain sequence wrappers inherit from.
1472      *
1473      * @private
1474      */
1475     function baseLodash() {
1476       // No operation performed.
1477     }
1478
1479     /**
1480      * The base constructor for creating `lodash` wrapper objects.
1481      *
1482      * @private
1483      * @param {*} value The value to wrap.
1484      * @param {boolean} [chainAll] Enable explicit method chain sequences.
1485      */
1486     function LodashWrapper(value, chainAll) {
1487       this.__wrapped__ = value;
1488       this.__actions__ = [];
1489       this.__chain__ = !!chainAll;
1490       this.__index__ = 0;
1491       this.__values__ = undefined;
1492     }
1493
1494     /**
1495      * By default, the template delimiters used by lodash are like those in
1496      * embedded Ruby (ERB). Change the following template settings to use
1497      * alternative delimiters.
1498      *
1499      * @static
1500      * @memberOf _
1501      * @type {Object}
1502      */
1503     lodash.templateSettings = {
1504
1505       /**
1506        * Used to detect `data` property values to be HTML-escaped.
1507        *
1508        * @memberOf _.templateSettings
1509        * @type {RegExp}
1510        */
1511       'escape': reEscape,
1512
1513       /**
1514        * Used to detect code to be evaluated.
1515        *
1516        * @memberOf _.templateSettings
1517        * @type {RegExp}
1518        */
1519       'evaluate': reEvaluate,
1520
1521       /**
1522        * Used to detect `data` property values to inject.
1523        *
1524        * @memberOf _.templateSettings
1525        * @type {RegExp}
1526        */
1527       'interpolate': reInterpolate,
1528
1529       /**
1530        * Used to reference the data object in the template text.
1531        *
1532        * @memberOf _.templateSettings
1533        * @type {string}
1534        */
1535       'variable': '',
1536
1537       /**
1538        * Used to import variables into the compiled template.
1539        *
1540        * @memberOf _.templateSettings
1541        * @type {Object}
1542        */
1543       'imports': {
1544
1545         /**
1546          * A reference to the `lodash` function.
1547          *
1548          * @memberOf _.templateSettings.imports
1549          * @type {Function}
1550          */
1551         '_': lodash
1552       }
1553     };
1554
1555     // Ensure wrappers are instances of `baseLodash`.
1556     lodash.prototype = baseLodash.prototype;
1557     lodash.prototype.constructor = lodash;
1558
1559     LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1560     LodashWrapper.prototype.constructor = LodashWrapper;
1561
1562     /*------------------------------------------------------------------------*/
1563
1564     /**
1565      * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1566      *
1567      * @private
1568      * @constructor
1569      * @param {*} value The value to wrap.
1570      */
1571     function LazyWrapper(value) {
1572       this.__wrapped__ = value;
1573       this.__actions__ = [];
1574       this.__dir__ = 1;
1575       this.__filtered__ = false;
1576       this.__iteratees__ = [];
1577       this.__takeCount__ = MAX_ARRAY_LENGTH;
1578       this.__views__ = [];
1579     }
1580
1581     /**
1582      * Creates a clone of the lazy wrapper object.
1583      *
1584      * @private
1585      * @name clone
1586      * @memberOf LazyWrapper
1587      * @returns {Object} Returns the cloned `LazyWrapper` object.
1588      */
1589     function lazyClone() {
1590       var result = new LazyWrapper(this.__wrapped__);
1591       result.__actions__ = copyArray(this.__actions__);
1592       result.__dir__ = this.__dir__;
1593       result.__filtered__ = this.__filtered__;
1594       result.__iteratees__ = copyArray(this.__iteratees__);
1595       result.__takeCount__ = this.__takeCount__;
1596       result.__views__ = copyArray(this.__views__);
1597       return result;
1598     }
1599
1600     /**
1601      * Reverses the direction of lazy iteration.
1602      *
1603      * @private
1604      * @name reverse
1605      * @memberOf LazyWrapper
1606      * @returns {Object} Returns the new reversed `LazyWrapper` object.
1607      */
1608     function lazyReverse() {
1609       if (this.__filtered__) {
1610         var result = new LazyWrapper(this);
1611         result.__dir__ = -1;
1612         result.__filtered__ = true;
1613       } else {
1614         result = this.clone();
1615         result.__dir__ *= -1;
1616       }
1617       return result;
1618     }
1619
1620     /**
1621      * Extracts the unwrapped value from its lazy wrapper.
1622      *
1623      * @private
1624      * @name value
1625      * @memberOf LazyWrapper
1626      * @returns {*} Returns the unwrapped value.
1627      */
1628     function lazyValue() {
1629       var array = this.__wrapped__.value(),
1630           dir = this.__dir__,
1631           isArr = isArray(array),
1632           isRight = dir < 0,
1633           arrLength = isArr ? array.length : 0,
1634           view = getView(0, arrLength, this.__views__),
1635           start = view.start,
1636           end = view.end,
1637           length = end - start,
1638           index = isRight ? end : (start - 1),
1639           iteratees = this.__iteratees__,
1640           iterLength = iteratees.length,
1641           resIndex = 0,
1642           takeCount = nativeMin(length, this.__takeCount__);
1643
1644       if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
1645           (arrLength == length && takeCount == length)) {
1646         return baseWrapperValue(array, this.__actions__);
1647       }
1648       var result = [];
1649
1650       outer:
1651       while (length-- && resIndex < takeCount) {
1652         index += dir;
1653
1654         var iterIndex = -1,
1655             value = array[index];
1656
1657         while (++iterIndex < iterLength) {
1658           var data = iteratees[iterIndex],
1659               iteratee = data.iteratee,
1660               type = data.type,
1661               computed = iteratee(value);
1662
1663           if (type == LAZY_MAP_FLAG) {
1664             value = computed;
1665           } else if (!computed) {
1666             if (type == LAZY_FILTER_FLAG) {
1667               continue outer;
1668             } else {
1669               break outer;
1670             }
1671           }
1672         }
1673         result[resIndex++] = value;
1674       }
1675       return result;
1676     }
1677
1678     // Ensure `LazyWrapper` is an instance of `baseLodash`.
1679     LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1680     LazyWrapper.prototype.constructor = LazyWrapper;
1681
1682     /*------------------------------------------------------------------------*/
1683
1684     /**
1685      * Creates a hash object.
1686      *
1687      * @private
1688      * @constructor
1689      * @returns {Object} Returns the new hash object.
1690      */
1691     function Hash() {}
1692
1693     /**
1694      * Removes `key` and its value from the hash.
1695      *
1696      * @private
1697      * @param {Object} hash The hash to modify.
1698      * @param {string} key The key of the value to remove.
1699      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1700      */
1701     function hashDelete(hash, key) {
1702       return hashHas(hash, key) && delete hash[key];
1703     }
1704
1705     /**
1706      * Gets the hash value for `key`.
1707      *
1708      * @private
1709      * @param {Object} hash The hash to query.
1710      * @param {string} key The key of the value to get.
1711      * @returns {*} Returns the entry value.
1712      */
1713     function hashGet(hash, key) {
1714       if (nativeCreate) {
1715         var result = hash[key];
1716         return result === HASH_UNDEFINED ? undefined : result;
1717       }
1718       return hasOwnProperty.call(hash, key) ? hash[key] : undefined;
1719     }
1720
1721     /**
1722      * Checks if a hash value for `key` exists.
1723      *
1724      * @private
1725      * @param {Object} hash The hash to query.
1726      * @param {string} key The key of the entry to check.
1727      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1728      */
1729     function hashHas(hash, key) {
1730       return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, key);
1731     }
1732
1733     /**
1734      * Sets the hash `key` to `value`.
1735      *
1736      * @private
1737      * @param {Object} hash The hash to modify.
1738      * @param {string} key The key of the value to set.
1739      * @param {*} value The value to set.
1740      */
1741     function hashSet(hash, key, value) {
1742       hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1743     }
1744
1745     // Avoid inheriting from `Object.prototype` when possible.
1746     Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto;
1747
1748     /*------------------------------------------------------------------------*/
1749
1750     /**
1751      * Creates a map cache object to store key-value pairs.
1752      *
1753      * @private
1754      * @constructor
1755      * @param {Array} [values] The values to cache.
1756      */
1757     function MapCache(values) {
1758       var index = -1,
1759           length = values ? values.length : 0;
1760
1761       this.clear();
1762       while (++index < length) {
1763         var entry = values[index];
1764         this.set(entry[0], entry[1]);
1765       }
1766     }
1767
1768     /**
1769      * Removes all key-value entries from the map.
1770      *
1771      * @private
1772      * @name clear
1773      * @memberOf MapCache
1774      */
1775     function mapClear() {
1776       this.__data__ = {
1777         'hash': new Hash,
1778         'map': Map ? new Map : [],
1779         'string': new Hash
1780       };
1781     }
1782
1783     /**
1784      * Removes `key` and its value from the map.
1785      *
1786      * @private
1787      * @name delete
1788      * @memberOf MapCache
1789      * @param {string} key The key of the value to remove.
1790      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1791      */
1792     function mapDelete(key) {
1793       var data = this.__data__;
1794       if (isKeyable(key)) {
1795         return hashDelete(typeof key == 'string' ? data.string : data.hash, key);
1796       }
1797       return Map ? data.map['delete'](key) : assocDelete(data.map, key);
1798     }
1799
1800     /**
1801      * Gets the map value for `key`.
1802      *
1803      * @private
1804      * @name get
1805      * @memberOf MapCache
1806      * @param {string} key The key of the value to get.
1807      * @returns {*} Returns the entry value.
1808      */
1809     function mapGet(key) {
1810       var data = this.__data__;
1811       if (isKeyable(key)) {
1812         return hashGet(typeof key == 'string' ? data.string : data.hash, key);
1813       }
1814       return Map ? data.map.get(key) : assocGet(data.map, key);
1815     }
1816
1817     /**
1818      * Checks if a map value for `key` exists.
1819      *
1820      * @private
1821      * @name has
1822      * @memberOf MapCache
1823      * @param {string} key The key of the entry to check.
1824      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1825      */
1826     function mapHas(key) {
1827       var data = this.__data__;
1828       if (isKeyable(key)) {
1829         return hashHas(typeof key == 'string' ? data.string : data.hash, key);
1830       }
1831       return Map ? data.map.has(key) : assocHas(data.map, key);
1832     }
1833
1834     /**
1835      * Sets the map `key` to `value`.
1836      *
1837      * @private
1838      * @name set
1839      * @memberOf MapCache
1840      * @param {string} key The key of the value to set.
1841      * @param {*} value The value to set.
1842      * @returns {Object} Returns the map cache instance.
1843      */
1844     function mapSet(key, value) {
1845       var data = this.__data__;
1846       if (isKeyable(key)) {
1847         hashSet(typeof key == 'string' ? data.string : data.hash, key, value);
1848       } else if (Map) {
1849         data.map.set(key, value);
1850       } else {
1851         assocSet(data.map, key, value);
1852       }
1853       return this;
1854     }
1855
1856     // Add methods to `MapCache`.
1857     MapCache.prototype.clear = mapClear;
1858     MapCache.prototype['delete'] = mapDelete;
1859     MapCache.prototype.get = mapGet;
1860     MapCache.prototype.has = mapHas;
1861     MapCache.prototype.set = mapSet;
1862
1863     /*------------------------------------------------------------------------*/
1864
1865     /**
1866      *
1867      * Creates a set cache object to store unique values.
1868      *
1869      * @private
1870      * @constructor
1871      * @param {Array} [values] The values to cache.
1872      */
1873     function SetCache(values) {
1874       var index = -1,
1875           length = values ? values.length : 0;
1876
1877       this.__data__ = new MapCache;
1878       while (++index < length) {
1879         this.push(values[index]);
1880       }
1881     }
1882
1883     /**
1884      * Checks if `value` is in `cache`.
1885      *
1886      * @private
1887      * @param {Object} cache The set cache to search.
1888      * @param {*} value The value to search for.
1889      * @returns {number} Returns `true` if `value` is found, else `false`.
1890      */
1891     function cacheHas(cache, value) {
1892       var map = cache.__data__;
1893       if (isKeyable(value)) {
1894         var data = map.__data__,
1895             hash = typeof value == 'string' ? data.string : data.hash;
1896
1897         return hash[value] === HASH_UNDEFINED;
1898       }
1899       return map.has(value);
1900     }
1901
1902     /**
1903      * Adds `value` to the set cache.
1904      *
1905      * @private
1906      * @name push
1907      * @memberOf SetCache
1908      * @param {*} value The value to cache.
1909      */
1910     function cachePush(value) {
1911       var map = this.__data__;
1912       if (isKeyable(value)) {
1913         var data = map.__data__,
1914             hash = typeof value == 'string' ? data.string : data.hash;
1915
1916         hash[value] = HASH_UNDEFINED;
1917       }
1918       else {
1919         map.set(value, HASH_UNDEFINED);
1920       }
1921     }
1922
1923     // Add methods to `SetCache`.
1924     SetCache.prototype.push = cachePush;
1925
1926     /*------------------------------------------------------------------------*/
1927
1928     /**
1929      * Creates a stack cache object to store key-value pairs.
1930      *
1931      * @private
1932      * @constructor
1933      * @param {Array} [values] The values to cache.
1934      */
1935     function Stack(values) {
1936       var index = -1,
1937           length = values ? values.length : 0;
1938
1939       this.clear();
1940       while (++index < length) {
1941         var entry = values[index];
1942         this.set(entry[0], entry[1]);
1943       }
1944     }
1945
1946     /**
1947      * Removes all key-value entries from the stack.
1948      *
1949      * @private
1950      * @name clear
1951      * @memberOf Stack
1952      */
1953     function stackClear() {
1954       this.__data__ = { 'array': [], 'map': null };
1955     }
1956
1957     /**
1958      * Removes `key` and its value from the stack.
1959      *
1960      * @private
1961      * @name delete
1962      * @memberOf Stack
1963      * @param {string} key The key of the value to remove.
1964      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1965      */
1966     function stackDelete(key) {
1967       var data = this.__data__,
1968           array = data.array;
1969
1970       return array ? assocDelete(array, key) : data.map['delete'](key);
1971     }
1972
1973     /**
1974      * Gets the stack value for `key`.
1975      *
1976      * @private
1977      * @name get
1978      * @memberOf Stack
1979      * @param {string} key The key of the value to get.
1980      * @returns {*} Returns the entry value.
1981      */
1982     function stackGet(key) {
1983       var data = this.__data__,
1984           array = data.array;
1985
1986       return array ? assocGet(array, key) : data.map.get(key);
1987     }
1988
1989     /**
1990      * Checks if a stack value for `key` exists.
1991      *
1992      * @private
1993      * @name has
1994      * @memberOf Stack
1995      * @param {string} key The key of the entry to check.
1996      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1997      */
1998     function stackHas(key) {
1999       var data = this.__data__,
2000           array = data.array;
2001
2002       return array ? assocHas(array, key) : data.map.has(key);
2003     }
2004
2005     /**
2006      * Sets the stack `key` to `value`.
2007      *
2008      * @private
2009      * @name set
2010      * @memberOf Stack
2011      * @param {string} key The key of the value to set.
2012      * @param {*} value The value to set.
2013      * @returns {Object} Returns the stack cache instance.
2014      */
2015     function stackSet(key, value) {
2016       var data = this.__data__,
2017           array = data.array;
2018
2019       if (array) {
2020         if (array.length < (LARGE_ARRAY_SIZE - 1)) {
2021           assocSet(array, key, value);
2022         } else {
2023           data.array = null;
2024           data.map = new MapCache(array);
2025         }
2026       }
2027       var map = data.map;
2028       if (map) {
2029         map.set(key, value);
2030       }
2031       return this;
2032     }
2033
2034     // Add methods to `Stack`.
2035     Stack.prototype.clear = stackClear;
2036     Stack.prototype['delete'] = stackDelete;
2037     Stack.prototype.get = stackGet;
2038     Stack.prototype.has = stackHas;
2039     Stack.prototype.set = stackSet;
2040
2041     /*------------------------------------------------------------------------*/
2042
2043     /**
2044      * Removes `key` and its value from the associative array.
2045      *
2046      * @private
2047      * @param {Array} array The array to modify.
2048      * @param {string} key The key of the value to remove.
2049      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2050      */
2051     function assocDelete(array, key) {
2052       var index = assocIndexOf(array, key);
2053       if (index < 0) {
2054         return false;
2055       }
2056       var lastIndex = array.length - 1;
2057       if (index == lastIndex) {
2058         array.pop();
2059       } else {
2060         splice.call(array, index, 1);
2061       }
2062       return true;
2063     }
2064
2065     /**
2066      * Gets the associative array value for `key`.
2067      *
2068      * @private
2069      * @param {Array} array The array to query.
2070      * @param {string} key The key of the value to get.
2071      * @returns {*} Returns the entry value.
2072      */
2073     function assocGet(array, key) {
2074       var index = assocIndexOf(array, key);
2075       return index < 0 ? undefined : array[index][1];
2076     }
2077
2078     /**
2079      * Checks if an associative array value for `key` exists.
2080      *
2081      * @private
2082      * @param {Array} array The array to query.
2083      * @param {string} key The key of the entry to check.
2084      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2085      */
2086     function assocHas(array, key) {
2087       return assocIndexOf(array, key) > -1;
2088     }
2089
2090     /**
2091      * Gets the index at which the `key` is found in `array` of key-value pairs.
2092      *
2093      * @private
2094      * @param {Array} array The array to search.
2095      * @param {*} key The key to search for.
2096      * @returns {number} Returns the index of the matched value, else `-1`.
2097      */
2098     function assocIndexOf(array, key) {
2099       var length = array.length;
2100       while (length--) {
2101         if (eq(array[length][0], key)) {
2102           return length;
2103         }
2104       }
2105       return -1;
2106     }
2107
2108     /**
2109      * Sets the associative array `key` to `value`.
2110      *
2111      * @private
2112      * @param {Array} array The array to modify.
2113      * @param {string} key The key of the value to set.
2114      * @param {*} value The value to set.
2115      */
2116     function assocSet(array, key, value) {
2117       var index = assocIndexOf(array, key);
2118       if (index < 0) {
2119         array.push([key, value]);
2120       } else {
2121         array[index][1] = value;
2122       }
2123     }
2124
2125     /*------------------------------------------------------------------------*/
2126
2127     /**
2128      * Used by `_.defaults` to customize its `_.assignIn` use.
2129      *
2130      * @private
2131      * @param {*} objValue The destination value.
2132      * @param {*} srcValue The source value.
2133      * @param {string} key The key of the property to assign.
2134      * @param {Object} object The parent object of `objValue`.
2135      * @returns {*} Returns the value to assign.
2136      */
2137     function assignInDefaults(objValue, srcValue, key, object) {
2138       if (objValue === undefined ||
2139           (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
2140         return srcValue;
2141       }
2142       return objValue;
2143     }
2144
2145     /**
2146      * This function is like `assignValue` except that it doesn't assign
2147      * `undefined` values.
2148      *
2149      * @private
2150      * @param {Object} object The object to modify.
2151      * @param {string} key The key of the property to assign.
2152      * @param {*} value The value to assign.
2153      */
2154     function assignMergeValue(object, key, value) {
2155       if ((value !== undefined && !eq(object[key], value)) ||
2156           (typeof key == 'number' && value === undefined && !(key in object))) {
2157         object[key] = value;
2158       }
2159     }
2160
2161     /**
2162      * Assigns `value` to `key` of `object` if the existing value is not equivalent
2163      * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
2164      * for equality comparisons.
2165      *
2166      * @private
2167      * @param {Object} object The object to modify.
2168      * @param {string} key The key of the property to assign.
2169      * @param {*} value The value to assign.
2170      */
2171     function assignValue(object, key, value) {
2172       var objValue = object[key];
2173       if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2174           (value === undefined && !(key in object))) {
2175         object[key] = value;
2176       }
2177     }
2178
2179     /**
2180      * Aggregates elements of `collection` on `accumulator` with keys transformed
2181      * by `iteratee` and values set by `setter`.
2182      *
2183      * @private
2184      * @param {Array|Object} collection The collection to iterate over.
2185      * @param {Function} setter The function to set `accumulator` values.
2186      * @param {Function} iteratee The iteratee to transform keys.
2187      * @param {Object} accumulator The initial aggregated object.
2188      * @returns {Function} Returns `accumulator`.
2189      */
2190     function baseAggregator(collection, setter, iteratee, accumulator) {
2191       baseEach(collection, function(value, key, collection) {
2192         setter(accumulator, value, iteratee(value), collection);
2193       });
2194       return accumulator;
2195     }
2196
2197     /**
2198      * The base implementation of `_.assign` without support for multiple sources
2199      * or `customizer` functions.
2200      *
2201      * @private
2202      * @param {Object} object The destination object.
2203      * @param {Object} source The source object.
2204      * @returns {Object} Returns `object`.
2205      */
2206     function baseAssign(object, source) {
2207       return object && copyObject(source, keys(source), object);
2208     }
2209
2210     /**
2211      * The base implementation of `_.at` without support for individual paths.
2212      *
2213      * @private
2214      * @param {Object} object The object to iterate over.
2215      * @param {string[]} paths The property paths of elements to pick.
2216      * @returns {Array} Returns the new array of picked elements.
2217      */
2218     function baseAt(object, paths) {
2219       var index = -1,
2220           isNil = object == null,
2221           length = paths.length,
2222           result = Array(length);
2223
2224       while (++index < length) {
2225         result[index] = isNil ? undefined : get(object, paths[index]);
2226       }
2227       return result;
2228     }
2229
2230     /**
2231      * The base implementation of `_.clamp` which doesn't coerce arguments to numbers.
2232      *
2233      * @private
2234      * @param {number} number The number to clamp.
2235      * @param {number} [lower] The lower bound.
2236      * @param {number} upper The upper bound.
2237      * @returns {number} Returns the clamped number.
2238      */
2239     function baseClamp(number, lower, upper) {
2240       if (number === number) {
2241         if (upper !== undefined) {
2242           number = number <= upper ? number : upper;
2243         }
2244         if (lower !== undefined) {
2245           number = number >= lower ? number : lower;
2246         }
2247       }
2248       return number;
2249     }
2250
2251     /**
2252      * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2253      * traversed objects.
2254      *
2255      * @private
2256      * @param {*} value The value to clone.
2257      * @param {boolean} [isDeep] Specify a deep clone.
2258      * @param {boolean} [isFull] Specify a clone including symbols.
2259      * @param {Function} [customizer] The function to customize cloning.
2260      * @param {string} [key] The key of `value`.
2261      * @param {Object} [object] The parent object of `value`.
2262      * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2263      * @returns {*} Returns the cloned value.
2264      */
2265     function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
2266       var result;
2267       if (customizer) {
2268         result = object ? customizer(value, key, object, stack) : customizer(value);
2269       }
2270       if (result !== undefined) {
2271         return result;
2272       }
2273       if (!isObject(value)) {
2274         return value;
2275       }
2276       var isArr = isArray(value);
2277       if (isArr) {
2278         result = initCloneArray(value);
2279         if (!isDeep) {
2280           return copyArray(value, result);
2281         }
2282       } else {
2283         var tag = getTag(value),
2284             isFunc = tag == funcTag || tag == genTag;
2285
2286         if (isBuffer(value)) {
2287           return cloneBuffer(value, isDeep);
2288         }
2289         if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2290           if (isHostObject(value)) {
2291             return object ? value : {};
2292           }
2293           result = initCloneObject(isFunc ? {} : value);
2294           if (!isDeep) {
2295             return copySymbols(value, baseAssign(result, value));
2296           }
2297         } else {
2298           if (!cloneableTags[tag]) {
2299             return object ? value : {};
2300           }
2301           result = initCloneByTag(value, tag, baseClone, isDeep);
2302         }
2303       }
2304       // Check for circular references and return its corresponding clone.
2305       stack || (stack = new Stack);
2306       var stacked = stack.get(value);
2307       if (stacked) {
2308         return stacked;
2309       }
2310       stack.set(value, result);
2311
2312       if (!isArr) {
2313         var props = isFull ? getAllKeys(value) : keys(value);
2314       }
2315       // Recursively populate clone (susceptible to call stack limits).
2316       arrayEach(props || value, function(subValue, key) {
2317         if (props) {
2318           key = subValue;
2319           subValue = value[key];
2320         }
2321         assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
2322       });
2323       return result;
2324     }
2325
2326     /**
2327      * The base implementation of `_.conforms` which doesn't clone `source`.
2328      *
2329      * @private
2330      * @param {Object} source The object of property predicates to conform to.
2331      * @returns {Function} Returns the new function.
2332      */
2333     function baseConforms(source) {
2334       var props = keys(source),
2335           length = props.length;
2336
2337       return function(object) {
2338         if (object == null) {
2339           return !length;
2340         }
2341         var index = length;
2342         while (index--) {
2343           var key = props[index],
2344               predicate = source[key],
2345               value = object[key];
2346
2347           if ((value === undefined &&
2348               !(key in Object(object))) || !predicate(value)) {
2349             return false;
2350           }
2351         }
2352         return true;
2353       };
2354     }
2355
2356     /**
2357      * The base implementation of `_.create` without support for assigning
2358      * properties to the created object.
2359      *
2360      * @private
2361      * @param {Object} prototype The object to inherit from.
2362      * @returns {Object} Returns the new object.
2363      */
2364     function baseCreate(proto) {
2365       return isObject(proto) ? objectCreate(proto) : {};
2366     }
2367
2368     /**
2369      * The base implementation of `_.delay` and `_.defer` which accepts an array
2370      * of `func` arguments.
2371      *
2372      * @private
2373      * @param {Function} func The function to delay.
2374      * @param {number} wait The number of milliseconds to delay invocation.
2375      * @param {Object} args The arguments to provide to `func`.
2376      * @returns {number} Returns the timer id.
2377      */
2378     function baseDelay(func, wait, args) {
2379       if (typeof func != 'function') {
2380         throw new TypeError(FUNC_ERROR_TEXT);
2381       }
2382       return setTimeout(function() { func.apply(undefined, args); }, wait);
2383     }
2384
2385     /**
2386      * The base implementation of methods like `_.difference` without support
2387      * for excluding multiple arrays or iteratee shorthands.
2388      *
2389      * @private
2390      * @param {Array} array The array to inspect.
2391      * @param {Array} values The values to exclude.
2392      * @param {Function} [iteratee] The iteratee invoked per element.
2393      * @param {Function} [comparator] The comparator invoked per element.
2394      * @returns {Array} Returns the new array of filtered values.
2395      */
2396     function baseDifference(array, values, iteratee, comparator) {
2397       var index = -1,
2398           includes = arrayIncludes,
2399           isCommon = true,
2400           length = array.length,
2401           result = [],
2402           valuesLength = values.length;
2403
2404       if (!length) {
2405         return result;
2406       }
2407       if (iteratee) {
2408         values = arrayMap(values, baseUnary(iteratee));
2409       }
2410       if (comparator) {
2411         includes = arrayIncludesWith;
2412         isCommon = false;
2413       }
2414       else if (values.length >= LARGE_ARRAY_SIZE) {
2415         includes = cacheHas;
2416         isCommon = false;
2417         values = new SetCache(values);
2418       }
2419       outer:
2420       while (++index < length) {
2421         var value = array[index],
2422             computed = iteratee ? iteratee(value) : value;
2423
2424         value = (comparator || value !== 0) ? value : 0;
2425         if (isCommon && computed === computed) {
2426           var valuesIndex = valuesLength;
2427           while (valuesIndex--) {
2428             if (values[valuesIndex] === computed) {
2429               continue outer;
2430             }
2431           }
2432           result.push(value);
2433         }
2434         else if (!includes(values, computed, comparator)) {
2435           result.push(value);
2436         }
2437       }
2438       return result;
2439     }
2440
2441     /**
2442      * The base implementation of `_.forEach` without support for iteratee shorthands.
2443      *
2444      * @private
2445      * @param {Array|Object} collection The collection to iterate over.
2446      * @param {Function} iteratee The function invoked per iteration.
2447      * @returns {Array|Object} Returns `collection`.
2448      */
2449     var baseEach = createBaseEach(baseForOwn);
2450
2451     /**
2452      * The base implementation of `_.forEachRight` without support for iteratee shorthands.
2453      *
2454      * @private
2455      * @param {Array|Object} collection The collection to iterate over.
2456      * @param {Function} iteratee The function invoked per iteration.
2457      * @returns {Array|Object} Returns `collection`.
2458      */
2459     var baseEachRight = createBaseEach(baseForOwnRight, true);
2460
2461     /**
2462      * The base implementation of `_.every` without support for iteratee shorthands.
2463      *
2464      * @private
2465      * @param {Array|Object} collection The collection to iterate over.
2466      * @param {Function} predicate The function invoked per iteration.
2467      * @returns {boolean} Returns `true` if all elements pass the predicate check,
2468      *  else `false`
2469      */
2470     function baseEvery(collection, predicate) {
2471       var result = true;
2472       baseEach(collection, function(value, index, collection) {
2473         result = !!predicate(value, index, collection);
2474         return result;
2475       });
2476       return result;
2477     }
2478
2479     /**
2480      * The base implementation of methods like `_.max` and `_.min` which accepts a
2481      * `comparator` to determine the extremum value.
2482      *
2483      * @private
2484      * @param {Array} array The array to iterate over.
2485      * @param {Function} iteratee The iteratee invoked per iteration.
2486      * @param {Function} comparator The comparator used to compare values.
2487      * @returns {*} Returns the extremum value.
2488      */
2489     function baseExtremum(array, iteratee, comparator) {
2490       var index = -1,
2491           length = array.length;
2492
2493       while (++index < length) {
2494         var value = array[index],
2495             current = iteratee(value);
2496
2497         if (current != null && (computed === undefined
2498               ? (current === current && !isSymbol(current))
2499               : comparator(current, computed)
2500             )) {
2501           var computed = current,
2502               result = value;
2503         }
2504       }
2505       return result;
2506     }
2507
2508     /**
2509      * The base implementation of `_.fill` without an iteratee call guard.
2510      *
2511      * @private
2512      * @param {Array} array The array to fill.
2513      * @param {*} value The value to fill `array` with.
2514      * @param {number} [start=0] The start position.
2515      * @param {number} [end=array.length] The end position.
2516      * @returns {Array} Returns `array`.
2517      */
2518     function baseFill(array, value, start, end) {
2519       var length = array.length;
2520
2521       start = toInteger(start);
2522       if (start < 0) {
2523         start = -start > length ? 0 : (length + start);
2524       }
2525       end = (end === undefined || end > length) ? length : toInteger(end);
2526       if (end < 0) {
2527         end += length;
2528       }
2529       end = start > end ? 0 : toLength(end);
2530       while (start < end) {
2531         array[start++] = value;
2532       }
2533       return array;
2534     }
2535
2536     /**
2537      * The base implementation of `_.filter` without support for iteratee shorthands.
2538      *
2539      * @private
2540      * @param {Array|Object} collection The collection to iterate over.
2541      * @param {Function} predicate The function invoked per iteration.
2542      * @returns {Array} Returns the new filtered array.
2543      */
2544     function baseFilter(collection, predicate) {
2545       var result = [];
2546       baseEach(collection, function(value, index, collection) {
2547         if (predicate(value, index, collection)) {
2548           result.push(value);
2549         }
2550       });
2551       return result;
2552     }
2553
2554     /**
2555      * The base implementation of `_.flatten` with support for restricting flattening.
2556      *
2557      * @private
2558      * @param {Array} array The array to flatten.
2559      * @param {number} depth The maximum recursion depth.
2560      * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
2561      * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
2562      * @param {Array} [result=[]] The initial result value.
2563      * @returns {Array} Returns the new flattened array.
2564      */
2565     function baseFlatten(array, depth, predicate, isStrict, result) {
2566       var index = -1,
2567           length = array.length;
2568
2569       predicate || (predicate = isFlattenable);
2570       result || (result = []);
2571
2572       while (++index < length) {
2573         var value = array[index];
2574         if (depth > 0 && predicate(value)) {
2575           if (depth > 1) {
2576             // Recursively flatten arrays (susceptible to call stack limits).
2577             baseFlatten(value, depth - 1, predicate, isStrict, result);
2578           } else {
2579             arrayPush(result, value);
2580           }
2581         } else if (!isStrict) {
2582           result[result.length] = value;
2583         }
2584       }
2585       return result;
2586     }
2587
2588     /**
2589      * The base implementation of `baseForOwn` which iterates over `object`
2590      * properties returned by `keysFunc` and invokes `iteratee` for each property.
2591      * Iteratee functions may exit iteration early by explicitly returning `false`.
2592      *
2593      * @private
2594      * @param {Object} object The object to iterate over.
2595      * @param {Function} iteratee The function invoked per iteration.
2596      * @param {Function} keysFunc The function to get the keys of `object`.
2597      * @returns {Object} Returns `object`.
2598      */
2599     var baseFor = createBaseFor();
2600
2601     /**
2602      * This function is like `baseFor` except that it iterates over properties
2603      * in the opposite order.
2604      *
2605      * @private
2606      * @param {Object} object The object to iterate over.
2607      * @param {Function} iteratee The function invoked per iteration.
2608      * @param {Function} keysFunc The function to get the keys of `object`.
2609      * @returns {Object} Returns `object`.
2610      */
2611     var baseForRight = createBaseFor(true);
2612
2613     /**
2614      * The base implementation of `_.forOwn` without support for iteratee shorthands.
2615      *
2616      * @private
2617      * @param {Object} object The object to iterate over.
2618      * @param {Function} iteratee The function invoked per iteration.
2619      * @returns {Object} Returns `object`.
2620      */
2621     function baseForOwn(object, iteratee) {
2622       return object && baseFor(object, iteratee, keys);
2623     }
2624
2625     /**
2626      * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
2627      *
2628      * @private
2629      * @param {Object} object The object to iterate over.
2630      * @param {Function} iteratee The function invoked per iteration.
2631      * @returns {Object} Returns `object`.
2632      */
2633     function baseForOwnRight(object, iteratee) {
2634       return object && baseForRight(object, iteratee, keys);
2635     }
2636
2637     /**
2638      * The base implementation of `_.functions` which creates an array of
2639      * `object` function property names filtered from `props`.
2640      *
2641      * @private
2642      * @param {Object} object The object to inspect.
2643      * @param {Array} props The property names to filter.
2644      * @returns {Array} Returns the new array of filtered property names.
2645      */
2646     function baseFunctions(object, props) {
2647       return arrayFilter(props, function(key) {
2648         return isFunction(object[key]);
2649       });
2650     }
2651
2652     /**
2653      * The base implementation of `_.get` without support for default values.
2654      *
2655      * @private
2656      * @param {Object} object The object to query.
2657      * @param {Array|string} path The path of the property to get.
2658      * @returns {*} Returns the resolved value.
2659      */
2660     function baseGet(object, path) {
2661       path = isKey(path, object) ? [path] : castPath(path);
2662
2663       var index = 0,
2664           length = path.length;
2665
2666       while (object != null && index < length) {
2667         object = object[toKey(path[index++])];
2668       }
2669       return (index && index == length) ? object : undefined;
2670     }
2671
2672     /**
2673      * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
2674      * `keysFunc` and `symbolsFunc` to get the enumerable property names and
2675      * symbols of `object`.
2676      *
2677      * @private
2678      * @param {Object} object The object to query.
2679      * @param {Function} keysFunc The function to get the keys of `object`.
2680      * @param {Function} symbolsFunc The function to get the symbols of `object`.
2681      * @returns {Array} Returns the array of property names and symbols.
2682      */
2683     function baseGetAllKeys(object, keysFunc, symbolsFunc) {
2684       var result = keysFunc(object);
2685       return isArray(object)
2686         ? result
2687         : arrayPush(result, symbolsFunc(object));
2688     }
2689
2690     /**
2691      * The base implementation of `_.gt` which doesn't coerce arguments to numbers.
2692      *
2693      * @private
2694      * @param {*} value The value to compare.
2695      * @param {*} other The other value to compare.
2696      * @returns {boolean} Returns `true` if `value` is greater than `other`,
2697      *  else `false`.
2698      */
2699     function baseGt(value, other) {
2700       return value > other;
2701     }
2702
2703     /**
2704      * The base implementation of `_.has` without support for deep paths.
2705      *
2706      * @private
2707      * @param {Object} object The object to query.
2708      * @param {Array|string} key The key to check.
2709      * @returns {boolean} Returns `true` if `key` exists, else `false`.
2710      */
2711     function baseHas(object, key) {
2712       // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
2713       // that are composed entirely of index properties, return `false` for
2714       // `hasOwnProperty` checks of them.
2715       return hasOwnProperty.call(object, key) ||
2716         (typeof object == 'object' && key in object && getPrototype(object) === null);
2717     }
2718
2719     /**
2720      * The base implementation of `_.hasIn` without support for deep paths.
2721      *
2722      * @private
2723      * @param {Object} object The object to query.
2724      * @param {Array|string} key The key to check.
2725      * @returns {boolean} Returns `true` if `key` exists, else `false`.
2726      */
2727     function baseHasIn(object, key) {
2728       return key in Object(object);
2729     }
2730
2731     /**
2732      * The base implementation of `_.inRange` which doesn't coerce arguments to numbers.
2733      *
2734      * @private
2735      * @param {number} number The number to check.
2736      * @param {number} start The start of the range.
2737      * @param {number} end The end of the range.
2738      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
2739      */
2740     function baseInRange(number, start, end) {
2741       return number >= nativeMin(start, end) && number < nativeMax(start, end);
2742     }
2743
2744     /**
2745      * The base implementation of methods like `_.intersection`, without support
2746      * for iteratee shorthands, that accepts an array of arrays to inspect.
2747      *
2748      * @private
2749      * @param {Array} arrays The arrays to inspect.
2750      * @param {Function} [iteratee] The iteratee invoked per element.
2751      * @param {Function} [comparator] The comparator invoked per element.
2752      * @returns {Array} Returns the new array of shared values.
2753      */
2754     function baseIntersection(arrays, iteratee, comparator) {
2755       var includes = comparator ? arrayIncludesWith : arrayIncludes,
2756           length = arrays[0].length,
2757           othLength = arrays.length,
2758           othIndex = othLength,
2759           caches = Array(othLength),
2760           maxLength = Infinity,
2761           result = [];
2762
2763       while (othIndex--) {
2764         var array = arrays[othIndex];
2765         if (othIndex && iteratee) {
2766           array = arrayMap(array, baseUnary(iteratee));
2767         }
2768         maxLength = nativeMin(array.length, maxLength);
2769         caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
2770           ? new SetCache(othIndex && array)
2771           : undefined;
2772       }
2773       array = arrays[0];
2774
2775       var index = -1,
2776           seen = caches[0];
2777
2778       outer:
2779       while (++index < length && result.length < maxLength) {
2780         var value = array[index],
2781             computed = iteratee ? iteratee(value) : value;
2782
2783         value = (comparator || value !== 0) ? value : 0;
2784         if (!(seen
2785               ? cacheHas(seen, computed)
2786               : includes(result, computed, comparator)
2787             )) {
2788           othIndex = othLength;
2789           while (--othIndex) {
2790             var cache = caches[othIndex];
2791             if (!(cache
2792                   ? cacheHas(cache, computed)
2793                   : includes(arrays[othIndex], computed, comparator))
2794                 ) {
2795               continue outer;
2796             }
2797           }
2798           if (seen) {
2799             seen.push(computed);
2800           }
2801           result.push(value);
2802         }
2803       }
2804       return result;
2805     }
2806
2807     /**
2808      * The base implementation of `_.invert` and `_.invertBy` which inverts
2809      * `object` with values transformed by `iteratee` and set by `setter`.
2810      *
2811      * @private
2812      * @param {Object} object The object to iterate over.
2813      * @param {Function} setter The function to set `accumulator` values.
2814      * @param {Function} iteratee The iteratee to transform values.
2815      * @param {Object} accumulator The initial inverted object.
2816      * @returns {Function} Returns `accumulator`.
2817      */
2818     function baseInverter(object, setter, iteratee, accumulator) {
2819       baseForOwn(object, function(value, key, object) {
2820         setter(accumulator, iteratee(value), key, object);
2821       });
2822       return accumulator;
2823     }
2824
2825     /**
2826      * The base implementation of `_.invoke` without support for individual
2827      * method arguments.
2828      *
2829      * @private
2830      * @param {Object} object The object to query.
2831      * @param {Array|string} path The path of the method to invoke.
2832      * @param {Array} args The arguments to invoke the method with.
2833      * @returns {*} Returns the result of the invoked method.
2834      */
2835     function baseInvoke(object, path, args) {
2836       if (!isKey(path, object)) {
2837         path = castPath(path);
2838         object = parent(object, path);
2839         path = last(path);
2840       }
2841       var func = object == null ? object : object[toKey(path)];
2842       return func == null ? undefined : apply(func, object, args);
2843     }
2844
2845     /**
2846      * The base implementation of `_.isEqual` which supports partial comparisons
2847      * and tracks traversed objects.
2848      *
2849      * @private
2850      * @param {*} value The value to compare.
2851      * @param {*} other The other value to compare.
2852      * @param {Function} [customizer] The function to customize comparisons.
2853      * @param {boolean} [bitmask] The bitmask of comparison flags.
2854      *  The bitmask may be composed of the following flags:
2855      *     1 - Unordered comparison
2856      *     2 - Partial comparison
2857      * @param {Object} [stack] Tracks traversed `value` and `other` objects.
2858      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2859      */
2860     function baseIsEqual(value, other, customizer, bitmask, stack) {
2861       if (value === other) {
2862         return true;
2863       }
2864       if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
2865         return value !== value && other !== other;
2866       }
2867       return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
2868     }
2869
2870     /**
2871      * A specialized version of `baseIsEqual` for arrays and objects which performs
2872      * deep comparisons and tracks traversed objects enabling objects with circular
2873      * references to be compared.
2874      *
2875      * @private
2876      * @param {Object} object The object to compare.
2877      * @param {Object} other The other object to compare.
2878      * @param {Function} equalFunc The function to determine equivalents of values.
2879      * @param {Function} [customizer] The function to customize comparisons.
2880      * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
2881      *  for more details.
2882      * @param {Object} [stack] Tracks traversed `object` and `other` objects.
2883      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2884      */
2885     function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
2886       var objIsArr = isArray(object),
2887           othIsArr = isArray(other),
2888           objTag = arrayTag,
2889           othTag = arrayTag;
2890
2891       if (!objIsArr) {
2892         objTag = getTag(object);
2893         objTag = objTag == argsTag ? objectTag : objTag;
2894       }
2895       if (!othIsArr) {
2896         othTag = getTag(other);
2897         othTag = othTag == argsTag ? objectTag : othTag;
2898       }
2899       var objIsObj = objTag == objectTag && !isHostObject(object),
2900           othIsObj = othTag == objectTag && !isHostObject(other),
2901           isSameTag = objTag == othTag;
2902
2903       if (isSameTag && !objIsObj) {
2904         stack || (stack = new Stack);
2905         return (objIsArr || isTypedArray(object))
2906           ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
2907           : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
2908       }
2909       if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
2910         var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
2911             othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
2912
2913         if (objIsWrapped || othIsWrapped) {
2914           var objUnwrapped = objIsWrapped ? object.value() : object,
2915               othUnwrapped = othIsWrapped ? other.value() : other;
2916
2917           stack || (stack = new Stack);
2918           return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
2919         }
2920       }
2921       if (!isSameTag) {
2922         return false;
2923       }
2924       stack || (stack = new Stack);
2925       return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
2926     }
2927
2928     /**
2929      * The base implementation of `_.isMatch` without support for iteratee shorthands.
2930      *
2931      * @private
2932      * @param {Object} object The object to inspect.
2933      * @param {Object} source The object of property values to match.
2934      * @param {Array} matchData The property names, values, and compare flags to match.
2935      * @param {Function} [customizer] The function to customize comparisons.
2936      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
2937      */
2938     function baseIsMatch(object, source, matchData, customizer) {
2939       var index = matchData.length,
2940           length = index,
2941           noCustomizer = !customizer;
2942
2943       if (object == null) {
2944         return !length;
2945       }
2946       object = Object(object);
2947       while (index--) {
2948         var data = matchData[index];
2949         if ((noCustomizer && data[2])
2950               ? data[1] !== object[data[0]]
2951               : !(data[0] in object)
2952             ) {
2953           return false;
2954         }
2955       }
2956       while (++index < length) {
2957         data = matchData[index];
2958         var key = data[0],
2959             objValue = object[key],
2960             srcValue = data[1];
2961
2962         if (noCustomizer && data[2]) {
2963           if (objValue === undefined && !(key in object)) {
2964             return false;
2965           }
2966         } else {
2967           var stack = new Stack;
2968           if (customizer) {
2969             var result = customizer(objValue, srcValue, key, object, source, stack);
2970           }
2971           if (!(result === undefined
2972                 ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
2973                 : result
2974               )) {
2975             return false;
2976           }
2977         }
2978       }
2979       return true;
2980     }
2981
2982     /**
2983      * The base implementation of `_.iteratee`.
2984      *
2985      * @private
2986      * @param {*} [value=_.identity] The value to convert to an iteratee.
2987      * @returns {Function} Returns the iteratee.
2988      */
2989     function baseIteratee(value) {
2990       // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
2991       // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
2992       if (typeof value == 'function') {
2993         return value;
2994       }
2995       if (value == null) {
2996         return identity;
2997       }
2998       if (typeof value == 'object') {
2999         return isArray(value)
3000           ? baseMatchesProperty(value[0], value[1])
3001           : baseMatches(value);
3002       }
3003       return property(value);
3004     }
3005
3006     /**
3007      * The base implementation of `_.keys` which doesn't skip the constructor
3008      * property of prototypes or treat sparse arrays as dense.
3009      *
3010      * @private
3011      * @param {Object} object The object to query.
3012      * @returns {Array} Returns the array of property names.
3013      */
3014     function baseKeys(object) {
3015       return nativeKeys(Object(object));
3016     }
3017
3018     /**
3019      * The base implementation of `_.keysIn` which doesn't skip the constructor
3020      * property of prototypes or treat sparse arrays as dense.
3021      *
3022      * @private
3023      * @param {Object} object The object to query.
3024      * @returns {Array} Returns the array of property names.
3025      */
3026     function baseKeysIn(object) {
3027       object = object == null ? object : Object(object);
3028
3029       var result = [];
3030       for (var key in object) {
3031         result.push(key);
3032       }
3033       return result;
3034     }
3035
3036     // Fallback for IE < 9 with es6-shim.
3037     if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) {
3038       baseKeysIn = function(object) {
3039         return iteratorToArray(enumerate(object));
3040       };
3041     }
3042
3043     /**
3044      * The base implementation of `_.lt` which doesn't coerce arguments to numbers.
3045      *
3046      * @private
3047      * @param {*} value The value to compare.
3048      * @param {*} other The other value to compare.
3049      * @returns {boolean} Returns `true` if `value` is less than `other`,
3050      *  else `false`.
3051      */
3052     function baseLt(value, other) {
3053       return value < other;
3054     }
3055
3056     /**
3057      * The base implementation of `_.map` without support for iteratee shorthands.
3058      *
3059      * @private
3060      * @param {Array|Object} collection The collection to iterate over.
3061      * @param {Function} iteratee The function invoked per iteration.
3062      * @returns {Array} Returns the new mapped array.
3063      */
3064     function baseMap(collection, iteratee) {
3065       var index = -1,
3066           result = isArrayLike(collection) ? Array(collection.length) : [];
3067
3068       baseEach(collection, function(value, key, collection) {
3069         result[++index] = iteratee(value, key, collection);
3070       });
3071       return result;
3072     }
3073
3074     /**
3075      * The base implementation of `_.matches` which doesn't clone `source`.
3076      *
3077      * @private
3078      * @param {Object} source The object of property values to match.
3079      * @returns {Function} Returns the new function.
3080      */
3081     function baseMatches(source) {
3082       var matchData = getMatchData(source);
3083       if (matchData.length == 1 && matchData[0][2]) {
3084         return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3085       }
3086       return function(object) {
3087         return object === source || baseIsMatch(object, source, matchData);
3088       };
3089     }
3090
3091     /**
3092      * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3093      *
3094      * @private
3095      * @param {string} path The path of the property to get.
3096      * @param {*} srcValue The value to match.
3097      * @returns {Function} Returns the new function.
3098      */
3099     function baseMatchesProperty(path, srcValue) {
3100       if (isKey(path) && isStrictComparable(srcValue)) {
3101         return matchesStrictComparable(toKey(path), srcValue);
3102       }
3103       return function(object) {
3104         var objValue = get(object, path);
3105         return (objValue === undefined && objValue === srcValue)
3106           ? hasIn(object, path)
3107           : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
3108       };
3109     }
3110
3111     /**
3112      * The base implementation of `_.merge` without support for multiple sources.
3113      *
3114      * @private
3115      * @param {Object} object The destination object.
3116      * @param {Object} source The source object.
3117      * @param {number} srcIndex The index of `source`.
3118      * @param {Function} [customizer] The function to customize merged values.
3119      * @param {Object} [stack] Tracks traversed source values and their merged
3120      *  counterparts.
3121      */
3122     function baseMerge(object, source, srcIndex, customizer, stack) {
3123       if (object === source) {
3124         return;
3125       }
3126       if (!(isArray(source) || isTypedArray(source))) {
3127         var props = keysIn(source);
3128       }
3129       arrayEach(props || source, function(srcValue, key) {
3130         if (props) {
3131           key = srcValue;
3132           srcValue = source[key];
3133         }
3134         if (isObject(srcValue)) {
3135           stack || (stack = new Stack);
3136           baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3137         }
3138         else {
3139           var newValue = customizer
3140             ? customizer(object[key], srcValue, (key + ''), object, source, stack)
3141             : undefined;
3142
3143           if (newValue === undefined) {
3144             newValue = srcValue;
3145           }
3146           assignMergeValue(object, key, newValue);
3147         }
3148       });
3149     }
3150
3151     /**
3152      * A specialized version of `baseMerge` for arrays and objects which performs
3153      * deep merges and tracks traversed objects enabling objects with circular
3154      * references to be merged.
3155      *
3156      * @private
3157      * @param {Object} object The destination object.
3158      * @param {Object} source The source object.
3159      * @param {string} key The key of the value to merge.
3160      * @param {number} srcIndex The index of `source`.
3161      * @param {Function} mergeFunc The function to merge values.
3162      * @param {Function} [customizer] The function to customize assigned values.
3163      * @param {Object} [stack] Tracks traversed source values and their merged
3164      *  counterparts.
3165      */
3166     function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3167       var objValue = object[key],
3168           srcValue = source[key],
3169           stacked = stack.get(srcValue);
3170
3171       if (stacked) {
3172         assignMergeValue(object, key, stacked);
3173         return;
3174       }
3175       var newValue = customizer
3176         ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3177         : undefined;
3178
3179       var isCommon = newValue === undefined;
3180
3181       if (isCommon) {
3182         newValue = srcValue;
3183         if (isArray(srcValue) || isTypedArray(srcValue)) {
3184           if (isArray(objValue)) {
3185             newValue = objValue;
3186           }
3187           else if (isArrayLikeObject(objValue)) {
3188             newValue = copyArray(objValue);
3189           }
3190           else {
3191             isCommon = false;
3192             newValue = baseClone(srcValue, true);
3193           }
3194         }
3195         else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3196           if (isArguments(objValue)) {
3197             newValue = toPlainObject(objValue);
3198           }
3199           else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
3200             isCommon = false;
3201             newValue = baseClone(srcValue, true);
3202           }
3203           else {
3204             newValue = objValue;
3205           }
3206         }
3207         else {
3208           isCommon = false;
3209         }
3210       }
3211       stack.set(srcValue, newValue);
3212
3213       if (isCommon) {
3214         // Recursively merge objects and arrays (susceptible to call stack limits).
3215         mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3216       }
3217       stack['delete'](srcValue);
3218       assignMergeValue(object, key, newValue);
3219     }
3220
3221     /**
3222      * The base implementation of `_.nth` which doesn't coerce `n` to an integer.
3223      *
3224      * @private
3225      * @param {Array} array The array to query.
3226      * @param {number} n The index of the element to return.
3227      * @returns {*} Returns the nth element of `array`.
3228      */
3229     function baseNth(array, n) {
3230       var length = array.length;
3231       if (!length) {
3232         return;
3233       }
3234       n += n < 0 ? length : 0;
3235       return isIndex(n, length) ? array[n] : undefined;
3236     }
3237
3238     /**
3239      * The base implementation of `_.orderBy` without param guards.
3240      *
3241      * @private
3242      * @param {Array|Object} collection The collection to iterate over.
3243      * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
3244      * @param {string[]} orders The sort orders of `iteratees`.
3245      * @returns {Array} Returns the new sorted array.
3246      */
3247     function baseOrderBy(collection, iteratees, orders) {
3248       var index = -1;
3249       iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
3250
3251       var result = baseMap(collection, function(value, key, collection) {
3252         var criteria = arrayMap(iteratees, function(iteratee) {
3253           return iteratee(value);
3254         });
3255         return { 'criteria': criteria, 'index': ++index, 'value': value };
3256       });
3257
3258       return baseSortBy(result, function(object, other) {
3259         return compareMultiple(object, other, orders);
3260       });
3261     }
3262
3263     /**
3264      * The base implementation of `_.pick` without support for individual
3265      * property identifiers.
3266      *
3267      * @private
3268      * @param {Object} object The source object.
3269      * @param {string[]} props The property identifiers to pick.
3270      * @returns {Object} Returns the new object.
3271      */
3272     function basePick(object, props) {
3273       object = Object(object);
3274       return arrayReduce(props, function(result, key) {
3275         if (key in object) {
3276           result[key] = object[key];
3277         }
3278         return result;
3279       }, {});
3280     }
3281
3282     /**
3283      * The base implementation of  `_.pickBy` without support for iteratee shorthands.
3284      *
3285      * @private
3286      * @param {Object} object The source object.
3287      * @param {Function} predicate The function invoked per property.
3288      * @returns {Object} Returns the new object.
3289      */
3290     function basePickBy(object, predicate) {
3291       var index = -1,
3292           props = getAllKeysIn(object),
3293           length = props.length,
3294           result = {};
3295
3296       while (++index < length) {
3297         var key = props[index],
3298             value = object[key];
3299
3300         if (predicate(value, key)) {
3301           result[key] = value;
3302         }
3303       }
3304       return result;
3305     }
3306
3307     /**
3308      * The base implementation of `_.property` without support for deep paths.
3309      *
3310      * @private
3311      * @param {string} key The key of the property to get.
3312      * @returns {Function} Returns the new function.
3313      */
3314     function baseProperty(key) {
3315       return function(object) {
3316         return object == null ? undefined : object[key];
3317       };
3318     }
3319
3320     /**
3321      * A specialized version of `baseProperty` which supports deep paths.
3322      *
3323      * @private
3324      * @param {Array|string} path The path of the property to get.
3325      * @returns {Function} Returns the new function.
3326      */
3327     function basePropertyDeep(path) {
3328       return function(object) {
3329         return baseGet(object, path);
3330       };
3331     }
3332
3333     /**
3334      * The base implementation of `_.pullAllBy` without support for iteratee
3335      * shorthands.
3336      *
3337      * @private
3338      * @param {Array} array The array to modify.
3339      * @param {Array} values The values to remove.
3340      * @param {Function} [iteratee] The iteratee invoked per element.
3341      * @param {Function} [comparator] The comparator invoked per element.
3342      * @returns {Array} Returns `array`.
3343      */
3344     function basePullAll(array, values, iteratee, comparator) {
3345       var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3346           index = -1,
3347           length = values.length,
3348           seen = array;
3349
3350       if (iteratee) {
3351         seen = arrayMap(array, baseUnary(iteratee));
3352       }
3353       while (++index < length) {
3354         var fromIndex = 0,
3355             value = values[index],
3356             computed = iteratee ? iteratee(value) : value;
3357
3358         while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3359           if (seen !== array) {
3360             splice.call(seen, fromIndex, 1);
3361           }
3362           splice.call(array, fromIndex, 1);
3363         }
3364       }
3365       return array;
3366     }
3367
3368     /**
3369      * The base implementation of `_.pullAt` without support for individual
3370      * indexes or capturing the removed elements.
3371      *
3372      * @private
3373      * @param {Array} array The array to modify.
3374      * @param {number[]} indexes The indexes of elements to remove.
3375      * @returns {Array} Returns `array`.
3376      */
3377     function basePullAt(array, indexes) {
3378       var length = array ? indexes.length : 0,
3379           lastIndex = length - 1;
3380
3381       while (length--) {
3382         var index = indexes[length];
3383         if (length == lastIndex || index !== previous) {
3384           var previous = index;
3385           if (isIndex(index)) {
3386             splice.call(array, index, 1);
3387           }
3388           else if (!isKey(index, array)) {
3389             var path = castPath(index),
3390                 object = parent(array, path);
3391
3392             if (object != null) {
3393               delete object[toKey(last(path))];
3394             }
3395           }
3396           else {
3397             delete array[toKey(index)];
3398           }
3399         }
3400       }
3401       return array;
3402     }
3403
3404     /**
3405      * The base implementation of `_.random` without support for returning
3406      * floating-point numbers.
3407      *
3408      * @private
3409      * @param {number} lower The lower bound.
3410      * @param {number} upper The upper bound.
3411      * @returns {number} Returns the random number.
3412      */
3413     function baseRandom(lower, upper) {
3414       return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
3415     }
3416
3417     /**
3418      * The base implementation of `_.range` and `_.rangeRight` which doesn't
3419      * coerce arguments to numbers.
3420      *
3421      * @private
3422      * @param {number} start The start of the range.
3423      * @param {number} end The end of the range.
3424      * @param {number} step The value to increment or decrement by.
3425      * @param {boolean} [fromRight] Specify iterating from right to left.
3426      * @returns {Array} Returns the new array of numbers.
3427      */
3428     function baseRange(start, end, step, fromRight) {
3429       var index = -1,
3430           length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
3431           result = Array(length);
3432
3433       while (length--) {
3434         result[fromRight ? length : ++index] = start;
3435         start += step;
3436       }
3437       return result;
3438     }
3439
3440     /**
3441      * The base implementation of `_.repeat` which doesn't coerce arguments.
3442      *
3443      * @private
3444      * @param {string} string The string to repeat.
3445      * @param {number} n The number of times to repeat the string.
3446      * @returns {string} Returns the repeated string.
3447      */
3448     function baseRepeat(string, n) {
3449       var result = '';
3450       if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
3451         return result;
3452       }
3453       // Leverage the exponentiation by squaring algorithm for a faster repeat.
3454       // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
3455       do {
3456         if (n % 2) {
3457           result += string;
3458         }
3459         n = nativeFloor(n / 2);
3460         if (n) {
3461           string += string;
3462         }
3463       } while (n);
3464
3465       return result;
3466     }
3467
3468     /**
3469      * The base implementation of `_.set`.
3470      *
3471      * @private
3472      * @param {Object} object The object to query.
3473      * @param {Array|string} path The path of the property to set.
3474      * @param {*} value The value to set.
3475      * @param {Function} [customizer] The function to customize path creation.
3476      * @returns {Object} Returns `object`.
3477      */
3478     function baseSet(object, path, value, customizer) {
3479       path = isKey(path, object) ? [path] : castPath(path);
3480
3481       var index = -1,
3482           length = path.length,
3483           lastIndex = length - 1,
3484           nested = object;
3485
3486       while (nested != null && ++index < length) {
3487         var key = toKey(path[index]);
3488         if (isObject(nested)) {
3489           var newValue = value;
3490           if (index != lastIndex) {
3491             var objValue = nested[key];
3492             newValue = customizer ? customizer(objValue, key, nested) : undefined;
3493             if (newValue === undefined) {
3494               newValue = objValue == null
3495                 ? (isIndex(path[index + 1]) ? [] : {})
3496                 : objValue;
3497             }
3498           }
3499           assignValue(nested, key, newValue);
3500         }
3501         nested = nested[key];
3502       }
3503       return object;
3504     }
3505
3506     /**
3507      * The base implementation of `setData` without support for hot loop detection.
3508      *
3509      * @private
3510      * @param {Function} func The function to associate metadata with.
3511      * @param {*} data The metadata.
3512      * @returns {Function} Returns `func`.
3513      */
3514     var baseSetData = !metaMap ? identity : function(func, data) {
3515       metaMap.set(func, data);
3516       return func;
3517     };
3518
3519     /**
3520      * The base implementation of `_.slice` without an iteratee call guard.
3521      *
3522      * @private
3523      * @param {Array} array The array to slice.
3524      * @param {number} [start=0] The start position.
3525      * @param {number} [end=array.length] The end position.
3526      * @returns {Array} Returns the slice of `array`.
3527      */
3528     function baseSlice(array, start, end) {
3529       var index = -1,
3530           length = array.length;
3531
3532       if (start < 0) {
3533         start = -start > length ? 0 : (length + start);
3534       }
3535       end = end > length ? length : end;
3536       if (end < 0) {
3537         end += length;
3538       }
3539       length = start > end ? 0 : ((end - start) >>> 0);
3540       start >>>= 0;
3541
3542       var result = Array(length);
3543       while (++index < length) {
3544         result[index] = array[index + start];
3545       }
3546       return result;
3547     }
3548
3549     /**
3550      * The base implementation of `_.some` without support for iteratee shorthands.
3551      *
3552      * @private
3553      * @param {Array|Object} collection The collection to iterate over.
3554      * @param {Function} predicate The function invoked per iteration.
3555      * @returns {boolean} Returns `true` if any element passes the predicate check,
3556      *  else `false`.
3557      */
3558     function baseSome(collection, predicate) {
3559       var result;
3560
3561       baseEach(collection, function(value, index, collection) {
3562         result = predicate(value, index, collection);
3563         return !result;
3564       });
3565       return !!result;
3566     }
3567
3568     /**
3569      * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
3570      * performs a binary search of `array` to determine the index at which `value`
3571      * should be inserted into `array` in order to maintain its sort order.
3572      *
3573      * @private
3574      * @param {Array} array The sorted array to inspect.
3575      * @param {*} value The value to evaluate.
3576      * @param {boolean} [retHighest] Specify returning the highest qualified index.
3577      * @returns {number} Returns the index at which `value` should be inserted
3578      *  into `array`.
3579      */
3580     function baseSortedIndex(array, value, retHighest) {
3581       var low = 0,
3582           high = array ? array.length : low;
3583
3584       if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
3585         while (low < high) {
3586           var mid = (low + high) >>> 1,
3587               computed = array[mid];
3588
3589           if (computed !== null && !isSymbol(computed) &&
3590               (retHighest ? (computed <= value) : (computed < value))) {
3591             low = mid + 1;
3592           } else {
3593             high = mid;
3594           }
3595         }
3596         return high;
3597       }
3598       return baseSortedIndexBy(array, value, identity, retHighest);
3599     }
3600
3601     /**
3602      * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
3603      * which invokes `iteratee` for `value` and each element of `array` to compute
3604      * their sort ranking. The iteratee is invoked with one argument; (value).
3605      *
3606      * @private
3607      * @param {Array} array The sorted array to inspect.
3608      * @param {*} value The value to evaluate.
3609      * @param {Function} iteratee The iteratee invoked per element.
3610      * @param {boolean} [retHighest] Specify returning the highest qualified index.
3611      * @returns {number} Returns the index at which `value` should be inserted
3612      *  into `array`.
3613      */
3614     function baseSortedIndexBy(array, value, iteratee, retHighest) {
3615       value = iteratee(value);
3616
3617       var low = 0,
3618           high = array ? array.length : 0,
3619           valIsNaN = value !== value,
3620           valIsNull = value === null,
3621           valIsSymbol = isSymbol(value),
3622           valIsUndefined = value === undefined;
3623
3624       while (low < high) {
3625         var mid = nativeFloor((low + high) / 2),
3626             computed = iteratee(array[mid]),
3627             othIsDefined = computed !== undefined,
3628             othIsNull = computed === null,
3629             othIsReflexive = computed === computed,
3630             othIsSymbol = isSymbol(computed);
3631
3632         if (valIsNaN) {
3633           var setLow = retHighest || othIsReflexive;
3634         } else if (valIsUndefined) {
3635           setLow = othIsReflexive && (retHighest || othIsDefined);
3636         } else if (valIsNull) {
3637           setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
3638         } else if (valIsSymbol) {
3639           setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
3640         } else if (othIsNull || othIsSymbol) {
3641           setLow = false;
3642         } else {
3643           setLow = retHighest ? (computed <= value) : (computed < value);
3644         }
3645         if (setLow) {
3646           low = mid + 1;
3647         } else {
3648           high = mid;
3649         }
3650       }
3651       return nativeMin(high, MAX_ARRAY_INDEX);
3652     }
3653
3654     /**
3655      * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
3656      * support for iteratee shorthands.
3657      *
3658      * @private
3659      * @param {Array} array The array to inspect.
3660      * @param {Function} [iteratee] The iteratee invoked per element.
3661      * @returns {Array} Returns the new duplicate free array.
3662      */
3663     function baseSortedUniq(array, iteratee) {
3664       var index = -1,
3665           length = array.length,
3666           resIndex = 0,
3667           result = [];
3668
3669       while (++index < length) {
3670         var value = array[index],
3671             computed = iteratee ? iteratee(value) : value;
3672
3673         if (!index || !eq(computed, seen)) {
3674           var seen = computed;
3675           result[resIndex++] = value === 0 ? 0 : value;
3676         }
3677       }
3678       return result;
3679     }
3680
3681     /**
3682      * The base implementation of `_.toNumber` which doesn't ensure correct
3683      * conversions of binary, hexadecimal, or octal string values.
3684      *
3685      * @private
3686      * @param {*} value The value to process.
3687      * @returns {number} Returns the number.
3688      */
3689     function baseToNumber(value) {
3690       if (typeof value == 'number') {
3691         return value;
3692       }
3693       if (isSymbol(value)) {
3694         return NAN;
3695       }
3696       return +value;
3697     }
3698
3699     /**
3700      * The base implementation of `_.toString` which doesn't convert nullish
3701      * values to empty strings.
3702      *
3703      * @private
3704      * @param {*} value The value to process.
3705      * @returns {string} Returns the string.
3706      */
3707     function baseToString(value) {
3708       // Exit early for strings to avoid a performance hit in some environments.
3709       if (typeof value == 'string') {
3710         return value;
3711       }
3712       if (isSymbol(value)) {
3713         return symbolToString ? symbolToString.call(value) : '';
3714       }
3715       var result = (value + '');
3716       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
3717     }
3718
3719     /**
3720      * The base implementation of `_.uniqBy` without support for iteratee shorthands.
3721      *
3722      * @private
3723      * @param {Array} array The array to inspect.
3724      * @param {Function} [iteratee] The iteratee invoked per element.
3725      * @param {Function} [comparator] The comparator invoked per element.
3726      * @returns {Array} Returns the new duplicate free array.
3727      */
3728     function baseUniq(array, iteratee, comparator) {
3729       var index = -1,
3730           includes = arrayIncludes,
3731           length = array.length,
3732           isCommon = true,
3733           result = [],
3734           seen = result;
3735
3736       if (comparator) {
3737         isCommon = false;
3738         includes = arrayIncludesWith;
3739       }
3740       else if (length >= LARGE_ARRAY_SIZE) {
3741         var set = iteratee ? null : createSet(array);
3742         if (set) {
3743           return setToArray(set);
3744         }
3745         isCommon = false;
3746         includes = cacheHas;
3747         seen = new SetCache;
3748       }
3749       else {
3750         seen = iteratee ? [] : result;
3751       }
3752       outer:
3753       while (++index < length) {
3754         var value = array[index],
3755             computed = iteratee ? iteratee(value) : value;
3756
3757         value = (comparator || value !== 0) ? value : 0;
3758         if (isCommon && computed === computed) {
3759           var seenIndex = seen.length;
3760           while (seenIndex--) {
3761             if (seen[seenIndex] === computed) {
3762               continue outer;
3763             }
3764           }
3765           if (iteratee) {
3766             seen.push(computed);
3767           }
3768           result.push(value);
3769         }
3770         else if (!includes(seen, computed, comparator)) {
3771           if (seen !== result) {
3772             seen.push(computed);
3773           }
3774           result.push(value);
3775         }
3776       }
3777       return result;
3778     }
3779
3780     /**
3781      * The base implementation of `_.unset`.
3782      *
3783      * @private
3784      * @param {Object} object The object to modify.
3785      * @param {Array|string} path The path of the property to unset.
3786      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
3787      */
3788     function baseUnset(object, path) {
3789       path = isKey(path, object) ? [path] : castPath(path);
3790       object = parent(object, path);
3791
3792       var key = toKey(last(path));
3793       return !(object != null && baseHas(object, key)) || delete object[key];
3794     }
3795
3796     /**
3797      * The base implementation of `_.update`.
3798      *
3799      * @private
3800      * @param {Object} object The object to query.
3801      * @param {Array|string} path The path of the property to update.
3802      * @param {Function} updater The function to produce the updated value.
3803      * @param {Function} [customizer] The function to customize path creation.
3804      * @returns {Object} Returns `object`.
3805      */
3806     function baseUpdate(object, path, updater, customizer) {
3807       return baseSet(object, path, updater(baseGet(object, path)), customizer);
3808     }
3809
3810     /**
3811      * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
3812      * without support for iteratee shorthands.
3813      *
3814      * @private
3815      * @param {Array} array The array to query.
3816      * @param {Function} predicate The function invoked per iteration.
3817      * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
3818      * @param {boolean} [fromRight] Specify iterating from right to left.
3819      * @returns {Array} Returns the slice of `array`.
3820      */
3821     function baseWhile(array, predicate, isDrop, fromRight) {
3822       var length = array.length,
3823           index = fromRight ? length : -1;
3824
3825       while ((fromRight ? index-- : ++index < length) &&
3826         predicate(array[index], index, array)) {}
3827
3828       return isDrop
3829         ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
3830         : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
3831     }
3832
3833     /**
3834      * The base implementation of `wrapperValue` which returns the result of
3835      * performing a sequence of actions on the unwrapped `value`, where each
3836      * successive action is supplied the return value of the previous.
3837      *
3838      * @private
3839      * @param {*} value The unwrapped value.
3840      * @param {Array} actions Actions to perform to resolve the unwrapped value.
3841      * @returns {*} Returns the resolved value.
3842      */
3843     function baseWrapperValue(value, actions) {
3844       var result = value;
3845       if (result instanceof LazyWrapper) {
3846         result = result.value();
3847       }
3848       return arrayReduce(actions, function(result, action) {
3849         return action.func.apply(action.thisArg, arrayPush([result], action.args));
3850       }, result);
3851     }
3852
3853     /**
3854      * The base implementation of methods like `_.xor`, without support for
3855      * iteratee shorthands, that accepts an array of arrays to inspect.
3856      *
3857      * @private
3858      * @param {Array} arrays The arrays to inspect.
3859      * @param {Function} [iteratee] The iteratee invoked per element.
3860      * @param {Function} [comparator] The comparator invoked per element.
3861      * @returns {Array} Returns the new array of values.
3862      */
3863     function baseXor(arrays, iteratee, comparator) {
3864       var index = -1,
3865           length = arrays.length;
3866
3867       while (++index < length) {
3868         var result = result
3869           ? arrayPush(
3870               baseDifference(result, arrays[index], iteratee, comparator),
3871               baseDifference(arrays[index], result, iteratee, comparator)
3872             )
3873           : arrays[index];
3874       }
3875       return (result && result.length) ? baseUniq(result, iteratee, comparator) : [];
3876     }
3877
3878     /**
3879      * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
3880      *
3881      * @private
3882      * @param {Array} props The property identifiers.
3883      * @param {Array} values The property values.
3884      * @param {Function} assignFunc The function to assign values.
3885      * @returns {Object} Returns the new object.
3886      */
3887     function baseZipObject(props, values, assignFunc) {
3888       var index = -1,
3889           length = props.length,
3890           valsLength = values.length,
3891           result = {};
3892
3893       while (++index < length) {
3894         var value = index < valsLength ? values[index] : undefined;
3895         assignFunc(result, props[index], value);
3896       }
3897       return result;
3898     }
3899
3900     /**
3901      * Casts `value` to an empty array if it's not an array like object.
3902      *
3903      * @private
3904      * @param {*} value The value to inspect.
3905      * @returns {Array|Object} Returns the cast array-like object.
3906      */
3907     function castArrayLikeObject(value) {
3908       return isArrayLikeObject(value) ? value : [];
3909     }
3910
3911     /**
3912      * Casts `value` to `identity` if it's not a function.
3913      *
3914      * @private
3915      * @param {*} value The value to inspect.
3916      * @returns {Function} Returns cast function.
3917      */
3918     function castFunction(value) {
3919       return typeof value == 'function' ? value : identity;
3920     }
3921
3922     /**
3923      * Casts `value` to a path array if it's not one.
3924      *
3925      * @private
3926      * @param {*} value The value to inspect.
3927      * @returns {Array} Returns the cast property path array.
3928      */
3929     function castPath(value) {
3930       return isArray(value) ? value : stringToPath(value);
3931     }
3932
3933     /**
3934      * Casts `array` to a slice if it's needed.
3935      *
3936      * @private
3937      * @param {Array} array The array to inspect.
3938      * @param {number} start The start position.
3939      * @param {number} [end=array.length] The end position.
3940      * @returns {Array} Returns the cast slice.
3941      */
3942     function castSlice(array, start, end) {
3943       var length = array.length;
3944       end = end === undefined ? length : end;
3945       return (!start && end >= length) ? array : baseSlice(array, start, end);
3946     }
3947
3948     /**
3949      * Creates a clone of  `buffer`.
3950      *
3951      * @private
3952      * @param {Buffer} buffer The buffer to clone.
3953      * @param {boolean} [isDeep] Specify a deep clone.
3954      * @returns {Buffer} Returns the cloned buffer.
3955      */
3956     function cloneBuffer(buffer, isDeep) {
3957       if (isDeep) {
3958         return buffer.slice();
3959       }
3960       var result = new buffer.constructor(buffer.length);
3961       buffer.copy(result);
3962       return result;
3963     }
3964
3965     /**
3966      * Creates a clone of `arrayBuffer`.
3967      *
3968      * @private
3969      * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
3970      * @returns {ArrayBuffer} Returns the cloned array buffer.
3971      */
3972     function cloneArrayBuffer(arrayBuffer) {
3973       var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
3974       new Uint8Array(result).set(new Uint8Array(arrayBuffer));
3975       return result;
3976     }
3977
3978     /**
3979      * Creates a clone of `dataView`.
3980      *
3981      * @private
3982      * @param {Object} dataView The data view to clone.
3983      * @param {boolean} [isDeep] Specify a deep clone.
3984      * @returns {Object} Returns the cloned data view.
3985      */
3986     function cloneDataView(dataView, isDeep) {
3987       var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
3988       return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
3989     }
3990
3991     /**
3992      * Creates a clone of `map`.
3993      *
3994      * @private
3995      * @param {Object} map The map to clone.
3996      * @param {Function} cloneFunc The function to clone values.
3997      * @param {boolean} [isDeep] Specify a deep clone.
3998      * @returns {Object} Returns the cloned map.
3999      */
4000     function cloneMap(map, isDeep, cloneFunc) {
4001       var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
4002       return arrayReduce(array, addMapEntry, new map.constructor);
4003     }
4004
4005     /**
4006      * Creates a clone of `regexp`.
4007      *
4008      * @private
4009      * @param {Object} regexp The regexp to clone.
4010      * @returns {Object} Returns the cloned regexp.
4011      */
4012     function cloneRegExp(regexp) {
4013       var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4014       result.lastIndex = regexp.lastIndex;
4015       return result;
4016     }
4017
4018     /**
4019      * Creates a clone of `set`.
4020      *
4021      * @private
4022      * @param {Object} set The set to clone.
4023      * @param {Function} cloneFunc The function to clone values.
4024      * @param {boolean} [isDeep] Specify a deep clone.
4025      * @returns {Object} Returns the cloned set.
4026      */
4027     function cloneSet(set, isDeep, cloneFunc) {
4028       var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
4029       return arrayReduce(array, addSetEntry, new set.constructor);
4030     }
4031
4032     /**
4033      * Creates a clone of the `symbol` object.
4034      *
4035      * @private
4036      * @param {Object} symbol The symbol object to clone.
4037      * @returns {Object} Returns the cloned symbol object.
4038      */
4039     function cloneSymbol(symbol) {
4040       return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4041     }
4042
4043     /**
4044      * Creates a clone of `typedArray`.
4045      *
4046      * @private
4047      * @param {Object} typedArray The typed array to clone.
4048      * @param {boolean} [isDeep] Specify a deep clone.
4049      * @returns {Object} Returns the cloned typed array.
4050      */
4051     function cloneTypedArray(typedArray, isDeep) {
4052       var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4053       return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4054     }
4055
4056     /**
4057      * Compares values to sort them in ascending order.
4058      *
4059      * @private
4060      * @param {*} value The value to compare.
4061      * @param {*} other The other value to compare.
4062      * @returns {number} Returns the sort order indicator for `value`.
4063      */
4064     function compareAscending(value, other) {
4065       if (value !== other) {
4066         var valIsDefined = value !== undefined,
4067             valIsNull = value === null,
4068             valIsReflexive = value === value,
4069             valIsSymbol = isSymbol(value);
4070
4071         var othIsDefined = other !== undefined,
4072             othIsNull = other === null,
4073             othIsReflexive = other === other,
4074             othIsSymbol = isSymbol(other);
4075
4076         if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4077             (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4078             (valIsNull && othIsDefined && othIsReflexive) ||
4079             (!valIsDefined && othIsReflexive) ||
4080             !valIsReflexive) {
4081           return 1;
4082         }
4083         if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4084             (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4085             (othIsNull && valIsDefined && valIsReflexive) ||
4086             (!othIsDefined && valIsReflexive) ||
4087             !othIsReflexive) {
4088           return -1;
4089         }
4090       }
4091       return 0;
4092     }
4093
4094     /**
4095      * Used by `_.orderBy` to compare multiple properties of a value to another
4096      * and stable sort them.
4097      *
4098      * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4099      * specify an order of "desc" for descending or "asc" for ascending sort order
4100      * of corresponding values.
4101      *
4102      * @private
4103      * @param {Object} object The object to compare.
4104      * @param {Object} other The other object to compare.
4105      * @param {boolean[]|string[]} orders The order to sort by for each property.
4106      * @returns {number} Returns the sort order indicator for `object`.
4107      */
4108     function compareMultiple(object, other, orders) {
4109       var index = -1,
4110           objCriteria = object.criteria,
4111           othCriteria = other.criteria,
4112           length = objCriteria.length,
4113           ordersLength = orders.length;
4114
4115       while (++index < length) {
4116         var result = compareAscending(objCriteria[index], othCriteria[index]);
4117         if (result) {
4118           if (index >= ordersLength) {
4119             return result;
4120           }
4121           var order = orders[index];
4122           return result * (order == 'desc' ? -1 : 1);
4123         }
4124       }
4125       // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
4126       // that causes it, under certain circumstances, to provide the same value for
4127       // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
4128       // for more details.
4129       //
4130       // This also ensures a stable sort in V8 and other engines.
4131       // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
4132       return object.index - other.index;
4133     }
4134
4135     /**
4136      * Creates an array that is the composition of partially applied arguments,
4137      * placeholders, and provided arguments into a single array of arguments.
4138      *
4139      * @private
4140      * @param {Array|Object} args The provided arguments.
4141      * @param {Array} partials The arguments to prepend to those provided.
4142      * @param {Array} holders The `partials` placeholder indexes.
4143      * @params {boolean} [isCurried] Specify composing for a curried function.
4144      * @returns {Array} Returns the new array of composed arguments.
4145      */
4146     function composeArgs(args, partials, holders, isCurried) {
4147       var argsIndex = -1,
4148           argsLength = args.length,
4149           holdersLength = holders.length,
4150           leftIndex = -1,
4151           leftLength = partials.length,
4152           rangeLength = nativeMax(argsLength - holdersLength, 0),
4153           result = Array(leftLength + rangeLength),
4154           isUncurried = !isCurried;
4155
4156       while (++leftIndex < leftLength) {
4157         result[leftIndex] = partials[leftIndex];
4158       }
4159       while (++argsIndex < holdersLength) {
4160         if (isUncurried || argsIndex < argsLength) {
4161           result[holders[argsIndex]] = args[argsIndex];
4162         }
4163       }
4164       while (rangeLength--) {
4165         result[leftIndex++] = args[argsIndex++];
4166       }
4167       return result;
4168     }
4169
4170     /**
4171      * This function is like `composeArgs` except that the arguments composition
4172      * is tailored for `_.partialRight`.
4173      *
4174      * @private
4175      * @param {Array|Object} args The provided arguments.
4176      * @param {Array} partials The arguments to append to those provided.
4177      * @param {Array} holders The `partials` placeholder indexes.
4178      * @params {boolean} [isCurried] Specify composing for a curried function.
4179      * @returns {Array} Returns the new array of composed arguments.
4180      */
4181     function composeArgsRight(args, partials, holders, isCurried) {
4182       var argsIndex = -1,
4183           argsLength = args.length,
4184           holdersIndex = -1,
4185           holdersLength = holders.length,
4186           rightIndex = -1,
4187           rightLength = partials.length,
4188           rangeLength = nativeMax(argsLength - holdersLength, 0),
4189           result = Array(rangeLength + rightLength),
4190           isUncurried = !isCurried;
4191
4192       while (++argsIndex < rangeLength) {
4193         result[argsIndex] = args[argsIndex];
4194       }
4195       var offset = argsIndex;
4196       while (++rightIndex < rightLength) {
4197         result[offset + rightIndex] = partials[rightIndex];
4198       }
4199       while (++holdersIndex < holdersLength) {
4200         if (isUncurried || argsIndex < argsLength) {
4201           result[offset + holders[holdersIndex]] = args[argsIndex++];
4202         }
4203       }
4204       return result;
4205     }
4206
4207     /**
4208      * Copies the values of `source` to `array`.
4209      *
4210      * @private
4211      * @param {Array} source The array to copy values from.
4212      * @param {Array} [array=[]] The array to copy values to.
4213      * @returns {Array} Returns `array`.
4214      */
4215     function copyArray(source, array) {
4216       var index = -1,
4217           length = source.length;
4218
4219       array || (array = Array(length));
4220       while (++index < length) {
4221         array[index] = source[index];
4222       }
4223       return array;
4224     }
4225
4226     /**
4227      * Copies properties of `source` to `object`.
4228      *
4229      * @private
4230      * @param {Object} source The object to copy properties from.
4231      * @param {Array} props The property identifiers to copy.
4232      * @param {Object} [object={}] The object to copy properties to.
4233      * @param {Function} [customizer] The function to customize copied values.
4234      * @returns {Object} Returns `object`.
4235      */
4236     function copyObject(source, props, object, customizer) {
4237       object || (object = {});
4238
4239       var index = -1,
4240           length = props.length;
4241
4242       while (++index < length) {
4243         var key = props[index];
4244
4245         var newValue = customizer
4246           ? customizer(object[key], source[key], key, object, source)
4247           : source[key];
4248
4249         assignValue(object, key, newValue);
4250       }
4251       return object;
4252     }
4253
4254     /**
4255      * Copies own symbol properties of `source` to `object`.
4256      *
4257      * @private
4258      * @param {Object} source The object to copy symbols from.
4259      * @param {Object} [object={}] The object to copy symbols to.
4260      * @returns {Object} Returns `object`.
4261      */
4262     function copySymbols(source, object) {
4263       return copyObject(source, getSymbols(source), object);
4264     }
4265
4266     /**
4267      * Creates a function like `_.groupBy`.
4268      *
4269      * @private
4270      * @param {Function} setter The function to set accumulator values.
4271      * @param {Function} [initializer] The accumulator object initializer.
4272      * @returns {Function} Returns the new aggregator function.
4273      */
4274     function createAggregator(setter, initializer) {
4275       return function(collection, iteratee) {
4276         var func = isArray(collection) ? arrayAggregator : baseAggregator,
4277             accumulator = initializer ? initializer() : {};
4278
4279         return func(collection, setter, getIteratee(iteratee), accumulator);
4280       };
4281     }
4282
4283     /**
4284      * Creates a function like `_.assign`.
4285      *
4286      * @private
4287      * @param {Function} assigner The function to assign values.
4288      * @returns {Function} Returns the new assigner function.
4289      */
4290     function createAssigner(assigner) {
4291       return rest(function(object, sources) {
4292         var index = -1,
4293             length = sources.length,
4294             customizer = length > 1 ? sources[length - 1] : undefined,
4295             guard = length > 2 ? sources[2] : undefined;
4296
4297         customizer = typeof customizer == 'function'
4298           ? (length--, customizer)
4299           : undefined;
4300
4301         if (guard && isIterateeCall(sources[0], sources[1], guard)) {
4302           customizer = length < 3 ? undefined : customizer;
4303           length = 1;
4304         }
4305         object = Object(object);
4306         while (++index < length) {
4307           var source = sources[index];
4308           if (source) {
4309             assigner(object, source, index, customizer);
4310           }
4311         }
4312         return object;
4313       });
4314     }
4315
4316     /**
4317      * Creates a `baseEach` or `baseEachRight` function.
4318      *
4319      * @private
4320      * @param {Function} eachFunc The function to iterate over a collection.
4321      * @param {boolean} [fromRight] Specify iterating from right to left.
4322      * @returns {Function} Returns the new base function.
4323      */
4324     function createBaseEach(eachFunc, fromRight) {
4325       return function(collection, iteratee) {
4326         if (collection == null) {
4327           return collection;
4328         }
4329         if (!isArrayLike(collection)) {
4330           return eachFunc(collection, iteratee);
4331         }
4332         var length = collection.length,
4333             index = fromRight ? length : -1,
4334             iterable = Object(collection);
4335
4336         while ((fromRight ? index-- : ++index < length)) {
4337           if (iteratee(iterable[index], index, iterable) === false) {
4338             break;
4339           }
4340         }
4341         return collection;
4342       };
4343     }
4344
4345     /**
4346      * Creates a base function for methods like `_.forIn` and `_.forOwn`.
4347      *
4348      * @private
4349      * @param {boolean} [fromRight] Specify iterating from right to left.
4350      * @returns {Function} Returns the new base function.
4351      */
4352     function createBaseFor(fromRight) {
4353       return function(object, iteratee, keysFunc) {
4354         var index = -1,
4355             iterable = Object(object),
4356             props = keysFunc(object),
4357             length = props.length;
4358
4359         while (length--) {
4360           var key = props[fromRight ? length : ++index];
4361           if (iteratee(iterable[key], key, iterable) === false) {
4362             break;
4363           }
4364         }
4365         return object;
4366       };
4367     }
4368
4369     /**
4370      * Creates a function that wraps `func` to invoke it with the optional `this`
4371      * binding of `thisArg`.
4372      *
4373      * @private
4374      * @param {Function} func The function to wrap.
4375      * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
4376      *  for more details.
4377      * @param {*} [thisArg] The `this` binding of `func`.
4378      * @returns {Function} Returns the new wrapped function.
4379      */
4380     function createBaseWrapper(func, bitmask, thisArg) {
4381       var isBind = bitmask & BIND_FLAG,
4382           Ctor = createCtorWrapper(func);
4383
4384       function wrapper() {
4385         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4386         return fn.apply(isBind ? thisArg : this, arguments);
4387       }
4388       return wrapper;
4389     }
4390
4391     /**
4392      * Creates a function like `_.lowerFirst`.
4393      *
4394      * @private
4395      * @param {string} methodName The name of the `String` case method to use.
4396      * @returns {Function} Returns the new function.
4397      */
4398     function createCaseFirst(methodName) {
4399       return function(string) {
4400         string = toString(string);
4401
4402         var strSymbols = reHasComplexSymbol.test(string)
4403           ? stringToArray(string)
4404           : undefined;
4405
4406         var chr = strSymbols
4407           ? strSymbols[0]
4408           : string.charAt(0);
4409
4410         var trailing = strSymbols
4411           ? castSlice(strSymbols, 1).join('')
4412           : string.slice(1);
4413
4414         return chr[methodName]() + trailing;
4415       };
4416     }
4417
4418     /**
4419      * Creates a function like `_.camelCase`.
4420      *
4421      * @private
4422      * @param {Function} callback The function to combine each word.
4423      * @returns {Function} Returns the new compounder function.
4424      */
4425     function createCompounder(callback) {
4426       return function(string) {
4427         return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
4428       };
4429     }
4430
4431     /**
4432      * Creates a function that produces an instance of `Ctor` regardless of
4433      * whether it was invoked as part of a `new` expression or by `call` or `apply`.
4434      *
4435      * @private
4436      * @param {Function} Ctor The constructor to wrap.
4437      * @returns {Function} Returns the new wrapped function.
4438      */
4439     function createCtorWrapper(Ctor) {
4440       return function() {
4441         // Use a `switch` statement to work with class constructors. See
4442         // http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
4443         // for more details.
4444         var args = arguments;
4445         switch (args.length) {
4446           case 0: return new Ctor;
4447           case 1: return new Ctor(args[0]);
4448           case 2: return new Ctor(args[0], args[1]);
4449           case 3: return new Ctor(args[0], args[1], args[2]);
4450           case 4: return new Ctor(args[0], args[1], args[2], args[3]);
4451           case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
4452           case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
4453           case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
4454         }
4455         var thisBinding = baseCreate(Ctor.prototype),
4456             result = Ctor.apply(thisBinding, args);
4457
4458         // Mimic the constructor's `return` behavior.
4459         // See https://es5.github.io/#x13.2.2 for more details.
4460         return isObject(result) ? result : thisBinding;
4461       };
4462     }
4463
4464     /**
4465      * Creates a function that wraps `func` to enable currying.
4466      *
4467      * @private
4468      * @param {Function} func The function to wrap.
4469      * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
4470      *  for more details.
4471      * @param {number} arity The arity of `func`.
4472      * @returns {Function} Returns the new wrapped function.
4473      */
4474     function createCurryWrapper(func, bitmask, arity) {
4475       var Ctor = createCtorWrapper(func);
4476
4477       function wrapper() {
4478         var length = arguments.length,
4479             args = Array(length),
4480             index = length,
4481             placeholder = getPlaceholder(wrapper);
4482
4483         while (index--) {
4484           args[index] = arguments[index];
4485         }
4486         var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
4487           ? []
4488           : replaceHolders(args, placeholder);
4489
4490         length -= holders.length;
4491         if (length < arity) {
4492           return createRecurryWrapper(
4493             func, bitmask, createHybridWrapper, wrapper.placeholder, undefined,
4494             args, holders, undefined, undefined, arity - length);
4495         }
4496         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4497         return apply(fn, this, args);
4498       }
4499       return wrapper;
4500     }
4501
4502     /**
4503      * Creates a `_.flow` or `_.flowRight` function.
4504      *
4505      * @private
4506      * @param {boolean} [fromRight] Specify iterating from right to left.
4507      * @returns {Function} Returns the new flow function.
4508      */
4509     function createFlow(fromRight) {
4510       return rest(function(funcs) {
4511         funcs = baseFlatten(funcs, 1);
4512
4513         var length = funcs.length,
4514             index = length,
4515             prereq = LodashWrapper.prototype.thru;
4516
4517         if (fromRight) {
4518           funcs.reverse();
4519         }
4520         while (index--) {
4521           var func = funcs[index];
4522           if (typeof func != 'function') {
4523             throw new TypeError(FUNC_ERROR_TEXT);
4524           }
4525           if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
4526             var wrapper = new LodashWrapper([], true);
4527           }
4528         }
4529         index = wrapper ? index : length;
4530         while (++index < length) {
4531           func = funcs[index];
4532
4533           var funcName = getFuncName(func),
4534               data = funcName == 'wrapper' ? getData(func) : undefined;
4535
4536           if (data && isLaziable(data[0]) &&
4537                 data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
4538                 !data[4].length && data[9] == 1
4539               ) {
4540             wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
4541           } else {
4542             wrapper = (func.length == 1 && isLaziable(func))
4543               ? wrapper[funcName]()
4544               : wrapper.thru(func);
4545           }
4546         }
4547         return function() {
4548           var args = arguments,
4549               value = args[0];
4550
4551           if (wrapper && args.length == 1 &&
4552               isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
4553             return wrapper.plant(value).value();
4554           }
4555           var index = 0,
4556               result = length ? funcs[index].apply(this, args) : value;
4557
4558           while (++index < length) {
4559             result = funcs[index].call(this, result);
4560           }
4561           return result;
4562         };
4563       });
4564     }
4565
4566     /**
4567      * Creates a function that wraps `func` to invoke it with optional `this`
4568      * binding of `thisArg`, partial application, and currying.
4569      *
4570      * @private
4571      * @param {Function|string} func The function or method name to wrap.
4572      * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
4573      *  for more details.
4574      * @param {*} [thisArg] The `this` binding of `func`.
4575      * @param {Array} [partials] The arguments to prepend to those provided to
4576      *  the new function.
4577      * @param {Array} [holders] The `partials` placeholder indexes.
4578      * @param {Array} [partialsRight] The arguments to append to those provided
4579      *  to the new function.
4580      * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
4581      * @param {Array} [argPos] The argument positions of the new function.
4582      * @param {number} [ary] The arity cap of `func`.
4583      * @param {number} [arity] The arity of `func`.
4584      * @returns {Function} Returns the new wrapped function.
4585      */
4586     function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
4587       var isAry = bitmask & ARY_FLAG,
4588           isBind = bitmask & BIND_FLAG,
4589           isBindKey = bitmask & BIND_KEY_FLAG,
4590           isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
4591           isFlip = bitmask & FLIP_FLAG,
4592           Ctor = isBindKey ? undefined : createCtorWrapper(func);
4593
4594       function wrapper() {
4595         var length = arguments.length,
4596             index = length,
4597             args = Array(length);
4598
4599         while (index--) {
4600           args[index] = arguments[index];
4601         }
4602         if (isCurried) {
4603           var placeholder = getPlaceholder(wrapper),
4604               holdersCount = countHolders(args, placeholder);
4605         }
4606         if (partials) {
4607           args = composeArgs(args, partials, holders, isCurried);
4608         }
4609         if (partialsRight) {
4610           args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
4611         }
4612         length -= holdersCount;
4613         if (isCurried && length < arity) {
4614           var newHolders = replaceHolders(args, placeholder);
4615           return createRecurryWrapper(
4616             func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
4617             args, newHolders, argPos, ary, arity - length
4618           );
4619         }
4620         var thisBinding = isBind ? thisArg : this,
4621             fn = isBindKey ? thisBinding[func] : func;
4622
4623         length = args.length;
4624         if (argPos) {
4625           args = reorder(args, argPos);
4626         } else if (isFlip && length > 1) {
4627           args.reverse();
4628         }
4629         if (isAry && ary < length) {
4630           args.length = ary;
4631         }
4632         if (this && this !== root && this instanceof wrapper) {
4633           fn = Ctor || createCtorWrapper(fn);
4634         }
4635         return fn.apply(thisBinding, args);
4636       }
4637       return wrapper;
4638     }
4639
4640     /**
4641      * Creates a function like `_.invertBy`.
4642      *
4643      * @private
4644      * @param {Function} setter The function to set accumulator values.
4645      * @param {Function} toIteratee The function to resolve iteratees.
4646      * @returns {Function} Returns the new inverter function.
4647      */
4648     function createInverter(setter, toIteratee) {
4649       return function(object, iteratee) {
4650         return baseInverter(object, setter, toIteratee(iteratee), {});
4651       };
4652     }
4653
4654     /**
4655      * Creates a function that performs a mathematical operation on two values.
4656      *
4657      * @private
4658      * @param {Function} operator The function to perform the operation.
4659      * @returns {Function} Returns the new mathematical operation function.
4660      */
4661     function createMathOperation(operator) {
4662       return function(value, other) {
4663         var result;
4664         if (value === undefined && other === undefined) {
4665           return 0;
4666         }
4667         if (value !== undefined) {
4668           result = value;
4669         }
4670         if (other !== undefined) {
4671           if (result === undefined) {
4672             return other;
4673           }
4674           if (typeof value == 'string' || typeof other == 'string') {
4675             value = baseToString(value);
4676             other = baseToString(other);
4677           } else {
4678             value = baseToNumber(value);
4679             other = baseToNumber(other);
4680           }
4681           result = operator(value, other);
4682         }
4683         return result;
4684       };
4685     }
4686
4687     /**
4688      * Creates a function like `_.over`.
4689      *
4690      * @private
4691      * @param {Function} arrayFunc The function to iterate over iteratees.
4692      * @returns {Function} Returns the new invoker function.
4693      */
4694     function createOver(arrayFunc) {
4695       return rest(function(iteratees) {
4696         iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
4697           ? arrayMap(iteratees[0], baseUnary(getIteratee()))
4698           : arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(getIteratee()));
4699
4700         return rest(function(args) {
4701           var thisArg = this;
4702           return arrayFunc(iteratees, function(iteratee) {
4703             return apply(iteratee, thisArg, args);
4704           });
4705         });
4706       });
4707     }
4708
4709     /**
4710      * Creates the padding for `string` based on `length`. The `chars` string
4711      * is truncated if the number of characters exceeds `length`.
4712      *
4713      * @private
4714      * @param {number} length The padding length.
4715      * @param {string} [chars=' '] The string used as padding.
4716      * @returns {string} Returns the padding for `string`.
4717      */
4718     function createPadding(length, chars) {
4719       chars = chars === undefined ? ' ' : baseToString(chars);
4720
4721       var charsLength = chars.length;
4722       if (charsLength < 2) {
4723         return charsLength ? baseRepeat(chars, length) : chars;
4724       }
4725       var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
4726       return reHasComplexSymbol.test(chars)
4727         ? castSlice(stringToArray(result), 0, length).join('')
4728         : result.slice(0, length);
4729     }
4730
4731     /**
4732      * Creates a function that wraps `func` to invoke it with the `this` binding
4733      * of `thisArg` and `partials` prepended to the arguments it receives.
4734      *
4735      * @private
4736      * @param {Function} func The function to wrap.
4737      * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
4738      *  for more details.
4739      * @param {*} thisArg The `this` binding of `func`.
4740      * @param {Array} partials The arguments to prepend to those provided to
4741      *  the new function.
4742      * @returns {Function} Returns the new wrapped function.
4743      */
4744     function createPartialWrapper(func, bitmask, thisArg, partials) {
4745       var isBind = bitmask & BIND_FLAG,
4746           Ctor = createCtorWrapper(func);
4747
4748       function wrapper() {
4749         var argsIndex = -1,
4750             argsLength = arguments.length,
4751             leftIndex = -1,
4752             leftLength = partials.length,
4753             args = Array(leftLength + argsLength),
4754             fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4755
4756         while (++leftIndex < leftLength) {
4757           args[leftIndex] = partials[leftIndex];
4758         }
4759         while (argsLength--) {
4760           args[leftIndex++] = arguments[++argsIndex];
4761         }
4762         return apply(fn, isBind ? thisArg : this, args);
4763       }
4764       return wrapper;
4765     }
4766
4767     /**
4768      * Creates a `_.range` or `_.rangeRight` function.
4769      *
4770      * @private
4771      * @param {boolean} [fromRight] Specify iterating from right to left.
4772      * @returns {Function} Returns the new range function.
4773      */
4774     function createRange(fromRight) {
4775       return function(start, end, step) {
4776         if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
4777           end = step = undefined;
4778         }
4779         // Ensure the sign of `-0` is preserved.
4780         start = toNumber(start);
4781         start = start === start ? start : 0;
4782         if (end === undefined) {
4783           end = start;
4784           start = 0;
4785         } else {
4786           end = toNumber(end) || 0;
4787         }
4788         step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0);
4789         return baseRange(start, end, step, fromRight);
4790       };
4791     }
4792
4793     /**
4794      * Creates a function that performs a relational operation on two values.
4795      *
4796      * @private
4797      * @param {Function} operator The function to perform the operation.
4798      * @returns {Function} Returns the new relational operation function.
4799      */
4800     function createRelationalOperation(operator) {
4801       return function(value, other) {
4802         if (!(typeof value == 'string' && typeof other == 'string')) {
4803           value = toNumber(value);
4804           other = toNumber(other);
4805         }
4806         return operator(value, other);
4807       };
4808     }
4809
4810     /**
4811      * Creates a function that wraps `func` to continue currying.
4812      *
4813      * @private
4814      * @param {Function} func The function to wrap.
4815      * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
4816      *  for more details.
4817      * @param {Function} wrapFunc The function to create the `func` wrapper.
4818      * @param {*} placeholder The placeholder value.
4819      * @param {*} [thisArg] The `this` binding of `func`.
4820      * @param {Array} [partials] The arguments to prepend to those provided to
4821      *  the new function.
4822      * @param {Array} [holders] The `partials` placeholder indexes.
4823      * @param {Array} [argPos] The argument positions of the new function.
4824      * @param {number} [ary] The arity cap of `func`.
4825      * @param {number} [arity] The arity of `func`.
4826      * @returns {Function} Returns the new wrapped function.
4827      */
4828     function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
4829       var isCurry = bitmask & CURRY_FLAG,
4830           newHolders = isCurry ? holders : undefined,
4831           newHoldersRight = isCurry ? undefined : holders,
4832           newPartials = isCurry ? partials : undefined,
4833           newPartialsRight = isCurry ? undefined : partials;
4834
4835       bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
4836       bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
4837
4838       if (!(bitmask & CURRY_BOUND_FLAG)) {
4839         bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
4840       }
4841       var newData = [
4842         func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
4843         newHoldersRight, argPos, ary, arity
4844       ];
4845
4846       var result = wrapFunc.apply(undefined, newData);
4847       if (isLaziable(func)) {
4848         setData(result, newData);
4849       }
4850       result.placeholder = placeholder;
4851       return result;
4852     }
4853
4854     /**
4855      * Creates a function like `_.round`.
4856      *
4857      * @private
4858      * @param {string} methodName The name of the `Math` method to use when rounding.
4859      * @returns {Function} Returns the new round function.
4860      */
4861     function createRound(methodName) {
4862       var func = Math[methodName];
4863       return function(number, precision) {
4864         number = toNumber(number);
4865         precision = toInteger(precision);
4866         if (precision) {
4867           // Shift with exponential notation to avoid floating-point issues.
4868           // See [MDN](https://mdn.io/round#Examples) for more details.
4869           var pair = (toString(number) + 'e').split('e'),
4870               value = func(pair[0] + 'e' + (+pair[1] + precision));
4871
4872           pair = (toString(value) + 'e').split('e');
4873           return +(pair[0] + 'e' + (+pair[1] - precision));
4874         }
4875         return func(number);
4876       };
4877     }
4878
4879     /**
4880      * Creates a set of `values`.
4881      *
4882      * @private
4883      * @param {Array} values The values to add to the set.
4884      * @returns {Object} Returns the new set.
4885      */
4886     var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
4887       return new Set(values);
4888     };
4889
4890     /**
4891      * Creates a function that either curries or invokes `func` with optional
4892      * `this` binding and partially applied arguments.
4893      *
4894      * @private
4895      * @param {Function|string} func The function or method name to wrap.
4896      * @param {number} bitmask The bitmask of wrapper flags.
4897      *  The bitmask may be composed of the following flags:
4898      *     1 - `_.bind`
4899      *     2 - `_.bindKey`
4900      *     4 - `_.curry` or `_.curryRight` of a bound function
4901      *     8 - `_.curry`
4902      *    16 - `_.curryRight`
4903      *    32 - `_.partial`
4904      *    64 - `_.partialRight`
4905      *   128 - `_.rearg`
4906      *   256 - `_.ary`
4907      * @param {*} [thisArg] The `this` binding of `func`.
4908      * @param {Array} [partials] The arguments to be partially applied.
4909      * @param {Array} [holders] The `partials` placeholder indexes.
4910      * @param {Array} [argPos] The argument positions of the new function.
4911      * @param {number} [ary] The arity cap of `func`.
4912      * @param {number} [arity] The arity of `func`.
4913      * @returns {Function} Returns the new wrapped function.
4914      */
4915     function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
4916       var isBindKey = bitmask & BIND_KEY_FLAG;
4917       if (!isBindKey && typeof func != 'function') {
4918         throw new TypeError(FUNC_ERROR_TEXT);
4919       }
4920       var length = partials ? partials.length : 0;
4921       if (!length) {
4922         bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
4923         partials = holders = undefined;
4924       }
4925       ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
4926       arity = arity === undefined ? arity : toInteger(arity);
4927       length -= holders ? holders.length : 0;
4928
4929       if (bitmask & PARTIAL_RIGHT_FLAG) {
4930         var partialsRight = partials,
4931             holdersRight = holders;
4932
4933         partials = holders = undefined;
4934       }
4935       var data = isBindKey ? undefined : getData(func);
4936
4937       var newData = [
4938         func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
4939         argPos, ary, arity
4940       ];
4941
4942       if (data) {
4943         mergeData(newData, data);
4944       }
4945       func = newData[0];
4946       bitmask = newData[1];
4947       thisArg = newData[2];
4948       partials = newData[3];
4949       holders = newData[4];
4950       arity = newData[9] = newData[9] == null
4951         ? (isBindKey ? 0 : func.length)
4952         : nativeMax(newData[9] - length, 0);
4953
4954       if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) {
4955         bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG);
4956       }
4957       if (!bitmask || bitmask == BIND_FLAG) {
4958         var result = createBaseWrapper(func, bitmask, thisArg);
4959       } else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) {
4960         result = createCurryWrapper(func, bitmask, arity);
4961       } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) {
4962         result = createPartialWrapper(func, bitmask, thisArg, partials);
4963       } else {
4964         result = createHybridWrapper.apply(undefined, newData);
4965       }
4966       var setter = data ? baseSetData : setData;
4967       return setter(result, newData);
4968     }
4969
4970     /**
4971      * A specialized version of `baseIsEqualDeep` for arrays with support for
4972      * partial deep comparisons.
4973      *
4974      * @private
4975      * @param {Array} array The array to compare.
4976      * @param {Array} other The other array to compare.
4977      * @param {Function} equalFunc The function to determine equivalents of values.
4978      * @param {Function} customizer The function to customize comparisons.
4979      * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
4980      *  for more details.
4981      * @param {Object} stack Tracks traversed `array` and `other` objects.
4982      * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
4983      */
4984     function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
4985       var index = -1,
4986           isPartial = bitmask & PARTIAL_COMPARE_FLAG,
4987           isUnordered = bitmask & UNORDERED_COMPARE_FLAG,
4988           arrLength = array.length,
4989           othLength = other.length;
4990
4991       if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
4992         return false;
4993       }
4994       // Assume cyclic values are equal.
4995       var stacked = stack.get(array);
4996       if (stacked) {
4997         return stacked == other;
4998       }
4999       var result = true;
5000       stack.set(array, other);
5001
5002       // Ignore non-index properties.
5003       while (++index < arrLength) {
5004         var arrValue = array[index],
5005             othValue = other[index];
5006
5007         if (customizer) {
5008           var compared = isPartial
5009             ? customizer(othValue, arrValue, index, other, array, stack)
5010             : customizer(arrValue, othValue, index, array, other, stack);
5011         }
5012         if (compared !== undefined) {
5013           if (compared) {
5014             continue;
5015           }
5016           result = false;
5017           break;
5018         }
5019         // Recursively compare arrays (susceptible to call stack limits).
5020         if (isUnordered) {
5021           if (!arraySome(other, function(othValue) {
5022                 return arrValue === othValue ||
5023                   equalFunc(arrValue, othValue, customizer, bitmask, stack);
5024               })) {
5025             result = false;
5026             break;
5027           }
5028         } else if (!(
5029               arrValue === othValue ||
5030                 equalFunc(arrValue, othValue, customizer, bitmask, stack)
5031             )) {
5032           result = false;
5033           break;
5034         }
5035       }
5036       stack['delete'](array);
5037       return result;
5038     }
5039
5040     /**
5041      * A specialized version of `baseIsEqualDeep` for comparing objects of
5042      * the same `toStringTag`.
5043      *
5044      * **Note:** This function only supports comparing values with tags of
5045      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5046      *
5047      * @private
5048      * @param {Object} object The object to compare.
5049      * @param {Object} other The other object to compare.
5050      * @param {string} tag The `toStringTag` of the objects to compare.
5051      * @param {Function} equalFunc The function to determine equivalents of values.
5052      * @param {Function} customizer The function to customize comparisons.
5053      * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
5054      *  for more details.
5055      * @param {Object} stack Tracks traversed `object` and `other` objects.
5056      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5057      */
5058     function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
5059       switch (tag) {
5060         case dataViewTag:
5061           if ((object.byteLength != other.byteLength) ||
5062               (object.byteOffset != other.byteOffset)) {
5063             return false;
5064           }
5065           object = object.buffer;
5066           other = other.buffer;
5067
5068         case arrayBufferTag:
5069           if ((object.byteLength != other.byteLength) ||
5070               !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5071             return false;
5072           }
5073           return true;
5074
5075         case boolTag:
5076         case dateTag:
5077           // Coerce dates and booleans to numbers, dates to milliseconds and
5078           // booleans to `1` or `0` treating invalid dates coerced to `NaN` as
5079           // not equal.
5080           return +object == +other;
5081
5082         case errorTag:
5083           return object.name == other.name && object.message == other.message;
5084
5085         case numberTag:
5086           // Treat `NaN` vs. `NaN` as equal.
5087           return (object != +object) ? other != +other : object == +other;
5088
5089         case regexpTag:
5090         case stringTag:
5091           // Coerce regexes to strings and treat strings, primitives and objects,
5092           // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
5093           // for more details.
5094           return object == (other + '');
5095
5096         case mapTag:
5097           var convert = mapToArray;
5098
5099         case setTag:
5100           var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
5101           convert || (convert = setToArray);
5102
5103           if (object.size != other.size && !isPartial) {
5104             return false;
5105           }
5106           // Assume cyclic values are equal.
5107           var stacked = stack.get(object);
5108           if (stacked) {
5109             return stacked == other;
5110           }
5111           bitmask |= UNORDERED_COMPARE_FLAG;
5112           stack.set(object, other);
5113
5114           // Recursively compare objects (susceptible to call stack limits).
5115           return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
5116
5117         case symbolTag:
5118           if (symbolValueOf) {
5119             return symbolValueOf.call(object) == symbolValueOf.call(other);
5120           }
5121       }
5122       return false;
5123     }
5124
5125     /**
5126      * A specialized version of `baseIsEqualDeep` for objects with support for
5127      * partial deep comparisons.
5128      *
5129      * @private
5130      * @param {Object} object The object to compare.
5131      * @param {Object} other The other object to compare.
5132      * @param {Function} equalFunc The function to determine equivalents of values.
5133      * @param {Function} customizer The function to customize comparisons.
5134      * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
5135      *  for more details.
5136      * @param {Object} stack Tracks traversed `object` and `other` objects.
5137      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5138      */
5139     function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
5140       var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
5141           objProps = keys(object),
5142           objLength = objProps.length,
5143           othProps = keys(other),
5144           othLength = othProps.length;
5145
5146       if (objLength != othLength && !isPartial) {
5147         return false;
5148       }
5149       var index = objLength;
5150       while (index--) {
5151         var key = objProps[index];
5152         if (!(isPartial ? key in other : baseHas(other, key))) {
5153           return false;
5154         }
5155       }
5156       // Assume cyclic values are equal.
5157       var stacked = stack.get(object);
5158       if (stacked) {
5159         return stacked == other;
5160       }
5161       var result = true;
5162       stack.set(object, other);
5163
5164       var skipCtor = isPartial;
5165       while (++index < objLength) {
5166         key = objProps[index];
5167         var objValue = object[key],
5168             othValue = other[key];
5169
5170         if (customizer) {
5171           var compared = isPartial
5172             ? customizer(othValue, objValue, key, other, object, stack)
5173             : customizer(objValue, othValue, key, object, other, stack);
5174         }
5175         // Recursively compare objects (susceptible to call stack limits).
5176         if (!(compared === undefined
5177               ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
5178               : compared
5179             )) {
5180           result = false;
5181           break;
5182         }
5183         skipCtor || (skipCtor = key == 'constructor');
5184       }
5185       if (result && !skipCtor) {
5186         var objCtor = object.constructor,
5187             othCtor = other.constructor;
5188
5189         // Non `Object` object instances with different constructors are not equal.
5190         if (objCtor != othCtor &&
5191             ('constructor' in object && 'constructor' in other) &&
5192             !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
5193               typeof othCtor == 'function' && othCtor instanceof othCtor)) {
5194           result = false;
5195         }
5196       }
5197       stack['delete'](object);
5198       return result;
5199     }
5200
5201     /**
5202      * Creates an array of own enumerable property names and symbols of `object`.
5203      *
5204      * @private
5205      * @param {Object} object The object to query.
5206      * @returns {Array} Returns the array of property names and symbols.
5207      */
5208     function getAllKeys(object) {
5209       return baseGetAllKeys(object, keys, getSymbols);
5210     }
5211
5212     /**
5213      * Creates an array of own and inherited enumerable property names and
5214      * symbols of `object`.
5215      *
5216      * @private
5217      * @param {Object} object The object to query.
5218      * @returns {Array} Returns the array of property names and symbols.
5219      */
5220     function getAllKeysIn(object) {
5221       return baseGetAllKeys(object, keysIn, getSymbolsIn);
5222     }
5223
5224     /**
5225      * Gets metadata for `func`.
5226      *
5227      * @private
5228      * @param {Function} func The function to query.
5229      * @returns {*} Returns the metadata for `func`.
5230      */
5231     var getData = !metaMap ? noop : function(func) {
5232       return metaMap.get(func);
5233     };
5234
5235     /**
5236      * Gets the name of `func`.
5237      *
5238      * @private
5239      * @param {Function} func The function to query.
5240      * @returns {string} Returns the function name.
5241      */
5242     function getFuncName(func) {
5243       var result = (func.name + ''),
5244           array = realNames[result],
5245           length = hasOwnProperty.call(realNames, result) ? array.length : 0;
5246
5247       while (length--) {
5248         var data = array[length],
5249             otherFunc = data.func;
5250         if (otherFunc == null || otherFunc == func) {
5251           return data.name;
5252         }
5253       }
5254       return result;
5255     }
5256
5257     /**
5258      * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
5259      * this function returns the custom method, otherwise it returns `baseIteratee`.
5260      * If arguments are provided, the chosen function is invoked with them and
5261      * its result is returned.
5262      *
5263      * @private
5264      * @param {*} [value] The value to convert to an iteratee.
5265      * @param {number} [arity] The arity of the created iteratee.
5266      * @returns {Function} Returns the chosen function or its result.
5267      */
5268     function getIteratee() {
5269       var result = lodash.iteratee || iteratee;
5270       result = result === iteratee ? baseIteratee : result;
5271       return arguments.length ? result(arguments[0], arguments[1]) : result;
5272     }
5273
5274     /**
5275      * Gets the "length" property value of `object`.
5276      *
5277      * **Note:** This function is used to avoid a
5278      * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
5279      * Safari on at least iOS 8.1-8.3 ARM64.
5280      *
5281      * @private
5282      * @param {Object} object The object to query.
5283      * @returns {*} Returns the "length" value.
5284      */
5285     var getLength = baseProperty('length');
5286
5287     /**
5288      * Gets the property names, values, and compare flags of `object`.
5289      *
5290      * @private
5291      * @param {Object} object The object to query.
5292      * @returns {Array} Returns the match data of `object`.
5293      */
5294     function getMatchData(object) {
5295       var result = toPairs(object),
5296           length = result.length;
5297
5298       while (length--) {
5299         result[length][2] = isStrictComparable(result[length][1]);
5300       }
5301       return result;
5302     }
5303
5304     /**
5305      * Gets the native function at `key` of `object`.
5306      *
5307      * @private
5308      * @param {Object} object The object to query.
5309      * @param {string} key The key of the method to get.
5310      * @returns {*} Returns the function if it's native, else `undefined`.
5311      */
5312     function getNative(object, key) {
5313       var value = object[key];
5314       return isNative(value) ? value : undefined;
5315     }
5316
5317     /**
5318      * Gets the argument placeholder value for `func`.
5319      *
5320      * @private
5321      * @param {Function} func The function to inspect.
5322      * @returns {*} Returns the placeholder value.
5323      */
5324     function getPlaceholder(func) {
5325       var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
5326       return object.placeholder;
5327     }
5328
5329     /**
5330      * Gets the `[[Prototype]]` of `value`.
5331      *
5332      * @private
5333      * @param {*} value The value to query.
5334      * @returns {null|Object} Returns the `[[Prototype]]`.
5335      */
5336     function getPrototype(value) {
5337       return nativeGetPrototype(Object(value));
5338     }
5339
5340     /**
5341      * Creates an array of the own enumerable symbol properties of `object`.
5342      *
5343      * @private
5344      * @param {Object} object The object to query.
5345      * @returns {Array} Returns the array of symbols.
5346      */
5347     function getSymbols(object) {
5348       // Coerce `object` to an object to avoid non-object errors in V8.
5349       // See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details.
5350       return getOwnPropertySymbols(Object(object));
5351     }
5352
5353     // Fallback for IE < 11.
5354     if (!getOwnPropertySymbols) {
5355       getSymbols = function() {
5356         return [];
5357       };
5358     }
5359
5360     /**
5361      * Creates an array of the own and inherited enumerable symbol properties
5362      * of `object`.
5363      *
5364      * @private
5365      * @param {Object} object The object to query.
5366      * @returns {Array} Returns the array of symbols.
5367      */
5368     var getSymbolsIn = !getOwnPropertySymbols ? getSymbols : function(object) {
5369       var result = [];
5370       while (object) {
5371         arrayPush(result, getSymbols(object));
5372         object = getPrototype(object);
5373       }
5374       return result;
5375     };
5376
5377     /**
5378      * Gets the `toStringTag` of `value`.
5379      *
5380      * @private
5381      * @param {*} value The value to query.
5382      * @returns {string} Returns the `toStringTag`.
5383      */
5384     function getTag(value) {
5385       return objectToString.call(value);
5386     }
5387
5388     // Fallback for data views, maps, sets, and weak maps in IE 11,
5389     // for data views in Edge, and promises in Node.js.
5390     if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
5391         (Map && getTag(new Map) != mapTag) ||
5392         (Promise && getTag(Promise.resolve()) != promiseTag) ||
5393         (Set && getTag(new Set) != setTag) ||
5394         (WeakMap && getTag(new WeakMap) != weakMapTag)) {
5395       getTag = function(value) {
5396         var result = objectToString.call(value),
5397             Ctor = result == objectTag ? value.constructor : undefined,
5398             ctorString = Ctor ? toSource(Ctor) : undefined;
5399
5400         if (ctorString) {
5401           switch (ctorString) {
5402             case dataViewCtorString: return dataViewTag;
5403             case mapCtorString: return mapTag;
5404             case promiseCtorString: return promiseTag;
5405             case setCtorString: return setTag;
5406             case weakMapCtorString: return weakMapTag;
5407           }
5408         }
5409         return result;
5410       };
5411     }
5412
5413     /**
5414      * Gets the view, applying any `transforms` to the `start` and `end` positions.
5415      *
5416      * @private
5417      * @param {number} start The start of the view.
5418      * @param {number} end The end of the view.
5419      * @param {Array} transforms The transformations to apply to the view.
5420      * @returns {Object} Returns an object containing the `start` and `end`
5421      *  positions of the view.
5422      */
5423     function getView(start, end, transforms) {
5424       var index = -1,
5425           length = transforms.length;
5426
5427       while (++index < length) {
5428         var data = transforms[index],
5429             size = data.size;
5430
5431         switch (data.type) {
5432           case 'drop':      start += size; break;
5433           case 'dropRight': end -= size; break;
5434           case 'take':      end = nativeMin(end, start + size); break;
5435           case 'takeRight': start = nativeMax(start, end - size); break;
5436         }
5437       }
5438       return { 'start': start, 'end': end };
5439     }
5440
5441     /**
5442      * Checks if `path` exists on `object`.
5443      *
5444      * @private
5445      * @param {Object} object The object to query.
5446      * @param {Array|string} path The path to check.
5447      * @param {Function} hasFunc The function to check properties.
5448      * @returns {boolean} Returns `true` if `path` exists, else `false`.
5449      */
5450     function hasPath(object, path, hasFunc) {
5451       path = isKey(path, object) ? [path] : castPath(path);
5452
5453       var result,
5454           index = -1,
5455           length = path.length;
5456
5457       while (++index < length) {
5458         var key = toKey(path[index]);
5459         if (!(result = object != null && hasFunc(object, key))) {
5460           break;
5461         }
5462         object = object[key];
5463       }
5464       if (result) {
5465         return result;
5466       }
5467       var length = object ? object.length : 0;
5468       return !!length && isLength(length) && isIndex(key, length) &&
5469         (isArray(object) || isString(object) || isArguments(object));
5470     }
5471
5472     /**
5473      * Initializes an array clone.
5474      *
5475      * @private
5476      * @param {Array} array The array to clone.
5477      * @returns {Array} Returns the initialized clone.
5478      */
5479     function initCloneArray(array) {
5480       var length = array.length,
5481           result = array.constructor(length);
5482
5483       // Add properties assigned by `RegExp#exec`.
5484       if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
5485         result.index = array.index;
5486         result.input = array.input;
5487       }
5488       return result;
5489     }
5490
5491     /**
5492      * Initializes an object clone.
5493      *
5494      * @private
5495      * @param {Object} object The object to clone.
5496      * @returns {Object} Returns the initialized clone.
5497      */
5498     function initCloneObject(object) {
5499       return (typeof object.constructor == 'function' && !isPrototype(object))
5500         ? baseCreate(getPrototype(object))
5501         : {};
5502     }
5503
5504     /**
5505      * Initializes an object clone based on its `toStringTag`.
5506      *
5507      * **Note:** This function only supports cloning values with tags of
5508      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5509      *
5510      * @private
5511      * @param {Object} object The object to clone.
5512      * @param {string} tag The `toStringTag` of the object to clone.
5513      * @param {Function} cloneFunc The function to clone values.
5514      * @param {boolean} [isDeep] Specify a deep clone.
5515      * @returns {Object} Returns the initialized clone.
5516      */
5517     function initCloneByTag(object, tag, cloneFunc, isDeep) {
5518       var Ctor = object.constructor;
5519       switch (tag) {
5520         case arrayBufferTag:
5521           return cloneArrayBuffer(object);
5522
5523         case boolTag:
5524         case dateTag:
5525           return new Ctor(+object);
5526
5527         case dataViewTag:
5528           return cloneDataView(object, isDeep);
5529
5530         case float32Tag: case float64Tag:
5531         case int8Tag: case int16Tag: case int32Tag:
5532         case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
5533           return cloneTypedArray(object, isDeep);
5534
5535         case mapTag:
5536           return cloneMap(object, isDeep, cloneFunc);
5537
5538         case numberTag:
5539         case stringTag:
5540           return new Ctor(object);
5541
5542         case regexpTag:
5543           return cloneRegExp(object);
5544
5545         case setTag:
5546           return cloneSet(object, isDeep, cloneFunc);
5547
5548         case symbolTag:
5549           return cloneSymbol(object);
5550       }
5551     }
5552
5553     /**
5554      * Creates an array of index keys for `object` values of arrays,
5555      * `arguments` objects, and strings, otherwise `null` is returned.
5556      *
5557      * @private
5558      * @param {Object} object The object to query.
5559      * @returns {Array|null} Returns index keys, else `null`.
5560      */
5561     function indexKeys(object) {
5562       var length = object ? object.length : undefined;
5563       if (isLength(length) &&
5564           (isArray(object) || isString(object) || isArguments(object))) {
5565         return baseTimes(length, String);
5566       }
5567       return null;
5568     }
5569
5570     /**
5571      * Checks if `value` is a flattenable `arguments` object or array.
5572      *
5573      * @private
5574      * @param {*} value The value to check.
5575      * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
5576      */
5577     function isFlattenable(value) {
5578       return isArrayLikeObject(value) && (isArray(value) || isArguments(value));
5579     }
5580
5581     /**
5582      * Checks if `value` is a flattenable array and not a `_.matchesProperty`
5583      * iteratee shorthand.
5584      *
5585      * @private
5586      * @param {*} value The value to check.
5587      * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
5588      */
5589     function isFlattenableIteratee(value) {
5590       return isArray(value) && !(value.length == 2 && !isFunction(value[0]));
5591     }
5592
5593     /**
5594      * Checks if `value` is a valid array-like index.
5595      *
5596      * @private
5597      * @param {*} value The value to check.
5598      * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
5599      * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
5600      */
5601     function isIndex(value, length) {
5602       length = length == null ? MAX_SAFE_INTEGER : length;
5603       return !!length &&
5604         (typeof value == 'number' || reIsUint.test(value)) &&
5605         (value > -1 && value % 1 == 0 && value < length);
5606     }
5607
5608     /**
5609      * Checks if the given arguments are from an iteratee call.
5610      *
5611      * @private
5612      * @param {*} value The potential iteratee value argument.
5613      * @param {*} index The potential iteratee index or key argument.
5614      * @param {*} object The potential iteratee object argument.
5615      * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
5616      *  else `false`.
5617      */
5618     function isIterateeCall(value, index, object) {
5619       if (!isObject(object)) {
5620         return false;
5621       }
5622       var type = typeof index;
5623       if (type == 'number'
5624             ? (isArrayLike(object) && isIndex(index, object.length))
5625             : (type == 'string' && index in object)
5626           ) {
5627         return eq(object[index], value);
5628       }
5629       return false;
5630     }
5631
5632     /**
5633      * Checks if `value` is a property name and not a property path.
5634      *
5635      * @private
5636      * @param {*} value The value to check.
5637      * @param {Object} [object] The object to query keys on.
5638      * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
5639      */
5640     function isKey(value, object) {
5641       if (isArray(value)) {
5642         return false;
5643       }
5644       var type = typeof value;
5645       if (type == 'number' || type == 'symbol' || type == 'boolean' ||
5646           value == null || isSymbol(value)) {
5647         return true;
5648       }
5649       return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
5650         (object != null && value in Object(object));
5651     }
5652
5653     /**
5654      * Checks if `value` is suitable for use as unique object key.
5655      *
5656      * @private
5657      * @param {*} value The value to check.
5658      * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
5659      */
5660     function isKeyable(value) {
5661       var type = typeof value;
5662       return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
5663         ? (value !== '__proto__')
5664         : (value === null);
5665     }
5666
5667     /**
5668      * Checks if `func` has a lazy counterpart.
5669      *
5670      * @private
5671      * @param {Function} func The function to check.
5672      * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
5673      *  else `false`.
5674      */
5675     function isLaziable(func) {
5676       var funcName = getFuncName(func),
5677           other = lodash[funcName];
5678
5679       if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
5680         return false;
5681       }
5682       if (func === other) {
5683         return true;
5684       }
5685       var data = getData(other);
5686       return !!data && func === data[0];
5687     }
5688
5689     /**
5690      * Checks if `value` is likely a prototype object.
5691      *
5692      * @private
5693      * @param {*} value The value to check.
5694      * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
5695      */
5696     function isPrototype(value) {
5697       var Ctor = value && value.constructor,
5698           proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
5699
5700       return value === proto;
5701     }
5702
5703     /**
5704      * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
5705      *
5706      * @private
5707      * @param {*} value The value to check.
5708      * @returns {boolean} Returns `true` if `value` if suitable for strict
5709      *  equality comparisons, else `false`.
5710      */
5711     function isStrictComparable(value) {
5712       return value === value && !isObject(value);
5713     }
5714
5715     /**
5716      * A specialized version of `matchesProperty` for source values suitable
5717      * for strict equality comparisons, i.e. `===`.
5718      *
5719      * @private
5720      * @param {string} key The key of the property to get.
5721      * @param {*} srcValue The value to match.
5722      * @returns {Function} Returns the new function.
5723      */
5724     function matchesStrictComparable(key, srcValue) {
5725       return function(object) {
5726         if (object == null) {
5727           return false;
5728         }
5729         return object[key] === srcValue &&
5730           (srcValue !== undefined || (key in Object(object)));
5731       };
5732     }
5733
5734     /**
5735      * Merges the function metadata of `source` into `data`.
5736      *
5737      * Merging metadata reduces the number of wrappers used to invoke a function.
5738      * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
5739      * may be applied regardless of execution order. Methods like `_.ary` and
5740      * `_.rearg` modify function arguments, making the order in which they are
5741      * executed important, preventing the merging of metadata. However, we make
5742      * an exception for a safe combined case where curried functions have `_.ary`
5743      * and or `_.rearg` applied.
5744      *
5745      * @private
5746      * @param {Array} data The destination metadata.
5747      * @param {Array} source The source metadata.
5748      * @returns {Array} Returns `data`.
5749      */
5750     function mergeData(data, source) {
5751       var bitmask = data[1],
5752           srcBitmask = source[1],
5753           newBitmask = bitmask | srcBitmask,
5754           isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
5755
5756       var isCombo =
5757         ((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
5758         ((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
5759         ((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
5760
5761       // Exit early if metadata can't be merged.
5762       if (!(isCommon || isCombo)) {
5763         return data;
5764       }
5765       // Use source `thisArg` if available.
5766       if (srcBitmask & BIND_FLAG) {
5767         data[2] = source[2];
5768         // Set when currying a bound function.
5769         newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
5770       }
5771       // Compose partial arguments.
5772       var value = source[3];
5773       if (value) {
5774         var partials = data[3];
5775         data[3] = partials ? composeArgs(partials, value, source[4]) : value;
5776         data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
5777       }
5778       // Compose partial right arguments.
5779       value = source[5];
5780       if (value) {
5781         partials = data[5];
5782         data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
5783         data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
5784       }
5785       // Use source `argPos` if available.
5786       value = source[7];
5787       if (value) {
5788         data[7] = value;
5789       }
5790       // Use source `ary` if it's smaller.
5791       if (srcBitmask & ARY_FLAG) {
5792         data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
5793       }
5794       // Use source `arity` if one is not provided.
5795       if (data[9] == null) {
5796         data[9] = source[9];
5797       }
5798       // Use source `func` and merge bitmasks.
5799       data[0] = source[0];
5800       data[1] = newBitmask;
5801
5802       return data;
5803     }
5804
5805     /**
5806      * Used by `_.defaultsDeep` to customize its `_.merge` use.
5807      *
5808      * @private
5809      * @param {*} objValue The destination value.
5810      * @param {*} srcValue The source value.
5811      * @param {string} key The key of the property to merge.
5812      * @param {Object} object The parent object of `objValue`.
5813      * @param {Object} source The parent object of `srcValue`.
5814      * @param {Object} [stack] Tracks traversed source values and their merged
5815      *  counterparts.
5816      * @returns {*} Returns the value to assign.
5817      */
5818     function mergeDefaults(objValue, srcValue, key, object, source, stack) {
5819       if (isObject(objValue) && isObject(srcValue)) {
5820         baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
5821       }
5822       return objValue;
5823     }
5824
5825     /**
5826      * Gets the parent value at `path` of `object`.
5827      *
5828      * @private
5829      * @param {Object} object The object to query.
5830      * @param {Array} path The path to get the parent value of.
5831      * @returns {*} Returns the parent value.
5832      */
5833     function parent(object, path) {
5834       return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
5835     }
5836
5837     /**
5838      * Reorder `array` according to the specified indexes where the element at
5839      * the first index is assigned as the first element, the element at
5840      * the second index is assigned as the second element, and so on.
5841      *
5842      * @private
5843      * @param {Array} array The array to reorder.
5844      * @param {Array} indexes The arranged array indexes.
5845      * @returns {Array} Returns `array`.
5846      */
5847     function reorder(array, indexes) {
5848       var arrLength = array.length,
5849           length = nativeMin(indexes.length, arrLength),
5850           oldArray = copyArray(array);
5851
5852       while (length--) {
5853         var index = indexes[length];
5854         array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
5855       }
5856       return array;
5857     }
5858
5859     /**
5860      * Sets metadata for `func`.
5861      *
5862      * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
5863      * period of time, it will trip its breaker and transition to an identity
5864      * function to avoid garbage collection pauses in V8. See
5865      * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
5866      * for more details.
5867      *
5868      * @private
5869      * @param {Function} func The function to associate metadata with.
5870      * @param {*} data The metadata.
5871      * @returns {Function} Returns `func`.
5872      */
5873     var setData = (function() {
5874       var count = 0,
5875           lastCalled = 0;
5876
5877       return function(key, value) {
5878         var stamp = now(),
5879             remaining = HOT_SPAN - (stamp - lastCalled);
5880
5881         lastCalled = stamp;
5882         if (remaining > 0) {
5883           if (++count >= HOT_COUNT) {
5884             return key;
5885           }
5886         } else {
5887           count = 0;
5888         }
5889         return baseSetData(key, value);
5890       };
5891     }());
5892
5893     /**
5894      * Converts `string` to a property path array.
5895      *
5896      * @private
5897      * @param {string} string The string to convert.
5898      * @returns {Array} Returns the property path array.
5899      */
5900     var stringToPath = memoize(function(string) {
5901       var result = [];
5902       toString(string).replace(rePropName, function(match, number, quote, string) {
5903         result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
5904       });
5905       return result;
5906     });
5907
5908     /**
5909      * Converts `value` to a string key if it's not a string or symbol.
5910      *
5911      * @private
5912      * @param {*} value The value to inspect.
5913      * @returns {string|symbol} Returns the key.
5914      */
5915     function toKey(value) {
5916       if (typeof value == 'string' || isSymbol(value)) {
5917         return value;
5918       }
5919       var result = (value + '');
5920       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
5921     }
5922
5923     /**
5924      * Converts `func` to its source code.
5925      *
5926      * @private
5927      * @param {Function} func The function to process.
5928      * @returns {string} Returns the source code.
5929      */
5930     function toSource(func) {
5931       if (func != null) {
5932         try {
5933           return funcToString.call(func);
5934         } catch (e) {}
5935         try {
5936           return (func + '');
5937         } catch (e) {}
5938       }
5939       return '';
5940     }
5941
5942     /**
5943      * Creates a clone of `wrapper`.
5944      *
5945      * @private
5946      * @param {Object} wrapper The wrapper to clone.
5947      * @returns {Object} Returns the cloned wrapper.
5948      */
5949     function wrapperClone(wrapper) {
5950       if (wrapper instanceof LazyWrapper) {
5951         return wrapper.clone();
5952       }
5953       var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
5954       result.__actions__ = copyArray(wrapper.__actions__);
5955       result.__index__  = wrapper.__index__;
5956       result.__values__ = wrapper.__values__;
5957       return result;
5958     }
5959
5960     /*------------------------------------------------------------------------*/
5961
5962     /**
5963      * Creates an array of elements split into groups the length of `size`.
5964      * If `array` can't be split evenly, the final chunk will be the remaining
5965      * elements.
5966      *
5967      * @static
5968      * @memberOf _
5969      * @since 3.0.0
5970      * @category Array
5971      * @param {Array} array The array to process.
5972      * @param {number} [size=1] The length of each chunk
5973      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
5974      * @returns {Array} Returns the new array containing chunks.
5975      * @example
5976      *
5977      * _.chunk(['a', 'b', 'c', 'd'], 2);
5978      * // => [['a', 'b'], ['c', 'd']]
5979      *
5980      * _.chunk(['a', 'b', 'c', 'd'], 3);
5981      * // => [['a', 'b', 'c'], ['d']]
5982      */
5983     function chunk(array, size, guard) {
5984       if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
5985         size = 1;
5986       } else {
5987         size = nativeMax(toInteger(size), 0);
5988       }
5989       var length = array ? array.length : 0;
5990       if (!length || size < 1) {
5991         return [];
5992       }
5993       var index = 0,
5994           resIndex = 0,
5995           result = Array(nativeCeil(length / size));
5996
5997       while (index < length) {
5998         result[resIndex++] = baseSlice(array, index, (index += size));
5999       }
6000       return result;
6001     }
6002
6003     /**
6004      * Creates an array with all falsey values removed. The values `false`, `null`,
6005      * `0`, `""`, `undefined`, and `NaN` are falsey.
6006      *
6007      * @static
6008      * @memberOf _
6009      * @since 0.1.0
6010      * @category Array
6011      * @param {Array} array The array to compact.
6012      * @returns {Array} Returns the new array of filtered values.
6013      * @example
6014      *
6015      * _.compact([0, 1, false, 2, '', 3]);
6016      * // => [1, 2, 3]
6017      */
6018     function compact(array) {
6019       var index = -1,
6020           length = array ? array.length : 0,
6021           resIndex = 0,
6022           result = [];
6023
6024       while (++index < length) {
6025         var value = array[index];
6026         if (value) {
6027           result[resIndex++] = value;
6028         }
6029       }
6030       return result;
6031     }
6032
6033     /**
6034      * Creates a new array concatenating `array` with any additional arrays
6035      * and/or values.
6036      *
6037      * @static
6038      * @memberOf _
6039      * @since 4.0.0
6040      * @category Array
6041      * @param {Array} array The array to concatenate.
6042      * @param {...*} [values] The values to concatenate.
6043      * @returns {Array} Returns the new concatenated array.
6044      * @example
6045      *
6046      * var array = [1];
6047      * var other = _.concat(array, 2, [3], [[4]]);
6048      *
6049      * console.log(other);
6050      * // => [1, 2, 3, [4]]
6051      *
6052      * console.log(array);
6053      * // => [1]
6054      */
6055     function concat() {
6056       var length = arguments.length,
6057           array = castArray(arguments[0]);
6058
6059       if (length < 2) {
6060         return length ? copyArray(array) : [];
6061       }
6062       var args = Array(length - 1);
6063       while (length--) {
6064         args[length - 1] = arguments[length];
6065       }
6066       return arrayConcat(array, baseFlatten(args, 1));
6067     }
6068
6069     /**
6070      * Creates an array of unique `array` values not included in the other given
6071      * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
6072      * for equality comparisons. The order of result values is determined by the
6073      * order they occur in the first array.
6074      *
6075      * @static
6076      * @memberOf _
6077      * @since 0.1.0
6078      * @category Array
6079      * @param {Array} array The array to inspect.
6080      * @param {...Array} [values] The values to exclude.
6081      * @returns {Array} Returns the new array of filtered values.
6082      * @see _.without, _.xor
6083      * @example
6084      *
6085      * _.difference([3, 2, 1], [4, 2]);
6086      * // => [3, 1]
6087      */
6088     var difference = rest(function(array, values) {
6089       return isArrayLikeObject(array)
6090         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
6091         : [];
6092     });
6093
6094     /**
6095      * This method is like `_.difference` except that it accepts `iteratee` which
6096      * is invoked for each element of `array` and `values` to generate the criterion
6097      * by which they're compared. Result values are chosen from the first array.
6098      * The iteratee is invoked with one argument: (value).
6099      *
6100      * @static
6101      * @memberOf _
6102      * @since 4.0.0
6103      * @category Array
6104      * @param {Array} array The array to inspect.
6105      * @param {...Array} [values] The values to exclude.
6106      * @param {Array|Function|Object|string} [iteratee=_.identity]
6107      *  The iteratee invoked per element.
6108      * @returns {Array} Returns the new array of filtered values.
6109      * @example
6110      *
6111      * _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor);
6112      * // => [3.1, 1.3]
6113      *
6114      * // The `_.property` iteratee shorthand.
6115      * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
6116      * // => [{ 'x': 2 }]
6117      */
6118     var differenceBy = rest(function(array, values) {
6119       var iteratee = last(values);
6120       if (isArrayLikeObject(iteratee)) {
6121         iteratee = undefined;
6122       }
6123       return isArrayLikeObject(array)
6124         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee))
6125         : [];
6126     });
6127
6128     /**
6129      * This method is like `_.difference` except that it accepts `comparator`
6130      * which is invoked to compare elements of `array` to `values`. Result values
6131      * are chosen from the first array. The comparator is invoked with two arguments:
6132      * (arrVal, othVal).
6133      *
6134      * @static
6135      * @memberOf _
6136      * @since 4.0.0
6137      * @category Array
6138      * @param {Array} array The array to inspect.
6139      * @param {...Array} [values] The values to exclude.
6140      * @param {Function} [comparator] The comparator invoked per element.
6141      * @returns {Array} Returns the new array of filtered values.
6142      * @example
6143      *
6144      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
6145      *
6146      * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
6147      * // => [{ 'x': 2, 'y': 1 }]
6148      */
6149     var differenceWith = rest(function(array, values) {
6150       var comparator = last(values);
6151       if (isArrayLikeObject(comparator)) {
6152         comparator = undefined;
6153       }
6154       return isArrayLikeObject(array)
6155         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
6156         : [];
6157     });
6158
6159     /**
6160      * Creates a slice of `array` with `n` elements dropped from the beginning.
6161      *
6162      * @static
6163      * @memberOf _
6164      * @since 0.5.0
6165      * @category Array
6166      * @param {Array} array The array to query.
6167      * @param {number} [n=1] The number of elements to drop.
6168      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
6169      * @returns {Array} Returns the slice of `array`.
6170      * @example
6171      *
6172      * _.drop([1, 2, 3]);
6173      * // => [2, 3]
6174      *
6175      * _.drop([1, 2, 3], 2);
6176      * // => [3]
6177      *
6178      * _.drop([1, 2, 3], 5);
6179      * // => []
6180      *
6181      * _.drop([1, 2, 3], 0);
6182      * // => [1, 2, 3]
6183      */
6184     function drop(array, n, guard) {
6185       var length = array ? array.length : 0;
6186       if (!length) {
6187         return [];
6188       }
6189       n = (guard || n === undefined) ? 1 : toInteger(n);
6190       return baseSlice(array, n < 0 ? 0 : n, length);
6191     }
6192
6193     /**
6194      * Creates a slice of `array` with `n` elements dropped from the end.
6195      *
6196      * @static
6197      * @memberOf _
6198      * @since 3.0.0
6199      * @category Array
6200      * @param {Array} array The array to query.
6201      * @param {number} [n=1] The number of elements to drop.
6202      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
6203      * @returns {Array} Returns the slice of `array`.
6204      * @example
6205      *
6206      * _.dropRight([1, 2, 3]);
6207      * // => [1, 2]
6208      *
6209      * _.dropRight([1, 2, 3], 2);
6210      * // => [1]
6211      *
6212      * _.dropRight([1, 2, 3], 5);
6213      * // => []
6214      *
6215      * _.dropRight([1, 2, 3], 0);
6216      * // => [1, 2, 3]
6217      */
6218     function dropRight(array, n, guard) {
6219       var length = array ? array.length : 0;
6220       if (!length) {
6221         return [];
6222       }
6223       n = (guard || n === undefined) ? 1 : toInteger(n);
6224       n = length - n;
6225       return baseSlice(array, 0, n < 0 ? 0 : n);
6226     }
6227
6228     /**
6229      * Creates a slice of `array` excluding elements dropped from the end.
6230      * Elements are dropped until `predicate` returns falsey. The predicate is
6231      * invoked with three arguments: (value, index, array).
6232      *
6233      * @static
6234      * @memberOf _
6235      * @since 3.0.0
6236      * @category Array
6237      * @param {Array} array The array to query.
6238      * @param {Array|Function|Object|string} [predicate=_.identity]
6239      *  The function invoked per iteration.
6240      * @returns {Array} Returns the slice of `array`.
6241      * @example
6242      *
6243      * var users = [
6244      *   { 'user': 'barney',  'active': true },
6245      *   { 'user': 'fred',    'active': false },
6246      *   { 'user': 'pebbles', 'active': false }
6247      * ];
6248      *
6249      * _.dropRightWhile(users, function(o) { return !o.active; });
6250      * // => objects for ['barney']
6251      *
6252      * // The `_.matches` iteratee shorthand.
6253      * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
6254      * // => objects for ['barney', 'fred']
6255      *
6256      * // The `_.matchesProperty` iteratee shorthand.
6257      * _.dropRightWhile(users, ['active', false]);
6258      * // => objects for ['barney']
6259      *
6260      * // The `_.property` iteratee shorthand.
6261      * _.dropRightWhile(users, 'active');
6262      * // => objects for ['barney', 'fred', 'pebbles']
6263      */
6264     function dropRightWhile(array, predicate) {
6265       return (array && array.length)
6266         ? baseWhile(array, getIteratee(predicate, 3), true, true)
6267         : [];
6268     }
6269
6270     /**
6271      * Creates a slice of `array` excluding elements dropped from the beginning.
6272      * Elements are dropped until `predicate` returns falsey. The predicate is
6273      * invoked with three arguments: (value, index, array).
6274      *
6275      * @static
6276      * @memberOf _
6277      * @since 3.0.0
6278      * @category Array
6279      * @param {Array} array The array to query.
6280      * @param {Array|Function|Object|string} [predicate=_.identity]
6281      *  The function invoked per iteration.
6282      * @returns {Array} Returns the slice of `array`.
6283      * @example
6284      *
6285      * var users = [
6286      *   { 'user': 'barney',  'active': false },
6287      *   { 'user': 'fred',    'active': false },
6288      *   { 'user': 'pebbles', 'active': true }
6289      * ];
6290      *
6291      * _.dropWhile(users, function(o) { return !o.active; });
6292      * // => objects for ['pebbles']
6293      *
6294      * // The `_.matches` iteratee shorthand.
6295      * _.dropWhile(users, { 'user': 'barney', 'active': false });
6296      * // => objects for ['fred', 'pebbles']
6297      *
6298      * // The `_.matchesProperty` iteratee shorthand.
6299      * _.dropWhile(users, ['active', false]);
6300      * // => objects for ['pebbles']
6301      *
6302      * // The `_.property` iteratee shorthand.
6303      * _.dropWhile(users, 'active');
6304      * // => objects for ['barney', 'fred', 'pebbles']
6305      */
6306     function dropWhile(array, predicate) {
6307       return (array && array.length)
6308         ? baseWhile(array, getIteratee(predicate, 3), true)
6309         : [];
6310     }
6311
6312     /**
6313      * Fills elements of `array` with `value` from `start` up to, but not
6314      * including, `end`.
6315      *
6316      * **Note:** This method mutates `array`.
6317      *
6318      * @static
6319      * @memberOf _
6320      * @since 3.2.0
6321      * @category Array
6322      * @param {Array} array The array to fill.
6323      * @param {*} value The value to fill `array` with.
6324      * @param {number} [start=0] The start position.
6325      * @param {number} [end=array.length] The end position.
6326      * @returns {Array} Returns `array`.
6327      * @example
6328      *
6329      * var array = [1, 2, 3];
6330      *
6331      * _.fill(array, 'a');
6332      * console.log(array);
6333      * // => ['a', 'a', 'a']
6334      *
6335      * _.fill(Array(3), 2);
6336      * // => [2, 2, 2]
6337      *
6338      * _.fill([4, 6, 8, 10], '*', 1, 3);
6339      * // => [4, '*', '*', 10]
6340      */
6341     function fill(array, value, start, end) {
6342       var length = array ? array.length : 0;
6343       if (!length) {
6344         return [];
6345       }
6346       if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
6347         start = 0;
6348         end = length;
6349       }
6350       return baseFill(array, value, start, end);
6351     }
6352
6353     /**
6354      * This method is like `_.find` except that it returns the index of the first
6355      * element `predicate` returns truthy for instead of the element itself.
6356      *
6357      * @static
6358      * @memberOf _
6359      * @since 1.1.0
6360      * @category Array
6361      * @param {Array} array The array to search.
6362      * @param {Array|Function|Object|string} [predicate=_.identity]
6363      *  The function invoked per iteration.
6364      * @returns {number} Returns the index of the found element, else `-1`.
6365      * @example
6366      *
6367      * var users = [
6368      *   { 'user': 'barney',  'active': false },
6369      *   { 'user': 'fred',    'active': false },
6370      *   { 'user': 'pebbles', 'active': true }
6371      * ];
6372      *
6373      * _.findIndex(users, function(o) { return o.user == 'barney'; });
6374      * // => 0
6375      *
6376      * // The `_.matches` iteratee shorthand.
6377      * _.findIndex(users, { 'user': 'fred', 'active': false });
6378      * // => 1
6379      *
6380      * // The `_.matchesProperty` iteratee shorthand.
6381      * _.findIndex(users, ['active', false]);
6382      * // => 0
6383      *
6384      * // The `_.property` iteratee shorthand.
6385      * _.findIndex(users, 'active');
6386      * // => 2
6387      */
6388     function findIndex(array, predicate) {
6389       return (array && array.length)
6390         ? baseFindIndex(array, getIteratee(predicate, 3))
6391         : -1;
6392     }
6393
6394     /**
6395      * This method is like `_.findIndex` except that it iterates over elements
6396      * of `collection` from right to left.
6397      *
6398      * @static
6399      * @memberOf _
6400      * @since 2.0.0
6401      * @category Array
6402      * @param {Array} array The array to search.
6403      * @param {Array|Function|Object|string} [predicate=_.identity]
6404      *  The function invoked per iteration.
6405      * @returns {number} Returns the index of the found element, else `-1`.
6406      * @example
6407      *
6408      * var users = [
6409      *   { 'user': 'barney',  'active': true },
6410      *   { 'user': 'fred',    'active': false },
6411      *   { 'user': 'pebbles', 'active': false }
6412      * ];
6413      *
6414      * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
6415      * // => 2
6416      *
6417      * // The `_.matches` iteratee shorthand.
6418      * _.findLastIndex(users, { 'user': 'barney', 'active': true });
6419      * // => 0
6420      *
6421      * // The `_.matchesProperty` iteratee shorthand.
6422      * _.findLastIndex(users, ['active', false]);
6423      * // => 2
6424      *
6425      * // The `_.property` iteratee shorthand.
6426      * _.findLastIndex(users, 'active');
6427      * // => 0
6428      */
6429     function findLastIndex(array, predicate) {
6430       return (array && array.length)
6431         ? baseFindIndex(array, getIteratee(predicate, 3), true)
6432         : -1;
6433     }
6434
6435     /**
6436      * Flattens `array` a single level deep.
6437      *
6438      * @static
6439      * @memberOf _
6440      * @since 0.1.0
6441      * @category Array
6442      * @param {Array} array The array to flatten.
6443      * @returns {Array} Returns the new flattened array.
6444      * @example
6445      *
6446      * _.flatten([1, [2, [3, [4]], 5]]);
6447      * // => [1, 2, [3, [4]], 5]
6448      */
6449     function flatten(array) {
6450       var length = array ? array.length : 0;
6451       return length ? baseFlatten(array, 1) : [];
6452     }
6453
6454     /**
6455      * Recursively flattens `array`.
6456      *
6457      * @static
6458      * @memberOf _
6459      * @since 3.0.0
6460      * @category Array
6461      * @param {Array} array The array to flatten.
6462      * @returns {Array} Returns the new flattened array.
6463      * @example
6464      *
6465      * _.flattenDeep([1, [2, [3, [4]], 5]]);
6466      * // => [1, 2, 3, 4, 5]
6467      */
6468     function flattenDeep(array) {
6469       var length = array ? array.length : 0;
6470       return length ? baseFlatten(array, INFINITY) : [];
6471     }
6472
6473     /**
6474      * Recursively flatten `array` up to `depth` times.
6475      *
6476      * @static
6477      * @memberOf _
6478      * @since 4.4.0
6479      * @category Array
6480      * @param {Array} array The array to flatten.
6481      * @param {number} [depth=1] The maximum recursion depth.
6482      * @returns {Array} Returns the new flattened array.
6483      * @example
6484      *
6485      * var array = [1, [2, [3, [4]], 5]];
6486      *
6487      * _.flattenDepth(array, 1);
6488      * // => [1, 2, [3, [4]], 5]
6489      *
6490      * _.flattenDepth(array, 2);
6491      * // => [1, 2, 3, [4], 5]
6492      */
6493     function flattenDepth(array, depth) {
6494       var length = array ? array.length : 0;
6495       if (!length) {
6496         return [];
6497       }
6498       depth = depth === undefined ? 1 : toInteger(depth);
6499       return baseFlatten(array, depth);
6500     }
6501
6502     /**
6503      * The inverse of `_.toPairs`; this method returns an object composed
6504      * from key-value `pairs`.
6505      *
6506      * @static
6507      * @memberOf _
6508      * @since 4.0.0
6509      * @category Array
6510      * @param {Array} pairs The key-value pairs.
6511      * @returns {Object} Returns the new object.
6512      * @example
6513      *
6514      * _.fromPairs([['fred', 30], ['barney', 40]]);
6515      * // => { 'fred': 30, 'barney': 40 }
6516      */
6517     function fromPairs(pairs) {
6518       var index = -1,
6519           length = pairs ? pairs.length : 0,
6520           result = {};
6521
6522       while (++index < length) {
6523         var pair = pairs[index];
6524         result[pair[0]] = pair[1];
6525       }
6526       return result;
6527     }
6528
6529     /**
6530      * Gets the first element of `array`.
6531      *
6532      * @static
6533      * @memberOf _
6534      * @since 0.1.0
6535      * @alias first
6536      * @category Array
6537      * @param {Array} array The array to query.
6538      * @returns {*} Returns the first element of `array`.
6539      * @example
6540      *
6541      * _.head([1, 2, 3]);
6542      * // => 1
6543      *
6544      * _.head([]);
6545      * // => undefined
6546      */
6547     function head(array) {
6548       return (array && array.length) ? array[0] : undefined;
6549     }
6550
6551     /**
6552      * Gets the index at which the first occurrence of `value` is found in `array`
6553      * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
6554      * for equality comparisons. If `fromIndex` is negative, it's used as the
6555      * offset from the end of `array`.
6556      *
6557      * @static
6558      * @memberOf _
6559      * @since 0.1.0
6560      * @category Array
6561      * @param {Array} array The array to search.
6562      * @param {*} value The value to search for.
6563      * @param {number} [fromIndex=0] The index to search from.
6564      * @returns {number} Returns the index of the matched value, else `-1`.
6565      * @example
6566      *
6567      * _.indexOf([1, 2, 1, 2], 2);
6568      * // => 1
6569      *
6570      * // Search from the `fromIndex`.
6571      * _.indexOf([1, 2, 1, 2], 2, 2);
6572      * // => 3
6573      */
6574     function indexOf(array, value, fromIndex) {
6575       var length = array ? array.length : 0;
6576       if (!length) {
6577         return -1;
6578       }
6579       fromIndex = toInteger(fromIndex);
6580       if (fromIndex < 0) {
6581         fromIndex = nativeMax(length + fromIndex, 0);
6582       }
6583       return baseIndexOf(array, value, fromIndex);
6584     }
6585
6586     /**
6587      * Gets all but the last element of `array`.
6588      *
6589      * @static
6590      * @memberOf _
6591      * @since 0.1.0
6592      * @category Array
6593      * @param {Array} array The array to query.
6594      * @returns {Array} Returns the slice of `array`.
6595      * @example
6596      *
6597      * _.initial([1, 2, 3]);
6598      * // => [1, 2]
6599      */
6600     function initial(array) {
6601       return dropRight(array, 1);
6602     }
6603
6604     /**
6605      * Creates an array of unique values that are included in all given arrays
6606      * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
6607      * for equality comparisons. The order of result values is determined by the
6608      * order they occur in the first array.
6609      *
6610      * @static
6611      * @memberOf _
6612      * @since 0.1.0
6613      * @category Array
6614      * @param {...Array} [arrays] The arrays to inspect.
6615      * @returns {Array} Returns the new array of intersecting values.
6616      * @example
6617      *
6618      * _.intersection([2, 1], [4, 2], [1, 2]);
6619      * // => [2]
6620      */
6621     var intersection = rest(function(arrays) {
6622       var mapped = arrayMap(arrays, castArrayLikeObject);
6623       return (mapped.length && mapped[0] === arrays[0])
6624         ? baseIntersection(mapped)
6625         : [];
6626     });
6627
6628     /**
6629      * This method is like `_.intersection` except that it accepts `iteratee`
6630      * which is invoked for each element of each `arrays` to generate the criterion
6631      * by which they're compared. Result values are chosen from the first array.
6632      * The iteratee is invoked with one argument: (value).
6633      *
6634      * @static
6635      * @memberOf _
6636      * @since 4.0.0
6637      * @category Array
6638      * @param {...Array} [arrays] The arrays to inspect.
6639      * @param {Array|Function|Object|string} [iteratee=_.identity]
6640      *  The iteratee invoked per element.
6641      * @returns {Array} Returns the new array of intersecting values.
6642      * @example
6643      *
6644      * _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
6645      * // => [2.1]
6646      *
6647      * // The `_.property` iteratee shorthand.
6648      * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
6649      * // => [{ 'x': 1 }]
6650      */
6651     var intersectionBy = rest(function(arrays) {
6652       var iteratee = last(arrays),
6653           mapped = arrayMap(arrays, castArrayLikeObject);
6654
6655       if (iteratee === last(mapped)) {
6656         iteratee = undefined;
6657       } else {
6658         mapped.pop();
6659       }
6660       return (mapped.length && mapped[0] === arrays[0])
6661         ? baseIntersection(mapped, getIteratee(iteratee))
6662         : [];
6663     });
6664
6665     /**
6666      * This method is like `_.intersection` except that it accepts `comparator`
6667      * which is invoked to compare elements of `arrays`. Result values are chosen
6668      * from the first array. The comparator is invoked with two arguments:
6669      * (arrVal, othVal).
6670      *
6671      * @static
6672      * @memberOf _
6673      * @since 4.0.0
6674      * @category Array
6675      * @param {...Array} [arrays] The arrays to inspect.
6676      * @param {Function} [comparator] The comparator invoked per element.
6677      * @returns {Array} Returns the new array of intersecting values.
6678      * @example
6679      *
6680      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
6681      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
6682      *
6683      * _.intersectionWith(objects, others, _.isEqual);
6684      * // => [{ 'x': 1, 'y': 2 }]
6685      */
6686     var intersectionWith = rest(function(arrays) {
6687       var comparator = last(arrays),
6688           mapped = arrayMap(arrays, castArrayLikeObject);
6689
6690       if (comparator === last(mapped)) {
6691         comparator = undefined;
6692       } else {
6693         mapped.pop();
6694       }
6695       return (mapped.length && mapped[0] === arrays[0])
6696         ? baseIntersection(mapped, undefined, comparator)
6697         : [];
6698     });
6699
6700     /**
6701      * Converts all elements in `array` into a string separated by `separator`.
6702      *
6703      * @static
6704      * @memberOf _
6705      * @since 4.0.0
6706      * @category Array
6707      * @param {Array} array The array to convert.
6708      * @param {string} [separator=','] The element separator.
6709      * @returns {string} Returns the joined string.
6710      * @example
6711      *
6712      * _.join(['a', 'b', 'c'], '~');
6713      * // => 'a~b~c'
6714      */
6715     function join(array, separator) {
6716       return array ? nativeJoin.call(array, separator) : '';
6717     }
6718
6719     /**
6720      * Gets the last element of `array`.
6721      *
6722      * @static
6723      * @memberOf _
6724      * @since 0.1.0
6725      * @category Array
6726      * @param {Array} array The array to query.
6727      * @returns {*} Returns the last element of `array`.
6728      * @example
6729      *
6730      * _.last([1, 2, 3]);
6731      * // => 3
6732      */
6733     function last(array) {
6734       var length = array ? array.length : 0;
6735       return length ? array[length - 1] : undefined;
6736     }
6737
6738     /**
6739      * This method is like `_.indexOf` except that it iterates over elements of
6740      * `array` from right to left.
6741      *
6742      * @static
6743      * @memberOf _
6744      * @since 0.1.0
6745      * @category Array
6746      * @param {Array} array The array to search.
6747      * @param {*} value The value to search for.
6748      * @param {number} [fromIndex=array.length-1] The index to search from.
6749      * @returns {number} Returns the index of the matched value, else `-1`.
6750      * @example
6751      *
6752      * _.lastIndexOf([1, 2, 1, 2], 2);
6753      * // => 3
6754      *
6755      * // Search from the `fromIndex`.
6756      * _.lastIndexOf([1, 2, 1, 2], 2, 2);
6757      * // => 1
6758      */
6759     function lastIndexOf(array, value, fromIndex) {
6760       var length = array ? array.length : 0;
6761       if (!length) {
6762         return -1;
6763       }
6764       var index = length;
6765       if (fromIndex !== undefined) {
6766         index = toInteger(fromIndex);
6767         index = (
6768           index < 0
6769             ? nativeMax(length + index, 0)
6770             : nativeMin(index, length - 1)
6771         ) + 1;
6772       }
6773       if (value !== value) {
6774         return indexOfNaN(array, index, true);
6775       }
6776       while (index--) {
6777         if (array[index] === value) {
6778           return index;
6779         }
6780       }
6781       return -1;
6782     }
6783
6784     /**
6785      * Gets the nth element of `array`. If `n` is negative, the nth element
6786      * from the end is returned.
6787      *
6788      * @static
6789      * @memberOf _
6790      * @since 4.11.0
6791      * @category Array
6792      * @param {Array} array The array to query.
6793      * @param {number} [n=0] The index of the element to return.
6794      * @returns {*} Returns the nth element of `array`.
6795      * @example
6796      *
6797      * var array = ['a', 'b', 'c', 'd'];
6798      *
6799      * _.nth(array, 1);
6800      * // => 'b'
6801      *
6802      * _.nth(array, -2);
6803      * // => 'c';
6804      */
6805     function nth(array, n) {
6806       return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
6807     }
6808
6809     /**
6810      * Removes all given values from `array` using
6811      * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
6812      * for equality comparisons.
6813      *
6814      * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
6815      * to remove elements from an array by predicate.
6816      *
6817      * @static
6818      * @memberOf _
6819      * @since 2.0.0
6820      * @category Array
6821      * @param {Array} array The array to modify.
6822      * @param {...*} [values] The values to remove.
6823      * @returns {Array} Returns `array`.
6824      * @example
6825      *
6826      * var array = [1, 2, 3, 1, 2, 3];
6827      *
6828      * _.pull(array, 2, 3);
6829      * console.log(array);
6830      * // => [1, 1]
6831      */
6832     var pull = rest(pullAll);
6833
6834     /**
6835      * This method is like `_.pull` except that it accepts an array of values to remove.
6836      *
6837      * **Note:** Unlike `_.difference`, this method mutates `array`.
6838      *
6839      * @static
6840      * @memberOf _
6841      * @since 4.0.0
6842      * @category Array
6843      * @param {Array} array The array to modify.
6844      * @param {Array} values The values to remove.
6845      * @returns {Array} Returns `array`.
6846      * @example
6847      *
6848      * var array = [1, 2, 3, 1, 2, 3];
6849      *
6850      * _.pullAll(array, [2, 3]);
6851      * console.log(array);
6852      * // => [1, 1]
6853      */
6854     function pullAll(array, values) {
6855       return (array && array.length && values && values.length)
6856         ? basePullAll(array, values)
6857         : array;
6858     }
6859
6860     /**
6861      * This method is like `_.pullAll` except that it accepts `iteratee` which is
6862      * invoked for each element of `array` and `values` to generate the criterion
6863      * by which they're compared. The iteratee is invoked with one argument: (value).
6864      *
6865      * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
6866      *
6867      * @static
6868      * @memberOf _
6869      * @since 4.0.0
6870      * @category Array
6871      * @param {Array} array The array to modify.
6872      * @param {Array} values The values to remove.
6873      * @param {Array|Function|Object|string} [iteratee=_.identity]
6874      *  The iteratee invoked per element.
6875      * @returns {Array} Returns `array`.
6876      * @example
6877      *
6878      * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
6879      *
6880      * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
6881      * console.log(array);
6882      * // => [{ 'x': 2 }]
6883      */
6884     function pullAllBy(array, values, iteratee) {
6885       return (array && array.length && values && values.length)
6886         ? basePullAll(array, values, getIteratee(iteratee))
6887         : array;
6888     }
6889
6890     /**
6891      * This method is like `_.pullAll` except that it accepts `comparator` which
6892      * is invoked to compare elements of `array` to `values`. The comparator is
6893      * invoked with two arguments: (arrVal, othVal).
6894      *
6895      * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
6896      *
6897      * @static
6898      * @memberOf _
6899      * @since 4.6.0
6900      * @category Array
6901      * @param {Array} array The array to modify.
6902      * @param {Array} values The values to remove.
6903      * @param {Function} [comparator] The comparator invoked per element.
6904      * @returns {Array} Returns `array`.
6905      * @example
6906      *
6907      * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
6908      *
6909      * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
6910      * console.log(array);
6911      * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
6912      */
6913     function pullAllWith(array, values, comparator) {
6914       return (array && array.length && values && values.length)
6915         ? basePullAll(array, values, undefined, comparator)
6916         : array;
6917     }
6918
6919     /**
6920      * Removes elements from `array` corresponding to `indexes` and returns an
6921      * array of removed elements.
6922      *
6923      * **Note:** Unlike `_.at`, this method mutates `array`.
6924      *
6925      * @static
6926      * @memberOf _
6927      * @since 3.0.0
6928      * @category Array
6929      * @param {Array} array The array to modify.
6930      * @param {...(number|number[])} [indexes] The indexes of elements to remove.
6931      * @returns {Array} Returns the new array of removed elements.
6932      * @example
6933      *
6934      * var array = [5, 10, 15, 20];
6935      * var evens = _.pullAt(array, 1, 3);
6936      *
6937      * console.log(array);
6938      * // => [5, 15]
6939      *
6940      * console.log(evens);
6941      * // => [10, 20]
6942      */
6943     var pullAt = rest(function(array, indexes) {
6944       indexes = baseFlatten(indexes, 1);
6945
6946       var length = array ? array.length : 0,
6947           result = baseAt(array, indexes);
6948
6949       basePullAt(array, arrayMap(indexes, function(index) {
6950         return isIndex(index, length) ? +index : index;
6951       }).sort(compareAscending));
6952
6953       return result;
6954     });
6955
6956     /**
6957      * Removes all elements from `array` that `predicate` returns truthy for
6958      * and returns an array of the removed elements. The predicate is invoked
6959      * with three arguments: (value, index, array).
6960      *
6961      * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
6962      * to pull elements from an array by value.
6963      *
6964      * @static
6965      * @memberOf _
6966      * @since 2.0.0
6967      * @category Array
6968      * @param {Array} array The array to modify.
6969      * @param {Array|Function|Object|string} [predicate=_.identity]
6970      *  The function invoked per iteration.
6971      * @returns {Array} Returns the new array of removed elements.
6972      * @example
6973      *
6974      * var array = [1, 2, 3, 4];
6975      * var evens = _.remove(array, function(n) {
6976      *   return n % 2 == 0;
6977      * });
6978      *
6979      * console.log(array);
6980      * // => [1, 3]
6981      *
6982      * console.log(evens);
6983      * // => [2, 4]
6984      */
6985     function remove(array, predicate) {
6986       var result = [];
6987       if (!(array && array.length)) {
6988         return result;
6989       }
6990       var index = -1,
6991           indexes = [],
6992           length = array.length;
6993
6994       predicate = getIteratee(predicate, 3);
6995       while (++index < length) {
6996         var value = array[index];
6997         if (predicate(value, index, array)) {
6998           result.push(value);
6999           indexes.push(index);
7000         }
7001       }
7002       basePullAt(array, indexes);
7003       return result;
7004     }
7005
7006     /**
7007      * Reverses `array` so that the first element becomes the last, the second
7008      * element becomes the second to last, and so on.
7009      *
7010      * **Note:** This method mutates `array` and is based on
7011      * [`Array#reverse`](https://mdn.io/Array/reverse).
7012      *
7013      * @static
7014      * @memberOf _
7015      * @since 4.0.0
7016      * @category Array
7017      * @param {Array} array The array to modify.
7018      * @returns {Array} Returns `array`.
7019      * @example
7020      *
7021      * var array = [1, 2, 3];
7022      *
7023      * _.reverse(array);
7024      * // => [3, 2, 1]
7025      *
7026      * console.log(array);
7027      * // => [3, 2, 1]
7028      */
7029     function reverse(array) {
7030       return array ? nativeReverse.call(array) : array;
7031     }
7032
7033     /**
7034      * Creates a slice of `array` from `start` up to, but not including, `end`.
7035      *
7036      * **Note:** This method is used instead of
7037      * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
7038      * returned.
7039      *
7040      * @static
7041      * @memberOf _
7042      * @since 3.0.0
7043      * @category Array
7044      * @param {Array} array The array to slice.
7045      * @param {number} [start=0] The start position.
7046      * @param {number} [end=array.length] The end position.
7047      * @returns {Array} Returns the slice of `array`.
7048      */
7049     function slice(array, start, end) {
7050       var length = array ? array.length : 0;
7051       if (!length) {
7052         return [];
7053       }
7054       if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
7055         start = 0;
7056         end = length;
7057       }
7058       else {
7059         start = start == null ? 0 : toInteger(start);
7060         end = end === undefined ? length : toInteger(end);
7061       }
7062       return baseSlice(array, start, end);
7063     }
7064
7065     /**
7066      * Uses a binary search to determine the lowest index at which `value`
7067      * should be inserted into `array` in order to maintain its sort order.
7068      *
7069      * @static
7070      * @memberOf _
7071      * @since 0.1.0
7072      * @category Array
7073      * @param {Array} array The sorted array to inspect.
7074      * @param {*} value The value to evaluate.
7075      * @returns {number} Returns the index at which `value` should be inserted
7076      *  into `array`.
7077      * @example
7078      *
7079      * _.sortedIndex([30, 50], 40);
7080      * // => 1
7081      *
7082      * _.sortedIndex([4, 5], 4);
7083      * // => 0
7084      */
7085     function sortedIndex(array, value) {
7086       return baseSortedIndex(array, value);
7087     }
7088
7089     /**
7090      * This method is like `_.sortedIndex` except that it accepts `iteratee`
7091      * which is invoked for `value` and each element of `array` to compute their
7092      * sort ranking. The iteratee is invoked with one argument: (value).
7093      *
7094      * @static
7095      * @memberOf _
7096      * @since 4.0.0
7097      * @category Array
7098      * @param {Array} array The sorted array to inspect.
7099      * @param {*} value The value to evaluate.
7100      * @param {Array|Function|Object|string} [iteratee=_.identity]
7101      *  The iteratee invoked per element.
7102      * @returns {number} Returns the index at which `value` should be inserted
7103      *  into `array`.
7104      * @example
7105      *
7106      * var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 };
7107      *
7108      * _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict));
7109      * // => 1
7110      *
7111      * // The `_.property` iteratee shorthand.
7112      * _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
7113      * // => 0
7114      */
7115     function sortedIndexBy(array, value, iteratee) {
7116       return baseSortedIndexBy(array, value, getIteratee(iteratee));
7117     }
7118
7119     /**
7120      * This method is like `_.indexOf` except that it performs a binary
7121      * search on a sorted `array`.
7122      *
7123      * @static
7124      * @memberOf _
7125      * @since 4.0.0
7126      * @category Array
7127      * @param {Array} array The array to search.
7128      * @param {*} value The value to search for.
7129      * @returns {number} Returns the index of the matched value, else `-1`.
7130      * @example
7131      *
7132      * _.sortedIndexOf([1, 1, 2, 2], 2);
7133      * // => 2
7134      */
7135     function sortedIndexOf(array, value) {
7136       var length = array ? array.length : 0;
7137       if (length) {
7138         var index = baseSortedIndex(array, value);
7139         if (index < length && eq(array[index], value)) {
7140           return index;
7141         }
7142       }
7143       return -1;
7144     }
7145
7146     /**
7147      * This method is like `_.sortedIndex` except that it returns the highest
7148      * index at which `value` should be inserted into `array` in order to
7149      * maintain its sort order.
7150      *
7151      * @static
7152      * @memberOf _
7153      * @since 3.0.0
7154      * @category Array
7155      * @param {Array} array The sorted array to inspect.
7156      * @param {*} value The value to evaluate.
7157      * @returns {number} Returns the index at which `value` should be inserted
7158      *  into `array`.
7159      * @example
7160      *
7161      * _.sortedLastIndex([4, 5], 4);
7162      * // => 1
7163      */
7164     function sortedLastIndex(array, value) {
7165       return baseSortedIndex(array, value, true);
7166     }
7167
7168     /**
7169      * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
7170      * which is invoked for `value` and each element of `array` to compute their
7171      * sort ranking. The iteratee is invoked with one argument: (value).
7172      *
7173      * @static
7174      * @memberOf _
7175      * @since 4.0.0
7176      * @category Array
7177      * @param {Array} array The sorted array to inspect.
7178      * @param {*} value The value to evaluate.
7179      * @param {Array|Function|Object|string} [iteratee=_.identity]
7180      *  The iteratee invoked per element.
7181      * @returns {number} Returns the index at which `value` should be inserted
7182      *  into `array`.
7183      * @example
7184      *
7185      * // The `_.property` iteratee shorthand.
7186      * _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
7187      * // => 1
7188      */
7189     function sortedLastIndexBy(array, value, iteratee) {
7190       return baseSortedIndexBy(array, value, getIteratee(iteratee), true);
7191     }
7192
7193     /**
7194      * This method is like `_.lastIndexOf` except that it performs a binary
7195      * search on a sorted `array`.
7196      *
7197      * @static
7198      * @memberOf _
7199      * @since 4.0.0
7200      * @category Array
7201      * @param {Array} array The array to search.
7202      * @param {*} value The value to search for.
7203      * @returns {number} Returns the index of the matched value, else `-1`.
7204      * @example
7205      *
7206      * _.sortedLastIndexOf([1, 1, 2, 2], 2);
7207      * // => 3
7208      */
7209     function sortedLastIndexOf(array, value) {
7210       var length = array ? array.length : 0;
7211       if (length) {
7212         var index = baseSortedIndex(array, value, true) - 1;
7213         if (eq(array[index], value)) {
7214           return index;
7215         }
7216       }
7217       return -1;
7218     }
7219
7220     /**
7221      * This method is like `_.uniq` except that it's designed and optimized
7222      * for sorted arrays.
7223      *
7224      * @static
7225      * @memberOf _
7226      * @since 4.0.0
7227      * @category Array
7228      * @param {Array} array The array to inspect.
7229      * @returns {Array} Returns the new duplicate free array.
7230      * @example
7231      *
7232      * _.sortedUniq([1, 1, 2]);
7233      * // => [1, 2]
7234      */
7235     function sortedUniq(array) {
7236       return (array && array.length)
7237         ? baseSortedUniq(array)
7238         : [];
7239     }
7240
7241     /**
7242      * This method is like `_.uniqBy` except that it's designed and optimized
7243      * for sorted arrays.
7244      *
7245      * @static
7246      * @memberOf _
7247      * @since 4.0.0
7248      * @category Array
7249      * @param {Array} array The array to inspect.
7250      * @param {Function} [iteratee] The iteratee invoked per element.
7251      * @returns {Array} Returns the new duplicate free array.
7252      * @example
7253      *
7254      * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
7255      * // => [1.1, 2.3]
7256      */
7257     function sortedUniqBy(array, iteratee) {
7258       return (array && array.length)
7259         ? baseSortedUniq(array, getIteratee(iteratee))
7260         : [];
7261     }
7262
7263     /**
7264      * Gets all but the first element of `array`.
7265      *
7266      * @static
7267      * @memberOf _
7268      * @since 4.0.0
7269      * @category Array
7270      * @param {Array} array The array to query.
7271      * @returns {Array} Returns the slice of `array`.
7272      * @example
7273      *
7274      * _.tail([1, 2, 3]);
7275      * // => [2, 3]
7276      */
7277     function tail(array) {
7278       return drop(array, 1);
7279     }
7280
7281     /**
7282      * Creates a slice of `array` with `n` elements taken from the beginning.
7283      *
7284      * @static
7285      * @memberOf _
7286      * @since 0.1.0
7287      * @category Array
7288      * @param {Array} array The array to query.
7289      * @param {number} [n=1] The number of elements to take.
7290      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7291      * @returns {Array} Returns the slice of `array`.
7292      * @example
7293      *
7294      * _.take([1, 2, 3]);
7295      * // => [1]
7296      *
7297      * _.take([1, 2, 3], 2);
7298      * // => [1, 2]
7299      *
7300      * _.take([1, 2, 3], 5);
7301      * // => [1, 2, 3]
7302      *
7303      * _.take([1, 2, 3], 0);
7304      * // => []
7305      */
7306     function take(array, n, guard) {
7307       if (!(array && array.length)) {
7308         return [];
7309       }
7310       n = (guard || n === undefined) ? 1 : toInteger(n);
7311       return baseSlice(array, 0, n < 0 ? 0 : n);
7312     }
7313
7314     /**
7315      * Creates a slice of `array` with `n` elements taken from the end.
7316      *
7317      * @static
7318      * @memberOf _
7319      * @since 3.0.0
7320      * @category Array
7321      * @param {Array} array The array to query.
7322      * @param {number} [n=1] The number of elements to take.
7323      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7324      * @returns {Array} Returns the slice of `array`.
7325      * @example
7326      *
7327      * _.takeRight([1, 2, 3]);
7328      * // => [3]
7329      *
7330      * _.takeRight([1, 2, 3], 2);
7331      * // => [2, 3]
7332      *
7333      * _.takeRight([1, 2, 3], 5);
7334      * // => [1, 2, 3]
7335      *
7336      * _.takeRight([1, 2, 3], 0);
7337      * // => []
7338      */
7339     function takeRight(array, n, guard) {
7340       var length = array ? array.length : 0;
7341       if (!length) {
7342         return [];
7343       }
7344       n = (guard || n === undefined) ? 1 : toInteger(n);
7345       n = length - n;
7346       return baseSlice(array, n < 0 ? 0 : n, length);
7347     }
7348
7349     /**
7350      * Creates a slice of `array` with elements taken from the end. Elements are
7351      * taken until `predicate` returns falsey. The predicate is invoked with
7352      * three arguments: (value, index, array).
7353      *
7354      * @static
7355      * @memberOf _
7356      * @since 3.0.0
7357      * @category Array
7358      * @param {Array} array The array to query.
7359      * @param {Array|Function|Object|string} [predicate=_.identity]
7360      *  The function invoked per iteration.
7361      * @returns {Array} Returns the slice of `array`.
7362      * @example
7363      *
7364      * var users = [
7365      *   { 'user': 'barney',  'active': true },
7366      *   { 'user': 'fred',    'active': false },
7367      *   { 'user': 'pebbles', 'active': false }
7368      * ];
7369      *
7370      * _.takeRightWhile(users, function(o) { return !o.active; });
7371      * // => objects for ['fred', 'pebbles']
7372      *
7373      * // The `_.matches` iteratee shorthand.
7374      * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
7375      * // => objects for ['pebbles']
7376      *
7377      * // The `_.matchesProperty` iteratee shorthand.
7378      * _.takeRightWhile(users, ['active', false]);
7379      * // => objects for ['fred', 'pebbles']
7380      *
7381      * // The `_.property` iteratee shorthand.
7382      * _.takeRightWhile(users, 'active');
7383      * // => []
7384      */
7385     function takeRightWhile(array, predicate) {
7386       return (array && array.length)
7387         ? baseWhile(array, getIteratee(predicate, 3), false, true)
7388         : [];
7389     }
7390
7391     /**
7392      * Creates a slice of `array` with elements taken from the beginning. Elements
7393      * are taken until `predicate` returns falsey. The predicate is invoked with
7394      * three arguments: (value, index, array).
7395      *
7396      * @static
7397      * @memberOf _
7398      * @since 3.0.0
7399      * @category Array
7400      * @param {Array} array The array to query.
7401      * @param {Array|Function|Object|string} [predicate=_.identity]
7402      *  The function invoked per iteration.
7403      * @returns {Array} Returns the slice of `array`.
7404      * @example
7405      *
7406      * var users = [
7407      *   { 'user': 'barney',  'active': false },
7408      *   { 'user': 'fred',    'active': false},
7409      *   { 'user': 'pebbles', 'active': true }
7410      * ];
7411      *
7412      * _.takeWhile(users, function(o) { return !o.active; });
7413      * // => objects for ['barney', 'fred']
7414      *
7415      * // The `_.matches` iteratee shorthand.
7416      * _.takeWhile(users, { 'user': 'barney', 'active': false });
7417      * // => objects for ['barney']
7418      *
7419      * // The `_.matchesProperty` iteratee shorthand.
7420      * _.takeWhile(users, ['active', false]);
7421      * // => objects for ['barney', 'fred']
7422      *
7423      * // The `_.property` iteratee shorthand.
7424      * _.takeWhile(users, 'active');
7425      * // => []
7426      */
7427     function takeWhile(array, predicate) {
7428       return (array && array.length)
7429         ? baseWhile(array, getIteratee(predicate, 3))
7430         : [];
7431     }
7432
7433     /**
7434      * Creates an array of unique values, in order, from all given arrays using
7435      * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
7436      * for equality comparisons.
7437      *
7438      * @static
7439      * @memberOf _
7440      * @since 0.1.0
7441      * @category Array
7442      * @param {...Array} [arrays] The arrays to inspect.
7443      * @returns {Array} Returns the new array of combined values.
7444      * @example
7445      *
7446      * _.union([2, 1], [4, 2], [1, 2]);
7447      * // => [2, 1, 4]
7448      */
7449     var union = rest(function(arrays) {
7450       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
7451     });
7452
7453     /**
7454      * This method is like `_.union` except that it accepts `iteratee` which is
7455      * invoked for each element of each `arrays` to generate the criterion by
7456      * which uniqueness is computed. The iteratee is invoked with one argument:
7457      * (value).
7458      *
7459      * @static
7460      * @memberOf _
7461      * @since 4.0.0
7462      * @category Array
7463      * @param {...Array} [arrays] The arrays to inspect.
7464      * @param {Array|Function|Object|string} [iteratee=_.identity]
7465      *  The iteratee invoked per element.
7466      * @returns {Array} Returns the new array of combined values.
7467      * @example
7468      *
7469      * _.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
7470      * // => [2.1, 1.2, 4.3]
7471      *
7472      * // The `_.property` iteratee shorthand.
7473      * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7474      * // => [{ 'x': 1 }, { 'x': 2 }]
7475      */
7476     var unionBy = rest(function(arrays) {
7477       var iteratee = last(arrays);
7478       if (isArrayLikeObject(iteratee)) {
7479         iteratee = undefined;
7480       }
7481       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee));
7482     });
7483
7484     /**
7485      * This method is like `_.union` except that it accepts `comparator` which
7486      * is invoked to compare elements of `arrays`. The comparator is invoked
7487      * with two arguments: (arrVal, othVal).
7488      *
7489      * @static
7490      * @memberOf _
7491      * @since 4.0.0
7492      * @category Array
7493      * @param {...Array} [arrays] The arrays to inspect.
7494      * @param {Function} [comparator] The comparator invoked per element.
7495      * @returns {Array} Returns the new array of combined values.
7496      * @example
7497      *
7498      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7499      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7500      *
7501      * _.unionWith(objects, others, _.isEqual);
7502      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
7503      */
7504     var unionWith = rest(function(arrays) {
7505       var comparator = last(arrays);
7506       if (isArrayLikeObject(comparator)) {
7507         comparator = undefined;
7508       }
7509       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
7510     });
7511
7512     /**
7513      * Creates a duplicate-free version of an array, using
7514      * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
7515      * for equality comparisons, in which only the first occurrence of each
7516      * element is kept.
7517      *
7518      * @static
7519      * @memberOf _
7520      * @since 0.1.0
7521      * @category Array
7522      * @param {Array} array The array to inspect.
7523      * @returns {Array} Returns the new duplicate free array.
7524      * @example
7525      *
7526      * _.uniq([2, 1, 2]);
7527      * // => [2, 1]
7528      */
7529     function uniq(array) {
7530       return (array && array.length)
7531         ? baseUniq(array)
7532         : [];
7533     }
7534
7535     /**
7536      * This method is like `_.uniq` except that it accepts `iteratee` which is
7537      * invoked for each element in `array` to generate the criterion by which
7538      * uniqueness is computed. The iteratee is invoked with one argument: (value).
7539      *
7540      * @static
7541      * @memberOf _
7542      * @since 4.0.0
7543      * @category Array
7544      * @param {Array} array The array to inspect.
7545      * @param {Array|Function|Object|string} [iteratee=_.identity]
7546      *  The iteratee invoked per element.
7547      * @returns {Array} Returns the new duplicate free array.
7548      * @example
7549      *
7550      * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
7551      * // => [2.1, 1.2]
7552      *
7553      * // The `_.property` iteratee shorthand.
7554      * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
7555      * // => [{ 'x': 1 }, { 'x': 2 }]
7556      */
7557     function uniqBy(array, iteratee) {
7558       return (array && array.length)
7559         ? baseUniq(array, getIteratee(iteratee))
7560         : [];
7561     }
7562
7563     /**
7564      * This method is like `_.uniq` except that it accepts `comparator` which
7565      * is invoked to compare elements of `array`. The comparator is invoked with
7566      * two arguments: (arrVal, othVal).
7567      *
7568      * @static
7569      * @memberOf _
7570      * @since 4.0.0
7571      * @category Array
7572      * @param {Array} array The array to inspect.
7573      * @param {Function} [comparator] The comparator invoked per element.
7574      * @returns {Array} Returns the new duplicate free array.
7575      * @example
7576      *
7577      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 },  { 'x': 1, 'y': 2 }];
7578      *
7579      * _.uniqWith(objects, _.isEqual);
7580      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
7581      */
7582     function uniqWith(array, comparator) {
7583       return (array && array.length)
7584         ? baseUniq(array, undefined, comparator)
7585         : [];
7586     }
7587
7588     /**
7589      * This method is like `_.zip` except that it accepts an array of grouped
7590      * elements and creates an array regrouping the elements to their pre-zip
7591      * configuration.
7592      *
7593      * @static
7594      * @memberOf _
7595      * @since 1.2.0
7596      * @category Array
7597      * @param {Array} array The array of grouped elements to process.
7598      * @returns {Array} Returns the new array of regrouped elements.
7599      * @example
7600      *
7601      * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
7602      * // => [['fred', 30, true], ['barney', 40, false]]
7603      *
7604      * _.unzip(zipped);
7605      * // => [['fred', 'barney'], [30, 40], [true, false]]
7606      */
7607     function unzip(array) {
7608       if (!(array && array.length)) {
7609         return [];
7610       }
7611       var length = 0;
7612       array = arrayFilter(array, function(group) {
7613         if (isArrayLikeObject(group)) {
7614           length = nativeMax(group.length, length);
7615           return true;
7616         }
7617       });
7618       return baseTimes(length, function(index) {
7619         return arrayMap(array, baseProperty(index));
7620       });
7621     }
7622
7623     /**
7624      * This method is like `_.unzip` except that it accepts `iteratee` to specify
7625      * how regrouped values should be combined. The iteratee is invoked with the
7626      * elements of each group: (...group).
7627      *
7628      * @static
7629      * @memberOf _
7630      * @since 3.8.0
7631      * @category Array
7632      * @param {Array} array The array of grouped elements to process.
7633      * @param {Function} [iteratee=_.identity] The function to combine
7634      *  regrouped values.
7635      * @returns {Array} Returns the new array of regrouped elements.
7636      * @example
7637      *
7638      * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
7639      * // => [[1, 10, 100], [2, 20, 200]]
7640      *
7641      * _.unzipWith(zipped, _.add);
7642      * // => [3, 30, 300]
7643      */
7644     function unzipWith(array, iteratee) {
7645       if (!(array && array.length)) {
7646         return [];
7647       }
7648       var result = unzip(array);
7649       if (iteratee == null) {
7650         return result;
7651       }
7652       return arrayMap(result, function(group) {
7653         return apply(iteratee, undefined, group);
7654       });
7655     }
7656
7657     /**
7658      * Creates an array excluding all given values using
7659      * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
7660      * for equality comparisons.
7661      *
7662      * @static
7663      * @memberOf _
7664      * @since 0.1.0
7665      * @category Array
7666      * @param {Array} array The array to filter.
7667      * @param {...*} [values] The values to exclude.
7668      * @returns {Array} Returns the new array of filtered values.
7669      * @see _.difference, _.xor
7670      * @example
7671      *
7672      * _.without([1, 2, 1, 3], 1, 2);
7673      * // => [3]
7674      */
7675     var without = rest(function(array, values) {
7676       return isArrayLikeObject(array)
7677         ? baseDifference(array, values)
7678         : [];
7679     });
7680
7681     /**
7682      * Creates an array of unique values that is the
7683      * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
7684      * of the given arrays. The order of result values is determined by the order
7685      * they occur in the arrays.
7686      *
7687      * @static
7688      * @memberOf _
7689      * @since 2.4.0
7690      * @category Array
7691      * @param {...Array} [arrays] The arrays to inspect.
7692      * @returns {Array} Returns the new array of values.
7693      * @see _.difference, _.without
7694      * @example
7695      *
7696      * _.xor([2, 1], [4, 2]);
7697      * // => [1, 4]
7698      */
7699     var xor = rest(function(arrays) {
7700       return baseXor(arrayFilter(arrays, isArrayLikeObject));
7701     });
7702
7703     /**
7704      * This method is like `_.xor` except that it accepts `iteratee` which is
7705      * invoked for each element of each `arrays` to generate the criterion by
7706      * which by which they're compared. The iteratee is invoked with one argument:
7707      * (value).
7708      *
7709      * @static
7710      * @memberOf _
7711      * @since 4.0.0
7712      * @category Array
7713      * @param {...Array} [arrays] The arrays to inspect.
7714      * @param {Array|Function|Object|string} [iteratee=_.identity]
7715      *  The iteratee invoked per element.
7716      * @returns {Array} Returns the new array of values.
7717      * @example
7718      *
7719      * _.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor);
7720      * // => [1.2, 4.3]
7721      *
7722      * // The `_.property` iteratee shorthand.
7723      * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7724      * // => [{ 'x': 2 }]
7725      */
7726     var xorBy = rest(function(arrays) {
7727       var iteratee = last(arrays);
7728       if (isArrayLikeObject(iteratee)) {
7729         iteratee = undefined;
7730       }
7731       return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee));
7732     });
7733
7734     /**
7735      * This method is like `_.xor` except that it accepts `comparator` which is
7736      * invoked to compare elements of `arrays`. The comparator is invoked with
7737      * two arguments: (arrVal, othVal).
7738      *
7739      * @static
7740      * @memberOf _
7741      * @since 4.0.0
7742      * @category Array
7743      * @param {...Array} [arrays] The arrays to inspect.
7744      * @param {Function} [comparator] The comparator invoked per element.
7745      * @returns {Array} Returns the new array of values.
7746      * @example
7747      *
7748      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7749      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7750      *
7751      * _.xorWith(objects, others, _.isEqual);
7752      * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
7753      */
7754     var xorWith = rest(function(arrays) {
7755       var comparator = last(arrays);
7756       if (isArrayLikeObject(comparator)) {
7757         comparator = undefined;
7758       }
7759       return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
7760     });
7761
7762     /**
7763      * Creates an array of grouped elements, the first of which contains the
7764      * first elements of the given arrays, the second of which contains the
7765      * second elements of the given arrays, and so on.
7766      *
7767      * @static
7768      * @memberOf _
7769      * @since 0.1.0
7770      * @category Array
7771      * @param {...Array} [arrays] The arrays to process.
7772      * @returns {Array} Returns the new array of grouped elements.
7773      * @example
7774      *
7775      * _.zip(['fred', 'barney'], [30, 40], [true, false]);
7776      * // => [['fred', 30, true], ['barney', 40, false]]
7777      */
7778     var zip = rest(unzip);
7779
7780     /**
7781      * This method is like `_.fromPairs` except that it accepts two arrays,
7782      * one of property identifiers and one of corresponding values.
7783      *
7784      * @static
7785      * @memberOf _
7786      * @since 0.4.0
7787      * @category Array
7788      * @param {Array} [props=[]] The property identifiers.
7789      * @param {Array} [values=[]] The property values.
7790      * @returns {Object} Returns the new object.
7791      * @example
7792      *
7793      * _.zipObject(['a', 'b'], [1, 2]);
7794      * // => { 'a': 1, 'b': 2 }
7795      */
7796     function zipObject(props, values) {
7797       return baseZipObject(props || [], values || [], assignValue);
7798     }
7799
7800     /**
7801      * This method is like `_.zipObject` except that it supports property paths.
7802      *
7803      * @static
7804      * @memberOf _
7805      * @since 4.1.0
7806      * @category Array
7807      * @param {Array} [props=[]] The property identifiers.
7808      * @param {Array} [values=[]] The property values.
7809      * @returns {Object} Returns the new object.
7810      * @example
7811      *
7812      * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
7813      * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
7814      */
7815     function zipObjectDeep(props, values) {
7816       return baseZipObject(props || [], values || [], baseSet);
7817     }
7818
7819     /**
7820      * This method is like `_.zip` except that it accepts `iteratee` to specify
7821      * how grouped values should be combined. The iteratee is invoked with the
7822      * elements of each group: (...group).
7823      *
7824      * @static
7825      * @memberOf _
7826      * @since 3.8.0
7827      * @category Array
7828      * @param {...Array} [arrays] The arrays to process.
7829      * @param {Function} [iteratee=_.identity] The function to combine grouped values.
7830      * @returns {Array} Returns the new array of grouped elements.
7831      * @example
7832      *
7833      * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
7834      *   return a + b + c;
7835      * });
7836      * // => [111, 222]
7837      */
7838     var zipWith = rest(function(arrays) {
7839       var length = arrays.length,
7840           iteratee = length > 1 ? arrays[length - 1] : undefined;
7841
7842       iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
7843       return unzipWith(arrays, iteratee);
7844     });
7845
7846     /*------------------------------------------------------------------------*/
7847
7848     /**
7849      * Creates a `lodash` wrapper instance that wraps `value` with explicit method
7850      * chain sequences enabled. The result of such sequences must be unwrapped
7851      * with `_#value`.
7852      *
7853      * @static
7854      * @memberOf _
7855      * @since 1.3.0
7856      * @category Seq
7857      * @param {*} value The value to wrap.
7858      * @returns {Object} Returns the new `lodash` wrapper instance.
7859      * @example
7860      *
7861      * var users = [
7862      *   { 'user': 'barney',  'age': 36 },
7863      *   { 'user': 'fred',    'age': 40 },
7864      *   { 'user': 'pebbles', 'age': 1 }
7865      * ];
7866      *
7867      * var youngest = _
7868      *   .chain(users)
7869      *   .sortBy('age')
7870      *   .map(function(o) {
7871      *     return o.user + ' is ' + o.age;
7872      *   })
7873      *   .head()
7874      *   .value();
7875      * // => 'pebbles is 1'
7876      */
7877     function chain(value) {
7878       var result = lodash(value);
7879       result.__chain__ = true;
7880       return result;
7881     }
7882
7883     /**
7884      * This method invokes `interceptor` and returns `value`. The interceptor
7885      * is invoked with one argument; (value). The purpose of this method is to
7886      * "tap into" a method chain sequence in order to modify intermediate results.
7887      *
7888      * @static
7889      * @memberOf _
7890      * @since 0.1.0
7891      * @category Seq
7892      * @param {*} value The value to provide to `interceptor`.
7893      * @param {Function} interceptor The function to invoke.
7894      * @returns {*} Returns `value`.
7895      * @example
7896      *
7897      * _([1, 2, 3])
7898      *  .tap(function(array) {
7899      *    // Mutate input array.
7900      *    array.pop();
7901      *  })
7902      *  .reverse()
7903      *  .value();
7904      * // => [2, 1]
7905      */
7906     function tap(value, interceptor) {
7907       interceptor(value);
7908       return value;
7909     }
7910
7911     /**
7912      * This method is like `_.tap` except that it returns the result of `interceptor`.
7913      * The purpose of this method is to "pass thru" values replacing intermediate
7914      * results in a method chain sequence.
7915      *
7916      * @static
7917      * @memberOf _
7918      * @since 3.0.0
7919      * @category Seq
7920      * @param {*} value The value to provide to `interceptor`.
7921      * @param {Function} interceptor The function to invoke.
7922      * @returns {*} Returns the result of `interceptor`.
7923      * @example
7924      *
7925      * _('  abc  ')
7926      *  .chain()
7927      *  .trim()
7928      *  .thru(function(value) {
7929      *    return [value];
7930      *  })
7931      *  .value();
7932      * // => ['abc']
7933      */
7934     function thru(value, interceptor) {
7935       return interceptor(value);
7936     }
7937
7938     /**
7939      * This method is the wrapper version of `_.at`.
7940      *
7941      * @name at
7942      * @memberOf _
7943      * @since 1.0.0
7944      * @category Seq
7945      * @param {...(string|string[])} [paths] The property paths of elements to pick.
7946      * @returns {Object} Returns the new `lodash` wrapper instance.
7947      * @example
7948      *
7949      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
7950      *
7951      * _(object).at(['a[0].b.c', 'a[1]']).value();
7952      * // => [3, 4]
7953      *
7954      * _(['a', 'b', 'c']).at(0, 2).value();
7955      * // => ['a', 'c']
7956      */
7957     var wrapperAt = rest(function(paths) {
7958       paths = baseFlatten(paths, 1);
7959       var length = paths.length,
7960           start = length ? paths[0] : 0,
7961           value = this.__wrapped__,
7962           interceptor = function(object) { return baseAt(object, paths); };
7963
7964       if (length > 1 || this.__actions__.length ||
7965           !(value instanceof LazyWrapper) || !isIndex(start)) {
7966         return this.thru(interceptor);
7967       }
7968       value = value.slice(start, +start + (length ? 1 : 0));
7969       value.__actions__.push({
7970         'func': thru,
7971         'args': [interceptor],
7972         'thisArg': undefined
7973       });
7974       return new LodashWrapper(value, this.__chain__).thru(function(array) {
7975         if (length && !array.length) {
7976           array.push(undefined);
7977         }
7978         return array;
7979       });
7980     });
7981
7982     /**
7983      * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
7984      *
7985      * @name chain
7986      * @memberOf _
7987      * @since 0.1.0
7988      * @category Seq
7989      * @returns {Object} Returns the new `lodash` wrapper instance.
7990      * @example
7991      *
7992      * var users = [
7993      *   { 'user': 'barney', 'age': 36 },
7994      *   { 'user': 'fred',   'age': 40 }
7995      * ];
7996      *
7997      * // A sequence without explicit chaining.
7998      * _(users).head();
7999      * // => { 'user': 'barney', 'age': 36 }
8000      *
8001      * // A sequence with explicit chaining.
8002      * _(users)
8003      *   .chain()
8004      *   .head()
8005      *   .pick('user')
8006      *   .value();
8007      * // => { 'user': 'barney' }
8008      */
8009     function wrapperChain() {
8010       return chain(this);
8011     }
8012
8013     /**
8014      * Executes the chain sequence and returns the wrapped result.
8015      *
8016      * @name commit
8017      * @memberOf _
8018      * @since 3.2.0
8019      * @category Seq
8020      * @returns {Object} Returns the new `lodash` wrapper instance.
8021      * @example
8022      *
8023      * var array = [1, 2];
8024      * var wrapped = _(array).push(3);
8025      *
8026      * console.log(array);
8027      * // => [1, 2]
8028      *
8029      * wrapped = wrapped.commit();
8030      * console.log(array);
8031      * // => [1, 2, 3]
8032      *
8033      * wrapped.last();
8034      * // => 3
8035      *
8036      * console.log(array);
8037      * // => [1, 2, 3]
8038      */
8039     function wrapperCommit() {
8040       return new LodashWrapper(this.value(), this.__chain__);
8041     }
8042
8043     /**
8044      * Gets the next value on a wrapped object following the
8045      * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
8046      *
8047      * @name next
8048      * @memberOf _
8049      * @since 4.0.0
8050      * @category Seq
8051      * @returns {Object} Returns the next iterator value.
8052      * @example
8053      *
8054      * var wrapped = _([1, 2]);
8055      *
8056      * wrapped.next();
8057      * // => { 'done': false, 'value': 1 }
8058      *
8059      * wrapped.next();
8060      * // => { 'done': false, 'value': 2 }
8061      *
8062      * wrapped.next();
8063      * // => { 'done': true, 'value': undefined }
8064      */
8065     function wrapperNext() {
8066       if (this.__values__ === undefined) {
8067         this.__values__ = toArray(this.value());
8068       }
8069       var done = this.__index__ >= this.__values__.length,
8070           value = done ? undefined : this.__values__[this.__index__++];
8071
8072       return { 'done': done, 'value': value };
8073     }
8074
8075     /**
8076      * Enables the wrapper to be iterable.
8077      *
8078      * @name Symbol.iterator
8079      * @memberOf _
8080      * @since 4.0.0
8081      * @category Seq
8082      * @returns {Object} Returns the wrapper object.
8083      * @example
8084      *
8085      * var wrapped = _([1, 2]);
8086      *
8087      * wrapped[Symbol.iterator]() === wrapped;
8088      * // => true
8089      *
8090      * Array.from(wrapped);
8091      * // => [1, 2]
8092      */
8093     function wrapperToIterator() {
8094       return this;
8095     }
8096
8097     /**
8098      * Creates a clone of the chain sequence planting `value` as the wrapped value.
8099      *
8100      * @name plant
8101      * @memberOf _
8102      * @since 3.2.0
8103      * @category Seq
8104      * @param {*} value The value to plant.
8105      * @returns {Object} Returns the new `lodash` wrapper instance.
8106      * @example
8107      *
8108      * function square(n) {
8109      *   return n * n;
8110      * }
8111      *
8112      * var wrapped = _([1, 2]).map(square);
8113      * var other = wrapped.plant([3, 4]);
8114      *
8115      * other.value();
8116      * // => [9, 16]
8117      *
8118      * wrapped.value();
8119      * // => [1, 4]
8120      */
8121     function wrapperPlant(value) {
8122       var result,
8123           parent = this;
8124
8125       while (parent instanceof baseLodash) {
8126         var clone = wrapperClone(parent);
8127         clone.__index__ = 0;
8128         clone.__values__ = undefined;
8129         if (result) {
8130           previous.__wrapped__ = clone;
8131         } else {
8132           result = clone;
8133         }
8134         var previous = clone;
8135         parent = parent.__wrapped__;
8136       }
8137       previous.__wrapped__ = value;
8138       return result;
8139     }
8140
8141     /**
8142      * This method is the wrapper version of `_.reverse`.
8143      *
8144      * **Note:** This method mutates the wrapped array.
8145      *
8146      * @name reverse
8147      * @memberOf _
8148      * @since 0.1.0
8149      * @category Seq
8150      * @returns {Object} Returns the new `lodash` wrapper instance.
8151      * @example
8152      *
8153      * var array = [1, 2, 3];
8154      *
8155      * _(array).reverse().value()
8156      * // => [3, 2, 1]
8157      *
8158      * console.log(array);
8159      * // => [3, 2, 1]
8160      */
8161     function wrapperReverse() {
8162       var value = this.__wrapped__;
8163       if (value instanceof LazyWrapper) {
8164         var wrapped = value;
8165         if (this.__actions__.length) {
8166           wrapped = new LazyWrapper(this);
8167         }
8168         wrapped = wrapped.reverse();
8169         wrapped.__actions__.push({
8170           'func': thru,
8171           'args': [reverse],
8172           'thisArg': undefined
8173         });
8174         return new LodashWrapper(wrapped, this.__chain__);
8175       }
8176       return this.thru(reverse);
8177     }
8178
8179     /**
8180      * Executes the chain sequence to resolve the unwrapped value.
8181      *
8182      * @name value
8183      * @memberOf _
8184      * @since 0.1.0
8185      * @alias toJSON, valueOf
8186      * @category Seq
8187      * @returns {*} Returns the resolved unwrapped value.
8188      * @example
8189      *
8190      * _([1, 2, 3]).value();
8191      * // => [1, 2, 3]
8192      */
8193     function wrapperValue() {
8194       return baseWrapperValue(this.__wrapped__, this.__actions__);
8195     }
8196
8197     /*------------------------------------------------------------------------*/
8198
8199     /**
8200      * Creates an object composed of keys generated from the results of running
8201      * each element of `collection` thru `iteratee`. The corresponding value of
8202      * each key is the number of times the key was returned by `iteratee`. The
8203      * iteratee is invoked with one argument: (value).
8204      *
8205      * @static
8206      * @memberOf _
8207      * @since 0.5.0
8208      * @category Collection
8209      * @param {Array|Object} collection The collection to iterate over.
8210      * @param {Array|Function|Object|string} [iteratee=_.identity]
8211      *  The iteratee to transform keys.
8212      * @returns {Object} Returns the composed aggregate object.
8213      * @example
8214      *
8215      * _.countBy([6.1, 4.2, 6.3], Math.floor);
8216      * // => { '4': 1, '6': 2 }
8217      *
8218      * _.countBy(['one', 'two', 'three'], 'length');
8219      * // => { '3': 2, '5': 1 }
8220      */
8221     var countBy = createAggregator(function(result, value, key) {
8222       hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);
8223     });
8224
8225     /**
8226      * Checks if `predicate` returns truthy for **all** elements of `collection`.
8227      * Iteration is stopped once `predicate` returns falsey. The predicate is
8228      * invoked with three arguments: (value, index|key, collection).
8229      *
8230      * @static
8231      * @memberOf _
8232      * @since 0.1.0
8233      * @category Collection
8234      * @param {Array|Object} collection The collection to iterate over.
8235      * @param {Array|Function|Object|string} [predicate=_.identity]
8236      *  The function invoked per iteration.
8237      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8238      * @returns {boolean} Returns `true` if all elements pass the predicate check,
8239      *  else `false`.
8240      * @example
8241      *
8242      * _.every([true, 1, null, 'yes'], Boolean);
8243      * // => false
8244      *
8245      * var users = [
8246      *   { 'user': 'barney', 'age': 36, 'active': false },
8247      *   { 'user': 'fred',   'age': 40, 'active': false }
8248      * ];
8249      *
8250      * // The `_.matches` iteratee shorthand.
8251      * _.every(users, { 'user': 'barney', 'active': false });
8252      * // => false
8253      *
8254      * // The `_.matchesProperty` iteratee shorthand.
8255      * _.every(users, ['active', false]);
8256      * // => true
8257      *
8258      * // The `_.property` iteratee shorthand.
8259      * _.every(users, 'active');
8260      * // => false
8261      */
8262     function every(collection, predicate, guard) {
8263       var func = isArray(collection) ? arrayEvery : baseEvery;
8264       if (guard && isIterateeCall(collection, predicate, guard)) {
8265         predicate = undefined;
8266       }
8267       return func(collection, getIteratee(predicate, 3));
8268     }
8269
8270     /**
8271      * Iterates over elements of `collection`, returning an array of all elements
8272      * `predicate` returns truthy for. The predicate is invoked with three
8273      * arguments: (value, index|key, collection).
8274      *
8275      * @static
8276      * @memberOf _
8277      * @since 0.1.0
8278      * @category Collection
8279      * @param {Array|Object} collection The collection to iterate over.
8280      * @param {Array|Function|Object|string} [predicate=_.identity]
8281      *  The function invoked per iteration.
8282      * @returns {Array} Returns the new filtered array.
8283      * @see _.reject
8284      * @example
8285      *
8286      * var users = [
8287      *   { 'user': 'barney', 'age': 36, 'active': true },
8288      *   { 'user': 'fred',   'age': 40, 'active': false }
8289      * ];
8290      *
8291      * _.filter(users, function(o) { return !o.active; });
8292      * // => objects for ['fred']
8293      *
8294      * // The `_.matches` iteratee shorthand.
8295      * _.filter(users, { 'age': 36, 'active': true });
8296      * // => objects for ['barney']
8297      *
8298      * // The `_.matchesProperty` iteratee shorthand.
8299      * _.filter(users, ['active', false]);
8300      * // => objects for ['fred']
8301      *
8302      * // The `_.property` iteratee shorthand.
8303      * _.filter(users, 'active');
8304      * // => objects for ['barney']
8305      */
8306     function filter(collection, predicate) {
8307       var func = isArray(collection) ? arrayFilter : baseFilter;
8308       return func(collection, getIteratee(predicate, 3));
8309     }
8310
8311     /**
8312      * Iterates over elements of `collection`, returning the first element
8313      * `predicate` returns truthy for. The predicate is invoked with three
8314      * arguments: (value, index|key, collection).
8315      *
8316      * @static
8317      * @memberOf _
8318      * @since 0.1.0
8319      * @category Collection
8320      * @param {Array|Object} collection The collection to search.
8321      * @param {Array|Function|Object|string} [predicate=_.identity]
8322      *  The function invoked per iteration.
8323      * @returns {*} Returns the matched element, else `undefined`.
8324      * @example
8325      *
8326      * var users = [
8327      *   { 'user': 'barney',  'age': 36, 'active': true },
8328      *   { 'user': 'fred',    'age': 40, 'active': false },
8329      *   { 'user': 'pebbles', 'age': 1,  'active': true }
8330      * ];
8331      *
8332      * _.find(users, function(o) { return o.age < 40; });
8333      * // => object for 'barney'
8334      *
8335      * // The `_.matches` iteratee shorthand.
8336      * _.find(users, { 'age': 1, 'active': true });
8337      * // => object for 'pebbles'
8338      *
8339      * // The `_.matchesProperty` iteratee shorthand.
8340      * _.find(users, ['active', false]);
8341      * // => object for 'fred'
8342      *
8343      * // The `_.property` iteratee shorthand.
8344      * _.find(users, 'active');
8345      * // => object for 'barney'
8346      */
8347     function find(collection, predicate) {
8348       predicate = getIteratee(predicate, 3);
8349       if (isArray(collection)) {
8350         var index = baseFindIndex(collection, predicate);
8351         return index > -1 ? collection[index] : undefined;
8352       }
8353       return baseFind(collection, predicate, baseEach);
8354     }
8355
8356     /**
8357      * This method is like `_.find` except that it iterates over elements of
8358      * `collection` from right to left.
8359      *
8360      * @static
8361      * @memberOf _
8362      * @since 2.0.0
8363      * @category Collection
8364      * @param {Array|Object} collection The collection to search.
8365      * @param {Array|Function|Object|string} [predicate=_.identity]
8366      *  The function invoked per iteration.
8367      * @returns {*} Returns the matched element, else `undefined`.
8368      * @example
8369      *
8370      * _.findLast([1, 2, 3, 4], function(n) {
8371      *   return n % 2 == 1;
8372      * });
8373      * // => 3
8374      */
8375     function findLast(collection, predicate) {
8376       predicate = getIteratee(predicate, 3);
8377       if (isArray(collection)) {
8378         var index = baseFindIndex(collection, predicate, true);
8379         return index > -1 ? collection[index] : undefined;
8380       }
8381       return baseFind(collection, predicate, baseEachRight);
8382     }
8383
8384     /**
8385      * Creates a flattened array of values by running each element in `collection`
8386      * thru `iteratee` and flattening the mapped results. The iteratee is invoked
8387      * with three arguments: (value, index|key, collection).
8388      *
8389      * @static
8390      * @memberOf _
8391      * @since 4.0.0
8392      * @category Collection
8393      * @param {Array|Object} collection The collection to iterate over.
8394      * @param {Array|Function|Object|string} [iteratee=_.identity]
8395      *  The function invoked per iteration.
8396      * @returns {Array} Returns the new flattened array.
8397      * @example
8398      *
8399      * function duplicate(n) {
8400      *   return [n, n];
8401      * }
8402      *
8403      * _.flatMap([1, 2], duplicate);
8404      * // => [1, 1, 2, 2]
8405      */
8406     function flatMap(collection, iteratee) {
8407       return baseFlatten(map(collection, iteratee), 1);
8408     }
8409
8410     /**
8411      * This method is like `_.flatMap` except that it recursively flattens the
8412      * mapped results.
8413      *
8414      * @static
8415      * @memberOf _
8416      * @since 4.7.0
8417      * @category Collection
8418      * @param {Array|Object} collection The collection to iterate over.
8419      * @param {Array|Function|Object|string} [iteratee=_.identity]
8420      *  The function invoked per iteration.
8421      * @returns {Array} Returns the new flattened array.
8422      * @example
8423      *
8424      * function duplicate(n) {
8425      *   return [[[n, n]]];
8426      * }
8427      *
8428      * _.flatMapDeep([1, 2], duplicate);
8429      * // => [1, 1, 2, 2]
8430      */
8431     function flatMapDeep(collection, iteratee) {
8432       return baseFlatten(map(collection, iteratee), INFINITY);
8433     }
8434
8435     /**
8436      * This method is like `_.flatMap` except that it recursively flattens the
8437      * mapped results up to `depth` times.
8438      *
8439      * @static
8440      * @memberOf _
8441      * @since 4.7.0
8442      * @category Collection
8443      * @param {Array|Object} collection The collection to iterate over.
8444      * @param {Array|Function|Object|string} [iteratee=_.identity]
8445      *  The function invoked per iteration.
8446      * @param {number} [depth=1] The maximum recursion depth.
8447      * @returns {Array} Returns the new flattened array.
8448      * @example
8449      *
8450      * function duplicate(n) {
8451      *   return [[[n, n]]];
8452      * }
8453      *
8454      * _.flatMapDepth([1, 2], duplicate, 2);
8455      * // => [[1, 1], [2, 2]]
8456      */
8457     function flatMapDepth(collection, iteratee, depth) {
8458       depth = depth === undefined ? 1 : toInteger(depth);
8459       return baseFlatten(map(collection, iteratee), depth);
8460     }
8461
8462     /**
8463      * Iterates over elements of `collection` and invokes `iteratee` for each element.
8464      * The iteratee is invoked with three arguments: (value, index|key, collection).
8465      * Iteratee functions may exit iteration early by explicitly returning `false`.
8466      *
8467      * **Note:** As with other "Collections" methods, objects with a "length"
8468      * property are iterated like arrays. To avoid this behavior use `_.forIn`
8469      * or `_.forOwn` for object iteration.
8470      *
8471      * @static
8472      * @memberOf _
8473      * @since 0.1.0
8474      * @alias each
8475      * @category Collection
8476      * @param {Array|Object} collection The collection to iterate over.
8477      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
8478      * @returns {Array|Object} Returns `collection`.
8479      * @see _.forEachRight
8480      * @example
8481      *
8482      * _([1, 2]).forEach(function(value) {
8483      *   console.log(value);
8484      * });
8485      * // => Logs `1` then `2`.
8486      *
8487      * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
8488      *   console.log(key);
8489      * });
8490      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
8491      */
8492     function forEach(collection, iteratee) {
8493       return (typeof iteratee == 'function' && isArray(collection))
8494         ? arrayEach(collection, iteratee)
8495         : baseEach(collection, getIteratee(iteratee));
8496     }
8497
8498     /**
8499      * This method is like `_.forEach` except that it iterates over elements of
8500      * `collection` from right to left.
8501      *
8502      * @static
8503      * @memberOf _
8504      * @since 2.0.0
8505      * @alias eachRight
8506      * @category Collection
8507      * @param {Array|Object} collection The collection to iterate over.
8508      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
8509      * @returns {Array|Object} Returns `collection`.
8510      * @see _.forEach
8511      * @example
8512      *
8513      * _.forEachRight([1, 2], function(value) {
8514      *   console.log(value);
8515      * });
8516      * // => Logs `2` then `1`.
8517      */
8518     function forEachRight(collection, iteratee) {
8519       return (typeof iteratee == 'function' && isArray(collection))
8520         ? arrayEachRight(collection, iteratee)
8521         : baseEachRight(collection, getIteratee(iteratee));
8522     }
8523
8524     /**
8525      * Creates an object composed of keys generated from the results of running
8526      * each element of `collection` thru `iteratee`. The order of grouped values
8527      * is determined by the order they occur in `collection`. The corresponding
8528      * value of each key is an array of elements responsible for generating the
8529      * key. The iteratee is invoked with one argument: (value).
8530      *
8531      * @static
8532      * @memberOf _
8533      * @since 0.1.0
8534      * @category Collection
8535      * @param {Array|Object} collection The collection to iterate over.
8536      * @param {Array|Function|Object|string} [iteratee=_.identity]
8537      *  The iteratee to transform keys.
8538      * @returns {Object} Returns the composed aggregate object.
8539      * @example
8540      *
8541      * _.groupBy([6.1, 4.2, 6.3], Math.floor);
8542      * // => { '4': [4.2], '6': [6.1, 6.3] }
8543      *
8544      * // The `_.property` iteratee shorthand.
8545      * _.groupBy(['one', 'two', 'three'], 'length');
8546      * // => { '3': ['one', 'two'], '5': ['three'] }
8547      */
8548     var groupBy = createAggregator(function(result, value, key) {
8549       if (hasOwnProperty.call(result, key)) {
8550         result[key].push(value);
8551       } else {
8552         result[key] = [value];
8553       }
8554     });
8555
8556     /**
8557      * Checks if `value` is in `collection`. If `collection` is a string, it's
8558      * checked for a substring of `value`, otherwise
8559      * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
8560      * is used for equality comparisons. If `fromIndex` is negative, it's used as
8561      * the offset from the end of `collection`.
8562      *
8563      * @static
8564      * @memberOf _
8565      * @since 0.1.0
8566      * @category Collection
8567      * @param {Array|Object|string} collection The collection to search.
8568      * @param {*} value The value to search for.
8569      * @param {number} [fromIndex=0] The index to search from.
8570      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
8571      * @returns {boolean} Returns `true` if `value` is found, else `false`.
8572      * @example
8573      *
8574      * _.includes([1, 2, 3], 1);
8575      * // => true
8576      *
8577      * _.includes([1, 2, 3], 1, 2);
8578      * // => false
8579      *
8580      * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
8581      * // => true
8582      *
8583      * _.includes('pebbles', 'eb');
8584      * // => true
8585      */
8586     function includes(collection, value, fromIndex, guard) {
8587       collection = isArrayLike(collection) ? collection : values(collection);
8588       fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
8589
8590       var length = collection.length;
8591       if (fromIndex < 0) {
8592         fromIndex = nativeMax(length + fromIndex, 0);
8593       }
8594       return isString(collection)
8595         ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
8596         : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
8597     }
8598
8599     /**
8600      * Invokes the method at `path` of each element in `collection`, returning
8601      * an array of the results of each invoked method. Any additional arguments
8602      * are provided to each invoked method. If `methodName` is a function, it's
8603      * invoked for and `this` bound to, each element in `collection`.
8604      *
8605      * @static
8606      * @memberOf _
8607      * @since 4.0.0
8608      * @category Collection
8609      * @param {Array|Object} collection The collection to iterate over.
8610      * @param {Array|Function|string} path The path of the method to invoke or
8611      *  the function invoked per iteration.
8612      * @param {...*} [args] The arguments to invoke each method with.
8613      * @returns {Array} Returns the array of results.
8614      * @example
8615      *
8616      * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
8617      * // => [[1, 5, 7], [1, 2, 3]]
8618      *
8619      * _.invokeMap([123, 456], String.prototype.split, '');
8620      * // => [['1', '2', '3'], ['4', '5', '6']]
8621      */
8622     var invokeMap = rest(function(collection, path, args) {
8623       var index = -1,
8624           isFunc = typeof path == 'function',
8625           isProp = isKey(path),
8626           result = isArrayLike(collection) ? Array(collection.length) : [];
8627
8628       baseEach(collection, function(value) {
8629         var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
8630         result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);
8631       });
8632       return result;
8633     });
8634
8635     /**
8636      * Creates an object composed of keys generated from the results of running
8637      * each element of `collection` thru `iteratee`. The corresponding value of
8638      * each key is the last element responsible for generating the key. The
8639      * iteratee is invoked with one argument: (value).
8640      *
8641      * @static
8642      * @memberOf _
8643      * @since 4.0.0
8644      * @category Collection
8645      * @param {Array|Object} collection The collection to iterate over.
8646      * @param {Array|Function|Object|string} [iteratee=_.identity]
8647      *  The iteratee to transform keys.
8648      * @returns {Object} Returns the composed aggregate object.
8649      * @example
8650      *
8651      * var array = [
8652      *   { 'dir': 'left', 'code': 97 },
8653      *   { 'dir': 'right', 'code': 100 }
8654      * ];
8655      *
8656      * _.keyBy(array, function(o) {
8657      *   return String.fromCharCode(o.code);
8658      * });
8659      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
8660      *
8661      * _.keyBy(array, 'dir');
8662      * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
8663      */
8664     var keyBy = createAggregator(function(result, value, key) {
8665       result[key] = value;
8666     });
8667
8668     /**
8669      * Creates an array of values by running each element in `collection` thru
8670      * `iteratee`. The iteratee is invoked with three arguments:
8671      * (value, index|key, collection).
8672      *
8673      * Many lodash methods are guarded to work as iteratees for methods like
8674      * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
8675      *
8676      * The guarded methods are:
8677      * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
8678      * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
8679      * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
8680      * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
8681      *
8682      * @static
8683      * @memberOf _
8684      * @since 0.1.0
8685      * @category Collection
8686      * @param {Array|Object} collection The collection to iterate over.
8687      * @param {Array|Function|Object|string} [iteratee=_.identity]
8688      *  The function invoked per iteration.
8689      * @returns {Array} Returns the new mapped array.
8690      * @example
8691      *
8692      * function square(n) {
8693      *   return n * n;
8694      * }
8695      *
8696      * _.map([4, 8], square);
8697      * // => [16, 64]
8698      *
8699      * _.map({ 'a': 4, 'b': 8 }, square);
8700      * // => [16, 64] (iteration order is not guaranteed)
8701      *
8702      * var users = [
8703      *   { 'user': 'barney' },
8704      *   { 'user': 'fred' }
8705      * ];
8706      *
8707      * // The `_.property` iteratee shorthand.
8708      * _.map(users, 'user');
8709      * // => ['barney', 'fred']
8710      */
8711     function map(collection, iteratee) {
8712       var func = isArray(collection) ? arrayMap : baseMap;
8713       return func(collection, getIteratee(iteratee, 3));
8714     }
8715
8716     /**
8717      * This method is like `_.sortBy` except that it allows specifying the sort
8718      * orders of the iteratees to sort by. If `orders` is unspecified, all values
8719      * are sorted in ascending order. Otherwise, specify an order of "desc" for
8720      * descending or "asc" for ascending sort order of corresponding values.
8721      *
8722      * @static
8723      * @memberOf _
8724      * @since 4.0.0
8725      * @category Collection
8726      * @param {Array|Object} collection The collection to iterate over.
8727      * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
8728      *  The iteratees to sort by.
8729      * @param {string[]} [orders] The sort orders of `iteratees`.
8730      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
8731      * @returns {Array} Returns the new sorted array.
8732      * @example
8733      *
8734      * var users = [
8735      *   { 'user': 'fred',   'age': 48 },
8736      *   { 'user': 'barney', 'age': 34 },
8737      *   { 'user': 'fred',   'age': 40 },
8738      *   { 'user': 'barney', 'age': 36 }
8739      * ];
8740      *
8741      * // Sort by `user` in ascending order and by `age` in descending order.
8742      * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
8743      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
8744      */
8745     function orderBy(collection, iteratees, orders, guard) {
8746       if (collection == null) {
8747         return [];
8748       }
8749       if (!isArray(iteratees)) {
8750         iteratees = iteratees == null ? [] : [iteratees];
8751       }
8752       orders = guard ? undefined : orders;
8753       if (!isArray(orders)) {
8754         orders = orders == null ? [] : [orders];
8755       }
8756       return baseOrderBy(collection, iteratees, orders);
8757     }
8758
8759     /**
8760      * Creates an array of elements split into two groups, the first of which
8761      * contains elements `predicate` returns truthy for, the second of which
8762      * contains elements `predicate` returns falsey for. The predicate is
8763      * invoked with one argument: (value).
8764      *
8765      * @static
8766      * @memberOf _
8767      * @since 3.0.0
8768      * @category Collection
8769      * @param {Array|Object} collection The collection to iterate over.
8770      * @param {Array|Function|Object|string} [predicate=_.identity]
8771      *  The function invoked per iteration.
8772      * @returns {Array} Returns the array of grouped elements.
8773      * @example
8774      *
8775      * var users = [
8776      *   { 'user': 'barney',  'age': 36, 'active': false },
8777      *   { 'user': 'fred',    'age': 40, 'active': true },
8778      *   { 'user': 'pebbles', 'age': 1,  'active': false }
8779      * ];
8780      *
8781      * _.partition(users, function(o) { return o.active; });
8782      * // => objects for [['fred'], ['barney', 'pebbles']]
8783      *
8784      * // The `_.matches` iteratee shorthand.
8785      * _.partition(users, { 'age': 1, 'active': false });
8786      * // => objects for [['pebbles'], ['barney', 'fred']]
8787      *
8788      * // The `_.matchesProperty` iteratee shorthand.
8789      * _.partition(users, ['active', false]);
8790      * // => objects for [['barney', 'pebbles'], ['fred']]
8791      *
8792      * // The `_.property` iteratee shorthand.
8793      * _.partition(users, 'active');
8794      * // => objects for [['fred'], ['barney', 'pebbles']]
8795      */
8796     var partition = createAggregator(function(result, value, key) {
8797       result[key ? 0 : 1].push(value);
8798     }, function() { return [[], []]; });
8799
8800     /**
8801      * Reduces `collection` to a value which is the accumulated result of running
8802      * each element in `collection` thru `iteratee`, where each successive
8803      * invocation is supplied the return value of the previous. If `accumulator`
8804      * is not given, the first element of `collection` is used as the initial
8805      * value. The iteratee is invoked with four arguments:
8806      * (accumulator, value, index|key, collection).
8807      *
8808      * Many lodash methods are guarded to work as iteratees for methods like
8809      * `_.reduce`, `_.reduceRight`, and `_.transform`.
8810      *
8811      * The guarded methods are:
8812      * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
8813      * and `sortBy`
8814      *
8815      * @static
8816      * @memberOf _
8817      * @since 0.1.0
8818      * @category Collection
8819      * @param {Array|Object} collection The collection to iterate over.
8820      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
8821      * @param {*} [accumulator] The initial value.
8822      * @returns {*} Returns the accumulated value.
8823      * @see _.reduceRight
8824      * @example
8825      *
8826      * _.reduce([1, 2], function(sum, n) {
8827      *   return sum + n;
8828      * }, 0);
8829      * // => 3
8830      *
8831      * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
8832      *   (result[value] || (result[value] = [])).push(key);
8833      *   return result;
8834      * }, {});
8835      * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
8836      */
8837     function reduce(collection, iteratee, accumulator) {
8838       var func = isArray(collection) ? arrayReduce : baseReduce,
8839           initAccum = arguments.length < 3;
8840
8841       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
8842     }
8843
8844     /**
8845      * This method is like `_.reduce` except that it iterates over elements of
8846      * `collection` from right to left.
8847      *
8848      * @static
8849      * @memberOf _
8850      * @since 0.1.0
8851      * @category Collection
8852      * @param {Array|Object} collection The collection to iterate over.
8853      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
8854      * @param {*} [accumulator] The initial value.
8855      * @returns {*} Returns the accumulated value.
8856      * @see _.reduce
8857      * @example
8858      *
8859      * var array = [[0, 1], [2, 3], [4, 5]];
8860      *
8861      * _.reduceRight(array, function(flattened, other) {
8862      *   return flattened.concat(other);
8863      * }, []);
8864      * // => [4, 5, 2, 3, 0, 1]
8865      */
8866     function reduceRight(collection, iteratee, accumulator) {
8867       var func = isArray(collection) ? arrayReduceRight : baseReduce,
8868           initAccum = arguments.length < 3;
8869
8870       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
8871     }
8872
8873     /**
8874      * The opposite of `_.filter`; this method returns the elements of `collection`
8875      * that `predicate` does **not** return truthy for.
8876      *
8877      * @static
8878      * @memberOf _
8879      * @since 0.1.0
8880      * @category Collection
8881      * @param {Array|Object} collection The collection to iterate over.
8882      * @param {Array|Function|Object|string} [predicate=_.identity]
8883      *  The function invoked per iteration.
8884      * @returns {Array} Returns the new filtered array.
8885      * @see _.filter
8886      * @example
8887      *
8888      * var users = [
8889      *   { 'user': 'barney', 'age': 36, 'active': false },
8890      *   { 'user': 'fred',   'age': 40, 'active': true }
8891      * ];
8892      *
8893      * _.reject(users, function(o) { return !o.active; });
8894      * // => objects for ['fred']
8895      *
8896      * // The `_.matches` iteratee shorthand.
8897      * _.reject(users, { 'age': 40, 'active': true });
8898      * // => objects for ['barney']
8899      *
8900      * // The `_.matchesProperty` iteratee shorthand.
8901      * _.reject(users, ['active', false]);
8902      * // => objects for ['fred']
8903      *
8904      * // The `_.property` iteratee shorthand.
8905      * _.reject(users, 'active');
8906      * // => objects for ['barney']
8907      */
8908     function reject(collection, predicate) {
8909       var func = isArray(collection) ? arrayFilter : baseFilter;
8910       predicate = getIteratee(predicate, 3);
8911       return func(collection, function(value, index, collection) {
8912         return !predicate(value, index, collection);
8913       });
8914     }
8915
8916     /**
8917      * Gets a random element from `collection`.
8918      *
8919      * @static
8920      * @memberOf _
8921      * @since 2.0.0
8922      * @category Collection
8923      * @param {Array|Object} collection The collection to sample.
8924      * @returns {*} Returns the random element.
8925      * @example
8926      *
8927      * _.sample([1, 2, 3, 4]);
8928      * // => 2
8929      */
8930     function sample(collection) {
8931       var array = isArrayLike(collection) ? collection : values(collection),
8932           length = array.length;
8933
8934       return length > 0 ? array[baseRandom(0, length - 1)] : undefined;
8935     }
8936
8937     /**
8938      * Gets `n` random elements at unique keys from `collection` up to the
8939      * size of `collection`.
8940      *
8941      * @static
8942      * @memberOf _
8943      * @since 4.0.0
8944      * @category Collection
8945      * @param {Array|Object} collection The collection to sample.
8946      * @param {number} [n=1] The number of elements to sample.
8947      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8948      * @returns {Array} Returns the random elements.
8949      * @example
8950      *
8951      * _.sampleSize([1, 2, 3], 2);
8952      * // => [3, 1]
8953      *
8954      * _.sampleSize([1, 2, 3], 4);
8955      * // => [2, 3, 1]
8956      */
8957     function sampleSize(collection, n, guard) {
8958       var index = -1,
8959           result = toArray(collection),
8960           length = result.length,
8961           lastIndex = length - 1;
8962
8963       if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
8964         n = 1;
8965       } else {
8966         n = baseClamp(toInteger(n), 0, length);
8967       }
8968       while (++index < n) {
8969         var rand = baseRandom(index, lastIndex),
8970             value = result[rand];
8971
8972         result[rand] = result[index];
8973         result[index] = value;
8974       }
8975       result.length = n;
8976       return result;
8977     }
8978
8979     /**
8980      * Creates an array of shuffled values, using a version of the
8981      * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
8982      *
8983      * @static
8984      * @memberOf _
8985      * @since 0.1.0
8986      * @category Collection
8987      * @param {Array|Object} collection The collection to shuffle.
8988      * @returns {Array} Returns the new shuffled array.
8989      * @example
8990      *
8991      * _.shuffle([1, 2, 3, 4]);
8992      * // => [4, 1, 3, 2]
8993      */
8994     function shuffle(collection) {
8995       return sampleSize(collection, MAX_ARRAY_LENGTH);
8996     }
8997
8998     /**
8999      * Gets the size of `collection` by returning its length for array-like
9000      * values or the number of own enumerable string keyed properties for objects.
9001      *
9002      * @static
9003      * @memberOf _
9004      * @since 0.1.0
9005      * @category Collection
9006      * @param {Array|Object} collection The collection to inspect.
9007      * @returns {number} Returns the collection size.
9008      * @example
9009      *
9010      * _.size([1, 2, 3]);
9011      * // => 3
9012      *
9013      * _.size({ 'a': 1, 'b': 2 });
9014      * // => 2
9015      *
9016      * _.size('pebbles');
9017      * // => 7
9018      */
9019     function size(collection) {
9020       if (collection == null) {
9021         return 0;
9022       }
9023       if (isArrayLike(collection)) {
9024         var result = collection.length;
9025         return (result && isString(collection)) ? stringSize(collection) : result;
9026       }
9027       if (isObjectLike(collection)) {
9028         var tag = getTag(collection);
9029         if (tag == mapTag || tag == setTag) {
9030           return collection.size;
9031         }
9032       }
9033       return keys(collection).length;
9034     }
9035
9036     /**
9037      * Checks if `predicate` returns truthy for **any** element of `collection`.
9038      * Iteration is stopped once `predicate` returns truthy. The predicate is
9039      * invoked with three arguments: (value, index|key, collection).
9040      *
9041      * @static
9042      * @memberOf _
9043      * @since 0.1.0
9044      * @category Collection
9045      * @param {Array|Object} collection The collection to iterate over.
9046      * @param {Array|Function|Object|string} [predicate=_.identity]
9047      *  The function invoked per iteration.
9048      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9049      * @returns {boolean} Returns `true` if any element passes the predicate check,
9050      *  else `false`.
9051      * @example
9052      *
9053      * _.some([null, 0, 'yes', false], Boolean);
9054      * // => true
9055      *
9056      * var users = [
9057      *   { 'user': 'barney', 'active': true },
9058      *   { 'user': 'fred',   'active': false }
9059      * ];
9060      *
9061      * // The `_.matches` iteratee shorthand.
9062      * _.some(users, { 'user': 'barney', 'active': false });
9063      * // => false
9064      *
9065      * // The `_.matchesProperty` iteratee shorthand.
9066      * _.some(users, ['active', false]);
9067      * // => true
9068      *
9069      * // The `_.property` iteratee shorthand.
9070      * _.some(users, 'active');
9071      * // => true
9072      */
9073     function some(collection, predicate, guard) {
9074       var func = isArray(collection) ? arraySome : baseSome;
9075       if (guard && isIterateeCall(collection, predicate, guard)) {
9076         predicate = undefined;
9077       }
9078       return func(collection, getIteratee(predicate, 3));
9079     }
9080
9081     /**
9082      * Creates an array of elements, sorted in ascending order by the results of
9083      * running each element in a collection thru each iteratee. This method
9084      * performs a stable sort, that is, it preserves the original sort order of
9085      * equal elements. The iteratees are invoked with one argument: (value).
9086      *
9087      * @static
9088      * @memberOf _
9089      * @since 0.1.0
9090      * @category Collection
9091      * @param {Array|Object} collection The collection to iterate over.
9092      * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
9093      *  [iteratees=[_.identity]] The iteratees to sort by.
9094      * @returns {Array} Returns the new sorted array.
9095      * @example
9096      *
9097      * var users = [
9098      *   { 'user': 'fred',   'age': 48 },
9099      *   { 'user': 'barney', 'age': 36 },
9100      *   { 'user': 'fred',   'age': 40 },
9101      *   { 'user': 'barney', 'age': 34 }
9102      * ];
9103      *
9104      * _.sortBy(users, function(o) { return o.user; });
9105      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9106      *
9107      * _.sortBy(users, ['user', 'age']);
9108      * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
9109      *
9110      * _.sortBy(users, 'user', function(o) {
9111      *   return Math.floor(o.age / 10);
9112      * });
9113      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9114      */
9115     var sortBy = rest(function(collection, iteratees) {
9116       if (collection == null) {
9117         return [];
9118       }
9119       var length = iteratees.length;
9120       if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
9121         iteratees = [];
9122       } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
9123         iteratees = [iteratees[0]];
9124       }
9125       iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
9126         ? iteratees[0]
9127         : baseFlatten(iteratees, 1, isFlattenableIteratee);
9128
9129       return baseOrderBy(collection, iteratees, []);
9130     });
9131
9132     /*------------------------------------------------------------------------*/
9133
9134     /**
9135      * Gets the timestamp of the number of milliseconds that have elapsed since
9136      * the Unix epoch (1 January 1970 00:00:00 UTC).
9137      *
9138      * @static
9139      * @memberOf _
9140      * @since 2.4.0
9141      * @type {Function}
9142      * @category Date
9143      * @returns {number} Returns the timestamp.
9144      * @example
9145      *
9146      * _.defer(function(stamp) {
9147      *   console.log(_.now() - stamp);
9148      * }, _.now());
9149      * // => Logs the number of milliseconds it took for the deferred function to be invoked.
9150      */
9151     var now = Date.now;
9152
9153     /*------------------------------------------------------------------------*/
9154
9155     /**
9156      * The opposite of `_.before`; this method creates a function that invokes
9157      * `func` once it's called `n` or more times.
9158      *
9159      * @static
9160      * @memberOf _
9161      * @since 0.1.0
9162      * @category Function
9163      * @param {number} n The number of calls before `func` is invoked.
9164      * @param {Function} func The function to restrict.
9165      * @returns {Function} Returns the new restricted function.
9166      * @example
9167      *
9168      * var saves = ['profile', 'settings'];
9169      *
9170      * var done = _.after(saves.length, function() {
9171      *   console.log('done saving!');
9172      * });
9173      *
9174      * _.forEach(saves, function(type) {
9175      *   asyncSave({ 'type': type, 'complete': done });
9176      * });
9177      * // => Logs 'done saving!' after the two async saves have completed.
9178      */
9179     function after(n, func) {
9180       if (typeof func != 'function') {
9181         throw new TypeError(FUNC_ERROR_TEXT);
9182       }
9183       n = toInteger(n);
9184       return function() {
9185         if (--n < 1) {
9186           return func.apply(this, arguments);
9187         }
9188       };
9189     }
9190
9191     /**
9192      * Creates a function that invokes `func`, with up to `n` arguments,
9193      * ignoring any additional arguments.
9194      *
9195      * @static
9196      * @memberOf _
9197      * @since 3.0.0
9198      * @category Function
9199      * @param {Function} func The function to cap arguments for.
9200      * @param {number} [n=func.length] The arity cap.
9201      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9202      * @returns {Function} Returns the new function.
9203      * @example
9204      *
9205      * _.map(['6', '8', '10'], _.ary(parseInt, 1));
9206      * // => [6, 8, 10]
9207      */
9208     function ary(func, n, guard) {
9209       n = guard ? undefined : n;
9210       n = (func && n == null) ? func.length : n;
9211       return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
9212     }
9213
9214     /**
9215      * Creates a function that invokes `func`, with the `this` binding and arguments
9216      * of the created function, while it's called less than `n` times. Subsequent
9217      * calls to the created function return the result of the last `func` invocation.
9218      *
9219      * @static
9220      * @memberOf _
9221      * @since 3.0.0
9222      * @category Function
9223      * @param {number} n The number of calls at which `func` is no longer invoked.
9224      * @param {Function} func The function to restrict.
9225      * @returns {Function} Returns the new restricted function.
9226      * @example
9227      *
9228      * jQuery(element).on('click', _.before(5, addContactToList));
9229      * // => allows adding up to 4 contacts to the list
9230      */
9231     function before(n, func) {
9232       var result;
9233       if (typeof func != 'function') {
9234         throw new TypeError(FUNC_ERROR_TEXT);
9235       }
9236       n = toInteger(n);
9237       return function() {
9238         if (--n > 0) {
9239           result = func.apply(this, arguments);
9240         }
9241         if (n <= 1) {
9242           func = undefined;
9243         }
9244         return result;
9245       };
9246     }
9247
9248     /**
9249      * Creates a function that invokes `func` with the `this` binding of `thisArg`
9250      * and `partials` prepended to the arguments it receives.
9251      *
9252      * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
9253      * may be used as a placeholder for partially applied arguments.
9254      *
9255      * **Note:** Unlike native `Function#bind` this method doesn't set the "length"
9256      * property of bound functions.
9257      *
9258      * @static
9259      * @memberOf _
9260      * @since 0.1.0
9261      * @category Function
9262      * @param {Function} func The function to bind.
9263      * @param {*} thisArg The `this` binding of `func`.
9264      * @param {...*} [partials] The arguments to be partially applied.
9265      * @returns {Function} Returns the new bound function.
9266      * @example
9267      *
9268      * var greet = function(greeting, punctuation) {
9269      *   return greeting + ' ' + this.user + punctuation;
9270      * };
9271      *
9272      * var object = { 'user': 'fred' };
9273      *
9274      * var bound = _.bind(greet, object, 'hi');
9275      * bound('!');
9276      * // => 'hi fred!'
9277      *
9278      * // Bound with placeholders.
9279      * var bound = _.bind(greet, object, _, '!');
9280      * bound('hi');
9281      * // => 'hi fred!'
9282      */
9283     var bind = rest(function(func, thisArg, partials) {
9284       var bitmask = BIND_FLAG;
9285       if (partials.length) {
9286         var holders = replaceHolders(partials, getPlaceholder(bind));
9287         bitmask |= PARTIAL_FLAG;
9288       }
9289       return createWrapper(func, bitmask, thisArg, partials, holders);
9290     });
9291
9292     /**
9293      * Creates a function that invokes the method at `object[key]` with `partials`
9294      * prepended to the arguments it receives.
9295      *
9296      * This method differs from `_.bind` by allowing bound functions to reference
9297      * methods that may be redefined or don't yet exist. See
9298      * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
9299      * for more details.
9300      *
9301      * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
9302      * builds, may be used as a placeholder for partially applied arguments.
9303      *
9304      * @static
9305      * @memberOf _
9306      * @since 0.10.0
9307      * @category Function
9308      * @param {Object} object The object to invoke the method on.
9309      * @param {string} key The key of the method.
9310      * @param {...*} [partials] The arguments to be partially applied.
9311      * @returns {Function} Returns the new bound function.
9312      * @example
9313      *
9314      * var object = {
9315      *   'user': 'fred',
9316      *   'greet': function(greeting, punctuation) {
9317      *     return greeting + ' ' + this.user + punctuation;
9318      *   }
9319      * };
9320      *
9321      * var bound = _.bindKey(object, 'greet', 'hi');
9322      * bound('!');
9323      * // => 'hi fred!'
9324      *
9325      * object.greet = function(greeting, punctuation) {
9326      *   return greeting + 'ya ' + this.user + punctuation;
9327      * };
9328      *
9329      * bound('!');
9330      * // => 'hiya fred!'
9331      *
9332      * // Bound with placeholders.
9333      * var bound = _.bindKey(object, 'greet', _, '!');
9334      * bound('hi');
9335      * // => 'hiya fred!'
9336      */
9337     var bindKey = rest(function(object, key, partials) {
9338       var bitmask = BIND_FLAG | BIND_KEY_FLAG;
9339       if (partials.length) {
9340         var holders = replaceHolders(partials, getPlaceholder(bindKey));
9341         bitmask |= PARTIAL_FLAG;
9342       }
9343       return createWrapper(key, bitmask, object, partials, holders);
9344     });
9345
9346     /**
9347      * Creates a function that accepts arguments of `func` and either invokes
9348      * `func` returning its result, if at least `arity` number of arguments have
9349      * been provided, or returns a function that accepts the remaining `func`
9350      * arguments, and so on. The arity of `func` may be specified if `func.length`
9351      * is not sufficient.
9352      *
9353      * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
9354      * may be used as a placeholder for provided arguments.
9355      *
9356      * **Note:** This method doesn't set the "length" property of curried functions.
9357      *
9358      * @static
9359      * @memberOf _
9360      * @since 2.0.0
9361      * @category Function
9362      * @param {Function} func The function to curry.
9363      * @param {number} [arity=func.length] The arity of `func`.
9364      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9365      * @returns {Function} Returns the new curried function.
9366      * @example
9367      *
9368      * var abc = function(a, b, c) {
9369      *   return [a, b, c];
9370      * };
9371      *
9372      * var curried = _.curry(abc);
9373      *
9374      * curried(1)(2)(3);
9375      * // => [1, 2, 3]
9376      *
9377      * curried(1, 2)(3);
9378      * // => [1, 2, 3]
9379      *
9380      * curried(1, 2, 3);
9381      * // => [1, 2, 3]
9382      *
9383      * // Curried with placeholders.
9384      * curried(1)(_, 3)(2);
9385      * // => [1, 2, 3]
9386      */
9387     function curry(func, arity, guard) {
9388       arity = guard ? undefined : arity;
9389       var result = createWrapper(func, CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
9390       result.placeholder = curry.placeholder;
9391       return result;
9392     }
9393
9394     /**
9395      * This method is like `_.curry` except that arguments are applied to `func`
9396      * in the manner of `_.partialRight` instead of `_.partial`.
9397      *
9398      * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
9399      * builds, may be used as a placeholder for provided arguments.
9400      *
9401      * **Note:** This method doesn't set the "length" property of curried functions.
9402      *
9403      * @static
9404      * @memberOf _
9405      * @since 3.0.0
9406      * @category Function
9407      * @param {Function} func The function to curry.
9408      * @param {number} [arity=func.length] The arity of `func`.
9409      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9410      * @returns {Function} Returns the new curried function.
9411      * @example
9412      *
9413      * var abc = function(a, b, c) {
9414      *   return [a, b, c];
9415      * };
9416      *
9417      * var curried = _.curryRight(abc);
9418      *
9419      * curried(3)(2)(1);
9420      * // => [1, 2, 3]
9421      *
9422      * curried(2, 3)(1);
9423      * // => [1, 2, 3]
9424      *
9425      * curried(1, 2, 3);
9426      * // => [1, 2, 3]
9427      *
9428      * // Curried with placeholders.
9429      * curried(3)(1, _)(2);
9430      * // => [1, 2, 3]
9431      */
9432     function curryRight(func, arity, guard) {
9433       arity = guard ? undefined : arity;
9434       var result = createWrapper(func, CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
9435       result.placeholder = curryRight.placeholder;
9436       return result;
9437     }
9438
9439     /**
9440      * Creates a debounced function that delays invoking `func` until after `wait`
9441      * milliseconds have elapsed since the last time the debounced function was
9442      * invoked. The debounced function comes with a `cancel` method to cancel
9443      * delayed `func` invocations and a `flush` method to immediately invoke them.
9444      * Provide an options object to indicate whether `func` should be invoked on
9445      * the leading and/or trailing edge of the `wait` timeout. The `func` is invoked
9446      * with the last arguments provided to the debounced function. Subsequent calls
9447      * to the debounced function return the result of the last `func` invocation.
9448      *
9449      * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
9450      * on the trailing edge of the timeout only if the debounced function is
9451      * invoked more than once during the `wait` timeout.
9452      *
9453      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
9454      * for details over the differences between `_.debounce` and `_.throttle`.
9455      *
9456      * @static
9457      * @memberOf _
9458      * @since 0.1.0
9459      * @category Function
9460      * @param {Function} func The function to debounce.
9461      * @param {number} [wait=0] The number of milliseconds to delay.
9462      * @param {Object} [options={}] The options object.
9463      * @param {boolean} [options.leading=false]
9464      *  Specify invoking on the leading edge of the timeout.
9465      * @param {number} [options.maxWait]
9466      *  The maximum time `func` is allowed to be delayed before it's invoked.
9467      * @param {boolean} [options.trailing=true]
9468      *  Specify invoking on the trailing edge of the timeout.
9469      * @returns {Function} Returns the new debounced function.
9470      * @example
9471      *
9472      * // Avoid costly calculations while the window size is in flux.
9473      * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
9474      *
9475      * // Invoke `sendMail` when clicked, debouncing subsequent calls.
9476      * jQuery(element).on('click', _.debounce(sendMail, 300, {
9477      *   'leading': true,
9478      *   'trailing': false
9479      * }));
9480      *
9481      * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
9482      * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
9483      * var source = new EventSource('/stream');
9484      * jQuery(source).on('message', debounced);
9485      *
9486      * // Cancel the trailing debounced invocation.
9487      * jQuery(window).on('popstate', debounced.cancel);
9488      */
9489     function debounce(func, wait, options) {
9490       var lastArgs,
9491           lastThis,
9492           maxWait,
9493           result,
9494           timerId,
9495           lastCallTime = 0,
9496           lastInvokeTime = 0,
9497           leading = false,
9498           maxing = false,
9499           trailing = true;
9500
9501       if (typeof func != 'function') {
9502         throw new TypeError(FUNC_ERROR_TEXT);
9503       }
9504       wait = toNumber(wait) || 0;
9505       if (isObject(options)) {
9506         leading = !!options.leading;
9507         maxing = 'maxWait' in options;
9508         maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
9509         trailing = 'trailing' in options ? !!options.trailing : trailing;
9510       }
9511
9512       function invokeFunc(time) {
9513         var args = lastArgs,
9514             thisArg = lastThis;
9515
9516         lastArgs = lastThis = undefined;
9517         lastInvokeTime = time;
9518         result = func.apply(thisArg, args);
9519         return result;
9520       }
9521
9522       function leadingEdge(time) {
9523         // Reset any `maxWait` timer.
9524         lastInvokeTime = time;
9525         // Start the timer for the trailing edge.
9526         timerId = setTimeout(timerExpired, wait);
9527         // Invoke the leading edge.
9528         return leading ? invokeFunc(time) : result;
9529       }
9530
9531       function remainingWait(time) {
9532         var timeSinceLastCall = time - lastCallTime,
9533             timeSinceLastInvoke = time - lastInvokeTime,
9534             result = wait - timeSinceLastCall;
9535
9536         return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
9537       }
9538
9539       function shouldInvoke(time) {
9540         var timeSinceLastCall = time - lastCallTime,
9541             timeSinceLastInvoke = time - lastInvokeTime;
9542
9543         // Either this is the first call, activity has stopped and we're at the
9544         // trailing edge, the system time has gone backwards and we're treating
9545         // it as the trailing edge, or we've hit the `maxWait` limit.
9546         return (!lastCallTime || (timeSinceLastCall >= wait) ||
9547           (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
9548       }
9549
9550       function timerExpired() {
9551         var time = now();
9552         if (shouldInvoke(time)) {
9553           return trailingEdge(time);
9554         }
9555         // Restart the timer.
9556         timerId = setTimeout(timerExpired, remainingWait(time));
9557       }
9558
9559       function trailingEdge(time) {
9560         clearTimeout(timerId);
9561         timerId = undefined;
9562
9563         // Only invoke if we have `lastArgs` which means `func` has been
9564         // debounced at least once.
9565         if (trailing && lastArgs) {
9566           return invokeFunc(time);
9567         }
9568         lastArgs = lastThis = undefined;
9569         return result;
9570       }
9571
9572       function cancel() {
9573         if (timerId !== undefined) {
9574           clearTimeout(timerId);
9575         }
9576         lastCallTime = lastInvokeTime = 0;
9577         lastArgs = lastThis = timerId = undefined;
9578       }
9579
9580       function flush() {
9581         return timerId === undefined ? result : trailingEdge(now());
9582       }
9583
9584       function debounced() {
9585         var time = now(),
9586             isInvoking = shouldInvoke(time);
9587
9588         lastArgs = arguments;
9589         lastThis = this;
9590         lastCallTime = time;
9591
9592         if (isInvoking) {
9593           if (timerId === undefined) {
9594             return leadingEdge(lastCallTime);
9595           }
9596           if (maxing) {
9597             // Handle invocations in a tight loop.
9598             clearTimeout(timerId);
9599             timerId = setTimeout(timerExpired, wait);
9600             return invokeFunc(lastCallTime);
9601           }
9602         }
9603         if (timerId === undefined) {
9604           timerId = setTimeout(timerExpired, wait);
9605         }
9606         return result;
9607       }
9608       debounced.cancel = cancel;
9609       debounced.flush = flush;
9610       return debounced;
9611     }
9612
9613     /**
9614      * Defers invoking the `func` until the current call stack has cleared. Any
9615      * additional arguments are provided to `func` when it's invoked.
9616      *
9617      * @static
9618      * @memberOf _
9619      * @since 0.1.0
9620      * @category Function
9621      * @param {Function} func The function to defer.
9622      * @param {...*} [args] The arguments to invoke `func` with.
9623      * @returns {number} Returns the timer id.
9624      * @example
9625      *
9626      * _.defer(function(text) {
9627      *   console.log(text);
9628      * }, 'deferred');
9629      * // => Logs 'deferred' after one or more milliseconds.
9630      */
9631     var defer = rest(function(func, args) {
9632       return baseDelay(func, 1, args);
9633     });
9634
9635     /**
9636      * Invokes `func` after `wait` milliseconds. Any additional arguments are
9637      * provided to `func` when it's invoked.
9638      *
9639      * @static
9640      * @memberOf _
9641      * @since 0.1.0
9642      * @category Function
9643      * @param {Function} func The function to delay.
9644      * @param {number} wait The number of milliseconds to delay invocation.
9645      * @param {...*} [args] The arguments to invoke `func` with.
9646      * @returns {number} Returns the timer id.
9647      * @example
9648      *
9649      * _.delay(function(text) {
9650      *   console.log(text);
9651      * }, 1000, 'later');
9652      * // => Logs 'later' after one second.
9653      */
9654     var delay = rest(function(func, wait, args) {
9655       return baseDelay(func, toNumber(wait) || 0, args);
9656     });
9657
9658     /**
9659      * Creates a function that invokes `func` with arguments reversed.
9660      *
9661      * @static
9662      * @memberOf _
9663      * @since 4.0.0
9664      * @category Function
9665      * @param {Function} func The function to flip arguments for.
9666      * @returns {Function} Returns the new function.
9667      * @example
9668      *
9669      * var flipped = _.flip(function() {
9670      *   return _.toArray(arguments);
9671      * });
9672      *
9673      * flipped('a', 'b', 'c', 'd');
9674      * // => ['d', 'c', 'b', 'a']
9675      */
9676     function flip(func) {
9677       return createWrapper(func, FLIP_FLAG);
9678     }
9679
9680     /**
9681      * Creates a function that memoizes the result of `func`. If `resolver` is
9682      * provided, it determines the cache key for storing the result based on the
9683      * arguments provided to the memoized function. By default, the first argument
9684      * provided to the memoized function is used as the map cache key. The `func`
9685      * is invoked with the `this` binding of the memoized function.
9686      *
9687      * **Note:** The cache is exposed as the `cache` property on the memoized
9688      * function. Its creation may be customized by replacing the `_.memoize.Cache`
9689      * constructor with one whose instances implement the
9690      * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
9691      * method interface of `delete`, `get`, `has`, and `set`.
9692      *
9693      * @static
9694      * @memberOf _
9695      * @since 0.1.0
9696      * @category Function
9697      * @param {Function} func The function to have its output memoized.
9698      * @param {Function} [resolver] The function to resolve the cache key.
9699      * @returns {Function} Returns the new memoizing function.
9700      * @example
9701      *
9702      * var object = { 'a': 1, 'b': 2 };
9703      * var other = { 'c': 3, 'd': 4 };
9704      *
9705      * var values = _.memoize(_.values);
9706      * values(object);
9707      * // => [1, 2]
9708      *
9709      * values(other);
9710      * // => [3, 4]
9711      *
9712      * object.a = 2;
9713      * values(object);
9714      * // => [1, 2]
9715      *
9716      * // Modify the result cache.
9717      * values.cache.set(object, ['a', 'b']);
9718      * values(object);
9719      * // => ['a', 'b']
9720      *
9721      * // Replace `_.memoize.Cache`.
9722      * _.memoize.Cache = WeakMap;
9723      */
9724     function memoize(func, resolver) {
9725       if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
9726         throw new TypeError(FUNC_ERROR_TEXT);
9727       }
9728       var memoized = function() {
9729         var args = arguments,
9730             key = resolver ? resolver.apply(this, args) : args[0],
9731             cache = memoized.cache;
9732
9733         if (cache.has(key)) {
9734           return cache.get(key);
9735         }
9736         var result = func.apply(this, args);
9737         memoized.cache = cache.set(key, result);
9738         return result;
9739       };
9740       memoized.cache = new (memoize.Cache || MapCache);
9741       return memoized;
9742     }
9743
9744     // Assign cache to `_.memoize`.
9745     memoize.Cache = MapCache;
9746
9747     /**
9748      * Creates a function that negates the result of the predicate `func`. The
9749      * `func` predicate is invoked with the `this` binding and arguments of the
9750      * created function.
9751      *
9752      * @static
9753      * @memberOf _
9754      * @since 3.0.0
9755      * @category Function
9756      * @param {Function} predicate The predicate to negate.
9757      * @returns {Function} Returns the new function.
9758      * @example
9759      *
9760      * function isEven(n) {
9761      *   return n % 2 == 0;
9762      * }
9763      *
9764      * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
9765      * // => [1, 3, 5]
9766      */
9767     function negate(predicate) {
9768       if (typeof predicate != 'function') {
9769         throw new TypeError(FUNC_ERROR_TEXT);
9770       }
9771       return function() {
9772         return !predicate.apply(this, arguments);
9773       };
9774     }
9775
9776     /**
9777      * Creates a function that is restricted to invoking `func` once. Repeat calls
9778      * to the function return the value of the first invocation. The `func` is
9779      * invoked with the `this` binding and arguments of the created function.
9780      *
9781      * @static
9782      * @memberOf _
9783      * @since 0.1.0
9784      * @category Function
9785      * @param {Function} func The function to restrict.
9786      * @returns {Function} Returns the new restricted function.
9787      * @example
9788      *
9789      * var initialize = _.once(createApplication);
9790      * initialize();
9791      * initialize();
9792      * // `initialize` invokes `createApplication` once
9793      */
9794     function once(func) {
9795       return before(2, func);
9796     }
9797
9798     /**
9799      * Creates a function that invokes `func` with arguments transformed by
9800      * corresponding `transforms`.
9801      *
9802      * @static
9803      * @since 4.0.0
9804      * @memberOf _
9805      * @category Function
9806      * @param {Function} func The function to wrap.
9807      * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
9808      *  [transforms[_.identity]] The functions to transform.
9809      * @returns {Function} Returns the new function.
9810      * @example
9811      *
9812      * function doubled(n) {
9813      *   return n * 2;
9814      * }
9815      *
9816      * function square(n) {
9817      *   return n * n;
9818      * }
9819      *
9820      * var func = _.overArgs(function(x, y) {
9821      *   return [x, y];
9822      * }, square, doubled);
9823      *
9824      * func(9, 3);
9825      * // => [81, 6]
9826      *
9827      * func(10, 5);
9828      * // => [100, 10]
9829      */
9830     var overArgs = rest(function(func, transforms) {
9831       transforms = (transforms.length == 1 && isArray(transforms[0]))
9832         ? arrayMap(transforms[0], baseUnary(getIteratee()))
9833         : arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(getIteratee()));
9834
9835       var funcsLength = transforms.length;
9836       return rest(function(args) {
9837         var index = -1,
9838             length = nativeMin(args.length, funcsLength);
9839
9840         while (++index < length) {
9841           args[index] = transforms[index].call(this, args[index]);
9842         }
9843         return apply(func, this, args);
9844       });
9845     });
9846
9847     /**
9848      * Creates a function that invokes `func` with `partials` prepended to the
9849      * arguments it receives. This method is like `_.bind` except it does **not**
9850      * alter the `this` binding.
9851      *
9852      * The `_.partial.placeholder` value, which defaults to `_` in monolithic
9853      * builds, may be used as a placeholder for partially applied arguments.
9854      *
9855      * **Note:** This method doesn't set the "length" property of partially
9856      * applied functions.
9857      *
9858      * @static
9859      * @memberOf _
9860      * @since 0.2.0
9861      * @category Function
9862      * @param {Function} func The function to partially apply arguments to.
9863      * @param {...*} [partials] The arguments to be partially applied.
9864      * @returns {Function} Returns the new partially applied function.
9865      * @example
9866      *
9867      * var greet = function(greeting, name) {
9868      *   return greeting + ' ' + name;
9869      * };
9870      *
9871      * var sayHelloTo = _.partial(greet, 'hello');
9872      * sayHelloTo('fred');
9873      * // => 'hello fred'
9874      *
9875      * // Partially applied with placeholders.
9876      * var greetFred = _.partial(greet, _, 'fred');
9877      * greetFred('hi');
9878      * // => 'hi fred'
9879      */
9880     var partial = rest(function(func, partials) {
9881       var holders = replaceHolders(partials, getPlaceholder(partial));
9882       return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders);
9883     });
9884
9885     /**
9886      * This method is like `_.partial` except that partially applied arguments
9887      * are appended to the arguments it receives.
9888      *
9889      * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
9890      * builds, may be used as a placeholder for partially applied arguments.
9891      *
9892      * **Note:** This method doesn't set the "length" property of partially
9893      * applied functions.
9894      *
9895      * @static
9896      * @memberOf _
9897      * @since 1.0.0
9898      * @category Function
9899      * @param {Function} func The function to partially apply arguments to.
9900      * @param {...*} [partials] The arguments to be partially applied.
9901      * @returns {Function} Returns the new partially applied function.
9902      * @example
9903      *
9904      * var greet = function(greeting, name) {
9905      *   return greeting + ' ' + name;
9906      * };
9907      *
9908      * var greetFred = _.partialRight(greet, 'fred');
9909      * greetFred('hi');
9910      * // => 'hi fred'
9911      *
9912      * // Partially applied with placeholders.
9913      * var sayHelloTo = _.partialRight(greet, 'hello', _);
9914      * sayHelloTo('fred');
9915      * // => 'hello fred'
9916      */
9917     var partialRight = rest(function(func, partials) {
9918       var holders = replaceHolders(partials, getPlaceholder(partialRight));
9919       return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders);
9920     });
9921
9922     /**
9923      * Creates a function that invokes `func` with arguments arranged according
9924      * to the specified `indexes` where the argument value at the first index is
9925      * provided as the first argument, the argument value at the second index is
9926      * provided as the second argument, and so on.
9927      *
9928      * @static
9929      * @memberOf _
9930      * @since 3.0.0
9931      * @category Function
9932      * @param {Function} func The function to rearrange arguments for.
9933      * @param {...(number|number[])} indexes The arranged argument indexes.
9934      * @returns {Function} Returns the new function.
9935      * @example
9936      *
9937      * var rearged = _.rearg(function(a, b, c) {
9938      *   return [a, b, c];
9939      * }, 2, 0, 1);
9940      *
9941      * rearged('b', 'c', 'a')
9942      * // => ['a', 'b', 'c']
9943      */
9944     var rearg = rest(function(func, indexes) {
9945       return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes, 1));
9946     });
9947
9948     /**
9949      * Creates a function that invokes `func` with the `this` binding of the
9950      * created function and arguments from `start` and beyond provided as
9951      * an array.
9952      *
9953      * **Note:** This method is based on the
9954      * [rest parameter](https://mdn.io/rest_parameters).
9955      *
9956      * @static
9957      * @memberOf _
9958      * @since 4.0.0
9959      * @category Function
9960      * @param {Function} func The function to apply a rest parameter to.
9961      * @param {number} [start=func.length-1] The start position of the rest parameter.
9962      * @returns {Function} Returns the new function.
9963      * @example
9964      *
9965      * var say = _.rest(function(what, names) {
9966      *   return what + ' ' + _.initial(names).join(', ') +
9967      *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
9968      * });
9969      *
9970      * say('hello', 'fred', 'barney', 'pebbles');
9971      * // => 'hello fred, barney, & pebbles'
9972      */
9973     function rest(func, start) {
9974       if (typeof func != 'function') {
9975         throw new TypeError(FUNC_ERROR_TEXT);
9976       }
9977       start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
9978       return function() {
9979         var args = arguments,
9980             index = -1,
9981             length = nativeMax(args.length - start, 0),
9982             array = Array(length);
9983
9984         while (++index < length) {
9985           array[index] = args[start + index];
9986         }
9987         switch (start) {
9988           case 0: return func.call(this, array);
9989           case 1: return func.call(this, args[0], array);
9990           case 2: return func.call(this, args[0], args[1], array);
9991         }
9992         var otherArgs = Array(start + 1);
9993         index = -1;
9994         while (++index < start) {
9995           otherArgs[index] = args[index];
9996         }
9997         otherArgs[start] = array;
9998         return apply(func, this, otherArgs);
9999       };
10000     }
10001
10002     /**
10003      * Creates a function that invokes `func` with the `this` binding of the
10004      * create function and an array of arguments much like
10005      * [`Function#apply`](http://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.apply).
10006      *
10007      * **Note:** This method is based on the
10008      * [spread operator](https://mdn.io/spread_operator).
10009      *
10010      * @static
10011      * @memberOf _
10012      * @since 3.2.0
10013      * @category Function
10014      * @param {Function} func The function to spread arguments over.
10015      * @param {number} [start=0] The start position of the spread.
10016      * @returns {Function} Returns the new function.
10017      * @example
10018      *
10019      * var say = _.spread(function(who, what) {
10020      *   return who + ' says ' + what;
10021      * });
10022      *
10023      * say(['fred', 'hello']);
10024      * // => 'fred says hello'
10025      *
10026      * var numbers = Promise.all([
10027      *   Promise.resolve(40),
10028      *   Promise.resolve(36)
10029      * ]);
10030      *
10031      * numbers.then(_.spread(function(x, y) {
10032      *   return x + y;
10033      * }));
10034      * // => a Promise of 76
10035      */
10036     function spread(func, start) {
10037       if (typeof func != 'function') {
10038         throw new TypeError(FUNC_ERROR_TEXT);
10039       }
10040       start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
10041       return rest(function(args) {
10042         var array = args[start],
10043             otherArgs = castSlice(args, 0, start);
10044
10045         if (array) {
10046           arrayPush(otherArgs, array);
10047         }
10048         return apply(func, this, otherArgs);
10049       });
10050     }
10051
10052     /**
10053      * Creates a throttled function that only invokes `func` at most once per
10054      * every `wait` milliseconds. The throttled function comes with a `cancel`
10055      * method to cancel delayed `func` invocations and a `flush` method to
10056      * immediately invoke them. Provide an options object to indicate whether
10057      * `func` should be invoked on the leading and/or trailing edge of the `wait`
10058      * timeout. The `func` is invoked with the last arguments provided to the
10059      * throttled function. Subsequent calls to the throttled function return the
10060      * result of the last `func` invocation.
10061      *
10062      * **Note:** If `leading` and `trailing` options are `true`, `func` is
10063      * invoked on the trailing edge of the timeout only if the throttled function
10064      * is invoked more than once during the `wait` timeout.
10065      *
10066      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10067      * for details over the differences between `_.throttle` and `_.debounce`.
10068      *
10069      * @static
10070      * @memberOf _
10071      * @since 0.1.0
10072      * @category Function
10073      * @param {Function} func The function to throttle.
10074      * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
10075      * @param {Object} [options={}] The options object.
10076      * @param {boolean} [options.leading=true]
10077      *  Specify invoking on the leading edge of the timeout.
10078      * @param {boolean} [options.trailing=true]
10079      *  Specify invoking on the trailing edge of the timeout.
10080      * @returns {Function} Returns the new throttled function.
10081      * @example
10082      *
10083      * // Avoid excessively updating the position while scrolling.
10084      * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
10085      *
10086      * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
10087      * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
10088      * jQuery(element).on('click', throttled);
10089      *
10090      * // Cancel the trailing throttled invocation.
10091      * jQuery(window).on('popstate', throttled.cancel);
10092      */
10093     function throttle(func, wait, options) {
10094       var leading = true,
10095           trailing = true;
10096
10097       if (typeof func != 'function') {
10098         throw new TypeError(FUNC_ERROR_TEXT);
10099       }
10100       if (isObject(options)) {
10101         leading = 'leading' in options ? !!options.leading : leading;
10102         trailing = 'trailing' in options ? !!options.trailing : trailing;
10103       }
10104       return debounce(func, wait, {
10105         'leading': leading,
10106         'maxWait': wait,
10107         'trailing': trailing
10108       });
10109     }
10110
10111     /**
10112      * Creates a function that accepts up to one argument, ignoring any
10113      * additional arguments.
10114      *
10115      * @static
10116      * @memberOf _
10117      * @since 4.0.0
10118      * @category Function
10119      * @param {Function} func The function to cap arguments for.
10120      * @returns {Function} Returns the new function.
10121      * @example
10122      *
10123      * _.map(['6', '8', '10'], _.unary(parseInt));
10124      * // => [6, 8, 10]
10125      */
10126     function unary(func) {
10127       return ary(func, 1);
10128     }
10129
10130     /**
10131      * Creates a function that provides `value` to the wrapper function as its
10132      * first argument. Any additional arguments provided to the function are
10133      * appended to those provided to the wrapper function. The wrapper is invoked
10134      * with the `this` binding of the created function.
10135      *
10136      * @static
10137      * @memberOf _
10138      * @since 0.1.0
10139      * @category Function
10140      * @param {*} value The value to wrap.
10141      * @param {Function} [wrapper=identity] The wrapper function.
10142      * @returns {Function} Returns the new function.
10143      * @example
10144      *
10145      * var p = _.wrap(_.escape, function(func, text) {
10146      *   return '<p>' + func(text) + '</p>';
10147      * });
10148      *
10149      * p('fred, barney, & pebbles');
10150      * // => '<p>fred, barney, &amp; pebbles</p>'
10151      */
10152     function wrap(value, wrapper) {
10153       wrapper = wrapper == null ? identity : wrapper;
10154       return partial(wrapper, value);
10155     }
10156
10157     /*------------------------------------------------------------------------*/
10158
10159     /**
10160      * Casts `value` as an array if it's not one.
10161      *
10162      * @static
10163      * @memberOf _
10164      * @since 4.4.0
10165      * @category Lang
10166      * @param {*} value The value to inspect.
10167      * @returns {Array} Returns the cast array.
10168      * @example
10169      *
10170      * _.castArray(1);
10171      * // => [1]
10172      *
10173      * _.castArray({ 'a': 1 });
10174      * // => [{ 'a': 1 }]
10175      *
10176      * _.castArray('abc');
10177      * // => ['abc']
10178      *
10179      * _.castArray(null);
10180      * // => [null]
10181      *
10182      * _.castArray(undefined);
10183      * // => [undefined]
10184      *
10185      * _.castArray();
10186      * // => []
10187      *
10188      * var array = [1, 2, 3];
10189      * console.log(_.castArray(array) === array);
10190      * // => true
10191      */
10192     function castArray() {
10193       if (!arguments.length) {
10194         return [];
10195       }
10196       var value = arguments[0];
10197       return isArray(value) ? value : [value];
10198     }
10199
10200     /**
10201      * Creates a shallow clone of `value`.
10202      *
10203      * **Note:** This method is loosely based on the
10204      * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
10205      * and supports cloning arrays, array buffers, booleans, date objects, maps,
10206      * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
10207      * arrays. The own enumerable properties of `arguments` objects are cloned
10208      * as plain objects. An empty object is returned for uncloneable values such
10209      * as error objects, functions, DOM nodes, and WeakMaps.
10210      *
10211      * @static
10212      * @memberOf _
10213      * @since 0.1.0
10214      * @category Lang
10215      * @param {*} value The value to clone.
10216      * @returns {*} Returns the cloned value.
10217      * @see _.cloneDeep
10218      * @example
10219      *
10220      * var objects = [{ 'a': 1 }, { 'b': 2 }];
10221      *
10222      * var shallow = _.clone(objects);
10223      * console.log(shallow[0] === objects[0]);
10224      * // => true
10225      */
10226     function clone(value) {
10227       return baseClone(value, false, true);
10228     }
10229
10230     /**
10231      * This method is like `_.clone` except that it accepts `customizer` which
10232      * is invoked to produce the cloned value. If `customizer` returns `undefined`,
10233      * cloning is handled by the method instead. The `customizer` is invoked with
10234      * up to four arguments; (value [, index|key, object, stack]).
10235      *
10236      * @static
10237      * @memberOf _
10238      * @since 4.0.0
10239      * @category Lang
10240      * @param {*} value The value to clone.
10241      * @param {Function} [customizer] The function to customize cloning.
10242      * @returns {*} Returns the cloned value.
10243      * @see _.cloneDeepWith
10244      * @example
10245      *
10246      * function customizer(value) {
10247      *   if (_.isElement(value)) {
10248      *     return value.cloneNode(false);
10249      *   }
10250      * }
10251      *
10252      * var el = _.cloneWith(document.body, customizer);
10253      *
10254      * console.log(el === document.body);
10255      * // => false
10256      * console.log(el.nodeName);
10257      * // => 'BODY'
10258      * console.log(el.childNodes.length);
10259      * // => 0
10260      */
10261     function cloneWith(value, customizer) {
10262       return baseClone(value, false, true, customizer);
10263     }
10264
10265     /**
10266      * This method is like `_.clone` except that it recursively clones `value`.
10267      *
10268      * @static
10269      * @memberOf _
10270      * @since 1.0.0
10271      * @category Lang
10272      * @param {*} value The value to recursively clone.
10273      * @returns {*} Returns the deep cloned value.
10274      * @see _.clone
10275      * @example
10276      *
10277      * var objects = [{ 'a': 1 }, { 'b': 2 }];
10278      *
10279      * var deep = _.cloneDeep(objects);
10280      * console.log(deep[0] === objects[0]);
10281      * // => false
10282      */
10283     function cloneDeep(value) {
10284       return baseClone(value, true, true);
10285     }
10286
10287     /**
10288      * This method is like `_.cloneWith` except that it recursively clones `value`.
10289      *
10290      * @static
10291      * @memberOf _
10292      * @since 4.0.0
10293      * @category Lang
10294      * @param {*} value The value to recursively clone.
10295      * @param {Function} [customizer] The function to customize cloning.
10296      * @returns {*} Returns the deep cloned value.
10297      * @see _.cloneWith
10298      * @example
10299      *
10300      * function customizer(value) {
10301      *   if (_.isElement(value)) {
10302      *     return value.cloneNode(true);
10303      *   }
10304      * }
10305      *
10306      * var el = _.cloneDeepWith(document.body, customizer);
10307      *
10308      * console.log(el === document.body);
10309      * // => false
10310      * console.log(el.nodeName);
10311      * // => 'BODY'
10312      * console.log(el.childNodes.length);
10313      * // => 20
10314      */
10315     function cloneDeepWith(value, customizer) {
10316       return baseClone(value, true, true, customizer);
10317     }
10318
10319     /**
10320      * Performs a
10321      * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
10322      * comparison between two values to determine if they are equivalent.
10323      *
10324      * @static
10325      * @memberOf _
10326      * @since 4.0.0
10327      * @category Lang
10328      * @param {*} value The value to compare.
10329      * @param {*} other The other value to compare.
10330      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
10331      * @example
10332      *
10333      * var object = { 'user': 'fred' };
10334      * var other = { 'user': 'fred' };
10335      *
10336      * _.eq(object, object);
10337      * // => true
10338      *
10339      * _.eq(object, other);
10340      * // => false
10341      *
10342      * _.eq('a', 'a');
10343      * // => true
10344      *
10345      * _.eq('a', Object('a'));
10346      * // => false
10347      *
10348      * _.eq(NaN, NaN);
10349      * // => true
10350      */
10351     function eq(value, other) {
10352       return value === other || (value !== value && other !== other);
10353     }
10354
10355     /**
10356      * Checks if `value` is greater than `other`.
10357      *
10358      * @static
10359      * @memberOf _
10360      * @since 3.9.0
10361      * @category Lang
10362      * @param {*} value The value to compare.
10363      * @param {*} other The other value to compare.
10364      * @returns {boolean} Returns `true` if `value` is greater than `other`,
10365      *  else `false`.
10366      * @see _.lt
10367      * @example
10368      *
10369      * _.gt(3, 1);
10370      * // => true
10371      *
10372      * _.gt(3, 3);
10373      * // => false
10374      *
10375      * _.gt(1, 3);
10376      * // => false
10377      */
10378     var gt = createRelationalOperation(baseGt);
10379
10380     /**
10381      * Checks if `value` is greater than or equal to `other`.
10382      *
10383      * @static
10384      * @memberOf _
10385      * @since 3.9.0
10386      * @category Lang
10387      * @param {*} value The value to compare.
10388      * @param {*} other The other value to compare.
10389      * @returns {boolean} Returns `true` if `value` is greater than or equal to
10390      *  `other`, else `false`.
10391      * @see _.lte
10392      * @example
10393      *
10394      * _.gte(3, 1);
10395      * // => true
10396      *
10397      * _.gte(3, 3);
10398      * // => true
10399      *
10400      * _.gte(1, 3);
10401      * // => false
10402      */
10403     var gte = createRelationalOperation(function(value, other) {
10404       return value >= other;
10405     });
10406
10407     /**
10408      * Checks if `value` is likely an `arguments` object.
10409      *
10410      * @static
10411      * @memberOf _
10412      * @since 0.1.0
10413      * @category Lang
10414      * @param {*} value The value to check.
10415      * @returns {boolean} Returns `true` if `value` is correctly classified,
10416      *  else `false`.
10417      * @example
10418      *
10419      * _.isArguments(function() { return arguments; }());
10420      * // => true
10421      *
10422      * _.isArguments([1, 2, 3]);
10423      * // => false
10424      */
10425     function isArguments(value) {
10426       // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
10427       return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
10428         (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
10429     }
10430
10431     /**
10432      * Checks if `value` is classified as an `Array` object.
10433      *
10434      * @static
10435      * @memberOf _
10436      * @since 0.1.0
10437      * @type {Function}
10438      * @category Lang
10439      * @param {*} value The value to check.
10440      * @returns {boolean} Returns `true` if `value` is correctly classified,
10441      *  else `false`.
10442      * @example
10443      *
10444      * _.isArray([1, 2, 3]);
10445      * // => true
10446      *
10447      * _.isArray(document.body.children);
10448      * // => false
10449      *
10450      * _.isArray('abc');
10451      * // => false
10452      *
10453      * _.isArray(_.noop);
10454      * // => false
10455      */
10456     var isArray = Array.isArray;
10457
10458     /**
10459      * Checks if `value` is classified as an `ArrayBuffer` object.
10460      *
10461      * @static
10462      * @memberOf _
10463      * @since 4.3.0
10464      * @category Lang
10465      * @param {*} value The value to check.
10466      * @returns {boolean} Returns `true` if `value` is correctly classified,
10467      *  else `false`.
10468      * @example
10469      *
10470      * _.isArrayBuffer(new ArrayBuffer(2));
10471      * // => true
10472      *
10473      * _.isArrayBuffer(new Array(2));
10474      * // => false
10475      */
10476     function isArrayBuffer(value) {
10477       return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
10478     }
10479
10480     /**
10481      * Checks if `value` is array-like. A value is considered array-like if it's
10482      * not a function and has a `value.length` that's an integer greater than or
10483      * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
10484      *
10485      * @static
10486      * @memberOf _
10487      * @since 4.0.0
10488      * @category Lang
10489      * @param {*} value The value to check.
10490      * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
10491      * @example
10492      *
10493      * _.isArrayLike([1, 2, 3]);
10494      * // => true
10495      *
10496      * _.isArrayLike(document.body.children);
10497      * // => true
10498      *
10499      * _.isArrayLike('abc');
10500      * // => true
10501      *
10502      * _.isArrayLike(_.noop);
10503      * // => false
10504      */
10505     function isArrayLike(value) {
10506       return value != null && isLength(getLength(value)) && !isFunction(value);
10507     }
10508
10509     /**
10510      * This method is like `_.isArrayLike` except that it also checks if `value`
10511      * is an object.
10512      *
10513      * @static
10514      * @memberOf _
10515      * @since 4.0.0
10516      * @category Lang
10517      * @param {*} value The value to check.
10518      * @returns {boolean} Returns `true` if `value` is an array-like object,
10519      *  else `false`.
10520      * @example
10521      *
10522      * _.isArrayLikeObject([1, 2, 3]);
10523      * // => true
10524      *
10525      * _.isArrayLikeObject(document.body.children);
10526      * // => true
10527      *
10528      * _.isArrayLikeObject('abc');
10529      * // => false
10530      *
10531      * _.isArrayLikeObject(_.noop);
10532      * // => false
10533      */
10534     function isArrayLikeObject(value) {
10535       return isObjectLike(value) && isArrayLike(value);
10536     }
10537
10538     /**
10539      * Checks if `value` is classified as a boolean primitive or object.
10540      *
10541      * @static
10542      * @memberOf _
10543      * @since 0.1.0
10544      * @category Lang
10545      * @param {*} value The value to check.
10546      * @returns {boolean} Returns `true` if `value` is correctly classified,
10547      *  else `false`.
10548      * @example
10549      *
10550      * _.isBoolean(false);
10551      * // => true
10552      *
10553      * _.isBoolean(null);
10554      * // => false
10555      */
10556     function isBoolean(value) {
10557       return value === true || value === false ||
10558         (isObjectLike(value) && objectToString.call(value) == boolTag);
10559     }
10560
10561     /**
10562      * Checks if `value` is a buffer.
10563      *
10564      * @static
10565      * @memberOf _
10566      * @since 4.3.0
10567      * @category Lang
10568      * @param {*} value The value to check.
10569      * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
10570      * @example
10571      *
10572      * _.isBuffer(new Buffer(2));
10573      * // => true
10574      *
10575      * _.isBuffer(new Uint8Array(2));
10576      * // => false
10577      */
10578     var isBuffer = !Buffer ? constant(false) : function(value) {
10579       return value instanceof Buffer;
10580     };
10581
10582     /**
10583      * Checks if `value` is classified as a `Date` object.
10584      *
10585      * @static
10586      * @memberOf _
10587      * @since 0.1.0
10588      * @category Lang
10589      * @param {*} value The value to check.
10590      * @returns {boolean} Returns `true` if `value` is correctly classified,
10591      *  else `false`.
10592      * @example
10593      *
10594      * _.isDate(new Date);
10595      * // => true
10596      *
10597      * _.isDate('Mon April 23 2012');
10598      * // => false
10599      */
10600     function isDate(value) {
10601       return isObjectLike(value) && objectToString.call(value) == dateTag;
10602     }
10603
10604     /**
10605      * Checks if `value` is likely a DOM element.
10606      *
10607      * @static
10608      * @memberOf _
10609      * @since 0.1.0
10610      * @category Lang
10611      * @param {*} value The value to check.
10612      * @returns {boolean} Returns `true` if `value` is a DOM element,
10613      *  else `false`.
10614      * @example
10615      *
10616      * _.isElement(document.body);
10617      * // => true
10618      *
10619      * _.isElement('<body>');
10620      * // => false
10621      */
10622     function isElement(value) {
10623       return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
10624     }
10625
10626     /**
10627      * Checks if `value` is an empty object, collection, map, or set.
10628      *
10629      * Objects are considered empty if they have no own enumerable string keyed
10630      * properties.
10631      *
10632      * Array-like values such as `arguments` objects, arrays, buffers, strings, or
10633      * jQuery-like collections are considered empty if they have a `length` of `0`.
10634      * Similarly, maps and sets are considered empty if they have a `size` of `0`.
10635      *
10636      * @static
10637      * @memberOf _
10638      * @since 0.1.0
10639      * @category Lang
10640      * @param {*} value The value to check.
10641      * @returns {boolean} Returns `true` if `value` is empty, else `false`.
10642      * @example
10643      *
10644      * _.isEmpty(null);
10645      * // => true
10646      *
10647      * _.isEmpty(true);
10648      * // => true
10649      *
10650      * _.isEmpty(1);
10651      * // => true
10652      *
10653      * _.isEmpty([1, 2, 3]);
10654      * // => false
10655      *
10656      * _.isEmpty({ 'a': 1 });
10657      * // => false
10658      */
10659     function isEmpty(value) {
10660       if (isArrayLike(value) &&
10661           (isArray(value) || isString(value) || isFunction(value.splice) ||
10662             isArguments(value) || isBuffer(value))) {
10663         return !value.length;
10664       }
10665       if (isObjectLike(value)) {
10666         var tag = getTag(value);
10667         if (tag == mapTag || tag == setTag) {
10668           return !value.size;
10669         }
10670       }
10671       for (var key in value) {
10672         if (hasOwnProperty.call(value, key)) {
10673           return false;
10674         }
10675       }
10676       return !(nonEnumShadows && keys(value).length);
10677     }
10678
10679     /**
10680      * Performs a deep comparison between two values to determine if they are
10681      * equivalent.
10682      *
10683      * **Note:** This method supports comparing arrays, array buffers, booleans,
10684      * date objects, error objects, maps, numbers, `Object` objects, regexes,
10685      * sets, strings, symbols, and typed arrays. `Object` objects are compared
10686      * by their own, not inherited, enumerable properties. Functions and DOM
10687      * nodes are **not** supported.
10688      *
10689      * @static
10690      * @memberOf _
10691      * @since 0.1.0
10692      * @category Lang
10693      * @param {*} value The value to compare.
10694      * @param {*} other The other value to compare.
10695      * @returns {boolean} Returns `true` if the values are equivalent,
10696      *  else `false`.
10697      * @example
10698      *
10699      * var object = { 'user': 'fred' };
10700      * var other = { 'user': 'fred' };
10701      *
10702      * _.isEqual(object, other);
10703      * // => true
10704      *
10705      * object === other;
10706      * // => false
10707      */
10708     function isEqual(value, other) {
10709       return baseIsEqual(value, other);
10710     }
10711
10712     /**
10713      * This method is like `_.isEqual` except that it accepts `customizer` which
10714      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
10715      * are handled by the method instead. The `customizer` is invoked with up to
10716      * six arguments: (objValue, othValue [, index|key, object, other, stack]).
10717      *
10718      * @static
10719      * @memberOf _
10720      * @since 4.0.0
10721      * @category Lang
10722      * @param {*} value The value to compare.
10723      * @param {*} other The other value to compare.
10724      * @param {Function} [customizer] The function to customize comparisons.
10725      * @returns {boolean} Returns `true` if the values are equivalent,
10726      *  else `false`.
10727      * @example
10728      *
10729      * function isGreeting(value) {
10730      *   return /^h(?:i|ello)$/.test(value);
10731      * }
10732      *
10733      * function customizer(objValue, othValue) {
10734      *   if (isGreeting(objValue) && isGreeting(othValue)) {
10735      *     return true;
10736      *   }
10737      * }
10738      *
10739      * var array = ['hello', 'goodbye'];
10740      * var other = ['hi', 'goodbye'];
10741      *
10742      * _.isEqualWith(array, other, customizer);
10743      * // => true
10744      */
10745     function isEqualWith(value, other, customizer) {
10746       customizer = typeof customizer == 'function' ? customizer : undefined;
10747       var result = customizer ? customizer(value, other) : undefined;
10748       return result === undefined ? baseIsEqual(value, other, customizer) : !!result;
10749     }
10750
10751     /**
10752      * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
10753      * `SyntaxError`, `TypeError`, or `URIError` object.
10754      *
10755      * @static
10756      * @memberOf _
10757      * @since 3.0.0
10758      * @category Lang
10759      * @param {*} value The value to check.
10760      * @returns {boolean} Returns `true` if `value` is an error object,
10761      *  else `false`.
10762      * @example
10763      *
10764      * _.isError(new Error);
10765      * // => true
10766      *
10767      * _.isError(Error);
10768      * // => false
10769      */
10770     function isError(value) {
10771       if (!isObjectLike(value)) {
10772         return false;
10773       }
10774       return (objectToString.call(value) == errorTag) ||
10775         (typeof value.message == 'string' && typeof value.name == 'string');
10776     }
10777
10778     /**
10779      * Checks if `value` is a finite primitive number.
10780      *
10781      * **Note:** This method is based on
10782      * [`Number.isFinite`](https://mdn.io/Number/isFinite).
10783      *
10784      * @static
10785      * @memberOf _
10786      * @since 0.1.0
10787      * @category Lang
10788      * @param {*} value The value to check.
10789      * @returns {boolean} Returns `true` if `value` is a finite number,
10790      *  else `false`.
10791      * @example
10792      *
10793      * _.isFinite(3);
10794      * // => true
10795      *
10796      * _.isFinite(Number.MAX_VALUE);
10797      * // => true
10798      *
10799      * _.isFinite(3.14);
10800      * // => true
10801      *
10802      * _.isFinite(Infinity);
10803      * // => false
10804      */
10805     function isFinite(value) {
10806       return typeof value == 'number' && nativeIsFinite(value);
10807     }
10808
10809     /**
10810      * Checks if `value` is classified as a `Function` object.
10811      *
10812      * @static
10813      * @memberOf _
10814      * @since 0.1.0
10815      * @category Lang
10816      * @param {*} value The value to check.
10817      * @returns {boolean} Returns `true` if `value` is correctly classified,
10818      *  else `false`.
10819      * @example
10820      *
10821      * _.isFunction(_);
10822      * // => true
10823      *
10824      * _.isFunction(/abc/);
10825      * // => false
10826      */
10827     function isFunction(value) {
10828       // The use of `Object#toString` avoids issues with the `typeof` operator
10829       // in Safari 8 which returns 'object' for typed array and weak map constructors,
10830       // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
10831       var tag = isObject(value) ? objectToString.call(value) : '';
10832       return tag == funcTag || tag == genTag;
10833     }
10834
10835     /**
10836      * Checks if `value` is an integer.
10837      *
10838      * **Note:** This method is based on
10839      * [`Number.isInteger`](https://mdn.io/Number/isInteger).
10840      *
10841      * @static
10842      * @memberOf _
10843      * @since 4.0.0
10844      * @category Lang
10845      * @param {*} value The value to check.
10846      * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
10847      * @example
10848      *
10849      * _.isInteger(3);
10850      * // => true
10851      *
10852      * _.isInteger(Number.MIN_VALUE);
10853      * // => false
10854      *
10855      * _.isInteger(Infinity);
10856      * // => false
10857      *
10858      * _.isInteger('3');
10859      * // => false
10860      */
10861     function isInteger(value) {
10862       return typeof value == 'number' && value == toInteger(value);
10863     }
10864
10865     /**
10866      * Checks if `value` is a valid array-like length.
10867      *
10868      * **Note:** This function is loosely based on
10869      * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
10870      *
10871      * @static
10872      * @memberOf _
10873      * @since 4.0.0
10874      * @category Lang
10875      * @param {*} value The value to check.
10876      * @returns {boolean} Returns `true` if `value` is a valid length,
10877      *  else `false`.
10878      * @example
10879      *
10880      * _.isLength(3);
10881      * // => true
10882      *
10883      * _.isLength(Number.MIN_VALUE);
10884      * // => false
10885      *
10886      * _.isLength(Infinity);
10887      * // => false
10888      *
10889      * _.isLength('3');
10890      * // => false
10891      */
10892     function isLength(value) {
10893       return typeof value == 'number' &&
10894         value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
10895     }
10896
10897     /**
10898      * Checks if `value` is the
10899      * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
10900      * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
10901      *
10902      * @static
10903      * @memberOf _
10904      * @since 0.1.0
10905      * @category Lang
10906      * @param {*} value The value to check.
10907      * @returns {boolean} Returns `true` if `value` is an object, else `false`.
10908      * @example
10909      *
10910      * _.isObject({});
10911      * // => true
10912      *
10913      * _.isObject([1, 2, 3]);
10914      * // => true
10915      *
10916      * _.isObject(_.noop);
10917      * // => true
10918      *
10919      * _.isObject(null);
10920      * // => false
10921      */
10922     function isObject(value) {
10923       var type = typeof value;
10924       return !!value && (type == 'object' || type == 'function');
10925     }
10926
10927     /**
10928      * Checks if `value` is object-like. A value is object-like if it's not `null`
10929      * and has a `typeof` result of "object".
10930      *
10931      * @static
10932      * @memberOf _
10933      * @since 4.0.0
10934      * @category Lang
10935      * @param {*} value The value to check.
10936      * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
10937      * @example
10938      *
10939      * _.isObjectLike({});
10940      * // => true
10941      *
10942      * _.isObjectLike([1, 2, 3]);
10943      * // => true
10944      *
10945      * _.isObjectLike(_.noop);
10946      * // => false
10947      *
10948      * _.isObjectLike(null);
10949      * // => false
10950      */
10951     function isObjectLike(value) {
10952       return !!value && typeof value == 'object';
10953     }
10954
10955     /**
10956      * Checks if `value` is classified as a `Map` object.
10957      *
10958      * @static
10959      * @memberOf _
10960      * @since 4.3.0
10961      * @category Lang
10962      * @param {*} value The value to check.
10963      * @returns {boolean} Returns `true` if `value` is correctly classified,
10964      *  else `false`.
10965      * @example
10966      *
10967      * _.isMap(new Map);
10968      * // => true
10969      *
10970      * _.isMap(new WeakMap);
10971      * // => false
10972      */
10973     function isMap(value) {
10974       return isObjectLike(value) && getTag(value) == mapTag;
10975     }
10976
10977     /**
10978      * Performs a partial deep comparison between `object` and `source` to
10979      * determine if `object` contains equivalent property values. This method is
10980      * equivalent to a `_.matches` function when `source` is partially applied.
10981      *
10982      * **Note:** This method supports comparing the same values as `_.isEqual`.
10983      *
10984      * @static
10985      * @memberOf _
10986      * @since 3.0.0
10987      * @category Lang
10988      * @param {Object} object The object to inspect.
10989      * @param {Object} source The object of property values to match.
10990      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
10991      * @example
10992      *
10993      * var object = { 'user': 'fred', 'age': 40 };
10994      *
10995      * _.isMatch(object, { 'age': 40 });
10996      * // => true
10997      *
10998      * _.isMatch(object, { 'age': 36 });
10999      * // => false
11000      */
11001     function isMatch(object, source) {
11002       return object === source || baseIsMatch(object, source, getMatchData(source));
11003     }
11004
11005     /**
11006      * This method is like `_.isMatch` except that it accepts `customizer` which
11007      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11008      * are handled by the method instead. The `customizer` is invoked with five
11009      * arguments: (objValue, srcValue, index|key, object, source).
11010      *
11011      * @static
11012      * @memberOf _
11013      * @since 4.0.0
11014      * @category Lang
11015      * @param {Object} object The object to inspect.
11016      * @param {Object} source The object of property values to match.
11017      * @param {Function} [customizer] The function to customize comparisons.
11018      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11019      * @example
11020      *
11021      * function isGreeting(value) {
11022      *   return /^h(?:i|ello)$/.test(value);
11023      * }
11024      *
11025      * function customizer(objValue, srcValue) {
11026      *   if (isGreeting(objValue) && isGreeting(srcValue)) {
11027      *     return true;
11028      *   }
11029      * }
11030      *
11031      * var object = { 'greeting': 'hello' };
11032      * var source = { 'greeting': 'hi' };
11033      *
11034      * _.isMatchWith(object, source, customizer);
11035      * // => true
11036      */
11037     function isMatchWith(object, source, customizer) {
11038       customizer = typeof customizer == 'function' ? customizer : undefined;
11039       return baseIsMatch(object, source, getMatchData(source), customizer);
11040     }
11041
11042     /**
11043      * Checks if `value` is `NaN`.
11044      *
11045      * **Note:** This method is based on
11046      * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
11047      * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
11048      * `undefined` and other non-number values.
11049      *
11050      * @static
11051      * @memberOf _
11052      * @since 0.1.0
11053      * @category Lang
11054      * @param {*} value The value to check.
11055      * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
11056      * @example
11057      *
11058      * _.isNaN(NaN);
11059      * // => true
11060      *
11061      * _.isNaN(new Number(NaN));
11062      * // => true
11063      *
11064      * isNaN(undefined);
11065      * // => true
11066      *
11067      * _.isNaN(undefined);
11068      * // => false
11069      */
11070     function isNaN(value) {
11071       // An `NaN` primitive is the only value that is not equal to itself.
11072       // Perform the `toStringTag` check first to avoid errors with some
11073       // ActiveX objects in IE.
11074       return isNumber(value) && value != +value;
11075     }
11076
11077     /**
11078      * Checks if `value` is a native function.
11079      *
11080      * @static
11081      * @memberOf _
11082      * @since 3.0.0
11083      * @category Lang
11084      * @param {*} value The value to check.
11085      * @returns {boolean} Returns `true` if `value` is a native function,
11086      *  else `false`.
11087      * @example
11088      *
11089      * _.isNative(Array.prototype.push);
11090      * // => true
11091      *
11092      * _.isNative(_);
11093      * // => false
11094      */
11095     function isNative(value) {
11096       if (!isObject(value)) {
11097         return false;
11098       }
11099       var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
11100       return pattern.test(toSource(value));
11101     }
11102
11103     /**
11104      * Checks if `value` is `null`.
11105      *
11106      * @static
11107      * @memberOf _
11108      * @since 0.1.0
11109      * @category Lang
11110      * @param {*} value The value to check.
11111      * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
11112      * @example
11113      *
11114      * _.isNull(null);
11115      * // => true
11116      *
11117      * _.isNull(void 0);
11118      * // => false
11119      */
11120     function isNull(value) {
11121       return value === null;
11122     }
11123
11124     /**
11125      * Checks if `value` is `null` or `undefined`.
11126      *
11127      * @static
11128      * @memberOf _
11129      * @since 4.0.0
11130      * @category Lang
11131      * @param {*} value The value to check.
11132      * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
11133      * @example
11134      *
11135      * _.isNil(null);
11136      * // => true
11137      *
11138      * _.isNil(void 0);
11139      * // => true
11140      *
11141      * _.isNil(NaN);
11142      * // => false
11143      */
11144     function isNil(value) {
11145       return value == null;
11146     }
11147
11148     /**
11149      * Checks if `value` is classified as a `Number` primitive or object.
11150      *
11151      * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
11152      * classified as numbers, use the `_.isFinite` method.
11153      *
11154      * @static
11155      * @memberOf _
11156      * @since 0.1.0
11157      * @category Lang
11158      * @param {*} value The value to check.
11159      * @returns {boolean} Returns `true` if `value` is correctly classified,
11160      *  else `false`.
11161      * @example
11162      *
11163      * _.isNumber(3);
11164      * // => true
11165      *
11166      * _.isNumber(Number.MIN_VALUE);
11167      * // => true
11168      *
11169      * _.isNumber(Infinity);
11170      * // => true
11171      *
11172      * _.isNumber('3');
11173      * // => false
11174      */
11175     function isNumber(value) {
11176       return typeof value == 'number' ||
11177         (isObjectLike(value) && objectToString.call(value) == numberTag);
11178     }
11179
11180     /**
11181      * Checks if `value` is a plain object, that is, an object created by the
11182      * `Object` constructor or one with a `[[Prototype]]` of `null`.
11183      *
11184      * @static
11185      * @memberOf _
11186      * @since 0.8.0
11187      * @category Lang
11188      * @param {*} value The value to check.
11189      * @returns {boolean} Returns `true` if `value` is a plain object,
11190      *  else `false`.
11191      * @example
11192      *
11193      * function Foo() {
11194      *   this.a = 1;
11195      * }
11196      *
11197      * _.isPlainObject(new Foo);
11198      * // => false
11199      *
11200      * _.isPlainObject([1, 2, 3]);
11201      * // => false
11202      *
11203      * _.isPlainObject({ 'x': 0, 'y': 0 });
11204      * // => true
11205      *
11206      * _.isPlainObject(Object.create(null));
11207      * // => true
11208      */
11209     function isPlainObject(value) {
11210       if (!isObjectLike(value) ||
11211           objectToString.call(value) != objectTag || isHostObject(value)) {
11212         return false;
11213       }
11214       var proto = getPrototype(value);
11215       if (proto === null) {
11216         return true;
11217       }
11218       var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
11219       return (typeof Ctor == 'function' &&
11220         Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
11221     }
11222
11223     /**
11224      * Checks if `value` is classified as a `RegExp` object.
11225      *
11226      * @static
11227      * @memberOf _
11228      * @since 0.1.0
11229      * @category Lang
11230      * @param {*} value The value to check.
11231      * @returns {boolean} Returns `true` if `value` is correctly classified,
11232      *  else `false`.
11233      * @example
11234      *
11235      * _.isRegExp(/abc/);
11236      * // => true
11237      *
11238      * _.isRegExp('/abc/');
11239      * // => false
11240      */
11241     function isRegExp(value) {
11242       return isObject(value) && objectToString.call(value) == regexpTag;
11243     }
11244
11245     /**
11246      * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
11247      * double precision number which isn't the result of a rounded unsafe integer.
11248      *
11249      * **Note:** This method is based on
11250      * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
11251      *
11252      * @static
11253      * @memberOf _
11254      * @since 4.0.0
11255      * @category Lang
11256      * @param {*} value The value to check.
11257      * @returns {boolean} Returns `true` if `value` is a safe integer,
11258      *  else `false`.
11259      * @example
11260      *
11261      * _.isSafeInteger(3);
11262      * // => true
11263      *
11264      * _.isSafeInteger(Number.MIN_VALUE);
11265      * // => false
11266      *
11267      * _.isSafeInteger(Infinity);
11268      * // => false
11269      *
11270      * _.isSafeInteger('3');
11271      * // => false
11272      */
11273     function isSafeInteger(value) {
11274       return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
11275     }
11276
11277     /**
11278      * Checks if `value` is classified as a `Set` object.
11279      *
11280      * @static
11281      * @memberOf _
11282      * @since 4.3.0
11283      * @category Lang
11284      * @param {*} value The value to check.
11285      * @returns {boolean} Returns `true` if `value` is correctly classified,
11286      *  else `false`.
11287      * @example
11288      *
11289      * _.isSet(new Set);
11290      * // => true
11291      *
11292      * _.isSet(new WeakSet);
11293      * // => false
11294      */
11295     function isSet(value) {
11296       return isObjectLike(value) && getTag(value) == setTag;
11297     }
11298
11299     /**
11300      * Checks if `value` is classified as a `String` primitive or object.
11301      *
11302      * @static
11303      * @since 0.1.0
11304      * @memberOf _
11305      * @category Lang
11306      * @param {*} value The value to check.
11307      * @returns {boolean} Returns `true` if `value` is correctly classified,
11308      *  else `false`.
11309      * @example
11310      *
11311      * _.isString('abc');
11312      * // => true
11313      *
11314      * _.isString(1);
11315      * // => false
11316      */
11317     function isString(value) {
11318       return typeof value == 'string' ||
11319         (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
11320     }
11321
11322     /**
11323      * Checks if `value` is classified as a `Symbol` primitive or object.
11324      *
11325      * @static
11326      * @memberOf _
11327      * @since 4.0.0
11328      * @category Lang
11329      * @param {*} value The value to check.
11330      * @returns {boolean} Returns `true` if `value` is correctly classified,
11331      *  else `false`.
11332      * @example
11333      *
11334      * _.isSymbol(Symbol.iterator);
11335      * // => true
11336      *
11337      * _.isSymbol('abc');
11338      * // => false
11339      */
11340     function isSymbol(value) {
11341       return typeof value == 'symbol' ||
11342         (isObjectLike(value) && objectToString.call(value) == symbolTag);
11343     }
11344
11345     /**
11346      * Checks if `value` is classified as a typed array.
11347      *
11348      * @static
11349      * @memberOf _
11350      * @since 3.0.0
11351      * @category Lang
11352      * @param {*} value The value to check.
11353      * @returns {boolean} Returns `true` if `value` is correctly classified,
11354      *  else `false`.
11355      * @example
11356      *
11357      * _.isTypedArray(new Uint8Array);
11358      * // => true
11359      *
11360      * _.isTypedArray([]);
11361      * // => false
11362      */
11363     function isTypedArray(value) {
11364       return isObjectLike(value) &&
11365         isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
11366     }
11367
11368     /**
11369      * Checks if `value` is `undefined`.
11370      *
11371      * @static
11372      * @since 0.1.0
11373      * @memberOf _
11374      * @category Lang
11375      * @param {*} value The value to check.
11376      * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
11377      * @example
11378      *
11379      * _.isUndefined(void 0);
11380      * // => true
11381      *
11382      * _.isUndefined(null);
11383      * // => false
11384      */
11385     function isUndefined(value) {
11386       return value === undefined;
11387     }
11388
11389     /**
11390      * Checks if `value` is classified as a `WeakMap` object.
11391      *
11392      * @static
11393      * @memberOf _
11394      * @since 4.3.0
11395      * @category Lang
11396      * @param {*} value The value to check.
11397      * @returns {boolean} Returns `true` if `value` is correctly classified,
11398      *  else `false`.
11399      * @example
11400      *
11401      * _.isWeakMap(new WeakMap);
11402      * // => true
11403      *
11404      * _.isWeakMap(new Map);
11405      * // => false
11406      */
11407     function isWeakMap(value) {
11408       return isObjectLike(value) && getTag(value) == weakMapTag;
11409     }
11410
11411     /**
11412      * Checks if `value` is classified as a `WeakSet` object.
11413      *
11414      * @static
11415      * @memberOf _
11416      * @since 4.3.0
11417      * @category Lang
11418      * @param {*} value The value to check.
11419      * @returns {boolean} Returns `true` if `value` is correctly classified,
11420      *  else `false`.
11421      * @example
11422      *
11423      * _.isWeakSet(new WeakSet);
11424      * // => true
11425      *
11426      * _.isWeakSet(new Set);
11427      * // => false
11428      */
11429     function isWeakSet(value) {
11430       return isObjectLike(value) && objectToString.call(value) == weakSetTag;
11431     }
11432
11433     /**
11434      * Checks if `value` is less than `other`.
11435      *
11436      * @static
11437      * @memberOf _
11438      * @since 3.9.0
11439      * @category Lang
11440      * @param {*} value The value to compare.
11441      * @param {*} other The other value to compare.
11442      * @returns {boolean} Returns `true` if `value` is less than `other`,
11443      *  else `false`.
11444      * @see _.gt
11445      * @example
11446      *
11447      * _.lt(1, 3);
11448      * // => true
11449      *
11450      * _.lt(3, 3);
11451      * // => false
11452      *
11453      * _.lt(3, 1);
11454      * // => false
11455      */
11456     var lt = createRelationalOperation(baseLt);
11457
11458     /**
11459      * Checks if `value` is less than or equal to `other`.
11460      *
11461      * @static
11462      * @memberOf _
11463      * @since 3.9.0
11464      * @category Lang
11465      * @param {*} value The value to compare.
11466      * @param {*} other The other value to compare.
11467      * @returns {boolean} Returns `true` if `value` is less than or equal to
11468      *  `other`, else `false`.
11469      * @see _.gte
11470      * @example
11471      *
11472      * _.lte(1, 3);
11473      * // => true
11474      *
11475      * _.lte(3, 3);
11476      * // => true
11477      *
11478      * _.lte(3, 1);
11479      * // => false
11480      */
11481     var lte = createRelationalOperation(function(value, other) {
11482       return value <= other;
11483     });
11484
11485     /**
11486      * Converts `value` to an array.
11487      *
11488      * @static
11489      * @since 0.1.0
11490      * @memberOf _
11491      * @category Lang
11492      * @param {*} value The value to convert.
11493      * @returns {Array} Returns the converted array.
11494      * @example
11495      *
11496      * _.toArray({ 'a': 1, 'b': 2 });
11497      * // => [1, 2]
11498      *
11499      * _.toArray('abc');
11500      * // => ['a', 'b', 'c']
11501      *
11502      * _.toArray(1);
11503      * // => []
11504      *
11505      * _.toArray(null);
11506      * // => []
11507      */
11508     function toArray(value) {
11509       if (!value) {
11510         return [];
11511       }
11512       if (isArrayLike(value)) {
11513         return isString(value) ? stringToArray(value) : copyArray(value);
11514       }
11515       if (iteratorSymbol && value[iteratorSymbol]) {
11516         return iteratorToArray(value[iteratorSymbol]());
11517       }
11518       var tag = getTag(value),
11519           func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
11520
11521       return func(value);
11522     }
11523
11524     /**
11525      * Converts `value` to an integer.
11526      *
11527      * **Note:** This function is loosely based on
11528      * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
11529      *
11530      * @static
11531      * @memberOf _
11532      * @since 4.0.0
11533      * @category Lang
11534      * @param {*} value The value to convert.
11535      * @returns {number} Returns the converted integer.
11536      * @example
11537      *
11538      * _.toInteger(3);
11539      * // => 3
11540      *
11541      * _.toInteger(Number.MIN_VALUE);
11542      * // => 0
11543      *
11544      * _.toInteger(Infinity);
11545      * // => 1.7976931348623157e+308
11546      *
11547      * _.toInteger('3');
11548      * // => 3
11549      */
11550     function toInteger(value) {
11551       if (!value) {
11552         return value === 0 ? value : 0;
11553       }
11554       value = toNumber(value);
11555       if (value === INFINITY || value === -INFINITY) {
11556         var sign = (value < 0 ? -1 : 1);
11557         return sign * MAX_INTEGER;
11558       }
11559       var remainder = value % 1;
11560       return value === value ? (remainder ? value - remainder : value) : 0;
11561     }
11562
11563     /**
11564      * Converts `value` to an integer suitable for use as the length of an
11565      * array-like object.
11566      *
11567      * **Note:** This method is based on
11568      * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
11569      *
11570      * @static
11571      * @memberOf _
11572      * @since 4.0.0
11573      * @category Lang
11574      * @param {*} value The value to convert.
11575      * @returns {number} Returns the converted integer.
11576      * @example
11577      *
11578      * _.toLength(3);
11579      * // => 3
11580      *
11581      * _.toLength(Number.MIN_VALUE);
11582      * // => 0
11583      *
11584      * _.toLength(Infinity);
11585      * // => 4294967295
11586      *
11587      * _.toLength('3');
11588      * // => 3
11589      */
11590     function toLength(value) {
11591       return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
11592     }
11593
11594     /**
11595      * Converts `value` to a number.
11596      *
11597      * @static
11598      * @memberOf _
11599      * @since 4.0.0
11600      * @category Lang
11601      * @param {*} value The value to process.
11602      * @returns {number} Returns the number.
11603      * @example
11604      *
11605      * _.toNumber(3);
11606      * // => 3
11607      *
11608      * _.toNumber(Number.MIN_VALUE);
11609      * // => 5e-324
11610      *
11611      * _.toNumber(Infinity);
11612      * // => Infinity
11613      *
11614      * _.toNumber('3');
11615      * // => 3
11616      */
11617     function toNumber(value) {
11618       if (typeof value == 'number') {
11619         return value;
11620       }
11621       if (isSymbol(value)) {
11622         return NAN;
11623       }
11624       if (isObject(value)) {
11625         var other = isFunction(value.valueOf) ? value.valueOf() : value;
11626         value = isObject(other) ? (other + '') : other;
11627       }
11628       if (typeof value != 'string') {
11629         return value === 0 ? value : +value;
11630       }
11631       value = value.replace(reTrim, '');
11632       var isBinary = reIsBinary.test(value);
11633       return (isBinary || reIsOctal.test(value))
11634         ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
11635         : (reIsBadHex.test(value) ? NAN : +value);
11636     }
11637
11638     /**
11639      * Converts `value` to a plain object flattening inherited enumerable string
11640      * keyed properties of `value` to own properties of the plain object.
11641      *
11642      * @static
11643      * @memberOf _
11644      * @since 3.0.0
11645      * @category Lang
11646      * @param {*} value The value to convert.
11647      * @returns {Object} Returns the converted plain object.
11648      * @example
11649      *
11650      * function Foo() {
11651      *   this.b = 2;
11652      * }
11653      *
11654      * Foo.prototype.c = 3;
11655      *
11656      * _.assign({ 'a': 1 }, new Foo);
11657      * // => { 'a': 1, 'b': 2 }
11658      *
11659      * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
11660      * // => { 'a': 1, 'b': 2, 'c': 3 }
11661      */
11662     function toPlainObject(value) {
11663       return copyObject(value, keysIn(value));
11664     }
11665
11666     /**
11667      * Converts `value` to a safe integer. A safe integer can be compared and
11668      * represented correctly.
11669      *
11670      * @static
11671      * @memberOf _
11672      * @since 4.0.0
11673      * @category Lang
11674      * @param {*} value The value to convert.
11675      * @returns {number} Returns the converted integer.
11676      * @example
11677      *
11678      * _.toSafeInteger(3);
11679      * // => 3
11680      *
11681      * _.toSafeInteger(Number.MIN_VALUE);
11682      * // => 0
11683      *
11684      * _.toSafeInteger(Infinity);
11685      * // => 9007199254740991
11686      *
11687      * _.toSafeInteger('3');
11688      * // => 3
11689      */
11690     function toSafeInteger(value) {
11691       return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
11692     }
11693
11694     /**
11695      * Converts `value` to a string. An empty string is returned for `null`
11696      * and `undefined` values. The sign of `-0` is preserved.
11697      *
11698      * @static
11699      * @memberOf _
11700      * @since 4.0.0
11701      * @category Lang
11702      * @param {*} value The value to process.
11703      * @returns {string} Returns the string.
11704      * @example
11705      *
11706      * _.toString(null);
11707      * // => ''
11708      *
11709      * _.toString(-0);
11710      * // => '-0'
11711      *
11712      * _.toString([1, 2, 3]);
11713      * // => '1,2,3'
11714      */
11715     function toString(value) {
11716       return value == null ? '' : baseToString(value);
11717     }
11718
11719     /*------------------------------------------------------------------------*/
11720
11721     /**
11722      * Assigns own enumerable string keyed properties of source objects to the
11723      * destination object. Source objects are applied from left to right.
11724      * Subsequent sources overwrite property assignments of previous sources.
11725      *
11726      * **Note:** This method mutates `object` and is loosely based on
11727      * [`Object.assign`](https://mdn.io/Object/assign).
11728      *
11729      * @static
11730      * @memberOf _
11731      * @since 0.10.0
11732      * @category Object
11733      * @param {Object} object The destination object.
11734      * @param {...Object} [sources] The source objects.
11735      * @returns {Object} Returns `object`.
11736      * @see _.assignIn
11737      * @example
11738      *
11739      * function Foo() {
11740      *   this.c = 3;
11741      * }
11742      *
11743      * function Bar() {
11744      *   this.e = 5;
11745      * }
11746      *
11747      * Foo.prototype.d = 4;
11748      * Bar.prototype.f = 6;
11749      *
11750      * _.assign({ 'a': 1 }, new Foo, new Bar);
11751      * // => { 'a': 1, 'c': 3, 'e': 5 }
11752      */
11753     var assign = createAssigner(function(object, source) {
11754       if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
11755         copyObject(source, keys(source), object);
11756         return;
11757       }
11758       for (var key in source) {
11759         if (hasOwnProperty.call(source, key)) {
11760           assignValue(object, key, source[key]);
11761         }
11762       }
11763     });
11764
11765     /**
11766      * This method is like `_.assign` except that it iterates over own and
11767      * inherited source properties.
11768      *
11769      * **Note:** This method mutates `object`.
11770      *
11771      * @static
11772      * @memberOf _
11773      * @since 4.0.0
11774      * @alias extend
11775      * @category Object
11776      * @param {Object} object The destination object.
11777      * @param {...Object} [sources] The source objects.
11778      * @returns {Object} Returns `object`.
11779      * @see _.assign
11780      * @example
11781      *
11782      * function Foo() {
11783      *   this.b = 2;
11784      * }
11785      *
11786      * function Bar() {
11787      *   this.d = 4;
11788      * }
11789      *
11790      * Foo.prototype.c = 3;
11791      * Bar.prototype.e = 5;
11792      *
11793      * _.assignIn({ 'a': 1 }, new Foo, new Bar);
11794      * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
11795      */
11796     var assignIn = createAssigner(function(object, source) {
11797       if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
11798         copyObject(source, keysIn(source), object);
11799         return;
11800       }
11801       for (var key in source) {
11802         assignValue(object, key, source[key]);
11803       }
11804     });
11805
11806     /**
11807      * This method is like `_.assignIn` except that it accepts `customizer`
11808      * which is invoked to produce the assigned values. If `customizer` returns
11809      * `undefined`, assignment is handled by the method instead. The `customizer`
11810      * is invoked with five arguments: (objValue, srcValue, key, object, source).
11811      *
11812      * **Note:** This method mutates `object`.
11813      *
11814      * @static
11815      * @memberOf _
11816      * @since 4.0.0
11817      * @alias extendWith
11818      * @category Object
11819      * @param {Object} object The destination object.
11820      * @param {...Object} sources The source objects.
11821      * @param {Function} [customizer] The function to customize assigned values.
11822      * @returns {Object} Returns `object`.
11823      * @see _.assignWith
11824      * @example
11825      *
11826      * function customizer(objValue, srcValue) {
11827      *   return _.isUndefined(objValue) ? srcValue : objValue;
11828      * }
11829      *
11830      * var defaults = _.partialRight(_.assignInWith, customizer);
11831      *
11832      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
11833      * // => { 'a': 1, 'b': 2 }
11834      */
11835     var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
11836       copyObject(source, keysIn(source), object, customizer);
11837     });
11838
11839     /**
11840      * This method is like `_.assign` except that it accepts `customizer`
11841      * which is invoked to produce the assigned values. If `customizer` returns
11842      * `undefined`, assignment is handled by the method instead. The `customizer`
11843      * is invoked with five arguments: (objValue, srcValue, key, object, source).
11844      *
11845      * **Note:** This method mutates `object`.
11846      *
11847      * @static
11848      * @memberOf _
11849      * @since 4.0.0
11850      * @category Object
11851      * @param {Object} object The destination object.
11852      * @param {...Object} sources The source objects.
11853      * @param {Function} [customizer] The function to customize assigned values.
11854      * @returns {Object} Returns `object`.
11855      * @see _.assignInWith
11856      * @example
11857      *
11858      * function customizer(objValue, srcValue) {
11859      *   return _.isUndefined(objValue) ? srcValue : objValue;
11860      * }
11861      *
11862      * var defaults = _.partialRight(_.assignWith, customizer);
11863      *
11864      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
11865      * // => { 'a': 1, 'b': 2 }
11866      */
11867     var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
11868       copyObject(source, keys(source), object, customizer);
11869     });
11870
11871     /**
11872      * Creates an array of values corresponding to `paths` of `object`.
11873      *
11874      * @static
11875      * @memberOf _
11876      * @since 1.0.0
11877      * @category Object
11878      * @param {Object} object The object to iterate over.
11879      * @param {...(string|string[])} [paths] The property paths of elements to pick.
11880      * @returns {Array} Returns the new array of picked elements.
11881      * @example
11882      *
11883      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
11884      *
11885      * _.at(object, ['a[0].b.c', 'a[1]']);
11886      * // => [3, 4]
11887      *
11888      * _.at(['a', 'b', 'c'], 0, 2);
11889      * // => ['a', 'c']
11890      */
11891     var at = rest(function(object, paths) {
11892       return baseAt(object, baseFlatten(paths, 1));
11893     });
11894
11895     /**
11896      * Creates an object that inherits from the `prototype` object. If a
11897      * `properties` object is given, its own enumerable string keyed properties
11898      * are assigned to the created object.
11899      *
11900      * @static
11901      * @memberOf _
11902      * @since 2.3.0
11903      * @category Object
11904      * @param {Object} prototype The object to inherit from.
11905      * @param {Object} [properties] The properties to assign to the object.
11906      * @returns {Object} Returns the new object.
11907      * @example
11908      *
11909      * function Shape() {
11910      *   this.x = 0;
11911      *   this.y = 0;
11912      * }
11913      *
11914      * function Circle() {
11915      *   Shape.call(this);
11916      * }
11917      *
11918      * Circle.prototype = _.create(Shape.prototype, {
11919      *   'constructor': Circle
11920      * });
11921      *
11922      * var circle = new Circle;
11923      * circle instanceof Circle;
11924      * // => true
11925      *
11926      * circle instanceof Shape;
11927      * // => true
11928      */
11929     function create(prototype, properties) {
11930       var result = baseCreate(prototype);
11931       return properties ? baseAssign(result, properties) : result;
11932     }
11933
11934     /**
11935      * Assigns own and inherited enumerable string keyed properties of source
11936      * objects to the destination object for all destination properties that
11937      * resolve to `undefined`. Source objects are applied from left to right.
11938      * Once a property is set, additional values of the same property are ignored.
11939      *
11940      * **Note:** This method mutates `object`.
11941      *
11942      * @static
11943      * @since 0.1.0
11944      * @memberOf _
11945      * @category Object
11946      * @param {Object} object The destination object.
11947      * @param {...Object} [sources] The source objects.
11948      * @returns {Object} Returns `object`.
11949      * @see _.defaultsDeep
11950      * @example
11951      *
11952      * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
11953      * // => { 'user': 'barney', 'age': 36 }
11954      */
11955     var defaults = rest(function(args) {
11956       args.push(undefined, assignInDefaults);
11957       return apply(assignInWith, undefined, args);
11958     });
11959
11960     /**
11961      * This method is like `_.defaults` except that it recursively assigns
11962      * default properties.
11963      *
11964      * **Note:** This method mutates `object`.
11965      *
11966      * @static
11967      * @memberOf _
11968      * @since 3.10.0
11969      * @category Object
11970      * @param {Object} object The destination object.
11971      * @param {...Object} [sources] The source objects.
11972      * @returns {Object} Returns `object`.
11973      * @see _.defaults
11974      * @example
11975      *
11976      * _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });
11977      * // => { 'user': { 'name': 'barney', 'age': 36 } }
11978      *
11979      */
11980     var defaultsDeep = rest(function(args) {
11981       args.push(undefined, mergeDefaults);
11982       return apply(mergeWith, undefined, args);
11983     });
11984
11985     /**
11986      * This method is like `_.find` except that it returns the key of the first
11987      * element `predicate` returns truthy for instead of the element itself.
11988      *
11989      * @static
11990      * @memberOf _
11991      * @since 1.1.0
11992      * @category Object
11993      * @param {Object} object The object to search.
11994      * @param {Array|Function|Object|string} [predicate=_.identity]
11995      *  The function invoked per iteration.
11996      * @returns {string|undefined} Returns the key of the matched element,
11997      *  else `undefined`.
11998      * @example
11999      *
12000      * var users = {
12001      *   'barney':  { 'age': 36, 'active': true },
12002      *   'fred':    { 'age': 40, 'active': false },
12003      *   'pebbles': { 'age': 1,  'active': true }
12004      * };
12005      *
12006      * _.findKey(users, function(o) { return o.age < 40; });
12007      * // => 'barney' (iteration order is not guaranteed)
12008      *
12009      * // The `_.matches` iteratee shorthand.
12010      * _.findKey(users, { 'age': 1, 'active': true });
12011      * // => 'pebbles'
12012      *
12013      * // The `_.matchesProperty` iteratee shorthand.
12014      * _.findKey(users, ['active', false]);
12015      * // => 'fred'
12016      *
12017      * // The `_.property` iteratee shorthand.
12018      * _.findKey(users, 'active');
12019      * // => 'barney'
12020      */
12021     function findKey(object, predicate) {
12022       return baseFind(object, getIteratee(predicate, 3), baseForOwn, true);
12023     }
12024
12025     /**
12026      * This method is like `_.findKey` except that it iterates over elements of
12027      * a collection in the opposite order.
12028      *
12029      * @static
12030      * @memberOf _
12031      * @since 2.0.0
12032      * @category Object
12033      * @param {Object} object The object to search.
12034      * @param {Array|Function|Object|string} [predicate=_.identity]
12035      *  The function invoked per iteration.
12036      * @returns {string|undefined} Returns the key of the matched element,
12037      *  else `undefined`.
12038      * @example
12039      *
12040      * var users = {
12041      *   'barney':  { 'age': 36, 'active': true },
12042      *   'fred':    { 'age': 40, 'active': false },
12043      *   'pebbles': { 'age': 1,  'active': true }
12044      * };
12045      *
12046      * _.findLastKey(users, function(o) { return o.age < 40; });
12047      * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
12048      *
12049      * // The `_.matches` iteratee shorthand.
12050      * _.findLastKey(users, { 'age': 36, 'active': true });
12051      * // => 'barney'
12052      *
12053      * // The `_.matchesProperty` iteratee shorthand.
12054      * _.findLastKey(users, ['active', false]);
12055      * // => 'fred'
12056      *
12057      * // The `_.property` iteratee shorthand.
12058      * _.findLastKey(users, 'active');
12059      * // => 'pebbles'
12060      */
12061     function findLastKey(object, predicate) {
12062       return baseFind(object, getIteratee(predicate, 3), baseForOwnRight, true);
12063     }
12064
12065     /**
12066      * Iterates over own and inherited enumerable string keyed properties of an
12067      * object and invokes `iteratee` for each property. The iteratee is invoked
12068      * with three arguments: (value, key, object). Iteratee functions may exit
12069      * iteration early by explicitly returning `false`.
12070      *
12071      * @static
12072      * @memberOf _
12073      * @since 0.3.0
12074      * @category Object
12075      * @param {Object} object The object to iterate over.
12076      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12077      * @returns {Object} Returns `object`.
12078      * @see _.forInRight
12079      * @example
12080      *
12081      * function Foo() {
12082      *   this.a = 1;
12083      *   this.b = 2;
12084      * }
12085      *
12086      * Foo.prototype.c = 3;
12087      *
12088      * _.forIn(new Foo, function(value, key) {
12089      *   console.log(key);
12090      * });
12091      * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
12092      */
12093     function forIn(object, iteratee) {
12094       return object == null
12095         ? object
12096         : baseFor(object, getIteratee(iteratee), keysIn);
12097     }
12098
12099     /**
12100      * This method is like `_.forIn` except that it iterates over properties of
12101      * `object` in the opposite order.
12102      *
12103      * @static
12104      * @memberOf _
12105      * @since 2.0.0
12106      * @category Object
12107      * @param {Object} object The object to iterate over.
12108      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12109      * @returns {Object} Returns `object`.
12110      * @see _.forIn
12111      * @example
12112      *
12113      * function Foo() {
12114      *   this.a = 1;
12115      *   this.b = 2;
12116      * }
12117      *
12118      * Foo.prototype.c = 3;
12119      *
12120      * _.forInRight(new Foo, function(value, key) {
12121      *   console.log(key);
12122      * });
12123      * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
12124      */
12125     function forInRight(object, iteratee) {
12126       return object == null
12127         ? object
12128         : baseForRight(object, getIteratee(iteratee), keysIn);
12129     }
12130
12131     /**
12132      * Iterates over own enumerable string keyed properties of an object and
12133      * invokes `iteratee` for each property. The iteratee is invoked with three
12134      * arguments: (value, key, object). Iteratee functions may exit iteration
12135      * early by explicitly returning `false`.
12136      *
12137      * @static
12138      * @memberOf _
12139      * @since 0.3.0
12140      * @category Object
12141      * @param {Object} object The object to iterate over.
12142      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12143      * @returns {Object} Returns `object`.
12144      * @see _.forOwnRight
12145      * @example
12146      *
12147      * function Foo() {
12148      *   this.a = 1;
12149      *   this.b = 2;
12150      * }
12151      *
12152      * Foo.prototype.c = 3;
12153      *
12154      * _.forOwn(new Foo, function(value, key) {
12155      *   console.log(key);
12156      * });
12157      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
12158      */
12159     function forOwn(object, iteratee) {
12160       return object && baseForOwn(object, getIteratee(iteratee));
12161     }
12162
12163     /**
12164      * This method is like `_.forOwn` except that it iterates over properties of
12165      * `object` in the opposite order.
12166      *
12167      * @static
12168      * @memberOf _
12169      * @since 2.0.0
12170      * @category Object
12171      * @param {Object} object The object to iterate over.
12172      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12173      * @returns {Object} Returns `object`.
12174      * @see _.forOwn
12175      * @example
12176      *
12177      * function Foo() {
12178      *   this.a = 1;
12179      *   this.b = 2;
12180      * }
12181      *
12182      * Foo.prototype.c = 3;
12183      *
12184      * _.forOwnRight(new Foo, function(value, key) {
12185      *   console.log(key);
12186      * });
12187      * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
12188      */
12189     function forOwnRight(object, iteratee) {
12190       return object && baseForOwnRight(object, getIteratee(iteratee));
12191     }
12192
12193     /**
12194      * Creates an array of function property names from own enumerable properties
12195      * of `object`.
12196      *
12197      * @static
12198      * @since 0.1.0
12199      * @memberOf _
12200      * @category Object
12201      * @param {Object} object The object to inspect.
12202      * @returns {Array} Returns the new array of property names.
12203      * @see _.functionsIn
12204      * @example
12205      *
12206      * function Foo() {
12207      *   this.a = _.constant('a');
12208      *   this.b = _.constant('b');
12209      * }
12210      *
12211      * Foo.prototype.c = _.constant('c');
12212      *
12213      * _.functions(new Foo);
12214      * // => ['a', 'b']
12215      */
12216     function functions(object) {
12217       return object == null ? [] : baseFunctions(object, keys(object));
12218     }
12219
12220     /**
12221      * Creates an array of function property names from own and inherited
12222      * enumerable properties of `object`.
12223      *
12224      * @static
12225      * @memberOf _
12226      * @since 4.0.0
12227      * @category Object
12228      * @param {Object} object The object to inspect.
12229      * @returns {Array} Returns the new array of property names.
12230      * @see _.functions
12231      * @example
12232      *
12233      * function Foo() {
12234      *   this.a = _.constant('a');
12235      *   this.b = _.constant('b');
12236      * }
12237      *
12238      * Foo.prototype.c = _.constant('c');
12239      *
12240      * _.functionsIn(new Foo);
12241      * // => ['a', 'b', 'c']
12242      */
12243     function functionsIn(object) {
12244       return object == null ? [] : baseFunctions(object, keysIn(object));
12245     }
12246
12247     /**
12248      * Gets the value at `path` of `object`. If the resolved value is
12249      * `undefined`, the `defaultValue` is used in its place.
12250      *
12251      * @static
12252      * @memberOf _
12253      * @since 3.7.0
12254      * @category Object
12255      * @param {Object} object The object to query.
12256      * @param {Array|string} path The path of the property to get.
12257      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
12258      * @returns {*} Returns the resolved value.
12259      * @example
12260      *
12261      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
12262      *
12263      * _.get(object, 'a[0].b.c');
12264      * // => 3
12265      *
12266      * _.get(object, ['a', '0', 'b', 'c']);
12267      * // => 3
12268      *
12269      * _.get(object, 'a.b.c', 'default');
12270      * // => 'default'
12271      */
12272     function get(object, path, defaultValue) {
12273       var result = object == null ? undefined : baseGet(object, path);
12274       return result === undefined ? defaultValue : result;
12275     }
12276
12277     /**
12278      * Checks if `path` is a direct property of `object`.
12279      *
12280      * @static
12281      * @since 0.1.0
12282      * @memberOf _
12283      * @category Object
12284      * @param {Object} object The object to query.
12285      * @param {Array|string} path The path to check.
12286      * @returns {boolean} Returns `true` if `path` exists, else `false`.
12287      * @example
12288      *
12289      * var object = { 'a': { 'b': 2 } };
12290      * var other = _.create({ 'a': _.create({ 'b': 2 }) });
12291      *
12292      * _.has(object, 'a');
12293      * // => true
12294      *
12295      * _.has(object, 'a.b');
12296      * // => true
12297      *
12298      * _.has(object, ['a', 'b']);
12299      * // => true
12300      *
12301      * _.has(other, 'a');
12302      * // => false
12303      */
12304     function has(object, path) {
12305       return object != null && hasPath(object, path, baseHas);
12306     }
12307
12308     /**
12309      * Checks if `path` is a direct or inherited property of `object`.
12310      *
12311      * @static
12312      * @memberOf _
12313      * @since 4.0.0
12314      * @category Object
12315      * @param {Object} object The object to query.
12316      * @param {Array|string} path The path to check.
12317      * @returns {boolean} Returns `true` if `path` exists, else `false`.
12318      * @example
12319      *
12320      * var object = _.create({ 'a': _.create({ 'b': 2 }) });
12321      *
12322      * _.hasIn(object, 'a');
12323      * // => true
12324      *
12325      * _.hasIn(object, 'a.b');
12326      * // => true
12327      *
12328      * _.hasIn(object, ['a', 'b']);
12329      * // => true
12330      *
12331      * _.hasIn(object, 'b');
12332      * // => false
12333      */
12334     function hasIn(object, path) {
12335       return object != null && hasPath(object, path, baseHasIn);
12336     }
12337
12338     /**
12339      * Creates an object composed of the inverted keys and values of `object`.
12340      * If `object` contains duplicate values, subsequent values overwrite
12341      * property assignments of previous values.
12342      *
12343      * @static
12344      * @memberOf _
12345      * @since 0.7.0
12346      * @category Object
12347      * @param {Object} object The object to invert.
12348      * @returns {Object} Returns the new inverted object.
12349      * @example
12350      *
12351      * var object = { 'a': 1, 'b': 2, 'c': 1 };
12352      *
12353      * _.invert(object);
12354      * // => { '1': 'c', '2': 'b' }
12355      */
12356     var invert = createInverter(function(result, value, key) {
12357       result[value] = key;
12358     }, constant(identity));
12359
12360     /**
12361      * This method is like `_.invert` except that the inverted object is generated
12362      * from the results of running each element of `object` thru `iteratee`. The
12363      * corresponding inverted value of each inverted key is an array of keys
12364      * responsible for generating the inverted value. The iteratee is invoked
12365      * with one argument: (value).
12366      *
12367      * @static
12368      * @memberOf _
12369      * @since 4.1.0
12370      * @category Object
12371      * @param {Object} object The object to invert.
12372      * @param {Array|Function|Object|string} [iteratee=_.identity]
12373      *  The iteratee invoked per element.
12374      * @returns {Object} Returns the new inverted object.
12375      * @example
12376      *
12377      * var object = { 'a': 1, 'b': 2, 'c': 1 };
12378      *
12379      * _.invertBy(object);
12380      * // => { '1': ['a', 'c'], '2': ['b'] }
12381      *
12382      * _.invertBy(object, function(value) {
12383      *   return 'group' + value;
12384      * });
12385      * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
12386      */
12387     var invertBy = createInverter(function(result, value, key) {
12388       if (hasOwnProperty.call(result, value)) {
12389         result[value].push(key);
12390       } else {
12391         result[value] = [key];
12392       }
12393     }, getIteratee);
12394
12395     /**
12396      * Invokes the method at `path` of `object`.
12397      *
12398      * @static
12399      * @memberOf _
12400      * @since 4.0.0
12401      * @category Object
12402      * @param {Object} object The object to query.
12403      * @param {Array|string} path The path of the method to invoke.
12404      * @param {...*} [args] The arguments to invoke the method with.
12405      * @returns {*} Returns the result of the invoked method.
12406      * @example
12407      *
12408      * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
12409      *
12410      * _.invoke(object, 'a[0].b.c.slice', 1, 3);
12411      * // => [2, 3]
12412      */
12413     var invoke = rest(baseInvoke);
12414
12415     /**
12416      * Creates an array of the own enumerable property names of `object`.
12417      *
12418      * **Note:** Non-object values are coerced to objects. See the
12419      * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
12420      * for more details.
12421      *
12422      * @static
12423      * @since 0.1.0
12424      * @memberOf _
12425      * @category Object
12426      * @param {Object} object The object to query.
12427      * @returns {Array} Returns the array of property names.
12428      * @example
12429      *
12430      * function Foo() {
12431      *   this.a = 1;
12432      *   this.b = 2;
12433      * }
12434      *
12435      * Foo.prototype.c = 3;
12436      *
12437      * _.keys(new Foo);
12438      * // => ['a', 'b'] (iteration order is not guaranteed)
12439      *
12440      * _.keys('hi');
12441      * // => ['0', '1']
12442      */
12443     function keys(object) {
12444       var isProto = isPrototype(object);
12445       if (!(isProto || isArrayLike(object))) {
12446         return baseKeys(object);
12447       }
12448       var indexes = indexKeys(object),
12449           skipIndexes = !!indexes,
12450           result = indexes || [],
12451           length = result.length;
12452
12453       for (var key in object) {
12454         if (baseHas(object, key) &&
12455             !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
12456             !(isProto && key == 'constructor')) {
12457           result.push(key);
12458         }
12459       }
12460       return result;
12461     }
12462
12463     /**
12464      * Creates an array of the own and inherited enumerable property names of `object`.
12465      *
12466      * **Note:** Non-object values are coerced to objects.
12467      *
12468      * @static
12469      * @memberOf _
12470      * @since 3.0.0
12471      * @category Object
12472      * @param {Object} object The object to query.
12473      * @returns {Array} Returns the array of property names.
12474      * @example
12475      *
12476      * function Foo() {
12477      *   this.a = 1;
12478      *   this.b = 2;
12479      * }
12480      *
12481      * Foo.prototype.c = 3;
12482      *
12483      * _.keysIn(new Foo);
12484      * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
12485      */
12486     function keysIn(object) {
12487       var index = -1,
12488           isProto = isPrototype(object),
12489           props = baseKeysIn(object),
12490           propsLength = props.length,
12491           indexes = indexKeys(object),
12492           skipIndexes = !!indexes,
12493           result = indexes || [],
12494           length = result.length;
12495
12496       while (++index < propsLength) {
12497         var key = props[index];
12498         if (!(skipIndexes && (key == 'length' || isIndex(key, length))) &&
12499             !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
12500           result.push(key);
12501         }
12502       }
12503       return result;
12504     }
12505
12506     /**
12507      * The opposite of `_.mapValues`; this method creates an object with the
12508      * same values as `object` and keys generated by running each own enumerable
12509      * string keyed property of `object` thru `iteratee`. The iteratee is invoked
12510      * with three arguments: (value, key, object).
12511      *
12512      * @static
12513      * @memberOf _
12514      * @since 3.8.0
12515      * @category Object
12516      * @param {Object} object The object to iterate over.
12517      * @param {Array|Function|Object|string} [iteratee=_.identity]
12518      *  The function invoked per iteration.
12519      * @returns {Object} Returns the new mapped object.
12520      * @see _.mapValues
12521      * @example
12522      *
12523      * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
12524      *   return key + value;
12525      * });
12526      * // => { 'a1': 1, 'b2': 2 }
12527      */
12528     function mapKeys(object, iteratee) {
12529       var result = {};
12530       iteratee = getIteratee(iteratee, 3);
12531
12532       baseForOwn(object, function(value, key, object) {
12533         result[iteratee(value, key, object)] = value;
12534       });
12535       return result;
12536     }
12537
12538     /**
12539      * Creates an object with the same keys as `object` and values generated
12540      * by running each own enumerable string keyed property of `object` thru
12541      * `iteratee`. The iteratee is invoked with three arguments:
12542      * (value, key, object).
12543      *
12544      * @static
12545      * @memberOf _
12546      * @since 2.4.0
12547      * @category Object
12548      * @param {Object} object The object to iterate over.
12549      * @param {Array|Function|Object|string} [iteratee=_.identity]
12550      *  The function invoked per iteration.
12551      * @returns {Object} Returns the new mapped object.
12552      * @see _.mapKeys
12553      * @example
12554      *
12555      * var users = {
12556      *   'fred':    { 'user': 'fred',    'age': 40 },
12557      *   'pebbles': { 'user': 'pebbles', 'age': 1 }
12558      * };
12559      *
12560      * _.mapValues(users, function(o) { return o.age; });
12561      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
12562      *
12563      * // The `_.property` iteratee shorthand.
12564      * _.mapValues(users, 'age');
12565      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
12566      */
12567     function mapValues(object, iteratee) {
12568       var result = {};
12569       iteratee = getIteratee(iteratee, 3);
12570
12571       baseForOwn(object, function(value, key, object) {
12572         result[key] = iteratee(value, key, object);
12573       });
12574       return result;
12575     }
12576
12577     /**
12578      * This method is like `_.assign` except that it recursively merges own and
12579      * inherited enumerable string keyed properties of source objects into the
12580      * destination object. Source properties that resolve to `undefined` are
12581      * skipped if a destination value exists. Array and plain object properties
12582      * are merged recursively.Other objects and value types are overridden by
12583      * assignment. Source objects are applied from left to right. Subsequent
12584      * sources overwrite property assignments of previous sources.
12585      *
12586      * **Note:** This method mutates `object`.
12587      *
12588      * @static
12589      * @memberOf _
12590      * @since 0.5.0
12591      * @category Object
12592      * @param {Object} object The destination object.
12593      * @param {...Object} [sources] The source objects.
12594      * @returns {Object} Returns `object`.
12595      * @example
12596      *
12597      * var users = {
12598      *   'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
12599      * };
12600      *
12601      * var ages = {
12602      *   'data': [{ 'age': 36 }, { 'age': 40 }]
12603      * };
12604      *
12605      * _.merge(users, ages);
12606      * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
12607      */
12608     var merge = createAssigner(function(object, source, srcIndex) {
12609       baseMerge(object, source, srcIndex);
12610     });
12611
12612     /**
12613      * This method is like `_.merge` except that it accepts `customizer` which
12614      * is invoked to produce the merged values of the destination and source
12615      * properties. If `customizer` returns `undefined`, merging is handled by the
12616      * method instead. The `customizer` is invoked with seven arguments:
12617      * (objValue, srcValue, key, object, source, stack).
12618      *
12619      * **Note:** This method mutates `object`.
12620      *
12621      * @static
12622      * @memberOf _
12623      * @since 4.0.0
12624      * @category Object
12625      * @param {Object} object The destination object.
12626      * @param {...Object} sources The source objects.
12627      * @param {Function} customizer The function to customize assigned values.
12628      * @returns {Object} Returns `object`.
12629      * @example
12630      *
12631      * function customizer(objValue, srcValue) {
12632      *   if (_.isArray(objValue)) {
12633      *     return objValue.concat(srcValue);
12634      *   }
12635      * }
12636      *
12637      * var object = {
12638      *   'fruits': ['apple'],
12639      *   'vegetables': ['beet']
12640      * };
12641      *
12642      * var other = {
12643      *   'fruits': ['banana'],
12644      *   'vegetables': ['carrot']
12645      * };
12646      *
12647      * _.mergeWith(object, other, customizer);
12648      * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
12649      */
12650     var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
12651       baseMerge(object, source, srcIndex, customizer);
12652     });
12653
12654     /**
12655      * The opposite of `_.pick`; this method creates an object composed of the
12656      * own and inherited enumerable string keyed properties of `object` that are
12657      * not omitted.
12658      *
12659      * @static
12660      * @since 0.1.0
12661      * @memberOf _
12662      * @category Object
12663      * @param {Object} object The source object.
12664      * @param {...(string|string[])} [props] The property identifiers to omit.
12665      * @returns {Object} Returns the new object.
12666      * @example
12667      *
12668      * var object = { 'a': 1, 'b': '2', 'c': 3 };
12669      *
12670      * _.omit(object, ['a', 'c']);
12671      * // => { 'b': '2' }
12672      */
12673     var omit = rest(function(object, props) {
12674       if (object == null) {
12675         return {};
12676       }
12677       props = arrayMap(baseFlatten(props, 1), toKey);
12678       return basePick(object, baseDifference(getAllKeysIn(object), props));
12679     });
12680
12681     /**
12682      * The opposite of `_.pickBy`; this method creates an object composed of
12683      * the own and inherited enumerable string keyed properties of `object` that
12684      * `predicate` doesn't return truthy for. The predicate is invoked with two
12685      * arguments: (value, key).
12686      *
12687      * @static
12688      * @memberOf _
12689      * @since 4.0.0
12690      * @category Object
12691      * @param {Object} object The source object.
12692      * @param {Array|Function|Object|string} [predicate=_.identity]
12693      *  The function invoked per property.
12694      * @returns {Object} Returns the new object.
12695      * @example
12696      *
12697      * var object = { 'a': 1, 'b': '2', 'c': 3 };
12698      *
12699      * _.omitBy(object, _.isNumber);
12700      * // => { 'b': '2' }
12701      */
12702     function omitBy(object, predicate) {
12703       predicate = getIteratee(predicate);
12704       return basePickBy(object, function(value, key) {
12705         return !predicate(value, key);
12706       });
12707     }
12708
12709     /**
12710      * Creates an object composed of the picked `object` properties.
12711      *
12712      * @static
12713      * @since 0.1.0
12714      * @memberOf _
12715      * @category Object
12716      * @param {Object} object The source object.
12717      * @param {...(string|string[])} [props] The property identifiers to pick.
12718      * @returns {Object} Returns the new object.
12719      * @example
12720      *
12721      * var object = { 'a': 1, 'b': '2', 'c': 3 };
12722      *
12723      * _.pick(object, ['a', 'c']);
12724      * // => { 'a': 1, 'c': 3 }
12725      */
12726     var pick = rest(function(object, props) {
12727       return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey));
12728     });
12729
12730     /**
12731      * Creates an object composed of the `object` properties `predicate` returns
12732      * truthy for. The predicate is invoked with two arguments: (value, key).
12733      *
12734      * @static
12735      * @memberOf _
12736      * @since 4.0.0
12737      * @category Object
12738      * @param {Object} object The source object.
12739      * @param {Array|Function|Object|string} [predicate=_.identity]
12740      *  The function invoked per property.
12741      * @returns {Object} Returns the new object.
12742      * @example
12743      *
12744      * var object = { 'a': 1, 'b': '2', 'c': 3 };
12745      *
12746      * _.pickBy(object, _.isNumber);
12747      * // => { 'a': 1, 'c': 3 }
12748      */
12749     function pickBy(object, predicate) {
12750       return object == null ? {} : basePickBy(object, getIteratee(predicate));
12751     }
12752
12753     /**
12754      * This method is like `_.get` except that if the resolved value is a
12755      * function it's invoked with the `this` binding of its parent object and
12756      * its result is returned.
12757      *
12758      * @static
12759      * @since 0.1.0
12760      * @memberOf _
12761      * @category Object
12762      * @param {Object} object The object to query.
12763      * @param {Array|string} path The path of the property to resolve.
12764      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
12765      * @returns {*} Returns the resolved value.
12766      * @example
12767      *
12768      * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
12769      *
12770      * _.result(object, 'a[0].b.c1');
12771      * // => 3
12772      *
12773      * _.result(object, 'a[0].b.c2');
12774      * // => 4
12775      *
12776      * _.result(object, 'a[0].b.c3', 'default');
12777      * // => 'default'
12778      *
12779      * _.result(object, 'a[0].b.c3', _.constant('default'));
12780      * // => 'default'
12781      */
12782     function result(object, path, defaultValue) {
12783       path = isKey(path, object) ? [path] : castPath(path);
12784
12785       var index = -1,
12786           length = path.length;
12787
12788       // Ensure the loop is entered when path is empty.
12789       if (!length) {
12790         object = undefined;
12791         length = 1;
12792       }
12793       while (++index < length) {
12794         var value = object == null ? undefined : object[toKey(path[index])];
12795         if (value === undefined) {
12796           index = length;
12797           value = defaultValue;
12798         }
12799         object = isFunction(value) ? value.call(object) : value;
12800       }
12801       return object;
12802     }
12803
12804     /**
12805      * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
12806      * it's created. Arrays are created for missing index properties while objects
12807      * are created for all other missing properties. Use `_.setWith` to customize
12808      * `path` creation.
12809      *
12810      * **Note:** This method mutates `object`.
12811      *
12812      * @static
12813      * @memberOf _
12814      * @since 3.7.0
12815      * @category Object
12816      * @param {Object} object The object to modify.
12817      * @param {Array|string} path The path of the property to set.
12818      * @param {*} value The value to set.
12819      * @returns {Object} Returns `object`.
12820      * @example
12821      *
12822      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
12823      *
12824      * _.set(object, 'a[0].b.c', 4);
12825      * console.log(object.a[0].b.c);
12826      * // => 4
12827      *
12828      * _.set(object, ['x', '0', 'y', 'z'], 5);
12829      * console.log(object.x[0].y.z);
12830      * // => 5
12831      */
12832     function set(object, path, value) {
12833       return object == null ? object : baseSet(object, path, value);
12834     }
12835
12836     /**
12837      * This method is like `_.set` except that it accepts `customizer` which is
12838      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
12839      * path creation is handled by the method instead. The `customizer` is invoked
12840      * with three arguments: (nsValue, key, nsObject).
12841      *
12842      * **Note:** This method mutates `object`.
12843      *
12844      * @static
12845      * @memberOf _
12846      * @since 4.0.0
12847      * @category Object
12848      * @param {Object} object The object to modify.
12849      * @param {Array|string} path The path of the property to set.
12850      * @param {*} value The value to set.
12851      * @param {Function} [customizer] The function to customize assigned values.
12852      * @returns {Object} Returns `object`.
12853      * @example
12854      *
12855      * var object = {};
12856      *
12857      * _.setWith(object, '[0][1]', 'a', Object);
12858      * // => { '0': { '1': 'a' } }
12859      */
12860     function setWith(object, path, value, customizer) {
12861       customizer = typeof customizer == 'function' ? customizer : undefined;
12862       return object == null ? object : baseSet(object, path, value, customizer);
12863     }
12864
12865     /**
12866      * Creates an array of own enumerable string keyed-value pairs for `object`
12867      * which can be consumed by `_.fromPairs`.
12868      *
12869      * @static
12870      * @memberOf _
12871      * @since 4.0.0
12872      * @alias entries
12873      * @category Object
12874      * @param {Object} object The object to query.
12875      * @returns {Array} Returns the new array of key-value pairs.
12876      * @example
12877      *
12878      * function Foo() {
12879      *   this.a = 1;
12880      *   this.b = 2;
12881      * }
12882      *
12883      * Foo.prototype.c = 3;
12884      *
12885      * _.toPairs(new Foo);
12886      * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
12887      */
12888     function toPairs(object) {
12889       return baseToPairs(object, keys(object));
12890     }
12891
12892     /**
12893      * Creates an array of own and inherited enumerable string keyed-value pairs
12894      * for `object` which can be consumed by `_.fromPairs`.
12895      *
12896      * @static
12897      * @memberOf _
12898      * @since 4.0.0
12899      * @alias entriesIn
12900      * @category Object
12901      * @param {Object} object The object to query.
12902      * @returns {Array} Returns the new array of key-value pairs.
12903      * @example
12904      *
12905      * function Foo() {
12906      *   this.a = 1;
12907      *   this.b = 2;
12908      * }
12909      *
12910      * Foo.prototype.c = 3;
12911      *
12912      * _.toPairsIn(new Foo);
12913      * // => [['a', 1], ['b', 2], ['c', 1]] (iteration order is not guaranteed)
12914      */
12915     function toPairsIn(object) {
12916       return baseToPairs(object, keysIn(object));
12917     }
12918
12919     /**
12920      * An alternative to `_.reduce`; this method transforms `object` to a new
12921      * `accumulator` object which is the result of running each of its own
12922      * enumerable string keyed properties thru `iteratee`, with each invocation
12923      * potentially mutating the `accumulator` object. The iteratee is invoked
12924      * with four arguments: (accumulator, value, key, object). Iteratee functions
12925      * may exit iteration early by explicitly returning `false`.
12926      *
12927      * @static
12928      * @memberOf _
12929      * @since 1.3.0
12930      * @category Object
12931      * @param {Array|Object} object The object to iterate over.
12932      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12933      * @param {*} [accumulator] The custom accumulator value.
12934      * @returns {*} Returns the accumulated value.
12935      * @example
12936      *
12937      * _.transform([2, 3, 4], function(result, n) {
12938      *   result.push(n *= n);
12939      *   return n % 2 == 0;
12940      * }, []);
12941      * // => [4, 9]
12942      *
12943      * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
12944      *   (result[value] || (result[value] = [])).push(key);
12945      * }, {});
12946      * // => { '1': ['a', 'c'], '2': ['b'] }
12947      */
12948     function transform(object, iteratee, accumulator) {
12949       var isArr = isArray(object) || isTypedArray(object);
12950       iteratee = getIteratee(iteratee, 4);
12951
12952       if (accumulator == null) {
12953         if (isArr || isObject(object)) {
12954           var Ctor = object.constructor;
12955           if (isArr) {
12956             accumulator = isArray(object) ? new Ctor : [];
12957           } else {
12958             accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
12959           }
12960         } else {
12961           accumulator = {};
12962         }
12963       }
12964       (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
12965         return iteratee(accumulator, value, index, object);
12966       });
12967       return accumulator;
12968     }
12969
12970     /**
12971      * Removes the property at `path` of `object`.
12972      *
12973      * **Note:** This method mutates `object`.
12974      *
12975      * @static
12976      * @memberOf _
12977      * @since 4.0.0
12978      * @category Object
12979      * @param {Object} object The object to modify.
12980      * @param {Array|string} path The path of the property to unset.
12981      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
12982      * @example
12983      *
12984      * var object = { 'a': [{ 'b': { 'c': 7 } }] };
12985      * _.unset(object, 'a[0].b.c');
12986      * // => true
12987      *
12988      * console.log(object);
12989      * // => { 'a': [{ 'b': {} }] };
12990      *
12991      * _.unset(object, ['a', '0', 'b', 'c']);
12992      * // => true
12993      *
12994      * console.log(object);
12995      * // => { 'a': [{ 'b': {} }] };
12996      */
12997     function unset(object, path) {
12998       return object == null ? true : baseUnset(object, path);
12999     }
13000
13001     /**
13002      * This method is like `_.set` except that accepts `updater` to produce the
13003      * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
13004      * is invoked with one argument: (value).
13005      *
13006      * **Note:** This method mutates `object`.
13007      *
13008      * @static
13009      * @memberOf _
13010      * @since 4.6.0
13011      * @category Object
13012      * @param {Object} object The object to modify.
13013      * @param {Array|string} path The path of the property to set.
13014      * @param {Function} updater The function to produce the updated value.
13015      * @returns {Object} Returns `object`.
13016      * @example
13017      *
13018      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13019      *
13020      * _.update(object, 'a[0].b.c', function(n) { return n * n; });
13021      * console.log(object.a[0].b.c);
13022      * // => 9
13023      *
13024      * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
13025      * console.log(object.x[0].y.z);
13026      * // => 0
13027      */
13028     function update(object, path, updater) {
13029       return object == null ? object : baseUpdate(object, path, castFunction(updater));
13030     }
13031
13032     /**
13033      * This method is like `_.update` except that it accepts `customizer` which is
13034      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13035      * path creation is handled by the method instead. The `customizer` is invoked
13036      * with three arguments: (nsValue, key, nsObject).
13037      *
13038      * **Note:** This method mutates `object`.
13039      *
13040      * @static
13041      * @memberOf _
13042      * @since 4.6.0
13043      * @category Object
13044      * @param {Object} object The object to modify.
13045      * @param {Array|string} path The path of the property to set.
13046      * @param {Function} updater The function to produce the updated value.
13047      * @param {Function} [customizer] The function to customize assigned values.
13048      * @returns {Object} Returns `object`.
13049      * @example
13050      *
13051      * var object = {};
13052      *
13053      * _.updateWith(object, '[0][1]', _.constant('a'), Object);
13054      * // => { '0': { '1': 'a' } }
13055      */
13056     function updateWith(object, path, updater, customizer) {
13057       customizer = typeof customizer == 'function' ? customizer : undefined;
13058       return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
13059     }
13060
13061     /**
13062      * Creates an array of the own enumerable string keyed property values of `object`.
13063      *
13064      * **Note:** Non-object values are coerced to objects.
13065      *
13066      * @static
13067      * @since 0.1.0
13068      * @memberOf _
13069      * @category Object
13070      * @param {Object} object The object to query.
13071      * @returns {Array} Returns the array of property values.
13072      * @example
13073      *
13074      * function Foo() {
13075      *   this.a = 1;
13076      *   this.b = 2;
13077      * }
13078      *
13079      * Foo.prototype.c = 3;
13080      *
13081      * _.values(new Foo);
13082      * // => [1, 2] (iteration order is not guaranteed)
13083      *
13084      * _.values('hi');
13085      * // => ['h', 'i']
13086      */
13087     function values(object) {
13088       return object ? baseValues(object, keys(object)) : [];
13089     }
13090
13091     /**
13092      * Creates an array of the own and inherited enumerable string keyed property
13093      * values of `object`.
13094      *
13095      * **Note:** Non-object values are coerced to objects.
13096      *
13097      * @static
13098      * @memberOf _
13099      * @since 3.0.0
13100      * @category Object
13101      * @param {Object} object The object to query.
13102      * @returns {Array} Returns the array of property values.
13103      * @example
13104      *
13105      * function Foo() {
13106      *   this.a = 1;
13107      *   this.b = 2;
13108      * }
13109      *
13110      * Foo.prototype.c = 3;
13111      *
13112      * _.valuesIn(new Foo);
13113      * // => [1, 2, 3] (iteration order is not guaranteed)
13114      */
13115     function valuesIn(object) {
13116       return object == null ? [] : baseValues(object, keysIn(object));
13117     }
13118
13119     /*------------------------------------------------------------------------*/
13120
13121     /**
13122      * Clamps `number` within the inclusive `lower` and `upper` bounds.
13123      *
13124      * @static
13125      * @memberOf _
13126      * @since 4.0.0
13127      * @category Number
13128      * @param {number} number The number to clamp.
13129      * @param {number} [lower] The lower bound.
13130      * @param {number} upper The upper bound.
13131      * @returns {number} Returns the clamped number.
13132      * @example
13133      *
13134      * _.clamp(-10, -5, 5);
13135      * // => -5
13136      *
13137      * _.clamp(10, -5, 5);
13138      * // => 5
13139      */
13140     function clamp(number, lower, upper) {
13141       if (upper === undefined) {
13142         upper = lower;
13143         lower = undefined;
13144       }
13145       if (upper !== undefined) {
13146         upper = toNumber(upper);
13147         upper = upper === upper ? upper : 0;
13148       }
13149       if (lower !== undefined) {
13150         lower = toNumber(lower);
13151         lower = lower === lower ? lower : 0;
13152       }
13153       return baseClamp(toNumber(number), lower, upper);
13154     }
13155
13156     /**
13157      * Checks if `n` is between `start` and up to, but not including, `end`. If
13158      * `end` is not specified, it's set to `start` with `start` then set to `0`.
13159      * If `start` is greater than `end` the params are swapped to support
13160      * negative ranges.
13161      *
13162      * @static
13163      * @memberOf _
13164      * @since 3.3.0
13165      * @category Number
13166      * @param {number} number The number to check.
13167      * @param {number} [start=0] The start of the range.
13168      * @param {number} end The end of the range.
13169      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
13170      * @see _.range, _.rangeRight
13171      * @example
13172      *
13173      * _.inRange(3, 2, 4);
13174      * // => true
13175      *
13176      * _.inRange(4, 8);
13177      * // => true
13178      *
13179      * _.inRange(4, 2);
13180      * // => false
13181      *
13182      * _.inRange(2, 2);
13183      * // => false
13184      *
13185      * _.inRange(1.2, 2);
13186      * // => true
13187      *
13188      * _.inRange(5.2, 4);
13189      * // => false
13190      *
13191      * _.inRange(-3, -2, -6);
13192      * // => true
13193      */
13194     function inRange(number, start, end) {
13195       start = toNumber(start) || 0;
13196       if (end === undefined) {
13197         end = start;
13198         start = 0;
13199       } else {
13200         end = toNumber(end) || 0;
13201       }
13202       number = toNumber(number);
13203       return baseInRange(number, start, end);
13204     }
13205
13206     /**
13207      * Produces a random number between the inclusive `lower` and `upper` bounds.
13208      * If only one argument is provided a number between `0` and the given number
13209      * is returned. If `floating` is `true`, or either `lower` or `upper` are
13210      * floats, a floating-point number is returned instead of an integer.
13211      *
13212      * **Note:** JavaScript follows the IEEE-754 standard for resolving
13213      * floating-point values which can produce unexpected results.
13214      *
13215      * @static
13216      * @memberOf _
13217      * @since 0.7.0
13218      * @category Number
13219      * @param {number} [lower=0] The lower bound.
13220      * @param {number} [upper=1] The upper bound.
13221      * @param {boolean} [floating] Specify returning a floating-point number.
13222      * @returns {number} Returns the random number.
13223      * @example
13224      *
13225      * _.random(0, 5);
13226      * // => an integer between 0 and 5
13227      *
13228      * _.random(5);
13229      * // => also an integer between 0 and 5
13230      *
13231      * _.random(5, true);
13232      * // => a floating-point number between 0 and 5
13233      *
13234      * _.random(1.2, 5.2);
13235      * // => a floating-point number between 1.2 and 5.2
13236      */
13237     function random(lower, upper, floating) {
13238       if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
13239         upper = floating = undefined;
13240       }
13241       if (floating === undefined) {
13242         if (typeof upper == 'boolean') {
13243           floating = upper;
13244           upper = undefined;
13245         }
13246         else if (typeof lower == 'boolean') {
13247           floating = lower;
13248           lower = undefined;
13249         }
13250       }
13251       if (lower === undefined && upper === undefined) {
13252         lower = 0;
13253         upper = 1;
13254       }
13255       else {
13256         lower = toNumber(lower) || 0;
13257         if (upper === undefined) {
13258           upper = lower;
13259           lower = 0;
13260         } else {
13261           upper = toNumber(upper) || 0;
13262         }
13263       }
13264       if (lower > upper) {
13265         var temp = lower;
13266         lower = upper;
13267         upper = temp;
13268       }
13269       if (floating || lower % 1 || upper % 1) {
13270         var rand = nativeRandom();
13271         return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
13272       }
13273       return baseRandom(lower, upper);
13274     }
13275
13276     /*------------------------------------------------------------------------*/
13277
13278     /**
13279      * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
13280      *
13281      * @static
13282      * @memberOf _
13283      * @since 3.0.0
13284      * @category String
13285      * @param {string} [string=''] The string to convert.
13286      * @returns {string} Returns the camel cased string.
13287      * @example
13288      *
13289      * _.camelCase('Foo Bar');
13290      * // => 'fooBar'
13291      *
13292      * _.camelCase('--foo-bar--');
13293      * // => 'fooBar'
13294      *
13295      * _.camelCase('__FOO_BAR__');
13296      * // => 'fooBar'
13297      */
13298     var camelCase = createCompounder(function(result, word, index) {
13299       word = word.toLowerCase();
13300       return result + (index ? capitalize(word) : word);
13301     });
13302
13303     /**
13304      * Converts the first character of `string` to upper case and the remaining
13305      * to lower case.
13306      *
13307      * @static
13308      * @memberOf _
13309      * @since 3.0.0
13310      * @category String
13311      * @param {string} [string=''] The string to capitalize.
13312      * @returns {string} Returns the capitalized string.
13313      * @example
13314      *
13315      * _.capitalize('FRED');
13316      * // => 'Fred'
13317      */
13318     function capitalize(string) {
13319       return upperFirst(toString(string).toLowerCase());
13320     }
13321
13322     /**
13323      * Deburrs `string` by converting
13324      * [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
13325      * to basic latin letters and removing
13326      * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
13327      *
13328      * @static
13329      * @memberOf _
13330      * @since 3.0.0
13331      * @category String
13332      * @param {string} [string=''] The string to deburr.
13333      * @returns {string} Returns the deburred string.
13334      * @example
13335      *
13336      * _.deburr('déjà vu');
13337      * // => 'deja vu'
13338      */
13339     function deburr(string) {
13340       string = toString(string);
13341       return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, '');
13342     }
13343
13344     /**
13345      * Checks if `string` ends with the given target string.
13346      *
13347      * @static
13348      * @memberOf _
13349      * @since 3.0.0
13350      * @category String
13351      * @param {string} [string=''] The string to search.
13352      * @param {string} [target] The string to search for.
13353      * @param {number} [position=string.length] The position to search from.
13354      * @returns {boolean} Returns `true` if `string` ends with `target`,
13355      *  else `false`.
13356      * @example
13357      *
13358      * _.endsWith('abc', 'c');
13359      * // => true
13360      *
13361      * _.endsWith('abc', 'b');
13362      * // => false
13363      *
13364      * _.endsWith('abc', 'b', 2);
13365      * // => true
13366      */
13367     function endsWith(string, target, position) {
13368       string = toString(string);
13369       target = baseToString(target);
13370
13371       var length = string.length;
13372       position = position === undefined
13373         ? length
13374         : baseClamp(toInteger(position), 0, length);
13375
13376       position -= target.length;
13377       return position >= 0 && string.indexOf(target, position) == position;
13378     }
13379
13380     /**
13381      * Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to
13382      * their corresponding HTML entities.
13383      *
13384      * **Note:** No other characters are escaped. To escape additional
13385      * characters use a third-party library like [_he_](https://mths.be/he).
13386      *
13387      * Though the ">" character is escaped for symmetry, characters like
13388      * ">" and "/" don't need escaping in HTML and have no special meaning
13389      * unless they're part of a tag or unquoted attribute value. See
13390      * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
13391      * (under "semi-related fun fact") for more details.
13392      *
13393      * Backticks are escaped because in IE < 9, they can break out of
13394      * attribute values or HTML comments. See [#59](https://html5sec.org/#59),
13395      * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and
13396      * [#133](https://html5sec.org/#133) of the
13397      * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
13398      *
13399      * When working with HTML you should always
13400      * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
13401      * XSS vectors.
13402      *
13403      * @static
13404      * @since 0.1.0
13405      * @memberOf _
13406      * @category String
13407      * @param {string} [string=''] The string to escape.
13408      * @returns {string} Returns the escaped string.
13409      * @example
13410      *
13411      * _.escape('fred, barney, & pebbles');
13412      * // => 'fred, barney, &amp; pebbles'
13413      */
13414     function escape(string) {
13415       string = toString(string);
13416       return (string && reHasUnescapedHtml.test(string))
13417         ? string.replace(reUnescapedHtml, escapeHtmlChar)
13418         : string;
13419     }
13420
13421     /**
13422      * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
13423      * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
13424      *
13425      * @static
13426      * @memberOf _
13427      * @since 3.0.0
13428      * @category String
13429      * @param {string} [string=''] The string to escape.
13430      * @returns {string} Returns the escaped string.
13431      * @example
13432      *
13433      * _.escapeRegExp('[lodash](https://lodash.com/)');
13434      * // => '\[lodash\]\(https://lodash\.com/\)'
13435      */
13436     function escapeRegExp(string) {
13437       string = toString(string);
13438       return (string && reHasRegExpChar.test(string))
13439         ? string.replace(reRegExpChar, '\\$&')
13440         : string;
13441     }
13442
13443     /**
13444      * Converts `string` to
13445      * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
13446      *
13447      * @static
13448      * @memberOf _
13449      * @since 3.0.0
13450      * @category String
13451      * @param {string} [string=''] The string to convert.
13452      * @returns {string} Returns the kebab cased string.
13453      * @example
13454      *
13455      * _.kebabCase('Foo Bar');
13456      * // => 'foo-bar'
13457      *
13458      * _.kebabCase('fooBar');
13459      * // => 'foo-bar'
13460      *
13461      * _.kebabCase('__FOO_BAR__');
13462      * // => 'foo-bar'
13463      */
13464     var kebabCase = createCompounder(function(result, word, index) {
13465       return result + (index ? '-' : '') + word.toLowerCase();
13466     });
13467
13468     /**
13469      * Converts `string`, as space separated words, to lower case.
13470      *
13471      * @static
13472      * @memberOf _
13473      * @since 4.0.0
13474      * @category String
13475      * @param {string} [string=''] The string to convert.
13476      * @returns {string} Returns the lower cased string.
13477      * @example
13478      *
13479      * _.lowerCase('--Foo-Bar--');
13480      * // => 'foo bar'
13481      *
13482      * _.lowerCase('fooBar');
13483      * // => 'foo bar'
13484      *
13485      * _.lowerCase('__FOO_BAR__');
13486      * // => 'foo bar'
13487      */
13488     var lowerCase = createCompounder(function(result, word, index) {
13489       return result + (index ? ' ' : '') + word.toLowerCase();
13490     });
13491
13492     /**
13493      * Converts the first character of `string` to lower case.
13494      *
13495      * @static
13496      * @memberOf _
13497      * @since 4.0.0
13498      * @category String
13499      * @param {string} [string=''] The string to convert.
13500      * @returns {string} Returns the converted string.
13501      * @example
13502      *
13503      * _.lowerFirst('Fred');
13504      * // => 'fred'
13505      *
13506      * _.lowerFirst('FRED');
13507      * // => 'fRED'
13508      */
13509     var lowerFirst = createCaseFirst('toLowerCase');
13510
13511     /**
13512      * Pads `string` on the left and right sides if it's shorter than `length`.
13513      * Padding characters are truncated if they can't be evenly divided by `length`.
13514      *
13515      * @static
13516      * @memberOf _
13517      * @since 3.0.0
13518      * @category String
13519      * @param {string} [string=''] The string to pad.
13520      * @param {number} [length=0] The padding length.
13521      * @param {string} [chars=' '] The string used as padding.
13522      * @returns {string} Returns the padded string.
13523      * @example
13524      *
13525      * _.pad('abc', 8);
13526      * // => '  abc   '
13527      *
13528      * _.pad('abc', 8, '_-');
13529      * // => '_-abc_-_'
13530      *
13531      * _.pad('abc', 3);
13532      * // => 'abc'
13533      */
13534     function pad(string, length, chars) {
13535       string = toString(string);
13536       length = toInteger(length);
13537
13538       var strLength = length ? stringSize(string) : 0;
13539       if (!length || strLength >= length) {
13540         return string;
13541       }
13542       var mid = (length - strLength) / 2;
13543       return (
13544         createPadding(nativeFloor(mid), chars) +
13545         string +
13546         createPadding(nativeCeil(mid), chars)
13547       );
13548     }
13549
13550     /**
13551      * Pads `string` on the right side if it's shorter than `length`. Padding
13552      * characters are truncated if they exceed `length`.
13553      *
13554      * @static
13555      * @memberOf _
13556      * @since 4.0.0
13557      * @category String
13558      * @param {string} [string=''] The string to pad.
13559      * @param {number} [length=0] The padding length.
13560      * @param {string} [chars=' '] The string used as padding.
13561      * @returns {string} Returns the padded string.
13562      * @example
13563      *
13564      * _.padEnd('abc', 6);
13565      * // => 'abc   '
13566      *
13567      * _.padEnd('abc', 6, '_-');
13568      * // => 'abc_-_'
13569      *
13570      * _.padEnd('abc', 3);
13571      * // => 'abc'
13572      */
13573     function padEnd(string, length, chars) {
13574       string = toString(string);
13575       length = toInteger(length);
13576
13577       var strLength = length ? stringSize(string) : 0;
13578       return (length && strLength < length)
13579         ? (string + createPadding(length - strLength, chars))
13580         : string;
13581     }
13582
13583     /**
13584      * Pads `string` on the left side if it's shorter than `length`. Padding
13585      * characters are truncated if they exceed `length`.
13586      *
13587      * @static
13588      * @memberOf _
13589      * @since 4.0.0
13590      * @category String
13591      * @param {string} [string=''] The string to pad.
13592      * @param {number} [length=0] The padding length.
13593      * @param {string} [chars=' '] The string used as padding.
13594      * @returns {string} Returns the padded string.
13595      * @example
13596      *
13597      * _.padStart('abc', 6);
13598      * // => '   abc'
13599      *
13600      * _.padStart('abc', 6, '_-');
13601      * // => '_-_abc'
13602      *
13603      * _.padStart('abc', 3);
13604      * // => 'abc'
13605      */
13606     function padStart(string, length, chars) {
13607       string = toString(string);
13608       length = toInteger(length);
13609
13610       var strLength = length ? stringSize(string) : 0;
13611       return (length && strLength < length)
13612         ? (createPadding(length - strLength, chars) + string)
13613         : string;
13614     }
13615
13616     /**
13617      * Converts `string` to an integer of the specified radix. If `radix` is
13618      * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
13619      * hexadecimal, in which case a `radix` of `16` is used.
13620      *
13621      * **Note:** This method aligns with the
13622      * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
13623      *
13624      * @static
13625      * @memberOf _
13626      * @since 1.1.0
13627      * @category String
13628      * @param {string} string The string to convert.
13629      * @param {number} [radix=10] The radix to interpret `value` by.
13630      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
13631      * @returns {number} Returns the converted integer.
13632      * @example
13633      *
13634      * _.parseInt('08');
13635      * // => 8
13636      *
13637      * _.map(['6', '08', '10'], _.parseInt);
13638      * // => [6, 8, 10]
13639      */
13640     function parseInt(string, radix, guard) {
13641       // Chrome fails to trim leading <BOM> whitespace characters.
13642       // See https://bugs.chromium.org/p/v8/issues/detail?id=3109 for more details.
13643       if (guard || radix == null) {
13644         radix = 0;
13645       } else if (radix) {
13646         radix = +radix;
13647       }
13648       string = toString(string).replace(reTrim, '');
13649       return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
13650     }
13651
13652     /**
13653      * Repeats the given string `n` times.
13654      *
13655      * @static
13656      * @memberOf _
13657      * @since 3.0.0
13658      * @category String
13659      * @param {string} [string=''] The string to repeat.
13660      * @param {number} [n=1] The number of times to repeat the string.
13661      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
13662      * @returns {string} Returns the repeated string.
13663      * @example
13664      *
13665      * _.repeat('*', 3);
13666      * // => '***'
13667      *
13668      * _.repeat('abc', 2);
13669      * // => 'abcabc'
13670      *
13671      * _.repeat('abc', 0);
13672      * // => ''
13673      */
13674     function repeat(string, n, guard) {
13675       if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
13676         n = 1;
13677       } else {
13678         n = toInteger(n);
13679       }
13680       return baseRepeat(toString(string), n);
13681     }
13682
13683     /**
13684      * Replaces matches for `pattern` in `string` with `replacement`.
13685      *
13686      * **Note:** This method is based on
13687      * [`String#replace`](https://mdn.io/String/replace).
13688      *
13689      * @static
13690      * @memberOf _
13691      * @since 4.0.0
13692      * @category String
13693      * @param {string} [string=''] The string to modify.
13694      * @param {RegExp|string} pattern The pattern to replace.
13695      * @param {Function|string} replacement The match replacement.
13696      * @returns {string} Returns the modified string.
13697      * @example
13698      *
13699      * _.replace('Hi Fred', 'Fred', 'Barney');
13700      * // => 'Hi Barney'
13701      */
13702     function replace() {
13703       var args = arguments,
13704           string = toString(args[0]);
13705
13706       return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
13707     }
13708
13709     /**
13710      * Converts `string` to
13711      * [snake case](https://en.wikipedia.org/wiki/Snake_case).
13712      *
13713      * @static
13714      * @memberOf _
13715      * @since 3.0.0
13716      * @category String
13717      * @param {string} [string=''] The string to convert.
13718      * @returns {string} Returns the snake cased string.
13719      * @example
13720      *
13721      * _.snakeCase('Foo Bar');
13722      * // => 'foo_bar'
13723      *
13724      * _.snakeCase('fooBar');
13725      * // => 'foo_bar'
13726      *
13727      * _.snakeCase('--FOO-BAR--');
13728      * // => 'foo_bar'
13729      */
13730     var snakeCase = createCompounder(function(result, word, index) {
13731       return result + (index ? '_' : '') + word.toLowerCase();
13732     });
13733
13734     /**
13735      * Splits `string` by `separator`.
13736      *
13737      * **Note:** This method is based on
13738      * [`String#split`](https://mdn.io/String/split).
13739      *
13740      * @static
13741      * @memberOf _
13742      * @since 4.0.0
13743      * @category String
13744      * @param {string} [string=''] The string to split.
13745      * @param {RegExp|string} separator The separator pattern to split by.
13746      * @param {number} [limit] The length to truncate results to.
13747      * @returns {Array} Returns the new array of string segments.
13748      * @example
13749      *
13750      * _.split('a-b-c', '-', 2);
13751      * // => ['a', 'b']
13752      */
13753     function split(string, separator, limit) {
13754       if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
13755         separator = limit = undefined;
13756       }
13757       limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
13758       if (!limit) {
13759         return [];
13760       }
13761       string = toString(string);
13762       if (string && (
13763             typeof separator == 'string' ||
13764             (separator != null && !isRegExp(separator))
13765           )) {
13766         separator = baseToString(separator);
13767         if (separator == '' && reHasComplexSymbol.test(string)) {
13768           return castSlice(stringToArray(string), 0, limit);
13769         }
13770       }
13771       return nativeSplit.call(string, separator, limit);
13772     }
13773
13774     /**
13775      * Converts `string` to
13776      * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
13777      *
13778      * @static
13779      * @memberOf _
13780      * @since 3.1.0
13781      * @category String
13782      * @param {string} [string=''] The string to convert.
13783      * @returns {string} Returns the start cased string.
13784      * @example
13785      *
13786      * _.startCase('--foo-bar--');
13787      * // => 'Foo Bar'
13788      *
13789      * _.startCase('fooBar');
13790      * // => 'Foo Bar'
13791      *
13792      * _.startCase('__FOO_BAR__');
13793      * // => 'FOO BAR'
13794      */
13795     var startCase = createCompounder(function(result, word, index) {
13796       return result + (index ? ' ' : '') + upperFirst(word);
13797     });
13798
13799     /**
13800      * Checks if `string` starts with the given target string.
13801      *
13802      * @static
13803      * @memberOf _
13804      * @since 3.0.0
13805      * @category String
13806      * @param {string} [string=''] The string to search.
13807      * @param {string} [target] The string to search for.
13808      * @param {number} [position=0] The position to search from.
13809      * @returns {boolean} Returns `true` if `string` starts with `target`,
13810      *  else `false`.
13811      * @example
13812      *
13813      * _.startsWith('abc', 'a');
13814      * // => true
13815      *
13816      * _.startsWith('abc', 'b');
13817      * // => false
13818      *
13819      * _.startsWith('abc', 'b', 1);
13820      * // => true
13821      */
13822     function startsWith(string, target, position) {
13823       string = toString(string);
13824       position = baseClamp(toInteger(position), 0, string.length);
13825       return string.lastIndexOf(baseToString(target), position) == position;
13826     }
13827
13828     /**
13829      * Creates a compiled template function that can interpolate data properties
13830      * in "interpolate" delimiters, HTML-escape interpolated data properties in
13831      * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
13832      * properties may be accessed as free variables in the template. If a setting
13833      * object is given, it takes precedence over `_.templateSettings` values.
13834      *
13835      * **Note:** In the development build `_.template` utilizes
13836      * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
13837      * for easier debugging.
13838      *
13839      * For more information on precompiling templates see
13840      * [lodash's custom builds documentation](https://lodash.com/custom-builds).
13841      *
13842      * For more information on Chrome extension sandboxes see
13843      * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
13844      *
13845      * @static
13846      * @since 0.1.0
13847      * @memberOf _
13848      * @category String
13849      * @param {string} [string=''] The template string.
13850      * @param {Object} [options={}] The options object.
13851      * @param {RegExp} [options.escape=_.templateSettings.escape]
13852      *  The HTML "escape" delimiter.
13853      * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
13854      *  The "evaluate" delimiter.
13855      * @param {Object} [options.imports=_.templateSettings.imports]
13856      *  An object to import into the template as free variables.
13857      * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
13858      *  The "interpolate" delimiter.
13859      * @param {string} [options.sourceURL='lodash.templateSources[n]']
13860      *  The sourceURL of the compiled template.
13861      * @param {string} [options.variable='obj']
13862      *  The data object variable name.
13863      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
13864      * @returns {Function} Returns the compiled template function.
13865      * @example
13866      *
13867      * // Use the "interpolate" delimiter to create a compiled template.
13868      * var compiled = _.template('hello <%= user %>!');
13869      * compiled({ 'user': 'fred' });
13870      * // => 'hello fred!'
13871      *
13872      * // Use the HTML "escape" delimiter to escape data property values.
13873      * var compiled = _.template('<b><%- value %></b>');
13874      * compiled({ 'value': '<script>' });
13875      * // => '<b>&lt;script&gt;</b>'
13876      *
13877      * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
13878      * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
13879      * compiled({ 'users': ['fred', 'barney'] });
13880      * // => '<li>fred</li><li>barney</li>'
13881      *
13882      * // Use the internal `print` function in "evaluate" delimiters.
13883      * var compiled = _.template('<% print("hello " + user); %>!');
13884      * compiled({ 'user': 'barney' });
13885      * // => 'hello barney!'
13886      *
13887      * // Use the ES delimiter as an alternative to the default "interpolate" delimiter.
13888      * var compiled = _.template('hello ${ user }!');
13889      * compiled({ 'user': 'pebbles' });
13890      * // => 'hello pebbles!'
13891      *
13892      * // Use custom template delimiters.
13893      * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
13894      * var compiled = _.template('hello {{ user }}!');
13895      * compiled({ 'user': 'mustache' });
13896      * // => 'hello mustache!'
13897      *
13898      * // Use backslashes to treat delimiters as plain text.
13899      * var compiled = _.template('<%= "\\<%- value %\\>" %>');
13900      * compiled({ 'value': 'ignored' });
13901      * // => '<%- value %>'
13902      *
13903      * // Use the `imports` option to import `jQuery` as `jq`.
13904      * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
13905      * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
13906      * compiled({ 'users': ['fred', 'barney'] });
13907      * // => '<li>fred</li><li>barney</li>'
13908      *
13909      * // Use the `sourceURL` option to specify a custom sourceURL for the template.
13910      * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
13911      * compiled(data);
13912      * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
13913      *
13914      * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
13915      * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
13916      * compiled.source;
13917      * // => function(data) {
13918      * //   var __t, __p = '';
13919      * //   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
13920      * //   return __p;
13921      * // }
13922      *
13923      * // Use the `source` property to inline compiled templates for meaningful
13924      * // line numbers in error messages and stack traces.
13925      * fs.writeFileSync(path.join(cwd, 'jst.js'), '\
13926      *   var JST = {\
13927      *     "main": ' + _.template(mainText).source + '\
13928      *   };\
13929      * ');
13930      */
13931     function template(string, options, guard) {
13932       // Based on John Resig's `tmpl` implementation
13933       // (http://ejohn.org/blog/javascript-micro-templating/)
13934       // and Laura Doktorova's doT.js (https://github.com/olado/doT).
13935       var settings = lodash.templateSettings;
13936
13937       if (guard && isIterateeCall(string, options, guard)) {
13938         options = undefined;
13939       }
13940       string = toString(string);
13941       options = assignInWith({}, options, settings, assignInDefaults);
13942
13943       var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),
13944           importsKeys = keys(imports),
13945           importsValues = baseValues(imports, importsKeys);
13946
13947       var isEscaping,
13948           isEvaluating,
13949           index = 0,
13950           interpolate = options.interpolate || reNoMatch,
13951           source = "__p += '";
13952
13953       // Compile the regexp to match each delimiter.
13954       var reDelimiters = RegExp(
13955         (options.escape || reNoMatch).source + '|' +
13956         interpolate.source + '|' +
13957         (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
13958         (options.evaluate || reNoMatch).source + '|$'
13959       , 'g');
13960
13961       // Use a sourceURL for easier debugging.
13962       var sourceURL = '//# sourceURL=' +
13963         ('sourceURL' in options
13964           ? options.sourceURL
13965           : ('lodash.templateSources[' + (++templateCounter) + ']')
13966         ) + '\n';
13967
13968       string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
13969         interpolateValue || (interpolateValue = esTemplateValue);
13970
13971         // Escape characters that can't be included in string literals.
13972         source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
13973
13974         // Replace delimiters with snippets.
13975         if (escapeValue) {
13976           isEscaping = true;
13977           source += "' +\n__e(" + escapeValue + ") +\n'";
13978         }
13979         if (evaluateValue) {
13980           isEvaluating = true;
13981           source += "';\n" + evaluateValue + ";\n__p += '";
13982         }
13983         if (interpolateValue) {
13984           source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
13985         }
13986         index = offset + match.length;
13987
13988         // The JS engine embedded in Adobe products needs `match` returned in
13989         // order to produce the correct `offset` value.
13990         return match;
13991       });
13992
13993       source += "';\n";
13994
13995       // If `variable` is not specified wrap a with-statement around the generated
13996       // code to add the data object to the top of the scope chain.
13997       var variable = options.variable;
13998       if (!variable) {
13999         source = 'with (obj) {\n' + source + '\n}\n';
14000       }
14001       // Cleanup code by stripping empty strings.
14002       source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
14003         .replace(reEmptyStringMiddle, '$1')
14004         .replace(reEmptyStringTrailing, '$1;');
14005
14006       // Frame code as the function body.
14007       source = 'function(' + (variable || 'obj') + ') {\n' +
14008         (variable
14009           ? ''
14010           : 'obj || (obj = {});\n'
14011         ) +
14012         "var __t, __p = ''" +
14013         (isEscaping
14014            ? ', __e = _.escape'
14015            : ''
14016         ) +
14017         (isEvaluating
14018           ? ', __j = Array.prototype.join;\n' +
14019             "function print() { __p += __j.call(arguments, '') }\n"
14020           : ';\n'
14021         ) +
14022         source +
14023         'return __p\n}';
14024
14025       var result = attempt(function() {
14026         return Function(importsKeys, sourceURL + 'return ' + source)
14027           .apply(undefined, importsValues);
14028       });
14029
14030       // Provide the compiled function's source by its `toString` method or
14031       // the `source` property as a convenience for inlining compiled templates.
14032       result.source = source;
14033       if (isError(result)) {
14034         throw result;
14035       }
14036       return result;
14037     }
14038
14039     /**
14040      * Converts `string`, as a whole, to lower case just like
14041      * [String#toLowerCase](https://mdn.io/toLowerCase).
14042      *
14043      * @static
14044      * @memberOf _
14045      * @since 4.0.0
14046      * @category String
14047      * @param {string} [string=''] The string to convert.
14048      * @returns {string} Returns the lower cased string.
14049      * @example
14050      *
14051      * _.toLower('--Foo-Bar--');
14052      * // => '--foo-bar--'
14053      *
14054      * _.toLower('fooBar');
14055      * // => 'foobar'
14056      *
14057      * _.toLower('__FOO_BAR__');
14058      * // => '__foo_bar__'
14059      */
14060     function toLower(value) {
14061       return toString(value).toLowerCase();
14062     }
14063
14064     /**
14065      * Converts `string`, as a whole, to upper case just like
14066      * [String#toUpperCase](https://mdn.io/toUpperCase).
14067      *
14068      * @static
14069      * @memberOf _
14070      * @since 4.0.0
14071      * @category String
14072      * @param {string} [string=''] The string to convert.
14073      * @returns {string} Returns the upper cased string.
14074      * @example
14075      *
14076      * _.toUpper('--foo-bar--');
14077      * // => '--FOO-BAR--'
14078      *
14079      * _.toUpper('fooBar');
14080      * // => 'FOOBAR'
14081      *
14082      * _.toUpper('__foo_bar__');
14083      * // => '__FOO_BAR__'
14084      */
14085     function toUpper(value) {
14086       return toString(value).toUpperCase();
14087     }
14088
14089     /**
14090      * Removes leading and trailing whitespace or specified characters from `string`.
14091      *
14092      * @static
14093      * @memberOf _
14094      * @since 3.0.0
14095      * @category String
14096      * @param {string} [string=''] The string to trim.
14097      * @param {string} [chars=whitespace] The characters to trim.
14098      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14099      * @returns {string} Returns the trimmed string.
14100      * @example
14101      *
14102      * _.trim('  abc  ');
14103      * // => 'abc'
14104      *
14105      * _.trim('-_-abc-_-', '_-');
14106      * // => 'abc'
14107      *
14108      * _.map(['  foo  ', '  bar  '], _.trim);
14109      * // => ['foo', 'bar']
14110      */
14111     function trim(string, chars, guard) {
14112       string = toString(string);
14113       if (string && (guard || chars === undefined)) {
14114         return string.replace(reTrim, '');
14115       }
14116       if (!string || !(chars = baseToString(chars))) {
14117         return string;
14118       }
14119       var strSymbols = stringToArray(string),
14120           chrSymbols = stringToArray(chars),
14121           start = charsStartIndex(strSymbols, chrSymbols),
14122           end = charsEndIndex(strSymbols, chrSymbols) + 1;
14123
14124       return castSlice(strSymbols, start, end).join('');
14125     }
14126
14127     /**
14128      * Removes trailing whitespace or specified characters from `string`.
14129      *
14130      * @static
14131      * @memberOf _
14132      * @since 4.0.0
14133      * @category String
14134      * @param {string} [string=''] The string to trim.
14135      * @param {string} [chars=whitespace] The characters to trim.
14136      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14137      * @returns {string} Returns the trimmed string.
14138      * @example
14139      *
14140      * _.trimEnd('  abc  ');
14141      * // => '  abc'
14142      *
14143      * _.trimEnd('-_-abc-_-', '_-');
14144      * // => '-_-abc'
14145      */
14146     function trimEnd(string, chars, guard) {
14147       string = toString(string);
14148       if (string && (guard || chars === undefined)) {
14149         return string.replace(reTrimEnd, '');
14150       }
14151       if (!string || !(chars = baseToString(chars))) {
14152         return string;
14153       }
14154       var strSymbols = stringToArray(string),
14155           end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
14156
14157       return castSlice(strSymbols, 0, end).join('');
14158     }
14159
14160     /**
14161      * Removes leading whitespace or specified characters from `string`.
14162      *
14163      * @static
14164      * @memberOf _
14165      * @since 4.0.0
14166      * @category String
14167      * @param {string} [string=''] The string to trim.
14168      * @param {string} [chars=whitespace] The characters to trim.
14169      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14170      * @returns {string} Returns the trimmed string.
14171      * @example
14172      *
14173      * _.trimStart('  abc  ');
14174      * // => 'abc  '
14175      *
14176      * _.trimStart('-_-abc-_-', '_-');
14177      * // => 'abc-_-'
14178      */
14179     function trimStart(string, chars, guard) {
14180       string = toString(string);
14181       if (string && (guard || chars === undefined)) {
14182         return string.replace(reTrimStart, '');
14183       }
14184       if (!string || !(chars = baseToString(chars))) {
14185         return string;
14186       }
14187       var strSymbols = stringToArray(string),
14188           start = charsStartIndex(strSymbols, stringToArray(chars));
14189
14190       return castSlice(strSymbols, start).join('');
14191     }
14192
14193     /**
14194      * Truncates `string` if it's longer than the given maximum string length.
14195      * The last characters of the truncated string are replaced with the omission
14196      * string which defaults to "...".
14197      *
14198      * @static
14199      * @memberOf _
14200      * @since 4.0.0
14201      * @category String
14202      * @param {string} [string=''] The string to truncate.
14203      * @param {Object} [options={}] The options object.
14204      * @param {number} [options.length=30] The maximum string length.
14205      * @param {string} [options.omission='...'] The string to indicate text is omitted.
14206      * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
14207      * @returns {string} Returns the truncated string.
14208      * @example
14209      *
14210      * _.truncate('hi-diddly-ho there, neighborino');
14211      * // => 'hi-diddly-ho there, neighbo...'
14212      *
14213      * _.truncate('hi-diddly-ho there, neighborino', {
14214      *   'length': 24,
14215      *   'separator': ' '
14216      * });
14217      * // => 'hi-diddly-ho there,...'
14218      *
14219      * _.truncate('hi-diddly-ho there, neighborino', {
14220      *   'length': 24,
14221      *   'separator': /,? +/
14222      * });
14223      * // => 'hi-diddly-ho there...'
14224      *
14225      * _.truncate('hi-diddly-ho there, neighborino', {
14226      *   'omission': ' [...]'
14227      * });
14228      * // => 'hi-diddly-ho there, neig [...]'
14229      */
14230     function truncate(string, options) {
14231       var length = DEFAULT_TRUNC_LENGTH,
14232           omission = DEFAULT_TRUNC_OMISSION;
14233
14234       if (isObject(options)) {
14235         var separator = 'separator' in options ? options.separator : separator;
14236         length = 'length' in options ? toInteger(options.length) : length;
14237         omission = 'omission' in options ? baseToString(options.omission) : omission;
14238       }
14239       string = toString(string);
14240
14241       var strLength = string.length;
14242       if (reHasComplexSymbol.test(string)) {
14243         var strSymbols = stringToArray(string);
14244         strLength = strSymbols.length;
14245       }
14246       if (length >= strLength) {
14247         return string;
14248       }
14249       var end = length - stringSize(omission);
14250       if (end < 1) {
14251         return omission;
14252       }
14253       var result = strSymbols
14254         ? castSlice(strSymbols, 0, end).join('')
14255         : string.slice(0, end);
14256
14257       if (separator === undefined) {
14258         return result + omission;
14259       }
14260       if (strSymbols) {
14261         end += (result.length - end);
14262       }
14263       if (isRegExp(separator)) {
14264         if (string.slice(end).search(separator)) {
14265           var match,
14266               substring = result;
14267
14268           if (!separator.global) {
14269             separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
14270           }
14271           separator.lastIndex = 0;
14272           while ((match = separator.exec(substring))) {
14273             var newEnd = match.index;
14274           }
14275           result = result.slice(0, newEnd === undefined ? end : newEnd);
14276         }
14277       } else if (string.indexOf(baseToString(separator), end) != end) {
14278         var index = result.lastIndexOf(separator);
14279         if (index > -1) {
14280           result = result.slice(0, index);
14281         }
14282       }
14283       return result + omission;
14284     }
14285
14286     /**
14287      * The inverse of `_.escape`; this method converts the HTML entities
14288      * `&amp;`, `&lt;`, `&gt;`, `&quot;`, `&#39;`, and `&#96;` in `string` to
14289      * their corresponding characters.
14290      *
14291      * **Note:** No other HTML entities are unescaped. To unescape additional
14292      * HTML entities use a third-party library like [_he_](https://mths.be/he).
14293      *
14294      * @static
14295      * @memberOf _
14296      * @since 0.6.0
14297      * @category String
14298      * @param {string} [string=''] The string to unescape.
14299      * @returns {string} Returns the unescaped string.
14300      * @example
14301      *
14302      * _.unescape('fred, barney, &amp; pebbles');
14303      * // => 'fred, barney, & pebbles'
14304      */
14305     function unescape(string) {
14306       string = toString(string);
14307       return (string && reHasEscapedHtml.test(string))
14308         ? string.replace(reEscapedHtml, unescapeHtmlChar)
14309         : string;
14310     }
14311
14312     /**
14313      * Converts `string`, as space separated words, to upper case.
14314      *
14315      * @static
14316      * @memberOf _
14317      * @since 4.0.0
14318      * @category String
14319      * @param {string} [string=''] The string to convert.
14320      * @returns {string} Returns the upper cased string.
14321      * @example
14322      *
14323      * _.upperCase('--foo-bar');
14324      * // => 'FOO BAR'
14325      *
14326      * _.upperCase('fooBar');
14327      * // => 'FOO BAR'
14328      *
14329      * _.upperCase('__foo_bar__');
14330      * // => 'FOO BAR'
14331      */
14332     var upperCase = createCompounder(function(result, word, index) {
14333       return result + (index ? ' ' : '') + word.toUpperCase();
14334     });
14335
14336     /**
14337      * Converts the first character of `string` to upper case.
14338      *
14339      * @static
14340      * @memberOf _
14341      * @since 4.0.0
14342      * @category String
14343      * @param {string} [string=''] The string to convert.
14344      * @returns {string} Returns the converted string.
14345      * @example
14346      *
14347      * _.upperFirst('fred');
14348      * // => 'Fred'
14349      *
14350      * _.upperFirst('FRED');
14351      * // => 'FRED'
14352      */
14353     var upperFirst = createCaseFirst('toUpperCase');
14354
14355     /**
14356      * Splits `string` into an array of its words.
14357      *
14358      * @static
14359      * @memberOf _
14360      * @since 3.0.0
14361      * @category String
14362      * @param {string} [string=''] The string to inspect.
14363      * @param {RegExp|string} [pattern] The pattern to match words.
14364      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14365      * @returns {Array} Returns the words of `string`.
14366      * @example
14367      *
14368      * _.words('fred, barney, & pebbles');
14369      * // => ['fred', 'barney', 'pebbles']
14370      *
14371      * _.words('fred, barney, & pebbles', /[^, ]+/g);
14372      * // => ['fred', 'barney', '&', 'pebbles']
14373      */
14374     function words(string, pattern, guard) {
14375       string = toString(string);
14376       pattern = guard ? undefined : pattern;
14377
14378       if (pattern === undefined) {
14379         pattern = reHasComplexWord.test(string) ? reComplexWord : reBasicWord;
14380       }
14381       return string.match(pattern) || [];
14382     }
14383
14384     /*------------------------------------------------------------------------*/
14385
14386     /**
14387      * Attempts to invoke `func`, returning either the result or the caught error
14388      * object. Any additional arguments are provided to `func` when it's invoked.
14389      *
14390      * @static
14391      * @memberOf _
14392      * @since 3.0.0
14393      * @category Util
14394      * @param {Function} func The function to attempt.
14395      * @param {...*} [args] The arguments to invoke `func` with.
14396      * @returns {*} Returns the `func` result or error object.
14397      * @example
14398      *
14399      * // Avoid throwing errors for invalid selectors.
14400      * var elements = _.attempt(function(selector) {
14401      *   return document.querySelectorAll(selector);
14402      * }, '>_>');
14403      *
14404      * if (_.isError(elements)) {
14405      *   elements = [];
14406      * }
14407      */
14408     var attempt = rest(function(func, args) {
14409       try {
14410         return apply(func, undefined, args);
14411       } catch (e) {
14412         return isError(e) ? e : new Error(e);
14413       }
14414     });
14415
14416     /**
14417      * Binds methods of an object to the object itself, overwriting the existing
14418      * method.
14419      *
14420      * **Note:** This method doesn't set the "length" property of bound functions.
14421      *
14422      * @static
14423      * @since 0.1.0
14424      * @memberOf _
14425      * @category Util
14426      * @param {Object} object The object to bind and assign the bound methods to.
14427      * @param {...(string|string[])} methodNames The object method names to bind.
14428      * @returns {Object} Returns `object`.
14429      * @example
14430      *
14431      * var view = {
14432      *   'label': 'docs',
14433      *   'onClick': function() {
14434      *     console.log('clicked ' + this.label);
14435      *   }
14436      * };
14437      *
14438      * _.bindAll(view, 'onClick');
14439      * jQuery(element).on('click', view.onClick);
14440      * // => Logs 'clicked docs' when clicked.
14441      */
14442     var bindAll = rest(function(object, methodNames) {
14443       arrayEach(baseFlatten(methodNames, 1), function(key) {
14444         key = toKey(key);
14445         object[key] = bind(object[key], object);
14446       });
14447       return object;
14448     });
14449
14450     /**
14451      * Creates a function that iterates over `pairs` and invokes the corresponding
14452      * function of the first predicate to return truthy. The predicate-function
14453      * pairs are invoked with the `this` binding and arguments of the created
14454      * function.
14455      *
14456      * @static
14457      * @memberOf _
14458      * @since 4.0.0
14459      * @category Util
14460      * @param {Array} pairs The predicate-function pairs.
14461      * @returns {Function} Returns the new function.
14462      * @example
14463      *
14464      * var func = _.cond([
14465      *   [_.matches({ 'a': 1 }),           _.constant('matches A')],
14466      *   [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
14467      *   [_.constant(true),                _.constant('no match')]
14468      * ]);
14469      *
14470      * func({ 'a': 1, 'b': 2 });
14471      * // => 'matches A'
14472      *
14473      * func({ 'a': 0, 'b': 1 });
14474      * // => 'matches B'
14475      *
14476      * func({ 'a': '1', 'b': '2' });
14477      * // => 'no match'
14478      */
14479     function cond(pairs) {
14480       var length = pairs ? pairs.length : 0,
14481           toIteratee = getIteratee();
14482
14483       pairs = !length ? [] : arrayMap(pairs, function(pair) {
14484         if (typeof pair[1] != 'function') {
14485           throw new TypeError(FUNC_ERROR_TEXT);
14486         }
14487         return [toIteratee(pair[0]), pair[1]];
14488       });
14489
14490       return rest(function(args) {
14491         var index = -1;
14492         while (++index < length) {
14493           var pair = pairs[index];
14494           if (apply(pair[0], this, args)) {
14495             return apply(pair[1], this, args);
14496           }
14497         }
14498       });
14499     }
14500
14501     /**
14502      * Creates a function that invokes the predicate properties of `source` with
14503      * the corresponding property values of a given object, returning `true` if
14504      * all predicates return truthy, else `false`.
14505      *
14506      * @static
14507      * @memberOf _
14508      * @since 4.0.0
14509      * @category Util
14510      * @param {Object} source The object of property predicates to conform to.
14511      * @returns {Function} Returns the new function.
14512      * @example
14513      *
14514      * var users = [
14515      *   { 'user': 'barney', 'age': 36 },
14516      *   { 'user': 'fred',   'age': 40 }
14517      * ];
14518      *
14519      * _.filter(users, _.conforms({ 'age': _.partial(_.gt, _, 38) }));
14520      * // => [{ 'user': 'fred', 'age': 40 }]
14521      */
14522     function conforms(source) {
14523       return baseConforms(baseClone(source, true));
14524     }
14525
14526     /**
14527      * Creates a function that returns `value`.
14528      *
14529      * @static
14530      * @memberOf _
14531      * @since 2.4.0
14532      * @category Util
14533      * @param {*} value The value to return from the new function.
14534      * @returns {Function} Returns the new function.
14535      * @example
14536      *
14537      * var object = { 'user': 'fred' };
14538      * var getter = _.constant(object);
14539      *
14540      * getter() === object;
14541      * // => true
14542      */
14543     function constant(value) {
14544       return function() {
14545         return value;
14546       };
14547     }
14548
14549     /**
14550      * Creates a function that returns the result of invoking the given functions
14551      * with the `this` binding of the created function, where each successive
14552      * invocation is supplied the return value of the previous.
14553      *
14554      * @static
14555      * @memberOf _
14556      * @since 3.0.0
14557      * @category Util
14558      * @param {...(Function|Function[])} [funcs] Functions to invoke.
14559      * @returns {Function} Returns the new function.
14560      * @see _.flowRight
14561      * @example
14562      *
14563      * function square(n) {
14564      *   return n * n;
14565      * }
14566      *
14567      * var addSquare = _.flow(_.add, square);
14568      * addSquare(1, 2);
14569      * // => 9
14570      */
14571     var flow = createFlow();
14572
14573     /**
14574      * This method is like `_.flow` except that it creates a function that
14575      * invokes the given functions from right to left.
14576      *
14577      * @static
14578      * @since 3.0.0
14579      * @memberOf _
14580      * @category Util
14581      * @param {...(Function|Function[])} [funcs] Functions to invoke.
14582      * @returns {Function} Returns the new function.
14583      * @see _.flow
14584      * @example
14585      *
14586      * function square(n) {
14587      *   return n * n;
14588      * }
14589      *
14590      * var addSquare = _.flowRight(square, _.add);
14591      * addSquare(1, 2);
14592      * // => 9
14593      */
14594     var flowRight = createFlow(true);
14595
14596     /**
14597      * This method returns the first argument given to it.
14598      *
14599      * @static
14600      * @since 0.1.0
14601      * @memberOf _
14602      * @category Util
14603      * @param {*} value Any value.
14604      * @returns {*} Returns `value`.
14605      * @example
14606      *
14607      * var object = { 'user': 'fred' };
14608      *
14609      * _.identity(object) === object;
14610      * // => true
14611      */
14612     function identity(value) {
14613       return value;
14614     }
14615
14616     /**
14617      * Creates a function that invokes `func` with the arguments of the created
14618      * function. If `func` is a property name, the created function returns the
14619      * property value for a given element. If `func` is an array or object, the
14620      * created function returns `true` for elements that contain the equivalent
14621      * source properties, otherwise it returns `false`.
14622      *
14623      * @static
14624      * @since 4.0.0
14625      * @memberOf _
14626      * @category Util
14627      * @param {*} [func=_.identity] The value to convert to a callback.
14628      * @returns {Function} Returns the callback.
14629      * @example
14630      *
14631      * var users = [
14632      *   { 'user': 'barney', 'age': 36, 'active': true },
14633      *   { 'user': 'fred',   'age': 40, 'active': false }
14634      * ];
14635      *
14636      * // The `_.matches` iteratee shorthand.
14637      * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
14638      * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
14639      *
14640      * // The `_.matchesProperty` iteratee shorthand.
14641      * _.filter(users, _.iteratee(['user', 'fred']));
14642      * // => [{ 'user': 'fred', 'age': 40 }]
14643      *
14644      * // The `_.property` iteratee shorthand.
14645      * _.map(users, _.iteratee('user'));
14646      * // => ['barney', 'fred']
14647      *
14648      * // Create custom iteratee shorthands.
14649      * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
14650      *   return !_.isRegExp(func) ? iteratee(func) : function(string) {
14651      *     return func.test(string);
14652      *   };
14653      * });
14654      *
14655      * _.filter(['abc', 'def'], /ef/);
14656      * // => ['def']
14657      */
14658     function iteratee(func) {
14659       return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
14660     }
14661
14662     /**
14663      * Creates a function that performs a partial deep comparison between a given
14664      * object and `source`, returning `true` if the given object has equivalent
14665      * property values, else `false`. The created function is equivalent to
14666      * `_.isMatch` with a `source` partially applied.
14667      *
14668      * **Note:** This method supports comparing the same values as `_.isEqual`.
14669      *
14670      * @static
14671      * @memberOf _
14672      * @since 3.0.0
14673      * @category Util
14674      * @param {Object} source The object of property values to match.
14675      * @returns {Function} Returns the new function.
14676      * @example
14677      *
14678      * var users = [
14679      *   { 'user': 'barney', 'age': 36, 'active': true },
14680      *   { 'user': 'fred',   'age': 40, 'active': false }
14681      * ];
14682      *
14683      * _.filter(users, _.matches({ 'age': 40, 'active': false }));
14684      * // => [{ 'user': 'fred', 'age': 40, 'active': false }]
14685      */
14686     function matches(source) {
14687       return baseMatches(baseClone(source, true));
14688     }
14689
14690     /**
14691      * Creates a function that performs a partial deep comparison between the
14692      * value at `path` of a given object to `srcValue`, returning `true` if the
14693      * object value is equivalent, else `false`.
14694      *
14695      * **Note:** This method supports comparing the same values as `_.isEqual`.
14696      *
14697      * @static
14698      * @memberOf _
14699      * @since 3.2.0
14700      * @category Util
14701      * @param {Array|string} path The path of the property to get.
14702      * @param {*} srcValue The value to match.
14703      * @returns {Function} Returns the new function.
14704      * @example
14705      *
14706      * var users = [
14707      *   { 'user': 'barney' },
14708      *   { 'user': 'fred' }
14709      * ];
14710      *
14711      * _.find(users, _.matchesProperty('user', 'fred'));
14712      * // => { 'user': 'fred' }
14713      */
14714     function matchesProperty(path, srcValue) {
14715       return baseMatchesProperty(path, baseClone(srcValue, true));
14716     }
14717
14718     /**
14719      * Creates a function that invokes the method at `path` of a given object.
14720      * Any additional arguments are provided to the invoked method.
14721      *
14722      * @static
14723      * @memberOf _
14724      * @since 3.7.0
14725      * @category Util
14726      * @param {Array|string} path The path of the method to invoke.
14727      * @param {...*} [args] The arguments to invoke the method with.
14728      * @returns {Function} Returns the new function.
14729      * @example
14730      *
14731      * var objects = [
14732      *   { 'a': { 'b': _.constant(2) } },
14733      *   { 'a': { 'b': _.constant(1) } }
14734      * ];
14735      *
14736      * _.map(objects, _.method('a.b'));
14737      * // => [2, 1]
14738      *
14739      * _.map(objects, _.method(['a', 'b']));
14740      * // => [2, 1]
14741      */
14742     var method = rest(function(path, args) {
14743       return function(object) {
14744         return baseInvoke(object, path, args);
14745       };
14746     });
14747
14748     /**
14749      * The opposite of `_.method`; this method creates a function that invokes
14750      * the method at a given path of `object`. Any additional arguments are
14751      * provided to the invoked method.
14752      *
14753      * @static
14754      * @memberOf _
14755      * @since 3.7.0
14756      * @category Util
14757      * @param {Object} object The object to query.
14758      * @param {...*} [args] The arguments to invoke the method with.
14759      * @returns {Function} Returns the new function.
14760      * @example
14761      *
14762      * var array = _.times(3, _.constant),
14763      *     object = { 'a': array, 'b': array, 'c': array };
14764      *
14765      * _.map(['a[2]', 'c[0]'], _.methodOf(object));
14766      * // => [2, 0]
14767      *
14768      * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
14769      * // => [2, 0]
14770      */
14771     var methodOf = rest(function(object, args) {
14772       return function(path) {
14773         return baseInvoke(object, path, args);
14774       };
14775     });
14776
14777     /**
14778      * Adds all own enumerable string keyed function properties of a source
14779      * object to the destination object. If `object` is a function, then methods
14780      * are added to its prototype as well.
14781      *
14782      * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
14783      * avoid conflicts caused by modifying the original.
14784      *
14785      * @static
14786      * @since 0.1.0
14787      * @memberOf _
14788      * @category Util
14789      * @param {Function|Object} [object=lodash] The destination object.
14790      * @param {Object} source The object of functions to add.
14791      * @param {Object} [options={}] The options object.
14792      * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
14793      * @returns {Function|Object} Returns `object`.
14794      * @example
14795      *
14796      * function vowels(string) {
14797      *   return _.filter(string, function(v) {
14798      *     return /[aeiou]/i.test(v);
14799      *   });
14800      * }
14801      *
14802      * _.mixin({ 'vowels': vowels });
14803      * _.vowels('fred');
14804      * // => ['e']
14805      *
14806      * _('fred').vowels().value();
14807      * // => ['e']
14808      *
14809      * _.mixin({ 'vowels': vowels }, { 'chain': false });
14810      * _('fred').vowels();
14811      * // => ['e']
14812      */
14813     function mixin(object, source, options) {
14814       var props = keys(source),
14815           methodNames = baseFunctions(source, props);
14816
14817       if (options == null &&
14818           !(isObject(source) && (methodNames.length || !props.length))) {
14819         options = source;
14820         source = object;
14821         object = this;
14822         methodNames = baseFunctions(source, keys(source));
14823       }
14824       var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
14825           isFunc = isFunction(object);
14826
14827       arrayEach(methodNames, function(methodName) {
14828         var func = source[methodName];
14829         object[methodName] = func;
14830         if (isFunc) {
14831           object.prototype[methodName] = function() {
14832             var chainAll = this.__chain__;
14833             if (chain || chainAll) {
14834               var result = object(this.__wrapped__),
14835                   actions = result.__actions__ = copyArray(this.__actions__);
14836
14837               actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
14838               result.__chain__ = chainAll;
14839               return result;
14840             }
14841             return func.apply(object, arrayPush([this.value()], arguments));
14842           };
14843         }
14844       });
14845
14846       return object;
14847     }
14848
14849     /**
14850      * Reverts the `_` variable to its previous value and returns a reference to
14851      * the `lodash` function.
14852      *
14853      * @static
14854      * @since 0.1.0
14855      * @memberOf _
14856      * @category Util
14857      * @returns {Function} Returns the `lodash` function.
14858      * @example
14859      *
14860      * var lodash = _.noConflict();
14861      */
14862     function noConflict() {
14863       if (root._ === this) {
14864         root._ = oldDash;
14865       }
14866       return this;
14867     }
14868
14869     /**
14870      * A no-operation function that returns `undefined` regardless of the
14871      * arguments it receives.
14872      *
14873      * @static
14874      * @memberOf _
14875      * @since 2.3.0
14876      * @category Util
14877      * @example
14878      *
14879      * var object = { 'user': 'fred' };
14880      *
14881      * _.noop(object) === undefined;
14882      * // => true
14883      */
14884     function noop() {
14885       // No operation performed.
14886     }
14887
14888     /**
14889      * Creates a function that returns its nth argument. If `n` is negative,
14890      * the nth argument from the end is returned.
14891      *
14892      * @static
14893      * @memberOf _
14894      * @since 4.0.0
14895      * @category Util
14896      * @param {number} [n=0] The index of the argument to return.
14897      * @returns {Function} Returns the new function.
14898      * @example
14899      *
14900      * var func = _.nthArg(1);
14901      * func('a', 'b', 'c', 'd');
14902      * // => 'b'
14903      *
14904      * var func = _.nthArg(-2);
14905      * func('a', 'b', 'c', 'd');
14906      * // => 'c'
14907      */
14908     function nthArg(n) {
14909       n = toInteger(n);
14910       return rest(function(args) {
14911         return baseNth(args, n);
14912       });
14913     }
14914
14915     /**
14916      * Creates a function that invokes `iteratees` with the arguments it receives
14917      * and returns their results.
14918      *
14919      * @static
14920      * @memberOf _
14921      * @since 4.0.0
14922      * @category Util
14923      * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
14924      *  [iteratees=[_.identity]] The iteratees to invoke.
14925      * @returns {Function} Returns the new function.
14926      * @example
14927      *
14928      * var func = _.over(Math.max, Math.min);
14929      *
14930      * func(1, 2, 3, 4);
14931      * // => [4, 1]
14932      */
14933     var over = createOver(arrayMap);
14934
14935     /**
14936      * Creates a function that checks if **all** of the `predicates` return
14937      * truthy when invoked with the arguments it receives.
14938      *
14939      * @static
14940      * @memberOf _
14941      * @since 4.0.0
14942      * @category Util
14943      * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
14944      *  [predicates=[_.identity]] The predicates to check.
14945      * @returns {Function} Returns the new function.
14946      * @example
14947      *
14948      * var func = _.overEvery(Boolean, isFinite);
14949      *
14950      * func('1');
14951      * // => true
14952      *
14953      * func(null);
14954      * // => false
14955      *
14956      * func(NaN);
14957      * // => false
14958      */
14959     var overEvery = createOver(arrayEvery);
14960
14961     /**
14962      * Creates a function that checks if **any** of the `predicates` return
14963      * truthy when invoked with the arguments it receives.
14964      *
14965      * @static
14966      * @memberOf _
14967      * @since 4.0.0
14968      * @category Util
14969      * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
14970      *  [predicates=[_.identity]] The predicates to check.
14971      * @returns {Function} Returns the new function.
14972      * @example
14973      *
14974      * var func = _.overSome(Boolean, isFinite);
14975      *
14976      * func('1');
14977      * // => true
14978      *
14979      * func(null);
14980      * // => true
14981      *
14982      * func(NaN);
14983      * // => false
14984      */
14985     var overSome = createOver(arraySome);
14986
14987     /**
14988      * Creates a function that returns the value at `path` of a given object.
14989      *
14990      * @static
14991      * @memberOf _
14992      * @since 2.4.0
14993      * @category Util
14994      * @param {Array|string} path The path of the property to get.
14995      * @returns {Function} Returns the new function.
14996      * @example
14997      *
14998      * var objects = [
14999      *   { 'a': { 'b': 2 } },
15000      *   { 'a': { 'b': 1 } }
15001      * ];
15002      *
15003      * _.map(objects, _.property('a.b'));
15004      * // => [2, 1]
15005      *
15006      * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
15007      * // => [1, 2]
15008      */
15009     function property(path) {
15010       return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
15011     }
15012
15013     /**
15014      * The opposite of `_.property`; this method creates a function that returns
15015      * the value at a given path of `object`.
15016      *
15017      * @static
15018      * @memberOf _
15019      * @since 3.0.0
15020      * @category Util
15021      * @param {Object} object The object to query.
15022      * @returns {Function} Returns the new function.
15023      * @example
15024      *
15025      * var array = [0, 1, 2],
15026      *     object = { 'a': array, 'b': array, 'c': array };
15027      *
15028      * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
15029      * // => [2, 0]
15030      *
15031      * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
15032      * // => [2, 0]
15033      */
15034     function propertyOf(object) {
15035       return function(path) {
15036         return object == null ? undefined : baseGet(object, path);
15037       };
15038     }
15039
15040     /**
15041      * Creates an array of numbers (positive and/or negative) progressing from
15042      * `start` up to, but not including, `end`. A step of `-1` is used if a negative
15043      * `start` is specified without an `end` or `step`. If `end` is not specified,
15044      * it's set to `start` with `start` then set to `0`.
15045      *
15046      * **Note:** JavaScript follows the IEEE-754 standard for resolving
15047      * floating-point values which can produce unexpected results.
15048      *
15049      * @static
15050      * @since 0.1.0
15051      * @memberOf _
15052      * @category Util
15053      * @param {number} [start=0] The start of the range.
15054      * @param {number} end The end of the range.
15055      * @param {number} [step=1] The value to increment or decrement by.
15056      * @returns {Array} Returns the new array of numbers.
15057      * @see _.inRange, _.rangeRight
15058      * @example
15059      *
15060      * _.range(4);
15061      * // => [0, 1, 2, 3]
15062      *
15063      * _.range(-4);
15064      * // => [0, -1, -2, -3]
15065      *
15066      * _.range(1, 5);
15067      * // => [1, 2, 3, 4]
15068      *
15069      * _.range(0, 20, 5);
15070      * // => [0, 5, 10, 15]
15071      *
15072      * _.range(0, -4, -1);
15073      * // => [0, -1, -2, -3]
15074      *
15075      * _.range(1, 4, 0);
15076      * // => [1, 1, 1]
15077      *
15078      * _.range(0);
15079      * // => []
15080      */
15081     var range = createRange();
15082
15083     /**
15084      * This method is like `_.range` except that it populates values in
15085      * descending order.
15086      *
15087      * @static
15088      * @memberOf _
15089      * @since 4.0.0
15090      * @category Util
15091      * @param {number} [start=0] The start of the range.
15092      * @param {number} end The end of the range.
15093      * @param {number} [step=1] The value to increment or decrement by.
15094      * @returns {Array} Returns the new array of numbers.
15095      * @see _.inRange, _.range
15096      * @example
15097      *
15098      * _.rangeRight(4);
15099      * // => [3, 2, 1, 0]
15100      *
15101      * _.rangeRight(-4);
15102      * // => [-3, -2, -1, 0]
15103      *
15104      * _.rangeRight(1, 5);
15105      * // => [4, 3, 2, 1]
15106      *
15107      * _.rangeRight(0, 20, 5);
15108      * // => [15, 10, 5, 0]
15109      *
15110      * _.rangeRight(0, -4, -1);
15111      * // => [-3, -2, -1, 0]
15112      *
15113      * _.rangeRight(1, 4, 0);
15114      * // => [1, 1, 1]
15115      *
15116      * _.rangeRight(0);
15117      * // => []
15118      */
15119     var rangeRight = createRange(true);
15120
15121     /**
15122      * Invokes the iteratee `n` times, returning an array of the results of
15123      * each invocation. The iteratee is invoked with one argument; (index).
15124      *
15125      * @static
15126      * @since 0.1.0
15127      * @memberOf _
15128      * @category Util
15129      * @param {number} n The number of times to invoke `iteratee`.
15130      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
15131      * @returns {Array} Returns the array of results.
15132      * @example
15133      *
15134      * _.times(3, String);
15135      * // => ['0', '1', '2']
15136      *
15137      *  _.times(4, _.constant(true));
15138      * // => [true, true, true, true]
15139      */
15140     function times(n, iteratee) {
15141       n = toInteger(n);
15142       if (n < 1 || n > MAX_SAFE_INTEGER) {
15143         return [];
15144       }
15145       var index = MAX_ARRAY_LENGTH,
15146           length = nativeMin(n, MAX_ARRAY_LENGTH);
15147
15148       iteratee = getIteratee(iteratee);
15149       n -= MAX_ARRAY_LENGTH;
15150
15151       var result = baseTimes(length, iteratee);
15152       while (++index < n) {
15153         iteratee(index);
15154       }
15155       return result;
15156     }
15157
15158     /**
15159      * Converts `value` to a property path array.
15160      *
15161      * @static
15162      * @memberOf _
15163      * @since 4.0.0
15164      * @category Util
15165      * @param {*} value The value to convert.
15166      * @returns {Array} Returns the new property path array.
15167      * @example
15168      *
15169      * _.toPath('a.b.c');
15170      * // => ['a', 'b', 'c']
15171      *
15172      * _.toPath('a[0].b.c');
15173      * // => ['a', '0', 'b', 'c']
15174      *
15175      * var path = ['a', 'b', 'c'],
15176      *     newPath = _.toPath(path);
15177      *
15178      * console.log(newPath);
15179      * // => ['a', 'b', 'c']
15180      *
15181      * console.log(path === newPath);
15182      * // => false
15183      */
15184     function toPath(value) {
15185       if (isArray(value)) {
15186         return arrayMap(value, toKey);
15187       }
15188       return isSymbol(value) ? [value] : copyArray(stringToPath(value));
15189     }
15190
15191     /**
15192      * Generates a unique ID. If `prefix` is given, the ID is appended to it.
15193      *
15194      * @static
15195      * @since 0.1.0
15196      * @memberOf _
15197      * @category Util
15198      * @param {string} [prefix=''] The value to prefix the ID with.
15199      * @returns {string} Returns the unique ID.
15200      * @example
15201      *
15202      * _.uniqueId('contact_');
15203      * // => 'contact_104'
15204      *
15205      * _.uniqueId();
15206      * // => '105'
15207      */
15208     function uniqueId(prefix) {
15209       var id = ++idCounter;
15210       return toString(prefix) + id;
15211     }
15212
15213     /*------------------------------------------------------------------------*/
15214
15215     /**
15216      * Adds two numbers.
15217      *
15218      * @static
15219      * @memberOf _
15220      * @since 3.4.0
15221      * @category Math
15222      * @param {number} augend The first number in an addition.
15223      * @param {number} addend The second number in an addition.
15224      * @returns {number} Returns the total.
15225      * @example
15226      *
15227      * _.add(6, 4);
15228      * // => 10
15229      */
15230     var add = createMathOperation(function(augend, addend) {
15231       return augend + addend;
15232     });
15233
15234     /**
15235      * Computes `number` rounded up to `precision`.
15236      *
15237      * @static
15238      * @memberOf _
15239      * @since 3.10.0
15240      * @category Math
15241      * @param {number} number The number to round up.
15242      * @param {number} [precision=0] The precision to round up to.
15243      * @returns {number} Returns the rounded up number.
15244      * @example
15245      *
15246      * _.ceil(4.006);
15247      * // => 5
15248      *
15249      * _.ceil(6.004, 2);
15250      * // => 6.01
15251      *
15252      * _.ceil(6040, -2);
15253      * // => 6100
15254      */
15255     var ceil = createRound('ceil');
15256
15257     /**
15258      * Divide two numbers.
15259      *
15260      * @static
15261      * @memberOf _
15262      * @since 4.7.0
15263      * @category Math
15264      * @param {number} dividend The first number in a division.
15265      * @param {number} divisor The second number in a division.
15266      * @returns {number} Returns the quotient.
15267      * @example
15268      *
15269      * _.divide(6, 4);
15270      * // => 1.5
15271      */
15272     var divide = createMathOperation(function(dividend, divisor) {
15273       return dividend / divisor;
15274     });
15275
15276     /**
15277      * Computes `number` rounded down to `precision`.
15278      *
15279      * @static
15280      * @memberOf _
15281      * @since 3.10.0
15282      * @category Math
15283      * @param {number} number The number to round down.
15284      * @param {number} [precision=0] The precision to round down to.
15285      * @returns {number} Returns the rounded down number.
15286      * @example
15287      *
15288      * _.floor(4.006);
15289      * // => 4
15290      *
15291      * _.floor(0.046, 2);
15292      * // => 0.04
15293      *
15294      * _.floor(4060, -2);
15295      * // => 4000
15296      */
15297     var floor = createRound('floor');
15298
15299     /**
15300      * Computes the maximum value of `array`. If `array` is empty or falsey,
15301      * `undefined` is returned.
15302      *
15303      * @static
15304      * @since 0.1.0
15305      * @memberOf _
15306      * @category Math
15307      * @param {Array} array The array to iterate over.
15308      * @returns {*} Returns the maximum value.
15309      * @example
15310      *
15311      * _.max([4, 2, 8, 6]);
15312      * // => 8
15313      *
15314      * _.max([]);
15315      * // => undefined
15316      */
15317     function max(array) {
15318       return (array && array.length)
15319         ? baseExtremum(array, identity, baseGt)
15320         : undefined;
15321     }
15322
15323     /**
15324      * This method is like `_.max` except that it accepts `iteratee` which is
15325      * invoked for each element in `array` to generate the criterion by which
15326      * the value is ranked. The iteratee is invoked with one argument: (value).
15327      *
15328      * @static
15329      * @memberOf _
15330      * @since 4.0.0
15331      * @category Math
15332      * @param {Array} array The array to iterate over.
15333      * @param {Array|Function|Object|string} [iteratee=_.identity]
15334      *  The iteratee invoked per element.
15335      * @returns {*} Returns the maximum value.
15336      * @example
15337      *
15338      * var objects = [{ 'n': 1 }, { 'n': 2 }];
15339      *
15340      * _.maxBy(objects, function(o) { return o.n; });
15341      * // => { 'n': 2 }
15342      *
15343      * // The `_.property` iteratee shorthand.
15344      * _.maxBy(objects, 'n');
15345      * // => { 'n': 2 }
15346      */
15347     function maxBy(array, iteratee) {
15348       return (array && array.length)
15349         ? baseExtremum(array, getIteratee(iteratee), baseGt)
15350         : undefined;
15351     }
15352
15353     /**
15354      * Computes the mean of the values in `array`.
15355      *
15356      * @static
15357      * @memberOf _
15358      * @since 4.0.0
15359      * @category Math
15360      * @param {Array} array The array to iterate over.
15361      * @returns {number} Returns the mean.
15362      * @example
15363      *
15364      * _.mean([4, 2, 8, 6]);
15365      * // => 5
15366      */
15367     function mean(array) {
15368       return baseMean(array, identity);
15369     }
15370
15371     /**
15372      * This method is like `_.mean` except that it accepts `iteratee` which is
15373      * invoked for each element in `array` to generate the value to be averaged.
15374      * The iteratee is invoked with one argument: (value).
15375      *
15376      * @static
15377      * @memberOf _
15378      * @since 4.7.0
15379      * @category Math
15380      * @param {Array} array The array to iterate over.
15381      * @param {Array|Function|Object|string} [iteratee=_.identity]
15382      *  The iteratee invoked per element.
15383      * @returns {number} Returns the mean.
15384      * @example
15385      *
15386      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
15387      *
15388      * _.meanBy(objects, function(o) { return o.n; });
15389      * // => 5
15390      *
15391      * // The `_.property` iteratee shorthand.
15392      * _.meanBy(objects, 'n');
15393      * // => 5
15394      */
15395     function meanBy(array, iteratee) {
15396       return baseMean(array, getIteratee(iteratee));
15397     }
15398
15399     /**
15400      * Computes the minimum value of `array`. If `array` is empty or falsey,
15401      * `undefined` is returned.
15402      *
15403      * @static
15404      * @since 0.1.0
15405      * @memberOf _
15406      * @category Math
15407      * @param {Array} array The array to iterate over.
15408      * @returns {*} Returns the minimum value.
15409      * @example
15410      *
15411      * _.min([4, 2, 8, 6]);
15412      * // => 2
15413      *
15414      * _.min([]);
15415      * // => undefined
15416      */
15417     function min(array) {
15418       return (array && array.length)
15419         ? baseExtremum(array, identity, baseLt)
15420         : undefined;
15421     }
15422
15423     /**
15424      * This method is like `_.min` except that it accepts `iteratee` which is
15425      * invoked for each element in `array` to generate the criterion by which
15426      * the value is ranked. The iteratee is invoked with one argument: (value).
15427      *
15428      * @static
15429      * @memberOf _
15430      * @since 4.0.0
15431      * @category Math
15432      * @param {Array} array The array to iterate over.
15433      * @param {Array|Function|Object|string} [iteratee=_.identity]
15434      *  The iteratee invoked per element.
15435      * @returns {*} Returns the minimum value.
15436      * @example
15437      *
15438      * var objects = [{ 'n': 1 }, { 'n': 2 }];
15439      *
15440      * _.minBy(objects, function(o) { return o.n; });
15441      * // => { 'n': 1 }
15442      *
15443      * // The `_.property` iteratee shorthand.
15444      * _.minBy(objects, 'n');
15445      * // => { 'n': 1 }
15446      */
15447     function minBy(array, iteratee) {
15448       return (array && array.length)
15449         ? baseExtremum(array, getIteratee(iteratee), baseLt)
15450         : undefined;
15451     }
15452
15453     /**
15454      * Multiply two numbers.
15455      *
15456      * @static
15457      * @memberOf _
15458      * @since 4.7.0
15459      * @category Math
15460      * @param {number} multiplier The first number in a multiplication.
15461      * @param {number} multiplicand The second number in a multiplication.
15462      * @returns {number} Returns the product.
15463      * @example
15464      *
15465      * _.multiply(6, 4);
15466      * // => 24
15467      */
15468     var multiply = createMathOperation(function(multiplier, multiplicand) {
15469       return multiplier * multiplicand;
15470     });
15471
15472     /**
15473      * Computes `number` rounded to `precision`.
15474      *
15475      * @static
15476      * @memberOf _
15477      * @since 3.10.0
15478      * @category Math
15479      * @param {number} number The number to round.
15480      * @param {number} [precision=0] The precision to round to.
15481      * @returns {number} Returns the rounded number.
15482      * @example
15483      *
15484      * _.round(4.006);
15485      * // => 4
15486      *
15487      * _.round(4.006, 2);
15488      * // => 4.01
15489      *
15490      * _.round(4060, -2);
15491      * // => 4100
15492      */
15493     var round = createRound('round');
15494
15495     /**
15496      * Subtract two numbers.
15497      *
15498      * @static
15499      * @memberOf _
15500      * @since 4.0.0
15501      * @category Math
15502      * @param {number} minuend The first number in a subtraction.
15503      * @param {number} subtrahend The second number in a subtraction.
15504      * @returns {number} Returns the difference.
15505      * @example
15506      *
15507      * _.subtract(6, 4);
15508      * // => 2
15509      */
15510     var subtract = createMathOperation(function(minuend, subtrahend) {
15511       return minuend - subtrahend;
15512     });
15513
15514     /**
15515      * Computes the sum of the values in `array`.
15516      *
15517      * @static
15518      * @memberOf _
15519      * @since 3.4.0
15520      * @category Math
15521      * @param {Array} array The array to iterate over.
15522      * @returns {number} Returns the sum.
15523      * @example
15524      *
15525      * _.sum([4, 2, 8, 6]);
15526      * // => 20
15527      */
15528     function sum(array) {
15529       return (array && array.length)
15530         ? baseSum(array, identity)
15531         : 0;
15532     }
15533
15534     /**
15535      * This method is like `_.sum` except that it accepts `iteratee` which is
15536      * invoked for each element in `array` to generate the value to be summed.
15537      * The iteratee is invoked with one argument: (value).
15538      *
15539      * @static
15540      * @memberOf _
15541      * @since 4.0.0
15542      * @category Math
15543      * @param {Array} array The array to iterate over.
15544      * @param {Array|Function|Object|string} [iteratee=_.identity]
15545      *  The iteratee invoked per element.
15546      * @returns {number} Returns the sum.
15547      * @example
15548      *
15549      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
15550      *
15551      * _.sumBy(objects, function(o) { return o.n; });
15552      * // => 20
15553      *
15554      * // The `_.property` iteratee shorthand.
15555      * _.sumBy(objects, 'n');
15556      * // => 20
15557      */
15558     function sumBy(array, iteratee) {
15559       return (array && array.length)
15560         ? baseSum(array, getIteratee(iteratee))
15561         : 0;
15562     }
15563
15564     /*------------------------------------------------------------------------*/
15565
15566     // Add methods that return wrapped values in chain sequences.
15567     lodash.after = after;
15568     lodash.ary = ary;
15569     lodash.assign = assign;
15570     lodash.assignIn = assignIn;
15571     lodash.assignInWith = assignInWith;
15572     lodash.assignWith = assignWith;
15573     lodash.at = at;
15574     lodash.before = before;
15575     lodash.bind = bind;
15576     lodash.bindAll = bindAll;
15577     lodash.bindKey = bindKey;
15578     lodash.castArray = castArray;
15579     lodash.chain = chain;
15580     lodash.chunk = chunk;
15581     lodash.compact = compact;
15582     lodash.concat = concat;
15583     lodash.cond = cond;
15584     lodash.conforms = conforms;
15585     lodash.constant = constant;
15586     lodash.countBy = countBy;
15587     lodash.create = create;
15588     lodash.curry = curry;
15589     lodash.curryRight = curryRight;
15590     lodash.debounce = debounce;
15591     lodash.defaults = defaults;
15592     lodash.defaultsDeep = defaultsDeep;
15593     lodash.defer = defer;
15594     lodash.delay = delay;
15595     lodash.difference = difference;
15596     lodash.differenceBy = differenceBy;
15597     lodash.differenceWith = differenceWith;
15598     lodash.drop = drop;
15599     lodash.dropRight = dropRight;
15600     lodash.dropRightWhile = dropRightWhile;
15601     lodash.dropWhile = dropWhile;
15602     lodash.fill = fill;
15603     lodash.filter = filter;
15604     lodash.flatMap = flatMap;
15605     lodash.flatMapDeep = flatMapDeep;
15606     lodash.flatMapDepth = flatMapDepth;
15607     lodash.flatten = flatten;
15608     lodash.flattenDeep = flattenDeep;
15609     lodash.flattenDepth = flattenDepth;
15610     lodash.flip = flip;
15611     lodash.flow = flow;
15612     lodash.flowRight = flowRight;
15613     lodash.fromPairs = fromPairs;
15614     lodash.functions = functions;
15615     lodash.functionsIn = functionsIn;
15616     lodash.groupBy = groupBy;
15617     lodash.initial = initial;
15618     lodash.intersection = intersection;
15619     lodash.intersectionBy = intersectionBy;
15620     lodash.intersectionWith = intersectionWith;
15621     lodash.invert = invert;
15622     lodash.invertBy = invertBy;
15623     lodash.invokeMap = invokeMap;
15624     lodash.iteratee = iteratee;
15625     lodash.keyBy = keyBy;
15626     lodash.keys = keys;
15627     lodash.keysIn = keysIn;
15628     lodash.map = map;
15629     lodash.mapKeys = mapKeys;
15630     lodash.mapValues = mapValues;
15631     lodash.matches = matches;
15632     lodash.matchesProperty = matchesProperty;
15633     lodash.memoize = memoize;
15634     lodash.merge = merge;
15635     lodash.mergeWith = mergeWith;
15636     lodash.method = method;
15637     lodash.methodOf = methodOf;
15638     lodash.mixin = mixin;
15639     lodash.negate = negate;
15640     lodash.nthArg = nthArg;
15641     lodash.omit = omit;
15642     lodash.omitBy = omitBy;
15643     lodash.once = once;
15644     lodash.orderBy = orderBy;
15645     lodash.over = over;
15646     lodash.overArgs = overArgs;
15647     lodash.overEvery = overEvery;
15648     lodash.overSome = overSome;
15649     lodash.partial = partial;
15650     lodash.partialRight = partialRight;
15651     lodash.partition = partition;
15652     lodash.pick = pick;
15653     lodash.pickBy = pickBy;
15654     lodash.property = property;
15655     lodash.propertyOf = propertyOf;
15656     lodash.pull = pull;
15657     lodash.pullAll = pullAll;
15658     lodash.pullAllBy = pullAllBy;
15659     lodash.pullAllWith = pullAllWith;
15660     lodash.pullAt = pullAt;
15661     lodash.range = range;
15662     lodash.rangeRight = rangeRight;
15663     lodash.rearg = rearg;
15664     lodash.reject = reject;
15665     lodash.remove = remove;
15666     lodash.rest = rest;
15667     lodash.reverse = reverse;
15668     lodash.sampleSize = sampleSize;
15669     lodash.set = set;
15670     lodash.setWith = setWith;
15671     lodash.shuffle = shuffle;
15672     lodash.slice = slice;
15673     lodash.sortBy = sortBy;
15674     lodash.sortedUniq = sortedUniq;
15675     lodash.sortedUniqBy = sortedUniqBy;
15676     lodash.split = split;
15677     lodash.spread = spread;
15678     lodash.tail = tail;
15679     lodash.take = take;
15680     lodash.takeRight = takeRight;
15681     lodash.takeRightWhile = takeRightWhile;
15682     lodash.takeWhile = takeWhile;
15683     lodash.tap = tap;
15684     lodash.throttle = throttle;
15685     lodash.thru = thru;
15686     lodash.toArray = toArray;
15687     lodash.toPairs = toPairs;
15688     lodash.toPairsIn = toPairsIn;
15689     lodash.toPath = toPath;
15690     lodash.toPlainObject = toPlainObject;
15691     lodash.transform = transform;
15692     lodash.unary = unary;
15693     lodash.union = union;
15694     lodash.unionBy = unionBy;
15695     lodash.unionWith = unionWith;
15696     lodash.uniq = uniq;
15697     lodash.uniqBy = uniqBy;
15698     lodash.uniqWith = uniqWith;
15699     lodash.unset = unset;
15700     lodash.unzip = unzip;
15701     lodash.unzipWith = unzipWith;
15702     lodash.update = update;
15703     lodash.updateWith = updateWith;
15704     lodash.values = values;
15705     lodash.valuesIn = valuesIn;
15706     lodash.without = without;
15707     lodash.words = words;
15708     lodash.wrap = wrap;
15709     lodash.xor = xor;
15710     lodash.xorBy = xorBy;
15711     lodash.xorWith = xorWith;
15712     lodash.zip = zip;
15713     lodash.zipObject = zipObject;
15714     lodash.zipObjectDeep = zipObjectDeep;
15715     lodash.zipWith = zipWith;
15716
15717     // Add aliases.
15718     lodash.entries = toPairs;
15719     lodash.entriesIn = toPairsIn;
15720     lodash.extend = assignIn;
15721     lodash.extendWith = assignInWith;
15722
15723     // Add methods to `lodash.prototype`.
15724     mixin(lodash, lodash);
15725
15726     /*------------------------------------------------------------------------*/
15727
15728     // Add methods that return unwrapped values in chain sequences.
15729     lodash.add = add;
15730     lodash.attempt = attempt;
15731     lodash.camelCase = camelCase;
15732     lodash.capitalize = capitalize;
15733     lodash.ceil = ceil;
15734     lodash.clamp = clamp;
15735     lodash.clone = clone;
15736     lodash.cloneDeep = cloneDeep;
15737     lodash.cloneDeepWith = cloneDeepWith;
15738     lodash.cloneWith = cloneWith;
15739     lodash.deburr = deburr;
15740     lodash.divide = divide;
15741     lodash.endsWith = endsWith;
15742     lodash.eq = eq;
15743     lodash.escape = escape;
15744     lodash.escapeRegExp = escapeRegExp;
15745     lodash.every = every;
15746     lodash.find = find;
15747     lodash.findIndex = findIndex;
15748     lodash.findKey = findKey;
15749     lodash.findLast = findLast;
15750     lodash.findLastIndex = findLastIndex;
15751     lodash.findLastKey = findLastKey;
15752     lodash.floor = floor;
15753     lodash.forEach = forEach;
15754     lodash.forEachRight = forEachRight;
15755     lodash.forIn = forIn;
15756     lodash.forInRight = forInRight;
15757     lodash.forOwn = forOwn;
15758     lodash.forOwnRight = forOwnRight;
15759     lodash.get = get;
15760     lodash.gt = gt;
15761     lodash.gte = gte;
15762     lodash.has = has;
15763     lodash.hasIn = hasIn;
15764     lodash.head = head;
15765     lodash.identity = identity;
15766     lodash.includes = includes;
15767     lodash.indexOf = indexOf;
15768     lodash.inRange = inRange;
15769     lodash.invoke = invoke;
15770     lodash.isArguments = isArguments;
15771     lodash.isArray = isArray;
15772     lodash.isArrayBuffer = isArrayBuffer;
15773     lodash.isArrayLike = isArrayLike;
15774     lodash.isArrayLikeObject = isArrayLikeObject;
15775     lodash.isBoolean = isBoolean;
15776     lodash.isBuffer = isBuffer;
15777     lodash.isDate = isDate;
15778     lodash.isElement = isElement;
15779     lodash.isEmpty = isEmpty;
15780     lodash.isEqual = isEqual;
15781     lodash.isEqualWith = isEqualWith;
15782     lodash.isError = isError;
15783     lodash.isFinite = isFinite;
15784     lodash.isFunction = isFunction;
15785     lodash.isInteger = isInteger;
15786     lodash.isLength = isLength;
15787     lodash.isMap = isMap;
15788     lodash.isMatch = isMatch;
15789     lodash.isMatchWith = isMatchWith;
15790     lodash.isNaN = isNaN;
15791     lodash.isNative = isNative;
15792     lodash.isNil = isNil;
15793     lodash.isNull = isNull;
15794     lodash.isNumber = isNumber;
15795     lodash.isObject = isObject;
15796     lodash.isObjectLike = isObjectLike;
15797     lodash.isPlainObject = isPlainObject;
15798     lodash.isRegExp = isRegExp;
15799     lodash.isSafeInteger = isSafeInteger;
15800     lodash.isSet = isSet;
15801     lodash.isString = isString;
15802     lodash.isSymbol = isSymbol;
15803     lodash.isTypedArray = isTypedArray;
15804     lodash.isUndefined = isUndefined;
15805     lodash.isWeakMap = isWeakMap;
15806     lodash.isWeakSet = isWeakSet;
15807     lodash.join = join;
15808     lodash.kebabCase = kebabCase;
15809     lodash.last = last;
15810     lodash.lastIndexOf = lastIndexOf;
15811     lodash.lowerCase = lowerCase;
15812     lodash.lowerFirst = lowerFirst;
15813     lodash.lt = lt;
15814     lodash.lte = lte;
15815     lodash.max = max;
15816     lodash.maxBy = maxBy;
15817     lodash.mean = mean;
15818     lodash.meanBy = meanBy;
15819     lodash.min = min;
15820     lodash.minBy = minBy;
15821     lodash.multiply = multiply;
15822     lodash.nth = nth;
15823     lodash.noConflict = noConflict;
15824     lodash.noop = noop;
15825     lodash.now = now;
15826     lodash.pad = pad;
15827     lodash.padEnd = padEnd;
15828     lodash.padStart = padStart;
15829     lodash.parseInt = parseInt;
15830     lodash.random = random;
15831     lodash.reduce = reduce;
15832     lodash.reduceRight = reduceRight;
15833     lodash.repeat = repeat;
15834     lodash.replace = replace;
15835     lodash.result = result;
15836     lodash.round = round;
15837     lodash.runInContext = runInContext;
15838     lodash.sample = sample;
15839     lodash.size = size;
15840     lodash.snakeCase = snakeCase;
15841     lodash.some = some;
15842     lodash.sortedIndex = sortedIndex;
15843     lodash.sortedIndexBy = sortedIndexBy;
15844     lodash.sortedIndexOf = sortedIndexOf;
15845     lodash.sortedLastIndex = sortedLastIndex;
15846     lodash.sortedLastIndexBy = sortedLastIndexBy;
15847     lodash.sortedLastIndexOf = sortedLastIndexOf;
15848     lodash.startCase = startCase;
15849     lodash.startsWith = startsWith;
15850     lodash.subtract = subtract;
15851     lodash.sum = sum;
15852     lodash.sumBy = sumBy;
15853     lodash.template = template;
15854     lodash.times = times;
15855     lodash.toInteger = toInteger;
15856     lodash.toLength = toLength;
15857     lodash.toLower = toLower;
15858     lodash.toNumber = toNumber;
15859     lodash.toSafeInteger = toSafeInteger;
15860     lodash.toString = toString;
15861     lodash.toUpper = toUpper;
15862     lodash.trim = trim;
15863     lodash.trimEnd = trimEnd;
15864     lodash.trimStart = trimStart;
15865     lodash.truncate = truncate;
15866     lodash.unescape = unescape;
15867     lodash.uniqueId = uniqueId;
15868     lodash.upperCase = upperCase;
15869     lodash.upperFirst = upperFirst;
15870
15871     // Add aliases.
15872     lodash.each = forEach;
15873     lodash.eachRight = forEachRight;
15874     lodash.first = head;
15875
15876     mixin(lodash, (function() {
15877       var source = {};
15878       baseForOwn(lodash, function(func, methodName) {
15879         if (!hasOwnProperty.call(lodash.prototype, methodName)) {
15880           source[methodName] = func;
15881         }
15882       });
15883       return source;
15884     }()), { 'chain': false });
15885
15886     /*------------------------------------------------------------------------*/
15887
15888     /**
15889      * The semantic version number.
15890      *
15891      * @static
15892      * @memberOf _
15893      * @type {string}
15894      */
15895     lodash.VERSION = VERSION;
15896
15897     // Assign default placeholders.
15898     arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
15899       lodash[methodName].placeholder = lodash;
15900     });
15901
15902     // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
15903     arrayEach(['drop', 'take'], function(methodName, index) {
15904       LazyWrapper.prototype[methodName] = function(n) {
15905         var filtered = this.__filtered__;
15906         if (filtered && !index) {
15907           return new LazyWrapper(this);
15908         }
15909         n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
15910
15911         var result = this.clone();
15912         if (filtered) {
15913           result.__takeCount__ = nativeMin(n, result.__takeCount__);
15914         } else {
15915           result.__views__.push({
15916             'size': nativeMin(n, MAX_ARRAY_LENGTH),
15917             'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
15918           });
15919         }
15920         return result;
15921       };
15922
15923       LazyWrapper.prototype[methodName + 'Right'] = function(n) {
15924         return this.reverse()[methodName](n).reverse();
15925       };
15926     });
15927
15928     // Add `LazyWrapper` methods that accept an `iteratee` value.
15929     arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
15930       var type = index + 1,
15931           isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
15932
15933       LazyWrapper.prototype[methodName] = function(iteratee) {
15934         var result = this.clone();
15935         result.__iteratees__.push({
15936           'iteratee': getIteratee(iteratee, 3),
15937           'type': type
15938         });
15939         result.__filtered__ = result.__filtered__ || isFilter;
15940         return result;
15941       };
15942     });
15943
15944     // Add `LazyWrapper` methods for `_.head` and `_.last`.
15945     arrayEach(['head', 'last'], function(methodName, index) {
15946       var takeName = 'take' + (index ? 'Right' : '');
15947
15948       LazyWrapper.prototype[methodName] = function() {
15949         return this[takeName](1).value()[0];
15950       };
15951     });
15952
15953     // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
15954     arrayEach(['initial', 'tail'], function(methodName, index) {
15955       var dropName = 'drop' + (index ? '' : 'Right');
15956
15957       LazyWrapper.prototype[methodName] = function() {
15958         return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
15959       };
15960     });
15961
15962     LazyWrapper.prototype.compact = function() {
15963       return this.filter(identity);
15964     };
15965
15966     LazyWrapper.prototype.find = function(predicate) {
15967       return this.filter(predicate).head();
15968     };
15969
15970     LazyWrapper.prototype.findLast = function(predicate) {
15971       return this.reverse().find(predicate);
15972     };
15973
15974     LazyWrapper.prototype.invokeMap = rest(function(path, args) {
15975       if (typeof path == 'function') {
15976         return new LazyWrapper(this);
15977       }
15978       return this.map(function(value) {
15979         return baseInvoke(value, path, args);
15980       });
15981     });
15982
15983     LazyWrapper.prototype.reject = function(predicate) {
15984       predicate = getIteratee(predicate, 3);
15985       return this.filter(function(value) {
15986         return !predicate(value);
15987       });
15988     };
15989
15990     LazyWrapper.prototype.slice = function(start, end) {
15991       start = toInteger(start);
15992
15993       var result = this;
15994       if (result.__filtered__ && (start > 0 || end < 0)) {
15995         return new LazyWrapper(result);
15996       }
15997       if (start < 0) {
15998         result = result.takeRight(-start);
15999       } else if (start) {
16000         result = result.drop(start);
16001       }
16002       if (end !== undefined) {
16003         end = toInteger(end);
16004         result = end < 0 ? result.dropRight(-end) : result.take(end - start);
16005       }
16006       return result;
16007     };
16008
16009     LazyWrapper.prototype.takeRightWhile = function(predicate) {
16010       return this.reverse().takeWhile(predicate).reverse();
16011     };
16012
16013     LazyWrapper.prototype.toArray = function() {
16014       return this.take(MAX_ARRAY_LENGTH);
16015     };
16016
16017     // Add `LazyWrapper` methods to `lodash.prototype`.
16018     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
16019       var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
16020           isTaker = /^(?:head|last)$/.test(methodName),
16021           lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
16022           retUnwrapped = isTaker || /^find/.test(methodName);
16023
16024       if (!lodashFunc) {
16025         return;
16026       }
16027       lodash.prototype[methodName] = function() {
16028         var value = this.__wrapped__,
16029             args = isTaker ? [1] : arguments,
16030             isLazy = value instanceof LazyWrapper,
16031             iteratee = args[0],
16032             useLazy = isLazy || isArray(value);
16033
16034         var interceptor = function(value) {
16035           var result = lodashFunc.apply(lodash, arrayPush([value], args));
16036           return (isTaker && chainAll) ? result[0] : result;
16037         };
16038
16039         if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
16040           // Avoid lazy use if the iteratee has a "length" value other than `1`.
16041           isLazy = useLazy = false;
16042         }
16043         var chainAll = this.__chain__,
16044             isHybrid = !!this.__actions__.length,
16045             isUnwrapped = retUnwrapped && !chainAll,
16046             onlyLazy = isLazy && !isHybrid;
16047
16048         if (!retUnwrapped && useLazy) {
16049           value = onlyLazy ? value : new LazyWrapper(this);
16050           var result = func.apply(value, args);
16051           result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
16052           return new LodashWrapper(result, chainAll);
16053         }
16054         if (isUnwrapped && onlyLazy) {
16055           return func.apply(this, args);
16056         }
16057         result = this.thru(interceptor);
16058         return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
16059       };
16060     });
16061
16062     // Add `Array` methods to `lodash.prototype`.
16063     arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
16064       var func = arrayProto[methodName],
16065           chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
16066           retUnwrapped = /^(?:pop|shift)$/.test(methodName);
16067
16068       lodash.prototype[methodName] = function() {
16069         var args = arguments;
16070         if (retUnwrapped && !this.__chain__) {
16071           var value = this.value();
16072           return func.apply(isArray(value) ? value : [], args);
16073         }
16074         return this[chainName](function(value) {
16075           return func.apply(isArray(value) ? value : [], args);
16076         });
16077       };
16078     });
16079
16080     // Map minified method names to their real names.
16081     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
16082       var lodashFunc = lodash[methodName];
16083       if (lodashFunc) {
16084         var key = (lodashFunc.name + ''),
16085             names = realNames[key] || (realNames[key] = []);
16086
16087         names.push({ 'name': methodName, 'func': lodashFunc });
16088       }
16089     });
16090
16091     realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{
16092       'name': 'wrapper',
16093       'func': undefined
16094     }];
16095
16096     // Add methods to `LazyWrapper`.
16097     LazyWrapper.prototype.clone = lazyClone;
16098     LazyWrapper.prototype.reverse = lazyReverse;
16099     LazyWrapper.prototype.value = lazyValue;
16100
16101     // Add chain sequence methods to the `lodash` wrapper.
16102     lodash.prototype.at = wrapperAt;
16103     lodash.prototype.chain = wrapperChain;
16104     lodash.prototype.commit = wrapperCommit;
16105     lodash.prototype.next = wrapperNext;
16106     lodash.prototype.plant = wrapperPlant;
16107     lodash.prototype.reverse = wrapperReverse;
16108     lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
16109
16110     if (iteratorSymbol) {
16111       lodash.prototype[iteratorSymbol] = wrapperToIterator;
16112     }
16113     return lodash;
16114   }
16115
16116   /*--------------------------------------------------------------------------*/
16117
16118   // Export lodash.
16119   var _ = runInContext();
16120
16121   // Expose Lodash on the free variable `window` or `self` when available so it's
16122   // globally accessible, even when bundled with Browserify, Webpack, etc. This
16123   // also prevents errors in cases where Lodash is loaded by a script tag in the
16124   // presence of an AMD loader. See http://requirejs.org/docs/errors.html#mismatch
16125   // for more details. Use `_.noConflict` to remove Lodash from the global object.
16126   (freeWindow || freeSelf || {})._ = _;
16127
16128   // Some AMD build optimizers like r.js check for condition patterns like the following:
16129   if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
16130     // Define as an anonymous module so, through path mapping, it can be
16131     // referenced as the "underscore" module.
16132     define(function() {
16133       return _;
16134     });
16135   }
16136   // Check for `exports` after `define` in case a build optimizer adds an `exports` object.
16137   else if (freeExports && freeModule) {
16138     // Export for Node.js.
16139     if (moduleExports) {
16140       (freeModule.exports = _)._ = _;
16141     }
16142     // Export for CommonJS support.
16143     freeExports._ = _;
16144   }
16145   else {
16146     // Export to the global object.
16147     root._ = _;
16148   }
16149 }.call(this));