Built motion from commit 9e1399f3.|2.5.37
[motion2.git] / public / tvox / js / lodash.min.js
1 /**
2  * @license
3  * Lodash <https://lodash.com/>
4  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5  * Released under MIT license <https://lodash.com/license>
6  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8  */
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.17.20';
17
18   /** Used as the size to enable large array optimizations. */
19   var LARGE_ARRAY_SIZE = 200;
20
21   /** Error message constants. */
22   var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
23     FUNC_ERROR_TEXT = 'Expected a function';
24
25   /** Used to stand-in for `undefined` hash values. */
26   var HASH_UNDEFINED = '__lodash_hash_undefined__';
27
28   /** Used as the maximum memoize cache size. */
29   var MAX_MEMOIZE_SIZE = 500;
30
31   /** Used as the internal argument placeholder. */
32   var PLACEHOLDER = '__lodash_placeholder__';
33
34   /** Used to compose bitmasks for cloning. */
35   var CLONE_DEEP_FLAG = 1,
36     CLONE_FLAT_FLAG = 2,
37     CLONE_SYMBOLS_FLAG = 4;
38
39   /** Used to compose bitmasks for value comparisons. */
40   var COMPARE_PARTIAL_FLAG = 1,
41     COMPARE_UNORDERED_FLAG = 2;
42
43   /** Used to compose bitmasks for function metadata. */
44   var WRAP_BIND_FLAG = 1,
45     WRAP_BIND_KEY_FLAG = 2,
46     WRAP_CURRY_BOUND_FLAG = 4,
47     WRAP_CURRY_FLAG = 8,
48     WRAP_CURRY_RIGHT_FLAG = 16,
49     WRAP_PARTIAL_FLAG = 32,
50     WRAP_PARTIAL_RIGHT_FLAG = 64,
51     WRAP_ARY_FLAG = 128,
52     WRAP_REARG_FLAG = 256,
53     WRAP_FLIP_FLAG = 512;
54
55   /** Used as default options for `_.truncate`. */
56   var DEFAULT_TRUNC_LENGTH = 30,
57     DEFAULT_TRUNC_OMISSION = '...';
58
59   /** Used to detect hot functions by number of calls within a span of milliseconds. */
60   var HOT_COUNT = 800,
61     HOT_SPAN = 16;
62
63   /** Used to indicate the type of lazy iteratees. */
64   var LAZY_FILTER_FLAG = 1,
65     LAZY_MAP_FLAG = 2,
66     LAZY_WHILE_FLAG = 3;
67
68   /** Used as references for various `Number` constants. */
69   var INFINITY = 1 / 0,
70     MAX_SAFE_INTEGER = 9007199254740991,
71     MAX_INTEGER = 1.7976931348623157e+308,
72     NAN = 0 / 0;
73
74   /** Used as references for the maximum length and index of an array. */
75   var MAX_ARRAY_LENGTH = 4294967295,
76     MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
77     HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
78
79   /** Used to associate wrap methods with their bit flags. */
80   var wrapFlags = [
81     ['ary', WRAP_ARY_FLAG],
82     ['bind', WRAP_BIND_FLAG],
83     ['bindKey', WRAP_BIND_KEY_FLAG],
84     ['curry', WRAP_CURRY_FLAG],
85     ['curryRight', WRAP_CURRY_RIGHT_FLAG],
86     ['flip', WRAP_FLIP_FLAG],
87     ['partial', WRAP_PARTIAL_FLAG],
88     ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
89     ['rearg', WRAP_REARG_FLAG]
90   ];
91
92   /** `Object#toString` result references. */
93   var argsTag = '[object Arguments]',
94     arrayTag = '[object Array]',
95     asyncTag = '[object AsyncFunction]',
96     boolTag = '[object Boolean]',
97     dateTag = '[object Date]',
98     domExcTag = '[object DOMException]',
99     errorTag = '[object Error]',
100     funcTag = '[object Function]',
101     genTag = '[object GeneratorFunction]',
102     mapTag = '[object Map]',
103     numberTag = '[object Number]',
104     nullTag = '[object Null]',
105     objectTag = '[object Object]',
106     promiseTag = '[object Promise]',
107     proxyTag = '[object Proxy]',
108     regexpTag = '[object RegExp]',
109     setTag = '[object Set]',
110     stringTag = '[object String]',
111     symbolTag = '[object Symbol]',
112     undefinedTag = '[object Undefined]',
113     weakMapTag = '[object WeakMap]',
114     weakSetTag = '[object WeakSet]';
115
116   var arrayBufferTag = '[object ArrayBuffer]',
117     dataViewTag = '[object DataView]',
118     float32Tag = '[object Float32Array]',
119     float64Tag = '[object Float64Array]',
120     int8Tag = '[object Int8Array]',
121     int16Tag = '[object Int16Array]',
122     int32Tag = '[object Int32Array]',
123     uint8Tag = '[object Uint8Array]',
124     uint8ClampedTag = '[object Uint8ClampedArray]',
125     uint16Tag = '[object Uint16Array]',
126     uint32Tag = '[object Uint32Array]';
127
128   /** Used to match empty string literals in compiled template source. */
129   var reEmptyStringLeading = /\b__p \+= '';/g,
130     reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
131     reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
132
133   /** Used to match HTML entities and HTML characters. */
134   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
135     reUnescapedHtml = /[&<>"']/g,
136     reHasEscapedHtml = RegExp(reEscapedHtml.source),
137     reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
138
139   /** Used to match template delimiters. */
140   var reEscape = /<%-([\s\S]+?)%>/g,
141     reEvaluate = /<%([\s\S]+?)%>/g,
142     reInterpolate = /<%=([\s\S]+?)%>/g;
143
144   /** Used to match property names within property paths. */
145   var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
146     reIsPlainProp = /^\w*$/,
147     rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
148
149   /**
150    * Used to match `RegExp`
151    * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
152    */
153   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
154     reHasRegExpChar = RegExp(reRegExpChar.source);
155
156   /** Used to match leading and trailing whitespace. */
157   var reTrim = /^\s+|\s+$/g,
158     reTrimStart = /^\s+/,
159     reTrimEnd = /\s+$/;
160
161   /** Used to match wrap detail comments. */
162   var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
163     reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
164     reSplitDetails = /,? & /;
165
166   /** Used to match words composed of alphanumeric characters. */
167   var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
168
169   /** Used to match backslashes in property paths. */
170   var reEscapeChar = /\\(\\)?/g;
171
172   /**
173    * Used to match
174    * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
175    */
176   var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
177
178   /** Used to match `RegExp` flags from their coerced string values. */
179   var reFlags = /\w*$/;
180
181   /** Used to detect bad signed hexadecimal string values. */
182   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
183
184   /** Used to detect binary string values. */
185   var reIsBinary = /^0b[01]+$/i;
186
187   /** Used to detect host constructors (Safari). */
188   var reIsHostCtor = /^\[object .+?Constructor\]$/;
189
190   /** Used to detect octal string values. */
191   var reIsOctal = /^0o[0-7]+$/i;
192
193   /** Used to detect unsigned integer values. */
194   var reIsUint = /^(?:0|[1-9]\d*)$/;
195
196   /** Used to match Latin Unicode letters (excluding mathematical operators). */
197   var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
198
199   /** Used to ensure capturing order of template delimiters. */
200   var reNoMatch = /($^)/;
201
202   /** Used to match unescaped characters in compiled string literals. */
203   var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
204
205   /** Used to compose unicode character classes. */
206   var rsAstralRange = '\\ud800-\\udfff',
207     rsComboMarksRange = '\\u0300-\\u036f',
208     reComboHalfMarksRange = '\\ufe20-\\ufe2f',
209     rsComboSymbolsRange = '\\u20d0-\\u20ff',
210     rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
211     rsDingbatRange = '\\u2700-\\u27bf',
212     rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
213     rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
214     rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
215     rsPunctuationRange = '\\u2000-\\u206f',
216     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',
217     rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
218     rsVarRange = '\\ufe0e\\ufe0f',
219     rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
220
221   /** Used to compose unicode capture groups. */
222   var rsApos = "['\u2019]",
223     rsAstral = '[' + rsAstralRange + ']',
224     rsBreak = '[' + rsBreakRange + ']',
225     rsCombo = '[' + rsComboRange + ']',
226     rsDigits = '\\d+',
227     rsDingbat = '[' + rsDingbatRange + ']',
228     rsLower = '[' + rsLowerRange + ']',
229     rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
230     rsFitz = '\\ud83c[\\udffb-\\udfff]',
231     rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
232     rsNonAstral = '[^' + rsAstralRange + ']',
233     rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
234     rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
235     rsUpper = '[' + rsUpperRange + ']',
236     rsZWJ = '\\u200d';
237
238   /** Used to compose unicode regexes. */
239   var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
240     rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
241     rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
242     rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
243     reOptMod = rsModifier + '?',
244     rsOptVar = '[' + rsVarRange + ']?',
245     rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
246     rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
247     rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
248     rsSeq = rsOptVar + reOptMod + rsOptJoin,
249     rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
250     rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
251
252   /** Used to match apostrophes. */
253   var reApos = RegExp(rsApos, 'g');
254
255   /**
256    * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
257    * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
258    */
259   var reComboMark = RegExp(rsCombo, 'g');
260
261   /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
262   var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
263
264   /** Used to match complex or compound words. */
265   var reUnicodeWord = RegExp([
266     rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
267     rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
268     rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
269     rsUpper + '+' + rsOptContrUpper,
270     rsOrdUpper,
271     rsOrdLower,
272     rsDigits,
273     rsEmoji
274   ].join('|'), 'g');
275
276   /** 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/). */
277   var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
278
279   /** Used to detect strings that need a more robust regexp to match words. */
280   var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
281
282   /** Used to assign default `context` object properties. */
283   var contextProps = [
284     'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
285     'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
286     'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
287     'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
288     '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
289   ];
290
291   /** Used to make template sourceURLs easier to identify. */
292   var templateCounter = -1;
293
294   /** Used to identify `toStringTag` values of typed arrays. */
295   var typedArrayTags = {};
296   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
297     typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
298     typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
299     typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
300     typedArrayTags[uint32Tag] = true;
301   typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
302     typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
303     typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
304     typedArrayTags[errorTag] = typedArrayTags[funcTag] =
305     typedArrayTags[mapTag] = typedArrayTags[numberTag] =
306     typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
307     typedArrayTags[setTag] = typedArrayTags[stringTag] =
308     typedArrayTags[weakMapTag] = false;
309
310   /** Used to identify `toStringTag` values supported by `_.clone`. */
311   var cloneableTags = {};
312   cloneableTags[argsTag] = cloneableTags[arrayTag] =
313     cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
314     cloneableTags[boolTag] = cloneableTags[dateTag] =
315     cloneableTags[float32Tag] = cloneableTags[float64Tag] =
316     cloneableTags[int8Tag] = cloneableTags[int16Tag] =
317     cloneableTags[int32Tag] = cloneableTags[mapTag] =
318     cloneableTags[numberTag] = cloneableTags[objectTag] =
319     cloneableTags[regexpTag] = cloneableTags[setTag] =
320     cloneableTags[stringTag] = cloneableTags[symbolTag] =
321     cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
322     cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
323   cloneableTags[errorTag] = cloneableTags[funcTag] =
324     cloneableTags[weakMapTag] = false;
325
326   /** Used to map Latin Unicode letters to basic Latin letters. */
327   var deburredLetters = {
328     // Latin-1 Supplement block.
329     '\xc0': 'A',
330     '\xc1': 'A',
331     '\xc2': 'A',
332     '\xc3': 'A',
333     '\xc4': 'A',
334     '\xc5': 'A',
335     '\xe0': 'a',
336     '\xe1': 'a',
337     '\xe2': 'a',
338     '\xe3': 'a',
339     '\xe4': 'a',
340     '\xe5': 'a',
341     '\xc7': 'C',
342     '\xe7': 'c',
343     '\xd0': 'D',
344     '\xf0': 'd',
345     '\xc8': 'E',
346     '\xc9': 'E',
347     '\xca': 'E',
348     '\xcb': 'E',
349     '\xe8': 'e',
350     '\xe9': 'e',
351     '\xea': 'e',
352     '\xeb': 'e',
353     '\xcc': 'I',
354     '\xcd': 'I',
355     '\xce': 'I',
356     '\xcf': 'I',
357     '\xec': 'i',
358     '\xed': 'i',
359     '\xee': 'i',
360     '\xef': 'i',
361     '\xd1': 'N',
362     '\xf1': 'n',
363     '\xd2': 'O',
364     '\xd3': 'O',
365     '\xd4': 'O',
366     '\xd5': 'O',
367     '\xd6': 'O',
368     '\xd8': 'O',
369     '\xf2': 'o',
370     '\xf3': 'o',
371     '\xf4': 'o',
372     '\xf5': 'o',
373     '\xf6': 'o',
374     '\xf8': 'o',
375     '\xd9': 'U',
376     '\xda': 'U',
377     '\xdb': 'U',
378     '\xdc': 'U',
379     '\xf9': 'u',
380     '\xfa': 'u',
381     '\xfb': 'u',
382     '\xfc': 'u',
383     '\xdd': 'Y',
384     '\xfd': 'y',
385     '\xff': 'y',
386     '\xc6': 'Ae',
387     '\xe6': 'ae',
388     '\xde': 'Th',
389     '\xfe': 'th',
390     '\xdf': 'ss',
391     // Latin Extended-A block.
392     '\u0100': 'A',
393     '\u0102': 'A',
394     '\u0104': 'A',
395     '\u0101': 'a',
396     '\u0103': 'a',
397     '\u0105': 'a',
398     '\u0106': 'C',
399     '\u0108': 'C',
400     '\u010a': 'C',
401     '\u010c': 'C',
402     '\u0107': 'c',
403     '\u0109': 'c',
404     '\u010b': 'c',
405     '\u010d': 'c',
406     '\u010e': 'D',
407     '\u0110': 'D',
408     '\u010f': 'd',
409     '\u0111': 'd',
410     '\u0112': 'E',
411     '\u0114': 'E',
412     '\u0116': 'E',
413     '\u0118': 'E',
414     '\u011a': 'E',
415     '\u0113': 'e',
416     '\u0115': 'e',
417     '\u0117': 'e',
418     '\u0119': 'e',
419     '\u011b': 'e',
420     '\u011c': 'G',
421     '\u011e': 'G',
422     '\u0120': 'G',
423     '\u0122': 'G',
424     '\u011d': 'g',
425     '\u011f': 'g',
426     '\u0121': 'g',
427     '\u0123': 'g',
428     '\u0124': 'H',
429     '\u0126': 'H',
430     '\u0125': 'h',
431     '\u0127': 'h',
432     '\u0128': 'I',
433     '\u012a': 'I',
434     '\u012c': 'I',
435     '\u012e': 'I',
436     '\u0130': 'I',
437     '\u0129': 'i',
438     '\u012b': 'i',
439     '\u012d': 'i',
440     '\u012f': 'i',
441     '\u0131': 'i',
442     '\u0134': 'J',
443     '\u0135': 'j',
444     '\u0136': 'K',
445     '\u0137': 'k',
446     '\u0138': 'k',
447     '\u0139': 'L',
448     '\u013b': 'L',
449     '\u013d': 'L',
450     '\u013f': 'L',
451     '\u0141': 'L',
452     '\u013a': 'l',
453     '\u013c': 'l',
454     '\u013e': 'l',
455     '\u0140': 'l',
456     '\u0142': 'l',
457     '\u0143': 'N',
458     '\u0145': 'N',
459     '\u0147': 'N',
460     '\u014a': 'N',
461     '\u0144': 'n',
462     '\u0146': 'n',
463     '\u0148': 'n',
464     '\u014b': 'n',
465     '\u014c': 'O',
466     '\u014e': 'O',
467     '\u0150': 'O',
468     '\u014d': 'o',
469     '\u014f': 'o',
470     '\u0151': 'o',
471     '\u0154': 'R',
472     '\u0156': 'R',
473     '\u0158': 'R',
474     '\u0155': 'r',
475     '\u0157': 'r',
476     '\u0159': 'r',
477     '\u015a': 'S',
478     '\u015c': 'S',
479     '\u015e': 'S',
480     '\u0160': 'S',
481     '\u015b': 's',
482     '\u015d': 's',
483     '\u015f': 's',
484     '\u0161': 's',
485     '\u0162': 'T',
486     '\u0164': 'T',
487     '\u0166': 'T',
488     '\u0163': 't',
489     '\u0165': 't',
490     '\u0167': 't',
491     '\u0168': 'U',
492     '\u016a': 'U',
493     '\u016c': 'U',
494     '\u016e': 'U',
495     '\u0170': 'U',
496     '\u0172': 'U',
497     '\u0169': 'u',
498     '\u016b': 'u',
499     '\u016d': 'u',
500     '\u016f': 'u',
501     '\u0171': 'u',
502     '\u0173': 'u',
503     '\u0174': 'W',
504     '\u0175': 'w',
505     '\u0176': 'Y',
506     '\u0177': 'y',
507     '\u0178': 'Y',
508     '\u0179': 'Z',
509     '\u017b': 'Z',
510     '\u017d': 'Z',
511     '\u017a': 'z',
512     '\u017c': 'z',
513     '\u017e': 'z',
514     '\u0132': 'IJ',
515     '\u0133': 'ij',
516     '\u0152': 'Oe',
517     '\u0153': 'oe',
518     '\u0149': "'n",
519     '\u017f': 's'
520   };
521
522   /** Used to map characters to HTML entities. */
523   var htmlEscapes = {
524     '&': '&amp;',
525     '<': '&lt;',
526     '>': '&gt;',
527     '"': '&quot;',
528     "'": '&#39;'
529   };
530
531   /** Used to map HTML entities to characters. */
532   var htmlUnescapes = {
533     '&amp;': '&',
534     '&lt;': '<',
535     '&gt;': '>',
536     '&quot;': '"',
537     '&#39;': "'"
538   };
539
540   /** Used to escape characters for inclusion in compiled string literals. */
541   var stringEscapes = {
542     '\\': '\\',
543     "'": "'",
544     '\n': 'n',
545     '\r': 'r',
546     '\u2028': 'u2028',
547     '\u2029': 'u2029'
548   };
549
550   /** Built-in method references without a dependency on `root`. */
551   var freeParseFloat = parseFloat,
552     freeParseInt = parseInt;
553
554   /** Detect free variable `global` from Node.js. */
555   var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
556
557   /** Detect free variable `self`. */
558   var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
559
560   /** Used as a reference to the global object. */
561   var root = freeGlobal || freeSelf || Function('return this')();
562
563   /** Detect free variable `exports`. */
564   var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
565
566   /** Detect free variable `module`. */
567   var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
568
569   /** Detect the popular CommonJS extension `module.exports`. */
570   var moduleExports = freeModule && freeModule.exports === freeExports;
571
572   /** Detect free variable `process` from Node.js. */
573   var freeProcess = moduleExports && freeGlobal.process;
574
575   /** Used to access faster Node.js helpers. */
576   var nodeUtil = (function() {
577     try {
578       // Use `util.types` for Node.js 10+.
579       var types = freeModule && freeModule.require && freeModule.require('util').types;
580
581       if (types) {
582         return types;
583       }
584
585       // Legacy `process.binding('util')` for Node.js < 10.
586       return freeProcess && freeProcess.binding && freeProcess.binding('util');
587     } catch (e) {}
588   }());
589
590   /* Node.js helper references. */
591   var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
592     nodeIsDate = nodeUtil && nodeUtil.isDate,
593     nodeIsMap = nodeUtil && nodeUtil.isMap,
594     nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
595     nodeIsSet = nodeUtil && nodeUtil.isSet,
596     nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
597
598   /*--------------------------------------------------------------------------*/
599
600   /**
601    * A faster alternative to `Function#apply`, this function invokes `func`
602    * with the `this` binding of `thisArg` and the arguments of `args`.
603    *
604    * @private
605    * @param {Function} func The function to invoke.
606    * @param {*} thisArg The `this` binding of `func`.
607    * @param {Array} args The arguments to invoke `func` with.
608    * @returns {*} Returns the result of `func`.
609    */
610   function apply(func, thisArg, args) {
611     switch (args.length) {
612       case 0:
613         return func.call(thisArg);
614       case 1:
615         return func.call(thisArg, args[0]);
616       case 2:
617         return func.call(thisArg, args[0], args[1]);
618       case 3:
619         return func.call(thisArg, args[0], args[1], args[2]);
620     }
621     return func.apply(thisArg, args);
622   }
623
624   /**
625    * A specialized version of `baseAggregator` for arrays.
626    *
627    * @private
628    * @param {Array} [array] The array to iterate over.
629    * @param {Function} setter The function to set `accumulator` values.
630    * @param {Function} iteratee The iteratee to transform keys.
631    * @param {Object} accumulator The initial aggregated object.
632    * @returns {Function} Returns `accumulator`.
633    */
634   function arrayAggregator(array, setter, iteratee, accumulator) {
635     var index = -1,
636       length = array == null ? 0 : array.length;
637
638     while (++index < length) {
639       var value = array[index];
640       setter(accumulator, value, iteratee(value), array);
641     }
642     return accumulator;
643   }
644
645   /**
646    * A specialized version of `_.forEach` for arrays without support for
647    * iteratee shorthands.
648    *
649    * @private
650    * @param {Array} [array] The array to iterate over.
651    * @param {Function} iteratee The function invoked per iteration.
652    * @returns {Array} Returns `array`.
653    */
654   function arrayEach(array, iteratee) {
655     var index = -1,
656       length = array == null ? 0 : array.length;
657
658     while (++index < length) {
659       if (iteratee(array[index], index, array) === false) {
660         break;
661       }
662     }
663     return array;
664   }
665
666   /**
667    * A specialized version of `_.forEachRight` for arrays without support for
668    * iteratee shorthands.
669    *
670    * @private
671    * @param {Array} [array] The array to iterate over.
672    * @param {Function} iteratee The function invoked per iteration.
673    * @returns {Array} Returns `array`.
674    */
675   function arrayEachRight(array, iteratee) {
676     var length = array == null ? 0 : array.length;
677
678     while (length--) {
679       if (iteratee(array[length], length, array) === false) {
680         break;
681       }
682     }
683     return array;
684   }
685
686   /**
687    * A specialized version of `_.every` for arrays without support for
688    * iteratee shorthands.
689    *
690    * @private
691    * @param {Array} [array] The array to iterate over.
692    * @param {Function} predicate The function invoked per iteration.
693    * @returns {boolean} Returns `true` if all elements pass the predicate check,
694    *  else `false`.
695    */
696   function arrayEvery(array, predicate) {
697     var index = -1,
698       length = array == null ? 0 : array.length;
699
700     while (++index < length) {
701       if (!predicate(array[index], index, array)) {
702         return false;
703       }
704     }
705     return true;
706   }
707
708   /**
709    * A specialized version of `_.filter` for arrays without support for
710    * iteratee shorthands.
711    *
712    * @private
713    * @param {Array} [array] The array to iterate over.
714    * @param {Function} predicate The function invoked per iteration.
715    * @returns {Array} Returns the new filtered array.
716    */
717   function arrayFilter(array, predicate) {
718     var index = -1,
719       length = array == null ? 0 : array.length,
720       resIndex = 0,
721       result = [];
722
723     while (++index < length) {
724       var value = array[index];
725       if (predicate(value, index, array)) {
726         result[resIndex++] = value;
727       }
728     }
729     return result;
730   }
731
732   /**
733    * A specialized version of `_.includes` for arrays without support for
734    * specifying an index to search from.
735    *
736    * @private
737    * @param {Array} [array] The array to inspect.
738    * @param {*} target The value to search for.
739    * @returns {boolean} Returns `true` if `target` is found, else `false`.
740    */
741   function arrayIncludes(array, value) {
742     var length = array == null ? 0 : array.length;
743     return !!length && baseIndexOf(array, value, 0) > -1;
744   }
745
746   /**
747    * This function is like `arrayIncludes` except that it accepts a comparator.
748    *
749    * @private
750    * @param {Array} [array] The array to inspect.
751    * @param {*} target The value to search for.
752    * @param {Function} comparator The comparator invoked per element.
753    * @returns {boolean} Returns `true` if `target` is found, else `false`.
754    */
755   function arrayIncludesWith(array, value, comparator) {
756     var index = -1,
757       length = array == null ? 0 : array.length;
758
759     while (++index < length) {
760       if (comparator(value, array[index])) {
761         return true;
762       }
763     }
764     return false;
765   }
766
767   /**
768    * A specialized version of `_.map` for arrays without support for iteratee
769    * shorthands.
770    *
771    * @private
772    * @param {Array} [array] The array to iterate over.
773    * @param {Function} iteratee The function invoked per iteration.
774    * @returns {Array} Returns the new mapped array.
775    */
776   function arrayMap(array, iteratee) {
777     var index = -1,
778       length = array == null ? 0 : array.length,
779       result = Array(length);
780
781     while (++index < length) {
782       result[index] = iteratee(array[index], index, array);
783     }
784     return result;
785   }
786
787   /**
788    * Appends the elements of `values` to `array`.
789    *
790    * @private
791    * @param {Array} array The array to modify.
792    * @param {Array} values The values to append.
793    * @returns {Array} Returns `array`.
794    */
795   function arrayPush(array, values) {
796     var index = -1,
797       length = values.length,
798       offset = array.length;
799
800     while (++index < length) {
801       array[offset + index] = values[index];
802     }
803     return array;
804   }
805
806   /**
807    * A specialized version of `_.reduce` for arrays 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    * @param {*} [accumulator] The initial value.
814    * @param {boolean} [initAccum] Specify using the first element of `array` as
815    *  the initial value.
816    * @returns {*} Returns the accumulated value.
817    */
818   function arrayReduce(array, iteratee, accumulator, initAccum) {
819     var index = -1,
820       length = array == null ? 0 : array.length;
821
822     if (initAccum && length) {
823       accumulator = array[++index];
824     }
825     while (++index < length) {
826       accumulator = iteratee(accumulator, array[index], index, array);
827     }
828     return accumulator;
829   }
830
831   /**
832    * A specialized version of `_.reduceRight` for arrays without support for
833    * iteratee shorthands.
834    *
835    * @private
836    * @param {Array} [array] The array to iterate over.
837    * @param {Function} iteratee The function invoked per iteration.
838    * @param {*} [accumulator] The initial value.
839    * @param {boolean} [initAccum] Specify using the last element of `array` as
840    *  the initial value.
841    * @returns {*} Returns the accumulated value.
842    */
843   function arrayReduceRight(array, iteratee, accumulator, initAccum) {
844     var length = array == null ? 0 : array.length;
845     if (initAccum && length) {
846       accumulator = array[--length];
847     }
848     while (length--) {
849       accumulator = iteratee(accumulator, array[length], length, array);
850     }
851     return accumulator;
852   }
853
854   /**
855    * A specialized version of `_.some` for arrays without support for iteratee
856    * shorthands.
857    *
858    * @private
859    * @param {Array} [array] The array to iterate over.
860    * @param {Function} predicate The function invoked per iteration.
861    * @returns {boolean} Returns `true` if any element passes the predicate check,
862    *  else `false`.
863    */
864   function arraySome(array, predicate) {
865     var index = -1,
866       length = array == null ? 0 : array.length;
867
868     while (++index < length) {
869       if (predicate(array[index], index, array)) {
870         return true;
871       }
872     }
873     return false;
874   }
875
876   /**
877    * Gets the size of an ASCII `string`.
878    *
879    * @private
880    * @param {string} string The string inspect.
881    * @returns {number} Returns the string size.
882    */
883   var asciiSize = baseProperty('length');
884
885   /**
886    * Converts an ASCII `string` to an array.
887    *
888    * @private
889    * @param {string} string The string to convert.
890    * @returns {Array} Returns the converted array.
891    */
892   function asciiToArray(string) {
893     return string.split('');
894   }
895
896   /**
897    * Splits an ASCII `string` into an array of its words.
898    *
899    * @private
900    * @param {string} The string to inspect.
901    * @returns {Array} Returns the words of `string`.
902    */
903   function asciiWords(string) {
904     return string.match(reAsciiWord) || [];
905   }
906
907   /**
908    * The base implementation of methods like `_.findKey` and `_.findLastKey`,
909    * without support for iteratee shorthands, which iterates over `collection`
910    * using `eachFunc`.
911    *
912    * @private
913    * @param {Array|Object} collection The collection to inspect.
914    * @param {Function} predicate The function invoked per iteration.
915    * @param {Function} eachFunc The function to iterate over `collection`.
916    * @returns {*} Returns the found element or its key, else `undefined`.
917    */
918   function baseFindKey(collection, predicate, eachFunc) {
919     var result;
920     eachFunc(collection, function(value, key, collection) {
921       if (predicate(value, key, collection)) {
922         result = key;
923         return false;
924       }
925     });
926     return result;
927   }
928
929   /**
930    * The base implementation of `_.findIndex` and `_.findLastIndex` without
931    * support for iteratee shorthands.
932    *
933    * @private
934    * @param {Array} array The array to inspect.
935    * @param {Function} predicate The function invoked per iteration.
936    * @param {number} fromIndex The index to search from.
937    * @param {boolean} [fromRight] Specify iterating from right to left.
938    * @returns {number} Returns the index of the matched value, else `-1`.
939    */
940   function baseFindIndex(array, predicate, fromIndex, fromRight) {
941     var length = array.length,
942       index = fromIndex + (fromRight ? 1 : -1);
943
944     while ((fromRight ? index-- : ++index < length)) {
945       if (predicate(array[index], index, array)) {
946         return index;
947       }
948     }
949     return -1;
950   }
951
952   /**
953    * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
954    *
955    * @private
956    * @param {Array} array The array to inspect.
957    * @param {*} value The value to search for.
958    * @param {number} fromIndex The index to search from.
959    * @returns {number} Returns the index of the matched value, else `-1`.
960    */
961   function baseIndexOf(array, value, fromIndex) {
962     return value === value ?
963       strictIndexOf(array, value, fromIndex) :
964       baseFindIndex(array, baseIsNaN, fromIndex);
965   }
966
967   /**
968    * This function is like `baseIndexOf` except that it accepts a comparator.
969    *
970    * @private
971    * @param {Array} array The array to inspect.
972    * @param {*} value The value to search for.
973    * @param {number} fromIndex The index to search from.
974    * @param {Function} comparator The comparator invoked per element.
975    * @returns {number} Returns the index of the matched value, else `-1`.
976    */
977   function baseIndexOfWith(array, value, fromIndex, comparator) {
978     var index = fromIndex - 1,
979       length = array.length;
980
981     while (++index < length) {
982       if (comparator(array[index], value)) {
983         return index;
984       }
985     }
986     return -1;
987   }
988
989   /**
990    * The base implementation of `_.isNaN` without support for number objects.
991    *
992    * @private
993    * @param {*} value The value to check.
994    * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
995    */
996   function baseIsNaN(value) {
997     return value !== value;
998   }
999
1000   /**
1001    * The base implementation of `_.mean` and `_.meanBy` without support for
1002    * iteratee shorthands.
1003    *
1004    * @private
1005    * @param {Array} array The array to iterate over.
1006    * @param {Function} iteratee The function invoked per iteration.
1007    * @returns {number} Returns the mean.
1008    */
1009   function baseMean(array, iteratee) {
1010     var length = array == null ? 0 : array.length;
1011     return length ? (baseSum(array, iteratee) / length) : NAN;
1012   }
1013
1014   /**
1015    * The base implementation of `_.property` without support for deep paths.
1016    *
1017    * @private
1018    * @param {string} key The key of the property to get.
1019    * @returns {Function} Returns the new accessor function.
1020    */
1021   function baseProperty(key) {
1022     return function(object) {
1023       return object == null ? undefined : object[key];
1024     };
1025   }
1026
1027   /**
1028    * The base implementation of `_.propertyOf` without support for deep paths.
1029    *
1030    * @private
1031    * @param {Object} object The object to query.
1032    * @returns {Function} Returns the new accessor function.
1033    */
1034   function basePropertyOf(object) {
1035     return function(key) {
1036       return object == null ? undefined : object[key];
1037     };
1038   }
1039
1040   /**
1041    * The base implementation of `_.reduce` and `_.reduceRight`, without support
1042    * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
1043    *
1044    * @private
1045    * @param {Array|Object} collection The collection to iterate over.
1046    * @param {Function} iteratee The function invoked per iteration.
1047    * @param {*} accumulator The initial value.
1048    * @param {boolean} initAccum Specify using the first or last element of
1049    *  `collection` as the initial value.
1050    * @param {Function} eachFunc The function to iterate over `collection`.
1051    * @returns {*} Returns the accumulated value.
1052    */
1053   function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
1054     eachFunc(collection, function(value, index, collection) {
1055       accumulator = initAccum ?
1056         (initAccum = false, value) :
1057         iteratee(accumulator, value, index, collection);
1058     });
1059     return accumulator;
1060   }
1061
1062   /**
1063    * The base implementation of `_.sortBy` which uses `comparer` to define the
1064    * sort order of `array` and replaces criteria objects with their corresponding
1065    * values.
1066    *
1067    * @private
1068    * @param {Array} array The array to sort.
1069    * @param {Function} comparer The function to define sort order.
1070    * @returns {Array} Returns `array`.
1071    */
1072   function baseSortBy(array, comparer) {
1073     var length = array.length;
1074
1075     array.sort(comparer);
1076     while (length--) {
1077       array[length] = array[length].value;
1078     }
1079     return array;
1080   }
1081
1082   /**
1083    * The base implementation of `_.sum` and `_.sumBy` without support for
1084    * iteratee shorthands.
1085    *
1086    * @private
1087    * @param {Array} array The array to iterate over.
1088    * @param {Function} iteratee The function invoked per iteration.
1089    * @returns {number} Returns the sum.
1090    */
1091   function baseSum(array, iteratee) {
1092     var result,
1093       index = -1,
1094       length = array.length;
1095
1096     while (++index < length) {
1097       var current = iteratee(array[index]);
1098       if (current !== undefined) {
1099         result = result === undefined ? current : (result + current);
1100       }
1101     }
1102     return result;
1103   }
1104
1105   /**
1106    * The base implementation of `_.times` without support for iteratee shorthands
1107    * or max array length checks.
1108    *
1109    * @private
1110    * @param {number} n The number of times to invoke `iteratee`.
1111    * @param {Function} iteratee The function invoked per iteration.
1112    * @returns {Array} Returns the array of results.
1113    */
1114   function baseTimes(n, iteratee) {
1115     var index = -1,
1116       result = Array(n);
1117
1118     while (++index < n) {
1119       result[index] = iteratee(index);
1120     }
1121     return result;
1122   }
1123
1124   /**
1125    * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
1126    * of key-value pairs for `object` corresponding to the property names of `props`.
1127    *
1128    * @private
1129    * @param {Object} object The object to query.
1130    * @param {Array} props The property names to get values for.
1131    * @returns {Object} Returns the key-value pairs.
1132    */
1133   function baseToPairs(object, props) {
1134     return arrayMap(props, function(key) {
1135       return [key, object[key]];
1136     });
1137   }
1138
1139   /**
1140    * The base implementation of `_.unary` without support for storing metadata.
1141    *
1142    * @private
1143    * @param {Function} func The function to cap arguments for.
1144    * @returns {Function} Returns the new capped function.
1145    */
1146   function baseUnary(func) {
1147     return function(value) {
1148       return func(value);
1149     };
1150   }
1151
1152   /**
1153    * The base implementation of `_.values` and `_.valuesIn` which creates an
1154    * array of `object` property values corresponding to the property names
1155    * of `props`.
1156    *
1157    * @private
1158    * @param {Object} object The object to query.
1159    * @param {Array} props The property names to get values for.
1160    * @returns {Object} Returns the array of property values.
1161    */
1162   function baseValues(object, props) {
1163     return arrayMap(props, function(key) {
1164       return object[key];
1165     });
1166   }
1167
1168   /**
1169    * Checks if a `cache` value for `key` exists.
1170    *
1171    * @private
1172    * @param {Object} cache The cache to query.
1173    * @param {string} key The key of the entry to check.
1174    * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1175    */
1176   function cacheHas(cache, key) {
1177     return cache.has(key);
1178   }
1179
1180   /**
1181    * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1182    * that is not found in the character symbols.
1183    *
1184    * @private
1185    * @param {Array} strSymbols The string symbols to inspect.
1186    * @param {Array} chrSymbols The character symbols to find.
1187    * @returns {number} Returns the index of the first unmatched string symbol.
1188    */
1189   function charsStartIndex(strSymbols, chrSymbols) {
1190     var index = -1,
1191       length = strSymbols.length;
1192
1193     while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1194     return index;
1195   }
1196
1197   /**
1198    * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1199    * that is not found in the character symbols.
1200    *
1201    * @private
1202    * @param {Array} strSymbols The string symbols to inspect.
1203    * @param {Array} chrSymbols The character symbols to find.
1204    * @returns {number} Returns the index of the last unmatched string symbol.
1205    */
1206   function charsEndIndex(strSymbols, chrSymbols) {
1207     var index = strSymbols.length;
1208
1209     while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1210     return index;
1211   }
1212
1213   /**
1214    * Gets the number of `placeholder` occurrences in `array`.
1215    *
1216    * @private
1217    * @param {Array} array The array to inspect.
1218    * @param {*} placeholder The placeholder to search for.
1219    * @returns {number} Returns the placeholder count.
1220    */
1221   function countHolders(array, placeholder) {
1222     var length = array.length,
1223       result = 0;
1224
1225     while (length--) {
1226       if (array[length] === placeholder) {
1227         ++result;
1228       }
1229     }
1230     return result;
1231   }
1232
1233   /**
1234    * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1235    * letters to basic Latin letters.
1236    *
1237    * @private
1238    * @param {string} letter The matched letter to deburr.
1239    * @returns {string} Returns the deburred letter.
1240    */
1241   var deburrLetter = basePropertyOf(deburredLetters);
1242
1243   /**
1244    * Used by `_.escape` to convert characters to HTML entities.
1245    *
1246    * @private
1247    * @param {string} chr The matched character to escape.
1248    * @returns {string} Returns the escaped character.
1249    */
1250   var escapeHtmlChar = basePropertyOf(htmlEscapes);
1251
1252   /**
1253    * Used by `_.template` to escape characters for inclusion in compiled string literals.
1254    *
1255    * @private
1256    * @param {string} chr The matched character to escape.
1257    * @returns {string} Returns the escaped character.
1258    */
1259   function escapeStringChar(chr) {
1260     return '\\' + stringEscapes[chr];
1261   }
1262
1263   /**
1264    * Gets the value at `key` of `object`.
1265    *
1266    * @private
1267    * @param {Object} [object] The object to query.
1268    * @param {string} key The key of the property to get.
1269    * @returns {*} Returns the property value.
1270    */
1271   function getValue(object, key) {
1272     return object == null ? undefined : object[key];
1273   }
1274
1275   /**
1276    * Checks if `string` contains Unicode symbols.
1277    *
1278    * @private
1279    * @param {string} string The string to inspect.
1280    * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1281    */
1282   function hasUnicode(string) {
1283     return reHasUnicode.test(string);
1284   }
1285
1286   /**
1287    * Checks if `string` contains a word composed of Unicode symbols.
1288    *
1289    * @private
1290    * @param {string} string The string to inspect.
1291    * @returns {boolean} Returns `true` if a word is found, else `false`.
1292    */
1293   function hasUnicodeWord(string) {
1294     return reHasUnicodeWord.test(string);
1295   }
1296
1297   /**
1298    * Converts `iterator` to an array.
1299    *
1300    * @private
1301    * @param {Object} iterator The iterator to convert.
1302    * @returns {Array} Returns the converted array.
1303    */
1304   function iteratorToArray(iterator) {
1305     var data,
1306       result = [];
1307
1308     while (!(data = iterator.next()).done) {
1309       result.push(data.value);
1310     }
1311     return result;
1312   }
1313
1314   /**
1315    * Converts `map` to its key-value pairs.
1316    *
1317    * @private
1318    * @param {Object} map The map to convert.
1319    * @returns {Array} Returns the key-value pairs.
1320    */
1321   function mapToArray(map) {
1322     var index = -1,
1323       result = Array(map.size);
1324
1325     map.forEach(function(value, key) {
1326       result[++index] = [key, value];
1327     });
1328     return result;
1329   }
1330
1331   /**
1332    * Creates a unary function that invokes `func` with its argument transformed.
1333    *
1334    * @private
1335    * @param {Function} func The function to wrap.
1336    * @param {Function} transform The argument transform.
1337    * @returns {Function} Returns the new function.
1338    */
1339   function overArg(func, transform) {
1340     return function(arg) {
1341       return func(transform(arg));
1342     };
1343   }
1344
1345   /**
1346    * Replaces all `placeholder` elements in `array` with an internal placeholder
1347    * and returns an array of their indexes.
1348    *
1349    * @private
1350    * @param {Array} array The array to modify.
1351    * @param {*} placeholder The placeholder to replace.
1352    * @returns {Array} Returns the new array of placeholder indexes.
1353    */
1354   function replaceHolders(array, placeholder) {
1355     var index = -1,
1356       length = array.length,
1357       resIndex = 0,
1358       result = [];
1359
1360     while (++index < length) {
1361       var value = array[index];
1362       if (value === placeholder || value === PLACEHOLDER) {
1363         array[index] = PLACEHOLDER;
1364         result[resIndex++] = index;
1365       }
1366     }
1367     return result;
1368   }
1369
1370   /**
1371    * Converts `set` to an array of its values.
1372    *
1373    * @private
1374    * @param {Object} set The set to convert.
1375    * @returns {Array} Returns the values.
1376    */
1377   function setToArray(set) {
1378     var index = -1,
1379       result = Array(set.size);
1380
1381     set.forEach(function(value) {
1382       result[++index] = value;
1383     });
1384     return result;
1385   }
1386
1387   /**
1388    * Converts `set` to its value-value pairs.
1389    *
1390    * @private
1391    * @param {Object} set The set to convert.
1392    * @returns {Array} Returns the value-value pairs.
1393    */
1394   function setToPairs(set) {
1395     var index = -1,
1396       result = Array(set.size);
1397
1398     set.forEach(function(value) {
1399       result[++index] = [value, value];
1400     });
1401     return result;
1402   }
1403
1404   /**
1405    * A specialized version of `_.indexOf` which performs strict equality
1406    * comparisons of values, i.e. `===`.
1407    *
1408    * @private
1409    * @param {Array} array The array to inspect.
1410    * @param {*} value The value to search for.
1411    * @param {number} fromIndex The index to search from.
1412    * @returns {number} Returns the index of the matched value, else `-1`.
1413    */
1414   function strictIndexOf(array, value, fromIndex) {
1415     var index = fromIndex - 1,
1416       length = array.length;
1417
1418     while (++index < length) {
1419       if (array[index] === value) {
1420         return index;
1421       }
1422     }
1423     return -1;
1424   }
1425
1426   /**
1427    * A specialized version of `_.lastIndexOf` which performs strict equality
1428    * comparisons of values, i.e. `===`.
1429    *
1430    * @private
1431    * @param {Array} array The array to inspect.
1432    * @param {*} value The value to search for.
1433    * @param {number} fromIndex The index to search from.
1434    * @returns {number} Returns the index of the matched value, else `-1`.
1435    */
1436   function strictLastIndexOf(array, value, fromIndex) {
1437     var index = fromIndex + 1;
1438     while (index--) {
1439       if (array[index] === value) {
1440         return index;
1441       }
1442     }
1443     return index;
1444   }
1445
1446   /**
1447    * Gets the number of symbols in `string`.
1448    *
1449    * @private
1450    * @param {string} string The string to inspect.
1451    * @returns {number} Returns the string size.
1452    */
1453   function stringSize(string) {
1454     return hasUnicode(string) ?
1455       unicodeSize(string) :
1456       asciiSize(string);
1457   }
1458
1459   /**
1460    * Converts `string` to an array.
1461    *
1462    * @private
1463    * @param {string} string The string to convert.
1464    * @returns {Array} Returns the converted array.
1465    */
1466   function stringToArray(string) {
1467     return hasUnicode(string) ?
1468       unicodeToArray(string) :
1469       asciiToArray(string);
1470   }
1471
1472   /**
1473    * Used by `_.unescape` to convert HTML entities to characters.
1474    *
1475    * @private
1476    * @param {string} chr The matched character to unescape.
1477    * @returns {string} Returns the unescaped character.
1478    */
1479   var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1480
1481   /**
1482    * Gets the size of a Unicode `string`.
1483    *
1484    * @private
1485    * @param {string} string The string inspect.
1486    * @returns {number} Returns the string size.
1487    */
1488   function unicodeSize(string) {
1489     var result = reUnicode.lastIndex = 0;
1490     while (reUnicode.test(string)) {
1491       ++result;
1492     }
1493     return result;
1494   }
1495
1496   /**
1497    * Converts a Unicode `string` to an array.
1498    *
1499    * @private
1500    * @param {string} string The string to convert.
1501    * @returns {Array} Returns the converted array.
1502    */
1503   function unicodeToArray(string) {
1504     return string.match(reUnicode) || [];
1505   }
1506
1507   /**
1508    * Splits a Unicode `string` into an array of its words.
1509    *
1510    * @private
1511    * @param {string} The string to inspect.
1512    * @returns {Array} Returns the words of `string`.
1513    */
1514   function unicodeWords(string) {
1515     return string.match(reUnicodeWord) || [];
1516   }
1517
1518   /*--------------------------------------------------------------------------*/
1519
1520   /**
1521    * Create a new pristine `lodash` function using the `context` object.
1522    *
1523    * @static
1524    * @memberOf _
1525    * @since 1.1.0
1526    * @category Util
1527    * @param {Object} [context=root] The context object.
1528    * @returns {Function} Returns a new `lodash` function.
1529    * @example
1530    *
1531    * _.mixin({ 'foo': _.constant('foo') });
1532    *
1533    * var lodash = _.runInContext();
1534    * lodash.mixin({ 'bar': lodash.constant('bar') });
1535    *
1536    * _.isFunction(_.foo);
1537    * // => true
1538    * _.isFunction(_.bar);
1539    * // => false
1540    *
1541    * lodash.isFunction(lodash.foo);
1542    * // => false
1543    * lodash.isFunction(lodash.bar);
1544    * // => true
1545    *
1546    * // Create a suped-up `defer` in Node.js.
1547    * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1548    */
1549   var runInContext = (function runInContext(context) {
1550     context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1551
1552     /** Built-in constructor references. */
1553     var Array = context.Array,
1554       Date = context.Date,
1555       Error = context.Error,
1556       Function = context.Function,
1557       Math = context.Math,
1558       Object = context.Object,
1559       RegExp = context.RegExp,
1560       String = context.String,
1561       TypeError = context.TypeError;
1562
1563     /** Used for built-in method references. */
1564     var arrayProto = Array.prototype,
1565       funcProto = Function.prototype,
1566       objectProto = Object.prototype;
1567
1568     /** Used to detect overreaching core-js shims. */
1569     var coreJsData = context['__core-js_shared__'];
1570
1571     /** Used to resolve the decompiled source of functions. */
1572     var funcToString = funcProto.toString;
1573
1574     /** Used to check objects for own properties. */
1575     var hasOwnProperty = objectProto.hasOwnProperty;
1576
1577     /** Used to generate unique IDs. */
1578     var idCounter = 0;
1579
1580     /** Used to detect methods masquerading as native. */
1581     var maskSrcKey = (function() {
1582       var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1583       return uid ? ('Symbol(src)_1.' + uid) : '';
1584     }());
1585
1586     /**
1587      * Used to resolve the
1588      * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1589      * of values.
1590      */
1591     var nativeObjectToString = objectProto.toString;
1592
1593     /** Used to infer the `Object` constructor. */
1594     var objectCtorString = funcToString.call(Object);
1595
1596     /** Used to restore the original `_` reference in `_.noConflict`. */
1597     var oldDash = root._;
1598
1599     /** Used to detect if a method is native. */
1600     var reIsNative = RegExp('^' +
1601       funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1602       .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1603     );
1604
1605     /** Built-in value references. */
1606     var Buffer = moduleExports ? context.Buffer : undefined,
1607       Symbol = context.Symbol,
1608       Uint8Array = context.Uint8Array,
1609       allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
1610       getPrototype = overArg(Object.getPrototypeOf, Object),
1611       objectCreate = Object.create,
1612       propertyIsEnumerable = objectProto.propertyIsEnumerable,
1613       splice = arrayProto.splice,
1614       spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
1615       symIterator = Symbol ? Symbol.iterator : undefined,
1616       symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1617
1618     var defineProperty = (function() {
1619       try {
1620         var func = getNative(Object, 'defineProperty');
1621         func({}, '', {});
1622         return func;
1623       } catch (e) {}
1624     }());
1625
1626     /** Mocked built-ins. */
1627     var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
1628       ctxNow = Date && Date.now !== root.Date.now && Date.now,
1629       ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1630
1631     /* Built-in method references for those with the same name as other `lodash` methods. */
1632     var nativeCeil = Math.ceil,
1633       nativeFloor = Math.floor,
1634       nativeGetSymbols = Object.getOwnPropertySymbols,
1635       nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
1636       nativeIsFinite = context.isFinite,
1637       nativeJoin = arrayProto.join,
1638       nativeKeys = overArg(Object.keys, Object),
1639       nativeMax = Math.max,
1640       nativeMin = Math.min,
1641       nativeNow = Date.now,
1642       nativeParseInt = context.parseInt,
1643       nativeRandom = Math.random,
1644       nativeReverse = arrayProto.reverse;
1645
1646     /* Built-in method references that are verified to be native. */
1647     var DataView = getNative(context, 'DataView'),
1648       Map = getNative(context, 'Map'),
1649       Promise = getNative(context, 'Promise'),
1650       Set = getNative(context, 'Set'),
1651       WeakMap = getNative(context, 'WeakMap'),
1652       nativeCreate = getNative(Object, 'create');
1653
1654     /** Used to store function metadata. */
1655     var metaMap = WeakMap && new WeakMap;
1656
1657     /** Used to lookup unminified function names. */
1658     var realNames = {};
1659
1660     /** Used to detect maps, sets, and weakmaps. */
1661     var dataViewCtorString = toSource(DataView),
1662       mapCtorString = toSource(Map),
1663       promiseCtorString = toSource(Promise),
1664       setCtorString = toSource(Set),
1665       weakMapCtorString = toSource(WeakMap);
1666
1667     /** Used to convert symbols to primitives and strings. */
1668     var symbolProto = Symbol ? Symbol.prototype : undefined,
1669       symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
1670       symbolToString = symbolProto ? symbolProto.toString : undefined;
1671
1672     /*------------------------------------------------------------------------*/
1673
1674     /**
1675      * Creates a `lodash` object which wraps `value` to enable implicit method
1676      * chain sequences. Methods that operate on and return arrays, collections,
1677      * and functions can be chained together. Methods that retrieve a single value
1678      * or may return a primitive value will automatically end the chain sequence
1679      * and return the unwrapped value. Otherwise, the value must be unwrapped
1680      * with `_#value`.
1681      *
1682      * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1683      * enabled using `_.chain`.
1684      *
1685      * The execution of chained methods is lazy, that is, it's deferred until
1686      * `_#value` is implicitly or explicitly called.
1687      *
1688      * Lazy evaluation allows several methods to support shortcut fusion.
1689      * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1690      * the creation of intermediate arrays and can greatly reduce the number of
1691      * iteratee executions. Sections of a chain sequence qualify for shortcut
1692      * fusion if the section is applied to an array and iteratees accept only
1693      * one argument. The heuristic for whether a section qualifies for shortcut
1694      * fusion is subject to change.
1695      *
1696      * Chaining is supported in custom builds as long as the `_#value` method is
1697      * directly or indirectly included in the build.
1698      *
1699      * In addition to lodash methods, wrappers have `Array` and `String` methods.
1700      *
1701      * The wrapper `Array` methods are:
1702      * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1703      *
1704      * The wrapper `String` methods are:
1705      * `replace` and `split`
1706      *
1707      * The wrapper methods that support shortcut fusion are:
1708      * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1709      * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1710      * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1711      *
1712      * The chainable wrapper methods are:
1713      * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1714      * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1715      * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1716      * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1717      * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1718      * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1719      * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1720      * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1721      * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1722      * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1723      * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1724      * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1725      * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1726      * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1727      * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1728      * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1729      * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1730      * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1731      * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1732      * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1733      * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1734      * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1735      * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1736      * `zipObject`, `zipObjectDeep`, and `zipWith`
1737      *
1738      * The wrapper methods that are **not** chainable by default are:
1739      * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1740      * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
1741      * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
1742      * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
1743      * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
1744      * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
1745      * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
1746      * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
1747      * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
1748      * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
1749      * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
1750      * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
1751      * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
1752      * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
1753      * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
1754      * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
1755      * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
1756      * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
1757      * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
1758      * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
1759      * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
1760      * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
1761      * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
1762      * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
1763      * `upperFirst`, `value`, and `words`
1764      *
1765      * @name _
1766      * @constructor
1767      * @category Seq
1768      * @param {*} value The value to wrap in a `lodash` instance.
1769      * @returns {Object} Returns the new `lodash` wrapper instance.
1770      * @example
1771      *
1772      * function square(n) {
1773      *   return n * n;
1774      * }
1775      *
1776      * var wrapped = _([1, 2, 3]);
1777      *
1778      * // Returns an unwrapped value.
1779      * wrapped.reduce(_.add);
1780      * // => 6
1781      *
1782      * // Returns a wrapped value.
1783      * var squares = wrapped.map(square);
1784      *
1785      * _.isArray(squares);
1786      * // => false
1787      *
1788      * _.isArray(squares.value());
1789      * // => true
1790      */
1791     function lodash(value) {
1792       if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1793         if (value instanceof LodashWrapper) {
1794           return value;
1795         }
1796         if (hasOwnProperty.call(value, '__wrapped__')) {
1797           return wrapperClone(value);
1798         }
1799       }
1800       return new LodashWrapper(value);
1801     }
1802
1803     /**
1804      * The base implementation of `_.create` without support for assigning
1805      * properties to the created object.
1806      *
1807      * @private
1808      * @param {Object} proto The object to inherit from.
1809      * @returns {Object} Returns the new object.
1810      */
1811     var baseCreate = (function() {
1812       function object() {}
1813       return function(proto) {
1814         if (!isObject(proto)) {
1815           return {};
1816         }
1817         if (objectCreate) {
1818           return objectCreate(proto);
1819         }
1820         object.prototype = proto;
1821         var result = new object;
1822         object.prototype = undefined;
1823         return result;
1824       };
1825     }());
1826
1827     /**
1828      * The function whose prototype chain sequence wrappers inherit from.
1829      *
1830      * @private
1831      */
1832     function baseLodash() {
1833       // No operation performed.
1834     }
1835
1836     /**
1837      * The base constructor for creating `lodash` wrapper objects.
1838      *
1839      * @private
1840      * @param {*} value The value to wrap.
1841      * @param {boolean} [chainAll] Enable explicit method chain sequences.
1842      */
1843     function LodashWrapper(value, chainAll) {
1844       this.__wrapped__ = value;
1845       this.__actions__ = [];
1846       this.__chain__ = !!chainAll;
1847       this.__index__ = 0;
1848       this.__values__ = undefined;
1849     }
1850
1851     /**
1852      * By default, the template delimiters used by lodash are like those in
1853      * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1854      * following template settings to use alternative delimiters.
1855      *
1856      * @static
1857      * @memberOf _
1858      * @type {Object}
1859      */
1860     lodash.templateSettings = {
1861
1862       /**
1863        * Used to detect `data` property values to be HTML-escaped.
1864        *
1865        * @memberOf _.templateSettings
1866        * @type {RegExp}
1867        */
1868       'escape': reEscape,
1869
1870       /**
1871        * Used to detect code to be evaluated.
1872        *
1873        * @memberOf _.templateSettings
1874        * @type {RegExp}
1875        */
1876       'evaluate': reEvaluate,
1877
1878       /**
1879        * Used to detect `data` property values to inject.
1880        *
1881        * @memberOf _.templateSettings
1882        * @type {RegExp}
1883        */
1884       'interpolate': reInterpolate,
1885
1886       /**
1887        * Used to reference the data object in the template text.
1888        *
1889        * @memberOf _.templateSettings
1890        * @type {string}
1891        */
1892       'variable': '',
1893
1894       /**
1895        * Used to import variables into the compiled template.
1896        *
1897        * @memberOf _.templateSettings
1898        * @type {Object}
1899        */
1900       'imports': {
1901
1902         /**
1903          * A reference to the `lodash` function.
1904          *
1905          * @memberOf _.templateSettings.imports
1906          * @type {Function}
1907          */
1908         '_': lodash
1909       }
1910     };
1911
1912     // Ensure wrappers are instances of `baseLodash`.
1913     lodash.prototype = baseLodash.prototype;
1914     lodash.prototype.constructor = lodash;
1915
1916     LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1917     LodashWrapper.prototype.constructor = LodashWrapper;
1918
1919     /*------------------------------------------------------------------------*/
1920
1921     /**
1922      * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1923      *
1924      * @private
1925      * @constructor
1926      * @param {*} value The value to wrap.
1927      */
1928     function LazyWrapper(value) {
1929       this.__wrapped__ = value;
1930       this.__actions__ = [];
1931       this.__dir__ = 1;
1932       this.__filtered__ = false;
1933       this.__iteratees__ = [];
1934       this.__takeCount__ = MAX_ARRAY_LENGTH;
1935       this.__views__ = [];
1936     }
1937
1938     /**
1939      * Creates a clone of the lazy wrapper object.
1940      *
1941      * @private
1942      * @name clone
1943      * @memberOf LazyWrapper
1944      * @returns {Object} Returns the cloned `LazyWrapper` object.
1945      */
1946     function lazyClone() {
1947       var result = new LazyWrapper(this.__wrapped__);
1948       result.__actions__ = copyArray(this.__actions__);
1949       result.__dir__ = this.__dir__;
1950       result.__filtered__ = this.__filtered__;
1951       result.__iteratees__ = copyArray(this.__iteratees__);
1952       result.__takeCount__ = this.__takeCount__;
1953       result.__views__ = copyArray(this.__views__);
1954       return result;
1955     }
1956
1957     /**
1958      * Reverses the direction of lazy iteration.
1959      *
1960      * @private
1961      * @name reverse
1962      * @memberOf LazyWrapper
1963      * @returns {Object} Returns the new reversed `LazyWrapper` object.
1964      */
1965     function lazyReverse() {
1966       if (this.__filtered__) {
1967         var result = new LazyWrapper(this);
1968         result.__dir__ = -1;
1969         result.__filtered__ = true;
1970       } else {
1971         result = this.clone();
1972         result.__dir__ *= -1;
1973       }
1974       return result;
1975     }
1976
1977     /**
1978      * Extracts the unwrapped value from its lazy wrapper.
1979      *
1980      * @private
1981      * @name value
1982      * @memberOf LazyWrapper
1983      * @returns {*} Returns the unwrapped value.
1984      */
1985     function lazyValue() {
1986       var array = this.__wrapped__.value(),
1987         dir = this.__dir__,
1988         isArr = isArray(array),
1989         isRight = dir < 0,
1990         arrLength = isArr ? array.length : 0,
1991         view = getView(0, arrLength, this.__views__),
1992         start = view.start,
1993         end = view.end,
1994         length = end - start,
1995         index = isRight ? end : (start - 1),
1996         iteratees = this.__iteratees__,
1997         iterLength = iteratees.length,
1998         resIndex = 0,
1999         takeCount = nativeMin(length, this.__takeCount__);
2000
2001       if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
2002         return baseWrapperValue(array, this.__actions__);
2003       }
2004       var result = [];
2005
2006       outer:
2007         while (length-- && resIndex < takeCount) {
2008           index += dir;
2009
2010           var iterIndex = -1,
2011             value = array[index];
2012
2013           while (++iterIndex < iterLength) {
2014             var data = iteratees[iterIndex],
2015               iteratee = data.iteratee,
2016               type = data.type,
2017               computed = iteratee(value);
2018
2019             if (type == LAZY_MAP_FLAG) {
2020               value = computed;
2021             } else if (!computed) {
2022               if (type == LAZY_FILTER_FLAG) {
2023                 continue outer;
2024               } else {
2025                 break outer;
2026               }
2027             }
2028           }
2029           result[resIndex++] = value;
2030         }
2031       return result;
2032     }
2033
2034     // Ensure `LazyWrapper` is an instance of `baseLodash`.
2035     LazyWrapper.prototype = baseCreate(baseLodash.prototype);
2036     LazyWrapper.prototype.constructor = LazyWrapper;
2037
2038     /*------------------------------------------------------------------------*/
2039
2040     /**
2041      * Creates a hash object.
2042      *
2043      * @private
2044      * @constructor
2045      * @param {Array} [entries] The key-value pairs to cache.
2046      */
2047     function Hash(entries) {
2048       var index = -1,
2049         length = entries == null ? 0 : entries.length;
2050
2051       this.clear();
2052       while (++index < length) {
2053         var entry = entries[index];
2054         this.set(entry[0], entry[1]);
2055       }
2056     }
2057
2058     /**
2059      * Removes all key-value entries from the hash.
2060      *
2061      * @private
2062      * @name clear
2063      * @memberOf Hash
2064      */
2065     function hashClear() {
2066       this.__data__ = nativeCreate ? nativeCreate(null) : {};
2067       this.size = 0;
2068     }
2069
2070     /**
2071      * Removes `key` and its value from the hash.
2072      *
2073      * @private
2074      * @name delete
2075      * @memberOf Hash
2076      * @param {Object} hash The hash to modify.
2077      * @param {string} key The key of the value to remove.
2078      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2079      */
2080     function hashDelete(key) {
2081       var result = this.has(key) && delete this.__data__[key];
2082       this.size -= result ? 1 : 0;
2083       return result;
2084     }
2085
2086     /**
2087      * Gets the hash value for `key`.
2088      *
2089      * @private
2090      * @name get
2091      * @memberOf Hash
2092      * @param {string} key The key of the value to get.
2093      * @returns {*} Returns the entry value.
2094      */
2095     function hashGet(key) {
2096       var data = this.__data__;
2097       if (nativeCreate) {
2098         var result = data[key];
2099         return result === HASH_UNDEFINED ? undefined : result;
2100       }
2101       return hasOwnProperty.call(data, key) ? data[key] : undefined;
2102     }
2103
2104     /**
2105      * Checks if a hash value for `key` exists.
2106      *
2107      * @private
2108      * @name has
2109      * @memberOf Hash
2110      * @param {string} key The key of the entry to check.
2111      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2112      */
2113     function hashHas(key) {
2114       var data = this.__data__;
2115       return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
2116     }
2117
2118     /**
2119      * Sets the hash `key` to `value`.
2120      *
2121      * @private
2122      * @name set
2123      * @memberOf Hash
2124      * @param {string} key The key of the value to set.
2125      * @param {*} value The value to set.
2126      * @returns {Object} Returns the hash instance.
2127      */
2128     function hashSet(key, value) {
2129       var data = this.__data__;
2130       this.size += this.has(key) ? 0 : 1;
2131       data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
2132       return this;
2133     }
2134
2135     // Add methods to `Hash`.
2136     Hash.prototype.clear = hashClear;
2137     Hash.prototype['delete'] = hashDelete;
2138     Hash.prototype.get = hashGet;
2139     Hash.prototype.has = hashHas;
2140     Hash.prototype.set = hashSet;
2141
2142     /*------------------------------------------------------------------------*/
2143
2144     /**
2145      * Creates an list cache object.
2146      *
2147      * @private
2148      * @constructor
2149      * @param {Array} [entries] The key-value pairs to cache.
2150      */
2151     function ListCache(entries) {
2152       var index = -1,
2153         length = entries == null ? 0 : entries.length;
2154
2155       this.clear();
2156       while (++index < length) {
2157         var entry = entries[index];
2158         this.set(entry[0], entry[1]);
2159       }
2160     }
2161
2162     /**
2163      * Removes all key-value entries from the list cache.
2164      *
2165      * @private
2166      * @name clear
2167      * @memberOf ListCache
2168      */
2169     function listCacheClear() {
2170       this.__data__ = [];
2171       this.size = 0;
2172     }
2173
2174     /**
2175      * Removes `key` and its value from the list cache.
2176      *
2177      * @private
2178      * @name delete
2179      * @memberOf ListCache
2180      * @param {string} key The key of the value to remove.
2181      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2182      */
2183     function listCacheDelete(key) {
2184       var data = this.__data__,
2185         index = assocIndexOf(data, key);
2186
2187       if (index < 0) {
2188         return false;
2189       }
2190       var lastIndex = data.length - 1;
2191       if (index == lastIndex) {
2192         data.pop();
2193       } else {
2194         splice.call(data, index, 1);
2195       }
2196       --this.size;
2197       return true;
2198     }
2199
2200     /**
2201      * Gets the list cache value for `key`.
2202      *
2203      * @private
2204      * @name get
2205      * @memberOf ListCache
2206      * @param {string} key The key of the value to get.
2207      * @returns {*} Returns the entry value.
2208      */
2209     function listCacheGet(key) {
2210       var data = this.__data__,
2211         index = assocIndexOf(data, key);
2212
2213       return index < 0 ? undefined : data[index][1];
2214     }
2215
2216     /**
2217      * Checks if a list cache value for `key` exists.
2218      *
2219      * @private
2220      * @name has
2221      * @memberOf ListCache
2222      * @param {string} key The key of the entry to check.
2223      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2224      */
2225     function listCacheHas(key) {
2226       return assocIndexOf(this.__data__, key) > -1;
2227     }
2228
2229     /**
2230      * Sets the list cache `key` to `value`.
2231      *
2232      * @private
2233      * @name set
2234      * @memberOf ListCache
2235      * @param {string} key The key of the value to set.
2236      * @param {*} value The value to set.
2237      * @returns {Object} Returns the list cache instance.
2238      */
2239     function listCacheSet(key, value) {
2240       var data = this.__data__,
2241         index = assocIndexOf(data, key);
2242
2243       if (index < 0) {
2244         ++this.size;
2245         data.push([key, value]);
2246       } else {
2247         data[index][1] = value;
2248       }
2249       return this;
2250     }
2251
2252     // Add methods to `ListCache`.
2253     ListCache.prototype.clear = listCacheClear;
2254     ListCache.prototype['delete'] = listCacheDelete;
2255     ListCache.prototype.get = listCacheGet;
2256     ListCache.prototype.has = listCacheHas;
2257     ListCache.prototype.set = listCacheSet;
2258
2259     /*------------------------------------------------------------------------*/
2260
2261     /**
2262      * Creates a map cache object to store key-value pairs.
2263      *
2264      * @private
2265      * @constructor
2266      * @param {Array} [entries] The key-value pairs to cache.
2267      */
2268     function MapCache(entries) {
2269       var index = -1,
2270         length = entries == null ? 0 : entries.length;
2271
2272       this.clear();
2273       while (++index < length) {
2274         var entry = entries[index];
2275         this.set(entry[0], entry[1]);
2276       }
2277     }
2278
2279     /**
2280      * Removes all key-value entries from the map.
2281      *
2282      * @private
2283      * @name clear
2284      * @memberOf MapCache
2285      */
2286     function mapCacheClear() {
2287       this.size = 0;
2288       this.__data__ = {
2289         'hash': new Hash,
2290         'map': new(Map || ListCache),
2291         'string': new Hash
2292       };
2293     }
2294
2295     /**
2296      * Removes `key` and its value from the map.
2297      *
2298      * @private
2299      * @name delete
2300      * @memberOf MapCache
2301      * @param {string} key The key of the value to remove.
2302      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2303      */
2304     function mapCacheDelete(key) {
2305       var result = getMapData(this, key)['delete'](key);
2306       this.size -= result ? 1 : 0;
2307       return result;
2308     }
2309
2310     /**
2311      * Gets the map value for `key`.
2312      *
2313      * @private
2314      * @name get
2315      * @memberOf MapCache
2316      * @param {string} key The key of the value to get.
2317      * @returns {*} Returns the entry value.
2318      */
2319     function mapCacheGet(key) {
2320       return getMapData(this, key).get(key);
2321     }
2322
2323     /**
2324      * Checks if a map value for `key` exists.
2325      *
2326      * @private
2327      * @name has
2328      * @memberOf MapCache
2329      * @param {string} key The key of the entry to check.
2330      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2331      */
2332     function mapCacheHas(key) {
2333       return getMapData(this, key).has(key);
2334     }
2335
2336     /**
2337      * Sets the map `key` to `value`.
2338      *
2339      * @private
2340      * @name set
2341      * @memberOf MapCache
2342      * @param {string} key The key of the value to set.
2343      * @param {*} value The value to set.
2344      * @returns {Object} Returns the map cache instance.
2345      */
2346     function mapCacheSet(key, value) {
2347       var data = getMapData(this, key),
2348         size = data.size;
2349
2350       data.set(key, value);
2351       this.size += data.size == size ? 0 : 1;
2352       return this;
2353     }
2354
2355     // Add methods to `MapCache`.
2356     MapCache.prototype.clear = mapCacheClear;
2357     MapCache.prototype['delete'] = mapCacheDelete;
2358     MapCache.prototype.get = mapCacheGet;
2359     MapCache.prototype.has = mapCacheHas;
2360     MapCache.prototype.set = mapCacheSet;
2361
2362     /*------------------------------------------------------------------------*/
2363
2364     /**
2365      *
2366      * Creates an array cache object to store unique values.
2367      *
2368      * @private
2369      * @constructor
2370      * @param {Array} [values] The values to cache.
2371      */
2372     function SetCache(values) {
2373       var index = -1,
2374         length = values == null ? 0 : values.length;
2375
2376       this.__data__ = new MapCache;
2377       while (++index < length) {
2378         this.add(values[index]);
2379       }
2380     }
2381
2382     /**
2383      * Adds `value` to the array cache.
2384      *
2385      * @private
2386      * @name add
2387      * @memberOf SetCache
2388      * @alias push
2389      * @param {*} value The value to cache.
2390      * @returns {Object} Returns the cache instance.
2391      */
2392     function setCacheAdd(value) {
2393       this.__data__.set(value, HASH_UNDEFINED);
2394       return this;
2395     }
2396
2397     /**
2398      * Checks if `value` is in the array cache.
2399      *
2400      * @private
2401      * @name has
2402      * @memberOf SetCache
2403      * @param {*} value The value to search for.
2404      * @returns {number} Returns `true` if `value` is found, else `false`.
2405      */
2406     function setCacheHas(value) {
2407       return this.__data__.has(value);
2408     }
2409
2410     // Add methods to `SetCache`.
2411     SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2412     SetCache.prototype.has = setCacheHas;
2413
2414     /*------------------------------------------------------------------------*/
2415
2416     /**
2417      * Creates a stack cache object to store key-value pairs.
2418      *
2419      * @private
2420      * @constructor
2421      * @param {Array} [entries] The key-value pairs to cache.
2422      */
2423     function Stack(entries) {
2424       var data = this.__data__ = new ListCache(entries);
2425       this.size = data.size;
2426     }
2427
2428     /**
2429      * Removes all key-value entries from the stack.
2430      *
2431      * @private
2432      * @name clear
2433      * @memberOf Stack
2434      */
2435     function stackClear() {
2436       this.__data__ = new ListCache;
2437       this.size = 0;
2438     }
2439
2440     /**
2441      * Removes `key` and its value from the stack.
2442      *
2443      * @private
2444      * @name delete
2445      * @memberOf Stack
2446      * @param {string} key The key of the value to remove.
2447      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2448      */
2449     function stackDelete(key) {
2450       var data = this.__data__,
2451         result = data['delete'](key);
2452
2453       this.size = data.size;
2454       return result;
2455     }
2456
2457     /**
2458      * Gets the stack value for `key`.
2459      *
2460      * @private
2461      * @name get
2462      * @memberOf Stack
2463      * @param {string} key The key of the value to get.
2464      * @returns {*} Returns the entry value.
2465      */
2466     function stackGet(key) {
2467       return this.__data__.get(key);
2468     }
2469
2470     /**
2471      * Checks if a stack value for `key` exists.
2472      *
2473      * @private
2474      * @name has
2475      * @memberOf Stack
2476      * @param {string} key The key of the entry to check.
2477      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2478      */
2479     function stackHas(key) {
2480       return this.__data__.has(key);
2481     }
2482
2483     /**
2484      * Sets the stack `key` to `value`.
2485      *
2486      * @private
2487      * @name set
2488      * @memberOf Stack
2489      * @param {string} key The key of the value to set.
2490      * @param {*} value The value to set.
2491      * @returns {Object} Returns the stack cache instance.
2492      */
2493     function stackSet(key, value) {
2494       var data = this.__data__;
2495       if (data instanceof ListCache) {
2496         var pairs = data.__data__;
2497         if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2498           pairs.push([key, value]);
2499           this.size = ++data.size;
2500           return this;
2501         }
2502         data = this.__data__ = new MapCache(pairs);
2503       }
2504       data.set(key, value);
2505       this.size = data.size;
2506       return this;
2507     }
2508
2509     // Add methods to `Stack`.
2510     Stack.prototype.clear = stackClear;
2511     Stack.prototype['delete'] = stackDelete;
2512     Stack.prototype.get = stackGet;
2513     Stack.prototype.has = stackHas;
2514     Stack.prototype.set = stackSet;
2515
2516     /*------------------------------------------------------------------------*/
2517
2518     /**
2519      * Creates an array of the enumerable property names of the array-like `value`.
2520      *
2521      * @private
2522      * @param {*} value The value to query.
2523      * @param {boolean} inherited Specify returning inherited property names.
2524      * @returns {Array} Returns the array of property names.
2525      */
2526     function arrayLikeKeys(value, inherited) {
2527       var isArr = isArray(value),
2528         isArg = !isArr && isArguments(value),
2529         isBuff = !isArr && !isArg && isBuffer(value),
2530         isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2531         skipIndexes = isArr || isArg || isBuff || isType,
2532         result = skipIndexes ? baseTimes(value.length, String) : [],
2533         length = result.length;
2534
2535       for (var key in value) {
2536         if ((inherited || hasOwnProperty.call(value, key)) &&
2537           !(skipIndexes && (
2538             // Safari 9 has enumerable `arguments.length` in strict mode.
2539             key == 'length' ||
2540             // Node.js 0.10 has enumerable non-index properties on buffers.
2541             (isBuff && (key == 'offset' || key == 'parent')) ||
2542             // PhantomJS 2 has enumerable non-index properties on typed arrays.
2543             (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2544             // Skip index properties.
2545             isIndex(key, length)
2546           ))) {
2547           result.push(key);
2548         }
2549       }
2550       return result;
2551     }
2552
2553     /**
2554      * A specialized version of `_.sample` for arrays.
2555      *
2556      * @private
2557      * @param {Array} array The array to sample.
2558      * @returns {*} Returns the random element.
2559      */
2560     function arraySample(array) {
2561       var length = array.length;
2562       return length ? array[baseRandom(0, length - 1)] : undefined;
2563     }
2564
2565     /**
2566      * A specialized version of `_.sampleSize` for arrays.
2567      *
2568      * @private
2569      * @param {Array} array The array to sample.
2570      * @param {number} n The number of elements to sample.
2571      * @returns {Array} Returns the random elements.
2572      */
2573     function arraySampleSize(array, n) {
2574       return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2575     }
2576
2577     /**
2578      * A specialized version of `_.shuffle` for arrays.
2579      *
2580      * @private
2581      * @param {Array} array The array to shuffle.
2582      * @returns {Array} Returns the new shuffled array.
2583      */
2584     function arrayShuffle(array) {
2585       return shuffleSelf(copyArray(array));
2586     }
2587
2588     /**
2589      * This function is like `assignValue` except that it doesn't assign
2590      * `undefined` values.
2591      *
2592      * @private
2593      * @param {Object} object The object to modify.
2594      * @param {string} key The key of the property to assign.
2595      * @param {*} value The value to assign.
2596      */
2597     function assignMergeValue(object, key, value) {
2598       if ((value !== undefined && !eq(object[key], value)) ||
2599         (value === undefined && !(key in object))) {
2600         baseAssignValue(object, key, value);
2601       }
2602     }
2603
2604     /**
2605      * Assigns `value` to `key` of `object` if the existing value is not equivalent
2606      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2607      * for equality comparisons.
2608      *
2609      * @private
2610      * @param {Object} object The object to modify.
2611      * @param {string} key The key of the property to assign.
2612      * @param {*} value The value to assign.
2613      */
2614     function assignValue(object, key, value) {
2615       var objValue = object[key];
2616       if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2617         (value === undefined && !(key in object))) {
2618         baseAssignValue(object, key, value);
2619       }
2620     }
2621
2622     /**
2623      * Gets the index at which the `key` is found in `array` of key-value pairs.
2624      *
2625      * @private
2626      * @param {Array} array The array to inspect.
2627      * @param {*} key The key to search for.
2628      * @returns {number} Returns the index of the matched value, else `-1`.
2629      */
2630     function assocIndexOf(array, key) {
2631       var length = array.length;
2632       while (length--) {
2633         if (eq(array[length][0], key)) {
2634           return length;
2635         }
2636       }
2637       return -1;
2638     }
2639
2640     /**
2641      * Aggregates elements of `collection` on `accumulator` with keys transformed
2642      * by `iteratee` and values set by `setter`.
2643      *
2644      * @private
2645      * @param {Array|Object} collection The collection to iterate over.
2646      * @param {Function} setter The function to set `accumulator` values.
2647      * @param {Function} iteratee The iteratee to transform keys.
2648      * @param {Object} accumulator The initial aggregated object.
2649      * @returns {Function} Returns `accumulator`.
2650      */
2651     function baseAggregator(collection, setter, iteratee, accumulator) {
2652       baseEach(collection, function(value, key, collection) {
2653         setter(accumulator, value, iteratee(value), collection);
2654       });
2655       return accumulator;
2656     }
2657
2658     /**
2659      * The base implementation of `_.assign` without support for multiple sources
2660      * or `customizer` functions.
2661      *
2662      * @private
2663      * @param {Object} object The destination object.
2664      * @param {Object} source The source object.
2665      * @returns {Object} Returns `object`.
2666      */
2667     function baseAssign(object, source) {
2668       return object && copyObject(source, keys(source), object);
2669     }
2670
2671     /**
2672      * The base implementation of `_.assignIn` without support for multiple sources
2673      * or `customizer` functions.
2674      *
2675      * @private
2676      * @param {Object} object The destination object.
2677      * @param {Object} source The source object.
2678      * @returns {Object} Returns `object`.
2679      */
2680     function baseAssignIn(object, source) {
2681       return object && copyObject(source, keysIn(source), object);
2682     }
2683
2684     /**
2685      * The base implementation of `assignValue` and `assignMergeValue` without
2686      * value checks.
2687      *
2688      * @private
2689      * @param {Object} object The object to modify.
2690      * @param {string} key The key of the property to assign.
2691      * @param {*} value The value to assign.
2692      */
2693     function baseAssignValue(object, key, value) {
2694       if (key == '__proto__' && defineProperty) {
2695         defineProperty(object, key, {
2696           'configurable': true,
2697           'enumerable': true,
2698           'value': value,
2699           'writable': true
2700         });
2701       } else {
2702         object[key] = value;
2703       }
2704     }
2705
2706     /**
2707      * The base implementation of `_.at` without support for individual paths.
2708      *
2709      * @private
2710      * @param {Object} object The object to iterate over.
2711      * @param {string[]} paths The property paths to pick.
2712      * @returns {Array} Returns the picked elements.
2713      */
2714     function baseAt(object, paths) {
2715       var index = -1,
2716         length = paths.length,
2717         result = Array(length),
2718         skip = object == null;
2719
2720       while (++index < length) {
2721         result[index] = skip ? undefined : get(object, paths[index]);
2722       }
2723       return result;
2724     }
2725
2726     /**
2727      * The base implementation of `_.clamp` which doesn't coerce arguments.
2728      *
2729      * @private
2730      * @param {number} number The number to clamp.
2731      * @param {number} [lower] The lower bound.
2732      * @param {number} upper The upper bound.
2733      * @returns {number} Returns the clamped number.
2734      */
2735     function baseClamp(number, lower, upper) {
2736       if (number === number) {
2737         if (upper !== undefined) {
2738           number = number <= upper ? number : upper;
2739         }
2740         if (lower !== undefined) {
2741           number = number >= lower ? number : lower;
2742         }
2743       }
2744       return number;
2745     }
2746
2747     /**
2748      * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2749      * traversed objects.
2750      *
2751      * @private
2752      * @param {*} value The value to clone.
2753      * @param {boolean} bitmask The bitmask flags.
2754      *  1 - Deep clone
2755      *  2 - Flatten inherited properties
2756      *  4 - Clone symbols
2757      * @param {Function} [customizer] The function to customize cloning.
2758      * @param {string} [key] The key of `value`.
2759      * @param {Object} [object] The parent object of `value`.
2760      * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2761      * @returns {*} Returns the cloned value.
2762      */
2763     function baseClone(value, bitmask, customizer, key, object, stack) {
2764       var result,
2765         isDeep = bitmask & CLONE_DEEP_FLAG,
2766         isFlat = bitmask & CLONE_FLAT_FLAG,
2767         isFull = bitmask & CLONE_SYMBOLS_FLAG;
2768
2769       if (customizer) {
2770         result = object ? customizer(value, key, object, stack) : customizer(value);
2771       }
2772       if (result !== undefined) {
2773         return result;
2774       }
2775       if (!isObject(value)) {
2776         return value;
2777       }
2778       var isArr = isArray(value);
2779       if (isArr) {
2780         result = initCloneArray(value);
2781         if (!isDeep) {
2782           return copyArray(value, result);
2783         }
2784       } else {
2785         var tag = getTag(value),
2786           isFunc = tag == funcTag || tag == genTag;
2787
2788         if (isBuffer(value)) {
2789           return cloneBuffer(value, isDeep);
2790         }
2791         if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2792           result = (isFlat || isFunc) ? {} : initCloneObject(value);
2793           if (!isDeep) {
2794             return isFlat ?
2795               copySymbolsIn(value, baseAssignIn(result, value)) :
2796               copySymbols(value, baseAssign(result, value));
2797           }
2798         } else {
2799           if (!cloneableTags[tag]) {
2800             return object ? value : {};
2801           }
2802           result = initCloneByTag(value, tag, isDeep);
2803         }
2804       }
2805       // Check for circular references and return its corresponding clone.
2806       stack || (stack = new Stack);
2807       var stacked = stack.get(value);
2808       if (stacked) {
2809         return stacked;
2810       }
2811       stack.set(value, result);
2812
2813       if (isSet(value)) {
2814         value.forEach(function(subValue) {
2815           result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2816         });
2817       } else if (isMap(value)) {
2818         value.forEach(function(subValue, key) {
2819           result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
2820         });
2821       }
2822
2823       var keysFunc = isFull ?
2824         (isFlat ? getAllKeysIn : getAllKeys) :
2825         (isFlat ? keysIn : keys);
2826
2827       var props = isArr ? undefined : keysFunc(value);
2828       arrayEach(props || value, function(subValue, key) {
2829         if (props) {
2830           key = subValue;
2831           subValue = value[key];
2832         }
2833         // Recursively populate clone (susceptible to call stack limits).
2834         assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
2835       });
2836       return result;
2837     }
2838
2839     /**
2840      * The base implementation of `_.conforms` which doesn't clone `source`.
2841      *
2842      * @private
2843      * @param {Object} source The object of property predicates to conform to.
2844      * @returns {Function} Returns the new spec function.
2845      */
2846     function baseConforms(source) {
2847       var props = keys(source);
2848       return function(object) {
2849         return baseConformsTo(object, source, props);
2850       };
2851     }
2852
2853     /**
2854      * The base implementation of `_.conformsTo` which accepts `props` to check.
2855      *
2856      * @private
2857      * @param {Object} object The object to inspect.
2858      * @param {Object} source The object of property predicates to conform to.
2859      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
2860      */
2861     function baseConformsTo(object, source, props) {
2862       var length = props.length;
2863       if (object == null) {
2864         return !length;
2865       }
2866       object = Object(object);
2867       while (length--) {
2868         var key = props[length],
2869           predicate = source[key],
2870           value = object[key];
2871
2872         if ((value === undefined && !(key in object)) || !predicate(value)) {
2873           return false;
2874         }
2875       }
2876       return true;
2877     }
2878
2879     /**
2880      * The base implementation of `_.delay` and `_.defer` which accepts `args`
2881      * to provide to `func`.
2882      *
2883      * @private
2884      * @param {Function} func The function to delay.
2885      * @param {number} wait The number of milliseconds to delay invocation.
2886      * @param {Array} args The arguments to provide to `func`.
2887      * @returns {number|Object} Returns the timer id or timeout object.
2888      */
2889     function baseDelay(func, wait, args) {
2890       if (typeof func != 'function') {
2891         throw new TypeError(FUNC_ERROR_TEXT);
2892       }
2893       return setTimeout(function() {
2894         func.apply(undefined, args);
2895       }, wait);
2896     }
2897
2898     /**
2899      * The base implementation of methods like `_.difference` without support
2900      * for excluding multiple arrays or iteratee shorthands.
2901      *
2902      * @private
2903      * @param {Array} array The array to inspect.
2904      * @param {Array} values The values to exclude.
2905      * @param {Function} [iteratee] The iteratee invoked per element.
2906      * @param {Function} [comparator] The comparator invoked per element.
2907      * @returns {Array} Returns the new array of filtered values.
2908      */
2909     function baseDifference(array, values, iteratee, comparator) {
2910       var index = -1,
2911         includes = arrayIncludes,
2912         isCommon = true,
2913         length = array.length,
2914         result = [],
2915         valuesLength = values.length;
2916
2917       if (!length) {
2918         return result;
2919       }
2920       if (iteratee) {
2921         values = arrayMap(values, baseUnary(iteratee));
2922       }
2923       if (comparator) {
2924         includes = arrayIncludesWith;
2925         isCommon = false;
2926       } else if (values.length >= LARGE_ARRAY_SIZE) {
2927         includes = cacheHas;
2928         isCommon = false;
2929         values = new SetCache(values);
2930       }
2931       outer:
2932         while (++index < length) {
2933           var value = array[index],
2934             computed = iteratee == null ? value : iteratee(value);
2935
2936           value = (comparator || value !== 0) ? value : 0;
2937           if (isCommon && computed === computed) {
2938             var valuesIndex = valuesLength;
2939             while (valuesIndex--) {
2940               if (values[valuesIndex] === computed) {
2941                 continue outer;
2942               }
2943             }
2944             result.push(value);
2945           } else if (!includes(values, computed, comparator)) {
2946             result.push(value);
2947           }
2948         }
2949       return result;
2950     }
2951
2952     /**
2953      * The base implementation of `_.forEach` without support for iteratee shorthands.
2954      *
2955      * @private
2956      * @param {Array|Object} collection The collection to iterate over.
2957      * @param {Function} iteratee The function invoked per iteration.
2958      * @returns {Array|Object} Returns `collection`.
2959      */
2960     var baseEach = createBaseEach(baseForOwn);
2961
2962     /**
2963      * The base implementation of `_.forEachRight` without support for iteratee shorthands.
2964      *
2965      * @private
2966      * @param {Array|Object} collection The collection to iterate over.
2967      * @param {Function} iteratee The function invoked per iteration.
2968      * @returns {Array|Object} Returns `collection`.
2969      */
2970     var baseEachRight = createBaseEach(baseForOwnRight, true);
2971
2972     /**
2973      * The base implementation of `_.every` without support for iteratee shorthands.
2974      *
2975      * @private
2976      * @param {Array|Object} collection The collection to iterate over.
2977      * @param {Function} predicate The function invoked per iteration.
2978      * @returns {boolean} Returns `true` if all elements pass the predicate check,
2979      *  else `false`
2980      */
2981     function baseEvery(collection, predicate) {
2982       var result = true;
2983       baseEach(collection, function(value, index, collection) {
2984         result = !!predicate(value, index, collection);
2985         return result;
2986       });
2987       return result;
2988     }
2989
2990     /**
2991      * The base implementation of methods like `_.max` and `_.min` which accepts a
2992      * `comparator` to determine the extremum value.
2993      *
2994      * @private
2995      * @param {Array} array The array to iterate over.
2996      * @param {Function} iteratee The iteratee invoked per iteration.
2997      * @param {Function} comparator The comparator used to compare values.
2998      * @returns {*} Returns the extremum value.
2999      */
3000     function baseExtremum(array, iteratee, comparator) {
3001       var index = -1,
3002         length = array.length;
3003
3004       while (++index < length) {
3005         var value = array[index],
3006           current = iteratee(value);
3007
3008         if (current != null && (computed === undefined ?
3009             (current === current && !isSymbol(current)) :
3010             comparator(current, computed)
3011           )) {
3012           var computed = current,
3013             result = value;
3014         }
3015       }
3016       return result;
3017     }
3018
3019     /**
3020      * The base implementation of `_.fill` without an iteratee call guard.
3021      *
3022      * @private
3023      * @param {Array} array The array to fill.
3024      * @param {*} value The value to fill `array` with.
3025      * @param {number} [start=0] The start position.
3026      * @param {number} [end=array.length] The end position.
3027      * @returns {Array} Returns `array`.
3028      */
3029     function baseFill(array, value, start, end) {
3030       var length = array.length;
3031
3032       start = toInteger(start);
3033       if (start < 0) {
3034         start = -start > length ? 0 : (length + start);
3035       }
3036       end = (end === undefined || end > length) ? length : toInteger(end);
3037       if (end < 0) {
3038         end += length;
3039       }
3040       end = start > end ? 0 : toLength(end);
3041       while (start < end) {
3042         array[start++] = value;
3043       }
3044       return array;
3045     }
3046
3047     /**
3048      * The base implementation of `_.filter` without support for iteratee shorthands.
3049      *
3050      * @private
3051      * @param {Array|Object} collection The collection to iterate over.
3052      * @param {Function} predicate The function invoked per iteration.
3053      * @returns {Array} Returns the new filtered array.
3054      */
3055     function baseFilter(collection, predicate) {
3056       var result = [];
3057       baseEach(collection, function(value, index, collection) {
3058         if (predicate(value, index, collection)) {
3059           result.push(value);
3060         }
3061       });
3062       return result;
3063     }
3064
3065     /**
3066      * The base implementation of `_.flatten` with support for restricting flattening.
3067      *
3068      * @private
3069      * @param {Array} array The array to flatten.
3070      * @param {number} depth The maximum recursion depth.
3071      * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
3072      * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
3073      * @param {Array} [result=[]] The initial result value.
3074      * @returns {Array} Returns the new flattened array.
3075      */
3076     function baseFlatten(array, depth, predicate, isStrict, result) {
3077       var index = -1,
3078         length = array.length;
3079
3080       predicate || (predicate = isFlattenable);
3081       result || (result = []);
3082
3083       while (++index < length) {
3084         var value = array[index];
3085         if (depth > 0 && predicate(value)) {
3086           if (depth > 1) {
3087             // Recursively flatten arrays (susceptible to call stack limits).
3088             baseFlatten(value, depth - 1, predicate, isStrict, result);
3089           } else {
3090             arrayPush(result, value);
3091           }
3092         } else if (!isStrict) {
3093           result[result.length] = value;
3094         }
3095       }
3096       return result;
3097     }
3098
3099     /**
3100      * The base implementation of `baseForOwn` which iterates over `object`
3101      * properties returned by `keysFunc` and invokes `iteratee` for each property.
3102      * Iteratee functions may exit iteration early by explicitly returning `false`.
3103      *
3104      * @private
3105      * @param {Object} object The object to iterate over.
3106      * @param {Function} iteratee The function invoked per iteration.
3107      * @param {Function} keysFunc The function to get the keys of `object`.
3108      * @returns {Object} Returns `object`.
3109      */
3110     var baseFor = createBaseFor();
3111
3112     /**
3113      * This function is like `baseFor` except that it iterates over properties
3114      * in the opposite order.
3115      *
3116      * @private
3117      * @param {Object} object The object to iterate over.
3118      * @param {Function} iteratee The function invoked per iteration.
3119      * @param {Function} keysFunc The function to get the keys of `object`.
3120      * @returns {Object} Returns `object`.
3121      */
3122     var baseForRight = createBaseFor(true);
3123
3124     /**
3125      * The base implementation of `_.forOwn` without support for iteratee shorthands.
3126      *
3127      * @private
3128      * @param {Object} object The object to iterate over.
3129      * @param {Function} iteratee The function invoked per iteration.
3130      * @returns {Object} Returns `object`.
3131      */
3132     function baseForOwn(object, iteratee) {
3133       return object && baseFor(object, iteratee, keys);
3134     }
3135
3136     /**
3137      * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
3138      *
3139      * @private
3140      * @param {Object} object The object to iterate over.
3141      * @param {Function} iteratee The function invoked per iteration.
3142      * @returns {Object} Returns `object`.
3143      */
3144     function baseForOwnRight(object, iteratee) {
3145       return object && baseForRight(object, iteratee, keys);
3146     }
3147
3148     /**
3149      * The base implementation of `_.functions` which creates an array of
3150      * `object` function property names filtered from `props`.
3151      *
3152      * @private
3153      * @param {Object} object The object to inspect.
3154      * @param {Array} props The property names to filter.
3155      * @returns {Array} Returns the function names.
3156      */
3157     function baseFunctions(object, props) {
3158       return arrayFilter(props, function(key) {
3159         return isFunction(object[key]);
3160       });
3161     }
3162
3163     /**
3164      * The base implementation of `_.get` without support for default values.
3165      *
3166      * @private
3167      * @param {Object} object The object to query.
3168      * @param {Array|string} path The path of the property to get.
3169      * @returns {*} Returns the resolved value.
3170      */
3171     function baseGet(object, path) {
3172       path = castPath(path, object);
3173
3174       var index = 0,
3175         length = path.length;
3176
3177       while (object != null && index < length) {
3178         object = object[toKey(path[index++])];
3179       }
3180       return (index && index == length) ? object : undefined;
3181     }
3182
3183     /**
3184      * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3185      * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3186      * symbols of `object`.
3187      *
3188      * @private
3189      * @param {Object} object The object to query.
3190      * @param {Function} keysFunc The function to get the keys of `object`.
3191      * @param {Function} symbolsFunc The function to get the symbols of `object`.
3192      * @returns {Array} Returns the array of property names and symbols.
3193      */
3194     function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3195       var result = keysFunc(object);
3196       return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3197     }
3198
3199     /**
3200      * The base implementation of `getTag` without fallbacks for buggy environments.
3201      *
3202      * @private
3203      * @param {*} value The value to query.
3204      * @returns {string} Returns the `toStringTag`.
3205      */
3206     function baseGetTag(value) {
3207       if (value == null) {
3208         return value === undefined ? undefinedTag : nullTag;
3209       }
3210       return (symToStringTag && symToStringTag in Object(value)) ?
3211         getRawTag(value) :
3212         objectToString(value);
3213     }
3214
3215     /**
3216      * The base implementation of `_.gt` which doesn't coerce arguments.
3217      *
3218      * @private
3219      * @param {*} value The value to compare.
3220      * @param {*} other The other value to compare.
3221      * @returns {boolean} Returns `true` if `value` is greater than `other`,
3222      *  else `false`.
3223      */
3224     function baseGt(value, other) {
3225       return value > other;
3226     }
3227
3228     /**
3229      * The base implementation of `_.has` without support for deep paths.
3230      *
3231      * @private
3232      * @param {Object} [object] The object to query.
3233      * @param {Array|string} key The key to check.
3234      * @returns {boolean} Returns `true` if `key` exists, else `false`.
3235      */
3236     function baseHas(object, key) {
3237       return object != null && hasOwnProperty.call(object, key);
3238     }
3239
3240     /**
3241      * The base implementation of `_.hasIn` without support for deep paths.
3242      *
3243      * @private
3244      * @param {Object} [object] The object to query.
3245      * @param {Array|string} key The key to check.
3246      * @returns {boolean} Returns `true` if `key` exists, else `false`.
3247      */
3248     function baseHasIn(object, key) {
3249       return object != null && key in Object(object);
3250     }
3251
3252     /**
3253      * The base implementation of `_.inRange` which doesn't coerce arguments.
3254      *
3255      * @private
3256      * @param {number} number The number to check.
3257      * @param {number} start The start of the range.
3258      * @param {number} end The end of the range.
3259      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
3260      */
3261     function baseInRange(number, start, end) {
3262       return number >= nativeMin(start, end) && number < nativeMax(start, end);
3263     }
3264
3265     /**
3266      * The base implementation of methods like `_.intersection`, without support
3267      * for iteratee shorthands, that accepts an array of arrays to inspect.
3268      *
3269      * @private
3270      * @param {Array} arrays The arrays to inspect.
3271      * @param {Function} [iteratee] The iteratee invoked per element.
3272      * @param {Function} [comparator] The comparator invoked per element.
3273      * @returns {Array} Returns the new array of shared values.
3274      */
3275     function baseIntersection(arrays, iteratee, comparator) {
3276       var includes = comparator ? arrayIncludesWith : arrayIncludes,
3277         length = arrays[0].length,
3278         othLength = arrays.length,
3279         othIndex = othLength,
3280         caches = Array(othLength),
3281         maxLength = Infinity,
3282         result = [];
3283
3284       while (othIndex--) {
3285         var array = arrays[othIndex];
3286         if (othIndex && iteratee) {
3287           array = arrayMap(array, baseUnary(iteratee));
3288         }
3289         maxLength = nativeMin(array.length, maxLength);
3290         caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) ?
3291           new SetCache(othIndex && array) :
3292           undefined;
3293       }
3294       array = arrays[0];
3295
3296       var index = -1,
3297         seen = caches[0];
3298
3299       outer:
3300         while (++index < length && result.length < maxLength) {
3301           var value = array[index],
3302             computed = iteratee ? iteratee(value) : value;
3303
3304           value = (comparator || value !== 0) ? value : 0;
3305           if (!(seen ?
3306               cacheHas(seen, computed) :
3307               includes(result, computed, comparator)
3308             )) {
3309             othIndex = othLength;
3310             while (--othIndex) {
3311               var cache = caches[othIndex];
3312               if (!(cache ?
3313                   cacheHas(cache, computed) :
3314                   includes(arrays[othIndex], computed, comparator))) {
3315                 continue outer;
3316               }
3317             }
3318             if (seen) {
3319               seen.push(computed);
3320             }
3321             result.push(value);
3322           }
3323         }
3324       return result;
3325     }
3326
3327     /**
3328      * The base implementation of `_.invert` and `_.invertBy` which inverts
3329      * `object` with values transformed by `iteratee` and set by `setter`.
3330      *
3331      * @private
3332      * @param {Object} object The object to iterate over.
3333      * @param {Function} setter The function to set `accumulator` values.
3334      * @param {Function} iteratee The iteratee to transform values.
3335      * @param {Object} accumulator The initial inverted object.
3336      * @returns {Function} Returns `accumulator`.
3337      */
3338     function baseInverter(object, setter, iteratee, accumulator) {
3339       baseForOwn(object, function(value, key, object) {
3340         setter(accumulator, iteratee(value), key, object);
3341       });
3342       return accumulator;
3343     }
3344
3345     /**
3346      * The base implementation of `_.invoke` without support for individual
3347      * method arguments.
3348      *
3349      * @private
3350      * @param {Object} object The object to query.
3351      * @param {Array|string} path The path of the method to invoke.
3352      * @param {Array} args The arguments to invoke the method with.
3353      * @returns {*} Returns the result of the invoked method.
3354      */
3355     function baseInvoke(object, path, args) {
3356       path = castPath(path, object);
3357       object = parent(object, path);
3358       var func = object == null ? object : object[toKey(last(path))];
3359       return func == null ? undefined : apply(func, object, args);
3360     }
3361
3362     /**
3363      * The base implementation of `_.isArguments`.
3364      *
3365      * @private
3366      * @param {*} value The value to check.
3367      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3368      */
3369     function baseIsArguments(value) {
3370       return isObjectLike(value) && baseGetTag(value) == argsTag;
3371     }
3372
3373     /**
3374      * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3375      *
3376      * @private
3377      * @param {*} value The value to check.
3378      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3379      */
3380     function baseIsArrayBuffer(value) {
3381       return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3382     }
3383
3384     /**
3385      * The base implementation of `_.isDate` without Node.js optimizations.
3386      *
3387      * @private
3388      * @param {*} value The value to check.
3389      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3390      */
3391     function baseIsDate(value) {
3392       return isObjectLike(value) && baseGetTag(value) == dateTag;
3393     }
3394
3395     /**
3396      * The base implementation of `_.isEqual` which supports partial comparisons
3397      * and tracks traversed objects.
3398      *
3399      * @private
3400      * @param {*} value The value to compare.
3401      * @param {*} other The other value to compare.
3402      * @param {boolean} bitmask The bitmask flags.
3403      *  1 - Unordered comparison
3404      *  2 - Partial comparison
3405      * @param {Function} [customizer] The function to customize comparisons.
3406      * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3407      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3408      */
3409     function baseIsEqual(value, other, bitmask, customizer, stack) {
3410       if (value === other) {
3411         return true;
3412       }
3413       if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3414         return value !== value && other !== other;
3415       }
3416       return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3417     }
3418
3419     /**
3420      * A specialized version of `baseIsEqual` for arrays and objects which performs
3421      * deep comparisons and tracks traversed objects enabling objects with circular
3422      * references to be compared.
3423      *
3424      * @private
3425      * @param {Object} object The object to compare.
3426      * @param {Object} other The other object to compare.
3427      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3428      * @param {Function} customizer The function to customize comparisons.
3429      * @param {Function} equalFunc The function to determine equivalents of values.
3430      * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3431      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3432      */
3433     function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3434       var objIsArr = isArray(object),
3435         othIsArr = isArray(other),
3436         objTag = objIsArr ? arrayTag : getTag(object),
3437         othTag = othIsArr ? arrayTag : getTag(other);
3438
3439       objTag = objTag == argsTag ? objectTag : objTag;
3440       othTag = othTag == argsTag ? objectTag : othTag;
3441
3442       var objIsObj = objTag == objectTag,
3443         othIsObj = othTag == objectTag,
3444         isSameTag = objTag == othTag;
3445
3446       if (isSameTag && isBuffer(object)) {
3447         if (!isBuffer(other)) {
3448           return false;
3449         }
3450         objIsArr = true;
3451         objIsObj = false;
3452       }
3453       if (isSameTag && !objIsObj) {
3454         stack || (stack = new Stack);
3455         return (objIsArr || isTypedArray(object)) ?
3456           equalArrays(object, other, bitmask, customizer, equalFunc, stack) :
3457           equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3458       }
3459       if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3460         var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3461           othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3462
3463         if (objIsWrapped || othIsWrapped) {
3464           var objUnwrapped = objIsWrapped ? object.value() : object,
3465             othUnwrapped = othIsWrapped ? other.value() : other;
3466
3467           stack || (stack = new Stack);
3468           return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3469         }
3470       }
3471       if (!isSameTag) {
3472         return false;
3473       }
3474       stack || (stack = new Stack);
3475       return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3476     }
3477
3478     /**
3479      * The base implementation of `_.isMap` without Node.js optimizations.
3480      *
3481      * @private
3482      * @param {*} value The value to check.
3483      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3484      */
3485     function baseIsMap(value) {
3486       return isObjectLike(value) && getTag(value) == mapTag;
3487     }
3488
3489     /**
3490      * The base implementation of `_.isMatch` without support for iteratee shorthands.
3491      *
3492      * @private
3493      * @param {Object} object The object to inspect.
3494      * @param {Object} source The object of property values to match.
3495      * @param {Array} matchData The property names, values, and compare flags to match.
3496      * @param {Function} [customizer] The function to customize comparisons.
3497      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3498      */
3499     function baseIsMatch(object, source, matchData, customizer) {
3500       var index = matchData.length,
3501         length = index,
3502         noCustomizer = !customizer;
3503
3504       if (object == null) {
3505         return !length;
3506       }
3507       object = Object(object);
3508       while (index--) {
3509         var data = matchData[index];
3510         if ((noCustomizer && data[2]) ?
3511           data[1] !== object[data[0]] :
3512           !(data[0] in object)
3513         ) {
3514           return false;
3515         }
3516       }
3517       while (++index < length) {
3518         data = matchData[index];
3519         var key = data[0],
3520           objValue = object[key],
3521           srcValue = data[1];
3522
3523         if (noCustomizer && data[2]) {
3524           if (objValue === undefined && !(key in object)) {
3525             return false;
3526           }
3527         } else {
3528           var stack = new Stack;
3529           if (customizer) {
3530             var result = customizer(objValue, srcValue, key, object, source, stack);
3531           }
3532           if (!(result === undefined ?
3533               baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) :
3534               result
3535             )) {
3536             return false;
3537           }
3538         }
3539       }
3540       return true;
3541     }
3542
3543     /**
3544      * The base implementation of `_.isNative` without bad shim checks.
3545      *
3546      * @private
3547      * @param {*} value The value to check.
3548      * @returns {boolean} Returns `true` if `value` is a native function,
3549      *  else `false`.
3550      */
3551     function baseIsNative(value) {
3552       if (!isObject(value) || isMasked(value)) {
3553         return false;
3554       }
3555       var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3556       return pattern.test(toSource(value));
3557     }
3558
3559     /**
3560      * The base implementation of `_.isRegExp` without Node.js optimizations.
3561      *
3562      * @private
3563      * @param {*} value The value to check.
3564      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3565      */
3566     function baseIsRegExp(value) {
3567       return isObjectLike(value) && baseGetTag(value) == regexpTag;
3568     }
3569
3570     /**
3571      * The base implementation of `_.isSet` without Node.js optimizations.
3572      *
3573      * @private
3574      * @param {*} value The value to check.
3575      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3576      */
3577     function baseIsSet(value) {
3578       return isObjectLike(value) && getTag(value) == setTag;
3579     }
3580
3581     /**
3582      * The base implementation of `_.isTypedArray` without Node.js optimizations.
3583      *
3584      * @private
3585      * @param {*} value The value to check.
3586      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3587      */
3588     function baseIsTypedArray(value) {
3589       return isObjectLike(value) &&
3590         isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3591     }
3592
3593     /**
3594      * The base implementation of `_.iteratee`.
3595      *
3596      * @private
3597      * @param {*} [value=_.identity] The value to convert to an iteratee.
3598      * @returns {Function} Returns the iteratee.
3599      */
3600     function baseIteratee(value) {
3601       // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3602       // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3603       if (typeof value == 'function') {
3604         return value;
3605       }
3606       if (value == null) {
3607         return identity;
3608       }
3609       if (typeof value == 'object') {
3610         return isArray(value) ?
3611           baseMatchesProperty(value[0], value[1]) :
3612           baseMatches(value);
3613       }
3614       return property(value);
3615     }
3616
3617     /**
3618      * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3619      *
3620      * @private
3621      * @param {Object} object The object to query.
3622      * @returns {Array} Returns the array of property names.
3623      */
3624     function baseKeys(object) {
3625       if (!isPrototype(object)) {
3626         return nativeKeys(object);
3627       }
3628       var result = [];
3629       for (var key in Object(object)) {
3630         if (hasOwnProperty.call(object, key) && key != 'constructor') {
3631           result.push(key);
3632         }
3633       }
3634       return result;
3635     }
3636
3637     /**
3638      * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3639      *
3640      * @private
3641      * @param {Object} object The object to query.
3642      * @returns {Array} Returns the array of property names.
3643      */
3644     function baseKeysIn(object) {
3645       if (!isObject(object)) {
3646         return nativeKeysIn(object);
3647       }
3648       var isProto = isPrototype(object),
3649         result = [];
3650
3651       for (var key in object) {
3652         if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3653           result.push(key);
3654         }
3655       }
3656       return result;
3657     }
3658
3659     /**
3660      * The base implementation of `_.lt` which doesn't coerce arguments.
3661      *
3662      * @private
3663      * @param {*} value The value to compare.
3664      * @param {*} other The other value to compare.
3665      * @returns {boolean} Returns `true` if `value` is less than `other`,
3666      *  else `false`.
3667      */
3668     function baseLt(value, other) {
3669       return value < other;
3670     }
3671
3672     /**
3673      * The base implementation of `_.map` without support for iteratee shorthands.
3674      *
3675      * @private
3676      * @param {Array|Object} collection The collection to iterate over.
3677      * @param {Function} iteratee The function invoked per iteration.
3678      * @returns {Array} Returns the new mapped array.
3679      */
3680     function baseMap(collection, iteratee) {
3681       var index = -1,
3682         result = isArrayLike(collection) ? Array(collection.length) : [];
3683
3684       baseEach(collection, function(value, key, collection) {
3685         result[++index] = iteratee(value, key, collection);
3686       });
3687       return result;
3688     }
3689
3690     /**
3691      * The base implementation of `_.matches` which doesn't clone `source`.
3692      *
3693      * @private
3694      * @param {Object} source The object of property values to match.
3695      * @returns {Function} Returns the new spec function.
3696      */
3697     function baseMatches(source) {
3698       var matchData = getMatchData(source);
3699       if (matchData.length == 1 && matchData[0][2]) {
3700         return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3701       }
3702       return function(object) {
3703         return object === source || baseIsMatch(object, source, matchData);
3704       };
3705     }
3706
3707     /**
3708      * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3709      *
3710      * @private
3711      * @param {string} path The path of the property to get.
3712      * @param {*} srcValue The value to match.
3713      * @returns {Function} Returns the new spec function.
3714      */
3715     function baseMatchesProperty(path, srcValue) {
3716       if (isKey(path) && isStrictComparable(srcValue)) {
3717         return matchesStrictComparable(toKey(path), srcValue);
3718       }
3719       return function(object) {
3720         var objValue = get(object, path);
3721         return (objValue === undefined && objValue === srcValue) ?
3722           hasIn(object, path) :
3723           baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3724       };
3725     }
3726
3727     /**
3728      * The base implementation of `_.merge` without support for multiple sources.
3729      *
3730      * @private
3731      * @param {Object} object The destination object.
3732      * @param {Object} source The source object.
3733      * @param {number} srcIndex The index of `source`.
3734      * @param {Function} [customizer] The function to customize merged values.
3735      * @param {Object} [stack] Tracks traversed source values and their merged
3736      *  counterparts.
3737      */
3738     function baseMerge(object, source, srcIndex, customizer, stack) {
3739       if (object === source) {
3740         return;
3741       }
3742       baseFor(source, function(srcValue, key) {
3743         stack || (stack = new Stack);
3744         if (isObject(srcValue)) {
3745           baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3746         } else {
3747           var newValue = customizer ?
3748             customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) :
3749             undefined;
3750
3751           if (newValue === undefined) {
3752             newValue = srcValue;
3753           }
3754           assignMergeValue(object, key, newValue);
3755         }
3756       }, keysIn);
3757     }
3758
3759     /**
3760      * A specialized version of `baseMerge` for arrays and objects which performs
3761      * deep merges and tracks traversed objects enabling objects with circular
3762      * references to be merged.
3763      *
3764      * @private
3765      * @param {Object} object The destination object.
3766      * @param {Object} source The source object.
3767      * @param {string} key The key of the value to merge.
3768      * @param {number} srcIndex The index of `source`.
3769      * @param {Function} mergeFunc The function to merge values.
3770      * @param {Function} [customizer] The function to customize assigned values.
3771      * @param {Object} [stack] Tracks traversed source values and their merged
3772      *  counterparts.
3773      */
3774     function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3775       var objValue = safeGet(object, key),
3776         srcValue = safeGet(source, key),
3777         stacked = stack.get(srcValue);
3778
3779       if (stacked) {
3780         assignMergeValue(object, key, stacked);
3781         return;
3782       }
3783       var newValue = customizer ?
3784         customizer(objValue, srcValue, (key + ''), object, source, stack) :
3785         undefined;
3786
3787       var isCommon = newValue === undefined;
3788
3789       if (isCommon) {
3790         var isArr = isArray(srcValue),
3791           isBuff = !isArr && isBuffer(srcValue),
3792           isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3793
3794         newValue = srcValue;
3795         if (isArr || isBuff || isTyped) {
3796           if (isArray(objValue)) {
3797             newValue = objValue;
3798           } else if (isArrayLikeObject(objValue)) {
3799             newValue = copyArray(objValue);
3800           } else if (isBuff) {
3801             isCommon = false;
3802             newValue = cloneBuffer(srcValue, true);
3803           } else if (isTyped) {
3804             isCommon = false;
3805             newValue = cloneTypedArray(srcValue, true);
3806           } else {
3807             newValue = [];
3808           }
3809         } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3810           newValue = objValue;
3811           if (isArguments(objValue)) {
3812             newValue = toPlainObject(objValue);
3813           } else if (!isObject(objValue) || isFunction(objValue)) {
3814             newValue = initCloneObject(srcValue);
3815           }
3816         } else {
3817           isCommon = false;
3818         }
3819       }
3820       if (isCommon) {
3821         // Recursively merge objects and arrays (susceptible to call stack limits).
3822         stack.set(srcValue, newValue);
3823         mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3824         stack['delete'](srcValue);
3825       }
3826       assignMergeValue(object, key, newValue);
3827     }
3828
3829     /**
3830      * The base implementation of `_.nth` which doesn't coerce arguments.
3831      *
3832      * @private
3833      * @param {Array} array The array to query.
3834      * @param {number} n The index of the element to return.
3835      * @returns {*} Returns the nth element of `array`.
3836      */
3837     function baseNth(array, n) {
3838       var length = array.length;
3839       if (!length) {
3840         return;
3841       }
3842       n += n < 0 ? length : 0;
3843       return isIndex(n, length) ? array[n] : undefined;
3844     }
3845
3846     /**
3847      * The base implementation of `_.orderBy` without param guards.
3848      *
3849      * @private
3850      * @param {Array|Object} collection The collection to iterate over.
3851      * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
3852      * @param {string[]} orders The sort orders of `iteratees`.
3853      * @returns {Array} Returns the new sorted array.
3854      */
3855     function baseOrderBy(collection, iteratees, orders) {
3856       if (iteratees.length) {
3857         iteratees = arrayMap(iteratees, function(iteratee) {
3858           if (isArray(iteratee)) {
3859             return function(value) {
3860               return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
3861             }
3862           }
3863           return iteratee;
3864         });
3865       } else {
3866         iteratees = [identity];
3867       }
3868
3869       var index = -1;
3870       iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
3871
3872       var result = baseMap(collection, function(value, key, collection) {
3873         var criteria = arrayMap(iteratees, function(iteratee) {
3874           return iteratee(value);
3875         });
3876         return {
3877           'criteria': criteria,
3878           'index': ++index,
3879           'value': value
3880         };
3881       });
3882
3883       return baseSortBy(result, function(object, other) {
3884         return compareMultiple(object, other, orders);
3885       });
3886     }
3887
3888     /**
3889      * The base implementation of `_.pick` without support for individual
3890      * property identifiers.
3891      *
3892      * @private
3893      * @param {Object} object The source object.
3894      * @param {string[]} paths The property paths to pick.
3895      * @returns {Object} Returns the new object.
3896      */
3897     function basePick(object, paths) {
3898       return basePickBy(object, paths, function(value, path) {
3899         return hasIn(object, path);
3900       });
3901     }
3902
3903     /**
3904      * The base implementation of  `_.pickBy` without support for iteratee shorthands.
3905      *
3906      * @private
3907      * @param {Object} object The source object.
3908      * @param {string[]} paths The property paths to pick.
3909      * @param {Function} predicate The function invoked per property.
3910      * @returns {Object} Returns the new object.
3911      */
3912     function basePickBy(object, paths, predicate) {
3913       var index = -1,
3914         length = paths.length,
3915         result = {};
3916
3917       while (++index < length) {
3918         var path = paths[index],
3919           value = baseGet(object, path);
3920
3921         if (predicate(value, path)) {
3922           baseSet(result, castPath(path, object), value);
3923         }
3924       }
3925       return result;
3926     }
3927
3928     /**
3929      * A specialized version of `baseProperty` which supports deep paths.
3930      *
3931      * @private
3932      * @param {Array|string} path The path of the property to get.
3933      * @returns {Function} Returns the new accessor function.
3934      */
3935     function basePropertyDeep(path) {
3936       return function(object) {
3937         return baseGet(object, path);
3938       };
3939     }
3940
3941     /**
3942      * The base implementation of `_.pullAllBy` without support for iteratee
3943      * shorthands.
3944      *
3945      * @private
3946      * @param {Array} array The array to modify.
3947      * @param {Array} values The values to remove.
3948      * @param {Function} [iteratee] The iteratee invoked per element.
3949      * @param {Function} [comparator] The comparator invoked per element.
3950      * @returns {Array} Returns `array`.
3951      */
3952     function basePullAll(array, values, iteratee, comparator) {
3953       var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3954         index = -1,
3955         length = values.length,
3956         seen = array;
3957
3958       if (array === values) {
3959         values = copyArray(values);
3960       }
3961       if (iteratee) {
3962         seen = arrayMap(array, baseUnary(iteratee));
3963       }
3964       while (++index < length) {
3965         var fromIndex = 0,
3966           value = values[index],
3967           computed = iteratee ? iteratee(value) : value;
3968
3969         while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3970           if (seen !== array) {
3971             splice.call(seen, fromIndex, 1);
3972           }
3973           splice.call(array, fromIndex, 1);
3974         }
3975       }
3976       return array;
3977     }
3978
3979     /**
3980      * The base implementation of `_.pullAt` without support for individual
3981      * indexes or capturing the removed elements.
3982      *
3983      * @private
3984      * @param {Array} array The array to modify.
3985      * @param {number[]} indexes The indexes of elements to remove.
3986      * @returns {Array} Returns `array`.
3987      */
3988     function basePullAt(array, indexes) {
3989       var length = array ? indexes.length : 0,
3990         lastIndex = length - 1;
3991
3992       while (length--) {
3993         var index = indexes[length];
3994         if (length == lastIndex || index !== previous) {
3995           var previous = index;
3996           if (isIndex(index)) {
3997             splice.call(array, index, 1);
3998           } else {
3999             baseUnset(array, index);
4000           }
4001         }
4002       }
4003       return array;
4004     }
4005
4006     /**
4007      * The base implementation of `_.random` without support for returning
4008      * floating-point numbers.
4009      *
4010      * @private
4011      * @param {number} lower The lower bound.
4012      * @param {number} upper The upper bound.
4013      * @returns {number} Returns the random number.
4014      */
4015     function baseRandom(lower, upper) {
4016       return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
4017     }
4018
4019     /**
4020      * The base implementation of `_.range` and `_.rangeRight` which doesn't
4021      * coerce arguments.
4022      *
4023      * @private
4024      * @param {number} start The start of the range.
4025      * @param {number} end The end of the range.
4026      * @param {number} step The value to increment or decrement by.
4027      * @param {boolean} [fromRight] Specify iterating from right to left.
4028      * @returns {Array} Returns the range of numbers.
4029      */
4030     function baseRange(start, end, step, fromRight) {
4031       var index = -1,
4032         length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
4033         result = Array(length);
4034
4035       while (length--) {
4036         result[fromRight ? length : ++index] = start;
4037         start += step;
4038       }
4039       return result;
4040     }
4041
4042     /**
4043      * The base implementation of `_.repeat` which doesn't coerce arguments.
4044      *
4045      * @private
4046      * @param {string} string The string to repeat.
4047      * @param {number} n The number of times to repeat the string.
4048      * @returns {string} Returns the repeated string.
4049      */
4050     function baseRepeat(string, n) {
4051       var result = '';
4052       if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
4053         return result;
4054       }
4055       // Leverage the exponentiation by squaring algorithm for a faster repeat.
4056       // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
4057       do {
4058         if (n % 2) {
4059           result += string;
4060         }
4061         n = nativeFloor(n / 2);
4062         if (n) {
4063           string += string;
4064         }
4065       } while (n);
4066
4067       return result;
4068     }
4069
4070     /**
4071      * The base implementation of `_.rest` which doesn't validate or coerce arguments.
4072      *
4073      * @private
4074      * @param {Function} func The function to apply a rest parameter to.
4075      * @param {number} [start=func.length-1] The start position of the rest parameter.
4076      * @returns {Function} Returns the new function.
4077      */
4078     function baseRest(func, start) {
4079       return setToString(overRest(func, start, identity), func + '');
4080     }
4081
4082     /**
4083      * The base implementation of `_.sample`.
4084      *
4085      * @private
4086      * @param {Array|Object} collection The collection to sample.
4087      * @returns {*} Returns the random element.
4088      */
4089     function baseSample(collection) {
4090       return arraySample(values(collection));
4091     }
4092
4093     /**
4094      * The base implementation of `_.sampleSize` without param guards.
4095      *
4096      * @private
4097      * @param {Array|Object} collection The collection to sample.
4098      * @param {number} n The number of elements to sample.
4099      * @returns {Array} Returns the random elements.
4100      */
4101     function baseSampleSize(collection, n) {
4102       var array = values(collection);
4103       return shuffleSelf(array, baseClamp(n, 0, array.length));
4104     }
4105
4106     /**
4107      * The base implementation of `_.set`.
4108      *
4109      * @private
4110      * @param {Object} object The object to modify.
4111      * @param {Array|string} path The path of the property to set.
4112      * @param {*} value The value to set.
4113      * @param {Function} [customizer] The function to customize path creation.
4114      * @returns {Object} Returns `object`.
4115      */
4116     function baseSet(object, path, value, customizer) {
4117       if (!isObject(object)) {
4118         return object;
4119       }
4120       path = castPath(path, object);
4121
4122       var index = -1,
4123         length = path.length,
4124         lastIndex = length - 1,
4125         nested = object;
4126
4127       while (nested != null && ++index < length) {
4128         var key = toKey(path[index]),
4129           newValue = value;
4130
4131         if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
4132           return object;
4133         }
4134
4135         if (index != lastIndex) {
4136           var objValue = nested[key];
4137           newValue = customizer ? customizer(objValue, key, nested) : undefined;
4138           if (newValue === undefined) {
4139             newValue = isObject(objValue) ?
4140               objValue :
4141               (isIndex(path[index + 1]) ? [] : {});
4142           }
4143         }
4144         assignValue(nested, key, newValue);
4145         nested = nested[key];
4146       }
4147       return object;
4148     }
4149
4150     /**
4151      * The base implementation of `setData` without support for hot loop shorting.
4152      *
4153      * @private
4154      * @param {Function} func The function to associate metadata with.
4155      * @param {*} data The metadata.
4156      * @returns {Function} Returns `func`.
4157      */
4158     var baseSetData = !metaMap ? identity : function(func, data) {
4159       metaMap.set(func, data);
4160       return func;
4161     };
4162
4163     /**
4164      * The base implementation of `setToString` without support for hot loop shorting.
4165      *
4166      * @private
4167      * @param {Function} func The function to modify.
4168      * @param {Function} string The `toString` result.
4169      * @returns {Function} Returns `func`.
4170      */
4171     var baseSetToString = !defineProperty ? identity : function(func, string) {
4172       return defineProperty(func, 'toString', {
4173         'configurable': true,
4174         'enumerable': false,
4175         'value': constant(string),
4176         'writable': true
4177       });
4178     };
4179
4180     /**
4181      * The base implementation of `_.shuffle`.
4182      *
4183      * @private
4184      * @param {Array|Object} collection The collection to shuffle.
4185      * @returns {Array} Returns the new shuffled array.
4186      */
4187     function baseShuffle(collection) {
4188       return shuffleSelf(values(collection));
4189     }
4190
4191     /**
4192      * The base implementation of `_.slice` without an iteratee call guard.
4193      *
4194      * @private
4195      * @param {Array} array The array to slice.
4196      * @param {number} [start=0] The start position.
4197      * @param {number} [end=array.length] The end position.
4198      * @returns {Array} Returns the slice of `array`.
4199      */
4200     function baseSlice(array, start, end) {
4201       var index = -1,
4202         length = array.length;
4203
4204       if (start < 0) {
4205         start = -start > length ? 0 : (length + start);
4206       }
4207       end = end > length ? length : end;
4208       if (end < 0) {
4209         end += length;
4210       }
4211       length = start > end ? 0 : ((end - start) >>> 0);
4212       start >>>= 0;
4213
4214       var result = Array(length);
4215       while (++index < length) {
4216         result[index] = array[index + start];
4217       }
4218       return result;
4219     }
4220
4221     /**
4222      * The base implementation of `_.some` without support for iteratee shorthands.
4223      *
4224      * @private
4225      * @param {Array|Object} collection The collection to iterate over.
4226      * @param {Function} predicate The function invoked per iteration.
4227      * @returns {boolean} Returns `true` if any element passes the predicate check,
4228      *  else `false`.
4229      */
4230     function baseSome(collection, predicate) {
4231       var result;
4232
4233       baseEach(collection, function(value, index, collection) {
4234         result = predicate(value, index, collection);
4235         return !result;
4236       });
4237       return !!result;
4238     }
4239
4240     /**
4241      * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
4242      * performs a binary search of `array` to determine the index at which `value`
4243      * should be inserted into `array` in order to maintain its sort order.
4244      *
4245      * @private
4246      * @param {Array} array The sorted array to inspect.
4247      * @param {*} value The value to evaluate.
4248      * @param {boolean} [retHighest] Specify returning the highest qualified index.
4249      * @returns {number} Returns the index at which `value` should be inserted
4250      *  into `array`.
4251      */
4252     function baseSortedIndex(array, value, retHighest) {
4253       var low = 0,
4254         high = array == null ? low : array.length;
4255
4256       if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4257         while (low < high) {
4258           var mid = (low + high) >>> 1,
4259             computed = array[mid];
4260
4261           if (computed !== null && !isSymbol(computed) &&
4262             (retHighest ? (computed <= value) : (computed < value))) {
4263             low = mid + 1;
4264           } else {
4265             high = mid;
4266           }
4267         }
4268         return high;
4269       }
4270       return baseSortedIndexBy(array, value, identity, retHighest);
4271     }
4272
4273     /**
4274      * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
4275      * which invokes `iteratee` for `value` and each element of `array` to compute
4276      * their sort ranking. The iteratee is invoked with one argument; (value).
4277      *
4278      * @private
4279      * @param {Array} array The sorted array to inspect.
4280      * @param {*} value The value to evaluate.
4281      * @param {Function} iteratee The iteratee invoked per element.
4282      * @param {boolean} [retHighest] Specify returning the highest qualified index.
4283      * @returns {number} Returns the index at which `value` should be inserted
4284      *  into `array`.
4285      */
4286     function baseSortedIndexBy(array, value, iteratee, retHighest) {
4287       var low = 0,
4288         high = array == null ? 0 : array.length;
4289       if (high === 0) {
4290         return 0;
4291       }
4292
4293       value = iteratee(value);
4294       var valIsNaN = value !== value,
4295         valIsNull = value === null,
4296         valIsSymbol = isSymbol(value),
4297         valIsUndefined = value === undefined;
4298
4299       while (low < high) {
4300         var mid = nativeFloor((low + high) / 2),
4301           computed = iteratee(array[mid]),
4302           othIsDefined = computed !== undefined,
4303           othIsNull = computed === null,
4304           othIsReflexive = computed === computed,
4305           othIsSymbol = isSymbol(computed);
4306
4307         if (valIsNaN) {
4308           var setLow = retHighest || othIsReflexive;
4309         } else if (valIsUndefined) {
4310           setLow = othIsReflexive && (retHighest || othIsDefined);
4311         } else if (valIsNull) {
4312           setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
4313         } else if (valIsSymbol) {
4314           setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
4315         } else if (othIsNull || othIsSymbol) {
4316           setLow = false;
4317         } else {
4318           setLow = retHighest ? (computed <= value) : (computed < value);
4319         }
4320         if (setLow) {
4321           low = mid + 1;
4322         } else {
4323           high = mid;
4324         }
4325       }
4326       return nativeMin(high, MAX_ARRAY_INDEX);
4327     }
4328
4329     /**
4330      * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4331      * support for iteratee shorthands.
4332      *
4333      * @private
4334      * @param {Array} array The array to inspect.
4335      * @param {Function} [iteratee] The iteratee invoked per element.
4336      * @returns {Array} Returns the new duplicate free array.
4337      */
4338     function baseSortedUniq(array, iteratee) {
4339       var index = -1,
4340         length = array.length,
4341         resIndex = 0,
4342         result = [];
4343
4344       while (++index < length) {
4345         var value = array[index],
4346           computed = iteratee ? iteratee(value) : value;
4347
4348         if (!index || !eq(computed, seen)) {
4349           var seen = computed;
4350           result[resIndex++] = value === 0 ? 0 : value;
4351         }
4352       }
4353       return result;
4354     }
4355
4356     /**
4357      * The base implementation of `_.toNumber` which doesn't ensure correct
4358      * conversions of binary, hexadecimal, or octal string values.
4359      *
4360      * @private
4361      * @param {*} value The value to process.
4362      * @returns {number} Returns the number.
4363      */
4364     function baseToNumber(value) {
4365       if (typeof value == 'number') {
4366         return value;
4367       }
4368       if (isSymbol(value)) {
4369         return NAN;
4370       }
4371       return +value;
4372     }
4373
4374     /**
4375      * The base implementation of `_.toString` which doesn't convert nullish
4376      * values to empty strings.
4377      *
4378      * @private
4379      * @param {*} value The value to process.
4380      * @returns {string} Returns the string.
4381      */
4382     function baseToString(value) {
4383       // Exit early for strings to avoid a performance hit in some environments.
4384       if (typeof value == 'string') {
4385         return value;
4386       }
4387       if (isArray(value)) {
4388         // Recursively convert values (susceptible to call stack limits).
4389         return arrayMap(value, baseToString) + '';
4390       }
4391       if (isSymbol(value)) {
4392         return symbolToString ? symbolToString.call(value) : '';
4393       }
4394       var result = (value + '');
4395       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4396     }
4397
4398     /**
4399      * The base implementation of `_.uniqBy` without support for iteratee shorthands.
4400      *
4401      * @private
4402      * @param {Array} array The array to inspect.
4403      * @param {Function} [iteratee] The iteratee invoked per element.
4404      * @param {Function} [comparator] The comparator invoked per element.
4405      * @returns {Array} Returns the new duplicate free array.
4406      */
4407     function baseUniq(array, iteratee, comparator) {
4408       var index = -1,
4409         includes = arrayIncludes,
4410         length = array.length,
4411         isCommon = true,
4412         result = [],
4413         seen = result;
4414
4415       if (comparator) {
4416         isCommon = false;
4417         includes = arrayIncludesWith;
4418       } else if (length >= LARGE_ARRAY_SIZE) {
4419         var set = iteratee ? null : createSet(array);
4420         if (set) {
4421           return setToArray(set);
4422         }
4423         isCommon = false;
4424         includes = cacheHas;
4425         seen = new SetCache;
4426       } else {
4427         seen = iteratee ? [] : result;
4428       }
4429       outer:
4430         while (++index < length) {
4431           var value = array[index],
4432             computed = iteratee ? iteratee(value) : value;
4433
4434           value = (comparator || value !== 0) ? value : 0;
4435           if (isCommon && computed === computed) {
4436             var seenIndex = seen.length;
4437             while (seenIndex--) {
4438               if (seen[seenIndex] === computed) {
4439                 continue outer;
4440               }
4441             }
4442             if (iteratee) {
4443               seen.push(computed);
4444             }
4445             result.push(value);
4446           } else if (!includes(seen, computed, comparator)) {
4447             if (seen !== result) {
4448               seen.push(computed);
4449             }
4450             result.push(value);
4451           }
4452         }
4453       return result;
4454     }
4455
4456     /**
4457      * The base implementation of `_.unset`.
4458      *
4459      * @private
4460      * @param {Object} object The object to modify.
4461      * @param {Array|string} path The property path to unset.
4462      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
4463      */
4464     function baseUnset(object, path) {
4465       path = castPath(path, object);
4466       object = parent(object, path);
4467       return object == null || delete object[toKey(last(path))];
4468     }
4469
4470     /**
4471      * The base implementation of `_.update`.
4472      *
4473      * @private
4474      * @param {Object} object The object to modify.
4475      * @param {Array|string} path The path of the property to update.
4476      * @param {Function} updater The function to produce the updated value.
4477      * @param {Function} [customizer] The function to customize path creation.
4478      * @returns {Object} Returns `object`.
4479      */
4480     function baseUpdate(object, path, updater, customizer) {
4481       return baseSet(object, path, updater(baseGet(object, path)), customizer);
4482     }
4483
4484     /**
4485      * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4486      * without support for iteratee shorthands.
4487      *
4488      * @private
4489      * @param {Array} array The array to query.
4490      * @param {Function} predicate The function invoked per iteration.
4491      * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
4492      * @param {boolean} [fromRight] Specify iterating from right to left.
4493      * @returns {Array} Returns the slice of `array`.
4494      */
4495     function baseWhile(array, predicate, isDrop, fromRight) {
4496       var length = array.length,
4497         index = fromRight ? length : -1;
4498
4499       while ((fromRight ? index-- : ++index < length) &&
4500         predicate(array[index], index, array)) {}
4501
4502       return isDrop ?
4503         baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) :
4504         baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
4505     }
4506
4507     /**
4508      * The base implementation of `wrapperValue` which returns the result of
4509      * performing a sequence of actions on the unwrapped `value`, where each
4510      * successive action is supplied the return value of the previous.
4511      *
4512      * @private
4513      * @param {*} value The unwrapped value.
4514      * @param {Array} actions Actions to perform to resolve the unwrapped value.
4515      * @returns {*} Returns the resolved value.
4516      */
4517     function baseWrapperValue(value, actions) {
4518       var result = value;
4519       if (result instanceof LazyWrapper) {
4520         result = result.value();
4521       }
4522       return arrayReduce(actions, function(result, action) {
4523         return action.func.apply(action.thisArg, arrayPush([result], action.args));
4524       }, result);
4525     }
4526
4527     /**
4528      * The base implementation of methods like `_.xor`, without support for
4529      * iteratee shorthands, that accepts an array of arrays to inspect.
4530      *
4531      * @private
4532      * @param {Array} arrays The arrays to inspect.
4533      * @param {Function} [iteratee] The iteratee invoked per element.
4534      * @param {Function} [comparator] The comparator invoked per element.
4535      * @returns {Array} Returns the new array of values.
4536      */
4537     function baseXor(arrays, iteratee, comparator) {
4538       var length = arrays.length;
4539       if (length < 2) {
4540         return length ? baseUniq(arrays[0]) : [];
4541       }
4542       var index = -1,
4543         result = Array(length);
4544
4545       while (++index < length) {
4546         var array = arrays[index],
4547           othIndex = -1;
4548
4549         while (++othIndex < length) {
4550           if (othIndex != index) {
4551             result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4552           }
4553         }
4554       }
4555       return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4556     }
4557
4558     /**
4559      * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
4560      *
4561      * @private
4562      * @param {Array} props The property identifiers.
4563      * @param {Array} values The property values.
4564      * @param {Function} assignFunc The function to assign values.
4565      * @returns {Object} Returns the new object.
4566      */
4567     function baseZipObject(props, values, assignFunc) {
4568       var index = -1,
4569         length = props.length,
4570         valsLength = values.length,
4571         result = {};
4572
4573       while (++index < length) {
4574         var value = index < valsLength ? values[index] : undefined;
4575         assignFunc(result, props[index], value);
4576       }
4577       return result;
4578     }
4579
4580     /**
4581      * Casts `value` to an empty array if it's not an array like object.
4582      *
4583      * @private
4584      * @param {*} value The value to inspect.
4585      * @returns {Array|Object} Returns the cast array-like object.
4586      */
4587     function castArrayLikeObject(value) {
4588       return isArrayLikeObject(value) ? value : [];
4589     }
4590
4591     /**
4592      * Casts `value` to `identity` if it's not a function.
4593      *
4594      * @private
4595      * @param {*} value The value to inspect.
4596      * @returns {Function} Returns cast function.
4597      */
4598     function castFunction(value) {
4599       return typeof value == 'function' ? value : identity;
4600     }
4601
4602     /**
4603      * Casts `value` to a path array if it's not one.
4604      *
4605      * @private
4606      * @param {*} value The value to inspect.
4607      * @param {Object} [object] The object to query keys on.
4608      * @returns {Array} Returns the cast property path array.
4609      */
4610     function castPath(value, object) {
4611       if (isArray(value)) {
4612         return value;
4613       }
4614       return isKey(value, object) ? [value] : stringToPath(toString(value));
4615     }
4616
4617     /**
4618      * A `baseRest` alias which can be replaced with `identity` by module
4619      * replacement plugins.
4620      *
4621      * @private
4622      * @type {Function}
4623      * @param {Function} func The function to apply a rest parameter to.
4624      * @returns {Function} Returns the new function.
4625      */
4626     var castRest = baseRest;
4627
4628     /**
4629      * Casts `array` to a slice if it's needed.
4630      *
4631      * @private
4632      * @param {Array} array The array to inspect.
4633      * @param {number} start The start position.
4634      * @param {number} [end=array.length] The end position.
4635      * @returns {Array} Returns the cast slice.
4636      */
4637     function castSlice(array, start, end) {
4638       var length = array.length;
4639       end = end === undefined ? length : end;
4640       return (!start && end >= length) ? array : baseSlice(array, start, end);
4641     }
4642
4643     /**
4644      * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4645      *
4646      * @private
4647      * @param {number|Object} id The timer id or timeout object of the timer to clear.
4648      */
4649     var clearTimeout = ctxClearTimeout || function(id) {
4650       return root.clearTimeout(id);
4651     };
4652
4653     /**
4654      * Creates a clone of  `buffer`.
4655      *
4656      * @private
4657      * @param {Buffer} buffer The buffer to clone.
4658      * @param {boolean} [isDeep] Specify a deep clone.
4659      * @returns {Buffer} Returns the cloned buffer.
4660      */
4661     function cloneBuffer(buffer, isDeep) {
4662       if (isDeep) {
4663         return buffer.slice();
4664       }
4665       var length = buffer.length,
4666         result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4667
4668       buffer.copy(result);
4669       return result;
4670     }
4671
4672     /**
4673      * Creates a clone of `arrayBuffer`.
4674      *
4675      * @private
4676      * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4677      * @returns {ArrayBuffer} Returns the cloned array buffer.
4678      */
4679     function cloneArrayBuffer(arrayBuffer) {
4680       var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4681       new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4682       return result;
4683     }
4684
4685     /**
4686      * Creates a clone of `dataView`.
4687      *
4688      * @private
4689      * @param {Object} dataView The data view to clone.
4690      * @param {boolean} [isDeep] Specify a deep clone.
4691      * @returns {Object} Returns the cloned data view.
4692      */
4693     function cloneDataView(dataView, isDeep) {
4694       var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4695       return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4696     }
4697
4698     /**
4699      * Creates a clone of `regexp`.
4700      *
4701      * @private
4702      * @param {Object} regexp The regexp to clone.
4703      * @returns {Object} Returns the cloned regexp.
4704      */
4705     function cloneRegExp(regexp) {
4706       var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4707       result.lastIndex = regexp.lastIndex;
4708       return result;
4709     }
4710
4711     /**
4712      * Creates a clone of the `symbol` object.
4713      *
4714      * @private
4715      * @param {Object} symbol The symbol object to clone.
4716      * @returns {Object} Returns the cloned symbol object.
4717      */
4718     function cloneSymbol(symbol) {
4719       return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4720     }
4721
4722     /**
4723      * Creates a clone of `typedArray`.
4724      *
4725      * @private
4726      * @param {Object} typedArray The typed array to clone.
4727      * @param {boolean} [isDeep] Specify a deep clone.
4728      * @returns {Object} Returns the cloned typed array.
4729      */
4730     function cloneTypedArray(typedArray, isDeep) {
4731       var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4732       return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4733     }
4734
4735     /**
4736      * Compares values to sort them in ascending order.
4737      *
4738      * @private
4739      * @param {*} value The value to compare.
4740      * @param {*} other The other value to compare.
4741      * @returns {number} Returns the sort order indicator for `value`.
4742      */
4743     function compareAscending(value, other) {
4744       if (value !== other) {
4745         var valIsDefined = value !== undefined,
4746           valIsNull = value === null,
4747           valIsReflexive = value === value,
4748           valIsSymbol = isSymbol(value);
4749
4750         var othIsDefined = other !== undefined,
4751           othIsNull = other === null,
4752           othIsReflexive = other === other,
4753           othIsSymbol = isSymbol(other);
4754
4755         if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4756           (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4757           (valIsNull && othIsDefined && othIsReflexive) ||
4758           (!valIsDefined && othIsReflexive) ||
4759           !valIsReflexive) {
4760           return 1;
4761         }
4762         if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4763           (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4764           (othIsNull && valIsDefined && valIsReflexive) ||
4765           (!othIsDefined && valIsReflexive) ||
4766           !othIsReflexive) {
4767           return -1;
4768         }
4769       }
4770       return 0;
4771     }
4772
4773     /**
4774      * Used by `_.orderBy` to compare multiple properties of a value to another
4775      * and stable sort them.
4776      *
4777      * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4778      * specify an order of "desc" for descending or "asc" for ascending sort order
4779      * of corresponding values.
4780      *
4781      * @private
4782      * @param {Object} object The object to compare.
4783      * @param {Object} other The other object to compare.
4784      * @param {boolean[]|string[]} orders The order to sort by for each property.
4785      * @returns {number} Returns the sort order indicator for `object`.
4786      */
4787     function compareMultiple(object, other, orders) {
4788       var index = -1,
4789         objCriteria = object.criteria,
4790         othCriteria = other.criteria,
4791         length = objCriteria.length,
4792         ordersLength = orders.length;
4793
4794       while (++index < length) {
4795         var result = compareAscending(objCriteria[index], othCriteria[index]);
4796         if (result) {
4797           if (index >= ordersLength) {
4798             return result;
4799           }
4800           var order = orders[index];
4801           return result * (order == 'desc' ? -1 : 1);
4802         }
4803       }
4804       // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
4805       // that causes it, under certain circumstances, to provide the same value for
4806       // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
4807       // for more details.
4808       //
4809       // This also ensures a stable sort in V8 and other engines.
4810       // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
4811       return object.index - other.index;
4812     }
4813
4814     /**
4815      * Creates an array that is the composition of partially applied arguments,
4816      * placeholders, and provided arguments into a single array of arguments.
4817      *
4818      * @private
4819      * @param {Array} args The provided arguments.
4820      * @param {Array} partials The arguments to prepend to those provided.
4821      * @param {Array} holders The `partials` placeholder indexes.
4822      * @params {boolean} [isCurried] Specify composing for a curried function.
4823      * @returns {Array} Returns the new array of composed arguments.
4824      */
4825     function composeArgs(args, partials, holders, isCurried) {
4826       var argsIndex = -1,
4827         argsLength = args.length,
4828         holdersLength = holders.length,
4829         leftIndex = -1,
4830         leftLength = partials.length,
4831         rangeLength = nativeMax(argsLength - holdersLength, 0),
4832         result = Array(leftLength + rangeLength),
4833         isUncurried = !isCurried;
4834
4835       while (++leftIndex < leftLength) {
4836         result[leftIndex] = partials[leftIndex];
4837       }
4838       while (++argsIndex < holdersLength) {
4839         if (isUncurried || argsIndex < argsLength) {
4840           result[holders[argsIndex]] = args[argsIndex];
4841         }
4842       }
4843       while (rangeLength--) {
4844         result[leftIndex++] = args[argsIndex++];
4845       }
4846       return result;
4847     }
4848
4849     /**
4850      * This function is like `composeArgs` except that the arguments composition
4851      * is tailored for `_.partialRight`.
4852      *
4853      * @private
4854      * @param {Array} args The provided arguments.
4855      * @param {Array} partials The arguments to append to those provided.
4856      * @param {Array} holders The `partials` placeholder indexes.
4857      * @params {boolean} [isCurried] Specify composing for a curried function.
4858      * @returns {Array} Returns the new array of composed arguments.
4859      */
4860     function composeArgsRight(args, partials, holders, isCurried) {
4861       var argsIndex = -1,
4862         argsLength = args.length,
4863         holdersIndex = -1,
4864         holdersLength = holders.length,
4865         rightIndex = -1,
4866         rightLength = partials.length,
4867         rangeLength = nativeMax(argsLength - holdersLength, 0),
4868         result = Array(rangeLength + rightLength),
4869         isUncurried = !isCurried;
4870
4871       while (++argsIndex < rangeLength) {
4872         result[argsIndex] = args[argsIndex];
4873       }
4874       var offset = argsIndex;
4875       while (++rightIndex < rightLength) {
4876         result[offset + rightIndex] = partials[rightIndex];
4877       }
4878       while (++holdersIndex < holdersLength) {
4879         if (isUncurried || argsIndex < argsLength) {
4880           result[offset + holders[holdersIndex]] = args[argsIndex++];
4881         }
4882       }
4883       return result;
4884     }
4885
4886     /**
4887      * Copies the values of `source` to `array`.
4888      *
4889      * @private
4890      * @param {Array} source The array to copy values from.
4891      * @param {Array} [array=[]] The array to copy values to.
4892      * @returns {Array} Returns `array`.
4893      */
4894     function copyArray(source, array) {
4895       var index = -1,
4896         length = source.length;
4897
4898       array || (array = Array(length));
4899       while (++index < length) {
4900         array[index] = source[index];
4901       }
4902       return array;
4903     }
4904
4905     /**
4906      * Copies properties of `source` to `object`.
4907      *
4908      * @private
4909      * @param {Object} source The object to copy properties from.
4910      * @param {Array} props The property identifiers to copy.
4911      * @param {Object} [object={}] The object to copy properties to.
4912      * @param {Function} [customizer] The function to customize copied values.
4913      * @returns {Object} Returns `object`.
4914      */
4915     function copyObject(source, props, object, customizer) {
4916       var isNew = !object;
4917       object || (object = {});
4918
4919       var index = -1,
4920         length = props.length;
4921
4922       while (++index < length) {
4923         var key = props[index];
4924
4925         var newValue = customizer ?
4926           customizer(object[key], source[key], key, object, source) :
4927           undefined;
4928
4929         if (newValue === undefined) {
4930           newValue = source[key];
4931         }
4932         if (isNew) {
4933           baseAssignValue(object, key, newValue);
4934         } else {
4935           assignValue(object, key, newValue);
4936         }
4937       }
4938       return object;
4939     }
4940
4941     /**
4942      * Copies own symbols of `source` to `object`.
4943      *
4944      * @private
4945      * @param {Object} source The object to copy symbols from.
4946      * @param {Object} [object={}] The object to copy symbols to.
4947      * @returns {Object} Returns `object`.
4948      */
4949     function copySymbols(source, object) {
4950       return copyObject(source, getSymbols(source), object);
4951     }
4952
4953     /**
4954      * Copies own and inherited symbols of `source` to `object`.
4955      *
4956      * @private
4957      * @param {Object} source The object to copy symbols from.
4958      * @param {Object} [object={}] The object to copy symbols to.
4959      * @returns {Object} Returns `object`.
4960      */
4961     function copySymbolsIn(source, object) {
4962       return copyObject(source, getSymbolsIn(source), object);
4963     }
4964
4965     /**
4966      * Creates a function like `_.groupBy`.
4967      *
4968      * @private
4969      * @param {Function} setter The function to set accumulator values.
4970      * @param {Function} [initializer] The accumulator object initializer.
4971      * @returns {Function} Returns the new aggregator function.
4972      */
4973     function createAggregator(setter, initializer) {
4974       return function(collection, iteratee) {
4975         var func = isArray(collection) ? arrayAggregator : baseAggregator,
4976           accumulator = initializer ? initializer() : {};
4977
4978         return func(collection, setter, getIteratee(iteratee, 2), accumulator);
4979       };
4980     }
4981
4982     /**
4983      * Creates a function like `_.assign`.
4984      *
4985      * @private
4986      * @param {Function} assigner The function to assign values.
4987      * @returns {Function} Returns the new assigner function.
4988      */
4989     function createAssigner(assigner) {
4990       return baseRest(function(object, sources) {
4991         var index = -1,
4992           length = sources.length,
4993           customizer = length > 1 ? sources[length - 1] : undefined,
4994           guard = length > 2 ? sources[2] : undefined;
4995
4996         customizer = (assigner.length > 3 && typeof customizer == 'function') ?
4997           (length--, customizer) :
4998           undefined;
4999
5000         if (guard && isIterateeCall(sources[0], sources[1], guard)) {
5001           customizer = length < 3 ? undefined : customizer;
5002           length = 1;
5003         }
5004         object = Object(object);
5005         while (++index < length) {
5006           var source = sources[index];
5007           if (source) {
5008             assigner(object, source, index, customizer);
5009           }
5010         }
5011         return object;
5012       });
5013     }
5014
5015     /**
5016      * Creates a `baseEach` or `baseEachRight` function.
5017      *
5018      * @private
5019      * @param {Function} eachFunc The function to iterate over a collection.
5020      * @param {boolean} [fromRight] Specify iterating from right to left.
5021      * @returns {Function} Returns the new base function.
5022      */
5023     function createBaseEach(eachFunc, fromRight) {
5024       return function(collection, iteratee) {
5025         if (collection == null) {
5026           return collection;
5027         }
5028         if (!isArrayLike(collection)) {
5029           return eachFunc(collection, iteratee);
5030         }
5031         var length = collection.length,
5032           index = fromRight ? length : -1,
5033           iterable = Object(collection);
5034
5035         while ((fromRight ? index-- : ++index < length)) {
5036           if (iteratee(iterable[index], index, iterable) === false) {
5037             break;
5038           }
5039         }
5040         return collection;
5041       };
5042     }
5043
5044     /**
5045      * Creates a base function for methods like `_.forIn` and `_.forOwn`.
5046      *
5047      * @private
5048      * @param {boolean} [fromRight] Specify iterating from right to left.
5049      * @returns {Function} Returns the new base function.
5050      */
5051     function createBaseFor(fromRight) {
5052       return function(object, iteratee, keysFunc) {
5053         var index = -1,
5054           iterable = Object(object),
5055           props = keysFunc(object),
5056           length = props.length;
5057
5058         while (length--) {
5059           var key = props[fromRight ? length : ++index];
5060           if (iteratee(iterable[key], key, iterable) === false) {
5061             break;
5062           }
5063         }
5064         return object;
5065       };
5066     }
5067
5068     /**
5069      * Creates a function that wraps `func` to invoke it with the optional `this`
5070      * binding of `thisArg`.
5071      *
5072      * @private
5073      * @param {Function} func The function to wrap.
5074      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5075      * @param {*} [thisArg] The `this` binding of `func`.
5076      * @returns {Function} Returns the new wrapped function.
5077      */
5078     function createBind(func, bitmask, thisArg) {
5079       var isBind = bitmask & WRAP_BIND_FLAG,
5080         Ctor = createCtor(func);
5081
5082       function wrapper() {
5083         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5084         return fn.apply(isBind ? thisArg : this, arguments);
5085       }
5086       return wrapper;
5087     }
5088
5089     /**
5090      * Creates a function like `_.lowerFirst`.
5091      *
5092      * @private
5093      * @param {string} methodName The name of the `String` case method to use.
5094      * @returns {Function} Returns the new case function.
5095      */
5096     function createCaseFirst(methodName) {
5097       return function(string) {
5098         string = toString(string);
5099
5100         var strSymbols = hasUnicode(string) ?
5101           stringToArray(string) :
5102           undefined;
5103
5104         var chr = strSymbols ?
5105           strSymbols[0] :
5106           string.charAt(0);
5107
5108         var trailing = strSymbols ?
5109           castSlice(strSymbols, 1).join('') :
5110           string.slice(1);
5111
5112         return chr[methodName]() + trailing;
5113       };
5114     }
5115
5116     /**
5117      * Creates a function like `_.camelCase`.
5118      *
5119      * @private
5120      * @param {Function} callback The function to combine each word.
5121      * @returns {Function} Returns the new compounder function.
5122      */
5123     function createCompounder(callback) {
5124       return function(string) {
5125         return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
5126       };
5127     }
5128
5129     /**
5130      * Creates a function that produces an instance of `Ctor` regardless of
5131      * whether it was invoked as part of a `new` expression or by `call` or `apply`.
5132      *
5133      * @private
5134      * @param {Function} Ctor The constructor to wrap.
5135      * @returns {Function} Returns the new wrapped function.
5136      */
5137     function createCtor(Ctor) {
5138       return function() {
5139         // Use a `switch` statement to work with class constructors. See
5140         // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
5141         // for more details.
5142         var args = arguments;
5143         switch (args.length) {
5144           case 0:
5145             return new Ctor;
5146           case 1:
5147             return new Ctor(args[0]);
5148           case 2:
5149             return new Ctor(args[0], args[1]);
5150           case 3:
5151             return new Ctor(args[0], args[1], args[2]);
5152           case 4:
5153             return new Ctor(args[0], args[1], args[2], args[3]);
5154           case 5:
5155             return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5156           case 6:
5157             return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5158           case 7:
5159             return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5160         }
5161         var thisBinding = baseCreate(Ctor.prototype),
5162           result = Ctor.apply(thisBinding, args);
5163
5164         // Mimic the constructor's `return` behavior.
5165         // See https://es5.github.io/#x13.2.2 for more details.
5166         return isObject(result) ? result : thisBinding;
5167       };
5168     }
5169
5170     /**
5171      * Creates a function that wraps `func` to enable currying.
5172      *
5173      * @private
5174      * @param {Function} func The function to wrap.
5175      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5176      * @param {number} arity The arity of `func`.
5177      * @returns {Function} Returns the new wrapped function.
5178      */
5179     function createCurry(func, bitmask, arity) {
5180       var Ctor = createCtor(func);
5181
5182       function wrapper() {
5183         var length = arguments.length,
5184           args = Array(length),
5185           index = length,
5186           placeholder = getHolder(wrapper);
5187
5188         while (index--) {
5189           args[index] = arguments[index];
5190         }
5191         var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) ? [] :
5192           replaceHolders(args, placeholder);
5193
5194         length -= holders.length;
5195         if (length < arity) {
5196           return createRecurry(
5197             func, bitmask, createHybrid, wrapper.placeholder, undefined,
5198             args, holders, undefined, undefined, arity - length);
5199         }
5200         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5201         return apply(fn, this, args);
5202       }
5203       return wrapper;
5204     }
5205
5206     /**
5207      * Creates a `_.find` or `_.findLast` function.
5208      *
5209      * @private
5210      * @param {Function} findIndexFunc The function to find the collection index.
5211      * @returns {Function} Returns the new find function.
5212      */
5213     function createFind(findIndexFunc) {
5214       return function(collection, predicate, fromIndex) {
5215         var iterable = Object(collection);
5216         if (!isArrayLike(collection)) {
5217           var iteratee = getIteratee(predicate, 3);
5218           collection = keys(collection);
5219           predicate = function(key) {
5220             return iteratee(iterable[key], key, iterable);
5221           };
5222         }
5223         var index = findIndexFunc(collection, predicate, fromIndex);
5224         return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
5225       };
5226     }
5227
5228     /**
5229      * Creates a `_.flow` or `_.flowRight` function.
5230      *
5231      * @private
5232      * @param {boolean} [fromRight] Specify iterating from right to left.
5233      * @returns {Function} Returns the new flow function.
5234      */
5235     function createFlow(fromRight) {
5236       return flatRest(function(funcs) {
5237         var length = funcs.length,
5238           index = length,
5239           prereq = LodashWrapper.prototype.thru;
5240
5241         if (fromRight) {
5242           funcs.reverse();
5243         }
5244         while (index--) {
5245           var func = funcs[index];
5246           if (typeof func != 'function') {
5247             throw new TypeError(FUNC_ERROR_TEXT);
5248           }
5249           if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5250             var wrapper = new LodashWrapper([], true);
5251           }
5252         }
5253         index = wrapper ? index : length;
5254         while (++index < length) {
5255           func = funcs[index];
5256
5257           var funcName = getFuncName(func),
5258             data = funcName == 'wrapper' ? getData(func) : undefined;
5259
5260           if (data && isLaziable(data[0]) &&
5261             data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
5262             !data[4].length && data[9] == 1
5263           ) {
5264             wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5265           } else {
5266             wrapper = (func.length == 1 && isLaziable(func)) ?
5267               wrapper[funcName]() :
5268               wrapper.thru(func);
5269           }
5270         }
5271         return function() {
5272           var args = arguments,
5273             value = args[0];
5274
5275           if (wrapper && args.length == 1 && isArray(value)) {
5276             return wrapper.plant(value).value();
5277           }
5278           var index = 0,
5279             result = length ? funcs[index].apply(this, args) : value;
5280
5281           while (++index < length) {
5282             result = funcs[index].call(this, result);
5283           }
5284           return result;
5285         };
5286       });
5287     }
5288
5289     /**
5290      * Creates a function that wraps `func` to invoke it with optional `this`
5291      * binding of `thisArg`, partial application, and currying.
5292      *
5293      * @private
5294      * @param {Function|string} func The function or method name to wrap.
5295      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5296      * @param {*} [thisArg] The `this` binding of `func`.
5297      * @param {Array} [partials] The arguments to prepend to those provided to
5298      *  the new function.
5299      * @param {Array} [holders] The `partials` placeholder indexes.
5300      * @param {Array} [partialsRight] The arguments to append to those provided
5301      *  to the new function.
5302      * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
5303      * @param {Array} [argPos] The argument positions of the new function.
5304      * @param {number} [ary] The arity cap of `func`.
5305      * @param {number} [arity] The arity of `func`.
5306      * @returns {Function} Returns the new wrapped function.
5307      */
5308     function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5309       var isAry = bitmask & WRAP_ARY_FLAG,
5310         isBind = bitmask & WRAP_BIND_FLAG,
5311         isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
5312         isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
5313         isFlip = bitmask & WRAP_FLIP_FLAG,
5314         Ctor = isBindKey ? undefined : createCtor(func);
5315
5316       function wrapper() {
5317         var length = arguments.length,
5318           args = Array(length),
5319           index = length;
5320
5321         while (index--) {
5322           args[index] = arguments[index];
5323         }
5324         if (isCurried) {
5325           var placeholder = getHolder(wrapper),
5326             holdersCount = countHolders(args, placeholder);
5327         }
5328         if (partials) {
5329           args = composeArgs(args, partials, holders, isCurried);
5330         }
5331         if (partialsRight) {
5332           args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
5333         }
5334         length -= holdersCount;
5335         if (isCurried && length < arity) {
5336           var newHolders = replaceHolders(args, placeholder);
5337           return createRecurry(
5338             func, bitmask, createHybrid, wrapper.placeholder, thisArg,
5339             args, newHolders, argPos, ary, arity - length
5340           );
5341         }
5342         var thisBinding = isBind ? thisArg : this,
5343           fn = isBindKey ? thisBinding[func] : func;
5344
5345         length = args.length;
5346         if (argPos) {
5347           args = reorder(args, argPos);
5348         } else if (isFlip && length > 1) {
5349           args.reverse();
5350         }
5351         if (isAry && ary < length) {
5352           args.length = ary;
5353         }
5354         if (this && this !== root && this instanceof wrapper) {
5355           fn = Ctor || createCtor(fn);
5356         }
5357         return fn.apply(thisBinding, args);
5358       }
5359       return wrapper;
5360     }
5361
5362     /**
5363      * Creates a function like `_.invertBy`.
5364      *
5365      * @private
5366      * @param {Function} setter The function to set accumulator values.
5367      * @param {Function} toIteratee The function to resolve iteratees.
5368      * @returns {Function} Returns the new inverter function.
5369      */
5370     function createInverter(setter, toIteratee) {
5371       return function(object, iteratee) {
5372         return baseInverter(object, setter, toIteratee(iteratee), {});
5373       };
5374     }
5375
5376     /**
5377      * Creates a function that performs a mathematical operation on two values.
5378      *
5379      * @private
5380      * @param {Function} operator The function to perform the operation.
5381      * @param {number} [defaultValue] The value used for `undefined` arguments.
5382      * @returns {Function} Returns the new mathematical operation function.
5383      */
5384     function createMathOperation(operator, defaultValue) {
5385       return function(value, other) {
5386         var result;
5387         if (value === undefined && other === undefined) {
5388           return defaultValue;
5389         }
5390         if (value !== undefined) {
5391           result = value;
5392         }
5393         if (other !== undefined) {
5394           if (result === undefined) {
5395             return other;
5396           }
5397           if (typeof value == 'string' || typeof other == 'string') {
5398             value = baseToString(value);
5399             other = baseToString(other);
5400           } else {
5401             value = baseToNumber(value);
5402             other = baseToNumber(other);
5403           }
5404           result = operator(value, other);
5405         }
5406         return result;
5407       };
5408     }
5409
5410     /**
5411      * Creates a function like `_.over`.
5412      *
5413      * @private
5414      * @param {Function} arrayFunc The function to iterate over iteratees.
5415      * @returns {Function} Returns the new over function.
5416      */
5417     function createOver(arrayFunc) {
5418       return flatRest(function(iteratees) {
5419         iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5420         return baseRest(function(args) {
5421           var thisArg = this;
5422           return arrayFunc(iteratees, function(iteratee) {
5423             return apply(iteratee, thisArg, args);
5424           });
5425         });
5426       });
5427     }
5428
5429     /**
5430      * Creates the padding for `string` based on `length`. The `chars` string
5431      * is truncated if the number of characters exceeds `length`.
5432      *
5433      * @private
5434      * @param {number} length The padding length.
5435      * @param {string} [chars=' '] The string used as padding.
5436      * @returns {string} Returns the padding for `string`.
5437      */
5438     function createPadding(length, chars) {
5439       chars = chars === undefined ? ' ' : baseToString(chars);
5440
5441       var charsLength = chars.length;
5442       if (charsLength < 2) {
5443         return charsLength ? baseRepeat(chars, length) : chars;
5444       }
5445       var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
5446       return hasUnicode(chars) ?
5447         castSlice(stringToArray(result), 0, length).join('') :
5448         result.slice(0, length);
5449     }
5450
5451     /**
5452      * Creates a function that wraps `func` to invoke it with the `this` binding
5453      * of `thisArg` and `partials` prepended to the arguments it receives.
5454      *
5455      * @private
5456      * @param {Function} func The function to wrap.
5457      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5458      * @param {*} thisArg The `this` binding of `func`.
5459      * @param {Array} partials The arguments to prepend to those provided to
5460      *  the new function.
5461      * @returns {Function} Returns the new wrapped function.
5462      */
5463     function createPartial(func, bitmask, thisArg, partials) {
5464       var isBind = bitmask & WRAP_BIND_FLAG,
5465         Ctor = createCtor(func);
5466
5467       function wrapper() {
5468         var argsIndex = -1,
5469           argsLength = arguments.length,
5470           leftIndex = -1,
5471           leftLength = partials.length,
5472           args = Array(leftLength + argsLength),
5473           fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5474
5475         while (++leftIndex < leftLength) {
5476           args[leftIndex] = partials[leftIndex];
5477         }
5478         while (argsLength--) {
5479           args[leftIndex++] = arguments[++argsIndex];
5480         }
5481         return apply(fn, isBind ? thisArg : this, args);
5482       }
5483       return wrapper;
5484     }
5485
5486     /**
5487      * Creates a `_.range` or `_.rangeRight` function.
5488      *
5489      * @private
5490      * @param {boolean} [fromRight] Specify iterating from right to left.
5491      * @returns {Function} Returns the new range function.
5492      */
5493     function createRange(fromRight) {
5494       return function(start, end, step) {
5495         if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5496           end = step = undefined;
5497         }
5498         // Ensure the sign of `-0` is preserved.
5499         start = toFinite(start);
5500         if (end === undefined) {
5501           end = start;
5502           start = 0;
5503         } else {
5504           end = toFinite(end);
5505         }
5506         step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
5507         return baseRange(start, end, step, fromRight);
5508       };
5509     }
5510
5511     /**
5512      * Creates a function that performs a relational operation on two values.
5513      *
5514      * @private
5515      * @param {Function} operator The function to perform the operation.
5516      * @returns {Function} Returns the new relational operation function.
5517      */
5518     function createRelationalOperation(operator) {
5519       return function(value, other) {
5520         if (!(typeof value == 'string' && typeof other == 'string')) {
5521           value = toNumber(value);
5522           other = toNumber(other);
5523         }
5524         return operator(value, other);
5525       };
5526     }
5527
5528     /**
5529      * Creates a function that wraps `func` to continue currying.
5530      *
5531      * @private
5532      * @param {Function} func The function to wrap.
5533      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5534      * @param {Function} wrapFunc The function to create the `func` wrapper.
5535      * @param {*} placeholder The placeholder value.
5536      * @param {*} [thisArg] The `this` binding of `func`.
5537      * @param {Array} [partials] The arguments to prepend to those provided to
5538      *  the new function.
5539      * @param {Array} [holders] The `partials` placeholder indexes.
5540      * @param {Array} [argPos] The argument positions of the new function.
5541      * @param {number} [ary] The arity cap of `func`.
5542      * @param {number} [arity] The arity of `func`.
5543      * @returns {Function} Returns the new wrapped function.
5544      */
5545     function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
5546       var isCurry = bitmask & WRAP_CURRY_FLAG,
5547         newHolders = isCurry ? holders : undefined,
5548         newHoldersRight = isCurry ? undefined : holders,
5549         newPartials = isCurry ? partials : undefined,
5550         newPartialsRight = isCurry ? undefined : partials;
5551
5552       bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
5553       bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
5554
5555       if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
5556         bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
5557       }
5558       var newData = [
5559         func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5560         newHoldersRight, argPos, ary, arity
5561       ];
5562
5563       var result = wrapFunc.apply(undefined, newData);
5564       if (isLaziable(func)) {
5565         setData(result, newData);
5566       }
5567       result.placeholder = placeholder;
5568       return setWrapToString(result, func, bitmask);
5569     }
5570
5571     /**
5572      * Creates a function like `_.round`.
5573      *
5574      * @private
5575      * @param {string} methodName The name of the `Math` method to use when rounding.
5576      * @returns {Function} Returns the new round function.
5577      */
5578     function createRound(methodName) {
5579       var func = Math[methodName];
5580       return function(number, precision) {
5581         number = toNumber(number);
5582         precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
5583         if (precision && nativeIsFinite(number)) {
5584           // Shift with exponential notation to avoid floating-point issues.
5585           // See [MDN](https://mdn.io/round#Examples) for more details.
5586           var pair = (toString(number) + 'e').split('e'),
5587             value = func(pair[0] + 'e' + (+pair[1] + precision));
5588
5589           pair = (toString(value) + 'e').split('e');
5590           return +(pair[0] + 'e' + (+pair[1] - precision));
5591         }
5592         return func(number);
5593       };
5594     }
5595
5596     /**
5597      * Creates a set object of `values`.
5598      *
5599      * @private
5600      * @param {Array} values The values to add to the set.
5601      * @returns {Object} Returns the new set.
5602      */
5603     var createSet = !(Set && (1 / setToArray(new Set([, -0]))[1]) == INFINITY) ? noop : function(values) {
5604       return new Set(values);
5605     };
5606
5607     /**
5608      * Creates a `_.toPairs` or `_.toPairsIn` function.
5609      *
5610      * @private
5611      * @param {Function} keysFunc The function to get the keys of a given object.
5612      * @returns {Function} Returns the new pairs function.
5613      */
5614     function createToPairs(keysFunc) {
5615       return function(object) {
5616         var tag = getTag(object);
5617         if (tag == mapTag) {
5618           return mapToArray(object);
5619         }
5620         if (tag == setTag) {
5621           return setToPairs(object);
5622         }
5623         return baseToPairs(object, keysFunc(object));
5624       };
5625     }
5626
5627     /**
5628      * Creates a function that either curries or invokes `func` with optional
5629      * `this` binding and partially applied arguments.
5630      *
5631      * @private
5632      * @param {Function|string} func The function or method name to wrap.
5633      * @param {number} bitmask The bitmask flags.
5634      *    1 - `_.bind`
5635      *    2 - `_.bindKey`
5636      *    4 - `_.curry` or `_.curryRight` of a bound function
5637      *    8 - `_.curry`
5638      *   16 - `_.curryRight`
5639      *   32 - `_.partial`
5640      *   64 - `_.partialRight`
5641      *  128 - `_.rearg`
5642      *  256 - `_.ary`
5643      *  512 - `_.flip`
5644      * @param {*} [thisArg] The `this` binding of `func`.
5645      * @param {Array} [partials] The arguments to be partially applied.
5646      * @param {Array} [holders] The `partials` placeholder indexes.
5647      * @param {Array} [argPos] The argument positions of the new function.
5648      * @param {number} [ary] The arity cap of `func`.
5649      * @param {number} [arity] The arity of `func`.
5650      * @returns {Function} Returns the new wrapped function.
5651      */
5652     function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5653       var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
5654       if (!isBindKey && typeof func != 'function') {
5655         throw new TypeError(FUNC_ERROR_TEXT);
5656       }
5657       var length = partials ? partials.length : 0;
5658       if (!length) {
5659         bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
5660         partials = holders = undefined;
5661       }
5662       ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
5663       arity = arity === undefined ? arity : toInteger(arity);
5664       length -= holders ? holders.length : 0;
5665
5666       if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
5667         var partialsRight = partials,
5668           holdersRight = holders;
5669
5670         partials = holders = undefined;
5671       }
5672       var data = isBindKey ? undefined : getData(func);
5673
5674       var newData = [
5675         func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5676         argPos, ary, arity
5677       ];
5678
5679       if (data) {
5680         mergeData(newData, data);
5681       }
5682       func = newData[0];
5683       bitmask = newData[1];
5684       thisArg = newData[2];
5685       partials = newData[3];
5686       holders = newData[4];
5687       arity = newData[9] = newData[9] === undefined ?
5688         (isBindKey ? 0 : func.length) :
5689         nativeMax(newData[9] - length, 0);
5690
5691       if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
5692         bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
5693       }
5694       if (!bitmask || bitmask == WRAP_BIND_FLAG) {
5695         var result = createBind(func, bitmask, thisArg);
5696       } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
5697         result = createCurry(func, bitmask, arity);
5698       } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
5699         result = createPartial(func, bitmask, thisArg, partials);
5700       } else {
5701         result = createHybrid.apply(undefined, newData);
5702       }
5703       var setter = data ? baseSetData : setData;
5704       return setWrapToString(setter(result, newData), func, bitmask);
5705     }
5706
5707     /**
5708      * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
5709      * of source objects to the destination object for all destination properties
5710      * that resolve to `undefined`.
5711      *
5712      * @private
5713      * @param {*} objValue The destination value.
5714      * @param {*} srcValue The source value.
5715      * @param {string} key The key of the property to assign.
5716      * @param {Object} object The parent object of `objValue`.
5717      * @returns {*} Returns the value to assign.
5718      */
5719     function customDefaultsAssignIn(objValue, srcValue, key, object) {
5720       if (objValue === undefined ||
5721         (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
5722         return srcValue;
5723       }
5724       return objValue;
5725     }
5726
5727     /**
5728      * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
5729      * objects into destination objects that are passed thru.
5730      *
5731      * @private
5732      * @param {*} objValue The destination value.
5733      * @param {*} srcValue The source value.
5734      * @param {string} key The key of the property to merge.
5735      * @param {Object} object The parent object of `objValue`.
5736      * @param {Object} source The parent object of `srcValue`.
5737      * @param {Object} [stack] Tracks traversed source values and their merged
5738      *  counterparts.
5739      * @returns {*} Returns the value to assign.
5740      */
5741     function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
5742       if (isObject(objValue) && isObject(srcValue)) {
5743         // Recursively merge objects and arrays (susceptible to call stack limits).
5744         stack.set(srcValue, objValue);
5745         baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
5746         stack['delete'](srcValue);
5747       }
5748       return objValue;
5749     }
5750
5751     /**
5752      * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
5753      * objects.
5754      *
5755      * @private
5756      * @param {*} value The value to inspect.
5757      * @param {string} key The key of the property to inspect.
5758      * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
5759      */
5760     function customOmitClone(value) {
5761       return isPlainObject(value) ? undefined : value;
5762     }
5763
5764     /**
5765      * A specialized version of `baseIsEqualDeep` for arrays with support for
5766      * partial deep comparisons.
5767      *
5768      * @private
5769      * @param {Array} array The array to compare.
5770      * @param {Array} other The other array to compare.
5771      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5772      * @param {Function} customizer The function to customize comparisons.
5773      * @param {Function} equalFunc The function to determine equivalents of values.
5774      * @param {Object} stack Tracks traversed `array` and `other` objects.
5775      * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
5776      */
5777     function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
5778       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5779         arrLength = array.length,
5780         othLength = other.length;
5781
5782       if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5783         return false;
5784       }
5785       // Check that cyclic values are equal.
5786       var arrStacked = stack.get(array);
5787       var othStacked = stack.get(other);
5788       if (arrStacked && othStacked) {
5789         return arrStacked == other && othStacked == array;
5790       }
5791       var index = -1,
5792         result = true,
5793         seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
5794
5795       stack.set(array, other);
5796       stack.set(other, array);
5797
5798       // Ignore non-index properties.
5799       while (++index < arrLength) {
5800         var arrValue = array[index],
5801           othValue = other[index];
5802
5803         if (customizer) {
5804           var compared = isPartial ?
5805             customizer(othValue, arrValue, index, other, array, stack) :
5806             customizer(arrValue, othValue, index, array, other, stack);
5807         }
5808         if (compared !== undefined) {
5809           if (compared) {
5810             continue;
5811           }
5812           result = false;
5813           break;
5814         }
5815         // Recursively compare arrays (susceptible to call stack limits).
5816         if (seen) {
5817           if (!arraySome(other, function(othValue, othIndex) {
5818               if (!cacheHas(seen, othIndex) &&
5819                 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
5820                 return seen.push(othIndex);
5821               }
5822             })) {
5823             result = false;
5824             break;
5825           }
5826         } else if (!(
5827             arrValue === othValue ||
5828             equalFunc(arrValue, othValue, bitmask, customizer, stack)
5829           )) {
5830           result = false;
5831           break;
5832         }
5833       }
5834       stack['delete'](array);
5835       stack['delete'](other);
5836       return result;
5837     }
5838
5839     /**
5840      * A specialized version of `baseIsEqualDeep` for comparing objects of
5841      * the same `toStringTag`.
5842      *
5843      * **Note:** This function only supports comparing values with tags of
5844      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5845      *
5846      * @private
5847      * @param {Object} object The object to compare.
5848      * @param {Object} other The other object to compare.
5849      * @param {string} tag The `toStringTag` of the objects to compare.
5850      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5851      * @param {Function} customizer The function to customize comparisons.
5852      * @param {Function} equalFunc The function to determine equivalents of values.
5853      * @param {Object} stack Tracks traversed `object` and `other` objects.
5854      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5855      */
5856     function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
5857       switch (tag) {
5858         case dataViewTag:
5859           if ((object.byteLength != other.byteLength) ||
5860             (object.byteOffset != other.byteOffset)) {
5861             return false;
5862           }
5863           object = object.buffer;
5864           other = other.buffer;
5865
5866         case arrayBufferTag:
5867           if ((object.byteLength != other.byteLength) ||
5868             !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5869             return false;
5870           }
5871           return true;
5872
5873         case boolTag:
5874         case dateTag:
5875         case numberTag:
5876           // Coerce booleans to `1` or `0` and dates to milliseconds.
5877           // Invalid dates are coerced to `NaN`.
5878           return eq(+object, +other);
5879
5880         case errorTag:
5881           return object.name == other.name && object.message == other.message;
5882
5883         case regexpTag:
5884         case stringTag:
5885           // Coerce regexes to strings and treat strings, primitives and objects,
5886           // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
5887           // for more details.
5888           return object == (other + '');
5889
5890         case mapTag:
5891           var convert = mapToArray;
5892
5893         case setTag:
5894           var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
5895           convert || (convert = setToArray);
5896
5897           if (object.size != other.size && !isPartial) {
5898             return false;
5899           }
5900           // Assume cyclic values are equal.
5901           var stacked = stack.get(object);
5902           if (stacked) {
5903             return stacked == other;
5904           }
5905           bitmask |= COMPARE_UNORDERED_FLAG;
5906
5907           // Recursively compare objects (susceptible to call stack limits).
5908           stack.set(object, other);
5909           var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
5910           stack['delete'](object);
5911           return result;
5912
5913         case symbolTag:
5914           if (symbolValueOf) {
5915             return symbolValueOf.call(object) == symbolValueOf.call(other);
5916           }
5917       }
5918       return false;
5919     }
5920
5921     /**
5922      * A specialized version of `baseIsEqualDeep` for objects with support for
5923      * partial deep comparisons.
5924      *
5925      * @private
5926      * @param {Object} object The object to compare.
5927      * @param {Object} other The other object to compare.
5928      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5929      * @param {Function} customizer The function to customize comparisons.
5930      * @param {Function} equalFunc The function to determine equivalents of values.
5931      * @param {Object} stack Tracks traversed `object` and `other` objects.
5932      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5933      */
5934     function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
5935       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5936         objProps = getAllKeys(object),
5937         objLength = objProps.length,
5938         othProps = getAllKeys(other),
5939         othLength = othProps.length;
5940
5941       if (objLength != othLength && !isPartial) {
5942         return false;
5943       }
5944       var index = objLength;
5945       while (index--) {
5946         var key = objProps[index];
5947         if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
5948           return false;
5949         }
5950       }
5951       // Check that cyclic values are equal.
5952       var objStacked = stack.get(object);
5953       var othStacked = stack.get(other);
5954       if (objStacked && othStacked) {
5955         return objStacked == other && othStacked == object;
5956       }
5957       var result = true;
5958       stack.set(object, other);
5959       stack.set(other, object);
5960
5961       var skipCtor = isPartial;
5962       while (++index < objLength) {
5963         key = objProps[index];
5964         var objValue = object[key],
5965           othValue = other[key];
5966
5967         if (customizer) {
5968           var compared = isPartial ?
5969             customizer(othValue, objValue, key, other, object, stack) :
5970             customizer(objValue, othValue, key, object, other, stack);
5971         }
5972         // Recursively compare objects (susceptible to call stack limits).
5973         if (!(compared === undefined ?
5974             (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) :
5975             compared
5976           )) {
5977           result = false;
5978           break;
5979         }
5980         skipCtor || (skipCtor = key == 'constructor');
5981       }
5982       if (result && !skipCtor) {
5983         var objCtor = object.constructor,
5984           othCtor = other.constructor;
5985
5986         // Non `Object` object instances with different constructors are not equal.
5987         if (objCtor != othCtor &&
5988           ('constructor' in object && 'constructor' in other) &&
5989           !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
5990             typeof othCtor == 'function' && othCtor instanceof othCtor)) {
5991           result = false;
5992         }
5993       }
5994       stack['delete'](object);
5995       stack['delete'](other);
5996       return result;
5997     }
5998
5999     /**
6000      * A specialized version of `baseRest` which flattens the rest array.
6001      *
6002      * @private
6003      * @param {Function} func The function to apply a rest parameter to.
6004      * @returns {Function} Returns the new function.
6005      */
6006     function flatRest(func) {
6007       return setToString(overRest(func, undefined, flatten), func + '');
6008     }
6009
6010     /**
6011      * Creates an array of own enumerable property names and symbols of `object`.
6012      *
6013      * @private
6014      * @param {Object} object The object to query.
6015      * @returns {Array} Returns the array of property names and symbols.
6016      */
6017     function getAllKeys(object) {
6018       return baseGetAllKeys(object, keys, getSymbols);
6019     }
6020
6021     /**
6022      * Creates an array of own and inherited enumerable property names and
6023      * symbols of `object`.
6024      *
6025      * @private
6026      * @param {Object} object The object to query.
6027      * @returns {Array} Returns the array of property names and symbols.
6028      */
6029     function getAllKeysIn(object) {
6030       return baseGetAllKeys(object, keysIn, getSymbolsIn);
6031     }
6032
6033     /**
6034      * Gets metadata for `func`.
6035      *
6036      * @private
6037      * @param {Function} func The function to query.
6038      * @returns {*} Returns the metadata for `func`.
6039      */
6040     var getData = !metaMap ? noop : function(func) {
6041       return metaMap.get(func);
6042     };
6043
6044     /**
6045      * Gets the name of `func`.
6046      *
6047      * @private
6048      * @param {Function} func The function to query.
6049      * @returns {string} Returns the function name.
6050      */
6051     function getFuncName(func) {
6052       var result = (func.name + ''),
6053         array = realNames[result],
6054         length = hasOwnProperty.call(realNames, result) ? array.length : 0;
6055
6056       while (length--) {
6057         var data = array[length],
6058           otherFunc = data.func;
6059         if (otherFunc == null || otherFunc == func) {
6060           return data.name;
6061         }
6062       }
6063       return result;
6064     }
6065
6066     /**
6067      * Gets the argument placeholder value for `func`.
6068      *
6069      * @private
6070      * @param {Function} func The function to inspect.
6071      * @returns {*} Returns the placeholder value.
6072      */
6073     function getHolder(func) {
6074       var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
6075       return object.placeholder;
6076     }
6077
6078     /**
6079      * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
6080      * this function returns the custom method, otherwise it returns `baseIteratee`.
6081      * If arguments are provided, the chosen function is invoked with them and
6082      * its result is returned.
6083      *
6084      * @private
6085      * @param {*} [value] The value to convert to an iteratee.
6086      * @param {number} [arity] The arity of the created iteratee.
6087      * @returns {Function} Returns the chosen function or its result.
6088      */
6089     function getIteratee() {
6090       var result = lodash.iteratee || iteratee;
6091       result = result === iteratee ? baseIteratee : result;
6092       return arguments.length ? result(arguments[0], arguments[1]) : result;
6093     }
6094
6095     /**
6096      * Gets the data for `map`.
6097      *
6098      * @private
6099      * @param {Object} map The map to query.
6100      * @param {string} key The reference key.
6101      * @returns {*} Returns the map data.
6102      */
6103     function getMapData(map, key) {
6104       var data = map.__data__;
6105       return isKeyable(key) ?
6106         data[typeof key == 'string' ? 'string' : 'hash'] :
6107         data.map;
6108     }
6109
6110     /**
6111      * Gets the property names, values, and compare flags of `object`.
6112      *
6113      * @private
6114      * @param {Object} object The object to query.
6115      * @returns {Array} Returns the match data of `object`.
6116      */
6117     function getMatchData(object) {
6118       var result = keys(object),
6119         length = result.length;
6120
6121       while (length--) {
6122         var key = result[length],
6123           value = object[key];
6124
6125         result[length] = [key, value, isStrictComparable(value)];
6126       }
6127       return result;
6128     }
6129
6130     /**
6131      * Gets the native function at `key` of `object`.
6132      *
6133      * @private
6134      * @param {Object} object The object to query.
6135      * @param {string} key The key of the method to get.
6136      * @returns {*} Returns the function if it's native, else `undefined`.
6137      */
6138     function getNative(object, key) {
6139       var value = getValue(object, key);
6140       return baseIsNative(value) ? value : undefined;
6141     }
6142
6143     /**
6144      * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
6145      *
6146      * @private
6147      * @param {*} value The value to query.
6148      * @returns {string} Returns the raw `toStringTag`.
6149      */
6150     function getRawTag(value) {
6151       var isOwn = hasOwnProperty.call(value, symToStringTag),
6152         tag = value[symToStringTag];
6153
6154       try {
6155         value[symToStringTag] = undefined;
6156         var unmasked = true;
6157       } catch (e) {}
6158
6159       var result = nativeObjectToString.call(value);
6160       if (unmasked) {
6161         if (isOwn) {
6162           value[symToStringTag] = tag;
6163         } else {
6164           delete value[symToStringTag];
6165         }
6166       }
6167       return result;
6168     }
6169
6170     /**
6171      * Creates an array of the own enumerable symbols of `object`.
6172      *
6173      * @private
6174      * @param {Object} object The object to query.
6175      * @returns {Array} Returns the array of symbols.
6176      */
6177     var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
6178       if (object == null) {
6179         return [];
6180       }
6181       object = Object(object);
6182       return arrayFilter(nativeGetSymbols(object), function(symbol) {
6183         return propertyIsEnumerable.call(object, symbol);
6184       });
6185     };
6186
6187     /**
6188      * Creates an array of the own and inherited enumerable symbols of `object`.
6189      *
6190      * @private
6191      * @param {Object} object The object to query.
6192      * @returns {Array} Returns the array of symbols.
6193      */
6194     var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6195       var result = [];
6196       while (object) {
6197         arrayPush(result, getSymbols(object));
6198         object = getPrototype(object);
6199       }
6200       return result;
6201     };
6202
6203     /**
6204      * Gets the `toStringTag` of `value`.
6205      *
6206      * @private
6207      * @param {*} value The value to query.
6208      * @returns {string} Returns the `toStringTag`.
6209      */
6210     var getTag = baseGetTag;
6211
6212     // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
6213     if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
6214       (Map && getTag(new Map) != mapTag) ||
6215       (Promise && getTag(Promise.resolve()) != promiseTag) ||
6216       (Set && getTag(new Set) != setTag) ||
6217       (WeakMap && getTag(new WeakMap) != weakMapTag)) {
6218       getTag = function(value) {
6219         var result = baseGetTag(value),
6220           Ctor = result == objectTag ? value.constructor : undefined,
6221           ctorString = Ctor ? toSource(Ctor) : '';
6222
6223         if (ctorString) {
6224           switch (ctorString) {
6225             case dataViewCtorString:
6226               return dataViewTag;
6227             case mapCtorString:
6228               return mapTag;
6229             case promiseCtorString:
6230               return promiseTag;
6231             case setCtorString:
6232               return setTag;
6233             case weakMapCtorString:
6234               return weakMapTag;
6235           }
6236         }
6237         return result;
6238       };
6239     }
6240
6241     /**
6242      * Gets the view, applying any `transforms` to the `start` and `end` positions.
6243      *
6244      * @private
6245      * @param {number} start The start of the view.
6246      * @param {number} end The end of the view.
6247      * @param {Array} transforms The transformations to apply to the view.
6248      * @returns {Object} Returns an object containing the `start` and `end`
6249      *  positions of the view.
6250      */
6251     function getView(start, end, transforms) {
6252       var index = -1,
6253         length = transforms.length;
6254
6255       while (++index < length) {
6256         var data = transforms[index],
6257           size = data.size;
6258
6259         switch (data.type) {
6260           case 'drop':
6261             start += size;
6262             break;
6263           case 'dropRight':
6264             end -= size;
6265             break;
6266           case 'take':
6267             end = nativeMin(end, start + size);
6268             break;
6269           case 'takeRight':
6270             start = nativeMax(start, end - size);
6271             break;
6272         }
6273       }
6274       return {
6275         'start': start,
6276         'end': end
6277       };
6278     }
6279
6280     /**
6281      * Extracts wrapper details from the `source` body comment.
6282      *
6283      * @private
6284      * @param {string} source The source to inspect.
6285      * @returns {Array} Returns the wrapper details.
6286      */
6287     function getWrapDetails(source) {
6288       var match = source.match(reWrapDetails);
6289       return match ? match[1].split(reSplitDetails) : [];
6290     }
6291
6292     /**
6293      * Checks if `path` exists on `object`.
6294      *
6295      * @private
6296      * @param {Object} object The object to query.
6297      * @param {Array|string} path The path to check.
6298      * @param {Function} hasFunc The function to check properties.
6299      * @returns {boolean} Returns `true` if `path` exists, else `false`.
6300      */
6301     function hasPath(object, path, hasFunc) {
6302       path = castPath(path, object);
6303
6304       var index = -1,
6305         length = path.length,
6306         result = false;
6307
6308       while (++index < length) {
6309         var key = toKey(path[index]);
6310         if (!(result = object != null && hasFunc(object, key))) {
6311           break;
6312         }
6313         object = object[key];
6314       }
6315       if (result || ++index != length) {
6316         return result;
6317       }
6318       length = object == null ? 0 : object.length;
6319       return !!length && isLength(length) && isIndex(key, length) &&
6320         (isArray(object) || isArguments(object));
6321     }
6322
6323     /**
6324      * Initializes an array clone.
6325      *
6326      * @private
6327      * @param {Array} array The array to clone.
6328      * @returns {Array} Returns the initialized clone.
6329      */
6330     function initCloneArray(array) {
6331       var length = array.length,
6332         result = new array.constructor(length);
6333
6334       // Add properties assigned by `RegExp#exec`.
6335       if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
6336         result.index = array.index;
6337         result.input = array.input;
6338       }
6339       return result;
6340     }
6341
6342     /**
6343      * Initializes an object clone.
6344      *
6345      * @private
6346      * @param {Object} object The object to clone.
6347      * @returns {Object} Returns the initialized clone.
6348      */
6349     function initCloneObject(object) {
6350       return (typeof object.constructor == 'function' && !isPrototype(object)) ?
6351         baseCreate(getPrototype(object)) : {};
6352     }
6353
6354     /**
6355      * Initializes an object clone based on its `toStringTag`.
6356      *
6357      * **Note:** This function only supports cloning values with tags of
6358      * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
6359      *
6360      * @private
6361      * @param {Object} object The object to clone.
6362      * @param {string} tag The `toStringTag` of the object to clone.
6363      * @param {boolean} [isDeep] Specify a deep clone.
6364      * @returns {Object} Returns the initialized clone.
6365      */
6366     function initCloneByTag(object, tag, isDeep) {
6367       var Ctor = object.constructor;
6368       switch (tag) {
6369         case arrayBufferTag:
6370           return cloneArrayBuffer(object);
6371
6372         case boolTag:
6373         case dateTag:
6374           return new Ctor(+object);
6375
6376         case dataViewTag:
6377           return cloneDataView(object, isDeep);
6378
6379         case float32Tag:
6380         case float64Tag:
6381         case int8Tag:
6382         case int16Tag:
6383         case int32Tag:
6384         case uint8Tag:
6385         case uint8ClampedTag:
6386         case uint16Tag:
6387         case uint32Tag:
6388           return cloneTypedArray(object, isDeep);
6389
6390         case mapTag:
6391           return new Ctor;
6392
6393         case numberTag:
6394         case stringTag:
6395           return new Ctor(object);
6396
6397         case regexpTag:
6398           return cloneRegExp(object);
6399
6400         case setTag:
6401           return new Ctor;
6402
6403         case symbolTag:
6404           return cloneSymbol(object);
6405       }
6406     }
6407
6408     /**
6409      * Inserts wrapper `details` in a comment at the top of the `source` body.
6410      *
6411      * @private
6412      * @param {string} source The source to modify.
6413      * @returns {Array} details The details to insert.
6414      * @returns {string} Returns the modified source.
6415      */
6416     function insertWrapDetails(source, details) {
6417       var length = details.length;
6418       if (!length) {
6419         return source;
6420       }
6421       var lastIndex = length - 1;
6422       details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
6423       details = details.join(length > 2 ? ', ' : ' ');
6424       return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
6425     }
6426
6427     /**
6428      * Checks if `value` is a flattenable `arguments` object or array.
6429      *
6430      * @private
6431      * @param {*} value The value to check.
6432      * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6433      */
6434     function isFlattenable(value) {
6435       return isArray(value) || isArguments(value) ||
6436         !!(spreadableSymbol && value && value[spreadableSymbol]);
6437     }
6438
6439     /**
6440      * Checks if `value` is a valid array-like index.
6441      *
6442      * @private
6443      * @param {*} value The value to check.
6444      * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
6445      * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
6446      */
6447     function isIndex(value, length) {
6448       var type = typeof value;
6449       length = length == null ? MAX_SAFE_INTEGER : length;
6450
6451       return !!length &&
6452         (type == 'number' ||
6453           (type != 'symbol' && reIsUint.test(value))) &&
6454         (value > -1 && value % 1 == 0 && value < length);
6455     }
6456
6457     /**
6458      * Checks if the given arguments are from an iteratee call.
6459      *
6460      * @private
6461      * @param {*} value The potential iteratee value argument.
6462      * @param {*} index The potential iteratee index or key argument.
6463      * @param {*} object The potential iteratee object argument.
6464      * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
6465      *  else `false`.
6466      */
6467     function isIterateeCall(value, index, object) {
6468       if (!isObject(object)) {
6469         return false;
6470       }
6471       var type = typeof index;
6472       if (type == 'number' ?
6473         (isArrayLike(object) && isIndex(index, object.length)) :
6474         (type == 'string' && index in object)
6475       ) {
6476         return eq(object[index], value);
6477       }
6478       return false;
6479     }
6480
6481     /**
6482      * Checks if `value` is a property name and not a property path.
6483      *
6484      * @private
6485      * @param {*} value The value to check.
6486      * @param {Object} [object] The object to query keys on.
6487      * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
6488      */
6489     function isKey(value, object) {
6490       if (isArray(value)) {
6491         return false;
6492       }
6493       var type = typeof value;
6494       if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6495         value == null || isSymbol(value)) {
6496         return true;
6497       }
6498       return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6499         (object != null && value in Object(object));
6500     }
6501
6502     /**
6503      * Checks if `value` is suitable for use as unique object key.
6504      *
6505      * @private
6506      * @param {*} value The value to check.
6507      * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6508      */
6509     function isKeyable(value) {
6510       var type = typeof value;
6511       return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') ?
6512         (value !== '__proto__') :
6513         (value === null);
6514     }
6515
6516     /**
6517      * Checks if `func` has a lazy counterpart.
6518      *
6519      * @private
6520      * @param {Function} func The function to check.
6521      * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6522      *  else `false`.
6523      */
6524     function isLaziable(func) {
6525       var funcName = getFuncName(func),
6526         other = lodash[funcName];
6527
6528       if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6529         return false;
6530       }
6531       if (func === other) {
6532         return true;
6533       }
6534       var data = getData(other);
6535       return !!data && func === data[0];
6536     }
6537
6538     /**
6539      * Checks if `func` has its source masked.
6540      *
6541      * @private
6542      * @param {Function} func The function to check.
6543      * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6544      */
6545     function isMasked(func) {
6546       return !!maskSrcKey && (maskSrcKey in func);
6547     }
6548
6549     /**
6550      * Checks if `func` is capable of being masked.
6551      *
6552      * @private
6553      * @param {*} value The value to check.
6554      * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6555      */
6556     var isMaskable = coreJsData ? isFunction : stubFalse;
6557
6558     /**
6559      * Checks if `value` is likely a prototype object.
6560      *
6561      * @private
6562      * @param {*} value The value to check.
6563      * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6564      */
6565     function isPrototype(value) {
6566       var Ctor = value && value.constructor,
6567         proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6568
6569       return value === proto;
6570     }
6571
6572     /**
6573      * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6574      *
6575      * @private
6576      * @param {*} value The value to check.
6577      * @returns {boolean} Returns `true` if `value` if suitable for strict
6578      *  equality comparisons, else `false`.
6579      */
6580     function isStrictComparable(value) {
6581       return value === value && !isObject(value);
6582     }
6583
6584     /**
6585      * A specialized version of `matchesProperty` for source values suitable
6586      * for strict equality comparisons, i.e. `===`.
6587      *
6588      * @private
6589      * @param {string} key The key of the property to get.
6590      * @param {*} srcValue The value to match.
6591      * @returns {Function} Returns the new spec function.
6592      */
6593     function matchesStrictComparable(key, srcValue) {
6594       return function(object) {
6595         if (object == null) {
6596           return false;
6597         }
6598         return object[key] === srcValue &&
6599           (srcValue !== undefined || (key in Object(object)));
6600       };
6601     }
6602
6603     /**
6604      * A specialized version of `_.memoize` which clears the memoized function's
6605      * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6606      *
6607      * @private
6608      * @param {Function} func The function to have its output memoized.
6609      * @returns {Function} Returns the new memoized function.
6610      */
6611     function memoizeCapped(func) {
6612       var result = memoize(func, function(key) {
6613         if (cache.size === MAX_MEMOIZE_SIZE) {
6614           cache.clear();
6615         }
6616         return key;
6617       });
6618
6619       var cache = result.cache;
6620       return result;
6621     }
6622
6623     /**
6624      * Merges the function metadata of `source` into `data`.
6625      *
6626      * Merging metadata reduces the number of wrappers used to invoke a function.
6627      * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
6628      * may be applied regardless of execution order. Methods like `_.ary` and
6629      * `_.rearg` modify function arguments, making the order in which they are
6630      * executed important, preventing the merging of metadata. However, we make
6631      * an exception for a safe combined case where curried functions have `_.ary`
6632      * and or `_.rearg` applied.
6633      *
6634      * @private
6635      * @param {Array} data The destination metadata.
6636      * @param {Array} source The source metadata.
6637      * @returns {Array} Returns `data`.
6638      */
6639     function mergeData(data, source) {
6640       var bitmask = data[1],
6641         srcBitmask = source[1],
6642         newBitmask = bitmask | srcBitmask,
6643         isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6644
6645       var isCombo =
6646         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
6647         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
6648         ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
6649
6650       // Exit early if metadata can't be merged.
6651       if (!(isCommon || isCombo)) {
6652         return data;
6653       }
6654       // Use source `thisArg` if available.
6655       if (srcBitmask & WRAP_BIND_FLAG) {
6656         data[2] = source[2];
6657         // Set when currying a bound function.
6658         newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6659       }
6660       // Compose partial arguments.
6661       var value = source[3];
6662       if (value) {
6663         var partials = data[3];
6664         data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6665         data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6666       }
6667       // Compose partial right arguments.
6668       value = source[5];
6669       if (value) {
6670         partials = data[5];
6671         data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6672         data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6673       }
6674       // Use source `argPos` if available.
6675       value = source[7];
6676       if (value) {
6677         data[7] = value;
6678       }
6679       // Use source `ary` if it's smaller.
6680       if (srcBitmask & WRAP_ARY_FLAG) {
6681         data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
6682       }
6683       // Use source `arity` if one is not provided.
6684       if (data[9] == null) {
6685         data[9] = source[9];
6686       }
6687       // Use source `func` and merge bitmasks.
6688       data[0] = source[0];
6689       data[1] = newBitmask;
6690
6691       return data;
6692     }
6693
6694     /**
6695      * This function is like
6696      * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
6697      * except that it includes inherited enumerable properties.
6698      *
6699      * @private
6700      * @param {Object} object The object to query.
6701      * @returns {Array} Returns the array of property names.
6702      */
6703     function nativeKeysIn(object) {
6704       var result = [];
6705       if (object != null) {
6706         for (var key in Object(object)) {
6707           result.push(key);
6708         }
6709       }
6710       return result;
6711     }
6712
6713     /**
6714      * Converts `value` to a string using `Object.prototype.toString`.
6715      *
6716      * @private
6717      * @param {*} value The value to convert.
6718      * @returns {string} Returns the converted string.
6719      */
6720     function objectToString(value) {
6721       return nativeObjectToString.call(value);
6722     }
6723
6724     /**
6725      * A specialized version of `baseRest` which transforms the rest array.
6726      *
6727      * @private
6728      * @param {Function} func The function to apply a rest parameter to.
6729      * @param {number} [start=func.length-1] The start position of the rest parameter.
6730      * @param {Function} transform The rest array transform.
6731      * @returns {Function} Returns the new function.
6732      */
6733     function overRest(func, start, transform) {
6734       start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
6735       return function() {
6736         var args = arguments,
6737           index = -1,
6738           length = nativeMax(args.length - start, 0),
6739           array = Array(length);
6740
6741         while (++index < length) {
6742           array[index] = args[start + index];
6743         }
6744         index = -1;
6745         var otherArgs = Array(start + 1);
6746         while (++index < start) {
6747           otherArgs[index] = args[index];
6748         }
6749         otherArgs[start] = transform(array);
6750         return apply(func, this, otherArgs);
6751       };
6752     }
6753
6754     /**
6755      * Gets the parent value at `path` of `object`.
6756      *
6757      * @private
6758      * @param {Object} object The object to query.
6759      * @param {Array} path The path to get the parent value of.
6760      * @returns {*} Returns the parent value.
6761      */
6762     function parent(object, path) {
6763       return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6764     }
6765
6766     /**
6767      * Reorder `array` according to the specified indexes where the element at
6768      * the first index is assigned as the first element, the element at
6769      * the second index is assigned as the second element, and so on.
6770      *
6771      * @private
6772      * @param {Array} array The array to reorder.
6773      * @param {Array} indexes The arranged array indexes.
6774      * @returns {Array} Returns `array`.
6775      */
6776     function reorder(array, indexes) {
6777       var arrLength = array.length,
6778         length = nativeMin(indexes.length, arrLength),
6779         oldArray = copyArray(array);
6780
6781       while (length--) {
6782         var index = indexes[length];
6783         array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
6784       }
6785       return array;
6786     }
6787
6788     /**
6789      * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
6790      *
6791      * @private
6792      * @param {Object} object The object to query.
6793      * @param {string} key The key of the property to get.
6794      * @returns {*} Returns the property value.
6795      */
6796     function safeGet(object, key) {
6797       if (key === 'constructor' && typeof object[key] === 'function') {
6798         return;
6799       }
6800
6801       if (key == '__proto__') {
6802         return;
6803       }
6804
6805       return object[key];
6806     }
6807
6808     /**
6809      * Sets metadata for `func`.
6810      *
6811      * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
6812      * period of time, it will trip its breaker and transition to an identity
6813      * function to avoid garbage collection pauses in V8. See
6814      * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
6815      * for more details.
6816      *
6817      * @private
6818      * @param {Function} func The function to associate metadata with.
6819      * @param {*} data The metadata.
6820      * @returns {Function} Returns `func`.
6821      */
6822     var setData = shortOut(baseSetData);
6823
6824     /**
6825      * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
6826      *
6827      * @private
6828      * @param {Function} func The function to delay.
6829      * @param {number} wait The number of milliseconds to delay invocation.
6830      * @returns {number|Object} Returns the timer id or timeout object.
6831      */
6832     var setTimeout = ctxSetTimeout || function(func, wait) {
6833       return root.setTimeout(func, wait);
6834     };
6835
6836     /**
6837      * Sets the `toString` method of `func` to return `string`.
6838      *
6839      * @private
6840      * @param {Function} func The function to modify.
6841      * @param {Function} string The `toString` result.
6842      * @returns {Function} Returns `func`.
6843      */
6844     var setToString = shortOut(baseSetToString);
6845
6846     /**
6847      * Sets the `toString` method of `wrapper` to mimic the source of `reference`
6848      * with wrapper details in a comment at the top of the source body.
6849      *
6850      * @private
6851      * @param {Function} wrapper The function to modify.
6852      * @param {Function} reference The reference function.
6853      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6854      * @returns {Function} Returns `wrapper`.
6855      */
6856     function setWrapToString(wrapper, reference, bitmask) {
6857       var source = (reference + '');
6858       return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6859     }
6860
6861     /**
6862      * Creates a function that'll short out and invoke `identity` instead
6863      * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
6864      * milliseconds.
6865      *
6866      * @private
6867      * @param {Function} func The function to restrict.
6868      * @returns {Function} Returns the new shortable function.
6869      */
6870     function shortOut(func) {
6871       var count = 0,
6872         lastCalled = 0;
6873
6874       return function() {
6875         var stamp = nativeNow(),
6876           remaining = HOT_SPAN - (stamp - lastCalled);
6877
6878         lastCalled = stamp;
6879         if (remaining > 0) {
6880           if (++count >= HOT_COUNT) {
6881             return arguments[0];
6882           }
6883         } else {
6884           count = 0;
6885         }
6886         return func.apply(undefined, arguments);
6887       };
6888     }
6889
6890     /**
6891      * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
6892      *
6893      * @private
6894      * @param {Array} array The array to shuffle.
6895      * @param {number} [size=array.length] The size of `array`.
6896      * @returns {Array} Returns `array`.
6897      */
6898     function shuffleSelf(array, size) {
6899       var index = -1,
6900         length = array.length,
6901         lastIndex = length - 1;
6902
6903       size = size === undefined ? length : size;
6904       while (++index < size) {
6905         var rand = baseRandom(index, lastIndex),
6906           value = array[rand];
6907
6908         array[rand] = array[index];
6909         array[index] = value;
6910       }
6911       array.length = size;
6912       return array;
6913     }
6914
6915     /**
6916      * Converts `string` to a property path array.
6917      *
6918      * @private
6919      * @param {string} string The string to convert.
6920      * @returns {Array} Returns the property path array.
6921      */
6922     var stringToPath = memoizeCapped(function(string) {
6923       var result = [];
6924       if (string.charCodeAt(0) === 46 /* . */ ) {
6925         result.push('');
6926       }
6927       string.replace(rePropName, function(match, number, quote, subString) {
6928         result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
6929       });
6930       return result;
6931     });
6932
6933     /**
6934      * Converts `value` to a string key if it's not a string or symbol.
6935      *
6936      * @private
6937      * @param {*} value The value to inspect.
6938      * @returns {string|symbol} Returns the key.
6939      */
6940     function toKey(value) {
6941       if (typeof value == 'string' || isSymbol(value)) {
6942         return value;
6943       }
6944       var result = (value + '');
6945       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
6946     }
6947
6948     /**
6949      * Converts `func` to its source code.
6950      *
6951      * @private
6952      * @param {Function} func The function to convert.
6953      * @returns {string} Returns the source code.
6954      */
6955     function toSource(func) {
6956       if (func != null) {
6957         try {
6958           return funcToString.call(func);
6959         } catch (e) {}
6960         try {
6961           return (func + '');
6962         } catch (e) {}
6963       }
6964       return '';
6965     }
6966
6967     /**
6968      * Updates wrapper `details` based on `bitmask` flags.
6969      *
6970      * @private
6971      * @returns {Array} details The details to modify.
6972      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6973      * @returns {Array} Returns `details`.
6974      */
6975     function updateWrapDetails(details, bitmask) {
6976       arrayEach(wrapFlags, function(pair) {
6977         var value = '_.' + pair[0];
6978         if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
6979           details.push(value);
6980         }
6981       });
6982       return details.sort();
6983     }
6984
6985     /**
6986      * Creates a clone of `wrapper`.
6987      *
6988      * @private
6989      * @param {Object} wrapper The wrapper to clone.
6990      * @returns {Object} Returns the cloned wrapper.
6991      */
6992     function wrapperClone(wrapper) {
6993       if (wrapper instanceof LazyWrapper) {
6994         return wrapper.clone();
6995       }
6996       var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6997       result.__actions__ = copyArray(wrapper.__actions__);
6998       result.__index__ = wrapper.__index__;
6999       result.__values__ = wrapper.__values__;
7000       return result;
7001     }
7002
7003     /*------------------------------------------------------------------------*/
7004
7005     /**
7006      * Creates an array of elements split into groups the length of `size`.
7007      * If `array` can't be split evenly, the final chunk will be the remaining
7008      * elements.
7009      *
7010      * @static
7011      * @memberOf _
7012      * @since 3.0.0
7013      * @category Array
7014      * @param {Array} array The array to process.
7015      * @param {number} [size=1] The length of each chunk
7016      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7017      * @returns {Array} Returns the new array of chunks.
7018      * @example
7019      *
7020      * _.chunk(['a', 'b', 'c', 'd'], 2);
7021      * // => [['a', 'b'], ['c', 'd']]
7022      *
7023      * _.chunk(['a', 'b', 'c', 'd'], 3);
7024      * // => [['a', 'b', 'c'], ['d']]
7025      */
7026     function chunk(array, size, guard) {
7027       if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
7028         size = 1;
7029       } else {
7030         size = nativeMax(toInteger(size), 0);
7031       }
7032       var length = array == null ? 0 : array.length;
7033       if (!length || size < 1) {
7034         return [];
7035       }
7036       var index = 0,
7037         resIndex = 0,
7038         result = Array(nativeCeil(length / size));
7039
7040       while (index < length) {
7041         result[resIndex++] = baseSlice(array, index, (index += size));
7042       }
7043       return result;
7044     }
7045
7046     /**
7047      * Creates an array with all falsey values removed. The values `false`, `null`,
7048      * `0`, `""`, `undefined`, and `NaN` are falsey.
7049      *
7050      * @static
7051      * @memberOf _
7052      * @since 0.1.0
7053      * @category Array
7054      * @param {Array} array The array to compact.
7055      * @returns {Array} Returns the new array of filtered values.
7056      * @example
7057      *
7058      * _.compact([0, 1, false, 2, '', 3]);
7059      * // => [1, 2, 3]
7060      */
7061     function compact(array) {
7062       var index = -1,
7063         length = array == null ? 0 : array.length,
7064         resIndex = 0,
7065         result = [];
7066
7067       while (++index < length) {
7068         var value = array[index];
7069         if (value) {
7070           result[resIndex++] = value;
7071         }
7072       }
7073       return result;
7074     }
7075
7076     /**
7077      * Creates a new array concatenating `array` with any additional arrays
7078      * and/or values.
7079      *
7080      * @static
7081      * @memberOf _
7082      * @since 4.0.0
7083      * @category Array
7084      * @param {Array} array The array to concatenate.
7085      * @param {...*} [values] The values to concatenate.
7086      * @returns {Array} Returns the new concatenated array.
7087      * @example
7088      *
7089      * var array = [1];
7090      * var other = _.concat(array, 2, [3], [[4]]);
7091      *
7092      * console.log(other);
7093      * // => [1, 2, 3, [4]]
7094      *
7095      * console.log(array);
7096      * // => [1]
7097      */
7098     function concat() {
7099       var length = arguments.length;
7100       if (!length) {
7101         return [];
7102       }
7103       var args = Array(length - 1),
7104         array = arguments[0],
7105         index = length;
7106
7107       while (index--) {
7108         args[index - 1] = arguments[index];
7109       }
7110       return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
7111     }
7112
7113     /**
7114      * Creates an array of `array` values not included in the other given arrays
7115      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7116      * for equality comparisons. The order and references of result values are
7117      * determined by the first array.
7118      *
7119      * **Note:** Unlike `_.pullAll`, this method returns a new array.
7120      *
7121      * @static
7122      * @memberOf _
7123      * @since 0.1.0
7124      * @category Array
7125      * @param {Array} array The array to inspect.
7126      * @param {...Array} [values] The values to exclude.
7127      * @returns {Array} Returns the new array of filtered values.
7128      * @see _.without, _.xor
7129      * @example
7130      *
7131      * _.difference([2, 1], [2, 3]);
7132      * // => [1]
7133      */
7134     var difference = baseRest(function(array, values) {
7135       return isArrayLikeObject(array) ?
7136         baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) : [];
7137     });
7138
7139     /**
7140      * This method is like `_.difference` except that it accepts `iteratee` which
7141      * is invoked for each element of `array` and `values` to generate the criterion
7142      * by which they're compared. The order and references of result values are
7143      * determined by the first array. The iteratee is invoked with one argument:
7144      * (value).
7145      *
7146      * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
7147      *
7148      * @static
7149      * @memberOf _
7150      * @since 4.0.0
7151      * @category Array
7152      * @param {Array} array The array to inspect.
7153      * @param {...Array} [values] The values to exclude.
7154      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7155      * @returns {Array} Returns the new array of filtered values.
7156      * @example
7157      *
7158      * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7159      * // => [1.2]
7160      *
7161      * // The `_.property` iteratee shorthand.
7162      * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
7163      * // => [{ 'x': 2 }]
7164      */
7165     var differenceBy = baseRest(function(array, values) {
7166       var iteratee = last(values);
7167       if (isArrayLikeObject(iteratee)) {
7168         iteratee = undefined;
7169       }
7170       return isArrayLikeObject(array) ?
7171         baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) : [];
7172     });
7173
7174     /**
7175      * This method is like `_.difference` except that it accepts `comparator`
7176      * which is invoked to compare elements of `array` to `values`. The order and
7177      * references of result values are determined by the first array. The comparator
7178      * is invoked with two arguments: (arrVal, othVal).
7179      *
7180      * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
7181      *
7182      * @static
7183      * @memberOf _
7184      * @since 4.0.0
7185      * @category Array
7186      * @param {Array} array The array to inspect.
7187      * @param {...Array} [values] The values to exclude.
7188      * @param {Function} [comparator] The comparator invoked per element.
7189      * @returns {Array} Returns the new array of filtered values.
7190      * @example
7191      *
7192      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7193      *
7194      * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
7195      * // => [{ 'x': 2, 'y': 1 }]
7196      */
7197     var differenceWith = baseRest(function(array, values) {
7198       var comparator = last(values);
7199       if (isArrayLikeObject(comparator)) {
7200         comparator = undefined;
7201       }
7202       return isArrayLikeObject(array) ?
7203         baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) : [];
7204     });
7205
7206     /**
7207      * Creates a slice of `array` with `n` elements dropped from the beginning.
7208      *
7209      * @static
7210      * @memberOf _
7211      * @since 0.5.0
7212      * @category Array
7213      * @param {Array} array The array to query.
7214      * @param {number} [n=1] The number of elements to drop.
7215      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7216      * @returns {Array} Returns the slice of `array`.
7217      * @example
7218      *
7219      * _.drop([1, 2, 3]);
7220      * // => [2, 3]
7221      *
7222      * _.drop([1, 2, 3], 2);
7223      * // => [3]
7224      *
7225      * _.drop([1, 2, 3], 5);
7226      * // => []
7227      *
7228      * _.drop([1, 2, 3], 0);
7229      * // => [1, 2, 3]
7230      */
7231     function drop(array, n, guard) {
7232       var length = array == null ? 0 : array.length;
7233       if (!length) {
7234         return [];
7235       }
7236       n = (guard || n === undefined) ? 1 : toInteger(n);
7237       return baseSlice(array, n < 0 ? 0 : n, length);
7238     }
7239
7240     /**
7241      * Creates a slice of `array` with `n` elements dropped from the end.
7242      *
7243      * @static
7244      * @memberOf _
7245      * @since 3.0.0
7246      * @category Array
7247      * @param {Array} array The array to query.
7248      * @param {number} [n=1] The number of elements to drop.
7249      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7250      * @returns {Array} Returns the slice of `array`.
7251      * @example
7252      *
7253      * _.dropRight([1, 2, 3]);
7254      * // => [1, 2]
7255      *
7256      * _.dropRight([1, 2, 3], 2);
7257      * // => [1]
7258      *
7259      * _.dropRight([1, 2, 3], 5);
7260      * // => []
7261      *
7262      * _.dropRight([1, 2, 3], 0);
7263      * // => [1, 2, 3]
7264      */
7265     function dropRight(array, n, guard) {
7266       var length = array == null ? 0 : array.length;
7267       if (!length) {
7268         return [];
7269       }
7270       n = (guard || n === undefined) ? 1 : toInteger(n);
7271       n = length - n;
7272       return baseSlice(array, 0, n < 0 ? 0 : n);
7273     }
7274
7275     /**
7276      * Creates a slice of `array` excluding elements dropped from the end.
7277      * Elements are dropped until `predicate` returns falsey. The predicate is
7278      * invoked with three arguments: (value, index, array).
7279      *
7280      * @static
7281      * @memberOf _
7282      * @since 3.0.0
7283      * @category Array
7284      * @param {Array} array The array to query.
7285      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7286      * @returns {Array} Returns the slice of `array`.
7287      * @example
7288      *
7289      * var users = [
7290      *   { 'user': 'barney',  'active': true },
7291      *   { 'user': 'fred',    'active': false },
7292      *   { 'user': 'pebbles', 'active': false }
7293      * ];
7294      *
7295      * _.dropRightWhile(users, function(o) { return !o.active; });
7296      * // => objects for ['barney']
7297      *
7298      * // The `_.matches` iteratee shorthand.
7299      * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7300      * // => objects for ['barney', 'fred']
7301      *
7302      * // The `_.matchesProperty` iteratee shorthand.
7303      * _.dropRightWhile(users, ['active', false]);
7304      * // => objects for ['barney']
7305      *
7306      * // The `_.property` iteratee shorthand.
7307      * _.dropRightWhile(users, 'active');
7308      * // => objects for ['barney', 'fred', 'pebbles']
7309      */
7310     function dropRightWhile(array, predicate) {
7311       return (array && array.length) ?
7312         baseWhile(array, getIteratee(predicate, 3), true, true) : [];
7313     }
7314
7315     /**
7316      * Creates a slice of `array` excluding elements dropped from the beginning.
7317      * Elements are dropped until `predicate` returns falsey. The predicate is
7318      * invoked with three arguments: (value, index, array).
7319      *
7320      * @static
7321      * @memberOf _
7322      * @since 3.0.0
7323      * @category Array
7324      * @param {Array} array The array to query.
7325      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7326      * @returns {Array} Returns the slice of `array`.
7327      * @example
7328      *
7329      * var users = [
7330      *   { 'user': 'barney',  'active': false },
7331      *   { 'user': 'fred',    'active': false },
7332      *   { 'user': 'pebbles', 'active': true }
7333      * ];
7334      *
7335      * _.dropWhile(users, function(o) { return !o.active; });
7336      * // => objects for ['pebbles']
7337      *
7338      * // The `_.matches` iteratee shorthand.
7339      * _.dropWhile(users, { 'user': 'barney', 'active': false });
7340      * // => objects for ['fred', 'pebbles']
7341      *
7342      * // The `_.matchesProperty` iteratee shorthand.
7343      * _.dropWhile(users, ['active', false]);
7344      * // => objects for ['pebbles']
7345      *
7346      * // The `_.property` iteratee shorthand.
7347      * _.dropWhile(users, 'active');
7348      * // => objects for ['barney', 'fred', 'pebbles']
7349      */
7350     function dropWhile(array, predicate) {
7351       return (array && array.length) ?
7352         baseWhile(array, getIteratee(predicate, 3), true) : [];
7353     }
7354
7355     /**
7356      * Fills elements of `array` with `value` from `start` up to, but not
7357      * including, `end`.
7358      *
7359      * **Note:** This method mutates `array`.
7360      *
7361      * @static
7362      * @memberOf _
7363      * @since 3.2.0
7364      * @category Array
7365      * @param {Array} array The array to fill.
7366      * @param {*} value The value to fill `array` with.
7367      * @param {number} [start=0] The start position.
7368      * @param {number} [end=array.length] The end position.
7369      * @returns {Array} Returns `array`.
7370      * @example
7371      *
7372      * var array = [1, 2, 3];
7373      *
7374      * _.fill(array, 'a');
7375      * console.log(array);
7376      * // => ['a', 'a', 'a']
7377      *
7378      * _.fill(Array(3), 2);
7379      * // => [2, 2, 2]
7380      *
7381      * _.fill([4, 6, 8, 10], '*', 1, 3);
7382      * // => [4, '*', '*', 10]
7383      */
7384     function fill(array, value, start, end) {
7385       var length = array == null ? 0 : array.length;
7386       if (!length) {
7387         return [];
7388       }
7389       if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7390         start = 0;
7391         end = length;
7392       }
7393       return baseFill(array, value, start, end);
7394     }
7395
7396     /**
7397      * This method is like `_.find` except that it returns the index of the first
7398      * element `predicate` returns truthy for instead of the element itself.
7399      *
7400      * @static
7401      * @memberOf _
7402      * @since 1.1.0
7403      * @category Array
7404      * @param {Array} array The array to inspect.
7405      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7406      * @param {number} [fromIndex=0] The index to search from.
7407      * @returns {number} Returns the index of the found element, else `-1`.
7408      * @example
7409      *
7410      * var users = [
7411      *   { 'user': 'barney',  'active': false },
7412      *   { 'user': 'fred',    'active': false },
7413      *   { 'user': 'pebbles', 'active': true }
7414      * ];
7415      *
7416      * _.findIndex(users, function(o) { return o.user == 'barney'; });
7417      * // => 0
7418      *
7419      * // The `_.matches` iteratee shorthand.
7420      * _.findIndex(users, { 'user': 'fred', 'active': false });
7421      * // => 1
7422      *
7423      * // The `_.matchesProperty` iteratee shorthand.
7424      * _.findIndex(users, ['active', false]);
7425      * // => 0
7426      *
7427      * // The `_.property` iteratee shorthand.
7428      * _.findIndex(users, 'active');
7429      * // => 2
7430      */
7431     function findIndex(array, predicate, fromIndex) {
7432       var length = array == null ? 0 : array.length;
7433       if (!length) {
7434         return -1;
7435       }
7436       var index = fromIndex == null ? 0 : toInteger(fromIndex);
7437       if (index < 0) {
7438         index = nativeMax(length + index, 0);
7439       }
7440       return baseFindIndex(array, getIteratee(predicate, 3), index);
7441     }
7442
7443     /**
7444      * This method is like `_.findIndex` except that it iterates over elements
7445      * of `collection` from right to left.
7446      *
7447      * @static
7448      * @memberOf _
7449      * @since 2.0.0
7450      * @category Array
7451      * @param {Array} array The array to inspect.
7452      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7453      * @param {number} [fromIndex=array.length-1] The index to search from.
7454      * @returns {number} Returns the index of the found element, else `-1`.
7455      * @example
7456      *
7457      * var users = [
7458      *   { 'user': 'barney',  'active': true },
7459      *   { 'user': 'fred',    'active': false },
7460      *   { 'user': 'pebbles', 'active': false }
7461      * ];
7462      *
7463      * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7464      * // => 2
7465      *
7466      * // The `_.matches` iteratee shorthand.
7467      * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7468      * // => 0
7469      *
7470      * // The `_.matchesProperty` iteratee shorthand.
7471      * _.findLastIndex(users, ['active', false]);
7472      * // => 2
7473      *
7474      * // The `_.property` iteratee shorthand.
7475      * _.findLastIndex(users, 'active');
7476      * // => 0
7477      */
7478     function findLastIndex(array, predicate, fromIndex) {
7479       var length = array == null ? 0 : array.length;
7480       if (!length) {
7481         return -1;
7482       }
7483       var index = length - 1;
7484       if (fromIndex !== undefined) {
7485         index = toInteger(fromIndex);
7486         index = fromIndex < 0 ?
7487           nativeMax(length + index, 0) :
7488           nativeMin(index, length - 1);
7489       }
7490       return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7491     }
7492
7493     /**
7494      * Flattens `array` a single level deep.
7495      *
7496      * @static
7497      * @memberOf _
7498      * @since 0.1.0
7499      * @category Array
7500      * @param {Array} array The array to flatten.
7501      * @returns {Array} Returns the new flattened array.
7502      * @example
7503      *
7504      * _.flatten([1, [2, [3, [4]], 5]]);
7505      * // => [1, 2, [3, [4]], 5]
7506      */
7507     function flatten(array) {
7508       var length = array == null ? 0 : array.length;
7509       return length ? baseFlatten(array, 1) : [];
7510     }
7511
7512     /**
7513      * Recursively flattens `array`.
7514      *
7515      * @static
7516      * @memberOf _
7517      * @since 3.0.0
7518      * @category Array
7519      * @param {Array} array The array to flatten.
7520      * @returns {Array} Returns the new flattened array.
7521      * @example
7522      *
7523      * _.flattenDeep([1, [2, [3, [4]], 5]]);
7524      * // => [1, 2, 3, 4, 5]
7525      */
7526     function flattenDeep(array) {
7527       var length = array == null ? 0 : array.length;
7528       return length ? baseFlatten(array, INFINITY) : [];
7529     }
7530
7531     /**
7532      * Recursively flatten `array` up to `depth` times.
7533      *
7534      * @static
7535      * @memberOf _
7536      * @since 4.4.0
7537      * @category Array
7538      * @param {Array} array The array to flatten.
7539      * @param {number} [depth=1] The maximum recursion depth.
7540      * @returns {Array} Returns the new flattened array.
7541      * @example
7542      *
7543      * var array = [1, [2, [3, [4]], 5]];
7544      *
7545      * _.flattenDepth(array, 1);
7546      * // => [1, 2, [3, [4]], 5]
7547      *
7548      * _.flattenDepth(array, 2);
7549      * // => [1, 2, 3, [4], 5]
7550      */
7551     function flattenDepth(array, depth) {
7552       var length = array == null ? 0 : array.length;
7553       if (!length) {
7554         return [];
7555       }
7556       depth = depth === undefined ? 1 : toInteger(depth);
7557       return baseFlatten(array, depth);
7558     }
7559
7560     /**
7561      * The inverse of `_.toPairs`; this method returns an object composed
7562      * from key-value `pairs`.
7563      *
7564      * @static
7565      * @memberOf _
7566      * @since 4.0.0
7567      * @category Array
7568      * @param {Array} pairs The key-value pairs.
7569      * @returns {Object} Returns the new object.
7570      * @example
7571      *
7572      * _.fromPairs([['a', 1], ['b', 2]]);
7573      * // => { 'a': 1, 'b': 2 }
7574      */
7575     function fromPairs(pairs) {
7576       var index = -1,
7577         length = pairs == null ? 0 : pairs.length,
7578         result = {};
7579
7580       while (++index < length) {
7581         var pair = pairs[index];
7582         result[pair[0]] = pair[1];
7583       }
7584       return result;
7585     }
7586
7587     /**
7588      * Gets the first element of `array`.
7589      *
7590      * @static
7591      * @memberOf _
7592      * @since 0.1.0
7593      * @alias first
7594      * @category Array
7595      * @param {Array} array The array to query.
7596      * @returns {*} Returns the first element of `array`.
7597      * @example
7598      *
7599      * _.head([1, 2, 3]);
7600      * // => 1
7601      *
7602      * _.head([]);
7603      * // => undefined
7604      */
7605     function head(array) {
7606       return (array && array.length) ? array[0] : undefined;
7607     }
7608
7609     /**
7610      * Gets the index at which the first occurrence of `value` is found in `array`
7611      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7612      * for equality comparisons. If `fromIndex` is negative, it's used as the
7613      * offset from the end of `array`.
7614      *
7615      * @static
7616      * @memberOf _
7617      * @since 0.1.0
7618      * @category Array
7619      * @param {Array} array The array to inspect.
7620      * @param {*} value The value to search for.
7621      * @param {number} [fromIndex=0] The index to search from.
7622      * @returns {number} Returns the index of the matched value, else `-1`.
7623      * @example
7624      *
7625      * _.indexOf([1, 2, 1, 2], 2);
7626      * // => 1
7627      *
7628      * // Search from the `fromIndex`.
7629      * _.indexOf([1, 2, 1, 2], 2, 2);
7630      * // => 3
7631      */
7632     function indexOf(array, value, fromIndex) {
7633       var length = array == null ? 0 : array.length;
7634       if (!length) {
7635         return -1;
7636       }
7637       var index = fromIndex == null ? 0 : toInteger(fromIndex);
7638       if (index < 0) {
7639         index = nativeMax(length + index, 0);
7640       }
7641       return baseIndexOf(array, value, index);
7642     }
7643
7644     /**
7645      * Gets all but the last element of `array`.
7646      *
7647      * @static
7648      * @memberOf _
7649      * @since 0.1.0
7650      * @category Array
7651      * @param {Array} array The array to query.
7652      * @returns {Array} Returns the slice of `array`.
7653      * @example
7654      *
7655      * _.initial([1, 2, 3]);
7656      * // => [1, 2]
7657      */
7658     function initial(array) {
7659       var length = array == null ? 0 : array.length;
7660       return length ? baseSlice(array, 0, -1) : [];
7661     }
7662
7663     /**
7664      * Creates an array of unique values that are included in all given arrays
7665      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7666      * for equality comparisons. The order and references of result values are
7667      * determined by the first array.
7668      *
7669      * @static
7670      * @memberOf _
7671      * @since 0.1.0
7672      * @category Array
7673      * @param {...Array} [arrays] The arrays to inspect.
7674      * @returns {Array} Returns the new array of intersecting values.
7675      * @example
7676      *
7677      * _.intersection([2, 1], [2, 3]);
7678      * // => [2]
7679      */
7680     var intersection = baseRest(function(arrays) {
7681       var mapped = arrayMap(arrays, castArrayLikeObject);
7682       return (mapped.length && mapped[0] === arrays[0]) ?
7683         baseIntersection(mapped) : [];
7684     });
7685
7686     /**
7687      * This method is like `_.intersection` except that it accepts `iteratee`
7688      * which is invoked for each element of each `arrays` to generate the criterion
7689      * by which they're compared. The order and references of result values are
7690      * determined by the first array. The iteratee is invoked with one argument:
7691      * (value).
7692      *
7693      * @static
7694      * @memberOf _
7695      * @since 4.0.0
7696      * @category Array
7697      * @param {...Array} [arrays] The arrays to inspect.
7698      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7699      * @returns {Array} Returns the new array of intersecting values.
7700      * @example
7701      *
7702      * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7703      * // => [2.1]
7704      *
7705      * // The `_.property` iteratee shorthand.
7706      * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7707      * // => [{ 'x': 1 }]
7708      */
7709     var intersectionBy = baseRest(function(arrays) {
7710       var iteratee = last(arrays),
7711         mapped = arrayMap(arrays, castArrayLikeObject);
7712
7713       if (iteratee === last(mapped)) {
7714         iteratee = undefined;
7715       } else {
7716         mapped.pop();
7717       }
7718       return (mapped.length && mapped[0] === arrays[0]) ?
7719         baseIntersection(mapped, getIteratee(iteratee, 2)) : [];
7720     });
7721
7722     /**
7723      * This method is like `_.intersection` except that it accepts `comparator`
7724      * which is invoked to compare elements of `arrays`. The order and references
7725      * of result values are determined by the first array. The comparator is
7726      * invoked with two arguments: (arrVal, othVal).
7727      *
7728      * @static
7729      * @memberOf _
7730      * @since 4.0.0
7731      * @category Array
7732      * @param {...Array} [arrays] The arrays to inspect.
7733      * @param {Function} [comparator] The comparator invoked per element.
7734      * @returns {Array} Returns the new array of intersecting values.
7735      * @example
7736      *
7737      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7738      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7739      *
7740      * _.intersectionWith(objects, others, _.isEqual);
7741      * // => [{ 'x': 1, 'y': 2 }]
7742      */
7743     var intersectionWith = baseRest(function(arrays) {
7744       var comparator = last(arrays),
7745         mapped = arrayMap(arrays, castArrayLikeObject);
7746
7747       comparator = typeof comparator == 'function' ? comparator : undefined;
7748       if (comparator) {
7749         mapped.pop();
7750       }
7751       return (mapped.length && mapped[0] === arrays[0]) ?
7752         baseIntersection(mapped, undefined, comparator) : [];
7753     });
7754
7755     /**
7756      * Converts all elements in `array` into a string separated by `separator`.
7757      *
7758      * @static
7759      * @memberOf _
7760      * @since 4.0.0
7761      * @category Array
7762      * @param {Array} array The array to convert.
7763      * @param {string} [separator=','] The element separator.
7764      * @returns {string} Returns the joined string.
7765      * @example
7766      *
7767      * _.join(['a', 'b', 'c'], '~');
7768      * // => 'a~b~c'
7769      */
7770     function join(array, separator) {
7771       return array == null ? '' : nativeJoin.call(array, separator);
7772     }
7773
7774     /**
7775      * Gets the last element of `array`.
7776      *
7777      * @static
7778      * @memberOf _
7779      * @since 0.1.0
7780      * @category Array
7781      * @param {Array} array The array to query.
7782      * @returns {*} Returns the last element of `array`.
7783      * @example
7784      *
7785      * _.last([1, 2, 3]);
7786      * // => 3
7787      */
7788     function last(array) {
7789       var length = array == null ? 0 : array.length;
7790       return length ? array[length - 1] : undefined;
7791     }
7792
7793     /**
7794      * This method is like `_.indexOf` except that it iterates over elements of
7795      * `array` from right to left.
7796      *
7797      * @static
7798      * @memberOf _
7799      * @since 0.1.0
7800      * @category Array
7801      * @param {Array} array The array to inspect.
7802      * @param {*} value The value to search for.
7803      * @param {number} [fromIndex=array.length-1] The index to search from.
7804      * @returns {number} Returns the index of the matched value, else `-1`.
7805      * @example
7806      *
7807      * _.lastIndexOf([1, 2, 1, 2], 2);
7808      * // => 3
7809      *
7810      * // Search from the `fromIndex`.
7811      * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7812      * // => 1
7813      */
7814     function lastIndexOf(array, value, fromIndex) {
7815       var length = array == null ? 0 : array.length;
7816       if (!length) {
7817         return -1;
7818       }
7819       var index = length;
7820       if (fromIndex !== undefined) {
7821         index = toInteger(fromIndex);
7822         index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7823       }
7824       return value === value ?
7825         strictLastIndexOf(array, value, index) :
7826         baseFindIndex(array, baseIsNaN, index, true);
7827     }
7828
7829     /**
7830      * Gets the element at index `n` of `array`. If `n` is negative, the nth
7831      * element from the end is returned.
7832      *
7833      * @static
7834      * @memberOf _
7835      * @since 4.11.0
7836      * @category Array
7837      * @param {Array} array The array to query.
7838      * @param {number} [n=0] The index of the element to return.
7839      * @returns {*} Returns the nth element of `array`.
7840      * @example
7841      *
7842      * var array = ['a', 'b', 'c', 'd'];
7843      *
7844      * _.nth(array, 1);
7845      * // => 'b'
7846      *
7847      * _.nth(array, -2);
7848      * // => 'c';
7849      */
7850     function nth(array, n) {
7851       return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
7852     }
7853
7854     /**
7855      * Removes all given values from `array` using
7856      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7857      * for equality comparisons.
7858      *
7859      * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
7860      * to remove elements from an array by predicate.
7861      *
7862      * @static
7863      * @memberOf _
7864      * @since 2.0.0
7865      * @category Array
7866      * @param {Array} array The array to modify.
7867      * @param {...*} [values] The values to remove.
7868      * @returns {Array} Returns `array`.
7869      * @example
7870      *
7871      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7872      *
7873      * _.pull(array, 'a', 'c');
7874      * console.log(array);
7875      * // => ['b', 'b']
7876      */
7877     var pull = baseRest(pullAll);
7878
7879     /**
7880      * This method is like `_.pull` except that it accepts an array of values to remove.
7881      *
7882      * **Note:** Unlike `_.difference`, this method mutates `array`.
7883      *
7884      * @static
7885      * @memberOf _
7886      * @since 4.0.0
7887      * @category Array
7888      * @param {Array} array The array to modify.
7889      * @param {Array} values The values to remove.
7890      * @returns {Array} Returns `array`.
7891      * @example
7892      *
7893      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7894      *
7895      * _.pullAll(array, ['a', 'c']);
7896      * console.log(array);
7897      * // => ['b', 'b']
7898      */
7899     function pullAll(array, values) {
7900       return (array && array.length && values && values.length) ?
7901         basePullAll(array, values) :
7902         array;
7903     }
7904
7905     /**
7906      * This method is like `_.pullAll` except that it accepts `iteratee` which is
7907      * invoked for each element of `array` and `values` to generate the criterion
7908      * by which they're compared. The iteratee is invoked with one argument: (value).
7909      *
7910      * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
7911      *
7912      * @static
7913      * @memberOf _
7914      * @since 4.0.0
7915      * @category Array
7916      * @param {Array} array The array to modify.
7917      * @param {Array} values The values to remove.
7918      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7919      * @returns {Array} Returns `array`.
7920      * @example
7921      *
7922      * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
7923      *
7924      * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
7925      * console.log(array);
7926      * // => [{ 'x': 2 }]
7927      */
7928     function pullAllBy(array, values, iteratee) {
7929       return (array && array.length && values && values.length) ?
7930         basePullAll(array, values, getIteratee(iteratee, 2)) :
7931         array;
7932     }
7933
7934     /**
7935      * This method is like `_.pullAll` except that it accepts `comparator` which
7936      * is invoked to compare elements of `array` to `values`. The comparator is
7937      * invoked with two arguments: (arrVal, othVal).
7938      *
7939      * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
7940      *
7941      * @static
7942      * @memberOf _
7943      * @since 4.6.0
7944      * @category Array
7945      * @param {Array} array The array to modify.
7946      * @param {Array} values The values to remove.
7947      * @param {Function} [comparator] The comparator invoked per element.
7948      * @returns {Array} Returns `array`.
7949      * @example
7950      *
7951      * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
7952      *
7953      * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
7954      * console.log(array);
7955      * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
7956      */
7957     function pullAllWith(array, values, comparator) {
7958       return (array && array.length && values && values.length) ?
7959         basePullAll(array, values, undefined, comparator) :
7960         array;
7961     }
7962
7963     /**
7964      * Removes elements from `array` corresponding to `indexes` and returns an
7965      * array of removed elements.
7966      *
7967      * **Note:** Unlike `_.at`, this method mutates `array`.
7968      *
7969      * @static
7970      * @memberOf _
7971      * @since 3.0.0
7972      * @category Array
7973      * @param {Array} array The array to modify.
7974      * @param {...(number|number[])} [indexes] The indexes of elements to remove.
7975      * @returns {Array} Returns the new array of removed elements.
7976      * @example
7977      *
7978      * var array = ['a', 'b', 'c', 'd'];
7979      * var pulled = _.pullAt(array, [1, 3]);
7980      *
7981      * console.log(array);
7982      * // => ['a', 'c']
7983      *
7984      * console.log(pulled);
7985      * // => ['b', 'd']
7986      */
7987     var pullAt = flatRest(function(array, indexes) {
7988       var length = array == null ? 0 : array.length,
7989         result = baseAt(array, indexes);
7990
7991       basePullAt(array, arrayMap(indexes, function(index) {
7992         return isIndex(index, length) ? +index : index;
7993       }).sort(compareAscending));
7994
7995       return result;
7996     });
7997
7998     /**
7999      * Removes all elements from `array` that `predicate` returns truthy for
8000      * and returns an array of the removed elements. The predicate is invoked
8001      * with three arguments: (value, index, array).
8002      *
8003      * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
8004      * to pull elements from an array by value.
8005      *
8006      * @static
8007      * @memberOf _
8008      * @since 2.0.0
8009      * @category Array
8010      * @param {Array} array The array to modify.
8011      * @param {Function} [predicate=_.identity] The function invoked per iteration.
8012      * @returns {Array} Returns the new array of removed elements.
8013      * @example
8014      *
8015      * var array = [1, 2, 3, 4];
8016      * var evens = _.remove(array, function(n) {
8017      *   return n % 2 == 0;
8018      * });
8019      *
8020      * console.log(array);
8021      * // => [1, 3]
8022      *
8023      * console.log(evens);
8024      * // => [2, 4]
8025      */
8026     function remove(array, predicate) {
8027       var result = [];
8028       if (!(array && array.length)) {
8029         return result;
8030       }
8031       var index = -1,
8032         indexes = [],
8033         length = array.length;
8034
8035       predicate = getIteratee(predicate, 3);
8036       while (++index < length) {
8037         var value = array[index];
8038         if (predicate(value, index, array)) {
8039           result.push(value);
8040           indexes.push(index);
8041         }
8042       }
8043       basePullAt(array, indexes);
8044       return result;
8045     }
8046
8047     /**
8048      * Reverses `array` so that the first element becomes the last, the second
8049      * element becomes the second to last, and so on.
8050      *
8051      * **Note:** This method mutates `array` and is based on
8052      * [`Array#reverse`](https://mdn.io/Array/reverse).
8053      *
8054      * @static
8055      * @memberOf _
8056      * @since 4.0.0
8057      * @category Array
8058      * @param {Array} array The array to modify.
8059      * @returns {Array} Returns `array`.
8060      * @example
8061      *
8062      * var array = [1, 2, 3];
8063      *
8064      * _.reverse(array);
8065      * // => [3, 2, 1]
8066      *
8067      * console.log(array);
8068      * // => [3, 2, 1]
8069      */
8070     function reverse(array) {
8071       return array == null ? array : nativeReverse.call(array);
8072     }
8073
8074     /**
8075      * Creates a slice of `array` from `start` up to, but not including, `end`.
8076      *
8077      * **Note:** This method is used instead of
8078      * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
8079      * returned.
8080      *
8081      * @static
8082      * @memberOf _
8083      * @since 3.0.0
8084      * @category Array
8085      * @param {Array} array The array to slice.
8086      * @param {number} [start=0] The start position.
8087      * @param {number} [end=array.length] The end position.
8088      * @returns {Array} Returns the slice of `array`.
8089      */
8090     function slice(array, start, end) {
8091       var length = array == null ? 0 : array.length;
8092       if (!length) {
8093         return [];
8094       }
8095       if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
8096         start = 0;
8097         end = length;
8098       } else {
8099         start = start == null ? 0 : toInteger(start);
8100         end = end === undefined ? length : toInteger(end);
8101       }
8102       return baseSlice(array, start, end);
8103     }
8104
8105     /**
8106      * Uses a binary search to determine the lowest index at which `value`
8107      * should be inserted into `array` in order to maintain its sort order.
8108      *
8109      * @static
8110      * @memberOf _
8111      * @since 0.1.0
8112      * @category Array
8113      * @param {Array} array The sorted array to inspect.
8114      * @param {*} value The value to evaluate.
8115      * @returns {number} Returns the index at which `value` should be inserted
8116      *  into `array`.
8117      * @example
8118      *
8119      * _.sortedIndex([30, 50], 40);
8120      * // => 1
8121      */
8122     function sortedIndex(array, value) {
8123       return baseSortedIndex(array, value);
8124     }
8125
8126     /**
8127      * This method is like `_.sortedIndex` except that it accepts `iteratee`
8128      * which is invoked for `value` and each element of `array` to compute their
8129      * sort ranking. The iteratee is invoked with one argument: (value).
8130      *
8131      * @static
8132      * @memberOf _
8133      * @since 4.0.0
8134      * @category Array
8135      * @param {Array} array The sorted array to inspect.
8136      * @param {*} value The value to evaluate.
8137      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8138      * @returns {number} Returns the index at which `value` should be inserted
8139      *  into `array`.
8140      * @example
8141      *
8142      * var objects = [{ 'x': 4 }, { 'x': 5 }];
8143      *
8144      * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8145      * // => 0
8146      *
8147      * // The `_.property` iteratee shorthand.
8148      * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
8149      * // => 0
8150      */
8151     function sortedIndexBy(array, value, iteratee) {
8152       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
8153     }
8154
8155     /**
8156      * This method is like `_.indexOf` except that it performs a binary
8157      * search on a sorted `array`.
8158      *
8159      * @static
8160      * @memberOf _
8161      * @since 4.0.0
8162      * @category Array
8163      * @param {Array} array The array to inspect.
8164      * @param {*} value The value to search for.
8165      * @returns {number} Returns the index of the matched value, else `-1`.
8166      * @example
8167      *
8168      * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
8169      * // => 1
8170      */
8171     function sortedIndexOf(array, value) {
8172       var length = array == null ? 0 : array.length;
8173       if (length) {
8174         var index = baseSortedIndex(array, value);
8175         if (index < length && eq(array[index], value)) {
8176           return index;
8177         }
8178       }
8179       return -1;
8180     }
8181
8182     /**
8183      * This method is like `_.sortedIndex` except that it returns the highest
8184      * index at which `value` should be inserted into `array` in order to
8185      * maintain its sort order.
8186      *
8187      * @static
8188      * @memberOf _
8189      * @since 3.0.0
8190      * @category Array
8191      * @param {Array} array The sorted array to inspect.
8192      * @param {*} value The value to evaluate.
8193      * @returns {number} Returns the index at which `value` should be inserted
8194      *  into `array`.
8195      * @example
8196      *
8197      * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
8198      * // => 4
8199      */
8200     function sortedLastIndex(array, value) {
8201       return baseSortedIndex(array, value, true);
8202     }
8203
8204     /**
8205      * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
8206      * which is invoked for `value` and each element of `array` to compute their
8207      * sort ranking. The iteratee is invoked with one argument: (value).
8208      *
8209      * @static
8210      * @memberOf _
8211      * @since 4.0.0
8212      * @category Array
8213      * @param {Array} array The sorted array to inspect.
8214      * @param {*} value The value to evaluate.
8215      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8216      * @returns {number} Returns the index at which `value` should be inserted
8217      *  into `array`.
8218      * @example
8219      *
8220      * var objects = [{ 'x': 4 }, { 'x': 5 }];
8221      *
8222      * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8223      * // => 1
8224      *
8225      * // The `_.property` iteratee shorthand.
8226      * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8227      * // => 1
8228      */
8229     function sortedLastIndexBy(array, value, iteratee) {
8230       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8231     }
8232
8233     /**
8234      * This method is like `_.lastIndexOf` except that it performs a binary
8235      * search on a sorted `array`.
8236      *
8237      * @static
8238      * @memberOf _
8239      * @since 4.0.0
8240      * @category Array
8241      * @param {Array} array The array to inspect.
8242      * @param {*} value The value to search for.
8243      * @returns {number} Returns the index of the matched value, else `-1`.
8244      * @example
8245      *
8246      * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8247      * // => 3
8248      */
8249     function sortedLastIndexOf(array, value) {
8250       var length = array == null ? 0 : array.length;
8251       if (length) {
8252         var index = baseSortedIndex(array, value, true) - 1;
8253         if (eq(array[index], value)) {
8254           return index;
8255         }
8256       }
8257       return -1;
8258     }
8259
8260     /**
8261      * This method is like `_.uniq` except that it's designed and optimized
8262      * for sorted arrays.
8263      *
8264      * @static
8265      * @memberOf _
8266      * @since 4.0.0
8267      * @category Array
8268      * @param {Array} array The array to inspect.
8269      * @returns {Array} Returns the new duplicate free array.
8270      * @example
8271      *
8272      * _.sortedUniq([1, 1, 2]);
8273      * // => [1, 2]
8274      */
8275     function sortedUniq(array) {
8276       return (array && array.length) ?
8277         baseSortedUniq(array) : [];
8278     }
8279
8280     /**
8281      * This method is like `_.uniqBy` except that it's designed and optimized
8282      * for sorted arrays.
8283      *
8284      * @static
8285      * @memberOf _
8286      * @since 4.0.0
8287      * @category Array
8288      * @param {Array} array The array to inspect.
8289      * @param {Function} [iteratee] The iteratee invoked per element.
8290      * @returns {Array} Returns the new duplicate free array.
8291      * @example
8292      *
8293      * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8294      * // => [1.1, 2.3]
8295      */
8296     function sortedUniqBy(array, iteratee) {
8297       return (array && array.length) ?
8298         baseSortedUniq(array, getIteratee(iteratee, 2)) : [];
8299     }
8300
8301     /**
8302      * Gets all but the first element of `array`.
8303      *
8304      * @static
8305      * @memberOf _
8306      * @since 4.0.0
8307      * @category Array
8308      * @param {Array} array The array to query.
8309      * @returns {Array} Returns the slice of `array`.
8310      * @example
8311      *
8312      * _.tail([1, 2, 3]);
8313      * // => [2, 3]
8314      */
8315     function tail(array) {
8316       var length = array == null ? 0 : array.length;
8317       return length ? baseSlice(array, 1, length) : [];
8318     }
8319
8320     /**
8321      * Creates a slice of `array` with `n` elements taken from the beginning.
8322      *
8323      * @static
8324      * @memberOf _
8325      * @since 0.1.0
8326      * @category Array
8327      * @param {Array} array The array to query.
8328      * @param {number} [n=1] The number of elements to take.
8329      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8330      * @returns {Array} Returns the slice of `array`.
8331      * @example
8332      *
8333      * _.take([1, 2, 3]);
8334      * // => [1]
8335      *
8336      * _.take([1, 2, 3], 2);
8337      * // => [1, 2]
8338      *
8339      * _.take([1, 2, 3], 5);
8340      * // => [1, 2, 3]
8341      *
8342      * _.take([1, 2, 3], 0);
8343      * // => []
8344      */
8345     function take(array, n, guard) {
8346       if (!(array && array.length)) {
8347         return [];
8348       }
8349       n = (guard || n === undefined) ? 1 : toInteger(n);
8350       return baseSlice(array, 0, n < 0 ? 0 : n);
8351     }
8352
8353     /**
8354      * Creates a slice of `array` with `n` elements taken from the end.
8355      *
8356      * @static
8357      * @memberOf _
8358      * @since 3.0.0
8359      * @category Array
8360      * @param {Array} array The array to query.
8361      * @param {number} [n=1] The number of elements to take.
8362      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8363      * @returns {Array} Returns the slice of `array`.
8364      * @example
8365      *
8366      * _.takeRight([1, 2, 3]);
8367      * // => [3]
8368      *
8369      * _.takeRight([1, 2, 3], 2);
8370      * // => [2, 3]
8371      *
8372      * _.takeRight([1, 2, 3], 5);
8373      * // => [1, 2, 3]
8374      *
8375      * _.takeRight([1, 2, 3], 0);
8376      * // => []
8377      */
8378     function takeRight(array, n, guard) {
8379       var length = array == null ? 0 : array.length;
8380       if (!length) {
8381         return [];
8382       }
8383       n = (guard || n === undefined) ? 1 : toInteger(n);
8384       n = length - n;
8385       return baseSlice(array, n < 0 ? 0 : n, length);
8386     }
8387
8388     /**
8389      * Creates a slice of `array` with elements taken from the end. Elements are
8390      * taken until `predicate` returns falsey. The predicate is invoked with
8391      * three arguments: (value, index, array).
8392      *
8393      * @static
8394      * @memberOf _
8395      * @since 3.0.0
8396      * @category Array
8397      * @param {Array} array The array to query.
8398      * @param {Function} [predicate=_.identity] The function invoked per iteration.
8399      * @returns {Array} Returns the slice of `array`.
8400      * @example
8401      *
8402      * var users = [
8403      *   { 'user': 'barney',  'active': true },
8404      *   { 'user': 'fred',    'active': false },
8405      *   { 'user': 'pebbles', 'active': false }
8406      * ];
8407      *
8408      * _.takeRightWhile(users, function(o) { return !o.active; });
8409      * // => objects for ['fred', 'pebbles']
8410      *
8411      * // The `_.matches` iteratee shorthand.
8412      * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8413      * // => objects for ['pebbles']
8414      *
8415      * // The `_.matchesProperty` iteratee shorthand.
8416      * _.takeRightWhile(users, ['active', false]);
8417      * // => objects for ['fred', 'pebbles']
8418      *
8419      * // The `_.property` iteratee shorthand.
8420      * _.takeRightWhile(users, 'active');
8421      * // => []
8422      */
8423     function takeRightWhile(array, predicate) {
8424       return (array && array.length) ?
8425         baseWhile(array, getIteratee(predicate, 3), false, true) : [];
8426     }
8427
8428     /**
8429      * Creates a slice of `array` with elements taken from the beginning. Elements
8430      * are taken until `predicate` returns falsey. The predicate is invoked with
8431      * three arguments: (value, index, array).
8432      *
8433      * @static
8434      * @memberOf _
8435      * @since 3.0.0
8436      * @category Array
8437      * @param {Array} array The array to query.
8438      * @param {Function} [predicate=_.identity] The function invoked per iteration.
8439      * @returns {Array} Returns the slice of `array`.
8440      * @example
8441      *
8442      * var users = [
8443      *   { 'user': 'barney',  'active': false },
8444      *   { 'user': 'fred',    'active': false },
8445      *   { 'user': 'pebbles', 'active': true }
8446      * ];
8447      *
8448      * _.takeWhile(users, function(o) { return !o.active; });
8449      * // => objects for ['barney', 'fred']
8450      *
8451      * // The `_.matches` iteratee shorthand.
8452      * _.takeWhile(users, { 'user': 'barney', 'active': false });
8453      * // => objects for ['barney']
8454      *
8455      * // The `_.matchesProperty` iteratee shorthand.
8456      * _.takeWhile(users, ['active', false]);
8457      * // => objects for ['barney', 'fred']
8458      *
8459      * // The `_.property` iteratee shorthand.
8460      * _.takeWhile(users, 'active');
8461      * // => []
8462      */
8463     function takeWhile(array, predicate) {
8464       return (array && array.length) ?
8465         baseWhile(array, getIteratee(predicate, 3)) : [];
8466     }
8467
8468     /**
8469      * Creates an array of unique values, in order, from all given arrays using
8470      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8471      * for equality comparisons.
8472      *
8473      * @static
8474      * @memberOf _
8475      * @since 0.1.0
8476      * @category Array
8477      * @param {...Array} [arrays] The arrays to inspect.
8478      * @returns {Array} Returns the new array of combined values.
8479      * @example
8480      *
8481      * _.union([2], [1, 2]);
8482      * // => [2, 1]
8483      */
8484     var union = baseRest(function(arrays) {
8485       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8486     });
8487
8488     /**
8489      * This method is like `_.union` except that it accepts `iteratee` which is
8490      * invoked for each element of each `arrays` to generate the criterion by
8491      * which uniqueness is computed. Result values are chosen from the first
8492      * array in which the value occurs. The iteratee is invoked with one argument:
8493      * (value).
8494      *
8495      * @static
8496      * @memberOf _
8497      * @since 4.0.0
8498      * @category Array
8499      * @param {...Array} [arrays] The arrays to inspect.
8500      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8501      * @returns {Array} Returns the new array of combined values.
8502      * @example
8503      *
8504      * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8505      * // => [2.1, 1.2]
8506      *
8507      * // The `_.property` iteratee shorthand.
8508      * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8509      * // => [{ 'x': 1 }, { 'x': 2 }]
8510      */
8511     var unionBy = baseRest(function(arrays) {
8512       var iteratee = last(arrays);
8513       if (isArrayLikeObject(iteratee)) {
8514         iteratee = undefined;
8515       }
8516       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
8517     });
8518
8519     /**
8520      * This method is like `_.union` except that it accepts `comparator` which
8521      * is invoked to compare elements of `arrays`. Result values are chosen from
8522      * the first array in which the value occurs. The comparator is invoked
8523      * with two arguments: (arrVal, othVal).
8524      *
8525      * @static
8526      * @memberOf _
8527      * @since 4.0.0
8528      * @category Array
8529      * @param {...Array} [arrays] The arrays to inspect.
8530      * @param {Function} [comparator] The comparator invoked per element.
8531      * @returns {Array} Returns the new array of combined values.
8532      * @example
8533      *
8534      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8535      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8536      *
8537      * _.unionWith(objects, others, _.isEqual);
8538      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8539      */
8540     var unionWith = baseRest(function(arrays) {
8541       var comparator = last(arrays);
8542       comparator = typeof comparator == 'function' ? comparator : undefined;
8543       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
8544     });
8545
8546     /**
8547      * Creates a duplicate-free version of an array, using
8548      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8549      * for equality comparisons, in which only the first occurrence of each element
8550      * is kept. The order of result values is determined by the order they occur
8551      * in the array.
8552      *
8553      * @static
8554      * @memberOf _
8555      * @since 0.1.0
8556      * @category Array
8557      * @param {Array} array The array to inspect.
8558      * @returns {Array} Returns the new duplicate free array.
8559      * @example
8560      *
8561      * _.uniq([2, 1, 2]);
8562      * // => [2, 1]
8563      */
8564     function uniq(array) {
8565       return (array && array.length) ? baseUniq(array) : [];
8566     }
8567
8568     /**
8569      * This method is like `_.uniq` except that it accepts `iteratee` which is
8570      * invoked for each element in `array` to generate the criterion by which
8571      * uniqueness is computed. The order of result values is determined by the
8572      * order they occur in the array. The iteratee is invoked with one argument:
8573      * (value).
8574      *
8575      * @static
8576      * @memberOf _
8577      * @since 4.0.0
8578      * @category Array
8579      * @param {Array} array The array to inspect.
8580      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8581      * @returns {Array} Returns the new duplicate free array.
8582      * @example
8583      *
8584      * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8585      * // => [2.1, 1.2]
8586      *
8587      * // The `_.property` iteratee shorthand.
8588      * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8589      * // => [{ 'x': 1 }, { 'x': 2 }]
8590      */
8591     function uniqBy(array, iteratee) {
8592       return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
8593     }
8594
8595     /**
8596      * This method is like `_.uniq` except that it accepts `comparator` which
8597      * is invoked to compare elements of `array`. The order of result values is
8598      * determined by the order they occur in the array.The comparator is invoked
8599      * with two arguments: (arrVal, othVal).
8600      *
8601      * @static
8602      * @memberOf _
8603      * @since 4.0.0
8604      * @category Array
8605      * @param {Array} array The array to inspect.
8606      * @param {Function} [comparator] The comparator invoked per element.
8607      * @returns {Array} Returns the new duplicate free array.
8608      * @example
8609      *
8610      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8611      *
8612      * _.uniqWith(objects, _.isEqual);
8613      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8614      */
8615     function uniqWith(array, comparator) {
8616       comparator = typeof comparator == 'function' ? comparator : undefined;
8617       return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
8618     }
8619
8620     /**
8621      * This method is like `_.zip` except that it accepts an array of grouped
8622      * elements and creates an array regrouping the elements to their pre-zip
8623      * configuration.
8624      *
8625      * @static
8626      * @memberOf _
8627      * @since 1.2.0
8628      * @category Array
8629      * @param {Array} array The array of grouped elements to process.
8630      * @returns {Array} Returns the new array of regrouped elements.
8631      * @example
8632      *
8633      * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8634      * // => [['a', 1, true], ['b', 2, false]]
8635      *
8636      * _.unzip(zipped);
8637      * // => [['a', 'b'], [1, 2], [true, false]]
8638      */
8639     function unzip(array) {
8640       if (!(array && array.length)) {
8641         return [];
8642       }
8643       var length = 0;
8644       array = arrayFilter(array, function(group) {
8645         if (isArrayLikeObject(group)) {
8646           length = nativeMax(group.length, length);
8647           return true;
8648         }
8649       });
8650       return baseTimes(length, function(index) {
8651         return arrayMap(array, baseProperty(index));
8652       });
8653     }
8654
8655     /**
8656      * This method is like `_.unzip` except that it accepts `iteratee` to specify
8657      * how regrouped values should be combined. The iteratee is invoked with the
8658      * elements of each group: (...group).
8659      *
8660      * @static
8661      * @memberOf _
8662      * @since 3.8.0
8663      * @category Array
8664      * @param {Array} array The array of grouped elements to process.
8665      * @param {Function} [iteratee=_.identity] The function to combine
8666      *  regrouped values.
8667      * @returns {Array} Returns the new array of regrouped elements.
8668      * @example
8669      *
8670      * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8671      * // => [[1, 10, 100], [2, 20, 200]]
8672      *
8673      * _.unzipWith(zipped, _.add);
8674      * // => [3, 30, 300]
8675      */
8676     function unzipWith(array, iteratee) {
8677       if (!(array && array.length)) {
8678         return [];
8679       }
8680       var result = unzip(array);
8681       if (iteratee == null) {
8682         return result;
8683       }
8684       return arrayMap(result, function(group) {
8685         return apply(iteratee, undefined, group);
8686       });
8687     }
8688
8689     /**
8690      * Creates an array excluding all given values using
8691      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8692      * for equality comparisons.
8693      *
8694      * **Note:** Unlike `_.pull`, this method returns a new array.
8695      *
8696      * @static
8697      * @memberOf _
8698      * @since 0.1.0
8699      * @category Array
8700      * @param {Array} array The array to inspect.
8701      * @param {...*} [values] The values to exclude.
8702      * @returns {Array} Returns the new array of filtered values.
8703      * @see _.difference, _.xor
8704      * @example
8705      *
8706      * _.without([2, 1, 2, 3], 1, 2);
8707      * // => [3]
8708      */
8709     var without = baseRest(function(array, values) {
8710       return isArrayLikeObject(array) ?
8711         baseDifference(array, values) : [];
8712     });
8713
8714     /**
8715      * Creates an array of unique values that is the
8716      * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
8717      * of the given arrays. The order of result values is determined by the order
8718      * they occur in the arrays.
8719      *
8720      * @static
8721      * @memberOf _
8722      * @since 2.4.0
8723      * @category Array
8724      * @param {...Array} [arrays] The arrays to inspect.
8725      * @returns {Array} Returns the new array of filtered values.
8726      * @see _.difference, _.without
8727      * @example
8728      *
8729      * _.xor([2, 1], [2, 3]);
8730      * // => [1, 3]
8731      */
8732     var xor = baseRest(function(arrays) {
8733       return baseXor(arrayFilter(arrays, isArrayLikeObject));
8734     });
8735
8736     /**
8737      * This method is like `_.xor` except that it accepts `iteratee` which is
8738      * invoked for each element of each `arrays` to generate the criterion by
8739      * which by which they're compared. The order of result values is determined
8740      * by the order they occur in the arrays. The iteratee is invoked with one
8741      * argument: (value).
8742      *
8743      * @static
8744      * @memberOf _
8745      * @since 4.0.0
8746      * @category Array
8747      * @param {...Array} [arrays] The arrays to inspect.
8748      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8749      * @returns {Array} Returns the new array of filtered values.
8750      * @example
8751      *
8752      * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8753      * // => [1.2, 3.4]
8754      *
8755      * // The `_.property` iteratee shorthand.
8756      * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8757      * // => [{ 'x': 2 }]
8758      */
8759     var xorBy = baseRest(function(arrays) {
8760       var iteratee = last(arrays);
8761       if (isArrayLikeObject(iteratee)) {
8762         iteratee = undefined;
8763       }
8764       return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
8765     });
8766
8767     /**
8768      * This method is like `_.xor` except that it accepts `comparator` which is
8769      * invoked to compare elements of `arrays`. The order of result values is
8770      * determined by the order they occur in the arrays. The comparator is invoked
8771      * with two arguments: (arrVal, othVal).
8772      *
8773      * @static
8774      * @memberOf _
8775      * @since 4.0.0
8776      * @category Array
8777      * @param {...Array} [arrays] The arrays to inspect.
8778      * @param {Function} [comparator] The comparator invoked per element.
8779      * @returns {Array} Returns the new array of filtered values.
8780      * @example
8781      *
8782      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8783      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8784      *
8785      * _.xorWith(objects, others, _.isEqual);
8786      * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8787      */
8788     var xorWith = baseRest(function(arrays) {
8789       var comparator = last(arrays);
8790       comparator = typeof comparator == 'function' ? comparator : undefined;
8791       return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
8792     });
8793
8794     /**
8795      * Creates an array of grouped elements, the first of which contains the
8796      * first elements of the given arrays, the second of which contains the
8797      * second elements of the given arrays, and so on.
8798      *
8799      * @static
8800      * @memberOf _
8801      * @since 0.1.0
8802      * @category Array
8803      * @param {...Array} [arrays] The arrays to process.
8804      * @returns {Array} Returns the new array of grouped elements.
8805      * @example
8806      *
8807      * _.zip(['a', 'b'], [1, 2], [true, false]);
8808      * // => [['a', 1, true], ['b', 2, false]]
8809      */
8810     var zip = baseRest(unzip);
8811
8812     /**
8813      * This method is like `_.fromPairs` except that it accepts two arrays,
8814      * one of property identifiers and one of corresponding values.
8815      *
8816      * @static
8817      * @memberOf _
8818      * @since 0.4.0
8819      * @category Array
8820      * @param {Array} [props=[]] The property identifiers.
8821      * @param {Array} [values=[]] The property values.
8822      * @returns {Object} Returns the new object.
8823      * @example
8824      *
8825      * _.zipObject(['a', 'b'], [1, 2]);
8826      * // => { 'a': 1, 'b': 2 }
8827      */
8828     function zipObject(props, values) {
8829       return baseZipObject(props || [], values || [], assignValue);
8830     }
8831
8832     /**
8833      * This method is like `_.zipObject` except that it supports property paths.
8834      *
8835      * @static
8836      * @memberOf _
8837      * @since 4.1.0
8838      * @category Array
8839      * @param {Array} [props=[]] The property identifiers.
8840      * @param {Array} [values=[]] The property values.
8841      * @returns {Object} Returns the new object.
8842      * @example
8843      *
8844      * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
8845      * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
8846      */
8847     function zipObjectDeep(props, values) {
8848       return baseZipObject(props || [], values || [], baseSet);
8849     }
8850
8851     /**
8852      * This method is like `_.zip` except that it accepts `iteratee` to specify
8853      * how grouped values should be combined. The iteratee is invoked with the
8854      * elements of each group: (...group).
8855      *
8856      * @static
8857      * @memberOf _
8858      * @since 3.8.0
8859      * @category Array
8860      * @param {...Array} [arrays] The arrays to process.
8861      * @param {Function} [iteratee=_.identity] The function to combine
8862      *  grouped values.
8863      * @returns {Array} Returns the new array of grouped elements.
8864      * @example
8865      *
8866      * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
8867      *   return a + b + c;
8868      * });
8869      * // => [111, 222]
8870      */
8871     var zipWith = baseRest(function(arrays) {
8872       var length = arrays.length,
8873         iteratee = length > 1 ? arrays[length - 1] : undefined;
8874
8875       iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
8876       return unzipWith(arrays, iteratee);
8877     });
8878
8879     /*------------------------------------------------------------------------*/
8880
8881     /**
8882      * Creates a `lodash` wrapper instance that wraps `value` with explicit method
8883      * chain sequences enabled. The result of such sequences must be unwrapped
8884      * with `_#value`.
8885      *
8886      * @static
8887      * @memberOf _
8888      * @since 1.3.0
8889      * @category Seq
8890      * @param {*} value The value to wrap.
8891      * @returns {Object} Returns the new `lodash` wrapper instance.
8892      * @example
8893      *
8894      * var users = [
8895      *   { 'user': 'barney',  'age': 36 },
8896      *   { 'user': 'fred',    'age': 40 },
8897      *   { 'user': 'pebbles', 'age': 1 }
8898      * ];
8899      *
8900      * var youngest = _
8901      *   .chain(users)
8902      *   .sortBy('age')
8903      *   .map(function(o) {
8904      *     return o.user + ' is ' + o.age;
8905      *   })
8906      *   .head()
8907      *   .value();
8908      * // => 'pebbles is 1'
8909      */
8910     function chain(value) {
8911       var result = lodash(value);
8912       result.__chain__ = true;
8913       return result;
8914     }
8915
8916     /**
8917      * This method invokes `interceptor` and returns `value`. The interceptor
8918      * is invoked with one argument; (value). The purpose of this method is to
8919      * "tap into" a method chain sequence in order to modify intermediate results.
8920      *
8921      * @static
8922      * @memberOf _
8923      * @since 0.1.0
8924      * @category Seq
8925      * @param {*} value The value to provide to `interceptor`.
8926      * @param {Function} interceptor The function to invoke.
8927      * @returns {*} Returns `value`.
8928      * @example
8929      *
8930      * _([1, 2, 3])
8931      *  .tap(function(array) {
8932      *    // Mutate input array.
8933      *    array.pop();
8934      *  })
8935      *  .reverse()
8936      *  .value();
8937      * // => [2, 1]
8938      */
8939     function tap(value, interceptor) {
8940       interceptor(value);
8941       return value;
8942     }
8943
8944     /**
8945      * This method is like `_.tap` except that it returns the result of `interceptor`.
8946      * The purpose of this method is to "pass thru" values replacing intermediate
8947      * results in a method chain sequence.
8948      *
8949      * @static
8950      * @memberOf _
8951      * @since 3.0.0
8952      * @category Seq
8953      * @param {*} value The value to provide to `interceptor`.
8954      * @param {Function} interceptor The function to invoke.
8955      * @returns {*} Returns the result of `interceptor`.
8956      * @example
8957      *
8958      * _('  abc  ')
8959      *  .chain()
8960      *  .trim()
8961      *  .thru(function(value) {
8962      *    return [value];
8963      *  })
8964      *  .value();
8965      * // => ['abc']
8966      */
8967     function thru(value, interceptor) {
8968       return interceptor(value);
8969     }
8970
8971     /**
8972      * This method is the wrapper version of `_.at`.
8973      *
8974      * @name at
8975      * @memberOf _
8976      * @since 1.0.0
8977      * @category Seq
8978      * @param {...(string|string[])} [paths] The property paths to pick.
8979      * @returns {Object} Returns the new `lodash` wrapper instance.
8980      * @example
8981      *
8982      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
8983      *
8984      * _(object).at(['a[0].b.c', 'a[1]']).value();
8985      * // => [3, 4]
8986      */
8987     var wrapperAt = flatRest(function(paths) {
8988       var length = paths.length,
8989         start = length ? paths[0] : 0,
8990         value = this.__wrapped__,
8991         interceptor = function(object) {
8992           return baseAt(object, paths);
8993         };
8994
8995       if (length > 1 || this.__actions__.length ||
8996         !(value instanceof LazyWrapper) || !isIndex(start)) {
8997         return this.thru(interceptor);
8998       }
8999       value = value.slice(start, +start + (length ? 1 : 0));
9000       value.__actions__.push({
9001         'func': thru,
9002         'args': [interceptor],
9003         'thisArg': undefined
9004       });
9005       return new LodashWrapper(value, this.__chain__).thru(function(array) {
9006         if (length && !array.length) {
9007           array.push(undefined);
9008         }
9009         return array;
9010       });
9011     });
9012
9013     /**
9014      * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
9015      *
9016      * @name chain
9017      * @memberOf _
9018      * @since 0.1.0
9019      * @category Seq
9020      * @returns {Object} Returns the new `lodash` wrapper instance.
9021      * @example
9022      *
9023      * var users = [
9024      *   { 'user': 'barney', 'age': 36 },
9025      *   { 'user': 'fred',   'age': 40 }
9026      * ];
9027      *
9028      * // A sequence without explicit chaining.
9029      * _(users).head();
9030      * // => { 'user': 'barney', 'age': 36 }
9031      *
9032      * // A sequence with explicit chaining.
9033      * _(users)
9034      *   .chain()
9035      *   .head()
9036      *   .pick('user')
9037      *   .value();
9038      * // => { 'user': 'barney' }
9039      */
9040     function wrapperChain() {
9041       return chain(this);
9042     }
9043
9044     /**
9045      * Executes the chain sequence and returns the wrapped result.
9046      *
9047      * @name commit
9048      * @memberOf _
9049      * @since 3.2.0
9050      * @category Seq
9051      * @returns {Object} Returns the new `lodash` wrapper instance.
9052      * @example
9053      *
9054      * var array = [1, 2];
9055      * var wrapped = _(array).push(3);
9056      *
9057      * console.log(array);
9058      * // => [1, 2]
9059      *
9060      * wrapped = wrapped.commit();
9061      * console.log(array);
9062      * // => [1, 2, 3]
9063      *
9064      * wrapped.last();
9065      * // => 3
9066      *
9067      * console.log(array);
9068      * // => [1, 2, 3]
9069      */
9070     function wrapperCommit() {
9071       return new LodashWrapper(this.value(), this.__chain__);
9072     }
9073
9074     /**
9075      * Gets the next value on a wrapped object following the
9076      * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
9077      *
9078      * @name next
9079      * @memberOf _
9080      * @since 4.0.0
9081      * @category Seq
9082      * @returns {Object} Returns the next iterator value.
9083      * @example
9084      *
9085      * var wrapped = _([1, 2]);
9086      *
9087      * wrapped.next();
9088      * // => { 'done': false, 'value': 1 }
9089      *
9090      * wrapped.next();
9091      * // => { 'done': false, 'value': 2 }
9092      *
9093      * wrapped.next();
9094      * // => { 'done': true, 'value': undefined }
9095      */
9096     function wrapperNext() {
9097       if (this.__values__ === undefined) {
9098         this.__values__ = toArray(this.value());
9099       }
9100       var done = this.__index__ >= this.__values__.length,
9101         value = done ? undefined : this.__values__[this.__index__++];
9102
9103       return {
9104         'done': done,
9105         'value': value
9106       };
9107     }
9108
9109     /**
9110      * Enables the wrapper to be iterable.
9111      *
9112      * @name Symbol.iterator
9113      * @memberOf _
9114      * @since 4.0.0
9115      * @category Seq
9116      * @returns {Object} Returns the wrapper object.
9117      * @example
9118      *
9119      * var wrapped = _([1, 2]);
9120      *
9121      * wrapped[Symbol.iterator]() === wrapped;
9122      * // => true
9123      *
9124      * Array.from(wrapped);
9125      * // => [1, 2]
9126      */
9127     function wrapperToIterator() {
9128       return this;
9129     }
9130
9131     /**
9132      * Creates a clone of the chain sequence planting `value` as the wrapped value.
9133      *
9134      * @name plant
9135      * @memberOf _
9136      * @since 3.2.0
9137      * @category Seq
9138      * @param {*} value The value to plant.
9139      * @returns {Object} Returns the new `lodash` wrapper instance.
9140      * @example
9141      *
9142      * function square(n) {
9143      *   return n * n;
9144      * }
9145      *
9146      * var wrapped = _([1, 2]).map(square);
9147      * var other = wrapped.plant([3, 4]);
9148      *
9149      * other.value();
9150      * // => [9, 16]
9151      *
9152      * wrapped.value();
9153      * // => [1, 4]
9154      */
9155     function wrapperPlant(value) {
9156       var result,
9157         parent = this;
9158
9159       while (parent instanceof baseLodash) {
9160         var clone = wrapperClone(parent);
9161         clone.__index__ = 0;
9162         clone.__values__ = undefined;
9163         if (result) {
9164           previous.__wrapped__ = clone;
9165         } else {
9166           result = clone;
9167         }
9168         var previous = clone;
9169         parent = parent.__wrapped__;
9170       }
9171       previous.__wrapped__ = value;
9172       return result;
9173     }
9174
9175     /**
9176      * This method is the wrapper version of `_.reverse`.
9177      *
9178      * **Note:** This method mutates the wrapped array.
9179      *
9180      * @name reverse
9181      * @memberOf _
9182      * @since 0.1.0
9183      * @category Seq
9184      * @returns {Object} Returns the new `lodash` wrapper instance.
9185      * @example
9186      *
9187      * var array = [1, 2, 3];
9188      *
9189      * _(array).reverse().value()
9190      * // => [3, 2, 1]
9191      *
9192      * console.log(array);
9193      * // => [3, 2, 1]
9194      */
9195     function wrapperReverse() {
9196       var value = this.__wrapped__;
9197       if (value instanceof LazyWrapper) {
9198         var wrapped = value;
9199         if (this.__actions__.length) {
9200           wrapped = new LazyWrapper(this);
9201         }
9202         wrapped = wrapped.reverse();
9203         wrapped.__actions__.push({
9204           'func': thru,
9205           'args': [reverse],
9206           'thisArg': undefined
9207         });
9208         return new LodashWrapper(wrapped, this.__chain__);
9209       }
9210       return this.thru(reverse);
9211     }
9212
9213     /**
9214      * Executes the chain sequence to resolve the unwrapped value.
9215      *
9216      * @name value
9217      * @memberOf _
9218      * @since 0.1.0
9219      * @alias toJSON, valueOf
9220      * @category Seq
9221      * @returns {*} Returns the resolved unwrapped value.
9222      * @example
9223      *
9224      * _([1, 2, 3]).value();
9225      * // => [1, 2, 3]
9226      */
9227     function wrapperValue() {
9228       return baseWrapperValue(this.__wrapped__, this.__actions__);
9229     }
9230
9231     /*------------------------------------------------------------------------*/
9232
9233     /**
9234      * Creates an object composed of keys generated from the results of running
9235      * each element of `collection` thru `iteratee`. The corresponding value of
9236      * each key is the number of times the key was returned by `iteratee`. The
9237      * iteratee is invoked with one argument: (value).
9238      *
9239      * @static
9240      * @memberOf _
9241      * @since 0.5.0
9242      * @category Collection
9243      * @param {Array|Object} collection The collection to iterate over.
9244      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9245      * @returns {Object} Returns the composed aggregate object.
9246      * @example
9247      *
9248      * _.countBy([6.1, 4.2, 6.3], Math.floor);
9249      * // => { '4': 1, '6': 2 }
9250      *
9251      * // The `_.property` iteratee shorthand.
9252      * _.countBy(['one', 'two', 'three'], 'length');
9253      * // => { '3': 2, '5': 1 }
9254      */
9255     var countBy = createAggregator(function(result, value, key) {
9256       if (hasOwnProperty.call(result, key)) {
9257         ++result[key];
9258       } else {
9259         baseAssignValue(result, key, 1);
9260       }
9261     });
9262
9263     /**
9264      * Checks if `predicate` returns truthy for **all** elements of `collection`.
9265      * Iteration is stopped once `predicate` returns falsey. The predicate is
9266      * invoked with three arguments: (value, index|key, collection).
9267      *
9268      * **Note:** This method returns `true` for
9269      * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
9270      * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
9271      * elements of empty collections.
9272      *
9273      * @static
9274      * @memberOf _
9275      * @since 0.1.0
9276      * @category Collection
9277      * @param {Array|Object} collection The collection to iterate over.
9278      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9279      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9280      * @returns {boolean} Returns `true` if all elements pass the predicate check,
9281      *  else `false`.
9282      * @example
9283      *
9284      * _.every([true, 1, null, 'yes'], Boolean);
9285      * // => false
9286      *
9287      * var users = [
9288      *   { 'user': 'barney', 'age': 36, 'active': false },
9289      *   { 'user': 'fred',   'age': 40, 'active': false }
9290      * ];
9291      *
9292      * // The `_.matches` iteratee shorthand.
9293      * _.every(users, { 'user': 'barney', 'active': false });
9294      * // => false
9295      *
9296      * // The `_.matchesProperty` iteratee shorthand.
9297      * _.every(users, ['active', false]);
9298      * // => true
9299      *
9300      * // The `_.property` iteratee shorthand.
9301      * _.every(users, 'active');
9302      * // => false
9303      */
9304     function every(collection, predicate, guard) {
9305       var func = isArray(collection) ? arrayEvery : baseEvery;
9306       if (guard && isIterateeCall(collection, predicate, guard)) {
9307         predicate = undefined;
9308       }
9309       return func(collection, getIteratee(predicate, 3));
9310     }
9311
9312     /**
9313      * Iterates over elements of `collection`, returning an array of all elements
9314      * `predicate` returns truthy for. The predicate is invoked with three
9315      * arguments: (value, index|key, collection).
9316      *
9317      * **Note:** Unlike `_.remove`, this method returns a new array.
9318      *
9319      * @static
9320      * @memberOf _
9321      * @since 0.1.0
9322      * @category Collection
9323      * @param {Array|Object} collection The collection to iterate over.
9324      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9325      * @returns {Array} Returns the new filtered array.
9326      * @see _.reject
9327      * @example
9328      *
9329      * var users = [
9330      *   { 'user': 'barney', 'age': 36, 'active': true },
9331      *   { 'user': 'fred',   'age': 40, 'active': false }
9332      * ];
9333      *
9334      * _.filter(users, function(o) { return !o.active; });
9335      * // => objects for ['fred']
9336      *
9337      * // The `_.matches` iteratee shorthand.
9338      * _.filter(users, { 'age': 36, 'active': true });
9339      * // => objects for ['barney']
9340      *
9341      * // The `_.matchesProperty` iteratee shorthand.
9342      * _.filter(users, ['active', false]);
9343      * // => objects for ['fred']
9344      *
9345      * // The `_.property` iteratee shorthand.
9346      * _.filter(users, 'active');
9347      * // => objects for ['barney']
9348      *
9349      * // Combining several predicates using `_.overEvery` or `_.overSome`.
9350      * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
9351      * // => objects for ['fred', 'barney']
9352      */
9353     function filter(collection, predicate) {
9354       var func = isArray(collection) ? arrayFilter : baseFilter;
9355       return func(collection, getIteratee(predicate, 3));
9356     }
9357
9358     /**
9359      * Iterates over elements of `collection`, returning the first element
9360      * `predicate` returns truthy for. The predicate is invoked with three
9361      * arguments: (value, index|key, collection).
9362      *
9363      * @static
9364      * @memberOf _
9365      * @since 0.1.0
9366      * @category Collection
9367      * @param {Array|Object} collection The collection to inspect.
9368      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9369      * @param {number} [fromIndex=0] The index to search from.
9370      * @returns {*} Returns the matched element, else `undefined`.
9371      * @example
9372      *
9373      * var users = [
9374      *   { 'user': 'barney',  'age': 36, 'active': true },
9375      *   { 'user': 'fred',    'age': 40, 'active': false },
9376      *   { 'user': 'pebbles', 'age': 1,  'active': true }
9377      * ];
9378      *
9379      * _.find(users, function(o) { return o.age < 40; });
9380      * // => object for 'barney'
9381      *
9382      * // The `_.matches` iteratee shorthand.
9383      * _.find(users, { 'age': 1, 'active': true });
9384      * // => object for 'pebbles'
9385      *
9386      * // The `_.matchesProperty` iteratee shorthand.
9387      * _.find(users, ['active', false]);
9388      * // => object for 'fred'
9389      *
9390      * // The `_.property` iteratee shorthand.
9391      * _.find(users, 'active');
9392      * // => object for 'barney'
9393      */
9394     var find = createFind(findIndex);
9395
9396     /**
9397      * This method is like `_.find` except that it iterates over elements of
9398      * `collection` from right to left.
9399      *
9400      * @static
9401      * @memberOf _
9402      * @since 2.0.0
9403      * @category Collection
9404      * @param {Array|Object} collection The collection to inspect.
9405      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9406      * @param {number} [fromIndex=collection.length-1] The index to search from.
9407      * @returns {*} Returns the matched element, else `undefined`.
9408      * @example
9409      *
9410      * _.findLast([1, 2, 3, 4], function(n) {
9411      *   return n % 2 == 1;
9412      * });
9413      * // => 3
9414      */
9415     var findLast = createFind(findLastIndex);
9416
9417     /**
9418      * Creates a flattened array of values by running each element in `collection`
9419      * thru `iteratee` and flattening the mapped results. The iteratee is invoked
9420      * with three arguments: (value, index|key, collection).
9421      *
9422      * @static
9423      * @memberOf _
9424      * @since 4.0.0
9425      * @category Collection
9426      * @param {Array|Object} collection The collection to iterate over.
9427      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9428      * @returns {Array} Returns the new flattened array.
9429      * @example
9430      *
9431      * function duplicate(n) {
9432      *   return [n, n];
9433      * }
9434      *
9435      * _.flatMap([1, 2], duplicate);
9436      * // => [1, 1, 2, 2]
9437      */
9438     function flatMap(collection, iteratee) {
9439       return baseFlatten(map(collection, iteratee), 1);
9440     }
9441
9442     /**
9443      * This method is like `_.flatMap` except that it recursively flattens the
9444      * mapped results.
9445      *
9446      * @static
9447      * @memberOf _
9448      * @since 4.7.0
9449      * @category Collection
9450      * @param {Array|Object} collection The collection to iterate over.
9451      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9452      * @returns {Array} Returns the new flattened array.
9453      * @example
9454      *
9455      * function duplicate(n) {
9456      *   return [[[n, n]]];
9457      * }
9458      *
9459      * _.flatMapDeep([1, 2], duplicate);
9460      * // => [1, 1, 2, 2]
9461      */
9462     function flatMapDeep(collection, iteratee) {
9463       return baseFlatten(map(collection, iteratee), INFINITY);
9464     }
9465
9466     /**
9467      * This method is like `_.flatMap` except that it recursively flattens the
9468      * mapped results up to `depth` times.
9469      *
9470      * @static
9471      * @memberOf _
9472      * @since 4.7.0
9473      * @category Collection
9474      * @param {Array|Object} collection The collection to iterate over.
9475      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9476      * @param {number} [depth=1] The maximum recursion depth.
9477      * @returns {Array} Returns the new flattened array.
9478      * @example
9479      *
9480      * function duplicate(n) {
9481      *   return [[[n, n]]];
9482      * }
9483      *
9484      * _.flatMapDepth([1, 2], duplicate, 2);
9485      * // => [[1, 1], [2, 2]]
9486      */
9487     function flatMapDepth(collection, iteratee, depth) {
9488       depth = depth === undefined ? 1 : toInteger(depth);
9489       return baseFlatten(map(collection, iteratee), depth);
9490     }
9491
9492     /**
9493      * Iterates over elements of `collection` and invokes `iteratee` for each element.
9494      * The iteratee is invoked with three arguments: (value, index|key, collection).
9495      * Iteratee functions may exit iteration early by explicitly returning `false`.
9496      *
9497      * **Note:** As with other "Collections" methods, objects with a "length"
9498      * property are iterated like arrays. To avoid this behavior use `_.forIn`
9499      * or `_.forOwn` for object iteration.
9500      *
9501      * @static
9502      * @memberOf _
9503      * @since 0.1.0
9504      * @alias each
9505      * @category Collection
9506      * @param {Array|Object} collection The collection to iterate over.
9507      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9508      * @returns {Array|Object} Returns `collection`.
9509      * @see _.forEachRight
9510      * @example
9511      *
9512      * _.forEach([1, 2], function(value) {
9513      *   console.log(value);
9514      * });
9515      * // => Logs `1` then `2`.
9516      *
9517      * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9518      *   console.log(key);
9519      * });
9520      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9521      */
9522     function forEach(collection, iteratee) {
9523       var func = isArray(collection) ? arrayEach : baseEach;
9524       return func(collection, getIteratee(iteratee, 3));
9525     }
9526
9527     /**
9528      * This method is like `_.forEach` except that it iterates over elements of
9529      * `collection` from right to left.
9530      *
9531      * @static
9532      * @memberOf _
9533      * @since 2.0.0
9534      * @alias eachRight
9535      * @category Collection
9536      * @param {Array|Object} collection The collection to iterate over.
9537      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9538      * @returns {Array|Object} Returns `collection`.
9539      * @see _.forEach
9540      * @example
9541      *
9542      * _.forEachRight([1, 2], function(value) {
9543      *   console.log(value);
9544      * });
9545      * // => Logs `2` then `1`.
9546      */
9547     function forEachRight(collection, iteratee) {
9548       var func = isArray(collection) ? arrayEachRight : baseEachRight;
9549       return func(collection, getIteratee(iteratee, 3));
9550     }
9551
9552     /**
9553      * Creates an object composed of keys generated from the results of running
9554      * each element of `collection` thru `iteratee`. The order of grouped values
9555      * is determined by the order they occur in `collection`. The corresponding
9556      * value of each key is an array of elements responsible for generating the
9557      * key. The iteratee is invoked with one argument: (value).
9558      *
9559      * @static
9560      * @memberOf _
9561      * @since 0.1.0
9562      * @category Collection
9563      * @param {Array|Object} collection The collection to iterate over.
9564      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9565      * @returns {Object} Returns the composed aggregate object.
9566      * @example
9567      *
9568      * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9569      * // => { '4': [4.2], '6': [6.1, 6.3] }
9570      *
9571      * // The `_.property` iteratee shorthand.
9572      * _.groupBy(['one', 'two', 'three'], 'length');
9573      * // => { '3': ['one', 'two'], '5': ['three'] }
9574      */
9575     var groupBy = createAggregator(function(result, value, key) {
9576       if (hasOwnProperty.call(result, key)) {
9577         result[key].push(value);
9578       } else {
9579         baseAssignValue(result, key, [value]);
9580       }
9581     });
9582
9583     /**
9584      * Checks if `value` is in `collection`. If `collection` is a string, it's
9585      * checked for a substring of `value`, otherwise
9586      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9587      * is used for equality comparisons. If `fromIndex` is negative, it's used as
9588      * the offset from the end of `collection`.
9589      *
9590      * @static
9591      * @memberOf _
9592      * @since 0.1.0
9593      * @category Collection
9594      * @param {Array|Object|string} collection The collection to inspect.
9595      * @param {*} value The value to search for.
9596      * @param {number} [fromIndex=0] The index to search from.
9597      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9598      * @returns {boolean} Returns `true` if `value` is found, else `false`.
9599      * @example
9600      *
9601      * _.includes([1, 2, 3], 1);
9602      * // => true
9603      *
9604      * _.includes([1, 2, 3], 1, 2);
9605      * // => false
9606      *
9607      * _.includes({ 'a': 1, 'b': 2 }, 1);
9608      * // => true
9609      *
9610      * _.includes('abcd', 'bc');
9611      * // => true
9612      */
9613     function includes(collection, value, fromIndex, guard) {
9614       collection = isArrayLike(collection) ? collection : values(collection);
9615       fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9616
9617       var length = collection.length;
9618       if (fromIndex < 0) {
9619         fromIndex = nativeMax(length + fromIndex, 0);
9620       }
9621       return isString(collection) ?
9622         (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) :
9623         (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9624     }
9625
9626     /**
9627      * Invokes the method at `path` of each element in `collection`, returning
9628      * an array of the results of each invoked method. Any additional arguments
9629      * are provided to each invoked method. If `path` is a function, it's invoked
9630      * for, and `this` bound to, each element in `collection`.
9631      *
9632      * @static
9633      * @memberOf _
9634      * @since 4.0.0
9635      * @category Collection
9636      * @param {Array|Object} collection The collection to iterate over.
9637      * @param {Array|Function|string} path The path of the method to invoke or
9638      *  the function invoked per iteration.
9639      * @param {...*} [args] The arguments to invoke each method with.
9640      * @returns {Array} Returns the array of results.
9641      * @example
9642      *
9643      * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9644      * // => [[1, 5, 7], [1, 2, 3]]
9645      *
9646      * _.invokeMap([123, 456], String.prototype.split, '');
9647      * // => [['1', '2', '3'], ['4', '5', '6']]
9648      */
9649     var invokeMap = baseRest(function(collection, path, args) {
9650       var index = -1,
9651         isFunc = typeof path == 'function',
9652         result = isArrayLike(collection) ? Array(collection.length) : [];
9653
9654       baseEach(collection, function(value) {
9655         result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
9656       });
9657       return result;
9658     });
9659
9660     /**
9661      * Creates an object composed of keys generated from the results of running
9662      * each element of `collection` thru `iteratee`. The corresponding value of
9663      * each key is the last element responsible for generating the key. The
9664      * iteratee is invoked with one argument: (value).
9665      *
9666      * @static
9667      * @memberOf _
9668      * @since 4.0.0
9669      * @category Collection
9670      * @param {Array|Object} collection The collection to iterate over.
9671      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9672      * @returns {Object} Returns the composed aggregate object.
9673      * @example
9674      *
9675      * var array = [
9676      *   { 'dir': 'left', 'code': 97 },
9677      *   { 'dir': 'right', 'code': 100 }
9678      * ];
9679      *
9680      * _.keyBy(array, function(o) {
9681      *   return String.fromCharCode(o.code);
9682      * });
9683      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9684      *
9685      * _.keyBy(array, 'dir');
9686      * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9687      */
9688     var keyBy = createAggregator(function(result, value, key) {
9689       baseAssignValue(result, key, value);
9690     });
9691
9692     /**
9693      * Creates an array of values by running each element in `collection` thru
9694      * `iteratee`. The iteratee is invoked with three arguments:
9695      * (value, index|key, collection).
9696      *
9697      * Many lodash methods are guarded to work as iteratees for methods like
9698      * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9699      *
9700      * The guarded methods are:
9701      * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9702      * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9703      * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9704      * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9705      *
9706      * @static
9707      * @memberOf _
9708      * @since 0.1.0
9709      * @category Collection
9710      * @param {Array|Object} collection The collection to iterate over.
9711      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9712      * @returns {Array} Returns the new mapped array.
9713      * @example
9714      *
9715      * function square(n) {
9716      *   return n * n;
9717      * }
9718      *
9719      * _.map([4, 8], square);
9720      * // => [16, 64]
9721      *
9722      * _.map({ 'a': 4, 'b': 8 }, square);
9723      * // => [16, 64] (iteration order is not guaranteed)
9724      *
9725      * var users = [
9726      *   { 'user': 'barney' },
9727      *   { 'user': 'fred' }
9728      * ];
9729      *
9730      * // The `_.property` iteratee shorthand.
9731      * _.map(users, 'user');
9732      * // => ['barney', 'fred']
9733      */
9734     function map(collection, iteratee) {
9735       var func = isArray(collection) ? arrayMap : baseMap;
9736       return func(collection, getIteratee(iteratee, 3));
9737     }
9738
9739     /**
9740      * This method is like `_.sortBy` except that it allows specifying the sort
9741      * orders of the iteratees to sort by. If `orders` is unspecified, all values
9742      * are sorted in ascending order. Otherwise, specify an order of "desc" for
9743      * descending or "asc" for ascending sort order of corresponding values.
9744      *
9745      * @static
9746      * @memberOf _
9747      * @since 4.0.0
9748      * @category Collection
9749      * @param {Array|Object} collection The collection to iterate over.
9750      * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
9751      *  The iteratees to sort by.
9752      * @param {string[]} [orders] The sort orders of `iteratees`.
9753      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9754      * @returns {Array} Returns the new sorted array.
9755      * @example
9756      *
9757      * var users = [
9758      *   { 'user': 'fred',   'age': 48 },
9759      *   { 'user': 'barney', 'age': 34 },
9760      *   { 'user': 'fred',   'age': 40 },
9761      *   { 'user': 'barney', 'age': 36 }
9762      * ];
9763      *
9764      * // Sort by `user` in ascending order and by `age` in descending order.
9765      * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
9766      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9767      */
9768     function orderBy(collection, iteratees, orders, guard) {
9769       if (collection == null) {
9770         return [];
9771       }
9772       if (!isArray(iteratees)) {
9773         iteratees = iteratees == null ? [] : [iteratees];
9774       }
9775       orders = guard ? undefined : orders;
9776       if (!isArray(orders)) {
9777         orders = orders == null ? [] : [orders];
9778       }
9779       return baseOrderBy(collection, iteratees, orders);
9780     }
9781
9782     /**
9783      * Creates an array of elements split into two groups, the first of which
9784      * contains elements `predicate` returns truthy for, the second of which
9785      * contains elements `predicate` returns falsey for. The predicate is
9786      * invoked with one argument: (value).
9787      *
9788      * @static
9789      * @memberOf _
9790      * @since 3.0.0
9791      * @category Collection
9792      * @param {Array|Object} collection The collection to iterate over.
9793      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9794      * @returns {Array} Returns the array of grouped elements.
9795      * @example
9796      *
9797      * var users = [
9798      *   { 'user': 'barney',  'age': 36, 'active': false },
9799      *   { 'user': 'fred',    'age': 40, 'active': true },
9800      *   { 'user': 'pebbles', 'age': 1,  'active': false }
9801      * ];
9802      *
9803      * _.partition(users, function(o) { return o.active; });
9804      * // => objects for [['fred'], ['barney', 'pebbles']]
9805      *
9806      * // The `_.matches` iteratee shorthand.
9807      * _.partition(users, { 'age': 1, 'active': false });
9808      * // => objects for [['pebbles'], ['barney', 'fred']]
9809      *
9810      * // The `_.matchesProperty` iteratee shorthand.
9811      * _.partition(users, ['active', false]);
9812      * // => objects for [['barney', 'pebbles'], ['fred']]
9813      *
9814      * // The `_.property` iteratee shorthand.
9815      * _.partition(users, 'active');
9816      * // => objects for [['fred'], ['barney', 'pebbles']]
9817      */
9818     var partition = createAggregator(function(result, value, key) {
9819       result[key ? 0 : 1].push(value);
9820     }, function() {
9821       return [
9822         [],
9823         []
9824       ];
9825     });
9826
9827     /**
9828      * Reduces `collection` to a value which is the accumulated result of running
9829      * each element in `collection` thru `iteratee`, where each successive
9830      * invocation is supplied the return value of the previous. If `accumulator`
9831      * is not given, the first element of `collection` is used as the initial
9832      * value. The iteratee is invoked with four arguments:
9833      * (accumulator, value, index|key, collection).
9834      *
9835      * Many lodash methods are guarded to work as iteratees for methods like
9836      * `_.reduce`, `_.reduceRight`, and `_.transform`.
9837      *
9838      * The guarded methods are:
9839      * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
9840      * and `sortBy`
9841      *
9842      * @static
9843      * @memberOf _
9844      * @since 0.1.0
9845      * @category Collection
9846      * @param {Array|Object} collection The collection to iterate over.
9847      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9848      * @param {*} [accumulator] The initial value.
9849      * @returns {*} Returns the accumulated value.
9850      * @see _.reduceRight
9851      * @example
9852      *
9853      * _.reduce([1, 2], function(sum, n) {
9854      *   return sum + n;
9855      * }, 0);
9856      * // => 3
9857      *
9858      * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
9859      *   (result[value] || (result[value] = [])).push(key);
9860      *   return result;
9861      * }, {});
9862      * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
9863      */
9864     function reduce(collection, iteratee, accumulator) {
9865       var func = isArray(collection) ? arrayReduce : baseReduce,
9866         initAccum = arguments.length < 3;
9867
9868       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
9869     }
9870
9871     /**
9872      * This method is like `_.reduce` except that it iterates over elements of
9873      * `collection` from right to left.
9874      *
9875      * @static
9876      * @memberOf _
9877      * @since 0.1.0
9878      * @category Collection
9879      * @param {Array|Object} collection The collection to iterate over.
9880      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9881      * @param {*} [accumulator] The initial value.
9882      * @returns {*} Returns the accumulated value.
9883      * @see _.reduce
9884      * @example
9885      *
9886      * var array = [[0, 1], [2, 3], [4, 5]];
9887      *
9888      * _.reduceRight(array, function(flattened, other) {
9889      *   return flattened.concat(other);
9890      * }, []);
9891      * // => [4, 5, 2, 3, 0, 1]
9892      */
9893     function reduceRight(collection, iteratee, accumulator) {
9894       var func = isArray(collection) ? arrayReduceRight : baseReduce,
9895         initAccum = arguments.length < 3;
9896
9897       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
9898     }
9899
9900     /**
9901      * The opposite of `_.filter`; this method returns the elements of `collection`
9902      * that `predicate` does **not** return truthy for.
9903      *
9904      * @static
9905      * @memberOf _
9906      * @since 0.1.0
9907      * @category Collection
9908      * @param {Array|Object} collection The collection to iterate over.
9909      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9910      * @returns {Array} Returns the new filtered array.
9911      * @see _.filter
9912      * @example
9913      *
9914      * var users = [
9915      *   { 'user': 'barney', 'age': 36, 'active': false },
9916      *   { 'user': 'fred',   'age': 40, 'active': true }
9917      * ];
9918      *
9919      * _.reject(users, function(o) { return !o.active; });
9920      * // => objects for ['fred']
9921      *
9922      * // The `_.matches` iteratee shorthand.
9923      * _.reject(users, { 'age': 40, 'active': true });
9924      * // => objects for ['barney']
9925      *
9926      * // The `_.matchesProperty` iteratee shorthand.
9927      * _.reject(users, ['active', false]);
9928      * // => objects for ['fred']
9929      *
9930      * // The `_.property` iteratee shorthand.
9931      * _.reject(users, 'active');
9932      * // => objects for ['barney']
9933      */
9934     function reject(collection, predicate) {
9935       var func = isArray(collection) ? arrayFilter : baseFilter;
9936       return func(collection, negate(getIteratee(predicate, 3)));
9937     }
9938
9939     /**
9940      * Gets a random element from `collection`.
9941      *
9942      * @static
9943      * @memberOf _
9944      * @since 2.0.0
9945      * @category Collection
9946      * @param {Array|Object} collection The collection to sample.
9947      * @returns {*} Returns the random element.
9948      * @example
9949      *
9950      * _.sample([1, 2, 3, 4]);
9951      * // => 2
9952      */
9953     function sample(collection) {
9954       var func = isArray(collection) ? arraySample : baseSample;
9955       return func(collection);
9956     }
9957
9958     /**
9959      * Gets `n` random elements at unique keys from `collection` up to the
9960      * size of `collection`.
9961      *
9962      * @static
9963      * @memberOf _
9964      * @since 4.0.0
9965      * @category Collection
9966      * @param {Array|Object} collection The collection to sample.
9967      * @param {number} [n=1] The number of elements to sample.
9968      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9969      * @returns {Array} Returns the random elements.
9970      * @example
9971      *
9972      * _.sampleSize([1, 2, 3], 2);
9973      * // => [3, 1]
9974      *
9975      * _.sampleSize([1, 2, 3], 4);
9976      * // => [2, 3, 1]
9977      */
9978     function sampleSize(collection, n, guard) {
9979       if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
9980         n = 1;
9981       } else {
9982         n = toInteger(n);
9983       }
9984       var func = isArray(collection) ? arraySampleSize : baseSampleSize;
9985       return func(collection, n);
9986     }
9987
9988     /**
9989      * Creates an array of shuffled values, using a version of the
9990      * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9991      *
9992      * @static
9993      * @memberOf _
9994      * @since 0.1.0
9995      * @category Collection
9996      * @param {Array|Object} collection The collection to shuffle.
9997      * @returns {Array} Returns the new shuffled array.
9998      * @example
9999      *
10000      * _.shuffle([1, 2, 3, 4]);
10001      * // => [4, 1, 3, 2]
10002      */
10003     function shuffle(collection) {
10004       var func = isArray(collection) ? arrayShuffle : baseShuffle;
10005       return func(collection);
10006     }
10007
10008     /**
10009      * Gets the size of `collection` by returning its length for array-like
10010      * values or the number of own enumerable string keyed properties for objects.
10011      *
10012      * @static
10013      * @memberOf _
10014      * @since 0.1.0
10015      * @category Collection
10016      * @param {Array|Object|string} collection The collection to inspect.
10017      * @returns {number} Returns the collection size.
10018      * @example
10019      *
10020      * _.size([1, 2, 3]);
10021      * // => 3
10022      *
10023      * _.size({ 'a': 1, 'b': 2 });
10024      * // => 2
10025      *
10026      * _.size('pebbles');
10027      * // => 7
10028      */
10029     function size(collection) {
10030       if (collection == null) {
10031         return 0;
10032       }
10033       if (isArrayLike(collection)) {
10034         return isString(collection) ? stringSize(collection) : collection.length;
10035       }
10036       var tag = getTag(collection);
10037       if (tag == mapTag || tag == setTag) {
10038         return collection.size;
10039       }
10040       return baseKeys(collection).length;
10041     }
10042
10043     /**
10044      * Checks if `predicate` returns truthy for **any** element of `collection`.
10045      * Iteration is stopped once `predicate` returns truthy. The predicate is
10046      * invoked with three arguments: (value, index|key, collection).
10047      *
10048      * @static
10049      * @memberOf _
10050      * @since 0.1.0
10051      * @category Collection
10052      * @param {Array|Object} collection The collection to iterate over.
10053      * @param {Function} [predicate=_.identity] The function invoked per iteration.
10054      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10055      * @returns {boolean} Returns `true` if any element passes the predicate check,
10056      *  else `false`.
10057      * @example
10058      *
10059      * _.some([null, 0, 'yes', false], Boolean);
10060      * // => true
10061      *
10062      * var users = [
10063      *   { 'user': 'barney', 'active': true },
10064      *   { 'user': 'fred',   'active': false }
10065      * ];
10066      *
10067      * // The `_.matches` iteratee shorthand.
10068      * _.some(users, { 'user': 'barney', 'active': false });
10069      * // => false
10070      *
10071      * // The `_.matchesProperty` iteratee shorthand.
10072      * _.some(users, ['active', false]);
10073      * // => true
10074      *
10075      * // The `_.property` iteratee shorthand.
10076      * _.some(users, 'active');
10077      * // => true
10078      */
10079     function some(collection, predicate, guard) {
10080       var func = isArray(collection) ? arraySome : baseSome;
10081       if (guard && isIterateeCall(collection, predicate, guard)) {
10082         predicate = undefined;
10083       }
10084       return func(collection, getIteratee(predicate, 3));
10085     }
10086
10087     /**
10088      * Creates an array of elements, sorted in ascending order by the results of
10089      * running each element in a collection thru each iteratee. This method
10090      * performs a stable sort, that is, it preserves the original sort order of
10091      * equal elements. The iteratees are invoked with one argument: (value).
10092      *
10093      * @static
10094      * @memberOf _
10095      * @since 0.1.0
10096      * @category Collection
10097      * @param {Array|Object} collection The collection to iterate over.
10098      * @param {...(Function|Function[])} [iteratees=[_.identity]]
10099      *  The iteratees to sort by.
10100      * @returns {Array} Returns the new sorted array.
10101      * @example
10102      *
10103      * var users = [
10104      *   { 'user': 'fred',   'age': 48 },
10105      *   { 'user': 'barney', 'age': 36 },
10106      *   { 'user': 'fred',   'age': 30 },
10107      *   { 'user': 'barney', 'age': 34 }
10108      * ];
10109      *
10110      * _.sortBy(users, [function(o) { return o.user; }]);
10111      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
10112      *
10113      * _.sortBy(users, ['user', 'age']);
10114      * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
10115      */
10116     var sortBy = baseRest(function(collection, iteratees) {
10117       if (collection == null) {
10118         return [];
10119       }
10120       var length = iteratees.length;
10121       if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
10122         iteratees = [];
10123       } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
10124         iteratees = [iteratees[0]];
10125       }
10126       return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
10127     });
10128
10129     /*------------------------------------------------------------------------*/
10130
10131     /**
10132      * Gets the timestamp of the number of milliseconds that have elapsed since
10133      * the Unix epoch (1 January 1970 00:00:00 UTC).
10134      *
10135      * @static
10136      * @memberOf _
10137      * @since 2.4.0
10138      * @category Date
10139      * @returns {number} Returns the timestamp.
10140      * @example
10141      *
10142      * _.defer(function(stamp) {
10143      *   console.log(_.now() - stamp);
10144      * }, _.now());
10145      * // => Logs the number of milliseconds it took for the deferred invocation.
10146      */
10147     var now = ctxNow || function() {
10148       return root.Date.now();
10149     };
10150
10151     /*------------------------------------------------------------------------*/
10152
10153     /**
10154      * The opposite of `_.before`; this method creates a function that invokes
10155      * `func` once it's called `n` or more times.
10156      *
10157      * @static
10158      * @memberOf _
10159      * @since 0.1.0
10160      * @category Function
10161      * @param {number} n The number of calls before `func` is invoked.
10162      * @param {Function} func The function to restrict.
10163      * @returns {Function} Returns the new restricted function.
10164      * @example
10165      *
10166      * var saves = ['profile', 'settings'];
10167      *
10168      * var done = _.after(saves.length, function() {
10169      *   console.log('done saving!');
10170      * });
10171      *
10172      * _.forEach(saves, function(type) {
10173      *   asyncSave({ 'type': type, 'complete': done });
10174      * });
10175      * // => Logs 'done saving!' after the two async saves have completed.
10176      */
10177     function after(n, func) {
10178       if (typeof func != 'function') {
10179         throw new TypeError(FUNC_ERROR_TEXT);
10180       }
10181       n = toInteger(n);
10182       return function() {
10183         if (--n < 1) {
10184           return func.apply(this, arguments);
10185         }
10186       };
10187     }
10188
10189     /**
10190      * Creates a function that invokes `func`, with up to `n` arguments,
10191      * ignoring any additional arguments.
10192      *
10193      * @static
10194      * @memberOf _
10195      * @since 3.0.0
10196      * @category Function
10197      * @param {Function} func The function to cap arguments for.
10198      * @param {number} [n=func.length] The arity cap.
10199      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10200      * @returns {Function} Returns the new capped function.
10201      * @example
10202      *
10203      * _.map(['6', '8', '10'], _.ary(parseInt, 1));
10204      * // => [6, 8, 10]
10205      */
10206     function ary(func, n, guard) {
10207       n = guard ? undefined : n;
10208       n = (func && n == null) ? func.length : n;
10209       return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
10210     }
10211
10212     /**
10213      * Creates a function that invokes `func`, with the `this` binding and arguments
10214      * of the created function, while it's called less than `n` times. Subsequent
10215      * calls to the created function return the result of the last `func` invocation.
10216      *
10217      * @static
10218      * @memberOf _
10219      * @since 3.0.0
10220      * @category Function
10221      * @param {number} n The number of calls at which `func` is no longer invoked.
10222      * @param {Function} func The function to restrict.
10223      * @returns {Function} Returns the new restricted function.
10224      * @example
10225      *
10226      * jQuery(element).on('click', _.before(5, addContactToList));
10227      * // => Allows adding up to 4 contacts to the list.
10228      */
10229     function before(n, func) {
10230       var result;
10231       if (typeof func != 'function') {
10232         throw new TypeError(FUNC_ERROR_TEXT);
10233       }
10234       n = toInteger(n);
10235       return function() {
10236         if (--n > 0) {
10237           result = func.apply(this, arguments);
10238         }
10239         if (n <= 1) {
10240           func = undefined;
10241         }
10242         return result;
10243       };
10244     }
10245
10246     /**
10247      * Creates a function that invokes `func` with the `this` binding of `thisArg`
10248      * and `partials` prepended to the arguments it receives.
10249      *
10250      * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10251      * may be used as a placeholder for partially applied arguments.
10252      *
10253      * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10254      * property of bound functions.
10255      *
10256      * @static
10257      * @memberOf _
10258      * @since 0.1.0
10259      * @category Function
10260      * @param {Function} func The function to bind.
10261      * @param {*} thisArg The `this` binding of `func`.
10262      * @param {...*} [partials] The arguments to be partially applied.
10263      * @returns {Function} Returns the new bound function.
10264      * @example
10265      *
10266      * function greet(greeting, punctuation) {
10267      *   return greeting + ' ' + this.user + punctuation;
10268      * }
10269      *
10270      * var object = { 'user': 'fred' };
10271      *
10272      * var bound = _.bind(greet, object, 'hi');
10273      * bound('!');
10274      * // => 'hi fred!'
10275      *
10276      * // Bound with placeholders.
10277      * var bound = _.bind(greet, object, _, '!');
10278      * bound('hi');
10279      * // => 'hi fred!'
10280      */
10281     var bind = baseRest(function(func, thisArg, partials) {
10282       var bitmask = WRAP_BIND_FLAG;
10283       if (partials.length) {
10284         var holders = replaceHolders(partials, getHolder(bind));
10285         bitmask |= WRAP_PARTIAL_FLAG;
10286       }
10287       return createWrap(func, bitmask, thisArg, partials, holders);
10288     });
10289
10290     /**
10291      * Creates a function that invokes the method at `object[key]` with `partials`
10292      * prepended to the arguments it receives.
10293      *
10294      * This method differs from `_.bind` by allowing bound functions to reference
10295      * methods that may be redefined or don't yet exist. See
10296      * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
10297      * for more details.
10298      *
10299      * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10300      * builds, may be used as a placeholder for partially applied arguments.
10301      *
10302      * @static
10303      * @memberOf _
10304      * @since 0.10.0
10305      * @category Function
10306      * @param {Object} object The object to invoke the method on.
10307      * @param {string} key The key of the method.
10308      * @param {...*} [partials] The arguments to be partially applied.
10309      * @returns {Function} Returns the new bound function.
10310      * @example
10311      *
10312      * var object = {
10313      *   'user': 'fred',
10314      *   'greet': function(greeting, punctuation) {
10315      *     return greeting + ' ' + this.user + punctuation;
10316      *   }
10317      * };
10318      *
10319      * var bound = _.bindKey(object, 'greet', 'hi');
10320      * bound('!');
10321      * // => 'hi fred!'
10322      *
10323      * object.greet = function(greeting, punctuation) {
10324      *   return greeting + 'ya ' + this.user + punctuation;
10325      * };
10326      *
10327      * bound('!');
10328      * // => 'hiya fred!'
10329      *
10330      * // Bound with placeholders.
10331      * var bound = _.bindKey(object, 'greet', _, '!');
10332      * bound('hi');
10333      * // => 'hiya fred!'
10334      */
10335     var bindKey = baseRest(function(object, key, partials) {
10336       var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
10337       if (partials.length) {
10338         var holders = replaceHolders(partials, getHolder(bindKey));
10339         bitmask |= WRAP_PARTIAL_FLAG;
10340       }
10341       return createWrap(key, bitmask, object, partials, holders);
10342     });
10343
10344     /**
10345      * Creates a function that accepts arguments of `func` and either invokes
10346      * `func` returning its result, if at least `arity` number of arguments have
10347      * been provided, or returns a function that accepts the remaining `func`
10348      * arguments, and so on. The arity of `func` may be specified if `func.length`
10349      * is not sufficient.
10350      *
10351      * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10352      * may be used as a placeholder for provided arguments.
10353      *
10354      * **Note:** This method doesn't set the "length" property of curried functions.
10355      *
10356      * @static
10357      * @memberOf _
10358      * @since 2.0.0
10359      * @category Function
10360      * @param {Function} func The function to curry.
10361      * @param {number} [arity=func.length] The arity of `func`.
10362      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10363      * @returns {Function} Returns the new curried function.
10364      * @example
10365      *
10366      * var abc = function(a, b, c) {
10367      *   return [a, b, c];
10368      * };
10369      *
10370      * var curried = _.curry(abc);
10371      *
10372      * curried(1)(2)(3);
10373      * // => [1, 2, 3]
10374      *
10375      * curried(1, 2)(3);
10376      * // => [1, 2, 3]
10377      *
10378      * curried(1, 2, 3);
10379      * // => [1, 2, 3]
10380      *
10381      * // Curried with placeholders.
10382      * curried(1)(_, 3)(2);
10383      * // => [1, 2, 3]
10384      */
10385     function curry(func, arity, guard) {
10386       arity = guard ? undefined : arity;
10387       var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10388       result.placeholder = curry.placeholder;
10389       return result;
10390     }
10391
10392     /**
10393      * This method is like `_.curry` except that arguments are applied to `func`
10394      * in the manner of `_.partialRight` instead of `_.partial`.
10395      *
10396      * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10397      * builds, may be used as a placeholder for provided arguments.
10398      *
10399      * **Note:** This method doesn't set the "length" property of curried functions.
10400      *
10401      * @static
10402      * @memberOf _
10403      * @since 3.0.0
10404      * @category Function
10405      * @param {Function} func The function to curry.
10406      * @param {number} [arity=func.length] The arity of `func`.
10407      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10408      * @returns {Function} Returns the new curried function.
10409      * @example
10410      *
10411      * var abc = function(a, b, c) {
10412      *   return [a, b, c];
10413      * };
10414      *
10415      * var curried = _.curryRight(abc);
10416      *
10417      * curried(3)(2)(1);
10418      * // => [1, 2, 3]
10419      *
10420      * curried(2, 3)(1);
10421      * // => [1, 2, 3]
10422      *
10423      * curried(1, 2, 3);
10424      * // => [1, 2, 3]
10425      *
10426      * // Curried with placeholders.
10427      * curried(3)(1, _)(2);
10428      * // => [1, 2, 3]
10429      */
10430     function curryRight(func, arity, guard) {
10431       arity = guard ? undefined : arity;
10432       var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10433       result.placeholder = curryRight.placeholder;
10434       return result;
10435     }
10436
10437     /**
10438      * Creates a debounced function that delays invoking `func` until after `wait`
10439      * milliseconds have elapsed since the last time the debounced function was
10440      * invoked. The debounced function comes with a `cancel` method to cancel
10441      * delayed `func` invocations and a `flush` method to immediately invoke them.
10442      * Provide `options` to indicate whether `func` should be invoked on the
10443      * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
10444      * with the last arguments provided to the debounced function. Subsequent
10445      * calls to the debounced function return the result of the last `func`
10446      * invocation.
10447      *
10448      * **Note:** If `leading` and `trailing` options are `true`, `func` is
10449      * invoked on the trailing edge of the timeout only if the debounced function
10450      * is invoked more than once during the `wait` timeout.
10451      *
10452      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10453      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10454      *
10455      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10456      * for details over the differences between `_.debounce` and `_.throttle`.
10457      *
10458      * @static
10459      * @memberOf _
10460      * @since 0.1.0
10461      * @category Function
10462      * @param {Function} func The function to debounce.
10463      * @param {number} [wait=0] The number of milliseconds to delay.
10464      * @param {Object} [options={}] The options object.
10465      * @param {boolean} [options.leading=false]
10466      *  Specify invoking on the leading edge of the timeout.
10467      * @param {number} [options.maxWait]
10468      *  The maximum time `func` is allowed to be delayed before it's invoked.
10469      * @param {boolean} [options.trailing=true]
10470      *  Specify invoking on the trailing edge of the timeout.
10471      * @returns {Function} Returns the new debounced function.
10472      * @example
10473      *
10474      * // Avoid costly calculations while the window size is in flux.
10475      * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10476      *
10477      * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10478      * jQuery(element).on('click', _.debounce(sendMail, 300, {
10479      *   'leading': true,
10480      *   'trailing': false
10481      * }));
10482      *
10483      * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
10484      * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
10485      * var source = new EventSource('/stream');
10486      * jQuery(source).on('message', debounced);
10487      *
10488      * // Cancel the trailing debounced invocation.
10489      * jQuery(window).on('popstate', debounced.cancel);
10490      */
10491     function debounce(func, wait, options) {
10492       var lastArgs,
10493         lastThis,
10494         maxWait,
10495         result,
10496         timerId,
10497         lastCallTime,
10498         lastInvokeTime = 0,
10499         leading = false,
10500         maxing = false,
10501         trailing = true;
10502
10503       if (typeof func != 'function') {
10504         throw new TypeError(FUNC_ERROR_TEXT);
10505       }
10506       wait = toNumber(wait) || 0;
10507       if (isObject(options)) {
10508         leading = !!options.leading;
10509         maxing = 'maxWait' in options;
10510         maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
10511         trailing = 'trailing' in options ? !!options.trailing : trailing;
10512       }
10513
10514       function invokeFunc(time) {
10515         var args = lastArgs,
10516           thisArg = lastThis;
10517
10518         lastArgs = lastThis = undefined;
10519         lastInvokeTime = time;
10520         result = func.apply(thisArg, args);
10521         return result;
10522       }
10523
10524       function leadingEdge(time) {
10525         // Reset any `maxWait` timer.
10526         lastInvokeTime = time;
10527         // Start the timer for the trailing edge.
10528         timerId = setTimeout(timerExpired, wait);
10529         // Invoke the leading edge.
10530         return leading ? invokeFunc(time) : result;
10531       }
10532
10533       function remainingWait(time) {
10534         var timeSinceLastCall = time - lastCallTime,
10535           timeSinceLastInvoke = time - lastInvokeTime,
10536           timeWaiting = wait - timeSinceLastCall;
10537
10538         return maxing ?
10539           nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) :
10540           timeWaiting;
10541       }
10542
10543       function shouldInvoke(time) {
10544         var timeSinceLastCall = time - lastCallTime,
10545           timeSinceLastInvoke = time - lastInvokeTime;
10546
10547         // Either this is the first call, activity has stopped and we're at the
10548         // trailing edge, the system time has gone backwards and we're treating
10549         // it as the trailing edge, or we've hit the `maxWait` limit.
10550         return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
10551           (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
10552       }
10553
10554       function timerExpired() {
10555         var time = now();
10556         if (shouldInvoke(time)) {
10557           return trailingEdge(time);
10558         }
10559         // Restart the timer.
10560         timerId = setTimeout(timerExpired, remainingWait(time));
10561       }
10562
10563       function trailingEdge(time) {
10564         timerId = undefined;
10565
10566         // Only invoke if we have `lastArgs` which means `func` has been
10567         // debounced at least once.
10568         if (trailing && lastArgs) {
10569           return invokeFunc(time);
10570         }
10571         lastArgs = lastThis = undefined;
10572         return result;
10573       }
10574
10575       function cancel() {
10576         if (timerId !== undefined) {
10577           clearTimeout(timerId);
10578         }
10579         lastInvokeTime = 0;
10580         lastArgs = lastCallTime = lastThis = timerId = undefined;
10581       }
10582
10583       function flush() {
10584         return timerId === undefined ? result : trailingEdge(now());
10585       }
10586
10587       function debounced() {
10588         var time = now(),
10589           isInvoking = shouldInvoke(time);
10590
10591         lastArgs = arguments;
10592         lastThis = this;
10593         lastCallTime = time;
10594
10595         if (isInvoking) {
10596           if (timerId === undefined) {
10597             return leadingEdge(lastCallTime);
10598           }
10599           if (maxing) {
10600             // Handle invocations in a tight loop.
10601             clearTimeout(timerId);
10602             timerId = setTimeout(timerExpired, wait);
10603             return invokeFunc(lastCallTime);
10604           }
10605         }
10606         if (timerId === undefined) {
10607           timerId = setTimeout(timerExpired, wait);
10608         }
10609         return result;
10610       }
10611       debounced.cancel = cancel;
10612       debounced.flush = flush;
10613       return debounced;
10614     }
10615
10616     /**
10617      * Defers invoking the `func` until the current call stack has cleared. Any
10618      * additional arguments are provided to `func` when it's invoked.
10619      *
10620      * @static
10621      * @memberOf _
10622      * @since 0.1.0
10623      * @category Function
10624      * @param {Function} func The function to defer.
10625      * @param {...*} [args] The arguments to invoke `func` with.
10626      * @returns {number} Returns the timer id.
10627      * @example
10628      *
10629      * _.defer(function(text) {
10630      *   console.log(text);
10631      * }, 'deferred');
10632      * // => Logs 'deferred' after one millisecond.
10633      */
10634     var defer = baseRest(function(func, args) {
10635       return baseDelay(func, 1, args);
10636     });
10637
10638     /**
10639      * Invokes `func` after `wait` milliseconds. Any additional arguments are
10640      * provided to `func` when it's invoked.
10641      *
10642      * @static
10643      * @memberOf _
10644      * @since 0.1.0
10645      * @category Function
10646      * @param {Function} func The function to delay.
10647      * @param {number} wait The number of milliseconds to delay invocation.
10648      * @param {...*} [args] The arguments to invoke `func` with.
10649      * @returns {number} Returns the timer id.
10650      * @example
10651      *
10652      * _.delay(function(text) {
10653      *   console.log(text);
10654      * }, 1000, 'later');
10655      * // => Logs 'later' after one second.
10656      */
10657     var delay = baseRest(function(func, wait, args) {
10658       return baseDelay(func, toNumber(wait) || 0, args);
10659     });
10660
10661     /**
10662      * Creates a function that invokes `func` with arguments reversed.
10663      *
10664      * @static
10665      * @memberOf _
10666      * @since 4.0.0
10667      * @category Function
10668      * @param {Function} func The function to flip arguments for.
10669      * @returns {Function} Returns the new flipped function.
10670      * @example
10671      *
10672      * var flipped = _.flip(function() {
10673      *   return _.toArray(arguments);
10674      * });
10675      *
10676      * flipped('a', 'b', 'c', 'd');
10677      * // => ['d', 'c', 'b', 'a']
10678      */
10679     function flip(func) {
10680       return createWrap(func, WRAP_FLIP_FLAG);
10681     }
10682
10683     /**
10684      * Creates a function that memoizes the result of `func`. If `resolver` is
10685      * provided, it determines the cache key for storing the result based on the
10686      * arguments provided to the memoized function. By default, the first argument
10687      * provided to the memoized function is used as the map cache key. The `func`
10688      * is invoked with the `this` binding of the memoized function.
10689      *
10690      * **Note:** The cache is exposed as the `cache` property on the memoized
10691      * function. Its creation may be customized by replacing the `_.memoize.Cache`
10692      * constructor with one whose instances implement the
10693      * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
10694      * method interface of `clear`, `delete`, `get`, `has`, and `set`.
10695      *
10696      * @static
10697      * @memberOf _
10698      * @since 0.1.0
10699      * @category Function
10700      * @param {Function} func The function to have its output memoized.
10701      * @param {Function} [resolver] The function to resolve the cache key.
10702      * @returns {Function} Returns the new memoized function.
10703      * @example
10704      *
10705      * var object = { 'a': 1, 'b': 2 };
10706      * var other = { 'c': 3, 'd': 4 };
10707      *
10708      * var values = _.memoize(_.values);
10709      * values(object);
10710      * // => [1, 2]
10711      *
10712      * values(other);
10713      * // => [3, 4]
10714      *
10715      * object.a = 2;
10716      * values(object);
10717      * // => [1, 2]
10718      *
10719      * // Modify the result cache.
10720      * values.cache.set(object, ['a', 'b']);
10721      * values(object);
10722      * // => ['a', 'b']
10723      *
10724      * // Replace `_.memoize.Cache`.
10725      * _.memoize.Cache = WeakMap;
10726      */
10727     function memoize(func, resolver) {
10728       if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10729         throw new TypeError(FUNC_ERROR_TEXT);
10730       }
10731       var memoized = function() {
10732         var args = arguments,
10733           key = resolver ? resolver.apply(this, args) : args[0],
10734           cache = memoized.cache;
10735
10736         if (cache.has(key)) {
10737           return cache.get(key);
10738         }
10739         var result = func.apply(this, args);
10740         memoized.cache = cache.set(key, result) || cache;
10741         return result;
10742       };
10743       memoized.cache = new(memoize.Cache || MapCache);
10744       return memoized;
10745     }
10746
10747     // Expose `MapCache`.
10748     memoize.Cache = MapCache;
10749
10750     /**
10751      * Creates a function that negates the result of the predicate `func`. The
10752      * `func` predicate is invoked with the `this` binding and arguments of the
10753      * created function.
10754      *
10755      * @static
10756      * @memberOf _
10757      * @since 3.0.0
10758      * @category Function
10759      * @param {Function} predicate The predicate to negate.
10760      * @returns {Function} Returns the new negated function.
10761      * @example
10762      *
10763      * function isEven(n) {
10764      *   return n % 2 == 0;
10765      * }
10766      *
10767      * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10768      * // => [1, 3, 5]
10769      */
10770     function negate(predicate) {
10771       if (typeof predicate != 'function') {
10772         throw new TypeError(FUNC_ERROR_TEXT);
10773       }
10774       return function() {
10775         var args = arguments;
10776         switch (args.length) {
10777           case 0:
10778             return !predicate.call(this);
10779           case 1:
10780             return !predicate.call(this, args[0]);
10781           case 2:
10782             return !predicate.call(this, args[0], args[1]);
10783           case 3:
10784             return !predicate.call(this, args[0], args[1], args[2]);
10785         }
10786         return !predicate.apply(this, args);
10787       };
10788     }
10789
10790     /**
10791      * Creates a function that is restricted to invoking `func` once. Repeat calls
10792      * to the function return the value of the first invocation. The `func` is
10793      * invoked with the `this` binding and arguments of the created function.
10794      *
10795      * @static
10796      * @memberOf _
10797      * @since 0.1.0
10798      * @category Function
10799      * @param {Function} func The function to restrict.
10800      * @returns {Function} Returns the new restricted function.
10801      * @example
10802      *
10803      * var initialize = _.once(createApplication);
10804      * initialize();
10805      * initialize();
10806      * // => `createApplication` is invoked once
10807      */
10808     function once(func) {
10809       return before(2, func);
10810     }
10811
10812     /**
10813      * Creates a function that invokes `func` with its arguments transformed.
10814      *
10815      * @static
10816      * @since 4.0.0
10817      * @memberOf _
10818      * @category Function
10819      * @param {Function} func The function to wrap.
10820      * @param {...(Function|Function[])} [transforms=[_.identity]]
10821      *  The argument transforms.
10822      * @returns {Function} Returns the new function.
10823      * @example
10824      *
10825      * function doubled(n) {
10826      *   return n * 2;
10827      * }
10828      *
10829      * function square(n) {
10830      *   return n * n;
10831      * }
10832      *
10833      * var func = _.overArgs(function(x, y) {
10834      *   return [x, y];
10835      * }, [square, doubled]);
10836      *
10837      * func(9, 3);
10838      * // => [81, 6]
10839      *
10840      * func(10, 5);
10841      * // => [100, 10]
10842      */
10843     var overArgs = castRest(function(func, transforms) {
10844       transforms = (transforms.length == 1 && isArray(transforms[0])) ?
10845         arrayMap(transforms[0], baseUnary(getIteratee())) :
10846         arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
10847
10848       var funcsLength = transforms.length;
10849       return baseRest(function(args) {
10850         var index = -1,
10851           length = nativeMin(args.length, funcsLength);
10852
10853         while (++index < length) {
10854           args[index] = transforms[index].call(this, args[index]);
10855         }
10856         return apply(func, this, args);
10857       });
10858     });
10859
10860     /**
10861      * Creates a function that invokes `func` with `partials` prepended to the
10862      * arguments it receives. This method is like `_.bind` except it does **not**
10863      * alter the `this` binding.
10864      *
10865      * The `_.partial.placeholder` value, which defaults to `_` in monolithic
10866      * builds, may be used as a placeholder for partially applied arguments.
10867      *
10868      * **Note:** This method doesn't set the "length" property of partially
10869      * applied functions.
10870      *
10871      * @static
10872      * @memberOf _
10873      * @since 0.2.0
10874      * @category Function
10875      * @param {Function} func The function to partially apply arguments to.
10876      * @param {...*} [partials] The arguments to be partially applied.
10877      * @returns {Function} Returns the new partially applied function.
10878      * @example
10879      *
10880      * function greet(greeting, name) {
10881      *   return greeting + ' ' + name;
10882      * }
10883      *
10884      * var sayHelloTo = _.partial(greet, 'hello');
10885      * sayHelloTo('fred');
10886      * // => 'hello fred'
10887      *
10888      * // Partially applied with placeholders.
10889      * var greetFred = _.partial(greet, _, 'fred');
10890      * greetFred('hi');
10891      * // => 'hi fred'
10892      */
10893     var partial = baseRest(function(func, partials) {
10894       var holders = replaceHolders(partials, getHolder(partial));
10895       return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
10896     });
10897
10898     /**
10899      * This method is like `_.partial` except that partially applied arguments
10900      * are appended to the arguments it receives.
10901      *
10902      * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
10903      * builds, may be used as a placeholder for partially applied arguments.
10904      *
10905      * **Note:** This method doesn't set the "length" property of partially
10906      * applied functions.
10907      *
10908      * @static
10909      * @memberOf _
10910      * @since 1.0.0
10911      * @category Function
10912      * @param {Function} func The function to partially apply arguments to.
10913      * @param {...*} [partials] The arguments to be partially applied.
10914      * @returns {Function} Returns the new partially applied function.
10915      * @example
10916      *
10917      * function greet(greeting, name) {
10918      *   return greeting + ' ' + name;
10919      * }
10920      *
10921      * var greetFred = _.partialRight(greet, 'fred');
10922      * greetFred('hi');
10923      * // => 'hi fred'
10924      *
10925      * // Partially applied with placeholders.
10926      * var sayHelloTo = _.partialRight(greet, 'hello', _);
10927      * sayHelloTo('fred');
10928      * // => 'hello fred'
10929      */
10930     var partialRight = baseRest(function(func, partials) {
10931       var holders = replaceHolders(partials, getHolder(partialRight));
10932       return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
10933     });
10934
10935     /**
10936      * Creates a function that invokes `func` with arguments arranged according
10937      * to the specified `indexes` where the argument value at the first index is
10938      * provided as the first argument, the argument value at the second index is
10939      * provided as the second argument, and so on.
10940      *
10941      * @static
10942      * @memberOf _
10943      * @since 3.0.0
10944      * @category Function
10945      * @param {Function} func The function to rearrange arguments for.
10946      * @param {...(number|number[])} indexes The arranged argument indexes.
10947      * @returns {Function} Returns the new function.
10948      * @example
10949      *
10950      * var rearged = _.rearg(function(a, b, c) {
10951      *   return [a, b, c];
10952      * }, [2, 0, 1]);
10953      *
10954      * rearged('b', 'c', 'a')
10955      * // => ['a', 'b', 'c']
10956      */
10957     var rearg = flatRest(function(func, indexes) {
10958       return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
10959     });
10960
10961     /**
10962      * Creates a function that invokes `func` with the `this` binding of the
10963      * created function and arguments from `start` and beyond provided as
10964      * an array.
10965      *
10966      * **Note:** This method is based on the
10967      * [rest parameter](https://mdn.io/rest_parameters).
10968      *
10969      * @static
10970      * @memberOf _
10971      * @since 4.0.0
10972      * @category Function
10973      * @param {Function} func The function to apply a rest parameter to.
10974      * @param {number} [start=func.length-1] The start position of the rest parameter.
10975      * @returns {Function} Returns the new function.
10976      * @example
10977      *
10978      * var say = _.rest(function(what, names) {
10979      *   return what + ' ' + _.initial(names).join(', ') +
10980      *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
10981      * });
10982      *
10983      * say('hello', 'fred', 'barney', 'pebbles');
10984      * // => 'hello fred, barney, & pebbles'
10985      */
10986     function rest(func, start) {
10987       if (typeof func != 'function') {
10988         throw new TypeError(FUNC_ERROR_TEXT);
10989       }
10990       start = start === undefined ? start : toInteger(start);
10991       return baseRest(func, start);
10992     }
10993
10994     /**
10995      * Creates a function that invokes `func` with the `this` binding of the
10996      * create function and an array of arguments much like
10997      * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
10998      *
10999      * **Note:** This method is based on the
11000      * [spread operator](https://mdn.io/spread_operator).
11001      *
11002      * @static
11003      * @memberOf _
11004      * @since 3.2.0
11005      * @category Function
11006      * @param {Function} func The function to spread arguments over.
11007      * @param {number} [start=0] The start position of the spread.
11008      * @returns {Function} Returns the new function.
11009      * @example
11010      *
11011      * var say = _.spread(function(who, what) {
11012      *   return who + ' says ' + what;
11013      * });
11014      *
11015      * say(['fred', 'hello']);
11016      * // => 'fred says hello'
11017      *
11018      * var numbers = Promise.all([
11019      *   Promise.resolve(40),
11020      *   Promise.resolve(36)
11021      * ]);
11022      *
11023      * numbers.then(_.spread(function(x, y) {
11024      *   return x + y;
11025      * }));
11026      * // => a Promise of 76
11027      */
11028     function spread(func, start) {
11029       if (typeof func != 'function') {
11030         throw new TypeError(FUNC_ERROR_TEXT);
11031       }
11032       start = start == null ? 0 : nativeMax(toInteger(start), 0);
11033       return baseRest(function(args) {
11034         var array = args[start],
11035           otherArgs = castSlice(args, 0, start);
11036
11037         if (array) {
11038           arrayPush(otherArgs, array);
11039         }
11040         return apply(func, this, otherArgs);
11041       });
11042     }
11043
11044     /**
11045      * Creates a throttled function that only invokes `func` at most once per
11046      * every `wait` milliseconds. The throttled function comes with a `cancel`
11047      * method to cancel delayed `func` invocations and a `flush` method to
11048      * immediately invoke them. Provide `options` to indicate whether `func`
11049      * should be invoked on the leading and/or trailing edge of the `wait`
11050      * timeout. The `func` is invoked with the last arguments provided to the
11051      * throttled function. Subsequent calls to the throttled function return the
11052      * result of the last `func` invocation.
11053      *
11054      * **Note:** If `leading` and `trailing` options are `true`, `func` is
11055      * invoked on the trailing edge of the timeout only if the throttled function
11056      * is invoked more than once during the `wait` timeout.
11057      *
11058      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
11059      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
11060      *
11061      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
11062      * for details over the differences between `_.throttle` and `_.debounce`.
11063      *
11064      * @static
11065      * @memberOf _
11066      * @since 0.1.0
11067      * @category Function
11068      * @param {Function} func The function to throttle.
11069      * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
11070      * @param {Object} [options={}] The options object.
11071      * @param {boolean} [options.leading=true]
11072      *  Specify invoking on the leading edge of the timeout.
11073      * @param {boolean} [options.trailing=true]
11074      *  Specify invoking on the trailing edge of the timeout.
11075      * @returns {Function} Returns the new throttled function.
11076      * @example
11077      *
11078      * // Avoid excessively updating the position while scrolling.
11079      * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
11080      *
11081      * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
11082      * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
11083      * jQuery(element).on('click', throttled);
11084      *
11085      * // Cancel the trailing throttled invocation.
11086      * jQuery(window).on('popstate', throttled.cancel);
11087      */
11088     function throttle(func, wait, options) {
11089       var leading = true,
11090         trailing = true;
11091
11092       if (typeof func != 'function') {
11093         throw new TypeError(FUNC_ERROR_TEXT);
11094       }
11095       if (isObject(options)) {
11096         leading = 'leading' in options ? !!options.leading : leading;
11097         trailing = 'trailing' in options ? !!options.trailing : trailing;
11098       }
11099       return debounce(func, wait, {
11100         'leading': leading,
11101         'maxWait': wait,
11102         'trailing': trailing
11103       });
11104     }
11105
11106     /**
11107      * Creates a function that accepts up to one argument, ignoring any
11108      * additional arguments.
11109      *
11110      * @static
11111      * @memberOf _
11112      * @since 4.0.0
11113      * @category Function
11114      * @param {Function} func The function to cap arguments for.
11115      * @returns {Function} Returns the new capped function.
11116      * @example
11117      *
11118      * _.map(['6', '8', '10'], _.unary(parseInt));
11119      * // => [6, 8, 10]
11120      */
11121     function unary(func) {
11122       return ary(func, 1);
11123     }
11124
11125     /**
11126      * Creates a function that provides `value` to `wrapper` as its first
11127      * argument. Any additional arguments provided to the function are appended
11128      * to those provided to the `wrapper`. The wrapper is invoked with the `this`
11129      * binding of the created function.
11130      *
11131      * @static
11132      * @memberOf _
11133      * @since 0.1.0
11134      * @category Function
11135      * @param {*} value The value to wrap.
11136      * @param {Function} [wrapper=identity] The wrapper function.
11137      * @returns {Function} Returns the new function.
11138      * @example
11139      *
11140      * var p = _.wrap(_.escape, function(func, text) {
11141      *   return '<p>' + func(text) + '</p>';
11142      * });
11143      *
11144      * p('fred, barney, & pebbles');
11145      * // => '<p>fred, barney, &amp; pebbles</p>'
11146      */
11147     function wrap(value, wrapper) {
11148       return partial(castFunction(wrapper), value);
11149     }
11150
11151     /*------------------------------------------------------------------------*/
11152
11153     /**
11154      * Casts `value` as an array if it's not one.
11155      *
11156      * @static
11157      * @memberOf _
11158      * @since 4.4.0
11159      * @category Lang
11160      * @param {*} value The value to inspect.
11161      * @returns {Array} Returns the cast array.
11162      * @example
11163      *
11164      * _.castArray(1);
11165      * // => [1]
11166      *
11167      * _.castArray({ 'a': 1 });
11168      * // => [{ 'a': 1 }]
11169      *
11170      * _.castArray('abc');
11171      * // => ['abc']
11172      *
11173      * _.castArray(null);
11174      * // => [null]
11175      *
11176      * _.castArray(undefined);
11177      * // => [undefined]
11178      *
11179      * _.castArray();
11180      * // => []
11181      *
11182      * var array = [1, 2, 3];
11183      * console.log(_.castArray(array) === array);
11184      * // => true
11185      */
11186     function castArray() {
11187       if (!arguments.length) {
11188         return [];
11189       }
11190       var value = arguments[0];
11191       return isArray(value) ? value : [value];
11192     }
11193
11194     /**
11195      * Creates a shallow clone of `value`.
11196      *
11197      * **Note:** This method is loosely based on the
11198      * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
11199      * and supports cloning arrays, array buffers, booleans, date objects, maps,
11200      * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
11201      * arrays. The own enumerable properties of `arguments` objects are cloned
11202      * as plain objects. An empty object is returned for uncloneable values such
11203      * as error objects, functions, DOM nodes, and WeakMaps.
11204      *
11205      * @static
11206      * @memberOf _
11207      * @since 0.1.0
11208      * @category Lang
11209      * @param {*} value The value to clone.
11210      * @returns {*} Returns the cloned value.
11211      * @see _.cloneDeep
11212      * @example
11213      *
11214      * var objects = [{ 'a': 1 }, { 'b': 2 }];
11215      *
11216      * var shallow = _.clone(objects);
11217      * console.log(shallow[0] === objects[0]);
11218      * // => true
11219      */
11220     function clone(value) {
11221       return baseClone(value, CLONE_SYMBOLS_FLAG);
11222     }
11223
11224     /**
11225      * This method is like `_.clone` except that it accepts `customizer` which
11226      * is invoked to produce the cloned value. If `customizer` returns `undefined`,
11227      * cloning is handled by the method instead. The `customizer` is invoked with
11228      * up to four arguments; (value [, index|key, object, stack]).
11229      *
11230      * @static
11231      * @memberOf _
11232      * @since 4.0.0
11233      * @category Lang
11234      * @param {*} value The value to clone.
11235      * @param {Function} [customizer] The function to customize cloning.
11236      * @returns {*} Returns the cloned value.
11237      * @see _.cloneDeepWith
11238      * @example
11239      *
11240      * function customizer(value) {
11241      *   if (_.isElement(value)) {
11242      *     return value.cloneNode(false);
11243      *   }
11244      * }
11245      *
11246      * var el = _.cloneWith(document.body, customizer);
11247      *
11248      * console.log(el === document.body);
11249      * // => false
11250      * console.log(el.nodeName);
11251      * // => 'BODY'
11252      * console.log(el.childNodes.length);
11253      * // => 0
11254      */
11255     function cloneWith(value, customizer) {
11256       customizer = typeof customizer == 'function' ? customizer : undefined;
11257       return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
11258     }
11259
11260     /**
11261      * This method is like `_.clone` except that it recursively clones `value`.
11262      *
11263      * @static
11264      * @memberOf _
11265      * @since 1.0.0
11266      * @category Lang
11267      * @param {*} value The value to recursively clone.
11268      * @returns {*} Returns the deep cloned value.
11269      * @see _.clone
11270      * @example
11271      *
11272      * var objects = [{ 'a': 1 }, { 'b': 2 }];
11273      *
11274      * var deep = _.cloneDeep(objects);
11275      * console.log(deep[0] === objects[0]);
11276      * // => false
11277      */
11278     function cloneDeep(value) {
11279       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
11280     }
11281
11282     /**
11283      * This method is like `_.cloneWith` except that it recursively clones `value`.
11284      *
11285      * @static
11286      * @memberOf _
11287      * @since 4.0.0
11288      * @category Lang
11289      * @param {*} value The value to recursively clone.
11290      * @param {Function} [customizer] The function to customize cloning.
11291      * @returns {*} Returns the deep cloned value.
11292      * @see _.cloneWith
11293      * @example
11294      *
11295      * function customizer(value) {
11296      *   if (_.isElement(value)) {
11297      *     return value.cloneNode(true);
11298      *   }
11299      * }
11300      *
11301      * var el = _.cloneDeepWith(document.body, customizer);
11302      *
11303      * console.log(el === document.body);
11304      * // => false
11305      * console.log(el.nodeName);
11306      * // => 'BODY'
11307      * console.log(el.childNodes.length);
11308      * // => 20
11309      */
11310     function cloneDeepWith(value, customizer) {
11311       customizer = typeof customizer == 'function' ? customizer : undefined;
11312       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
11313     }
11314
11315     /**
11316      * Checks if `object` conforms to `source` by invoking the predicate
11317      * properties of `source` with the corresponding property values of `object`.
11318      *
11319      * **Note:** This method is equivalent to `_.conforms` when `source` is
11320      * partially applied.
11321      *
11322      * @static
11323      * @memberOf _
11324      * @since 4.14.0
11325      * @category Lang
11326      * @param {Object} object The object to inspect.
11327      * @param {Object} source The object of property predicates to conform to.
11328      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
11329      * @example
11330      *
11331      * var object = { 'a': 1, 'b': 2 };
11332      *
11333      * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11334      * // => true
11335      *
11336      * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11337      * // => false
11338      */
11339     function conformsTo(object, source) {
11340       return source == null || baseConformsTo(object, source, keys(source));
11341     }
11342
11343     /**
11344      * Performs a
11345      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11346      * comparison between two values to determine if they are equivalent.
11347      *
11348      * @static
11349      * @memberOf _
11350      * @since 4.0.0
11351      * @category Lang
11352      * @param {*} value The value to compare.
11353      * @param {*} other The other value to compare.
11354      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11355      * @example
11356      *
11357      * var object = { 'a': 1 };
11358      * var other = { 'a': 1 };
11359      *
11360      * _.eq(object, object);
11361      * // => true
11362      *
11363      * _.eq(object, other);
11364      * // => false
11365      *
11366      * _.eq('a', 'a');
11367      * // => true
11368      *
11369      * _.eq('a', Object('a'));
11370      * // => false
11371      *
11372      * _.eq(NaN, NaN);
11373      * // => true
11374      */
11375     function eq(value, other) {
11376       return value === other || (value !== value && other !== other);
11377     }
11378
11379     /**
11380      * Checks if `value` is greater than `other`.
11381      *
11382      * @static
11383      * @memberOf _
11384      * @since 3.9.0
11385      * @category Lang
11386      * @param {*} value The value to compare.
11387      * @param {*} other The other value to compare.
11388      * @returns {boolean} Returns `true` if `value` is greater than `other`,
11389      *  else `false`.
11390      * @see _.lt
11391      * @example
11392      *
11393      * _.gt(3, 1);
11394      * // => true
11395      *
11396      * _.gt(3, 3);
11397      * // => false
11398      *
11399      * _.gt(1, 3);
11400      * // => false
11401      */
11402     var gt = createRelationalOperation(baseGt);
11403
11404     /**
11405      * Checks if `value` is greater than or equal to `other`.
11406      *
11407      * @static
11408      * @memberOf _
11409      * @since 3.9.0
11410      * @category Lang
11411      * @param {*} value The value to compare.
11412      * @param {*} other The other value to compare.
11413      * @returns {boolean} Returns `true` if `value` is greater than or equal to
11414      *  `other`, else `false`.
11415      * @see _.lte
11416      * @example
11417      *
11418      * _.gte(3, 1);
11419      * // => true
11420      *
11421      * _.gte(3, 3);
11422      * // => true
11423      *
11424      * _.gte(1, 3);
11425      * // => false
11426      */
11427     var gte = createRelationalOperation(function(value, other) {
11428       return value >= other;
11429     });
11430
11431     /**
11432      * Checks if `value` is likely an `arguments` object.
11433      *
11434      * @static
11435      * @memberOf _
11436      * @since 0.1.0
11437      * @category Lang
11438      * @param {*} value The value to check.
11439      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11440      *  else `false`.
11441      * @example
11442      *
11443      * _.isArguments(function() { return arguments; }());
11444      * // => true
11445      *
11446      * _.isArguments([1, 2, 3]);
11447      * // => false
11448      */
11449     var isArguments = baseIsArguments(function() {
11450       return arguments;
11451     }()) ? baseIsArguments : function(value) {
11452       return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11453         !propertyIsEnumerable.call(value, 'callee');
11454     };
11455
11456     /**
11457      * Checks if `value` is classified as an `Array` object.
11458      *
11459      * @static
11460      * @memberOf _
11461      * @since 0.1.0
11462      * @category Lang
11463      * @param {*} value The value to check.
11464      * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11465      * @example
11466      *
11467      * _.isArray([1, 2, 3]);
11468      * // => true
11469      *
11470      * _.isArray(document.body.children);
11471      * // => false
11472      *
11473      * _.isArray('abc');
11474      * // => false
11475      *
11476      * _.isArray(_.noop);
11477      * // => false
11478      */
11479     var isArray = Array.isArray;
11480
11481     /**
11482      * Checks if `value` is classified as an `ArrayBuffer` object.
11483      *
11484      * @static
11485      * @memberOf _
11486      * @since 4.3.0
11487      * @category Lang
11488      * @param {*} value The value to check.
11489      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11490      * @example
11491      *
11492      * _.isArrayBuffer(new ArrayBuffer(2));
11493      * // => true
11494      *
11495      * _.isArrayBuffer(new Array(2));
11496      * // => false
11497      */
11498     var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
11499
11500     /**
11501      * Checks if `value` is array-like. A value is considered array-like if it's
11502      * not a function and has a `value.length` that's an integer greater than or
11503      * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
11504      *
11505      * @static
11506      * @memberOf _
11507      * @since 4.0.0
11508      * @category Lang
11509      * @param {*} value The value to check.
11510      * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11511      * @example
11512      *
11513      * _.isArrayLike([1, 2, 3]);
11514      * // => true
11515      *
11516      * _.isArrayLike(document.body.children);
11517      * // => true
11518      *
11519      * _.isArrayLike('abc');
11520      * // => true
11521      *
11522      * _.isArrayLike(_.noop);
11523      * // => false
11524      */
11525     function isArrayLike(value) {
11526       return value != null && isLength(value.length) && !isFunction(value);
11527     }
11528
11529     /**
11530      * This method is like `_.isArrayLike` except that it also checks if `value`
11531      * is an object.
11532      *
11533      * @static
11534      * @memberOf _
11535      * @since 4.0.0
11536      * @category Lang
11537      * @param {*} value The value to check.
11538      * @returns {boolean} Returns `true` if `value` is an array-like object,
11539      *  else `false`.
11540      * @example
11541      *
11542      * _.isArrayLikeObject([1, 2, 3]);
11543      * // => true
11544      *
11545      * _.isArrayLikeObject(document.body.children);
11546      * // => true
11547      *
11548      * _.isArrayLikeObject('abc');
11549      * // => false
11550      *
11551      * _.isArrayLikeObject(_.noop);
11552      * // => false
11553      */
11554     function isArrayLikeObject(value) {
11555       return isObjectLike(value) && isArrayLike(value);
11556     }
11557
11558     /**
11559      * Checks if `value` is classified as a boolean primitive or object.
11560      *
11561      * @static
11562      * @memberOf _
11563      * @since 0.1.0
11564      * @category Lang
11565      * @param {*} value The value to check.
11566      * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11567      * @example
11568      *
11569      * _.isBoolean(false);
11570      * // => true
11571      *
11572      * _.isBoolean(null);
11573      * // => false
11574      */
11575     function isBoolean(value) {
11576       return value === true || value === false ||
11577         (isObjectLike(value) && baseGetTag(value) == boolTag);
11578     }
11579
11580     /**
11581      * Checks if `value` is a buffer.
11582      *
11583      * @static
11584      * @memberOf _
11585      * @since 4.3.0
11586      * @category Lang
11587      * @param {*} value The value to check.
11588      * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11589      * @example
11590      *
11591      * _.isBuffer(new Buffer(2));
11592      * // => true
11593      *
11594      * _.isBuffer(new Uint8Array(2));
11595      * // => false
11596      */
11597     var isBuffer = nativeIsBuffer || stubFalse;
11598
11599     /**
11600      * Checks if `value` is classified as a `Date` object.
11601      *
11602      * @static
11603      * @memberOf _
11604      * @since 0.1.0
11605      * @category Lang
11606      * @param {*} value The value to check.
11607      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11608      * @example
11609      *
11610      * _.isDate(new Date);
11611      * // => true
11612      *
11613      * _.isDate('Mon April 23 2012');
11614      * // => false
11615      */
11616     var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11617
11618     /**
11619      * Checks if `value` is likely a DOM element.
11620      *
11621      * @static
11622      * @memberOf _
11623      * @since 0.1.0
11624      * @category Lang
11625      * @param {*} value The value to check.
11626      * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11627      * @example
11628      *
11629      * _.isElement(document.body);
11630      * // => true
11631      *
11632      * _.isElement('<body>');
11633      * // => false
11634      */
11635     function isElement(value) {
11636       return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11637     }
11638
11639     /**
11640      * Checks if `value` is an empty object, collection, map, or set.
11641      *
11642      * Objects are considered empty if they have no own enumerable string keyed
11643      * properties.
11644      *
11645      * Array-like values such as `arguments` objects, arrays, buffers, strings, or
11646      * jQuery-like collections are considered empty if they have a `length` of `0`.
11647      * Similarly, maps and sets are considered empty if they have a `size` of `0`.
11648      *
11649      * @static
11650      * @memberOf _
11651      * @since 0.1.0
11652      * @category Lang
11653      * @param {*} value The value to check.
11654      * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11655      * @example
11656      *
11657      * _.isEmpty(null);
11658      * // => true
11659      *
11660      * _.isEmpty(true);
11661      * // => true
11662      *
11663      * _.isEmpty(1);
11664      * // => true
11665      *
11666      * _.isEmpty([1, 2, 3]);
11667      * // => false
11668      *
11669      * _.isEmpty({ 'a': 1 });
11670      * // => false
11671      */
11672     function isEmpty(value) {
11673       if (value == null) {
11674         return true;
11675       }
11676       if (isArrayLike(value) &&
11677         (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
11678           isBuffer(value) || isTypedArray(value) || isArguments(value))) {
11679         return !value.length;
11680       }
11681       var tag = getTag(value);
11682       if (tag == mapTag || tag == setTag) {
11683         return !value.size;
11684       }
11685       if (isPrototype(value)) {
11686         return !baseKeys(value).length;
11687       }
11688       for (var key in value) {
11689         if (hasOwnProperty.call(value, key)) {
11690           return false;
11691         }
11692       }
11693       return true;
11694     }
11695
11696     /**
11697      * Performs a deep comparison between two values to determine if they are
11698      * equivalent.
11699      *
11700      * **Note:** This method supports comparing arrays, array buffers, booleans,
11701      * date objects, error objects, maps, numbers, `Object` objects, regexes,
11702      * sets, strings, symbols, and typed arrays. `Object` objects are compared
11703      * by their own, not inherited, enumerable properties. Functions and DOM
11704      * nodes are compared by strict equality, i.e. `===`.
11705      *
11706      * @static
11707      * @memberOf _
11708      * @since 0.1.0
11709      * @category Lang
11710      * @param {*} value The value to compare.
11711      * @param {*} other The other value to compare.
11712      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11713      * @example
11714      *
11715      * var object = { 'a': 1 };
11716      * var other = { 'a': 1 };
11717      *
11718      * _.isEqual(object, other);
11719      * // => true
11720      *
11721      * object === other;
11722      * // => false
11723      */
11724     function isEqual(value, other) {
11725       return baseIsEqual(value, other);
11726     }
11727
11728     /**
11729      * This method is like `_.isEqual` except that it accepts `customizer` which
11730      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11731      * are handled by the method instead. The `customizer` is invoked with up to
11732      * six arguments: (objValue, othValue [, index|key, object, other, stack]).
11733      *
11734      * @static
11735      * @memberOf _
11736      * @since 4.0.0
11737      * @category Lang
11738      * @param {*} value The value to compare.
11739      * @param {*} other The other value to compare.
11740      * @param {Function} [customizer] The function to customize comparisons.
11741      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11742      * @example
11743      *
11744      * function isGreeting(value) {
11745      *   return /^h(?:i|ello)$/.test(value);
11746      * }
11747      *
11748      * function customizer(objValue, othValue) {
11749      *   if (isGreeting(objValue) && isGreeting(othValue)) {
11750      *     return true;
11751      *   }
11752      * }
11753      *
11754      * var array = ['hello', 'goodbye'];
11755      * var other = ['hi', 'goodbye'];
11756      *
11757      * _.isEqualWith(array, other, customizer);
11758      * // => true
11759      */
11760     function isEqualWith(value, other, customizer) {
11761       customizer = typeof customizer == 'function' ? customizer : undefined;
11762       var result = customizer ? customizer(value, other) : undefined;
11763       return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
11764     }
11765
11766     /**
11767      * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11768      * `SyntaxError`, `TypeError`, or `URIError` object.
11769      *
11770      * @static
11771      * @memberOf _
11772      * @since 3.0.0
11773      * @category Lang
11774      * @param {*} value The value to check.
11775      * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11776      * @example
11777      *
11778      * _.isError(new Error);
11779      * // => true
11780      *
11781      * _.isError(Error);
11782      * // => false
11783      */
11784     function isError(value) {
11785       if (!isObjectLike(value)) {
11786         return false;
11787       }
11788       var tag = baseGetTag(value);
11789       return tag == errorTag || tag == domExcTag ||
11790         (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11791     }
11792
11793     /**
11794      * Checks if `value` is a finite primitive number.
11795      *
11796      * **Note:** This method is based on
11797      * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11798      *
11799      * @static
11800      * @memberOf _
11801      * @since 0.1.0
11802      * @category Lang
11803      * @param {*} value The value to check.
11804      * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11805      * @example
11806      *
11807      * _.isFinite(3);
11808      * // => true
11809      *
11810      * _.isFinite(Number.MIN_VALUE);
11811      * // => true
11812      *
11813      * _.isFinite(Infinity);
11814      * // => false
11815      *
11816      * _.isFinite('3');
11817      * // => false
11818      */
11819     function isFinite(value) {
11820       return typeof value == 'number' && nativeIsFinite(value);
11821     }
11822
11823     /**
11824      * Checks if `value` is classified as a `Function` object.
11825      *
11826      * @static
11827      * @memberOf _
11828      * @since 0.1.0
11829      * @category Lang
11830      * @param {*} value The value to check.
11831      * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11832      * @example
11833      *
11834      * _.isFunction(_);
11835      * // => true
11836      *
11837      * _.isFunction(/abc/);
11838      * // => false
11839      */
11840     function isFunction(value) {
11841       if (!isObject(value)) {
11842         return false;
11843       }
11844       // The use of `Object#toString` avoids issues with the `typeof` operator
11845       // in Safari 9 which returns 'object' for typed arrays and other constructors.
11846       var tag = baseGetTag(value);
11847       return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11848     }
11849
11850     /**
11851      * Checks if `value` is an integer.
11852      *
11853      * **Note:** This method is based on
11854      * [`Number.isInteger`](https://mdn.io/Number/isInteger).
11855      *
11856      * @static
11857      * @memberOf _
11858      * @since 4.0.0
11859      * @category Lang
11860      * @param {*} value The value to check.
11861      * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
11862      * @example
11863      *
11864      * _.isInteger(3);
11865      * // => true
11866      *
11867      * _.isInteger(Number.MIN_VALUE);
11868      * // => false
11869      *
11870      * _.isInteger(Infinity);
11871      * // => false
11872      *
11873      * _.isInteger('3');
11874      * // => false
11875      */
11876     function isInteger(value) {
11877       return typeof value == 'number' && value == toInteger(value);
11878     }
11879
11880     /**
11881      * Checks if `value` is a valid array-like length.
11882      *
11883      * **Note:** This method is loosely based on
11884      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
11885      *
11886      * @static
11887      * @memberOf _
11888      * @since 4.0.0
11889      * @category Lang
11890      * @param {*} value The value to check.
11891      * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11892      * @example
11893      *
11894      * _.isLength(3);
11895      * // => true
11896      *
11897      * _.isLength(Number.MIN_VALUE);
11898      * // => false
11899      *
11900      * _.isLength(Infinity);
11901      * // => false
11902      *
11903      * _.isLength('3');
11904      * // => false
11905      */
11906     function isLength(value) {
11907       return typeof value == 'number' &&
11908         value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
11909     }
11910
11911     /**
11912      * Checks if `value` is the
11913      * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11914      * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11915      *
11916      * @static
11917      * @memberOf _
11918      * @since 0.1.0
11919      * @category Lang
11920      * @param {*} value The value to check.
11921      * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11922      * @example
11923      *
11924      * _.isObject({});
11925      * // => true
11926      *
11927      * _.isObject([1, 2, 3]);
11928      * // => true
11929      *
11930      * _.isObject(_.noop);
11931      * // => true
11932      *
11933      * _.isObject(null);
11934      * // => false
11935      */
11936     function isObject(value) {
11937       var type = typeof value;
11938       return value != null && (type == 'object' || type == 'function');
11939     }
11940
11941     /**
11942      * Checks if `value` is object-like. A value is object-like if it's not `null`
11943      * and has a `typeof` result of "object".
11944      *
11945      * @static
11946      * @memberOf _
11947      * @since 4.0.0
11948      * @category Lang
11949      * @param {*} value The value to check.
11950      * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11951      * @example
11952      *
11953      * _.isObjectLike({});
11954      * // => true
11955      *
11956      * _.isObjectLike([1, 2, 3]);
11957      * // => true
11958      *
11959      * _.isObjectLike(_.noop);
11960      * // => false
11961      *
11962      * _.isObjectLike(null);
11963      * // => false
11964      */
11965     function isObjectLike(value) {
11966       return value != null && typeof value == 'object';
11967     }
11968
11969     /**
11970      * Checks if `value` is classified as a `Map` object.
11971      *
11972      * @static
11973      * @memberOf _
11974      * @since 4.3.0
11975      * @category Lang
11976      * @param {*} value The value to check.
11977      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
11978      * @example
11979      *
11980      * _.isMap(new Map);
11981      * // => true
11982      *
11983      * _.isMap(new WeakMap);
11984      * // => false
11985      */
11986     var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
11987
11988     /**
11989      * Performs a partial deep comparison between `object` and `source` to
11990      * determine if `object` contains equivalent property values.
11991      *
11992      * **Note:** This method is equivalent to `_.matches` when `source` is
11993      * partially applied.
11994      *
11995      * Partial comparisons will match empty array and empty object `source`
11996      * values against any array or object value, respectively. See `_.isEqual`
11997      * for a list of supported value comparisons.
11998      *
11999      * @static
12000      * @memberOf _
12001      * @since 3.0.0
12002      * @category Lang
12003      * @param {Object} object The object to inspect.
12004      * @param {Object} source The object of property values to match.
12005      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
12006      * @example
12007      *
12008      * var object = { 'a': 1, 'b': 2 };
12009      *
12010      * _.isMatch(object, { 'b': 2 });
12011      * // => true
12012      *
12013      * _.isMatch(object, { 'b': 1 });
12014      * // => false
12015      */
12016     function isMatch(object, source) {
12017       return object === source || baseIsMatch(object, source, getMatchData(source));
12018     }
12019
12020     /**
12021      * This method is like `_.isMatch` except that it accepts `customizer` which
12022      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
12023      * are handled by the method instead. The `customizer` is invoked with five
12024      * arguments: (objValue, srcValue, index|key, object, source).
12025      *
12026      * @static
12027      * @memberOf _
12028      * @since 4.0.0
12029      * @category Lang
12030      * @param {Object} object The object to inspect.
12031      * @param {Object} source The object of property values to match.
12032      * @param {Function} [customizer] The function to customize comparisons.
12033      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
12034      * @example
12035      *
12036      * function isGreeting(value) {
12037      *   return /^h(?:i|ello)$/.test(value);
12038      * }
12039      *
12040      * function customizer(objValue, srcValue) {
12041      *   if (isGreeting(objValue) && isGreeting(srcValue)) {
12042      *     return true;
12043      *   }
12044      * }
12045      *
12046      * var object = { 'greeting': 'hello' };
12047      * var source = { 'greeting': 'hi' };
12048      *
12049      * _.isMatchWith(object, source, customizer);
12050      * // => true
12051      */
12052     function isMatchWith(object, source, customizer) {
12053       customizer = typeof customizer == 'function' ? customizer : undefined;
12054       return baseIsMatch(object, source, getMatchData(source), customizer);
12055     }
12056
12057     /**
12058      * Checks if `value` is `NaN`.
12059      *
12060      * **Note:** This method is based on
12061      * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
12062      * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
12063      * `undefined` and other non-number values.
12064      *
12065      * @static
12066      * @memberOf _
12067      * @since 0.1.0
12068      * @category Lang
12069      * @param {*} value The value to check.
12070      * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
12071      * @example
12072      *
12073      * _.isNaN(NaN);
12074      * // => true
12075      *
12076      * _.isNaN(new Number(NaN));
12077      * // => true
12078      *
12079      * isNaN(undefined);
12080      * // => true
12081      *
12082      * _.isNaN(undefined);
12083      * // => false
12084      */
12085     function isNaN(value) {
12086       // An `NaN` primitive is the only value that is not equal to itself.
12087       // Perform the `toStringTag` check first to avoid errors with some
12088       // ActiveX objects in IE.
12089       return isNumber(value) && value != +value;
12090     }
12091
12092     /**
12093      * Checks if `value` is a pristine native function.
12094      *
12095      * **Note:** This method can't reliably detect native functions in the presence
12096      * of the core-js package because core-js circumvents this kind of detection.
12097      * Despite multiple requests, the core-js maintainer has made it clear: any
12098      * attempt to fix the detection will be obstructed. As a result, we're left
12099      * with little choice but to throw an error. Unfortunately, this also affects
12100      * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
12101      * which rely on core-js.
12102      *
12103      * @static
12104      * @memberOf _
12105      * @since 3.0.0
12106      * @category Lang
12107      * @param {*} value The value to check.
12108      * @returns {boolean} Returns `true` if `value` is a native function,
12109      *  else `false`.
12110      * @example
12111      *
12112      * _.isNative(Array.prototype.push);
12113      * // => true
12114      *
12115      * _.isNative(_);
12116      * // => false
12117      */
12118     function isNative(value) {
12119       if (isMaskable(value)) {
12120         throw new Error(CORE_ERROR_TEXT);
12121       }
12122       return baseIsNative(value);
12123     }
12124
12125     /**
12126      * Checks if `value` is `null`.
12127      *
12128      * @static
12129      * @memberOf _
12130      * @since 0.1.0
12131      * @category Lang
12132      * @param {*} value The value to check.
12133      * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
12134      * @example
12135      *
12136      * _.isNull(null);
12137      * // => true
12138      *
12139      * _.isNull(void 0);
12140      * // => false
12141      */
12142     function isNull(value) {
12143       return value === null;
12144     }
12145
12146     /**
12147      * Checks if `value` is `null` or `undefined`.
12148      *
12149      * @static
12150      * @memberOf _
12151      * @since 4.0.0
12152      * @category Lang
12153      * @param {*} value The value to check.
12154      * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
12155      * @example
12156      *
12157      * _.isNil(null);
12158      * // => true
12159      *
12160      * _.isNil(void 0);
12161      * // => true
12162      *
12163      * _.isNil(NaN);
12164      * // => false
12165      */
12166     function isNil(value) {
12167       return value == null;
12168     }
12169
12170     /**
12171      * Checks if `value` is classified as a `Number` primitive or object.
12172      *
12173      * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
12174      * classified as numbers, use the `_.isFinite` method.
12175      *
12176      * @static
12177      * @memberOf _
12178      * @since 0.1.0
12179      * @category Lang
12180      * @param {*} value The value to check.
12181      * @returns {boolean} Returns `true` if `value` is a number, else `false`.
12182      * @example
12183      *
12184      * _.isNumber(3);
12185      * // => true
12186      *
12187      * _.isNumber(Number.MIN_VALUE);
12188      * // => true
12189      *
12190      * _.isNumber(Infinity);
12191      * // => true
12192      *
12193      * _.isNumber('3');
12194      * // => false
12195      */
12196     function isNumber(value) {
12197       return typeof value == 'number' ||
12198         (isObjectLike(value) && baseGetTag(value) == numberTag);
12199     }
12200
12201     /**
12202      * Checks if `value` is a plain object, that is, an object created by the
12203      * `Object` constructor or one with a `[[Prototype]]` of `null`.
12204      *
12205      * @static
12206      * @memberOf _
12207      * @since 0.8.0
12208      * @category Lang
12209      * @param {*} value The value to check.
12210      * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
12211      * @example
12212      *
12213      * function Foo() {
12214      *   this.a = 1;
12215      * }
12216      *
12217      * _.isPlainObject(new Foo);
12218      * // => false
12219      *
12220      * _.isPlainObject([1, 2, 3]);
12221      * // => false
12222      *
12223      * _.isPlainObject({ 'x': 0, 'y': 0 });
12224      * // => true
12225      *
12226      * _.isPlainObject(Object.create(null));
12227      * // => true
12228      */
12229     function isPlainObject(value) {
12230       if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12231         return false;
12232       }
12233       var proto = getPrototype(value);
12234       if (proto === null) {
12235         return true;
12236       }
12237       var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12238       return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12239         funcToString.call(Ctor) == objectCtorString;
12240     }
12241
12242     /**
12243      * Checks if `value` is classified as a `RegExp` object.
12244      *
12245      * @static
12246      * @memberOf _
12247      * @since 0.1.0
12248      * @category Lang
12249      * @param {*} value The value to check.
12250      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12251      * @example
12252      *
12253      * _.isRegExp(/abc/);
12254      * // => true
12255      *
12256      * _.isRegExp('/abc/');
12257      * // => false
12258      */
12259     var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
12260
12261     /**
12262      * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
12263      * double precision number which isn't the result of a rounded unsafe integer.
12264      *
12265      * **Note:** This method is based on
12266      * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12267      *
12268      * @static
12269      * @memberOf _
12270      * @since 4.0.0
12271      * @category Lang
12272      * @param {*} value The value to check.
12273      * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12274      * @example
12275      *
12276      * _.isSafeInteger(3);
12277      * // => true
12278      *
12279      * _.isSafeInteger(Number.MIN_VALUE);
12280      * // => false
12281      *
12282      * _.isSafeInteger(Infinity);
12283      * // => false
12284      *
12285      * _.isSafeInteger('3');
12286      * // => false
12287      */
12288     function isSafeInteger(value) {
12289       return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12290     }
12291
12292     /**
12293      * Checks if `value` is classified as a `Set` object.
12294      *
12295      * @static
12296      * @memberOf _
12297      * @since 4.3.0
12298      * @category Lang
12299      * @param {*} value The value to check.
12300      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12301      * @example
12302      *
12303      * _.isSet(new Set);
12304      * // => true
12305      *
12306      * _.isSet(new WeakSet);
12307      * // => false
12308      */
12309     var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12310
12311     /**
12312      * Checks if `value` is classified as a `String` primitive or object.
12313      *
12314      * @static
12315      * @since 0.1.0
12316      * @memberOf _
12317      * @category Lang
12318      * @param {*} value The value to check.
12319      * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12320      * @example
12321      *
12322      * _.isString('abc');
12323      * // => true
12324      *
12325      * _.isString(1);
12326      * // => false
12327      */
12328     function isString(value) {
12329       return typeof value == 'string' ||
12330         (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12331     }
12332
12333     /**
12334      * Checks if `value` is classified as a `Symbol` primitive or object.
12335      *
12336      * @static
12337      * @memberOf _
12338      * @since 4.0.0
12339      * @category Lang
12340      * @param {*} value The value to check.
12341      * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12342      * @example
12343      *
12344      * _.isSymbol(Symbol.iterator);
12345      * // => true
12346      *
12347      * _.isSymbol('abc');
12348      * // => false
12349      */
12350     function isSymbol(value) {
12351       return typeof value == 'symbol' ||
12352         (isObjectLike(value) && baseGetTag(value) == symbolTag);
12353     }
12354
12355     /**
12356      * Checks if `value` is classified as a typed array.
12357      *
12358      * @static
12359      * @memberOf _
12360      * @since 3.0.0
12361      * @category Lang
12362      * @param {*} value The value to check.
12363      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12364      * @example
12365      *
12366      * _.isTypedArray(new Uint8Array);
12367      * // => true
12368      *
12369      * _.isTypedArray([]);
12370      * // => false
12371      */
12372     var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12373
12374     /**
12375      * Checks if `value` is `undefined`.
12376      *
12377      * @static
12378      * @since 0.1.0
12379      * @memberOf _
12380      * @category Lang
12381      * @param {*} value The value to check.
12382      * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12383      * @example
12384      *
12385      * _.isUndefined(void 0);
12386      * // => true
12387      *
12388      * _.isUndefined(null);
12389      * // => false
12390      */
12391     function isUndefined(value) {
12392       return value === undefined;
12393     }
12394
12395     /**
12396      * Checks if `value` is classified as a `WeakMap` object.
12397      *
12398      * @static
12399      * @memberOf _
12400      * @since 4.3.0
12401      * @category Lang
12402      * @param {*} value The value to check.
12403      * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12404      * @example
12405      *
12406      * _.isWeakMap(new WeakMap);
12407      * // => true
12408      *
12409      * _.isWeakMap(new Map);
12410      * // => false
12411      */
12412     function isWeakMap(value) {
12413       return isObjectLike(value) && getTag(value) == weakMapTag;
12414     }
12415
12416     /**
12417      * Checks if `value` is classified as a `WeakSet` object.
12418      *
12419      * @static
12420      * @memberOf _
12421      * @since 4.3.0
12422      * @category Lang
12423      * @param {*} value The value to check.
12424      * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12425      * @example
12426      *
12427      * _.isWeakSet(new WeakSet);
12428      * // => true
12429      *
12430      * _.isWeakSet(new Set);
12431      * // => false
12432      */
12433     function isWeakSet(value) {
12434       return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12435     }
12436
12437     /**
12438      * Checks if `value` is less than `other`.
12439      *
12440      * @static
12441      * @memberOf _
12442      * @since 3.9.0
12443      * @category Lang
12444      * @param {*} value The value to compare.
12445      * @param {*} other The other value to compare.
12446      * @returns {boolean} Returns `true` if `value` is less than `other`,
12447      *  else `false`.
12448      * @see _.gt
12449      * @example
12450      *
12451      * _.lt(1, 3);
12452      * // => true
12453      *
12454      * _.lt(3, 3);
12455      * // => false
12456      *
12457      * _.lt(3, 1);
12458      * // => false
12459      */
12460     var lt = createRelationalOperation(baseLt);
12461
12462     /**
12463      * Checks if `value` is less than or equal to `other`.
12464      *
12465      * @static
12466      * @memberOf _
12467      * @since 3.9.0
12468      * @category Lang
12469      * @param {*} value The value to compare.
12470      * @param {*} other The other value to compare.
12471      * @returns {boolean} Returns `true` if `value` is less than or equal to
12472      *  `other`, else `false`.
12473      * @see _.gte
12474      * @example
12475      *
12476      * _.lte(1, 3);
12477      * // => true
12478      *
12479      * _.lte(3, 3);
12480      * // => true
12481      *
12482      * _.lte(3, 1);
12483      * // => false
12484      */
12485     var lte = createRelationalOperation(function(value, other) {
12486       return value <= other;
12487     });
12488
12489     /**
12490      * Converts `value` to an array.
12491      *
12492      * @static
12493      * @since 0.1.0
12494      * @memberOf _
12495      * @category Lang
12496      * @param {*} value The value to convert.
12497      * @returns {Array} Returns the converted array.
12498      * @example
12499      *
12500      * _.toArray({ 'a': 1, 'b': 2 });
12501      * // => [1, 2]
12502      *
12503      * _.toArray('abc');
12504      * // => ['a', 'b', 'c']
12505      *
12506      * _.toArray(1);
12507      * // => []
12508      *
12509      * _.toArray(null);
12510      * // => []
12511      */
12512     function toArray(value) {
12513       if (!value) {
12514         return [];
12515       }
12516       if (isArrayLike(value)) {
12517         return isString(value) ? stringToArray(value) : copyArray(value);
12518       }
12519       if (symIterator && value[symIterator]) {
12520         return iteratorToArray(value[symIterator]());
12521       }
12522       var tag = getTag(value),
12523         func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12524
12525       return func(value);
12526     }
12527
12528     /**
12529      * Converts `value` to a finite number.
12530      *
12531      * @static
12532      * @memberOf _
12533      * @since 4.12.0
12534      * @category Lang
12535      * @param {*} value The value to convert.
12536      * @returns {number} Returns the converted number.
12537      * @example
12538      *
12539      * _.toFinite(3.2);
12540      * // => 3.2
12541      *
12542      * _.toFinite(Number.MIN_VALUE);
12543      * // => 5e-324
12544      *
12545      * _.toFinite(Infinity);
12546      * // => 1.7976931348623157e+308
12547      *
12548      * _.toFinite('3.2');
12549      * // => 3.2
12550      */
12551     function toFinite(value) {
12552       if (!value) {
12553         return value === 0 ? value : 0;
12554       }
12555       value = toNumber(value);
12556       if (value === INFINITY || value === -INFINITY) {
12557         var sign = (value < 0 ? -1 : 1);
12558         return sign * MAX_INTEGER;
12559       }
12560       return value === value ? value : 0;
12561     }
12562
12563     /**
12564      * Converts `value` to an integer.
12565      *
12566      * **Note:** This method is loosely based on
12567      * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12568      *
12569      * @static
12570      * @memberOf _
12571      * @since 4.0.0
12572      * @category Lang
12573      * @param {*} value The value to convert.
12574      * @returns {number} Returns the converted integer.
12575      * @example
12576      *
12577      * _.toInteger(3.2);
12578      * // => 3
12579      *
12580      * _.toInteger(Number.MIN_VALUE);
12581      * // => 0
12582      *
12583      * _.toInteger(Infinity);
12584      * // => 1.7976931348623157e+308
12585      *
12586      * _.toInteger('3.2');
12587      * // => 3
12588      */
12589     function toInteger(value) {
12590       var result = toFinite(value),
12591         remainder = result % 1;
12592
12593       return result === result ? (remainder ? result - remainder : result) : 0;
12594     }
12595
12596     /**
12597      * Converts `value` to an integer suitable for use as the length of an
12598      * array-like object.
12599      *
12600      * **Note:** This method is based on
12601      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12602      *
12603      * @static
12604      * @memberOf _
12605      * @since 4.0.0
12606      * @category Lang
12607      * @param {*} value The value to convert.
12608      * @returns {number} Returns the converted integer.
12609      * @example
12610      *
12611      * _.toLength(3.2);
12612      * // => 3
12613      *
12614      * _.toLength(Number.MIN_VALUE);
12615      * // => 0
12616      *
12617      * _.toLength(Infinity);
12618      * // => 4294967295
12619      *
12620      * _.toLength('3.2');
12621      * // => 3
12622      */
12623     function toLength(value) {
12624       return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12625     }
12626
12627     /**
12628      * Converts `value` to a number.
12629      *
12630      * @static
12631      * @memberOf _
12632      * @since 4.0.0
12633      * @category Lang
12634      * @param {*} value The value to process.
12635      * @returns {number} Returns the number.
12636      * @example
12637      *
12638      * _.toNumber(3.2);
12639      * // => 3.2
12640      *
12641      * _.toNumber(Number.MIN_VALUE);
12642      * // => 5e-324
12643      *
12644      * _.toNumber(Infinity);
12645      * // => Infinity
12646      *
12647      * _.toNumber('3.2');
12648      * // => 3.2
12649      */
12650     function toNumber(value) {
12651       if (typeof value == 'number') {
12652         return value;
12653       }
12654       if (isSymbol(value)) {
12655         return NAN;
12656       }
12657       if (isObject(value)) {
12658         var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12659         value = isObject(other) ? (other + '') : other;
12660       }
12661       if (typeof value != 'string') {
12662         return value === 0 ? value : +value;
12663       }
12664       value = value.replace(reTrim, '');
12665       var isBinary = reIsBinary.test(value);
12666       return (isBinary || reIsOctal.test(value)) ?
12667         freeParseInt(value.slice(2), isBinary ? 2 : 8) :
12668         (reIsBadHex.test(value) ? NAN : +value);
12669     }
12670
12671     /**
12672      * Converts `value` to a plain object flattening inherited enumerable string
12673      * keyed properties of `value` to own properties of the plain object.
12674      *
12675      * @static
12676      * @memberOf _
12677      * @since 3.0.0
12678      * @category Lang
12679      * @param {*} value The value to convert.
12680      * @returns {Object} Returns the converted plain object.
12681      * @example
12682      *
12683      * function Foo() {
12684      *   this.b = 2;
12685      * }
12686      *
12687      * Foo.prototype.c = 3;
12688      *
12689      * _.assign({ 'a': 1 }, new Foo);
12690      * // => { 'a': 1, 'b': 2 }
12691      *
12692      * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12693      * // => { 'a': 1, 'b': 2, 'c': 3 }
12694      */
12695     function toPlainObject(value) {
12696       return copyObject(value, keysIn(value));
12697     }
12698
12699     /**
12700      * Converts `value` to a safe integer. A safe integer can be compared and
12701      * represented correctly.
12702      *
12703      * @static
12704      * @memberOf _
12705      * @since 4.0.0
12706      * @category Lang
12707      * @param {*} value The value to convert.
12708      * @returns {number} Returns the converted integer.
12709      * @example
12710      *
12711      * _.toSafeInteger(3.2);
12712      * // => 3
12713      *
12714      * _.toSafeInteger(Number.MIN_VALUE);
12715      * // => 0
12716      *
12717      * _.toSafeInteger(Infinity);
12718      * // => 9007199254740991
12719      *
12720      * _.toSafeInteger('3.2');
12721      * // => 3
12722      */
12723     function toSafeInteger(value) {
12724       return value ?
12725         baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) :
12726         (value === 0 ? value : 0);
12727     }
12728
12729     /**
12730      * Converts `value` to a string. An empty string is returned for `null`
12731      * and `undefined` values. The sign of `-0` is preserved.
12732      *
12733      * @static
12734      * @memberOf _
12735      * @since 4.0.0
12736      * @category Lang
12737      * @param {*} value The value to convert.
12738      * @returns {string} Returns the converted string.
12739      * @example
12740      *
12741      * _.toString(null);
12742      * // => ''
12743      *
12744      * _.toString(-0);
12745      * // => '-0'
12746      *
12747      * _.toString([1, 2, 3]);
12748      * // => '1,2,3'
12749      */
12750     function toString(value) {
12751       return value == null ? '' : baseToString(value);
12752     }
12753
12754     /*------------------------------------------------------------------------*/
12755
12756     /**
12757      * Assigns own enumerable string keyed properties of source objects to the
12758      * destination object. Source objects are applied from left to right.
12759      * Subsequent sources overwrite property assignments of previous sources.
12760      *
12761      * **Note:** This method mutates `object` and is loosely based on
12762      * [`Object.assign`](https://mdn.io/Object/assign).
12763      *
12764      * @static
12765      * @memberOf _
12766      * @since 0.10.0
12767      * @category Object
12768      * @param {Object} object The destination object.
12769      * @param {...Object} [sources] The source objects.
12770      * @returns {Object} Returns `object`.
12771      * @see _.assignIn
12772      * @example
12773      *
12774      * function Foo() {
12775      *   this.a = 1;
12776      * }
12777      *
12778      * function Bar() {
12779      *   this.c = 3;
12780      * }
12781      *
12782      * Foo.prototype.b = 2;
12783      * Bar.prototype.d = 4;
12784      *
12785      * _.assign({ 'a': 0 }, new Foo, new Bar);
12786      * // => { 'a': 1, 'c': 3 }
12787      */
12788     var assign = createAssigner(function(object, source) {
12789       if (isPrototype(source) || isArrayLike(source)) {
12790         copyObject(source, keys(source), object);
12791         return;
12792       }
12793       for (var key in source) {
12794         if (hasOwnProperty.call(source, key)) {
12795           assignValue(object, key, source[key]);
12796         }
12797       }
12798     });
12799
12800     /**
12801      * This method is like `_.assign` except that it iterates over own and
12802      * inherited source properties.
12803      *
12804      * **Note:** This method mutates `object`.
12805      *
12806      * @static
12807      * @memberOf _
12808      * @since 4.0.0
12809      * @alias extend
12810      * @category Object
12811      * @param {Object} object The destination object.
12812      * @param {...Object} [sources] The source objects.
12813      * @returns {Object} Returns `object`.
12814      * @see _.assign
12815      * @example
12816      *
12817      * function Foo() {
12818      *   this.a = 1;
12819      * }
12820      *
12821      * function Bar() {
12822      *   this.c = 3;
12823      * }
12824      *
12825      * Foo.prototype.b = 2;
12826      * Bar.prototype.d = 4;
12827      *
12828      * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12829      * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12830      */
12831     var assignIn = createAssigner(function(object, source) {
12832       copyObject(source, keysIn(source), object);
12833     });
12834
12835     /**
12836      * This method is like `_.assignIn` except that it accepts `customizer`
12837      * which is invoked to produce the assigned values. If `customizer` returns
12838      * `undefined`, assignment is handled by the method instead. The `customizer`
12839      * is invoked with five arguments: (objValue, srcValue, key, object, source).
12840      *
12841      * **Note:** This method mutates `object`.
12842      *
12843      * @static
12844      * @memberOf _
12845      * @since 4.0.0
12846      * @alias extendWith
12847      * @category Object
12848      * @param {Object} object The destination object.
12849      * @param {...Object} sources The source objects.
12850      * @param {Function} [customizer] The function to customize assigned values.
12851      * @returns {Object} Returns `object`.
12852      * @see _.assignWith
12853      * @example
12854      *
12855      * function customizer(objValue, srcValue) {
12856      *   return _.isUndefined(objValue) ? srcValue : objValue;
12857      * }
12858      *
12859      * var defaults = _.partialRight(_.assignInWith, customizer);
12860      *
12861      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12862      * // => { 'a': 1, 'b': 2 }
12863      */
12864     var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
12865       copyObject(source, keysIn(source), object, customizer);
12866     });
12867
12868     /**
12869      * This method is like `_.assign` except that it accepts `customizer`
12870      * which is invoked to produce the assigned values. If `customizer` returns
12871      * `undefined`, assignment is handled by the method instead. The `customizer`
12872      * is invoked with five arguments: (objValue, srcValue, key, object, source).
12873      *
12874      * **Note:** This method mutates `object`.
12875      *
12876      * @static
12877      * @memberOf _
12878      * @since 4.0.0
12879      * @category Object
12880      * @param {Object} object The destination object.
12881      * @param {...Object} sources The source objects.
12882      * @param {Function} [customizer] The function to customize assigned values.
12883      * @returns {Object} Returns `object`.
12884      * @see _.assignInWith
12885      * @example
12886      *
12887      * function customizer(objValue, srcValue) {
12888      *   return _.isUndefined(objValue) ? srcValue : objValue;
12889      * }
12890      *
12891      * var defaults = _.partialRight(_.assignWith, customizer);
12892      *
12893      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12894      * // => { 'a': 1, 'b': 2 }
12895      */
12896     var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
12897       copyObject(source, keys(source), object, customizer);
12898     });
12899
12900     /**
12901      * Creates an array of values corresponding to `paths` of `object`.
12902      *
12903      * @static
12904      * @memberOf _
12905      * @since 1.0.0
12906      * @category Object
12907      * @param {Object} object The object to iterate over.
12908      * @param {...(string|string[])} [paths] The property paths to pick.
12909      * @returns {Array} Returns the picked values.
12910      * @example
12911      *
12912      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
12913      *
12914      * _.at(object, ['a[0].b.c', 'a[1]']);
12915      * // => [3, 4]
12916      */
12917     var at = flatRest(baseAt);
12918
12919     /**
12920      * Creates an object that inherits from the `prototype` object. If a
12921      * `properties` object is given, its own enumerable string keyed properties
12922      * are assigned to the created object.
12923      *
12924      * @static
12925      * @memberOf _
12926      * @since 2.3.0
12927      * @category Object
12928      * @param {Object} prototype The object to inherit from.
12929      * @param {Object} [properties] The properties to assign to the object.
12930      * @returns {Object} Returns the new object.
12931      * @example
12932      *
12933      * function Shape() {
12934      *   this.x = 0;
12935      *   this.y = 0;
12936      * }
12937      *
12938      * function Circle() {
12939      *   Shape.call(this);
12940      * }
12941      *
12942      * Circle.prototype = _.create(Shape.prototype, {
12943      *   'constructor': Circle
12944      * });
12945      *
12946      * var circle = new Circle;
12947      * circle instanceof Circle;
12948      * // => true
12949      *
12950      * circle instanceof Shape;
12951      * // => true
12952      */
12953     function create(prototype, properties) {
12954       var result = baseCreate(prototype);
12955       return properties == null ? result : baseAssign(result, properties);
12956     }
12957
12958     /**
12959      * Assigns own and inherited enumerable string keyed properties of source
12960      * objects to the destination object for all destination properties that
12961      * resolve to `undefined`. Source objects are applied from left to right.
12962      * Once a property is set, additional values of the same property are ignored.
12963      *
12964      * **Note:** This method mutates `object`.
12965      *
12966      * @static
12967      * @since 0.1.0
12968      * @memberOf _
12969      * @category Object
12970      * @param {Object} object The destination object.
12971      * @param {...Object} [sources] The source objects.
12972      * @returns {Object} Returns `object`.
12973      * @see _.defaultsDeep
12974      * @example
12975      *
12976      * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12977      * // => { 'a': 1, 'b': 2 }
12978      */
12979     var defaults = baseRest(function(object, sources) {
12980       object = Object(object);
12981
12982       var index = -1;
12983       var length = sources.length;
12984       var guard = length > 2 ? sources[2] : undefined;
12985
12986       if (guard && isIterateeCall(sources[0], sources[1], guard)) {
12987         length = 1;
12988       }
12989
12990       while (++index < length) {
12991         var source = sources[index];
12992         var props = keysIn(source);
12993         var propsIndex = -1;
12994         var propsLength = props.length;
12995
12996         while (++propsIndex < propsLength) {
12997           var key = props[propsIndex];
12998           var value = object[key];
12999
13000           if (value === undefined ||
13001             (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
13002             object[key] = source[key];
13003           }
13004         }
13005       }
13006
13007       return object;
13008     });
13009
13010     /**
13011      * This method is like `_.defaults` except that it recursively assigns
13012      * default properties.
13013      *
13014      * **Note:** This method mutates `object`.
13015      *
13016      * @static
13017      * @memberOf _
13018      * @since 3.10.0
13019      * @category Object
13020      * @param {Object} object The destination object.
13021      * @param {...Object} [sources] The source objects.
13022      * @returns {Object} Returns `object`.
13023      * @see _.defaults
13024      * @example
13025      *
13026      * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
13027      * // => { 'a': { 'b': 2, 'c': 3 } }
13028      */
13029     var defaultsDeep = baseRest(function(args) {
13030       args.push(undefined, customDefaultsMerge);
13031       return apply(mergeWith, undefined, args);
13032     });
13033
13034     /**
13035      * This method is like `_.find` except that it returns the key of the first
13036      * element `predicate` returns truthy for instead of the element itself.
13037      *
13038      * @static
13039      * @memberOf _
13040      * @since 1.1.0
13041      * @category Object
13042      * @param {Object} object The object to inspect.
13043      * @param {Function} [predicate=_.identity] The function invoked per iteration.
13044      * @returns {string|undefined} Returns the key of the matched element,
13045      *  else `undefined`.
13046      * @example
13047      *
13048      * var users = {
13049      *   'barney':  { 'age': 36, 'active': true },
13050      *   'fred':    { 'age': 40, 'active': false },
13051      *   'pebbles': { 'age': 1,  'active': true }
13052      * };
13053      *
13054      * _.findKey(users, function(o) { return o.age < 40; });
13055      * // => 'barney' (iteration order is not guaranteed)
13056      *
13057      * // The `_.matches` iteratee shorthand.
13058      * _.findKey(users, { 'age': 1, 'active': true });
13059      * // => 'pebbles'
13060      *
13061      * // The `_.matchesProperty` iteratee shorthand.
13062      * _.findKey(users, ['active', false]);
13063      * // => 'fred'
13064      *
13065      * // The `_.property` iteratee shorthand.
13066      * _.findKey(users, 'active');
13067      * // => 'barney'
13068      */
13069     function findKey(object, predicate) {
13070       return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
13071     }
13072
13073     /**
13074      * This method is like `_.findKey` except that it iterates over elements of
13075      * a collection in the opposite order.
13076      *
13077      * @static
13078      * @memberOf _
13079      * @since 2.0.0
13080      * @category Object
13081      * @param {Object} object The object to inspect.
13082      * @param {Function} [predicate=_.identity] The function invoked per iteration.
13083      * @returns {string|undefined} Returns the key of the matched element,
13084      *  else `undefined`.
13085      * @example
13086      *
13087      * var users = {
13088      *   'barney':  { 'age': 36, 'active': true },
13089      *   'fred':    { 'age': 40, 'active': false },
13090      *   'pebbles': { 'age': 1,  'active': true }
13091      * };
13092      *
13093      * _.findLastKey(users, function(o) { return o.age < 40; });
13094      * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
13095      *
13096      * // The `_.matches` iteratee shorthand.
13097      * _.findLastKey(users, { 'age': 36, 'active': true });
13098      * // => 'barney'
13099      *
13100      * // The `_.matchesProperty` iteratee shorthand.
13101      * _.findLastKey(users, ['active', false]);
13102      * // => 'fred'
13103      *
13104      * // The `_.property` iteratee shorthand.
13105      * _.findLastKey(users, 'active');
13106      * // => 'pebbles'
13107      */
13108     function findLastKey(object, predicate) {
13109       return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
13110     }
13111
13112     /**
13113      * Iterates over own and inherited enumerable string keyed properties of an
13114      * object and invokes `iteratee` for each property. The iteratee is invoked
13115      * with three arguments: (value, key, object). Iteratee functions may exit
13116      * iteration early by explicitly returning `false`.
13117      *
13118      * @static
13119      * @memberOf _
13120      * @since 0.3.0
13121      * @category Object
13122      * @param {Object} object The object to iterate over.
13123      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13124      * @returns {Object} Returns `object`.
13125      * @see _.forInRight
13126      * @example
13127      *
13128      * function Foo() {
13129      *   this.a = 1;
13130      *   this.b = 2;
13131      * }
13132      *
13133      * Foo.prototype.c = 3;
13134      *
13135      * _.forIn(new Foo, function(value, key) {
13136      *   console.log(key);
13137      * });
13138      * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
13139      */
13140     function forIn(object, iteratee) {
13141       return object == null ?
13142         object :
13143         baseFor(object, getIteratee(iteratee, 3), keysIn);
13144     }
13145
13146     /**
13147      * This method is like `_.forIn` except that it iterates over properties of
13148      * `object` in the opposite order.
13149      *
13150      * @static
13151      * @memberOf _
13152      * @since 2.0.0
13153      * @category Object
13154      * @param {Object} object The object to iterate over.
13155      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13156      * @returns {Object} Returns `object`.
13157      * @see _.forIn
13158      * @example
13159      *
13160      * function Foo() {
13161      *   this.a = 1;
13162      *   this.b = 2;
13163      * }
13164      *
13165      * Foo.prototype.c = 3;
13166      *
13167      * _.forInRight(new Foo, function(value, key) {
13168      *   console.log(key);
13169      * });
13170      * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
13171      */
13172     function forInRight(object, iteratee) {
13173       return object == null ?
13174         object :
13175         baseForRight(object, getIteratee(iteratee, 3), keysIn);
13176     }
13177
13178     /**
13179      * Iterates over own enumerable string keyed properties of an object and
13180      * invokes `iteratee` for each property. The iteratee is invoked with three
13181      * arguments: (value, key, object). Iteratee functions may exit iteration
13182      * early by explicitly returning `false`.
13183      *
13184      * @static
13185      * @memberOf _
13186      * @since 0.3.0
13187      * @category Object
13188      * @param {Object} object The object to iterate over.
13189      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13190      * @returns {Object} Returns `object`.
13191      * @see _.forOwnRight
13192      * @example
13193      *
13194      * function Foo() {
13195      *   this.a = 1;
13196      *   this.b = 2;
13197      * }
13198      *
13199      * Foo.prototype.c = 3;
13200      *
13201      * _.forOwn(new Foo, function(value, key) {
13202      *   console.log(key);
13203      * });
13204      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
13205      */
13206     function forOwn(object, iteratee) {
13207       return object && baseForOwn(object, getIteratee(iteratee, 3));
13208     }
13209
13210     /**
13211      * This method is like `_.forOwn` except that it iterates over properties of
13212      * `object` in the opposite order.
13213      *
13214      * @static
13215      * @memberOf _
13216      * @since 2.0.0
13217      * @category Object
13218      * @param {Object} object The object to iterate over.
13219      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13220      * @returns {Object} Returns `object`.
13221      * @see _.forOwn
13222      * @example
13223      *
13224      * function Foo() {
13225      *   this.a = 1;
13226      *   this.b = 2;
13227      * }
13228      *
13229      * Foo.prototype.c = 3;
13230      *
13231      * _.forOwnRight(new Foo, function(value, key) {
13232      *   console.log(key);
13233      * });
13234      * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
13235      */
13236     function forOwnRight(object, iteratee) {
13237       return object && baseForOwnRight(object, getIteratee(iteratee, 3));
13238     }
13239
13240     /**
13241      * Creates an array of function property names from own enumerable properties
13242      * of `object`.
13243      *
13244      * @static
13245      * @since 0.1.0
13246      * @memberOf _
13247      * @category Object
13248      * @param {Object} object The object to inspect.
13249      * @returns {Array} Returns the function names.
13250      * @see _.functionsIn
13251      * @example
13252      *
13253      * function Foo() {
13254      *   this.a = _.constant('a');
13255      *   this.b = _.constant('b');
13256      * }
13257      *
13258      * Foo.prototype.c = _.constant('c');
13259      *
13260      * _.functions(new Foo);
13261      * // => ['a', 'b']
13262      */
13263     function functions(object) {
13264       return object == null ? [] : baseFunctions(object, keys(object));
13265     }
13266
13267     /**
13268      * Creates an array of function property names from own and inherited
13269      * enumerable properties of `object`.
13270      *
13271      * @static
13272      * @memberOf _
13273      * @since 4.0.0
13274      * @category Object
13275      * @param {Object} object The object to inspect.
13276      * @returns {Array} Returns the function names.
13277      * @see _.functions
13278      * @example
13279      *
13280      * function Foo() {
13281      *   this.a = _.constant('a');
13282      *   this.b = _.constant('b');
13283      * }
13284      *
13285      * Foo.prototype.c = _.constant('c');
13286      *
13287      * _.functionsIn(new Foo);
13288      * // => ['a', 'b', 'c']
13289      */
13290     function functionsIn(object) {
13291       return object == null ? [] : baseFunctions(object, keysIn(object));
13292     }
13293
13294     /**
13295      * Gets the value at `path` of `object`. If the resolved value is
13296      * `undefined`, the `defaultValue` is returned in its place.
13297      *
13298      * @static
13299      * @memberOf _
13300      * @since 3.7.0
13301      * @category Object
13302      * @param {Object} object The object to query.
13303      * @param {Array|string} path The path of the property to get.
13304      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13305      * @returns {*} Returns the resolved value.
13306      * @example
13307      *
13308      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13309      *
13310      * _.get(object, 'a[0].b.c');
13311      * // => 3
13312      *
13313      * _.get(object, ['a', '0', 'b', 'c']);
13314      * // => 3
13315      *
13316      * _.get(object, 'a.b.c', 'default');
13317      * // => 'default'
13318      */
13319     function get(object, path, defaultValue) {
13320       var result = object == null ? undefined : baseGet(object, path);
13321       return result === undefined ? defaultValue : result;
13322     }
13323
13324     /**
13325      * Checks if `path` is a direct property of `object`.
13326      *
13327      * @static
13328      * @since 0.1.0
13329      * @memberOf _
13330      * @category Object
13331      * @param {Object} object The object to query.
13332      * @param {Array|string} path The path to check.
13333      * @returns {boolean} Returns `true` if `path` exists, else `false`.
13334      * @example
13335      *
13336      * var object = { 'a': { 'b': 2 } };
13337      * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13338      *
13339      * _.has(object, 'a');
13340      * // => true
13341      *
13342      * _.has(object, 'a.b');
13343      * // => true
13344      *
13345      * _.has(object, ['a', 'b']);
13346      * // => true
13347      *
13348      * _.has(other, 'a');
13349      * // => false
13350      */
13351     function has(object, path) {
13352       return object != null && hasPath(object, path, baseHas);
13353     }
13354
13355     /**
13356      * Checks if `path` is a direct or inherited property of `object`.
13357      *
13358      * @static
13359      * @memberOf _
13360      * @since 4.0.0
13361      * @category Object
13362      * @param {Object} object The object to query.
13363      * @param {Array|string} path The path to check.
13364      * @returns {boolean} Returns `true` if `path` exists, else `false`.
13365      * @example
13366      *
13367      * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13368      *
13369      * _.hasIn(object, 'a');
13370      * // => true
13371      *
13372      * _.hasIn(object, 'a.b');
13373      * // => true
13374      *
13375      * _.hasIn(object, ['a', 'b']);
13376      * // => true
13377      *
13378      * _.hasIn(object, 'b');
13379      * // => false
13380      */
13381     function hasIn(object, path) {
13382       return object != null && hasPath(object, path, baseHasIn);
13383     }
13384
13385     /**
13386      * Creates an object composed of the inverted keys and values of `object`.
13387      * If `object` contains duplicate values, subsequent values overwrite
13388      * property assignments of previous values.
13389      *
13390      * @static
13391      * @memberOf _
13392      * @since 0.7.0
13393      * @category Object
13394      * @param {Object} object The object to invert.
13395      * @returns {Object} Returns the new inverted object.
13396      * @example
13397      *
13398      * var object = { 'a': 1, 'b': 2, 'c': 1 };
13399      *
13400      * _.invert(object);
13401      * // => { '1': 'c', '2': 'b' }
13402      */
13403     var invert = createInverter(function(result, value, key) {
13404       if (value != null &&
13405         typeof value.toString != 'function') {
13406         value = nativeObjectToString.call(value);
13407       }
13408
13409       result[value] = key;
13410     }, constant(identity));
13411
13412     /**
13413      * This method is like `_.invert` except that the inverted object is generated
13414      * from the results of running each element of `object` thru `iteratee`. The
13415      * corresponding inverted value of each inverted key is an array of keys
13416      * responsible for generating the inverted value. The iteratee is invoked
13417      * with one argument: (value).
13418      *
13419      * @static
13420      * @memberOf _
13421      * @since 4.1.0
13422      * @category Object
13423      * @param {Object} object The object to invert.
13424      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
13425      * @returns {Object} Returns the new inverted object.
13426      * @example
13427      *
13428      * var object = { 'a': 1, 'b': 2, 'c': 1 };
13429      *
13430      * _.invertBy(object);
13431      * // => { '1': ['a', 'c'], '2': ['b'] }
13432      *
13433      * _.invertBy(object, function(value) {
13434      *   return 'group' + value;
13435      * });
13436      * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13437      */
13438     var invertBy = createInverter(function(result, value, key) {
13439       if (value != null &&
13440         typeof value.toString != 'function') {
13441         value = nativeObjectToString.call(value);
13442       }
13443
13444       if (hasOwnProperty.call(result, value)) {
13445         result[value].push(key);
13446       } else {
13447         result[value] = [key];
13448       }
13449     }, getIteratee);
13450
13451     /**
13452      * Invokes the method at `path` of `object`.
13453      *
13454      * @static
13455      * @memberOf _
13456      * @since 4.0.0
13457      * @category Object
13458      * @param {Object} object The object to query.
13459      * @param {Array|string} path The path of the method to invoke.
13460      * @param {...*} [args] The arguments to invoke the method with.
13461      * @returns {*} Returns the result of the invoked method.
13462      * @example
13463      *
13464      * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13465      *
13466      * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13467      * // => [2, 3]
13468      */
13469     var invoke = baseRest(baseInvoke);
13470
13471     /**
13472      * Creates an array of the own enumerable property names of `object`.
13473      *
13474      * **Note:** Non-object values are coerced to objects. See the
13475      * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
13476      * for more details.
13477      *
13478      * @static
13479      * @since 0.1.0
13480      * @memberOf _
13481      * @category Object
13482      * @param {Object} object The object to query.
13483      * @returns {Array} Returns the array of property names.
13484      * @example
13485      *
13486      * function Foo() {
13487      *   this.a = 1;
13488      *   this.b = 2;
13489      * }
13490      *
13491      * Foo.prototype.c = 3;
13492      *
13493      * _.keys(new Foo);
13494      * // => ['a', 'b'] (iteration order is not guaranteed)
13495      *
13496      * _.keys('hi');
13497      * // => ['0', '1']
13498      */
13499     function keys(object) {
13500       return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13501     }
13502
13503     /**
13504      * Creates an array of the own and inherited enumerable property names of `object`.
13505      *
13506      * **Note:** Non-object values are coerced to objects.
13507      *
13508      * @static
13509      * @memberOf _
13510      * @since 3.0.0
13511      * @category Object
13512      * @param {Object} object The object to query.
13513      * @returns {Array} Returns the array of property names.
13514      * @example
13515      *
13516      * function Foo() {
13517      *   this.a = 1;
13518      *   this.b = 2;
13519      * }
13520      *
13521      * Foo.prototype.c = 3;
13522      *
13523      * _.keysIn(new Foo);
13524      * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13525      */
13526     function keysIn(object) {
13527       return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
13528     }
13529
13530     /**
13531      * The opposite of `_.mapValues`; this method creates an object with the
13532      * same values as `object` and keys generated by running each own enumerable
13533      * string keyed property of `object` thru `iteratee`. The iteratee is invoked
13534      * with three arguments: (value, key, object).
13535      *
13536      * @static
13537      * @memberOf _
13538      * @since 3.8.0
13539      * @category Object
13540      * @param {Object} object The object to iterate over.
13541      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13542      * @returns {Object} Returns the new mapped object.
13543      * @see _.mapValues
13544      * @example
13545      *
13546      * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13547      *   return key + value;
13548      * });
13549      * // => { 'a1': 1, 'b2': 2 }
13550      */
13551     function mapKeys(object, iteratee) {
13552       var result = {};
13553       iteratee = getIteratee(iteratee, 3);
13554
13555       baseForOwn(object, function(value, key, object) {
13556         baseAssignValue(result, iteratee(value, key, object), value);
13557       });
13558       return result;
13559     }
13560
13561     /**
13562      * Creates an object with the same keys as `object` and values generated
13563      * by running each own enumerable string keyed property of `object` thru
13564      * `iteratee`. The iteratee is invoked with three arguments:
13565      * (value, key, object).
13566      *
13567      * @static
13568      * @memberOf _
13569      * @since 2.4.0
13570      * @category Object
13571      * @param {Object} object The object to iterate over.
13572      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13573      * @returns {Object} Returns the new mapped object.
13574      * @see _.mapKeys
13575      * @example
13576      *
13577      * var users = {
13578      *   'fred':    { 'user': 'fred',    'age': 40 },
13579      *   'pebbles': { 'user': 'pebbles', 'age': 1 }
13580      * };
13581      *
13582      * _.mapValues(users, function(o) { return o.age; });
13583      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13584      *
13585      * // The `_.property` iteratee shorthand.
13586      * _.mapValues(users, 'age');
13587      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13588      */
13589     function mapValues(object, iteratee) {
13590       var result = {};
13591       iteratee = getIteratee(iteratee, 3);
13592
13593       baseForOwn(object, function(value, key, object) {
13594         baseAssignValue(result, key, iteratee(value, key, object));
13595       });
13596       return result;
13597     }
13598
13599     /**
13600      * This method is like `_.assign` except that it recursively merges own and
13601      * inherited enumerable string keyed properties of source objects into the
13602      * destination object. Source properties that resolve to `undefined` are
13603      * skipped if a destination value exists. Array and plain object properties
13604      * are merged recursively. Other objects and value types are overridden by
13605      * assignment. Source objects are applied from left to right. Subsequent
13606      * sources overwrite property assignments of previous sources.
13607      *
13608      * **Note:** This method mutates `object`.
13609      *
13610      * @static
13611      * @memberOf _
13612      * @since 0.5.0
13613      * @category Object
13614      * @param {Object} object The destination object.
13615      * @param {...Object} [sources] The source objects.
13616      * @returns {Object} Returns `object`.
13617      * @example
13618      *
13619      * var object = {
13620      *   'a': [{ 'b': 2 }, { 'd': 4 }]
13621      * };
13622      *
13623      * var other = {
13624      *   'a': [{ 'c': 3 }, { 'e': 5 }]
13625      * };
13626      *
13627      * _.merge(object, other);
13628      * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13629      */
13630     var merge = createAssigner(function(object, source, srcIndex) {
13631       baseMerge(object, source, srcIndex);
13632     });
13633
13634     /**
13635      * This method is like `_.merge` except that it accepts `customizer` which
13636      * is invoked to produce the merged values of the destination and source
13637      * properties. If `customizer` returns `undefined`, merging is handled by the
13638      * method instead. The `customizer` is invoked with six arguments:
13639      * (objValue, srcValue, key, object, source, stack).
13640      *
13641      * **Note:** This method mutates `object`.
13642      *
13643      * @static
13644      * @memberOf _
13645      * @since 4.0.0
13646      * @category Object
13647      * @param {Object} object The destination object.
13648      * @param {...Object} sources The source objects.
13649      * @param {Function} customizer The function to customize assigned values.
13650      * @returns {Object} Returns `object`.
13651      * @example
13652      *
13653      * function customizer(objValue, srcValue) {
13654      *   if (_.isArray(objValue)) {
13655      *     return objValue.concat(srcValue);
13656      *   }
13657      * }
13658      *
13659      * var object = { 'a': [1], 'b': [2] };
13660      * var other = { 'a': [3], 'b': [4] };
13661      *
13662      * _.mergeWith(object, other, customizer);
13663      * // => { 'a': [1, 3], 'b': [2, 4] }
13664      */
13665     var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13666       baseMerge(object, source, srcIndex, customizer);
13667     });
13668
13669     /**
13670      * The opposite of `_.pick`; this method creates an object composed of the
13671      * own and inherited enumerable property paths of `object` that are not omitted.
13672      *
13673      * **Note:** This method is considerably slower than `_.pick`.
13674      *
13675      * @static
13676      * @since 0.1.0
13677      * @memberOf _
13678      * @category Object
13679      * @param {Object} object The source object.
13680      * @param {...(string|string[])} [paths] The property paths to omit.
13681      * @returns {Object} Returns the new object.
13682      * @example
13683      *
13684      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13685      *
13686      * _.omit(object, ['a', 'c']);
13687      * // => { 'b': '2' }
13688      */
13689     var omit = flatRest(function(object, paths) {
13690       var result = {};
13691       if (object == null) {
13692         return result;
13693       }
13694       var isDeep = false;
13695       paths = arrayMap(paths, function(path) {
13696         path = castPath(path, object);
13697         isDeep || (isDeep = path.length > 1);
13698         return path;
13699       });
13700       copyObject(object, getAllKeysIn(object), result);
13701       if (isDeep) {
13702         result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
13703       }
13704       var length = paths.length;
13705       while (length--) {
13706         baseUnset(result, paths[length]);
13707       }
13708       return result;
13709     });
13710
13711     /**
13712      * The opposite of `_.pickBy`; this method creates an object composed of
13713      * the own and inherited enumerable string keyed properties of `object` that
13714      * `predicate` doesn't return truthy for. The predicate is invoked with two
13715      * arguments: (value, key).
13716      *
13717      * @static
13718      * @memberOf _
13719      * @since 4.0.0
13720      * @category Object
13721      * @param {Object} object The source object.
13722      * @param {Function} [predicate=_.identity] The function invoked per property.
13723      * @returns {Object} Returns the new object.
13724      * @example
13725      *
13726      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13727      *
13728      * _.omitBy(object, _.isNumber);
13729      * // => { 'b': '2' }
13730      */
13731     function omitBy(object, predicate) {
13732       return pickBy(object, negate(getIteratee(predicate)));
13733     }
13734
13735     /**
13736      * Creates an object composed of the picked `object` properties.
13737      *
13738      * @static
13739      * @since 0.1.0
13740      * @memberOf _
13741      * @category Object
13742      * @param {Object} object The source object.
13743      * @param {...(string|string[])} [paths] The property paths to pick.
13744      * @returns {Object} Returns the new object.
13745      * @example
13746      *
13747      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13748      *
13749      * _.pick(object, ['a', 'c']);
13750      * // => { 'a': 1, 'c': 3 }
13751      */
13752     var pick = flatRest(function(object, paths) {
13753       return object == null ? {} : basePick(object, paths);
13754     });
13755
13756     /**
13757      * Creates an object composed of the `object` properties `predicate` returns
13758      * truthy for. The predicate is invoked with two arguments: (value, key).
13759      *
13760      * @static
13761      * @memberOf _
13762      * @since 4.0.0
13763      * @category Object
13764      * @param {Object} object The source object.
13765      * @param {Function} [predicate=_.identity] The function invoked per property.
13766      * @returns {Object} Returns the new object.
13767      * @example
13768      *
13769      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13770      *
13771      * _.pickBy(object, _.isNumber);
13772      * // => { 'a': 1, 'c': 3 }
13773      */
13774     function pickBy(object, predicate) {
13775       if (object == null) {
13776         return {};
13777       }
13778       var props = arrayMap(getAllKeysIn(object), function(prop) {
13779         return [prop];
13780       });
13781       predicate = getIteratee(predicate);
13782       return basePickBy(object, props, function(value, path) {
13783         return predicate(value, path[0]);
13784       });
13785     }
13786
13787     /**
13788      * This method is like `_.get` except that if the resolved value is a
13789      * function it's invoked with the `this` binding of its parent object and
13790      * its result is returned.
13791      *
13792      * @static
13793      * @since 0.1.0
13794      * @memberOf _
13795      * @category Object
13796      * @param {Object} object The object to query.
13797      * @param {Array|string} path The path of the property to resolve.
13798      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13799      * @returns {*} Returns the resolved value.
13800      * @example
13801      *
13802      * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13803      *
13804      * _.result(object, 'a[0].b.c1');
13805      * // => 3
13806      *
13807      * _.result(object, 'a[0].b.c2');
13808      * // => 4
13809      *
13810      * _.result(object, 'a[0].b.c3', 'default');
13811      * // => 'default'
13812      *
13813      * _.result(object, 'a[0].b.c3', _.constant('default'));
13814      * // => 'default'
13815      */
13816     function result(object, path, defaultValue) {
13817       path = castPath(path, object);
13818
13819       var index = -1,
13820         length = path.length;
13821
13822       // Ensure the loop is entered when path is empty.
13823       if (!length) {
13824         length = 1;
13825         object = undefined;
13826       }
13827       while (++index < length) {
13828         var value = object == null ? undefined : object[toKey(path[index])];
13829         if (value === undefined) {
13830           index = length;
13831           value = defaultValue;
13832         }
13833         object = isFunction(value) ? value.call(object) : value;
13834       }
13835       return object;
13836     }
13837
13838     /**
13839      * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
13840      * it's created. Arrays are created for missing index properties while objects
13841      * are created for all other missing properties. Use `_.setWith` to customize
13842      * `path` creation.
13843      *
13844      * **Note:** This method mutates `object`.
13845      *
13846      * @static
13847      * @memberOf _
13848      * @since 3.7.0
13849      * @category Object
13850      * @param {Object} object The object to modify.
13851      * @param {Array|string} path The path of the property to set.
13852      * @param {*} value The value to set.
13853      * @returns {Object} Returns `object`.
13854      * @example
13855      *
13856      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13857      *
13858      * _.set(object, 'a[0].b.c', 4);
13859      * console.log(object.a[0].b.c);
13860      * // => 4
13861      *
13862      * _.set(object, ['x', '0', 'y', 'z'], 5);
13863      * console.log(object.x[0].y.z);
13864      * // => 5
13865      */
13866     function set(object, path, value) {
13867       return object == null ? object : baseSet(object, path, value);
13868     }
13869
13870     /**
13871      * This method is like `_.set` except that it accepts `customizer` which is
13872      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13873      * path creation is handled by the method instead. The `customizer` is invoked
13874      * with three arguments: (nsValue, key, nsObject).
13875      *
13876      * **Note:** This method mutates `object`.
13877      *
13878      * @static
13879      * @memberOf _
13880      * @since 4.0.0
13881      * @category Object
13882      * @param {Object} object The object to modify.
13883      * @param {Array|string} path The path of the property to set.
13884      * @param {*} value The value to set.
13885      * @param {Function} [customizer] The function to customize assigned values.
13886      * @returns {Object} Returns `object`.
13887      * @example
13888      *
13889      * var object = {};
13890      *
13891      * _.setWith(object, '[0][1]', 'a', Object);
13892      * // => { '0': { '1': 'a' } }
13893      */
13894     function setWith(object, path, value, customizer) {
13895       customizer = typeof customizer == 'function' ? customizer : undefined;
13896       return object == null ? object : baseSet(object, path, value, customizer);
13897     }
13898
13899     /**
13900      * Creates an array of own enumerable string keyed-value pairs for `object`
13901      * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
13902      * entries are returned.
13903      *
13904      * @static
13905      * @memberOf _
13906      * @since 4.0.0
13907      * @alias entries
13908      * @category Object
13909      * @param {Object} object The object to query.
13910      * @returns {Array} Returns the key-value pairs.
13911      * @example
13912      *
13913      * function Foo() {
13914      *   this.a = 1;
13915      *   this.b = 2;
13916      * }
13917      *
13918      * Foo.prototype.c = 3;
13919      *
13920      * _.toPairs(new Foo);
13921      * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
13922      */
13923     var toPairs = createToPairs(keys);
13924
13925     /**
13926      * Creates an array of own and inherited enumerable string keyed-value pairs
13927      * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
13928      * or set, its entries are returned.
13929      *
13930      * @static
13931      * @memberOf _
13932      * @since 4.0.0
13933      * @alias entriesIn
13934      * @category Object
13935      * @param {Object} object The object to query.
13936      * @returns {Array} Returns the key-value pairs.
13937      * @example
13938      *
13939      * function Foo() {
13940      *   this.a = 1;
13941      *   this.b = 2;
13942      * }
13943      *
13944      * Foo.prototype.c = 3;
13945      *
13946      * _.toPairsIn(new Foo);
13947      * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
13948      */
13949     var toPairsIn = createToPairs(keysIn);
13950
13951     /**
13952      * An alternative to `_.reduce`; this method transforms `object` to a new
13953      * `accumulator` object which is the result of running each of its own
13954      * enumerable string keyed properties thru `iteratee`, with each invocation
13955      * potentially mutating the `accumulator` object. If `accumulator` is not
13956      * provided, a new object with the same `[[Prototype]]` will be used. The
13957      * iteratee is invoked with four arguments: (accumulator, value, key, object).
13958      * Iteratee functions may exit iteration early by explicitly returning `false`.
13959      *
13960      * @static
13961      * @memberOf _
13962      * @since 1.3.0
13963      * @category Object
13964      * @param {Object} object The object to iterate over.
13965      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13966      * @param {*} [accumulator] The custom accumulator value.
13967      * @returns {*} Returns the accumulated value.
13968      * @example
13969      *
13970      * _.transform([2, 3, 4], function(result, n) {
13971      *   result.push(n *= n);
13972      *   return n % 2 == 0;
13973      * }, []);
13974      * // => [4, 9]
13975      *
13976      * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
13977      *   (result[value] || (result[value] = [])).push(key);
13978      * }, {});
13979      * // => { '1': ['a', 'c'], '2': ['b'] }
13980      */
13981     function transform(object, iteratee, accumulator) {
13982       var isArr = isArray(object),
13983         isArrLike = isArr || isBuffer(object) || isTypedArray(object);
13984
13985       iteratee = getIteratee(iteratee, 4);
13986       if (accumulator == null) {
13987         var Ctor = object && object.constructor;
13988         if (isArrLike) {
13989           accumulator = isArr ? new Ctor : [];
13990         } else if (isObject(object)) {
13991           accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
13992         } else {
13993           accumulator = {};
13994         }
13995       }
13996       (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
13997         return iteratee(accumulator, value, index, object);
13998       });
13999       return accumulator;
14000     }
14001
14002     /**
14003      * Removes the property at `path` of `object`.
14004      *
14005      * **Note:** This method mutates `object`.
14006      *
14007      * @static
14008      * @memberOf _
14009      * @since 4.0.0
14010      * @category Object
14011      * @param {Object} object The object to modify.
14012      * @param {Array|string} path The path of the property to unset.
14013      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
14014      * @example
14015      *
14016      * var object = { 'a': [{ 'b': { 'c': 7 } }] };
14017      * _.unset(object, 'a[0].b.c');
14018      * // => true
14019      *
14020      * console.log(object);
14021      * // => { 'a': [{ 'b': {} }] };
14022      *
14023      * _.unset(object, ['a', '0', 'b', 'c']);
14024      * // => true
14025      *
14026      * console.log(object);
14027      * // => { 'a': [{ 'b': {} }] };
14028      */
14029     function unset(object, path) {
14030       return object == null ? true : baseUnset(object, path);
14031     }
14032
14033     /**
14034      * This method is like `_.set` except that accepts `updater` to produce the
14035      * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
14036      * is invoked with one argument: (value).
14037      *
14038      * **Note:** This method mutates `object`.
14039      *
14040      * @static
14041      * @memberOf _
14042      * @since 4.6.0
14043      * @category Object
14044      * @param {Object} object The object to modify.
14045      * @param {Array|string} path The path of the property to set.
14046      * @param {Function} updater The function to produce the updated value.
14047      * @returns {Object} Returns `object`.
14048      * @example
14049      *
14050      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
14051      *
14052      * _.update(object, 'a[0].b.c', function(n) { return n * n; });
14053      * console.log(object.a[0].b.c);
14054      * // => 9
14055      *
14056      * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
14057      * console.log(object.x[0].y.z);
14058      * // => 0
14059      */
14060     function update(object, path, updater) {
14061       return object == null ? object : baseUpdate(object, path, castFunction(updater));
14062     }
14063
14064     /**
14065      * This method is like `_.update` except that it accepts `customizer` which is
14066      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
14067      * path creation is handled by the method instead. The `customizer` is invoked
14068      * with three arguments: (nsValue, key, nsObject).
14069      *
14070      * **Note:** This method mutates `object`.
14071      *
14072      * @static
14073      * @memberOf _
14074      * @since 4.6.0
14075      * @category Object
14076      * @param {Object} object The object to modify.
14077      * @param {Array|string} path The path of the property to set.
14078      * @param {Function} updater The function to produce the updated value.
14079      * @param {Function} [customizer] The function to customize assigned values.
14080      * @returns {Object} Returns `object`.
14081      * @example
14082      *
14083      * var object = {};
14084      *
14085      * _.updateWith(object, '[0][1]', _.constant('a'), Object);
14086      * // => { '0': { '1': 'a' } }
14087      */
14088     function updateWith(object, path, updater, customizer) {
14089       customizer = typeof customizer == 'function' ? customizer : undefined;
14090       return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
14091     }
14092
14093     /**
14094      * Creates an array of the own enumerable string keyed property values of `object`.
14095      *
14096      * **Note:** Non-object values are coerced to objects.
14097      *
14098      * @static
14099      * @since 0.1.0
14100      * @memberOf _
14101      * @category Object
14102      * @param {Object} object The object to query.
14103      * @returns {Array} Returns the array of property values.
14104      * @example
14105      *
14106      * function Foo() {
14107      *   this.a = 1;
14108      *   this.b = 2;
14109      * }
14110      *
14111      * Foo.prototype.c = 3;
14112      *
14113      * _.values(new Foo);
14114      * // => [1, 2] (iteration order is not guaranteed)
14115      *
14116      * _.values('hi');
14117      * // => ['h', 'i']
14118      */
14119     function values(object) {
14120       return object == null ? [] : baseValues(object, keys(object));
14121     }
14122
14123     /**
14124      * Creates an array of the own and inherited enumerable string keyed property
14125      * values of `object`.
14126      *
14127      * **Note:** Non-object values are coerced to objects.
14128      *
14129      * @static
14130      * @memberOf _
14131      * @since 3.0.0
14132      * @category Object
14133      * @param {Object} object The object to query.
14134      * @returns {Array} Returns the array of property values.
14135      * @example
14136      *
14137      * function Foo() {
14138      *   this.a = 1;
14139      *   this.b = 2;
14140      * }
14141      *
14142      * Foo.prototype.c = 3;
14143      *
14144      * _.valuesIn(new Foo);
14145      * // => [1, 2, 3] (iteration order is not guaranteed)
14146      */
14147     function valuesIn(object) {
14148       return object == null ? [] : baseValues(object, keysIn(object));
14149     }
14150
14151     /*------------------------------------------------------------------------*/
14152
14153     /**
14154      * Clamps `number` within the inclusive `lower` and `upper` bounds.
14155      *
14156      * @static
14157      * @memberOf _
14158      * @since 4.0.0
14159      * @category Number
14160      * @param {number} number The number to clamp.
14161      * @param {number} [lower] The lower bound.
14162      * @param {number} upper The upper bound.
14163      * @returns {number} Returns the clamped number.
14164      * @example
14165      *
14166      * _.clamp(-10, -5, 5);
14167      * // => -5
14168      *
14169      * _.clamp(10, -5, 5);
14170      * // => 5
14171      */
14172     function clamp(number, lower, upper) {
14173       if (upper === undefined) {
14174         upper = lower;
14175         lower = undefined;
14176       }
14177       if (upper !== undefined) {
14178         upper = toNumber(upper);
14179         upper = upper === upper ? upper : 0;
14180       }
14181       if (lower !== undefined) {
14182         lower = toNumber(lower);
14183         lower = lower === lower ? lower : 0;
14184       }
14185       return baseClamp(toNumber(number), lower, upper);
14186     }
14187
14188     /**
14189      * Checks if `n` is between `start` and up to, but not including, `end`. If
14190      * `end` is not specified, it's set to `start` with `start` then set to `0`.
14191      * If `start` is greater than `end` the params are swapped to support
14192      * negative ranges.
14193      *
14194      * @static
14195      * @memberOf _
14196      * @since 3.3.0
14197      * @category Number
14198      * @param {number} number The number to check.
14199      * @param {number} [start=0] The start of the range.
14200      * @param {number} end The end of the range.
14201      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
14202      * @see _.range, _.rangeRight
14203      * @example
14204      *
14205      * _.inRange(3, 2, 4);
14206      * // => true
14207      *
14208      * _.inRange(4, 8);
14209      * // => true
14210      *
14211      * _.inRange(4, 2);
14212      * // => false
14213      *
14214      * _.inRange(2, 2);
14215      * // => false
14216      *
14217      * _.inRange(1.2, 2);
14218      * // => true
14219      *
14220      * _.inRange(5.2, 4);
14221      * // => false
14222      *
14223      * _.inRange(-3, -2, -6);
14224      * // => true
14225      */
14226     function inRange(number, start, end) {
14227       start = toFinite(start);
14228       if (end === undefined) {
14229         end = start;
14230         start = 0;
14231       } else {
14232         end = toFinite(end);
14233       }
14234       number = toNumber(number);
14235       return baseInRange(number, start, end);
14236     }
14237
14238     /**
14239      * Produces a random number between the inclusive `lower` and `upper` bounds.
14240      * If only one argument is provided a number between `0` and the given number
14241      * is returned. If `floating` is `true`, or either `lower` or `upper` are
14242      * floats, a floating-point number is returned instead of an integer.
14243      *
14244      * **Note:** JavaScript follows the IEEE-754 standard for resolving
14245      * floating-point values which can produce unexpected results.
14246      *
14247      * @static
14248      * @memberOf _
14249      * @since 0.7.0
14250      * @category Number
14251      * @param {number} [lower=0] The lower bound.
14252      * @param {number} [upper=1] The upper bound.
14253      * @param {boolean} [floating] Specify returning a floating-point number.
14254      * @returns {number} Returns the random number.
14255      * @example
14256      *
14257      * _.random(0, 5);
14258      * // => an integer between 0 and 5
14259      *
14260      * _.random(5);
14261      * // => also an integer between 0 and 5
14262      *
14263      * _.random(5, true);
14264      * // => a floating-point number between 0 and 5
14265      *
14266      * _.random(1.2, 5.2);
14267      * // => a floating-point number between 1.2 and 5.2
14268      */
14269     function random(lower, upper, floating) {
14270       if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
14271         upper = floating = undefined;
14272       }
14273       if (floating === undefined) {
14274         if (typeof upper == 'boolean') {
14275           floating = upper;
14276           upper = undefined;
14277         } else if (typeof lower == 'boolean') {
14278           floating = lower;
14279           lower = undefined;
14280         }
14281       }
14282       if (lower === undefined && upper === undefined) {
14283         lower = 0;
14284         upper = 1;
14285       } else {
14286         lower = toFinite(lower);
14287         if (upper === undefined) {
14288           upper = lower;
14289           lower = 0;
14290         } else {
14291           upper = toFinite(upper);
14292         }
14293       }
14294       if (lower > upper) {
14295         var temp = lower;
14296         lower = upper;
14297         upper = temp;
14298       }
14299       if (floating || lower % 1 || upper % 1) {
14300         var rand = nativeRandom();
14301         return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14302       }
14303       return baseRandom(lower, upper);
14304     }
14305
14306     /*------------------------------------------------------------------------*/
14307
14308     /**
14309      * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14310      *
14311      * @static
14312      * @memberOf _
14313      * @since 3.0.0
14314      * @category String
14315      * @param {string} [string=''] The string to convert.
14316      * @returns {string} Returns the camel cased string.
14317      * @example
14318      *
14319      * _.camelCase('Foo Bar');
14320      * // => 'fooBar'
14321      *
14322      * _.camelCase('--foo-bar--');
14323      * // => 'fooBar'
14324      *
14325      * _.camelCase('__FOO_BAR__');
14326      * // => 'fooBar'
14327      */
14328     var camelCase = createCompounder(function(result, word, index) {
14329       word = word.toLowerCase();
14330       return result + (index ? capitalize(word) : word);
14331     });
14332
14333     /**
14334      * Converts the first character of `string` to upper case and the remaining
14335      * to lower case.
14336      *
14337      * @static
14338      * @memberOf _
14339      * @since 3.0.0
14340      * @category String
14341      * @param {string} [string=''] The string to capitalize.
14342      * @returns {string} Returns the capitalized string.
14343      * @example
14344      *
14345      * _.capitalize('FRED');
14346      * // => 'Fred'
14347      */
14348     function capitalize(string) {
14349       return upperFirst(toString(string).toLowerCase());
14350     }
14351
14352     /**
14353      * Deburrs `string` by converting
14354      * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
14355      * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
14356      * letters to basic Latin letters and removing
14357      * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
14358      *
14359      * @static
14360      * @memberOf _
14361      * @since 3.0.0
14362      * @category String
14363      * @param {string} [string=''] The string to deburr.
14364      * @returns {string} Returns the deburred string.
14365      * @example
14366      *
14367      * _.deburr('déjà vu');
14368      * // => 'deja vu'
14369      */
14370     function deburr(string) {
14371       string = toString(string);
14372       return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14373     }
14374
14375     /**
14376      * Checks if `string` ends with the given target string.
14377      *
14378      * @static
14379      * @memberOf _
14380      * @since 3.0.0
14381      * @category String
14382      * @param {string} [string=''] The string to inspect.
14383      * @param {string} [target] The string to search for.
14384      * @param {number} [position=string.length] The position to search up to.
14385      * @returns {boolean} Returns `true` if `string` ends with `target`,
14386      *  else `false`.
14387      * @example
14388      *
14389      * _.endsWith('abc', 'c');
14390      * // => true
14391      *
14392      * _.endsWith('abc', 'b');
14393      * // => false
14394      *
14395      * _.endsWith('abc', 'b', 2);
14396      * // => true
14397      */
14398     function endsWith(string, target, position) {
14399       string = toString(string);
14400       target = baseToString(target);
14401
14402       var length = string.length;
14403       position = position === undefined ?
14404         length :
14405         baseClamp(toInteger(position), 0, length);
14406
14407       var end = position;
14408       position -= target.length;
14409       return position >= 0 && string.slice(position, end) == target;
14410     }
14411
14412     /**
14413      * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14414      * corresponding HTML entities.
14415      *
14416      * **Note:** No other characters are escaped. To escape additional
14417      * characters use a third-party library like [_he_](https://mths.be/he).
14418      *
14419      * Though the ">" character is escaped for symmetry, characters like
14420      * ">" and "/" don't need escaping in HTML and have no special meaning
14421      * unless they're part of a tag or unquoted attribute value. See
14422      * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
14423      * (under "semi-related fun fact") for more details.
14424      *
14425      * When working with HTML you should always
14426      * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14427      * XSS vectors.
14428      *
14429      * @static
14430      * @since 0.1.0
14431      * @memberOf _
14432      * @category String
14433      * @param {string} [string=''] The string to escape.
14434      * @returns {string} Returns the escaped string.
14435      * @example
14436      *
14437      * _.escape('fred, barney, & pebbles');
14438      * // => 'fred, barney, &amp; pebbles'
14439      */
14440     function escape(string) {
14441       string = toString(string);
14442       return (string && reHasUnescapedHtml.test(string)) ?
14443         string.replace(reUnescapedHtml, escapeHtmlChar) :
14444         string;
14445     }
14446
14447     /**
14448      * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14449      * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14450      *
14451      * @static
14452      * @memberOf _
14453      * @since 3.0.0
14454      * @category String
14455      * @param {string} [string=''] The string to escape.
14456      * @returns {string} Returns the escaped string.
14457      * @example
14458      *
14459      * _.escapeRegExp('[lodash](https://lodash.com/)');
14460      * // => '\[lodash\]\(https://lodash\.com/\)'
14461      */
14462     function escapeRegExp(string) {
14463       string = toString(string);
14464       return (string && reHasRegExpChar.test(string)) ?
14465         string.replace(reRegExpChar, '\\$&') :
14466         string;
14467     }
14468
14469     /**
14470      * Converts `string` to
14471      * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14472      *
14473      * @static
14474      * @memberOf _
14475      * @since 3.0.0
14476      * @category String
14477      * @param {string} [string=''] The string to convert.
14478      * @returns {string} Returns the kebab cased string.
14479      * @example
14480      *
14481      * _.kebabCase('Foo Bar');
14482      * // => 'foo-bar'
14483      *
14484      * _.kebabCase('fooBar');
14485      * // => 'foo-bar'
14486      *
14487      * _.kebabCase('__FOO_BAR__');
14488      * // => 'foo-bar'
14489      */
14490     var kebabCase = createCompounder(function(result, word, index) {
14491       return result + (index ? '-' : '') + word.toLowerCase();
14492     });
14493
14494     /**
14495      * Converts `string`, as space separated words, to lower case.
14496      *
14497      * @static
14498      * @memberOf _
14499      * @since 4.0.0
14500      * @category String
14501      * @param {string} [string=''] The string to convert.
14502      * @returns {string} Returns the lower cased string.
14503      * @example
14504      *
14505      * _.lowerCase('--Foo-Bar--');
14506      * // => 'foo bar'
14507      *
14508      * _.lowerCase('fooBar');
14509      * // => 'foo bar'
14510      *
14511      * _.lowerCase('__FOO_BAR__');
14512      * // => 'foo bar'
14513      */
14514     var lowerCase = createCompounder(function(result, word, index) {
14515       return result + (index ? ' ' : '') + word.toLowerCase();
14516     });
14517
14518     /**
14519      * Converts the first character of `string` to lower case.
14520      *
14521      * @static
14522      * @memberOf _
14523      * @since 4.0.0
14524      * @category String
14525      * @param {string} [string=''] The string to convert.
14526      * @returns {string} Returns the converted string.
14527      * @example
14528      *
14529      * _.lowerFirst('Fred');
14530      * // => 'fred'
14531      *
14532      * _.lowerFirst('FRED');
14533      * // => 'fRED'
14534      */
14535     var lowerFirst = createCaseFirst('toLowerCase');
14536
14537     /**
14538      * Pads `string` on the left and right sides if it's shorter than `length`.
14539      * Padding characters are truncated if they can't be evenly divided by `length`.
14540      *
14541      * @static
14542      * @memberOf _
14543      * @since 3.0.0
14544      * @category String
14545      * @param {string} [string=''] The string to pad.
14546      * @param {number} [length=0] The padding length.
14547      * @param {string} [chars=' '] The string used as padding.
14548      * @returns {string} Returns the padded string.
14549      * @example
14550      *
14551      * _.pad('abc', 8);
14552      * // => '  abc   '
14553      *
14554      * _.pad('abc', 8, '_-');
14555      * // => '_-abc_-_'
14556      *
14557      * _.pad('abc', 3);
14558      * // => 'abc'
14559      */
14560     function pad(string, length, chars) {
14561       string = toString(string);
14562       length = toInteger(length);
14563
14564       var strLength = length ? stringSize(string) : 0;
14565       if (!length || strLength >= length) {
14566         return string;
14567       }
14568       var mid = (length - strLength) / 2;
14569       return (
14570         createPadding(nativeFloor(mid), chars) +
14571         string +
14572         createPadding(nativeCeil(mid), chars)
14573       );
14574     }
14575
14576     /**
14577      * Pads `string` on the right side if it's shorter than `length`. Padding
14578      * characters are truncated if they exceed `length`.
14579      *
14580      * @static
14581      * @memberOf _
14582      * @since 4.0.0
14583      * @category String
14584      * @param {string} [string=''] The string to pad.
14585      * @param {number} [length=0] The padding length.
14586      * @param {string} [chars=' '] The string used as padding.
14587      * @returns {string} Returns the padded string.
14588      * @example
14589      *
14590      * _.padEnd('abc', 6);
14591      * // => 'abc   '
14592      *
14593      * _.padEnd('abc', 6, '_-');
14594      * // => 'abc_-_'
14595      *
14596      * _.padEnd('abc', 3);
14597      * // => 'abc'
14598      */
14599     function padEnd(string, length, chars) {
14600       string = toString(string);
14601       length = toInteger(length);
14602
14603       var strLength = length ? stringSize(string) : 0;
14604       return (length && strLength < length) ?
14605         (string + createPadding(length - strLength, chars)) :
14606         string;
14607     }
14608
14609     /**
14610      * Pads `string` on the left side if it's shorter than `length`. Padding
14611      * characters are truncated if they exceed `length`.
14612      *
14613      * @static
14614      * @memberOf _
14615      * @since 4.0.0
14616      * @category String
14617      * @param {string} [string=''] The string to pad.
14618      * @param {number} [length=0] The padding length.
14619      * @param {string} [chars=' '] The string used as padding.
14620      * @returns {string} Returns the padded string.
14621      * @example
14622      *
14623      * _.padStart('abc', 6);
14624      * // => '   abc'
14625      *
14626      * _.padStart('abc', 6, '_-');
14627      * // => '_-_abc'
14628      *
14629      * _.padStart('abc', 3);
14630      * // => 'abc'
14631      */
14632     function padStart(string, length, chars) {
14633       string = toString(string);
14634       length = toInteger(length);
14635
14636       var strLength = length ? stringSize(string) : 0;
14637       return (length && strLength < length) ?
14638         (createPadding(length - strLength, chars) + string) :
14639         string;
14640     }
14641
14642     /**
14643      * Converts `string` to an integer of the specified radix. If `radix` is
14644      * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
14645      * hexadecimal, in which case a `radix` of `16` is used.
14646      *
14647      * **Note:** This method aligns with the
14648      * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
14649      *
14650      * @static
14651      * @memberOf _
14652      * @since 1.1.0
14653      * @category String
14654      * @param {string} string The string to convert.
14655      * @param {number} [radix=10] The radix to interpret `value` by.
14656      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14657      * @returns {number} Returns the converted integer.
14658      * @example
14659      *
14660      * _.parseInt('08');
14661      * // => 8
14662      *
14663      * _.map(['6', '08', '10'], _.parseInt);
14664      * // => [6, 8, 10]
14665      */
14666     function parseInt(string, radix, guard) {
14667       if (guard || radix == null) {
14668         radix = 0;
14669       } else if (radix) {
14670         radix = +radix;
14671       }
14672       return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14673     }
14674
14675     /**
14676      * Repeats the given string `n` times.
14677      *
14678      * @static
14679      * @memberOf _
14680      * @since 3.0.0
14681      * @category String
14682      * @param {string} [string=''] The string to repeat.
14683      * @param {number} [n=1] The number of times to repeat the string.
14684      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14685      * @returns {string} Returns the repeated string.
14686      * @example
14687      *
14688      * _.repeat('*', 3);
14689      * // => '***'
14690      *
14691      * _.repeat('abc', 2);
14692      * // => 'abcabc'
14693      *
14694      * _.repeat('abc', 0);
14695      * // => ''
14696      */
14697     function repeat(string, n, guard) {
14698       if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
14699         n = 1;
14700       } else {
14701         n = toInteger(n);
14702       }
14703       return baseRepeat(toString(string), n);
14704     }
14705
14706     /**
14707      * Replaces matches for `pattern` in `string` with `replacement`.
14708      *
14709      * **Note:** This method is based on
14710      * [`String#replace`](https://mdn.io/String/replace).
14711      *
14712      * @static
14713      * @memberOf _
14714      * @since 4.0.0
14715      * @category String
14716      * @param {string} [string=''] The string to modify.
14717      * @param {RegExp|string} pattern The pattern to replace.
14718      * @param {Function|string} replacement The match replacement.
14719      * @returns {string} Returns the modified string.
14720      * @example
14721      *
14722      * _.replace('Hi Fred', 'Fred', 'Barney');
14723      * // => 'Hi Barney'
14724      */
14725     function replace() {
14726       var args = arguments,
14727         string = toString(args[0]);
14728
14729       return args.length < 3 ? string : string.replace(args[1], args[2]);
14730     }
14731
14732     /**
14733      * Converts `string` to
14734      * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14735      *
14736      * @static
14737      * @memberOf _
14738      * @since 3.0.0
14739      * @category String
14740      * @param {string} [string=''] The string to convert.
14741      * @returns {string} Returns the snake cased string.
14742      * @example
14743      *
14744      * _.snakeCase('Foo Bar');
14745      * // => 'foo_bar'
14746      *
14747      * _.snakeCase('fooBar');
14748      * // => 'foo_bar'
14749      *
14750      * _.snakeCase('--FOO-BAR--');
14751      * // => 'foo_bar'
14752      */
14753     var snakeCase = createCompounder(function(result, word, index) {
14754       return result + (index ? '_' : '') + word.toLowerCase();
14755     });
14756
14757     /**
14758      * Splits `string` by `separator`.
14759      *
14760      * **Note:** This method is based on
14761      * [`String#split`](https://mdn.io/String/split).
14762      *
14763      * @static
14764      * @memberOf _
14765      * @since 4.0.0
14766      * @category String
14767      * @param {string} [string=''] The string to split.
14768      * @param {RegExp|string} separator The separator pattern to split by.
14769      * @param {number} [limit] The length to truncate results to.
14770      * @returns {Array} Returns the string segments.
14771      * @example
14772      *
14773      * _.split('a-b-c', '-', 2);
14774      * // => ['a', 'b']
14775      */
14776     function split(string, separator, limit) {
14777       if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14778         separator = limit = undefined;
14779       }
14780       limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
14781       if (!limit) {
14782         return [];
14783       }
14784       string = toString(string);
14785       if (string && (
14786           typeof separator == 'string' ||
14787           (separator != null && !isRegExp(separator))
14788         )) {
14789         separator = baseToString(separator);
14790         if (!separator && hasUnicode(string)) {
14791           return castSlice(stringToArray(string), 0, limit);
14792         }
14793       }
14794       return string.split(separator, limit);
14795     }
14796
14797     /**
14798      * Converts `string` to
14799      * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14800      *
14801      * @static
14802      * @memberOf _
14803      * @since 3.1.0
14804      * @category String
14805      * @param {string} [string=''] The string to convert.
14806      * @returns {string} Returns the start cased string.
14807      * @example
14808      *
14809      * _.startCase('--foo-bar--');
14810      * // => 'Foo Bar'
14811      *
14812      * _.startCase('fooBar');
14813      * // => 'Foo Bar'
14814      *
14815      * _.startCase('__FOO_BAR__');
14816      * // => 'FOO BAR'
14817      */
14818     var startCase = createCompounder(function(result, word, index) {
14819       return result + (index ? ' ' : '') + upperFirst(word);
14820     });
14821
14822     /**
14823      * Checks if `string` starts with the given target string.
14824      *
14825      * @static
14826      * @memberOf _
14827      * @since 3.0.0
14828      * @category String
14829      * @param {string} [string=''] The string to inspect.
14830      * @param {string} [target] The string to search for.
14831      * @param {number} [position=0] The position to search from.
14832      * @returns {boolean} Returns `true` if `string` starts with `target`,
14833      *  else `false`.
14834      * @example
14835      *
14836      * _.startsWith('abc', 'a');
14837      * // => true
14838      *
14839      * _.startsWith('abc', 'b');
14840      * // => false
14841      *
14842      * _.startsWith('abc', 'b', 1);
14843      * // => true
14844      */
14845     function startsWith(string, target, position) {
14846       string = toString(string);
14847       position = position == null ?
14848         0 :
14849         baseClamp(toInteger(position), 0, string.length);
14850
14851       target = baseToString(target);
14852       return string.slice(position, position + target.length) == target;
14853     }
14854
14855     /**
14856      * Creates a compiled template function that can interpolate data properties
14857      * in "interpolate" delimiters, HTML-escape interpolated data properties in
14858      * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
14859      * properties may be accessed as free variables in the template. If a setting
14860      * object is given, it takes precedence over `_.templateSettings` values.
14861      *
14862      * **Note:** In the development build `_.template` utilizes
14863      * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
14864      * for easier debugging.
14865      *
14866      * For more information on precompiling templates see
14867      * [lodash's custom builds documentation](https://lodash.com/custom-builds).
14868      *
14869      * For more information on Chrome extension sandboxes see
14870      * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
14871      *
14872      * @static
14873      * @since 0.1.0
14874      * @memberOf _
14875      * @category String
14876      * @param {string} [string=''] The template string.
14877      * @param {Object} [options={}] The options object.
14878      * @param {RegExp} [options.escape=_.templateSettings.escape]
14879      *  The HTML "escape" delimiter.
14880      * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
14881      *  The "evaluate" delimiter.
14882      * @param {Object} [options.imports=_.templateSettings.imports]
14883      *  An object to import into the template as free variables.
14884      * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
14885      *  The "interpolate" delimiter.
14886      * @param {string} [options.sourceURL='lodash.templateSources[n]']
14887      *  The sourceURL of the compiled template.
14888      * @param {string} [options.variable='obj']
14889      *  The data object variable name.
14890      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14891      * @returns {Function} Returns the compiled template function.
14892      * @example
14893      *
14894      * // Use the "interpolate" delimiter to create a compiled template.
14895      * var compiled = _.template('hello <%= user %>!');
14896      * compiled({ 'user': 'fred' });
14897      * // => 'hello fred!'
14898      *
14899      * // Use the HTML "escape" delimiter to escape data property values.
14900      * var compiled = _.template('<b><%- value %></b>');
14901      * compiled({ 'value': '<script>' });
14902      * // => '<b>&lt;script&gt;</b>'
14903      *
14904      * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
14905      * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
14906      * compiled({ 'users': ['fred', 'barney'] });
14907      * // => '<li>fred</li><li>barney</li>'
14908      *
14909      * // Use the internal `print` function in "evaluate" delimiters.
14910      * var compiled = _.template('<% print("hello " + user); %>!');
14911      * compiled({ 'user': 'barney' });
14912      * // => 'hello barney!'
14913      *
14914      * // Use the ES template literal delimiter as an "interpolate" delimiter.
14915      * // Disable support by replacing the "interpolate" delimiter.
14916      * var compiled = _.template('hello ${ user }!');
14917      * compiled({ 'user': 'pebbles' });
14918      * // => 'hello pebbles!'
14919      *
14920      * // Use backslashes to treat delimiters as plain text.
14921      * var compiled = _.template('<%= "\\<%- value %\\>" %>');
14922      * compiled({ 'value': 'ignored' });
14923      * // => '<%- value %>'
14924      *
14925      * // Use the `imports` option to import `jQuery` as `jq`.
14926      * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
14927      * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
14928      * compiled({ 'users': ['fred', 'barney'] });
14929      * // => '<li>fred</li><li>barney</li>'
14930      *
14931      * // Use the `sourceURL` option to specify a custom sourceURL for the template.
14932      * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
14933      * compiled(data);
14934      * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
14935      *
14936      * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
14937      * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
14938      * compiled.source;
14939      * // => function(data) {
14940      * //   var __t, __p = '';
14941      * //   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
14942      * //   return __p;
14943      * // }
14944      *
14945      * // Use custom template delimiters.
14946      * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
14947      * var compiled = _.template('hello {{ user }}!');
14948      * compiled({ 'user': 'mustache' });
14949      * // => 'hello mustache!'
14950      *
14951      * // Use the `source` property to inline compiled templates for meaningful
14952      * // line numbers in error messages and stack traces.
14953      * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
14954      *   var JST = {\
14955      *     "main": ' + _.template(mainText).source + '\
14956      *   };\
14957      * ');
14958      */
14959     function template(string, options, guard) {
14960       // Based on John Resig's `tmpl` implementation
14961       // (http://ejohn.org/blog/javascript-micro-templating/)
14962       // and Laura Doktorova's doT.js (https://github.com/olado/doT).
14963       var settings = lodash.templateSettings;
14964
14965       if (guard && isIterateeCall(string, options, guard)) {
14966         options = undefined;
14967       }
14968       string = toString(string);
14969       options = assignInWith({}, options, settings, customDefaultsAssignIn);
14970
14971       var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
14972         importsKeys = keys(imports),
14973         importsValues = baseValues(imports, importsKeys);
14974
14975       var isEscaping,
14976         isEvaluating,
14977         index = 0,
14978         interpolate = options.interpolate || reNoMatch,
14979         source = "__p += '";
14980
14981       // Compile the regexp to match each delimiter.
14982       var reDelimiters = RegExp(
14983         (options.escape || reNoMatch).source + '|' +
14984         interpolate.source + '|' +
14985         (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
14986         (options.evaluate || reNoMatch).source + '|$', 'g');
14987
14988       // Use a sourceURL for easier debugging.
14989       // The sourceURL gets injected into the source that's eval-ed, so be careful
14990       // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
14991       // and escape the comment, thus injecting code that gets evaled.
14992       var sourceURL = '//# sourceURL=' +
14993         (hasOwnProperty.call(options, 'sourceURL') ?
14994           (options.sourceURL + '').replace(/\s/g, ' ') :
14995           ('lodash.templateSources[' + (++templateCounter) + ']')
14996         ) + '\n';
14997
14998       string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
14999         interpolateValue || (interpolateValue = esTemplateValue);
15000
15001         // Escape characters that can't be included in string literals.
15002         source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
15003
15004         // Replace delimiters with snippets.
15005         if (escapeValue) {
15006           isEscaping = true;
15007           source += "' +\n__e(" + escapeValue + ") +\n'";
15008         }
15009         if (evaluateValue) {
15010           isEvaluating = true;
15011           source += "';\n" + evaluateValue + ";\n__p += '";
15012         }
15013         if (interpolateValue) {
15014           source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
15015         }
15016         index = offset + match.length;
15017
15018         // The JS engine embedded in Adobe products needs `match` returned in
15019         // order to produce the correct `offset` value.
15020         return match;
15021       });
15022
15023       source += "';\n";
15024
15025       // If `variable` is not specified wrap a with-statement around the generated
15026       // code to add the data object to the top of the scope chain.
15027       var variable = hasOwnProperty.call(options, 'variable') && options.variable;
15028       if (!variable) {
15029         source = 'with (obj) {\n' + source + '\n}\n';
15030       }
15031       // Cleanup code by stripping empty strings.
15032       source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
15033         .replace(reEmptyStringMiddle, '$1')
15034         .replace(reEmptyStringTrailing, '$1;');
15035
15036       // Frame code as the function body.
15037       source = 'function(' + (variable || 'obj') + ') {\n' +
15038         (variable ?
15039           '' :
15040           'obj || (obj = {});\n'
15041         ) +
15042         "var __t, __p = ''" +
15043         (isEscaping ?
15044           ', __e = _.escape' :
15045           ''
15046         ) +
15047         (isEvaluating ?
15048           ', __j = Array.prototype.join;\n' +
15049           "function print() { __p += __j.call(arguments, '') }\n" :
15050           ';\n'
15051         ) +
15052         source +
15053         'return __p\n}';
15054
15055       var result = attempt(function() {
15056         return Function(importsKeys, sourceURL + 'return ' + source)
15057           .apply(undefined, importsValues);
15058       });
15059
15060       // Provide the compiled function's source by its `toString` method or
15061       // the `source` property as a convenience for inlining compiled templates.
15062       result.source = source;
15063       if (isError(result)) {
15064         throw result;
15065       }
15066       return result;
15067     }
15068
15069     /**
15070      * Converts `string`, as a whole, to lower case just like
15071      * [String#toLowerCase](https://mdn.io/toLowerCase).
15072      *
15073      * @static
15074      * @memberOf _
15075      * @since 4.0.0
15076      * @category String
15077      * @param {string} [string=''] The string to convert.
15078      * @returns {string} Returns the lower cased string.
15079      * @example
15080      *
15081      * _.toLower('--Foo-Bar--');
15082      * // => '--foo-bar--'
15083      *
15084      * _.toLower('fooBar');
15085      * // => 'foobar'
15086      *
15087      * _.toLower('__FOO_BAR__');
15088      * // => '__foo_bar__'
15089      */
15090     function toLower(value) {
15091       return toString(value).toLowerCase();
15092     }
15093
15094     /**
15095      * Converts `string`, as a whole, to upper case just like
15096      * [String#toUpperCase](https://mdn.io/toUpperCase).
15097      *
15098      * @static
15099      * @memberOf _
15100      * @since 4.0.0
15101      * @category String
15102      * @param {string} [string=''] The string to convert.
15103      * @returns {string} Returns the upper cased string.
15104      * @example
15105      *
15106      * _.toUpper('--foo-bar--');
15107      * // => '--FOO-BAR--'
15108      *
15109      * _.toUpper('fooBar');
15110      * // => 'FOOBAR'
15111      *
15112      * _.toUpper('__foo_bar__');
15113      * // => '__FOO_BAR__'
15114      */
15115     function toUpper(value) {
15116       return toString(value).toUpperCase();
15117     }
15118
15119     /**
15120      * Removes leading and trailing whitespace or specified characters from `string`.
15121      *
15122      * @static
15123      * @memberOf _
15124      * @since 3.0.0
15125      * @category String
15126      * @param {string} [string=''] The string to trim.
15127      * @param {string} [chars=whitespace] The characters to trim.
15128      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15129      * @returns {string} Returns the trimmed string.
15130      * @example
15131      *
15132      * _.trim('  abc  ');
15133      * // => 'abc'
15134      *
15135      * _.trim('-_-abc-_-', '_-');
15136      * // => 'abc'
15137      *
15138      * _.map(['  foo  ', '  bar  '], _.trim);
15139      * // => ['foo', 'bar']
15140      */
15141     function trim(string, chars, guard) {
15142       string = toString(string);
15143       if (string && (guard || chars === undefined)) {
15144         return string.replace(reTrim, '');
15145       }
15146       if (!string || !(chars = baseToString(chars))) {
15147         return string;
15148       }
15149       var strSymbols = stringToArray(string),
15150         chrSymbols = stringToArray(chars),
15151         start = charsStartIndex(strSymbols, chrSymbols),
15152         end = charsEndIndex(strSymbols, chrSymbols) + 1;
15153
15154       return castSlice(strSymbols, start, end).join('');
15155     }
15156
15157     /**
15158      * Removes trailing whitespace or specified characters from `string`.
15159      *
15160      * @static
15161      * @memberOf _
15162      * @since 4.0.0
15163      * @category String
15164      * @param {string} [string=''] The string to trim.
15165      * @param {string} [chars=whitespace] The characters to trim.
15166      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15167      * @returns {string} Returns the trimmed string.
15168      * @example
15169      *
15170      * _.trimEnd('  abc  ');
15171      * // => '  abc'
15172      *
15173      * _.trimEnd('-_-abc-_-', '_-');
15174      * // => '-_-abc'
15175      */
15176     function trimEnd(string, chars, guard) {
15177       string = toString(string);
15178       if (string && (guard || chars === undefined)) {
15179         return string.replace(reTrimEnd, '');
15180       }
15181       if (!string || !(chars = baseToString(chars))) {
15182         return string;
15183       }
15184       var strSymbols = stringToArray(string),
15185         end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
15186
15187       return castSlice(strSymbols, 0, end).join('');
15188     }
15189
15190     /**
15191      * Removes leading whitespace or specified characters from `string`.
15192      *
15193      * @static
15194      * @memberOf _
15195      * @since 4.0.0
15196      * @category String
15197      * @param {string} [string=''] The string to trim.
15198      * @param {string} [chars=whitespace] The characters to trim.
15199      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15200      * @returns {string} Returns the trimmed string.
15201      * @example
15202      *
15203      * _.trimStart('  abc  ');
15204      * // => 'abc  '
15205      *
15206      * _.trimStart('-_-abc-_-', '_-');
15207      * // => 'abc-_-'
15208      */
15209     function trimStart(string, chars, guard) {
15210       string = toString(string);
15211       if (string && (guard || chars === undefined)) {
15212         return string.replace(reTrimStart, '');
15213       }
15214       if (!string || !(chars = baseToString(chars))) {
15215         return string;
15216       }
15217       var strSymbols = stringToArray(string),
15218         start = charsStartIndex(strSymbols, stringToArray(chars));
15219
15220       return castSlice(strSymbols, start).join('');
15221     }
15222
15223     /**
15224      * Truncates `string` if it's longer than the given maximum string length.
15225      * The last characters of the truncated string are replaced with the omission
15226      * string which defaults to "...".
15227      *
15228      * @static
15229      * @memberOf _
15230      * @since 4.0.0
15231      * @category String
15232      * @param {string} [string=''] The string to truncate.
15233      * @param {Object} [options={}] The options object.
15234      * @param {number} [options.length=30] The maximum string length.
15235      * @param {string} [options.omission='...'] The string to indicate text is omitted.
15236      * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
15237      * @returns {string} Returns the truncated string.
15238      * @example
15239      *
15240      * _.truncate('hi-diddly-ho there, neighborino');
15241      * // => 'hi-diddly-ho there, neighbo...'
15242      *
15243      * _.truncate('hi-diddly-ho there, neighborino', {
15244      *   'length': 24,
15245      *   'separator': ' '
15246      * });
15247      * // => 'hi-diddly-ho there,...'
15248      *
15249      * _.truncate('hi-diddly-ho there, neighborino', {
15250      *   'length': 24,
15251      *   'separator': /,? +/
15252      * });
15253      * // => 'hi-diddly-ho there...'
15254      *
15255      * _.truncate('hi-diddly-ho there, neighborino', {
15256      *   'omission': ' [...]'
15257      * });
15258      * // => 'hi-diddly-ho there, neig [...]'
15259      */
15260     function truncate(string, options) {
15261       var length = DEFAULT_TRUNC_LENGTH,
15262         omission = DEFAULT_TRUNC_OMISSION;
15263
15264       if (isObject(options)) {
15265         var separator = 'separator' in options ? options.separator : separator;
15266         length = 'length' in options ? toInteger(options.length) : length;
15267         omission = 'omission' in options ? baseToString(options.omission) : omission;
15268       }
15269       string = toString(string);
15270
15271       var strLength = string.length;
15272       if (hasUnicode(string)) {
15273         var strSymbols = stringToArray(string);
15274         strLength = strSymbols.length;
15275       }
15276       if (length >= strLength) {
15277         return string;
15278       }
15279       var end = length - stringSize(omission);
15280       if (end < 1) {
15281         return omission;
15282       }
15283       var result = strSymbols ?
15284         castSlice(strSymbols, 0, end).join('') :
15285         string.slice(0, end);
15286
15287       if (separator === undefined) {
15288         return result + omission;
15289       }
15290       if (strSymbols) {
15291         end += (result.length - end);
15292       }
15293       if (isRegExp(separator)) {
15294         if (string.slice(end).search(separator)) {
15295           var match,
15296             substring = result;
15297
15298           if (!separator.global) {
15299             separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15300           }
15301           separator.lastIndex = 0;
15302           while ((match = separator.exec(substring))) {
15303             var newEnd = match.index;
15304           }
15305           result = result.slice(0, newEnd === undefined ? end : newEnd);
15306         }
15307       } else if (string.indexOf(baseToString(separator), end) != end) {
15308         var index = result.lastIndexOf(separator);
15309         if (index > -1) {
15310           result = result.slice(0, index);
15311         }
15312       }
15313       return result + omission;
15314     }
15315
15316     /**
15317      * The inverse of `_.escape`; this method converts the HTML entities
15318      * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
15319      * their corresponding characters.
15320      *
15321      * **Note:** No other HTML entities are unescaped. To unescape additional
15322      * HTML entities use a third-party library like [_he_](https://mths.be/he).
15323      *
15324      * @static
15325      * @memberOf _
15326      * @since 0.6.0
15327      * @category String
15328      * @param {string} [string=''] The string to unescape.
15329      * @returns {string} Returns the unescaped string.
15330      * @example
15331      *
15332      * _.unescape('fred, barney, &amp; pebbles');
15333      * // => 'fred, barney, & pebbles'
15334      */
15335     function unescape(string) {
15336       string = toString(string);
15337       return (string && reHasEscapedHtml.test(string)) ?
15338         string.replace(reEscapedHtml, unescapeHtmlChar) :
15339         string;
15340     }
15341
15342     /**
15343      * Converts `string`, as space separated words, to upper case.
15344      *
15345      * @static
15346      * @memberOf _
15347      * @since 4.0.0
15348      * @category String
15349      * @param {string} [string=''] The string to convert.
15350      * @returns {string} Returns the upper cased string.
15351      * @example
15352      *
15353      * _.upperCase('--foo-bar');
15354      * // => 'FOO BAR'
15355      *
15356      * _.upperCase('fooBar');
15357      * // => 'FOO BAR'
15358      *
15359      * _.upperCase('__foo_bar__');
15360      * // => 'FOO BAR'
15361      */
15362     var upperCase = createCompounder(function(result, word, index) {
15363       return result + (index ? ' ' : '') + word.toUpperCase();
15364     });
15365
15366     /**
15367      * Converts the first character of `string` to upper case.
15368      *
15369      * @static
15370      * @memberOf _
15371      * @since 4.0.0
15372      * @category String
15373      * @param {string} [string=''] The string to convert.
15374      * @returns {string} Returns the converted string.
15375      * @example
15376      *
15377      * _.upperFirst('fred');
15378      * // => 'Fred'
15379      *
15380      * _.upperFirst('FRED');
15381      * // => 'FRED'
15382      */
15383     var upperFirst = createCaseFirst('toUpperCase');
15384
15385     /**
15386      * Splits `string` into an array of its words.
15387      *
15388      * @static
15389      * @memberOf _
15390      * @since 3.0.0
15391      * @category String
15392      * @param {string} [string=''] The string to inspect.
15393      * @param {RegExp|string} [pattern] The pattern to match words.
15394      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15395      * @returns {Array} Returns the words of `string`.
15396      * @example
15397      *
15398      * _.words('fred, barney, & pebbles');
15399      * // => ['fred', 'barney', 'pebbles']
15400      *
15401      * _.words('fred, barney, & pebbles', /[^, ]+/g);
15402      * // => ['fred', 'barney', '&', 'pebbles']
15403      */
15404     function words(string, pattern, guard) {
15405       string = toString(string);
15406       pattern = guard ? undefined : pattern;
15407
15408       if (pattern === undefined) {
15409         return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15410       }
15411       return string.match(pattern) || [];
15412     }
15413
15414     /*------------------------------------------------------------------------*/
15415
15416     /**
15417      * Attempts to invoke `func`, returning either the result or the caught error
15418      * object. Any additional arguments are provided to `func` when it's invoked.
15419      *
15420      * @static
15421      * @memberOf _
15422      * @since 3.0.0
15423      * @category Util
15424      * @param {Function} func The function to attempt.
15425      * @param {...*} [args] The arguments to invoke `func` with.
15426      * @returns {*} Returns the `func` result or error object.
15427      * @example
15428      *
15429      * // Avoid throwing errors for invalid selectors.
15430      * var elements = _.attempt(function(selector) {
15431      *   return document.querySelectorAll(selector);
15432      * }, '>_>');
15433      *
15434      * if (_.isError(elements)) {
15435      *   elements = [];
15436      * }
15437      */
15438     var attempt = baseRest(function(func, args) {
15439       try {
15440         return apply(func, undefined, args);
15441       } catch (e) {
15442         return isError(e) ? e : new Error(e);
15443       }
15444     });
15445
15446     /**
15447      * Binds methods of an object to the object itself, overwriting the existing
15448      * method.
15449      *
15450      * **Note:** This method doesn't set the "length" property of bound functions.
15451      *
15452      * @static
15453      * @since 0.1.0
15454      * @memberOf _
15455      * @category Util
15456      * @param {Object} object The object to bind and assign the bound methods to.
15457      * @param {...(string|string[])} methodNames The object method names to bind.
15458      * @returns {Object} Returns `object`.
15459      * @example
15460      *
15461      * var view = {
15462      *   'label': 'docs',
15463      *   'click': function() {
15464      *     console.log('clicked ' + this.label);
15465      *   }
15466      * };
15467      *
15468      * _.bindAll(view, ['click']);
15469      * jQuery(element).on('click', view.click);
15470      * // => Logs 'clicked docs' when clicked.
15471      */
15472     var bindAll = flatRest(function(object, methodNames) {
15473       arrayEach(methodNames, function(key) {
15474         key = toKey(key);
15475         baseAssignValue(object, key, bind(object[key], object));
15476       });
15477       return object;
15478     });
15479
15480     /**
15481      * Creates a function that iterates over `pairs` and invokes the corresponding
15482      * function of the first predicate to return truthy. The predicate-function
15483      * pairs are invoked with the `this` binding and arguments of the created
15484      * function.
15485      *
15486      * @static
15487      * @memberOf _
15488      * @since 4.0.0
15489      * @category Util
15490      * @param {Array} pairs The predicate-function pairs.
15491      * @returns {Function} Returns the new composite function.
15492      * @example
15493      *
15494      * var func = _.cond([
15495      *   [_.matches({ 'a': 1 }),           _.constant('matches A')],
15496      *   [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15497      *   [_.stubTrue,                      _.constant('no match')]
15498      * ]);
15499      *
15500      * func({ 'a': 1, 'b': 2 });
15501      * // => 'matches A'
15502      *
15503      * func({ 'a': 0, 'b': 1 });
15504      * // => 'matches B'
15505      *
15506      * func({ 'a': '1', 'b': '2' });
15507      * // => 'no match'
15508      */
15509     function cond(pairs) {
15510       var length = pairs == null ? 0 : pairs.length,
15511         toIteratee = getIteratee();
15512
15513       pairs = !length ? [] : arrayMap(pairs, function(pair) {
15514         if (typeof pair[1] != 'function') {
15515           throw new TypeError(FUNC_ERROR_TEXT);
15516         }
15517         return [toIteratee(pair[0]), pair[1]];
15518       });
15519
15520       return baseRest(function(args) {
15521         var index = -1;
15522         while (++index < length) {
15523           var pair = pairs[index];
15524           if (apply(pair[0], this, args)) {
15525             return apply(pair[1], this, args);
15526           }
15527         }
15528       });
15529     }
15530
15531     /**
15532      * Creates a function that invokes the predicate properties of `source` with
15533      * the corresponding property values of a given object, returning `true` if
15534      * all predicates return truthy, else `false`.
15535      *
15536      * **Note:** The created function is equivalent to `_.conformsTo` with
15537      * `source` partially applied.
15538      *
15539      * @static
15540      * @memberOf _
15541      * @since 4.0.0
15542      * @category Util
15543      * @param {Object} source The object of property predicates to conform to.
15544      * @returns {Function} Returns the new spec function.
15545      * @example
15546      *
15547      * var objects = [
15548      *   { 'a': 2, 'b': 1 },
15549      *   { 'a': 1, 'b': 2 }
15550      * ];
15551      *
15552      * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15553      * // => [{ 'a': 1, 'b': 2 }]
15554      */
15555     function conforms(source) {
15556       return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
15557     }
15558
15559     /**
15560      * Creates a function that returns `value`.
15561      *
15562      * @static
15563      * @memberOf _
15564      * @since 2.4.0
15565      * @category Util
15566      * @param {*} value The value to return from the new function.
15567      * @returns {Function} Returns the new constant function.
15568      * @example
15569      *
15570      * var objects = _.times(2, _.constant({ 'a': 1 }));
15571      *
15572      * console.log(objects);
15573      * // => [{ 'a': 1 }, { 'a': 1 }]
15574      *
15575      * console.log(objects[0] === objects[1]);
15576      * // => true
15577      */
15578     function constant(value) {
15579       return function() {
15580         return value;
15581       };
15582     }
15583
15584     /**
15585      * Checks `value` to determine whether a default value should be returned in
15586      * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
15587      * or `undefined`.
15588      *
15589      * @static
15590      * @memberOf _
15591      * @since 4.14.0
15592      * @category Util
15593      * @param {*} value The value to check.
15594      * @param {*} defaultValue The default value.
15595      * @returns {*} Returns the resolved value.
15596      * @example
15597      *
15598      * _.defaultTo(1, 10);
15599      * // => 1
15600      *
15601      * _.defaultTo(undefined, 10);
15602      * // => 10
15603      */
15604     function defaultTo(value, defaultValue) {
15605       return (value == null || value !== value) ? defaultValue : value;
15606     }
15607
15608     /**
15609      * Creates a function that returns the result of invoking the given functions
15610      * with the `this` binding of the created function, where each successive
15611      * invocation is supplied the return value of the previous.
15612      *
15613      * @static
15614      * @memberOf _
15615      * @since 3.0.0
15616      * @category Util
15617      * @param {...(Function|Function[])} [funcs] The functions to invoke.
15618      * @returns {Function} Returns the new composite function.
15619      * @see _.flowRight
15620      * @example
15621      *
15622      * function square(n) {
15623      *   return n * n;
15624      * }
15625      *
15626      * var addSquare = _.flow([_.add, square]);
15627      * addSquare(1, 2);
15628      * // => 9
15629      */
15630     var flow = createFlow();
15631
15632     /**
15633      * This method is like `_.flow` except that it creates a function that
15634      * invokes the given functions from right to left.
15635      *
15636      * @static
15637      * @since 3.0.0
15638      * @memberOf _
15639      * @category Util
15640      * @param {...(Function|Function[])} [funcs] The functions to invoke.
15641      * @returns {Function} Returns the new composite function.
15642      * @see _.flow
15643      * @example
15644      *
15645      * function square(n) {
15646      *   return n * n;
15647      * }
15648      *
15649      * var addSquare = _.flowRight([square, _.add]);
15650      * addSquare(1, 2);
15651      * // => 9
15652      */
15653     var flowRight = createFlow(true);
15654
15655     /**
15656      * This method returns the first argument it receives.
15657      *
15658      * @static
15659      * @since 0.1.0
15660      * @memberOf _
15661      * @category Util
15662      * @param {*} value Any value.
15663      * @returns {*} Returns `value`.
15664      * @example
15665      *
15666      * var object = { 'a': 1 };
15667      *
15668      * console.log(_.identity(object) === object);
15669      * // => true
15670      */
15671     function identity(value) {
15672       return value;
15673     }
15674
15675     /**
15676      * Creates a function that invokes `func` with the arguments of the created
15677      * function. If `func` is a property name, the created function returns the
15678      * property value for a given element. If `func` is an array or object, the
15679      * created function returns `true` for elements that contain the equivalent
15680      * source properties, otherwise it returns `false`.
15681      *
15682      * @static
15683      * @since 4.0.0
15684      * @memberOf _
15685      * @category Util
15686      * @param {*} [func=_.identity] The value to convert to a callback.
15687      * @returns {Function} Returns the callback.
15688      * @example
15689      *
15690      * var users = [
15691      *   { 'user': 'barney', 'age': 36, 'active': true },
15692      *   { 'user': 'fred',   'age': 40, 'active': false }
15693      * ];
15694      *
15695      * // The `_.matches` iteratee shorthand.
15696      * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15697      * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15698      *
15699      * // The `_.matchesProperty` iteratee shorthand.
15700      * _.filter(users, _.iteratee(['user', 'fred']));
15701      * // => [{ 'user': 'fred', 'age': 40 }]
15702      *
15703      * // The `_.property` iteratee shorthand.
15704      * _.map(users, _.iteratee('user'));
15705      * // => ['barney', 'fred']
15706      *
15707      * // Create custom iteratee shorthands.
15708      * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
15709      *   return !_.isRegExp(func) ? iteratee(func) : function(string) {
15710      *     return func.test(string);
15711      *   };
15712      * });
15713      *
15714      * _.filter(['abc', 'def'], /ef/);
15715      * // => ['def']
15716      */
15717     function iteratee(func) {
15718       return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
15719     }
15720
15721     /**
15722      * Creates a function that performs a partial deep comparison between a given
15723      * object and `source`, returning `true` if the given object has equivalent
15724      * property values, else `false`.
15725      *
15726      * **Note:** The created function is equivalent to `_.isMatch` with `source`
15727      * partially applied.
15728      *
15729      * Partial comparisons will match empty array and empty object `source`
15730      * values against any array or object value, respectively. See `_.isEqual`
15731      * for a list of supported value comparisons.
15732      *
15733      * **Note:** Multiple values can be checked by combining several matchers
15734      * using `_.overSome`
15735      *
15736      * @static
15737      * @memberOf _
15738      * @since 3.0.0
15739      * @category Util
15740      * @param {Object} source The object of property values to match.
15741      * @returns {Function} Returns the new spec function.
15742      * @example
15743      *
15744      * var objects = [
15745      *   { 'a': 1, 'b': 2, 'c': 3 },
15746      *   { 'a': 4, 'b': 5, 'c': 6 }
15747      * ];
15748      *
15749      * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15750      * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15751      *
15752      * // Checking for several possible values
15753      * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
15754      * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
15755      */
15756     function matches(source) {
15757       return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
15758     }
15759
15760     /**
15761      * Creates a function that performs a partial deep comparison between the
15762      * value at `path` of a given object to `srcValue`, returning `true` if the
15763      * object value is equivalent, else `false`.
15764      *
15765      * **Note:** Partial comparisons will match empty array and empty object
15766      * `srcValue` values against any array or object value, respectively. See
15767      * `_.isEqual` for a list of supported value comparisons.
15768      *
15769      * **Note:** Multiple values can be checked by combining several matchers
15770      * using `_.overSome`
15771      *
15772      * @static
15773      * @memberOf _
15774      * @since 3.2.0
15775      * @category Util
15776      * @param {Array|string} path The path of the property to get.
15777      * @param {*} srcValue The value to match.
15778      * @returns {Function} Returns the new spec function.
15779      * @example
15780      *
15781      * var objects = [
15782      *   { 'a': 1, 'b': 2, 'c': 3 },
15783      *   { 'a': 4, 'b': 5, 'c': 6 }
15784      * ];
15785      *
15786      * _.find(objects, _.matchesProperty('a', 4));
15787      * // => { 'a': 4, 'b': 5, 'c': 6 }
15788      *
15789      * // Checking for several possible values
15790      * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
15791      * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
15792      */
15793     function matchesProperty(path, srcValue) {
15794       return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
15795     }
15796
15797     /**
15798      * Creates a function that invokes the method at `path` of a given object.
15799      * Any additional arguments are provided to the invoked method.
15800      *
15801      * @static
15802      * @memberOf _
15803      * @since 3.7.0
15804      * @category Util
15805      * @param {Array|string} path The path of the method to invoke.
15806      * @param {...*} [args] The arguments to invoke the method with.
15807      * @returns {Function} Returns the new invoker function.
15808      * @example
15809      *
15810      * var objects = [
15811      *   { 'a': { 'b': _.constant(2) } },
15812      *   { 'a': { 'b': _.constant(1) } }
15813      * ];
15814      *
15815      * _.map(objects, _.method('a.b'));
15816      * // => [2, 1]
15817      *
15818      * _.map(objects, _.method(['a', 'b']));
15819      * // => [2, 1]
15820      */
15821     var method = baseRest(function(path, args) {
15822       return function(object) {
15823         return baseInvoke(object, path, args);
15824       };
15825     });
15826
15827     /**
15828      * The opposite of `_.method`; this method creates a function that invokes
15829      * the method at a given path of `object`. Any additional arguments are
15830      * provided to the invoked method.
15831      *
15832      * @static
15833      * @memberOf _
15834      * @since 3.7.0
15835      * @category Util
15836      * @param {Object} object The object to query.
15837      * @param {...*} [args] The arguments to invoke the method with.
15838      * @returns {Function} Returns the new invoker function.
15839      * @example
15840      *
15841      * var array = _.times(3, _.constant),
15842      *     object = { 'a': array, 'b': array, 'c': array };
15843      *
15844      * _.map(['a[2]', 'c[0]'], _.methodOf(object));
15845      * // => [2, 0]
15846      *
15847      * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
15848      * // => [2, 0]
15849      */
15850     var methodOf = baseRest(function(object, args) {
15851       return function(path) {
15852         return baseInvoke(object, path, args);
15853       };
15854     });
15855
15856     /**
15857      * Adds all own enumerable string keyed function properties of a source
15858      * object to the destination object. If `object` is a function, then methods
15859      * are added to its prototype as well.
15860      *
15861      * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
15862      * avoid conflicts caused by modifying the original.
15863      *
15864      * @static
15865      * @since 0.1.0
15866      * @memberOf _
15867      * @category Util
15868      * @param {Function|Object} [object=lodash] The destination object.
15869      * @param {Object} source The object of functions to add.
15870      * @param {Object} [options={}] The options object.
15871      * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
15872      * @returns {Function|Object} Returns `object`.
15873      * @example
15874      *
15875      * function vowels(string) {
15876      *   return _.filter(string, function(v) {
15877      *     return /[aeiou]/i.test(v);
15878      *   });
15879      * }
15880      *
15881      * _.mixin({ 'vowels': vowels });
15882      * _.vowels('fred');
15883      * // => ['e']
15884      *
15885      * _('fred').vowels().value();
15886      * // => ['e']
15887      *
15888      * _.mixin({ 'vowels': vowels }, { 'chain': false });
15889      * _('fred').vowels();
15890      * // => ['e']
15891      */
15892     function mixin(object, source, options) {
15893       var props = keys(source),
15894         methodNames = baseFunctions(source, props);
15895
15896       if (options == null &&
15897         !(isObject(source) && (methodNames.length || !props.length))) {
15898         options = source;
15899         source = object;
15900         object = this;
15901         methodNames = baseFunctions(source, keys(source));
15902       }
15903       var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
15904         isFunc = isFunction(object);
15905
15906       arrayEach(methodNames, function(methodName) {
15907         var func = source[methodName];
15908         object[methodName] = func;
15909         if (isFunc) {
15910           object.prototype[methodName] = function() {
15911             var chainAll = this.__chain__;
15912             if (chain || chainAll) {
15913               var result = object(this.__wrapped__),
15914                 actions = result.__actions__ = copyArray(this.__actions__);
15915
15916               actions.push({
15917                 'func': func,
15918                 'args': arguments,
15919                 'thisArg': object
15920               });
15921               result.__chain__ = chainAll;
15922               return result;
15923             }
15924             return func.apply(object, arrayPush([this.value()], arguments));
15925           };
15926         }
15927       });
15928
15929       return object;
15930     }
15931
15932     /**
15933      * Reverts the `_` variable to its previous value and returns a reference to
15934      * the `lodash` function.
15935      *
15936      * @static
15937      * @since 0.1.0
15938      * @memberOf _
15939      * @category Util
15940      * @returns {Function} Returns the `lodash` function.
15941      * @example
15942      *
15943      * var lodash = _.noConflict();
15944      */
15945     function noConflict() {
15946       if (root._ === this) {
15947         root._ = oldDash;
15948       }
15949       return this;
15950     }
15951
15952     /**
15953      * This method returns `undefined`.
15954      *
15955      * @static
15956      * @memberOf _
15957      * @since 2.3.0
15958      * @category Util
15959      * @example
15960      *
15961      * _.times(2, _.noop);
15962      * // => [undefined, undefined]
15963      */
15964     function noop() {
15965       // No operation performed.
15966     }
15967
15968     /**
15969      * Creates a function that gets the argument at index `n`. If `n` is negative,
15970      * the nth argument from the end is returned.
15971      *
15972      * @static
15973      * @memberOf _
15974      * @since 4.0.0
15975      * @category Util
15976      * @param {number} [n=0] The index of the argument to return.
15977      * @returns {Function} Returns the new pass-thru function.
15978      * @example
15979      *
15980      * var func = _.nthArg(1);
15981      * func('a', 'b', 'c', 'd');
15982      * // => 'b'
15983      *
15984      * var func = _.nthArg(-2);
15985      * func('a', 'b', 'c', 'd');
15986      * // => 'c'
15987      */
15988     function nthArg(n) {
15989       n = toInteger(n);
15990       return baseRest(function(args) {
15991         return baseNth(args, n);
15992       });
15993     }
15994
15995     /**
15996      * Creates a function that invokes `iteratees` with the arguments it receives
15997      * and returns their results.
15998      *
15999      * @static
16000      * @memberOf _
16001      * @since 4.0.0
16002      * @category Util
16003      * @param {...(Function|Function[])} [iteratees=[_.identity]]
16004      *  The iteratees to invoke.
16005      * @returns {Function} Returns the new function.
16006      * @example
16007      *
16008      * var func = _.over([Math.max, Math.min]);
16009      *
16010      * func(1, 2, 3, 4);
16011      * // => [4, 1]
16012      */
16013     var over = createOver(arrayMap);
16014
16015     /**
16016      * Creates a function that checks if **all** of the `predicates` return
16017      * truthy when invoked with the arguments it receives.
16018      *
16019      * Following shorthands are possible for providing predicates.
16020      * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
16021      * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
16022      *
16023      * @static
16024      * @memberOf _
16025      * @since 4.0.0
16026      * @category Util
16027      * @param {...(Function|Function[])} [predicates=[_.identity]]
16028      *  The predicates to check.
16029      * @returns {Function} Returns the new function.
16030      * @example
16031      *
16032      * var func = _.overEvery([Boolean, isFinite]);
16033      *
16034      * func('1');
16035      * // => true
16036      *
16037      * func(null);
16038      * // => false
16039      *
16040      * func(NaN);
16041      * // => false
16042      */
16043     var overEvery = createOver(arrayEvery);
16044
16045     /**
16046      * Creates a function that checks if **any** of the `predicates` return
16047      * truthy when invoked with the arguments it receives.
16048      *
16049      * Following shorthands are possible for providing predicates.
16050      * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
16051      * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
16052      *
16053      * @static
16054      * @memberOf _
16055      * @since 4.0.0
16056      * @category Util
16057      * @param {...(Function|Function[])} [predicates=[_.identity]]
16058      *  The predicates to check.
16059      * @returns {Function} Returns the new function.
16060      * @example
16061      *
16062      * var func = _.overSome([Boolean, isFinite]);
16063      *
16064      * func('1');
16065      * // => true
16066      *
16067      * func(null);
16068      * // => true
16069      *
16070      * func(NaN);
16071      * // => false
16072      *
16073      * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
16074      * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
16075      */
16076     var overSome = createOver(arraySome);
16077
16078     /**
16079      * Creates a function that returns the value at `path` of a given object.
16080      *
16081      * @static
16082      * @memberOf _
16083      * @since 2.4.0
16084      * @category Util
16085      * @param {Array|string} path The path of the property to get.
16086      * @returns {Function} Returns the new accessor function.
16087      * @example
16088      *
16089      * var objects = [
16090      *   { 'a': { 'b': 2 } },
16091      *   { 'a': { 'b': 1 } }
16092      * ];
16093      *
16094      * _.map(objects, _.property('a.b'));
16095      * // => [2, 1]
16096      *
16097      * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
16098      * // => [1, 2]
16099      */
16100     function property(path) {
16101       return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
16102     }
16103
16104     /**
16105      * The opposite of `_.property`; this method creates a function that returns
16106      * the value at a given path of `object`.
16107      *
16108      * @static
16109      * @memberOf _
16110      * @since 3.0.0
16111      * @category Util
16112      * @param {Object} object The object to query.
16113      * @returns {Function} Returns the new accessor function.
16114      * @example
16115      *
16116      * var array = [0, 1, 2],
16117      *     object = { 'a': array, 'b': array, 'c': array };
16118      *
16119      * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
16120      * // => [2, 0]
16121      *
16122      * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
16123      * // => [2, 0]
16124      */
16125     function propertyOf(object) {
16126       return function(path) {
16127         return object == null ? undefined : baseGet(object, path);
16128       };
16129     }
16130
16131     /**
16132      * Creates an array of numbers (positive and/or negative) progressing from
16133      * `start` up to, but not including, `end`. A step of `-1` is used if a negative
16134      * `start` is specified without an `end` or `step`. If `end` is not specified,
16135      * it's set to `start` with `start` then set to `0`.
16136      *
16137      * **Note:** JavaScript follows the IEEE-754 standard for resolving
16138      * floating-point values which can produce unexpected results.
16139      *
16140      * @static
16141      * @since 0.1.0
16142      * @memberOf _
16143      * @category Util
16144      * @param {number} [start=0] The start of the range.
16145      * @param {number} end The end of the range.
16146      * @param {number} [step=1] The value to increment or decrement by.
16147      * @returns {Array} Returns the range of numbers.
16148      * @see _.inRange, _.rangeRight
16149      * @example
16150      *
16151      * _.range(4);
16152      * // => [0, 1, 2, 3]
16153      *
16154      * _.range(-4);
16155      * // => [0, -1, -2, -3]
16156      *
16157      * _.range(1, 5);
16158      * // => [1, 2, 3, 4]
16159      *
16160      * _.range(0, 20, 5);
16161      * // => [0, 5, 10, 15]
16162      *
16163      * _.range(0, -4, -1);
16164      * // => [0, -1, -2, -3]
16165      *
16166      * _.range(1, 4, 0);
16167      * // => [1, 1, 1]
16168      *
16169      * _.range(0);
16170      * // => []
16171      */
16172     var range = createRange();
16173
16174     /**
16175      * This method is like `_.range` except that it populates values in
16176      * descending order.
16177      *
16178      * @static
16179      * @memberOf _
16180      * @since 4.0.0
16181      * @category Util
16182      * @param {number} [start=0] The start of the range.
16183      * @param {number} end The end of the range.
16184      * @param {number} [step=1] The value to increment or decrement by.
16185      * @returns {Array} Returns the range of numbers.
16186      * @see _.inRange, _.range
16187      * @example
16188      *
16189      * _.rangeRight(4);
16190      * // => [3, 2, 1, 0]
16191      *
16192      * _.rangeRight(-4);
16193      * // => [-3, -2, -1, 0]
16194      *
16195      * _.rangeRight(1, 5);
16196      * // => [4, 3, 2, 1]
16197      *
16198      * _.rangeRight(0, 20, 5);
16199      * // => [15, 10, 5, 0]
16200      *
16201      * _.rangeRight(0, -4, -1);
16202      * // => [-3, -2, -1, 0]
16203      *
16204      * _.rangeRight(1, 4, 0);
16205      * // => [1, 1, 1]
16206      *
16207      * _.rangeRight(0);
16208      * // => []
16209      */
16210     var rangeRight = createRange(true);
16211
16212     /**
16213      * This method returns a new empty array.
16214      *
16215      * @static
16216      * @memberOf _
16217      * @since 4.13.0
16218      * @category Util
16219      * @returns {Array} Returns the new empty array.
16220      * @example
16221      *
16222      * var arrays = _.times(2, _.stubArray);
16223      *
16224      * console.log(arrays);
16225      * // => [[], []]
16226      *
16227      * console.log(arrays[0] === arrays[1]);
16228      * // => false
16229      */
16230     function stubArray() {
16231       return [];
16232     }
16233
16234     /**
16235      * This method returns `false`.
16236      *
16237      * @static
16238      * @memberOf _
16239      * @since 4.13.0
16240      * @category Util
16241      * @returns {boolean} Returns `false`.
16242      * @example
16243      *
16244      * _.times(2, _.stubFalse);
16245      * // => [false, false]
16246      */
16247     function stubFalse() {
16248       return false;
16249     }
16250
16251     /**
16252      * This method returns a new empty object.
16253      *
16254      * @static
16255      * @memberOf _
16256      * @since 4.13.0
16257      * @category Util
16258      * @returns {Object} Returns the new empty object.
16259      * @example
16260      *
16261      * var objects = _.times(2, _.stubObject);
16262      *
16263      * console.log(objects);
16264      * // => [{}, {}]
16265      *
16266      * console.log(objects[0] === objects[1]);
16267      * // => false
16268      */
16269     function stubObject() {
16270       return {};
16271     }
16272
16273     /**
16274      * This method returns an empty string.
16275      *
16276      * @static
16277      * @memberOf _
16278      * @since 4.13.0
16279      * @category Util
16280      * @returns {string} Returns the empty string.
16281      * @example
16282      *
16283      * _.times(2, _.stubString);
16284      * // => ['', '']
16285      */
16286     function stubString() {
16287       return '';
16288     }
16289
16290     /**
16291      * This method returns `true`.
16292      *
16293      * @static
16294      * @memberOf _
16295      * @since 4.13.0
16296      * @category Util
16297      * @returns {boolean} Returns `true`.
16298      * @example
16299      *
16300      * _.times(2, _.stubTrue);
16301      * // => [true, true]
16302      */
16303     function stubTrue() {
16304       return true;
16305     }
16306
16307     /**
16308      * Invokes the iteratee `n` times, returning an array of the results of
16309      * each invocation. The iteratee is invoked with one argument; (index).
16310      *
16311      * @static
16312      * @since 0.1.0
16313      * @memberOf _
16314      * @category Util
16315      * @param {number} n The number of times to invoke `iteratee`.
16316      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16317      * @returns {Array} Returns the array of results.
16318      * @example
16319      *
16320      * _.times(3, String);
16321      * // => ['0', '1', '2']
16322      *
16323      *  _.times(4, _.constant(0));
16324      * // => [0, 0, 0, 0]
16325      */
16326     function times(n, iteratee) {
16327       n = toInteger(n);
16328       if (n < 1 || n > MAX_SAFE_INTEGER) {
16329         return [];
16330       }
16331       var index = MAX_ARRAY_LENGTH,
16332         length = nativeMin(n, MAX_ARRAY_LENGTH);
16333
16334       iteratee = getIteratee(iteratee);
16335       n -= MAX_ARRAY_LENGTH;
16336
16337       var result = baseTimes(length, iteratee);
16338       while (++index < n) {
16339         iteratee(index);
16340       }
16341       return result;
16342     }
16343
16344     /**
16345      * Converts `value` to a property path array.
16346      *
16347      * @static
16348      * @memberOf _
16349      * @since 4.0.0
16350      * @category Util
16351      * @param {*} value The value to convert.
16352      * @returns {Array} Returns the new property path array.
16353      * @example
16354      *
16355      * _.toPath('a.b.c');
16356      * // => ['a', 'b', 'c']
16357      *
16358      * _.toPath('a[0].b.c');
16359      * // => ['a', '0', 'b', 'c']
16360      */
16361     function toPath(value) {
16362       if (isArray(value)) {
16363         return arrayMap(value, toKey);
16364       }
16365       return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
16366     }
16367
16368     /**
16369      * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16370      *
16371      * @static
16372      * @since 0.1.0
16373      * @memberOf _
16374      * @category Util
16375      * @param {string} [prefix=''] The value to prefix the ID with.
16376      * @returns {string} Returns the unique ID.
16377      * @example
16378      *
16379      * _.uniqueId('contact_');
16380      * // => 'contact_104'
16381      *
16382      * _.uniqueId();
16383      * // => '105'
16384      */
16385     function uniqueId(prefix) {
16386       var id = ++idCounter;
16387       return toString(prefix) + id;
16388     }
16389
16390     /*------------------------------------------------------------------------*/
16391
16392     /**
16393      * Adds two numbers.
16394      *
16395      * @static
16396      * @memberOf _
16397      * @since 3.4.0
16398      * @category Math
16399      * @param {number} augend The first number in an addition.
16400      * @param {number} addend The second number in an addition.
16401      * @returns {number} Returns the total.
16402      * @example
16403      *
16404      * _.add(6, 4);
16405      * // => 10
16406      */
16407     var add = createMathOperation(function(augend, addend) {
16408       return augend + addend;
16409     }, 0);
16410
16411     /**
16412      * Computes `number` rounded up to `precision`.
16413      *
16414      * @static
16415      * @memberOf _
16416      * @since 3.10.0
16417      * @category Math
16418      * @param {number} number The number to round up.
16419      * @param {number} [precision=0] The precision to round up to.
16420      * @returns {number} Returns the rounded up number.
16421      * @example
16422      *
16423      * _.ceil(4.006);
16424      * // => 5
16425      *
16426      * _.ceil(6.004, 2);
16427      * // => 6.01
16428      *
16429      * _.ceil(6040, -2);
16430      * // => 6100
16431      */
16432     var ceil = createRound('ceil');
16433
16434     /**
16435      * Divide two numbers.
16436      *
16437      * @static
16438      * @memberOf _
16439      * @since 4.7.0
16440      * @category Math
16441      * @param {number} dividend The first number in a division.
16442      * @param {number} divisor The second number in a division.
16443      * @returns {number} Returns the quotient.
16444      * @example
16445      *
16446      * _.divide(6, 4);
16447      * // => 1.5
16448      */
16449     var divide = createMathOperation(function(dividend, divisor) {
16450       return dividend / divisor;
16451     }, 1);
16452
16453     /**
16454      * Computes `number` rounded down to `precision`.
16455      *
16456      * @static
16457      * @memberOf _
16458      * @since 3.10.0
16459      * @category Math
16460      * @param {number} number The number to round down.
16461      * @param {number} [precision=0] The precision to round down to.
16462      * @returns {number} Returns the rounded down number.
16463      * @example
16464      *
16465      * _.floor(4.006);
16466      * // => 4
16467      *
16468      * _.floor(0.046, 2);
16469      * // => 0.04
16470      *
16471      * _.floor(4060, -2);
16472      * // => 4000
16473      */
16474     var floor = createRound('floor');
16475
16476     /**
16477      * Computes the maximum value of `array`. If `array` is empty or falsey,
16478      * `undefined` is returned.
16479      *
16480      * @static
16481      * @since 0.1.0
16482      * @memberOf _
16483      * @category Math
16484      * @param {Array} array The array to iterate over.
16485      * @returns {*} Returns the maximum value.
16486      * @example
16487      *
16488      * _.max([4, 2, 8, 6]);
16489      * // => 8
16490      *
16491      * _.max([]);
16492      * // => undefined
16493      */
16494     function max(array) {
16495       return (array && array.length) ?
16496         baseExtremum(array, identity, baseGt) :
16497         undefined;
16498     }
16499
16500     /**
16501      * This method is like `_.max` except that it accepts `iteratee` which is
16502      * invoked for each element in `array` to generate the criterion by which
16503      * the value is ranked. The iteratee is invoked with one argument: (value).
16504      *
16505      * @static
16506      * @memberOf _
16507      * @since 4.0.0
16508      * @category Math
16509      * @param {Array} array The array to iterate over.
16510      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16511      * @returns {*} Returns the maximum value.
16512      * @example
16513      *
16514      * var objects = [{ 'n': 1 }, { 'n': 2 }];
16515      *
16516      * _.maxBy(objects, function(o) { return o.n; });
16517      * // => { 'n': 2 }
16518      *
16519      * // The `_.property` iteratee shorthand.
16520      * _.maxBy(objects, 'n');
16521      * // => { 'n': 2 }
16522      */
16523     function maxBy(array, iteratee) {
16524       return (array && array.length) ?
16525         baseExtremum(array, getIteratee(iteratee, 2), baseGt) :
16526         undefined;
16527     }
16528
16529     /**
16530      * Computes the mean of the values in `array`.
16531      *
16532      * @static
16533      * @memberOf _
16534      * @since 4.0.0
16535      * @category Math
16536      * @param {Array} array The array to iterate over.
16537      * @returns {number} Returns the mean.
16538      * @example
16539      *
16540      * _.mean([4, 2, 8, 6]);
16541      * // => 5
16542      */
16543     function mean(array) {
16544       return baseMean(array, identity);
16545     }
16546
16547     /**
16548      * This method is like `_.mean` except that it accepts `iteratee` which is
16549      * invoked for each element in `array` to generate the value to be averaged.
16550      * The iteratee is invoked with one argument: (value).
16551      *
16552      * @static
16553      * @memberOf _
16554      * @since 4.7.0
16555      * @category Math
16556      * @param {Array} array The array to iterate over.
16557      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16558      * @returns {number} Returns the mean.
16559      * @example
16560      *
16561      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16562      *
16563      * _.meanBy(objects, function(o) { return o.n; });
16564      * // => 5
16565      *
16566      * // The `_.property` iteratee shorthand.
16567      * _.meanBy(objects, 'n');
16568      * // => 5
16569      */
16570     function meanBy(array, iteratee) {
16571       return baseMean(array, getIteratee(iteratee, 2));
16572     }
16573
16574     /**
16575      * Computes the minimum value of `array`. If `array` is empty or falsey,
16576      * `undefined` is returned.
16577      *
16578      * @static
16579      * @since 0.1.0
16580      * @memberOf _
16581      * @category Math
16582      * @param {Array} array The array to iterate over.
16583      * @returns {*} Returns the minimum value.
16584      * @example
16585      *
16586      * _.min([4, 2, 8, 6]);
16587      * // => 2
16588      *
16589      * _.min([]);
16590      * // => undefined
16591      */
16592     function min(array) {
16593       return (array && array.length) ?
16594         baseExtremum(array, identity, baseLt) :
16595         undefined;
16596     }
16597
16598     /**
16599      * This method is like `_.min` except that it accepts `iteratee` which is
16600      * invoked for each element in `array` to generate the criterion by which
16601      * the value is ranked. The iteratee is invoked with one argument: (value).
16602      *
16603      * @static
16604      * @memberOf _
16605      * @since 4.0.0
16606      * @category Math
16607      * @param {Array} array The array to iterate over.
16608      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16609      * @returns {*} Returns the minimum value.
16610      * @example
16611      *
16612      * var objects = [{ 'n': 1 }, { 'n': 2 }];
16613      *
16614      * _.minBy(objects, function(o) { return o.n; });
16615      * // => { 'n': 1 }
16616      *
16617      * // The `_.property` iteratee shorthand.
16618      * _.minBy(objects, 'n');
16619      * // => { 'n': 1 }
16620      */
16621     function minBy(array, iteratee) {
16622       return (array && array.length) ?
16623         baseExtremum(array, getIteratee(iteratee, 2), baseLt) :
16624         undefined;
16625     }
16626
16627     /**
16628      * Multiply two numbers.
16629      *
16630      * @static
16631      * @memberOf _
16632      * @since 4.7.0
16633      * @category Math
16634      * @param {number} multiplier The first number in a multiplication.
16635      * @param {number} multiplicand The second number in a multiplication.
16636      * @returns {number} Returns the product.
16637      * @example
16638      *
16639      * _.multiply(6, 4);
16640      * // => 24
16641      */
16642     var multiply = createMathOperation(function(multiplier, multiplicand) {
16643       return multiplier * multiplicand;
16644     }, 1);
16645
16646     /**
16647      * Computes `number` rounded to `precision`.
16648      *
16649      * @static
16650      * @memberOf _
16651      * @since 3.10.0
16652      * @category Math
16653      * @param {number} number The number to round.
16654      * @param {number} [precision=0] The precision to round to.
16655      * @returns {number} Returns the rounded number.
16656      * @example
16657      *
16658      * _.round(4.006);
16659      * // => 4
16660      *
16661      * _.round(4.006, 2);
16662      * // => 4.01
16663      *
16664      * _.round(4060, -2);
16665      * // => 4100
16666      */
16667     var round = createRound('round');
16668
16669     /**
16670      * Subtract two numbers.
16671      *
16672      * @static
16673      * @memberOf _
16674      * @since 4.0.0
16675      * @category Math
16676      * @param {number} minuend The first number in a subtraction.
16677      * @param {number} subtrahend The second number in a subtraction.
16678      * @returns {number} Returns the difference.
16679      * @example
16680      *
16681      * _.subtract(6, 4);
16682      * // => 2
16683      */
16684     var subtract = createMathOperation(function(minuend, subtrahend) {
16685       return minuend - subtrahend;
16686     }, 0);
16687
16688     /**
16689      * Computes the sum of the values in `array`.
16690      *
16691      * @static
16692      * @memberOf _
16693      * @since 3.4.0
16694      * @category Math
16695      * @param {Array} array The array to iterate over.
16696      * @returns {number} Returns the sum.
16697      * @example
16698      *
16699      * _.sum([4, 2, 8, 6]);
16700      * // => 20
16701      */
16702     function sum(array) {
16703       return (array && array.length) ?
16704         baseSum(array, identity) :
16705         0;
16706     }
16707
16708     /**
16709      * This method is like `_.sum` except that it accepts `iteratee` which is
16710      * invoked for each element in `array` to generate the value to be summed.
16711      * The iteratee is invoked with one argument: (value).
16712      *
16713      * @static
16714      * @memberOf _
16715      * @since 4.0.0
16716      * @category Math
16717      * @param {Array} array The array to iterate over.
16718      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16719      * @returns {number} Returns the sum.
16720      * @example
16721      *
16722      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16723      *
16724      * _.sumBy(objects, function(o) { return o.n; });
16725      * // => 20
16726      *
16727      * // The `_.property` iteratee shorthand.
16728      * _.sumBy(objects, 'n');
16729      * // => 20
16730      */
16731     function sumBy(array, iteratee) {
16732       return (array && array.length) ?
16733         baseSum(array, getIteratee(iteratee, 2)) :
16734         0;
16735     }
16736
16737     /*------------------------------------------------------------------------*/
16738
16739     // Add methods that return wrapped values in chain sequences.
16740     lodash.after = after;
16741     lodash.ary = ary;
16742     lodash.assign = assign;
16743     lodash.assignIn = assignIn;
16744     lodash.assignInWith = assignInWith;
16745     lodash.assignWith = assignWith;
16746     lodash.at = at;
16747     lodash.before = before;
16748     lodash.bind = bind;
16749     lodash.bindAll = bindAll;
16750     lodash.bindKey = bindKey;
16751     lodash.castArray = castArray;
16752     lodash.chain = chain;
16753     lodash.chunk = chunk;
16754     lodash.compact = compact;
16755     lodash.concat = concat;
16756     lodash.cond = cond;
16757     lodash.conforms = conforms;
16758     lodash.constant = constant;
16759     lodash.countBy = countBy;
16760     lodash.create = create;
16761     lodash.curry = curry;
16762     lodash.curryRight = curryRight;
16763     lodash.debounce = debounce;
16764     lodash.defaults = defaults;
16765     lodash.defaultsDeep = defaultsDeep;
16766     lodash.defer = defer;
16767     lodash.delay = delay;
16768     lodash.difference = difference;
16769     lodash.differenceBy = differenceBy;
16770     lodash.differenceWith = differenceWith;
16771     lodash.drop = drop;
16772     lodash.dropRight = dropRight;
16773     lodash.dropRightWhile = dropRightWhile;
16774     lodash.dropWhile = dropWhile;
16775     lodash.fill = fill;
16776     lodash.filter = filter;
16777     lodash.flatMap = flatMap;
16778     lodash.flatMapDeep = flatMapDeep;
16779     lodash.flatMapDepth = flatMapDepth;
16780     lodash.flatten = flatten;
16781     lodash.flattenDeep = flattenDeep;
16782     lodash.flattenDepth = flattenDepth;
16783     lodash.flip = flip;
16784     lodash.flow = flow;
16785     lodash.flowRight = flowRight;
16786     lodash.fromPairs = fromPairs;
16787     lodash.functions = functions;
16788     lodash.functionsIn = functionsIn;
16789     lodash.groupBy = groupBy;
16790     lodash.initial = initial;
16791     lodash.intersection = intersection;
16792     lodash.intersectionBy = intersectionBy;
16793     lodash.intersectionWith = intersectionWith;
16794     lodash.invert = invert;
16795     lodash.invertBy = invertBy;
16796     lodash.invokeMap = invokeMap;
16797     lodash.iteratee = iteratee;
16798     lodash.keyBy = keyBy;
16799     lodash.keys = keys;
16800     lodash.keysIn = keysIn;
16801     lodash.map = map;
16802     lodash.mapKeys = mapKeys;
16803     lodash.mapValues = mapValues;
16804     lodash.matches = matches;
16805     lodash.matchesProperty = matchesProperty;
16806     lodash.memoize = memoize;
16807     lodash.merge = merge;
16808     lodash.mergeWith = mergeWith;
16809     lodash.method = method;
16810     lodash.methodOf = methodOf;
16811     lodash.mixin = mixin;
16812     lodash.negate = negate;
16813     lodash.nthArg = nthArg;
16814     lodash.omit = omit;
16815     lodash.omitBy = omitBy;
16816     lodash.once = once;
16817     lodash.orderBy = orderBy;
16818     lodash.over = over;
16819     lodash.overArgs = overArgs;
16820     lodash.overEvery = overEvery;
16821     lodash.overSome = overSome;
16822     lodash.partial = partial;
16823     lodash.partialRight = partialRight;
16824     lodash.partition = partition;
16825     lodash.pick = pick;
16826     lodash.pickBy = pickBy;
16827     lodash.property = property;
16828     lodash.propertyOf = propertyOf;
16829     lodash.pull = pull;
16830     lodash.pullAll = pullAll;
16831     lodash.pullAllBy = pullAllBy;
16832     lodash.pullAllWith = pullAllWith;
16833     lodash.pullAt = pullAt;
16834     lodash.range = range;
16835     lodash.rangeRight = rangeRight;
16836     lodash.rearg = rearg;
16837     lodash.reject = reject;
16838     lodash.remove = remove;
16839     lodash.rest = rest;
16840     lodash.reverse = reverse;
16841     lodash.sampleSize = sampleSize;
16842     lodash.set = set;
16843     lodash.setWith = setWith;
16844     lodash.shuffle = shuffle;
16845     lodash.slice = slice;
16846     lodash.sortBy = sortBy;
16847     lodash.sortedUniq = sortedUniq;
16848     lodash.sortedUniqBy = sortedUniqBy;
16849     lodash.split = split;
16850     lodash.spread = spread;
16851     lodash.tail = tail;
16852     lodash.take = take;
16853     lodash.takeRight = takeRight;
16854     lodash.takeRightWhile = takeRightWhile;
16855     lodash.takeWhile = takeWhile;
16856     lodash.tap = tap;
16857     lodash.throttle = throttle;
16858     lodash.thru = thru;
16859     lodash.toArray = toArray;
16860     lodash.toPairs = toPairs;
16861     lodash.toPairsIn = toPairsIn;
16862     lodash.toPath = toPath;
16863     lodash.toPlainObject = toPlainObject;
16864     lodash.transform = transform;
16865     lodash.unary = unary;
16866     lodash.union = union;
16867     lodash.unionBy = unionBy;
16868     lodash.unionWith = unionWith;
16869     lodash.uniq = uniq;
16870     lodash.uniqBy = uniqBy;
16871     lodash.uniqWith = uniqWith;
16872     lodash.unset = unset;
16873     lodash.unzip = unzip;
16874     lodash.unzipWith = unzipWith;
16875     lodash.update = update;
16876     lodash.updateWith = updateWith;
16877     lodash.values = values;
16878     lodash.valuesIn = valuesIn;
16879     lodash.without = without;
16880     lodash.words = words;
16881     lodash.wrap = wrap;
16882     lodash.xor = xor;
16883     lodash.xorBy = xorBy;
16884     lodash.xorWith = xorWith;
16885     lodash.zip = zip;
16886     lodash.zipObject = zipObject;
16887     lodash.zipObjectDeep = zipObjectDeep;
16888     lodash.zipWith = zipWith;
16889
16890     // Add aliases.
16891     lodash.entries = toPairs;
16892     lodash.entriesIn = toPairsIn;
16893     lodash.extend = assignIn;
16894     lodash.extendWith = assignInWith;
16895
16896     // Add methods to `lodash.prototype`.
16897     mixin(lodash, lodash);
16898
16899     /*------------------------------------------------------------------------*/
16900
16901     // Add methods that return unwrapped values in chain sequences.
16902     lodash.add = add;
16903     lodash.attempt = attempt;
16904     lodash.camelCase = camelCase;
16905     lodash.capitalize = capitalize;
16906     lodash.ceil = ceil;
16907     lodash.clamp = clamp;
16908     lodash.clone = clone;
16909     lodash.cloneDeep = cloneDeep;
16910     lodash.cloneDeepWith = cloneDeepWith;
16911     lodash.cloneWith = cloneWith;
16912     lodash.conformsTo = conformsTo;
16913     lodash.deburr = deburr;
16914     lodash.defaultTo = defaultTo;
16915     lodash.divide = divide;
16916     lodash.endsWith = endsWith;
16917     lodash.eq = eq;
16918     lodash.escape = escape;
16919     lodash.escapeRegExp = escapeRegExp;
16920     lodash.every = every;
16921     lodash.find = find;
16922     lodash.findIndex = findIndex;
16923     lodash.findKey = findKey;
16924     lodash.findLast = findLast;
16925     lodash.findLastIndex = findLastIndex;
16926     lodash.findLastKey = findLastKey;
16927     lodash.floor = floor;
16928     lodash.forEach = forEach;
16929     lodash.forEachRight = forEachRight;
16930     lodash.forIn = forIn;
16931     lodash.forInRight = forInRight;
16932     lodash.forOwn = forOwn;
16933     lodash.forOwnRight = forOwnRight;
16934     lodash.get = get;
16935     lodash.gt = gt;
16936     lodash.gte = gte;
16937     lodash.has = has;
16938     lodash.hasIn = hasIn;
16939     lodash.head = head;
16940     lodash.identity = identity;
16941     lodash.includes = includes;
16942     lodash.indexOf = indexOf;
16943     lodash.inRange = inRange;
16944     lodash.invoke = invoke;
16945     lodash.isArguments = isArguments;
16946     lodash.isArray = isArray;
16947     lodash.isArrayBuffer = isArrayBuffer;
16948     lodash.isArrayLike = isArrayLike;
16949     lodash.isArrayLikeObject = isArrayLikeObject;
16950     lodash.isBoolean = isBoolean;
16951     lodash.isBuffer = isBuffer;
16952     lodash.isDate = isDate;
16953     lodash.isElement = isElement;
16954     lodash.isEmpty = isEmpty;
16955     lodash.isEqual = isEqual;
16956     lodash.isEqualWith = isEqualWith;
16957     lodash.isError = isError;
16958     lodash.isFinite = isFinite;
16959     lodash.isFunction = isFunction;
16960     lodash.isInteger = isInteger;
16961     lodash.isLength = isLength;
16962     lodash.isMap = isMap;
16963     lodash.isMatch = isMatch;
16964     lodash.isMatchWith = isMatchWith;
16965     lodash.isNaN = isNaN;
16966     lodash.isNative = isNative;
16967     lodash.isNil = isNil;
16968     lodash.isNull = isNull;
16969     lodash.isNumber = isNumber;
16970     lodash.isObject = isObject;
16971     lodash.isObjectLike = isObjectLike;
16972     lodash.isPlainObject = isPlainObject;
16973     lodash.isRegExp = isRegExp;
16974     lodash.isSafeInteger = isSafeInteger;
16975     lodash.isSet = isSet;
16976     lodash.isString = isString;
16977     lodash.isSymbol = isSymbol;
16978     lodash.isTypedArray = isTypedArray;
16979     lodash.isUndefined = isUndefined;
16980     lodash.isWeakMap = isWeakMap;
16981     lodash.isWeakSet = isWeakSet;
16982     lodash.join = join;
16983     lodash.kebabCase = kebabCase;
16984     lodash.last = last;
16985     lodash.lastIndexOf = lastIndexOf;
16986     lodash.lowerCase = lowerCase;
16987     lodash.lowerFirst = lowerFirst;
16988     lodash.lt = lt;
16989     lodash.lte = lte;
16990     lodash.max = max;
16991     lodash.maxBy = maxBy;
16992     lodash.mean = mean;
16993     lodash.meanBy = meanBy;
16994     lodash.min = min;
16995     lodash.minBy = minBy;
16996     lodash.stubArray = stubArray;
16997     lodash.stubFalse = stubFalse;
16998     lodash.stubObject = stubObject;
16999     lodash.stubString = stubString;
17000     lodash.stubTrue = stubTrue;
17001     lodash.multiply = multiply;
17002     lodash.nth = nth;
17003     lodash.noConflict = noConflict;
17004     lodash.noop = noop;
17005     lodash.now = now;
17006     lodash.pad = pad;
17007     lodash.padEnd = padEnd;
17008     lodash.padStart = padStart;
17009     lodash.parseInt = parseInt;
17010     lodash.random = random;
17011     lodash.reduce = reduce;
17012     lodash.reduceRight = reduceRight;
17013     lodash.repeat = repeat;
17014     lodash.replace = replace;
17015     lodash.result = result;
17016     lodash.round = round;
17017     lodash.runInContext = runInContext;
17018     lodash.sample = sample;
17019     lodash.size = size;
17020     lodash.snakeCase = snakeCase;
17021     lodash.some = some;
17022     lodash.sortedIndex = sortedIndex;
17023     lodash.sortedIndexBy = sortedIndexBy;
17024     lodash.sortedIndexOf = sortedIndexOf;
17025     lodash.sortedLastIndex = sortedLastIndex;
17026     lodash.sortedLastIndexBy = sortedLastIndexBy;
17027     lodash.sortedLastIndexOf = sortedLastIndexOf;
17028     lodash.startCase = startCase;
17029     lodash.startsWith = startsWith;
17030     lodash.subtract = subtract;
17031     lodash.sum = sum;
17032     lodash.sumBy = sumBy;
17033     lodash.template = template;
17034     lodash.times = times;
17035     lodash.toFinite = toFinite;
17036     lodash.toInteger = toInteger;
17037     lodash.toLength = toLength;
17038     lodash.toLower = toLower;
17039     lodash.toNumber = toNumber;
17040     lodash.toSafeInteger = toSafeInteger;
17041     lodash.toString = toString;
17042     lodash.toUpper = toUpper;
17043     lodash.trim = trim;
17044     lodash.trimEnd = trimEnd;
17045     lodash.trimStart = trimStart;
17046     lodash.truncate = truncate;
17047     lodash.unescape = unescape;
17048     lodash.uniqueId = uniqueId;
17049     lodash.upperCase = upperCase;
17050     lodash.upperFirst = upperFirst;
17051
17052     // Add aliases.
17053     lodash.each = forEach;
17054     lodash.eachRight = forEachRight;
17055     lodash.first = head;
17056
17057     mixin(lodash, (function() {
17058       var source = {};
17059       baseForOwn(lodash, function(func, methodName) {
17060         if (!hasOwnProperty.call(lodash.prototype, methodName)) {
17061           source[methodName] = func;
17062         }
17063       });
17064       return source;
17065     }()), {
17066       'chain': false
17067     });
17068
17069     /*------------------------------------------------------------------------*/
17070
17071     /**
17072      * The semantic version number.
17073      *
17074      * @static
17075      * @memberOf _
17076      * @type {string}
17077      */
17078     lodash.VERSION = VERSION;
17079
17080     // Assign default placeholders.
17081     arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
17082       lodash[methodName].placeholder = lodash;
17083     });
17084
17085     // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
17086     arrayEach(['drop', 'take'], function(methodName, index) {
17087       LazyWrapper.prototype[methodName] = function(n) {
17088         n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
17089
17090         var result = (this.__filtered__ && !index) ?
17091           new LazyWrapper(this) :
17092           this.clone();
17093
17094         if (result.__filtered__) {
17095           result.__takeCount__ = nativeMin(n, result.__takeCount__);
17096         } else {
17097           result.__views__.push({
17098             'size': nativeMin(n, MAX_ARRAY_LENGTH),
17099             'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
17100           });
17101         }
17102         return result;
17103       };
17104
17105       LazyWrapper.prototype[methodName + 'Right'] = function(n) {
17106         return this.reverse()[methodName](n).reverse();
17107       };
17108     });
17109
17110     // Add `LazyWrapper` methods that accept an `iteratee` value.
17111     arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
17112       var type = index + 1,
17113         isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
17114
17115       LazyWrapper.prototype[methodName] = function(iteratee) {
17116         var result = this.clone();
17117         result.__iteratees__.push({
17118           'iteratee': getIteratee(iteratee, 3),
17119           'type': type
17120         });
17121         result.__filtered__ = result.__filtered__ || isFilter;
17122         return result;
17123       };
17124     });
17125
17126     // Add `LazyWrapper` methods for `_.head` and `_.last`.
17127     arrayEach(['head', 'last'], function(methodName, index) {
17128       var takeName = 'take' + (index ? 'Right' : '');
17129
17130       LazyWrapper.prototype[methodName] = function() {
17131         return this[takeName](1).value()[0];
17132       };
17133     });
17134
17135     // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
17136     arrayEach(['initial', 'tail'], function(methodName, index) {
17137       var dropName = 'drop' + (index ? '' : 'Right');
17138
17139       LazyWrapper.prototype[methodName] = function() {
17140         return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
17141       };
17142     });
17143
17144     LazyWrapper.prototype.compact = function() {
17145       return this.filter(identity);
17146     };
17147
17148     LazyWrapper.prototype.find = function(predicate) {
17149       return this.filter(predicate).head();
17150     };
17151
17152     LazyWrapper.prototype.findLast = function(predicate) {
17153       return this.reverse().find(predicate);
17154     };
17155
17156     LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
17157       if (typeof path == 'function') {
17158         return new LazyWrapper(this);
17159       }
17160       return this.map(function(value) {
17161         return baseInvoke(value, path, args);
17162       });
17163     });
17164
17165     LazyWrapper.prototype.reject = function(predicate) {
17166       return this.filter(negate(getIteratee(predicate)));
17167     };
17168
17169     LazyWrapper.prototype.slice = function(start, end) {
17170       start = toInteger(start);
17171
17172       var result = this;
17173       if (result.__filtered__ && (start > 0 || end < 0)) {
17174         return new LazyWrapper(result);
17175       }
17176       if (start < 0) {
17177         result = result.takeRight(-start);
17178       } else if (start) {
17179         result = result.drop(start);
17180       }
17181       if (end !== undefined) {
17182         end = toInteger(end);
17183         result = end < 0 ? result.dropRight(-end) : result.take(end - start);
17184       }
17185       return result;
17186     };
17187
17188     LazyWrapper.prototype.takeRightWhile = function(predicate) {
17189       return this.reverse().takeWhile(predicate).reverse();
17190     };
17191
17192     LazyWrapper.prototype.toArray = function() {
17193       return this.take(MAX_ARRAY_LENGTH);
17194     };
17195
17196     // Add `LazyWrapper` methods to `lodash.prototype`.
17197     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17198       var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
17199         isTaker = /^(?:head|last)$/.test(methodName),
17200         lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
17201         retUnwrapped = isTaker || /^find/.test(methodName);
17202
17203       if (!lodashFunc) {
17204         return;
17205       }
17206       lodash.prototype[methodName] = function() {
17207         var value = this.__wrapped__,
17208           args = isTaker ? [1] : arguments,
17209           isLazy = value instanceof LazyWrapper,
17210           iteratee = args[0],
17211           useLazy = isLazy || isArray(value);
17212
17213         var interceptor = function(value) {
17214           var result = lodashFunc.apply(lodash, arrayPush([value], args));
17215           return (isTaker && chainAll) ? result[0] : result;
17216         };
17217
17218         if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
17219           // Avoid lazy use if the iteratee has a "length" value other than `1`.
17220           isLazy = useLazy = false;
17221         }
17222         var chainAll = this.__chain__,
17223           isHybrid = !!this.__actions__.length,
17224           isUnwrapped = retUnwrapped && !chainAll,
17225           onlyLazy = isLazy && !isHybrid;
17226
17227         if (!retUnwrapped && useLazy) {
17228           value = onlyLazy ? value : new LazyWrapper(this);
17229           var result = func.apply(value, args);
17230           result.__actions__.push({
17231             'func': thru,
17232             'args': [interceptor],
17233             'thisArg': undefined
17234           });
17235           return new LodashWrapper(result, chainAll);
17236         }
17237         if (isUnwrapped && onlyLazy) {
17238           return func.apply(this, args);
17239         }
17240         result = this.thru(interceptor);
17241         return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
17242       };
17243     });
17244
17245     // Add `Array` methods to `lodash.prototype`.
17246     arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
17247       var func = arrayProto[methodName],
17248         chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
17249         retUnwrapped = /^(?:pop|shift)$/.test(methodName);
17250
17251       lodash.prototype[methodName] = function() {
17252         var args = arguments;
17253         if (retUnwrapped && !this.__chain__) {
17254           var value = this.value();
17255           return func.apply(isArray(value) ? value : [], args);
17256         }
17257         return this[chainName](function(value) {
17258           return func.apply(isArray(value) ? value : [], args);
17259         });
17260       };
17261     });
17262
17263     // Map minified method names to their real names.
17264     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17265       var lodashFunc = lodash[methodName];
17266       if (lodashFunc) {
17267         var key = lodashFunc.name + '';
17268         if (!hasOwnProperty.call(realNames, key)) {
17269           realNames[key] = [];
17270         }
17271         realNames[key].push({
17272           'name': methodName,
17273           'func': lodashFunc
17274         });
17275       }
17276     });
17277
17278     realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
17279       'name': 'wrapper',
17280       'func': undefined
17281     }];
17282
17283     // Add methods to `LazyWrapper`.
17284     LazyWrapper.prototype.clone = lazyClone;
17285     LazyWrapper.prototype.reverse = lazyReverse;
17286     LazyWrapper.prototype.value = lazyValue;
17287
17288     // Add chain sequence methods to the `lodash` wrapper.
17289     lodash.prototype.at = wrapperAt;
17290     lodash.prototype.chain = wrapperChain;
17291     lodash.prototype.commit = wrapperCommit;
17292     lodash.prototype.next = wrapperNext;
17293     lodash.prototype.plant = wrapperPlant;
17294     lodash.prototype.reverse = wrapperReverse;
17295     lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
17296
17297     // Add lazy aliases.
17298     lodash.prototype.first = lodash.prototype.head;
17299
17300     if (symIterator) {
17301       lodash.prototype[symIterator] = wrapperToIterator;
17302     }
17303     return lodash;
17304   });
17305
17306   /*--------------------------------------------------------------------------*/
17307
17308   // Export lodash.
17309   var _ = runInContext();
17310
17311   // Some AMD build optimizers, like r.js, check for condition patterns like:
17312   if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
17313     // Expose Lodash on the global object to prevent errors when Lodash is
17314     // loaded by a script tag in the presence of an AMD loader.
17315     // See http://requirejs.org/docs/errors.html#mismatch for more details.
17316     // Use `_.noConflict` to remove Lodash from the global object.
17317     root._ = _;
17318
17319     // Define as an anonymous module so, through path mapping, it can be
17320     // referenced as the "underscore" module.
17321     define(function() {
17322       return _;
17323     });
17324   }
17325   // Check for `exports` after `define` in case a build optimizer adds it.
17326   else if (freeModule) {
17327     // Export for Node.js.
17328     (freeModule.exports = _)._ = _;
17329     // Export for CommonJS support.
17330     freeExports._ = _;
17331   } else {
17332     // Export to the global object.
17333     root._ = _;
17334   }
17335 }.call(this));