Initial commit
[yaffs-website] / node_modules / node-sass / node_modules / lodash / lodash.js
1 /**
2  * @license
3  * lodash <https://lodash.com/>
4  * Copyright JS Foundation and other contributors <https://js.foundation/>
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 ;(function() {
10
11   /** Used as a safe reference for `undefined` in pre-ES5 environments. */
12   var undefined;
13
14   /** Used as the semantic version number. */
15   var VERSION = '4.16.6';
16
17   /** Used as the size to enable large array optimizations. */
18   var LARGE_ARRAY_SIZE = 200;
19
20   /** Error message constants. */
21   var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.',
22       FUNC_ERROR_TEXT = 'Expected a function';
23
24   /** Used to stand-in for `undefined` hash values. */
25   var HASH_UNDEFINED = '__lodash_hash_undefined__';
26
27   /** Used as the maximum memoize cache size. */
28   var MAX_MEMOIZE_SIZE = 500;
29
30   /** Used as the internal argument placeholder. */
31   var PLACEHOLDER = '__lodash_placeholder__';
32
33   /** Used to compose bitmasks for function metadata. */
34   var BIND_FLAG = 1,
35       BIND_KEY_FLAG = 2,
36       CURRY_BOUND_FLAG = 4,
37       CURRY_FLAG = 8,
38       CURRY_RIGHT_FLAG = 16,
39       PARTIAL_FLAG = 32,
40       PARTIAL_RIGHT_FLAG = 64,
41       ARY_FLAG = 128,
42       REARG_FLAG = 256,
43       FLIP_FLAG = 512;
44
45   /** Used to compose bitmasks for comparison styles. */
46   var UNORDERED_COMPARE_FLAG = 1,
47       PARTIAL_COMPARE_FLAG = 2;
48
49   /** Used as default options for `_.truncate`. */
50   var DEFAULT_TRUNC_LENGTH = 30,
51       DEFAULT_TRUNC_OMISSION = '...';
52
53   /** Used to detect hot functions by number of calls within a span of milliseconds. */
54   var HOT_COUNT = 800,
55       HOT_SPAN = 16;
56
57   /** Used to indicate the type of lazy iteratees. */
58   var LAZY_FILTER_FLAG = 1,
59       LAZY_MAP_FLAG = 2,
60       LAZY_WHILE_FLAG = 3;
61
62   /** Used as references for various `Number` constants. */
63   var INFINITY = 1 / 0,
64       MAX_SAFE_INTEGER = 9007199254740991,
65       MAX_INTEGER = 1.7976931348623157e+308,
66       NAN = 0 / 0;
67
68   /** Used as references for the maximum length and index of an array. */
69   var MAX_ARRAY_LENGTH = 4294967295,
70       MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
71       HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
72
73   /** Used to associate wrap methods with their bit flags. */
74   var wrapFlags = [
75     ['ary', ARY_FLAG],
76     ['bind', BIND_FLAG],
77     ['bindKey', BIND_KEY_FLAG],
78     ['curry', CURRY_FLAG],
79     ['curryRight', CURRY_RIGHT_FLAG],
80     ['flip', FLIP_FLAG],
81     ['partial', PARTIAL_FLAG],
82     ['partialRight', PARTIAL_RIGHT_FLAG],
83     ['rearg', REARG_FLAG]
84   ];
85
86   /** `Object#toString` result references. */
87   var argsTag = '[object Arguments]',
88       arrayTag = '[object Array]',
89       asyncTag = '[object AsyncFunction]',
90       boolTag = '[object Boolean]',
91       dateTag = '[object Date]',
92       domExcTag = '[object DOMException]',
93       errorTag = '[object Error]',
94       funcTag = '[object Function]',
95       genTag = '[object GeneratorFunction]',
96       mapTag = '[object Map]',
97       numberTag = '[object Number]',
98       nullTag = '[object Null]',
99       objectTag = '[object Object]',
100       promiseTag = '[object Promise]',
101       proxyTag = '[object Proxy]',
102       regexpTag = '[object RegExp]',
103       setTag = '[object Set]',
104       stringTag = '[object String]',
105       symbolTag = '[object Symbol]',
106       undefinedTag = '[object Undefined]',
107       weakMapTag = '[object WeakMap]',
108       weakSetTag = '[object WeakSet]';
109
110   var arrayBufferTag = '[object ArrayBuffer]',
111       dataViewTag = '[object DataView]',
112       float32Tag = '[object Float32Array]',
113       float64Tag = '[object Float64Array]',
114       int8Tag = '[object Int8Array]',
115       int16Tag = '[object Int16Array]',
116       int32Tag = '[object Int32Array]',
117       uint8Tag = '[object Uint8Array]',
118       uint8ClampedTag = '[object Uint8ClampedArray]',
119       uint16Tag = '[object Uint16Array]',
120       uint32Tag = '[object Uint32Array]';
121
122   /** Used to match empty string literals in compiled template source. */
123   var reEmptyStringLeading = /\b__p \+= '';/g,
124       reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
125       reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
126
127   /** Used to match HTML entities and HTML characters. */
128   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
129       reUnescapedHtml = /[&<>"']/g,
130       reHasEscapedHtml = RegExp(reEscapedHtml.source),
131       reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
132
133   /** Used to match template delimiters. */
134   var reEscape = /<%-([\s\S]+?)%>/g,
135       reEvaluate = /<%([\s\S]+?)%>/g,
136       reInterpolate = /<%=([\s\S]+?)%>/g;
137
138   /** Used to match property names within property paths. */
139   var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
140       reIsPlainProp = /^\w*$/,
141       reLeadingDot = /^\./,
142       rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
143
144   /**
145    * Used to match `RegExp`
146    * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
147    */
148   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
149       reHasRegExpChar = RegExp(reRegExpChar.source);
150
151   /** Used to match leading and trailing whitespace. */
152   var reTrim = /^\s+|\s+$/g,
153       reTrimStart = /^\s+/,
154       reTrimEnd = /\s+$/;
155
156   /** Used to match wrap detail comments. */
157   var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
158       reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
159       reSplitDetails = /,? & /;
160
161   /** Used to match words composed of alphanumeric characters. */
162   var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
163
164   /** Used to match backslashes in property paths. */
165   var reEscapeChar = /\\(\\)?/g;
166
167   /**
168    * Used to match
169    * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
170    */
171   var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
172
173   /** Used to match `RegExp` flags from their coerced string values. */
174   var reFlags = /\w*$/;
175
176   /** Used to detect bad signed hexadecimal string values. */
177   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
178
179   /** Used to detect binary string values. */
180   var reIsBinary = /^0b[01]+$/i;
181
182   /** Used to detect host constructors (Safari). */
183   var reIsHostCtor = /^\[object .+?Constructor\]$/;
184
185   /** Used to detect octal string values. */
186   var reIsOctal = /^0o[0-7]+$/i;
187
188   /** Used to detect unsigned integer values. */
189   var reIsUint = /^(?:0|[1-9]\d*)$/;
190
191   /** Used to match Latin Unicode letters (excluding mathematical operators). */
192   var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
193
194   /** Used to ensure capturing order of template delimiters. */
195   var reNoMatch = /($^)/;
196
197   /** Used to match unescaped characters in compiled string literals. */
198   var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
199
200   /** Used to compose unicode character classes. */
201   var rsAstralRange = '\\ud800-\\udfff',
202       rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
203       rsComboSymbolsRange = '\\u20d0-\\u20f0',
204       rsDingbatRange = '\\u2700-\\u27bf',
205       rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
206       rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
207       rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
208       rsPunctuationRange = '\\u2000-\\u206f',
209       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',
210       rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
211       rsVarRange = '\\ufe0e\\ufe0f',
212       rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
213
214   /** Used to compose unicode capture groups. */
215   var rsApos = "['\u2019]",
216       rsAstral = '[' + rsAstralRange + ']',
217       rsBreak = '[' + rsBreakRange + ']',
218       rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
219       rsDigits = '\\d+',
220       rsDingbat = '[' + rsDingbatRange + ']',
221       rsLower = '[' + rsLowerRange + ']',
222       rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
223       rsFitz = '\\ud83c[\\udffb-\\udfff]',
224       rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
225       rsNonAstral = '[^' + rsAstralRange + ']',
226       rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
227       rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
228       rsUpper = '[' + rsUpperRange + ']',
229       rsZWJ = '\\u200d';
230
231   /** Used to compose unicode regexes. */
232   var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
233       rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
234       rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
235       rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
236       reOptMod = rsModifier + '?',
237       rsOptVar = '[' + rsVarRange + ']?',
238       rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
239       rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
240       rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
241       rsSeq = rsOptVar + reOptMod + rsOptJoin,
242       rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
243       rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
244
245   /** Used to match apostrophes. */
246   var reApos = RegExp(rsApos, 'g');
247
248   /**
249    * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
250    * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
251    */
252   var reComboMark = RegExp(rsCombo, 'g');
253
254   /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
255   var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
256
257   /** Used to match complex or compound words. */
258   var reUnicodeWord = RegExp([
259     rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
260     rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
261     rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
262     rsUpper + '+' + rsOptContrUpper,
263     rsOrdUpper,
264     rsOrdLower,
265     rsDigits,
266     rsEmoji
267   ].join('|'), 'g');
268
269   /** 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/). */
270   var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange  + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
271
272   /** Used to detect strings that need a more robust regexp to match words. */
273   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 ]/;
274
275   /** Used to assign default `context` object properties. */
276   var contextProps = [
277     'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
278     'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
279     'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
280     'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
281     '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
282   ];
283
284   /** Used to make template sourceURLs easier to identify. */
285   var templateCounter = -1;
286
287   /** Used to identify `toStringTag` values of typed arrays. */
288   var typedArrayTags = {};
289   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
290   typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
291   typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
292   typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
293   typedArrayTags[uint32Tag] = true;
294   typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
295   typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
296   typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
297   typedArrayTags[errorTag] = typedArrayTags[funcTag] =
298   typedArrayTags[mapTag] = typedArrayTags[numberTag] =
299   typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
300   typedArrayTags[setTag] = typedArrayTags[stringTag] =
301   typedArrayTags[weakMapTag] = false;
302
303   /** Used to identify `toStringTag` values supported by `_.clone`. */
304   var cloneableTags = {};
305   cloneableTags[argsTag] = cloneableTags[arrayTag] =
306   cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
307   cloneableTags[boolTag] = cloneableTags[dateTag] =
308   cloneableTags[float32Tag] = cloneableTags[float64Tag] =
309   cloneableTags[int8Tag] = cloneableTags[int16Tag] =
310   cloneableTags[int32Tag] = cloneableTags[mapTag] =
311   cloneableTags[numberTag] = cloneableTags[objectTag] =
312   cloneableTags[regexpTag] = cloneableTags[setTag] =
313   cloneableTags[stringTag] = cloneableTags[symbolTag] =
314   cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
315   cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
316   cloneableTags[errorTag] = cloneableTags[funcTag] =
317   cloneableTags[weakMapTag] = false;
318
319   /** Used to map Latin Unicode letters to basic Latin letters. */
320   var deburredLetters = {
321     // Latin-1 Supplement block.
322     '\xc0': 'A',  '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
323     '\xe0': 'a',  '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
324     '\xc7': 'C',  '\xe7': 'c',
325     '\xd0': 'D',  '\xf0': 'd',
326     '\xc8': 'E',  '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
327     '\xe8': 'e',  '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
328     '\xcc': 'I',  '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
329     '\xec': 'i',  '\xed': 'i', '\xee': 'i', '\xef': 'i',
330     '\xd1': 'N',  '\xf1': 'n',
331     '\xd2': 'O',  '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
332     '\xf2': 'o',  '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
333     '\xd9': 'U',  '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
334     '\xf9': 'u',  '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
335     '\xdd': 'Y',  '\xfd': 'y', '\xff': 'y',
336     '\xc6': 'Ae', '\xe6': 'ae',
337     '\xde': 'Th', '\xfe': 'th',
338     '\xdf': 'ss',
339     // Latin Extended-A block.
340     '\u0100': 'A',  '\u0102': 'A', '\u0104': 'A',
341     '\u0101': 'a',  '\u0103': 'a', '\u0105': 'a',
342     '\u0106': 'C',  '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
343     '\u0107': 'c',  '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
344     '\u010e': 'D',  '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
345     '\u0112': 'E',  '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
346     '\u0113': 'e',  '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
347     '\u011c': 'G',  '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
348     '\u011d': 'g',  '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
349     '\u0124': 'H',  '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
350     '\u0128': 'I',  '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
351     '\u0129': 'i',  '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
352     '\u0134': 'J',  '\u0135': 'j',
353     '\u0136': 'K',  '\u0137': 'k', '\u0138': 'k',
354     '\u0139': 'L',  '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
355     '\u013a': 'l',  '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
356     '\u0143': 'N',  '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
357     '\u0144': 'n',  '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
358     '\u014c': 'O',  '\u014e': 'O', '\u0150': 'O',
359     '\u014d': 'o',  '\u014f': 'o', '\u0151': 'o',
360     '\u0154': 'R',  '\u0156': 'R', '\u0158': 'R',
361     '\u0155': 'r',  '\u0157': 'r', '\u0159': 'r',
362     '\u015a': 'S',  '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
363     '\u015b': 's',  '\u015d': 's', '\u015f': 's', '\u0161': 's',
364     '\u0162': 'T',  '\u0164': 'T', '\u0166': 'T',
365     '\u0163': 't',  '\u0165': 't', '\u0167': 't',
366     '\u0168': 'U',  '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
367     '\u0169': 'u',  '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
368     '\u0174': 'W',  '\u0175': 'w',
369     '\u0176': 'Y',  '\u0177': 'y', '\u0178': 'Y',
370     '\u0179': 'Z',  '\u017b': 'Z', '\u017d': 'Z',
371     '\u017a': 'z',  '\u017c': 'z', '\u017e': 'z',
372     '\u0132': 'IJ', '\u0133': 'ij',
373     '\u0152': 'Oe', '\u0153': 'oe',
374     '\u0149': "'n", '\u017f': 's'
375   };
376
377   /** Used to map characters to HTML entities. */
378   var htmlEscapes = {
379     '&': '&amp;',
380     '<': '&lt;',
381     '>': '&gt;',
382     '"': '&quot;',
383     "'": '&#39;'
384   };
385
386   /** Used to map HTML entities to characters. */
387   var htmlUnescapes = {
388     '&amp;': '&',
389     '&lt;': '<',
390     '&gt;': '>',
391     '&quot;': '"',
392     '&#39;': "'"
393   };
394
395   /** Used to escape characters for inclusion in compiled string literals. */
396   var stringEscapes = {
397     '\\': '\\',
398     "'": "'",
399     '\n': 'n',
400     '\r': 'r',
401     '\u2028': 'u2028',
402     '\u2029': 'u2029'
403   };
404
405   /** Built-in method references without a dependency on `root`. */
406   var freeParseFloat = parseFloat,
407       freeParseInt = parseInt;
408
409   /** Detect free variable `global` from Node.js. */
410   var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
411
412   /** Detect free variable `self`. */
413   var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
414
415   /** Used as a reference to the global object. */
416   var root = freeGlobal || freeSelf || Function('return this')();
417
418   /** Detect free variable `exports`. */
419   var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
420
421   /** Detect free variable `module`. */
422   var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
423
424   /** Detect the popular CommonJS extension `module.exports`. */
425   var moduleExports = freeModule && freeModule.exports === freeExports;
426
427   /** Detect free variable `process` from Node.js. */
428   var freeProcess = moduleExports && freeGlobal.process;
429
430   /** Used to access faster Node.js helpers. */
431   var nodeUtil = (function() {
432     try {
433       return freeProcess && freeProcess.binding('util');
434     } catch (e) {}
435   }());
436
437   /* Node.js helper references. */
438   var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
439       nodeIsDate = nodeUtil && nodeUtil.isDate,
440       nodeIsMap = nodeUtil && nodeUtil.isMap,
441       nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
442       nodeIsSet = nodeUtil && nodeUtil.isSet,
443       nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
444
445   /*--------------------------------------------------------------------------*/
446
447   /**
448    * Adds the key-value `pair` to `map`.
449    *
450    * @private
451    * @param {Object} map The map to modify.
452    * @param {Array} pair The key-value pair to add.
453    * @returns {Object} Returns `map`.
454    */
455   function addMapEntry(map, pair) {
456     // Don't return `map.set` because it's not chainable in IE 11.
457     map.set(pair[0], pair[1]);
458     return map;
459   }
460
461   /**
462    * Adds `value` to `set`.
463    *
464    * @private
465    * @param {Object} set The set to modify.
466    * @param {*} value The value to add.
467    * @returns {Object} Returns `set`.
468    */
469   function addSetEntry(set, value) {
470     // Don't return `set.add` because it's not chainable in IE 11.
471     set.add(value);
472     return set;
473   }
474
475   /**
476    * A faster alternative to `Function#apply`, this function invokes `func`
477    * with the `this` binding of `thisArg` and the arguments of `args`.
478    *
479    * @private
480    * @param {Function} func The function to invoke.
481    * @param {*} thisArg The `this` binding of `func`.
482    * @param {Array} args The arguments to invoke `func` with.
483    * @returns {*} Returns the result of `func`.
484    */
485   function apply(func, thisArg, args) {
486     switch (args.length) {
487       case 0: return func.call(thisArg);
488       case 1: return func.call(thisArg, args[0]);
489       case 2: return func.call(thisArg, args[0], args[1]);
490       case 3: return func.call(thisArg, args[0], args[1], args[2]);
491     }
492     return func.apply(thisArg, args);
493   }
494
495   /**
496    * A specialized version of `baseAggregator` for arrays.
497    *
498    * @private
499    * @param {Array} [array] The array to iterate over.
500    * @param {Function} setter The function to set `accumulator` values.
501    * @param {Function} iteratee The iteratee to transform keys.
502    * @param {Object} accumulator The initial aggregated object.
503    * @returns {Function} Returns `accumulator`.
504    */
505   function arrayAggregator(array, setter, iteratee, accumulator) {
506     var index = -1,
507         length = array == null ? 0 : array.length;
508
509     while (++index < length) {
510       var value = array[index];
511       setter(accumulator, value, iteratee(value), array);
512     }
513     return accumulator;
514   }
515
516   /**
517    * A specialized version of `_.forEach` for arrays without support for
518    * iteratee shorthands.
519    *
520    * @private
521    * @param {Array} [array] The array to iterate over.
522    * @param {Function} iteratee The function invoked per iteration.
523    * @returns {Array} Returns `array`.
524    */
525   function arrayEach(array, iteratee) {
526     var index = -1,
527         length = array == null ? 0 : array.length;
528
529     while (++index < length) {
530       if (iteratee(array[index], index, array) === false) {
531         break;
532       }
533     }
534     return array;
535   }
536
537   /**
538    * A specialized version of `_.forEachRight` for arrays without support for
539    * iteratee shorthands.
540    *
541    * @private
542    * @param {Array} [array] The array to iterate over.
543    * @param {Function} iteratee The function invoked per iteration.
544    * @returns {Array} Returns `array`.
545    */
546   function arrayEachRight(array, iteratee) {
547     var length = array == null ? 0 : array.length;
548
549     while (length--) {
550       if (iteratee(array[length], length, array) === false) {
551         break;
552       }
553     }
554     return array;
555   }
556
557   /**
558    * A specialized version of `_.every` for arrays without support for
559    * iteratee shorthands.
560    *
561    * @private
562    * @param {Array} [array] The array to iterate over.
563    * @param {Function} predicate The function invoked per iteration.
564    * @returns {boolean} Returns `true` if all elements pass the predicate check,
565    *  else `false`.
566    */
567   function arrayEvery(array, predicate) {
568     var index = -1,
569         length = array == null ? 0 : array.length;
570
571     while (++index < length) {
572       if (!predicate(array[index], index, array)) {
573         return false;
574       }
575     }
576     return true;
577   }
578
579   /**
580    * A specialized version of `_.filter` for arrays without support for
581    * iteratee shorthands.
582    *
583    * @private
584    * @param {Array} [array] The array to iterate over.
585    * @param {Function} predicate The function invoked per iteration.
586    * @returns {Array} Returns the new filtered array.
587    */
588   function arrayFilter(array, predicate) {
589     var index = -1,
590         length = array == null ? 0 : array.length,
591         resIndex = 0,
592         result = [];
593
594     while (++index < length) {
595       var value = array[index];
596       if (predicate(value, index, array)) {
597         result[resIndex++] = value;
598       }
599     }
600     return result;
601   }
602
603   /**
604    * A specialized version of `_.includes` for arrays without support for
605    * specifying an index to search from.
606    *
607    * @private
608    * @param {Array} [array] The array to inspect.
609    * @param {*} target The value to search for.
610    * @returns {boolean} Returns `true` if `target` is found, else `false`.
611    */
612   function arrayIncludes(array, value) {
613     var length = array == null ? 0 : array.length;
614     return !!length && baseIndexOf(array, value, 0) > -1;
615   }
616
617   /**
618    * This function is like `arrayIncludes` except that it accepts a comparator.
619    *
620    * @private
621    * @param {Array} [array] The array to inspect.
622    * @param {*} target The value to search for.
623    * @param {Function} comparator The comparator invoked per element.
624    * @returns {boolean} Returns `true` if `target` is found, else `false`.
625    */
626   function arrayIncludesWith(array, value, comparator) {
627     var index = -1,
628         length = array == null ? 0 : array.length;
629
630     while (++index < length) {
631       if (comparator(value, array[index])) {
632         return true;
633       }
634     }
635     return false;
636   }
637
638   /**
639    * A specialized version of `_.map` for arrays without support for iteratee
640    * shorthands.
641    *
642    * @private
643    * @param {Array} [array] The array to iterate over.
644    * @param {Function} iteratee The function invoked per iteration.
645    * @returns {Array} Returns the new mapped array.
646    */
647   function arrayMap(array, iteratee) {
648     var index = -1,
649         length = array == null ? 0 : array.length,
650         result = Array(length);
651
652     while (++index < length) {
653       result[index] = iteratee(array[index], index, array);
654     }
655     return result;
656   }
657
658   /**
659    * Appends the elements of `values` to `array`.
660    *
661    * @private
662    * @param {Array} array The array to modify.
663    * @param {Array} values The values to append.
664    * @returns {Array} Returns `array`.
665    */
666   function arrayPush(array, values) {
667     var index = -1,
668         length = values.length,
669         offset = array.length;
670
671     while (++index < length) {
672       array[offset + index] = values[index];
673     }
674     return array;
675   }
676
677   /**
678    * A specialized version of `_.reduce` for arrays without support for
679    * iteratee shorthands.
680    *
681    * @private
682    * @param {Array} [array] The array to iterate over.
683    * @param {Function} iteratee The function invoked per iteration.
684    * @param {*} [accumulator] The initial value.
685    * @param {boolean} [initAccum] Specify using the first element of `array` as
686    *  the initial value.
687    * @returns {*} Returns the accumulated value.
688    */
689   function arrayReduce(array, iteratee, accumulator, initAccum) {
690     var index = -1,
691         length = array == null ? 0 : array.length;
692
693     if (initAccum && length) {
694       accumulator = array[++index];
695     }
696     while (++index < length) {
697       accumulator = iteratee(accumulator, array[index], index, array);
698     }
699     return accumulator;
700   }
701
702   /**
703    * A specialized version of `_.reduceRight` for arrays without support for
704    * iteratee shorthands.
705    *
706    * @private
707    * @param {Array} [array] The array to iterate over.
708    * @param {Function} iteratee The function invoked per iteration.
709    * @param {*} [accumulator] The initial value.
710    * @param {boolean} [initAccum] Specify using the last element of `array` as
711    *  the initial value.
712    * @returns {*} Returns the accumulated value.
713    */
714   function arrayReduceRight(array, iteratee, accumulator, initAccum) {
715     var length = array == null ? 0 : array.length;
716     if (initAccum && length) {
717       accumulator = array[--length];
718     }
719     while (length--) {
720       accumulator = iteratee(accumulator, array[length], length, array);
721     }
722     return accumulator;
723   }
724
725   /**
726    * A specialized version of `_.some` for arrays without support for iteratee
727    * shorthands.
728    *
729    * @private
730    * @param {Array} [array] The array to iterate over.
731    * @param {Function} predicate The function invoked per iteration.
732    * @returns {boolean} Returns `true` if any element passes the predicate check,
733    *  else `false`.
734    */
735   function arraySome(array, predicate) {
736     var index = -1,
737         length = array == null ? 0 : array.length;
738
739     while (++index < length) {
740       if (predicate(array[index], index, array)) {
741         return true;
742       }
743     }
744     return false;
745   }
746
747   /**
748    * Gets the size of an ASCII `string`.
749    *
750    * @private
751    * @param {string} string The string inspect.
752    * @returns {number} Returns the string size.
753    */
754   var asciiSize = baseProperty('length');
755
756   /**
757    * Converts an ASCII `string` to an array.
758    *
759    * @private
760    * @param {string} string The string to convert.
761    * @returns {Array} Returns the converted array.
762    */
763   function asciiToArray(string) {
764     return string.split('');
765   }
766
767   /**
768    * Splits an ASCII `string` into an array of its words.
769    *
770    * @private
771    * @param {string} The string to inspect.
772    * @returns {Array} Returns the words of `string`.
773    */
774   function asciiWords(string) {
775     return string.match(reAsciiWord) || [];
776   }
777
778   /**
779    * The base implementation of methods like `_.findKey` and `_.findLastKey`,
780    * without support for iteratee shorthands, which iterates over `collection`
781    * using `eachFunc`.
782    *
783    * @private
784    * @param {Array|Object} collection The collection to inspect.
785    * @param {Function} predicate The function invoked per iteration.
786    * @param {Function} eachFunc The function to iterate over `collection`.
787    * @returns {*} Returns the found element or its key, else `undefined`.
788    */
789   function baseFindKey(collection, predicate, eachFunc) {
790     var result;
791     eachFunc(collection, function(value, key, collection) {
792       if (predicate(value, key, collection)) {
793         result = key;
794         return false;
795       }
796     });
797     return result;
798   }
799
800   /**
801    * The base implementation of `_.findIndex` and `_.findLastIndex` without
802    * support for iteratee shorthands.
803    *
804    * @private
805    * @param {Array} array The array to inspect.
806    * @param {Function} predicate The function invoked per iteration.
807    * @param {number} fromIndex The index to search from.
808    * @param {boolean} [fromRight] Specify iterating from right to left.
809    * @returns {number} Returns the index of the matched value, else `-1`.
810    */
811   function baseFindIndex(array, predicate, fromIndex, fromRight) {
812     var length = array.length,
813         index = fromIndex + (fromRight ? 1 : -1);
814
815     while ((fromRight ? index-- : ++index < length)) {
816       if (predicate(array[index], index, array)) {
817         return index;
818       }
819     }
820     return -1;
821   }
822
823   /**
824    * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
825    *
826    * @private
827    * @param {Array} array The array to inspect.
828    * @param {*} value The value to search for.
829    * @param {number} fromIndex The index to search from.
830    * @returns {number} Returns the index of the matched value, else `-1`.
831    */
832   function baseIndexOf(array, value, fromIndex) {
833     return value === value
834       ? strictIndexOf(array, value, fromIndex)
835       : baseFindIndex(array, baseIsNaN, fromIndex);
836   }
837
838   /**
839    * This function is like `baseIndexOf` except that it accepts a comparator.
840    *
841    * @private
842    * @param {Array} array The array to inspect.
843    * @param {*} value The value to search for.
844    * @param {number} fromIndex The index to search from.
845    * @param {Function} comparator The comparator invoked per element.
846    * @returns {number} Returns the index of the matched value, else `-1`.
847    */
848   function baseIndexOfWith(array, value, fromIndex, comparator) {
849     var index = fromIndex - 1,
850         length = array.length;
851
852     while (++index < length) {
853       if (comparator(array[index], value)) {
854         return index;
855       }
856     }
857     return -1;
858   }
859
860   /**
861    * The base implementation of `_.isNaN` without support for number objects.
862    *
863    * @private
864    * @param {*} value The value to check.
865    * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
866    */
867   function baseIsNaN(value) {
868     return value !== value;
869   }
870
871   /**
872    * The base implementation of `_.mean` and `_.meanBy` without support for
873    * iteratee shorthands.
874    *
875    * @private
876    * @param {Array} array The array to iterate over.
877    * @param {Function} iteratee The function invoked per iteration.
878    * @returns {number} Returns the mean.
879    */
880   function baseMean(array, iteratee) {
881     var length = array == null ? 0 : array.length;
882     return length ? (baseSum(array, iteratee) / length) : NAN;
883   }
884
885   /**
886    * The base implementation of `_.property` without support for deep paths.
887    *
888    * @private
889    * @param {string} key The key of the property to get.
890    * @returns {Function} Returns the new accessor function.
891    */
892   function baseProperty(key) {
893     return function(object) {
894       return object == null ? undefined : object[key];
895     };
896   }
897
898   /**
899    * The base implementation of `_.propertyOf` without support for deep paths.
900    *
901    * @private
902    * @param {Object} object The object to query.
903    * @returns {Function} Returns the new accessor function.
904    */
905   function basePropertyOf(object) {
906     return function(key) {
907       return object == null ? undefined : object[key];
908     };
909   }
910
911   /**
912    * The base implementation of `_.reduce` and `_.reduceRight`, without support
913    * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
914    *
915    * @private
916    * @param {Array|Object} collection The collection to iterate over.
917    * @param {Function} iteratee The function invoked per iteration.
918    * @param {*} accumulator The initial value.
919    * @param {boolean} initAccum Specify using the first or last element of
920    *  `collection` as the initial value.
921    * @param {Function} eachFunc The function to iterate over `collection`.
922    * @returns {*} Returns the accumulated value.
923    */
924   function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
925     eachFunc(collection, function(value, index, collection) {
926       accumulator = initAccum
927         ? (initAccum = false, value)
928         : iteratee(accumulator, value, index, collection);
929     });
930     return accumulator;
931   }
932
933   /**
934    * The base implementation of `_.sortBy` which uses `comparer` to define the
935    * sort order of `array` and replaces criteria objects with their corresponding
936    * values.
937    *
938    * @private
939    * @param {Array} array The array to sort.
940    * @param {Function} comparer The function to define sort order.
941    * @returns {Array} Returns `array`.
942    */
943   function baseSortBy(array, comparer) {
944     var length = array.length;
945
946     array.sort(comparer);
947     while (length--) {
948       array[length] = array[length].value;
949     }
950     return array;
951   }
952
953   /**
954    * The base implementation of `_.sum` and `_.sumBy` without support for
955    * iteratee shorthands.
956    *
957    * @private
958    * @param {Array} array The array to iterate over.
959    * @param {Function} iteratee The function invoked per iteration.
960    * @returns {number} Returns the sum.
961    */
962   function baseSum(array, iteratee) {
963     var result,
964         index = -1,
965         length = array.length;
966
967     while (++index < length) {
968       var current = iteratee(array[index]);
969       if (current !== undefined) {
970         result = result === undefined ? current : (result + current);
971       }
972     }
973     return result;
974   }
975
976   /**
977    * The base implementation of `_.times` without support for iteratee shorthands
978    * or max array length checks.
979    *
980    * @private
981    * @param {number} n The number of times to invoke `iteratee`.
982    * @param {Function} iteratee The function invoked per iteration.
983    * @returns {Array} Returns the array of results.
984    */
985   function baseTimes(n, iteratee) {
986     var index = -1,
987         result = Array(n);
988
989     while (++index < n) {
990       result[index] = iteratee(index);
991     }
992     return result;
993   }
994
995   /**
996    * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
997    * of key-value pairs for `object` corresponding to the property names of `props`.
998    *
999    * @private
1000    * @param {Object} object The object to query.
1001    * @param {Array} props The property names to get values for.
1002    * @returns {Object} Returns the key-value pairs.
1003    */
1004   function baseToPairs(object, props) {
1005     return arrayMap(props, function(key) {
1006       return [key, object[key]];
1007     });
1008   }
1009
1010   /**
1011    * The base implementation of `_.unary` without support for storing metadata.
1012    *
1013    * @private
1014    * @param {Function} func The function to cap arguments for.
1015    * @returns {Function} Returns the new capped function.
1016    */
1017   function baseUnary(func) {
1018     return function(value) {
1019       return func(value);
1020     };
1021   }
1022
1023   /**
1024    * The base implementation of `_.values` and `_.valuesIn` which creates an
1025    * array of `object` property values corresponding to the property names
1026    * of `props`.
1027    *
1028    * @private
1029    * @param {Object} object The object to query.
1030    * @param {Array} props The property names to get values for.
1031    * @returns {Object} Returns the array of property values.
1032    */
1033   function baseValues(object, props) {
1034     return arrayMap(props, function(key) {
1035       return object[key];
1036     });
1037   }
1038
1039   /**
1040    * Checks if a `cache` value for `key` exists.
1041    *
1042    * @private
1043    * @param {Object} cache The cache to query.
1044    * @param {string} key The key of the entry to check.
1045    * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1046    */
1047   function cacheHas(cache, key) {
1048     return cache.has(key);
1049   }
1050
1051   /**
1052    * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1053    * that is not found in the character symbols.
1054    *
1055    * @private
1056    * @param {Array} strSymbols The string symbols to inspect.
1057    * @param {Array} chrSymbols The character symbols to find.
1058    * @returns {number} Returns the index of the first unmatched string symbol.
1059    */
1060   function charsStartIndex(strSymbols, chrSymbols) {
1061     var index = -1,
1062         length = strSymbols.length;
1063
1064     while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1065     return index;
1066   }
1067
1068   /**
1069    * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1070    * that is not found in the character symbols.
1071    *
1072    * @private
1073    * @param {Array} strSymbols The string symbols to inspect.
1074    * @param {Array} chrSymbols The character symbols to find.
1075    * @returns {number} Returns the index of the last unmatched string symbol.
1076    */
1077   function charsEndIndex(strSymbols, chrSymbols) {
1078     var index = strSymbols.length;
1079
1080     while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1081     return index;
1082   }
1083
1084   /**
1085    * Gets the number of `placeholder` occurrences in `array`.
1086    *
1087    * @private
1088    * @param {Array} array The array to inspect.
1089    * @param {*} placeholder The placeholder to search for.
1090    * @returns {number} Returns the placeholder count.
1091    */
1092   function countHolders(array, placeholder) {
1093     var length = array.length,
1094         result = 0;
1095
1096     while (length--) {
1097       if (array[length] === placeholder) {
1098         ++result;
1099       }
1100     }
1101     return result;
1102   }
1103
1104   /**
1105    * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1106    * letters to basic Latin letters.
1107    *
1108    * @private
1109    * @param {string} letter The matched letter to deburr.
1110    * @returns {string} Returns the deburred letter.
1111    */
1112   var deburrLetter = basePropertyOf(deburredLetters);
1113
1114   /**
1115    * Used by `_.escape` to convert characters to HTML entities.
1116    *
1117    * @private
1118    * @param {string} chr The matched character to escape.
1119    * @returns {string} Returns the escaped character.
1120    */
1121   var escapeHtmlChar = basePropertyOf(htmlEscapes);
1122
1123   /**
1124    * Used by `_.template` to escape characters for inclusion in compiled string literals.
1125    *
1126    * @private
1127    * @param {string} chr The matched character to escape.
1128    * @returns {string} Returns the escaped character.
1129    */
1130   function escapeStringChar(chr) {
1131     return '\\' + stringEscapes[chr];
1132   }
1133
1134   /**
1135    * Gets the value at `key` of `object`.
1136    *
1137    * @private
1138    * @param {Object} [object] The object to query.
1139    * @param {string} key The key of the property to get.
1140    * @returns {*} Returns the property value.
1141    */
1142   function getValue(object, key) {
1143     return object == null ? undefined : object[key];
1144   }
1145
1146   /**
1147    * Checks if `string` contains Unicode symbols.
1148    *
1149    * @private
1150    * @param {string} string The string to inspect.
1151    * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1152    */
1153   function hasUnicode(string) {
1154     return reHasUnicode.test(string);
1155   }
1156
1157   /**
1158    * Checks if `string` contains a word composed of Unicode symbols.
1159    *
1160    * @private
1161    * @param {string} string The string to inspect.
1162    * @returns {boolean} Returns `true` if a word is found, else `false`.
1163    */
1164   function hasUnicodeWord(string) {
1165     return reHasUnicodeWord.test(string);
1166   }
1167
1168   /**
1169    * Converts `iterator` to an array.
1170    *
1171    * @private
1172    * @param {Object} iterator The iterator to convert.
1173    * @returns {Array} Returns the converted array.
1174    */
1175   function iteratorToArray(iterator) {
1176     var data,
1177         result = [];
1178
1179     while (!(data = iterator.next()).done) {
1180       result.push(data.value);
1181     }
1182     return result;
1183   }
1184
1185   /**
1186    * Converts `map` to its key-value pairs.
1187    *
1188    * @private
1189    * @param {Object} map The map to convert.
1190    * @returns {Array} Returns the key-value pairs.
1191    */
1192   function mapToArray(map) {
1193     var index = -1,
1194         result = Array(map.size);
1195
1196     map.forEach(function(value, key) {
1197       result[++index] = [key, value];
1198     });
1199     return result;
1200   }
1201
1202   /**
1203    * Creates a unary function that invokes `func` with its argument transformed.
1204    *
1205    * @private
1206    * @param {Function} func The function to wrap.
1207    * @param {Function} transform The argument transform.
1208    * @returns {Function} Returns the new function.
1209    */
1210   function overArg(func, transform) {
1211     return function(arg) {
1212       return func(transform(arg));
1213     };
1214   }
1215
1216   /**
1217    * Replaces all `placeholder` elements in `array` with an internal placeholder
1218    * and returns an array of their indexes.
1219    *
1220    * @private
1221    * @param {Array} array The array to modify.
1222    * @param {*} placeholder The placeholder to replace.
1223    * @returns {Array} Returns the new array of placeholder indexes.
1224    */
1225   function replaceHolders(array, placeholder) {
1226     var index = -1,
1227         length = array.length,
1228         resIndex = 0,
1229         result = [];
1230
1231     while (++index < length) {
1232       var value = array[index];
1233       if (value === placeholder || value === PLACEHOLDER) {
1234         array[index] = PLACEHOLDER;
1235         result[resIndex++] = index;
1236       }
1237     }
1238     return result;
1239   }
1240
1241   /**
1242    * Converts `set` to an array of its values.
1243    *
1244    * @private
1245    * @param {Object} set The set to convert.
1246    * @returns {Array} Returns the values.
1247    */
1248   function setToArray(set) {
1249     var index = -1,
1250         result = Array(set.size);
1251
1252     set.forEach(function(value) {
1253       result[++index] = value;
1254     });
1255     return result;
1256   }
1257
1258   /**
1259    * Converts `set` to its value-value pairs.
1260    *
1261    * @private
1262    * @param {Object} set The set to convert.
1263    * @returns {Array} Returns the value-value pairs.
1264    */
1265   function setToPairs(set) {
1266     var index = -1,
1267         result = Array(set.size);
1268
1269     set.forEach(function(value) {
1270       result[++index] = [value, value];
1271     });
1272     return result;
1273   }
1274
1275   /**
1276    * A specialized version of `_.indexOf` which performs strict equality
1277    * comparisons of values, i.e. `===`.
1278    *
1279    * @private
1280    * @param {Array} array The array to inspect.
1281    * @param {*} value The value to search for.
1282    * @param {number} fromIndex The index to search from.
1283    * @returns {number} Returns the index of the matched value, else `-1`.
1284    */
1285   function strictIndexOf(array, value, fromIndex) {
1286     var index = fromIndex - 1,
1287         length = array.length;
1288
1289     while (++index < length) {
1290       if (array[index] === value) {
1291         return index;
1292       }
1293     }
1294     return -1;
1295   }
1296
1297   /**
1298    * A specialized version of `_.lastIndexOf` which performs strict equality
1299    * comparisons of values, i.e. `===`.
1300    *
1301    * @private
1302    * @param {Array} array The array to inspect.
1303    * @param {*} value The value to search for.
1304    * @param {number} fromIndex The index to search from.
1305    * @returns {number} Returns the index of the matched value, else `-1`.
1306    */
1307   function strictLastIndexOf(array, value, fromIndex) {
1308     var index = fromIndex + 1;
1309     while (index--) {
1310       if (array[index] === value) {
1311         return index;
1312       }
1313     }
1314     return index;
1315   }
1316
1317   /**
1318    * Gets the number of symbols in `string`.
1319    *
1320    * @private
1321    * @param {string} string The string to inspect.
1322    * @returns {number} Returns the string size.
1323    */
1324   function stringSize(string) {
1325     return hasUnicode(string)
1326       ? unicodeSize(string)
1327       : asciiSize(string);
1328   }
1329
1330   /**
1331    * Converts `string` to an array.
1332    *
1333    * @private
1334    * @param {string} string The string to convert.
1335    * @returns {Array} Returns the converted array.
1336    */
1337   function stringToArray(string) {
1338     return hasUnicode(string)
1339       ? unicodeToArray(string)
1340       : asciiToArray(string);
1341   }
1342
1343   /**
1344    * Used by `_.unescape` to convert HTML entities to characters.
1345    *
1346    * @private
1347    * @param {string} chr The matched character to unescape.
1348    * @returns {string} Returns the unescaped character.
1349    */
1350   var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1351
1352   /**
1353    * Gets the size of a Unicode `string`.
1354    *
1355    * @private
1356    * @param {string} string The string inspect.
1357    * @returns {number} Returns the string size.
1358    */
1359   function unicodeSize(string) {
1360     var result = reUnicode.lastIndex = 0;
1361     while (reUnicode.test(string)) {
1362       ++result;
1363     }
1364     return result;
1365   }
1366
1367   /**
1368    * Converts a Unicode `string` to an array.
1369    *
1370    * @private
1371    * @param {string} string The string to convert.
1372    * @returns {Array} Returns the converted array.
1373    */
1374   function unicodeToArray(string) {
1375     return string.match(reUnicode) || [];
1376   }
1377
1378   /**
1379    * Splits a Unicode `string` into an array of its words.
1380    *
1381    * @private
1382    * @param {string} The string to inspect.
1383    * @returns {Array} Returns the words of `string`.
1384    */
1385   function unicodeWords(string) {
1386     return string.match(reUnicodeWord) || [];
1387   }
1388
1389   /*--------------------------------------------------------------------------*/
1390
1391   /**
1392    * Create a new pristine `lodash` function using the `context` object.
1393    *
1394    * @static
1395    * @memberOf _
1396    * @since 1.1.0
1397    * @category Util
1398    * @param {Object} [context=root] The context object.
1399    * @returns {Function} Returns a new `lodash` function.
1400    * @example
1401    *
1402    * _.mixin({ 'foo': _.constant('foo') });
1403    *
1404    * var lodash = _.runInContext();
1405    * lodash.mixin({ 'bar': lodash.constant('bar') });
1406    *
1407    * _.isFunction(_.foo);
1408    * // => true
1409    * _.isFunction(_.bar);
1410    * // => false
1411    *
1412    * lodash.isFunction(lodash.foo);
1413    * // => false
1414    * lodash.isFunction(lodash.bar);
1415    * // => true
1416    *
1417    * // Create a suped-up `defer` in Node.js.
1418    * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1419    */
1420   var runInContext = (function runInContext(context) {
1421     context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1422
1423     /** Built-in constructor references. */
1424     var Array = context.Array,
1425         Date = context.Date,
1426         Error = context.Error,
1427         Function = context.Function,
1428         Math = context.Math,
1429         Object = context.Object,
1430         RegExp = context.RegExp,
1431         String = context.String,
1432         TypeError = context.TypeError;
1433
1434     /** Used for built-in method references. */
1435     var arrayProto = Array.prototype,
1436         funcProto = Function.prototype,
1437         objectProto = Object.prototype;
1438
1439     /** Used to detect overreaching core-js shims. */
1440     var coreJsData = context['__core-js_shared__'];
1441
1442     /** Used to resolve the decompiled source of functions. */
1443     var funcToString = funcProto.toString;
1444
1445     /** Used to check objects for own properties. */
1446     var hasOwnProperty = objectProto.hasOwnProperty;
1447
1448     /** Used to generate unique IDs. */
1449     var idCounter = 0;
1450
1451     /** Used to detect methods masquerading as native. */
1452     var maskSrcKey = (function() {
1453       var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1454       return uid ? ('Symbol(src)_1.' + uid) : '';
1455     }());
1456
1457     /**
1458      * Used to resolve the
1459      * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1460      * of values.
1461      */
1462     var nativeObjectToString = objectProto.toString;
1463
1464     /** Used to infer the `Object` constructor. */
1465     var objectCtorString = funcToString.call(Object);
1466
1467     /** Used to restore the original `_` reference in `_.noConflict`. */
1468     var oldDash = root._;
1469
1470     /** Used to detect if a method is native. */
1471     var reIsNative = RegExp('^' +
1472       funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1473       .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1474     );
1475
1476     /** Built-in value references. */
1477     var Buffer = moduleExports ? context.Buffer : undefined,
1478         Symbol = context.Symbol,
1479         Uint8Array = context.Uint8Array,
1480         allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
1481         getPrototype = overArg(Object.getPrototypeOf, Object),
1482         objectCreate = Object.create,
1483         propertyIsEnumerable = objectProto.propertyIsEnumerable,
1484         splice = arrayProto.splice,
1485         spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
1486         symIterator = Symbol ? Symbol.iterator : undefined,
1487         symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1488
1489     var defineProperty = (function() {
1490       try {
1491         var func = getNative(Object, 'defineProperty');
1492         func({}, '', {});
1493         return func;
1494       } catch (e) {}
1495     }());
1496
1497     /** Mocked built-ins. */
1498     var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
1499         ctxNow = Date && Date.now !== root.Date.now && Date.now,
1500         ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1501
1502     /* Built-in method references for those with the same name as other `lodash` methods. */
1503     var nativeCeil = Math.ceil,
1504         nativeFloor = Math.floor,
1505         nativeGetSymbols = Object.getOwnPropertySymbols,
1506         nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
1507         nativeIsFinite = context.isFinite,
1508         nativeJoin = arrayProto.join,
1509         nativeKeys = overArg(Object.keys, Object),
1510         nativeMax = Math.max,
1511         nativeMin = Math.min,
1512         nativeNow = Date.now,
1513         nativeParseInt = context.parseInt,
1514         nativeRandom = Math.random,
1515         nativeReverse = arrayProto.reverse;
1516
1517     /* Built-in method references that are verified to be native. */
1518     var DataView = getNative(context, 'DataView'),
1519         Map = getNative(context, 'Map'),
1520         Promise = getNative(context, 'Promise'),
1521         Set = getNative(context, 'Set'),
1522         WeakMap = getNative(context, 'WeakMap'),
1523         nativeCreate = getNative(Object, 'create');
1524
1525     /** Used to store function metadata. */
1526     var metaMap = WeakMap && new WeakMap;
1527
1528     /** Used to lookup unminified function names. */
1529     var realNames = {};
1530
1531     /** Used to detect maps, sets, and weakmaps. */
1532     var dataViewCtorString = toSource(DataView),
1533         mapCtorString = toSource(Map),
1534         promiseCtorString = toSource(Promise),
1535         setCtorString = toSource(Set),
1536         weakMapCtorString = toSource(WeakMap);
1537
1538     /** Used to convert symbols to primitives and strings. */
1539     var symbolProto = Symbol ? Symbol.prototype : undefined,
1540         symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
1541         symbolToString = symbolProto ? symbolProto.toString : undefined;
1542
1543     /*------------------------------------------------------------------------*/
1544
1545     /**
1546      * Creates a `lodash` object which wraps `value` to enable implicit method
1547      * chain sequences. Methods that operate on and return arrays, collections,
1548      * and functions can be chained together. Methods that retrieve a single value
1549      * or may return a primitive value will automatically end the chain sequence
1550      * and return the unwrapped value. Otherwise, the value must be unwrapped
1551      * with `_#value`.
1552      *
1553      * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1554      * enabled using `_.chain`.
1555      *
1556      * The execution of chained methods is lazy, that is, it's deferred until
1557      * `_#value` is implicitly or explicitly called.
1558      *
1559      * Lazy evaluation allows several methods to support shortcut fusion.
1560      * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1561      * the creation of intermediate arrays and can greatly reduce the number of
1562      * iteratee executions. Sections of a chain sequence qualify for shortcut
1563      * fusion if the section is applied to an array of at least `200` elements
1564      * and any iteratees accept only one argument. The heuristic for whether a
1565      * section qualifies for shortcut fusion is subject to change.
1566      *
1567      * Chaining is supported in custom builds as long as the `_#value` method is
1568      * directly or indirectly included in the build.
1569      *
1570      * In addition to lodash methods, wrappers have `Array` and `String` methods.
1571      *
1572      * The wrapper `Array` methods are:
1573      * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1574      *
1575      * The wrapper `String` methods are:
1576      * `replace` and `split`
1577      *
1578      * The wrapper methods that support shortcut fusion are:
1579      * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1580      * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1581      * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1582      *
1583      * The chainable wrapper methods are:
1584      * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1585      * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1586      * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1587      * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1588      * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1589      * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1590      * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1591      * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1592      * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1593      * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1594      * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1595      * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1596      * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1597      * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1598      * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1599      * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1600      * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1601      * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1602      * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1603      * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1604      * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1605      * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1606      * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1607      * `zipObject`, `zipObjectDeep`, and `zipWith`
1608      *
1609      * The wrapper methods that are **not** chainable by default are:
1610      * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1611      * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
1612      * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
1613      * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
1614      * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
1615      * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
1616      * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
1617      * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
1618      * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
1619      * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
1620      * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
1621      * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
1622      * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
1623      * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
1624      * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
1625      * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
1626      * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
1627      * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
1628      * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
1629      * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
1630      * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
1631      * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
1632      * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
1633      * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
1634      * `upperFirst`, `value`, and `words`
1635      *
1636      * @name _
1637      * @constructor
1638      * @category Seq
1639      * @param {*} value The value to wrap in a `lodash` instance.
1640      * @returns {Object} Returns the new `lodash` wrapper instance.
1641      * @example
1642      *
1643      * function square(n) {
1644      *   return n * n;
1645      * }
1646      *
1647      * var wrapped = _([1, 2, 3]);
1648      *
1649      * // Returns an unwrapped value.
1650      * wrapped.reduce(_.add);
1651      * // => 6
1652      *
1653      * // Returns a wrapped value.
1654      * var squares = wrapped.map(square);
1655      *
1656      * _.isArray(squares);
1657      * // => false
1658      *
1659      * _.isArray(squares.value());
1660      * // => true
1661      */
1662     function lodash(value) {
1663       if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1664         if (value instanceof LodashWrapper) {
1665           return value;
1666         }
1667         if (hasOwnProperty.call(value, '__wrapped__')) {
1668           return wrapperClone(value);
1669         }
1670       }
1671       return new LodashWrapper(value);
1672     }
1673
1674     /**
1675      * The base implementation of `_.create` without support for assigning
1676      * properties to the created object.
1677      *
1678      * @private
1679      * @param {Object} proto The object to inherit from.
1680      * @returns {Object} Returns the new object.
1681      */
1682     var baseCreate = (function() {
1683       function object() {}
1684       return function(proto) {
1685         if (!isObject(proto)) {
1686           return {};
1687         }
1688         if (objectCreate) {
1689           return objectCreate(proto);
1690         }
1691         object.prototype = proto;
1692         var result = new object;
1693         object.prototype = undefined;
1694         return result;
1695       };
1696     }());
1697
1698     /**
1699      * The function whose prototype chain sequence wrappers inherit from.
1700      *
1701      * @private
1702      */
1703     function baseLodash() {
1704       // No operation performed.
1705     }
1706
1707     /**
1708      * The base constructor for creating `lodash` wrapper objects.
1709      *
1710      * @private
1711      * @param {*} value The value to wrap.
1712      * @param {boolean} [chainAll] Enable explicit method chain sequences.
1713      */
1714     function LodashWrapper(value, chainAll) {
1715       this.__wrapped__ = value;
1716       this.__actions__ = [];
1717       this.__chain__ = !!chainAll;
1718       this.__index__ = 0;
1719       this.__values__ = undefined;
1720     }
1721
1722     /**
1723      * By default, the template delimiters used by lodash are like those in
1724      * embedded Ruby (ERB). Change the following template settings to use
1725      * alternative delimiters.
1726      *
1727      * @static
1728      * @memberOf _
1729      * @type {Object}
1730      */
1731     lodash.templateSettings = {
1732
1733       /**
1734        * Used to detect `data` property values to be HTML-escaped.
1735        *
1736        * @memberOf _.templateSettings
1737        * @type {RegExp}
1738        */
1739       'escape': reEscape,
1740
1741       /**
1742        * Used to detect code to be evaluated.
1743        *
1744        * @memberOf _.templateSettings
1745        * @type {RegExp}
1746        */
1747       'evaluate': reEvaluate,
1748
1749       /**
1750        * Used to detect `data` property values to inject.
1751        *
1752        * @memberOf _.templateSettings
1753        * @type {RegExp}
1754        */
1755       'interpolate': reInterpolate,
1756
1757       /**
1758        * Used to reference the data object in the template text.
1759        *
1760        * @memberOf _.templateSettings
1761        * @type {string}
1762        */
1763       'variable': '',
1764
1765       /**
1766        * Used to import variables into the compiled template.
1767        *
1768        * @memberOf _.templateSettings
1769        * @type {Object}
1770        */
1771       'imports': {
1772
1773         /**
1774          * A reference to the `lodash` function.
1775          *
1776          * @memberOf _.templateSettings.imports
1777          * @type {Function}
1778          */
1779         '_': lodash
1780       }
1781     };
1782
1783     // Ensure wrappers are instances of `baseLodash`.
1784     lodash.prototype = baseLodash.prototype;
1785     lodash.prototype.constructor = lodash;
1786
1787     LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1788     LodashWrapper.prototype.constructor = LodashWrapper;
1789
1790     /*------------------------------------------------------------------------*/
1791
1792     /**
1793      * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1794      *
1795      * @private
1796      * @constructor
1797      * @param {*} value The value to wrap.
1798      */
1799     function LazyWrapper(value) {
1800       this.__wrapped__ = value;
1801       this.__actions__ = [];
1802       this.__dir__ = 1;
1803       this.__filtered__ = false;
1804       this.__iteratees__ = [];
1805       this.__takeCount__ = MAX_ARRAY_LENGTH;
1806       this.__views__ = [];
1807     }
1808
1809     /**
1810      * Creates a clone of the lazy wrapper object.
1811      *
1812      * @private
1813      * @name clone
1814      * @memberOf LazyWrapper
1815      * @returns {Object} Returns the cloned `LazyWrapper` object.
1816      */
1817     function lazyClone() {
1818       var result = new LazyWrapper(this.__wrapped__);
1819       result.__actions__ = copyArray(this.__actions__);
1820       result.__dir__ = this.__dir__;
1821       result.__filtered__ = this.__filtered__;
1822       result.__iteratees__ = copyArray(this.__iteratees__);
1823       result.__takeCount__ = this.__takeCount__;
1824       result.__views__ = copyArray(this.__views__);
1825       return result;
1826     }
1827
1828     /**
1829      * Reverses the direction of lazy iteration.
1830      *
1831      * @private
1832      * @name reverse
1833      * @memberOf LazyWrapper
1834      * @returns {Object} Returns the new reversed `LazyWrapper` object.
1835      */
1836     function lazyReverse() {
1837       if (this.__filtered__) {
1838         var result = new LazyWrapper(this);
1839         result.__dir__ = -1;
1840         result.__filtered__ = true;
1841       } else {
1842         result = this.clone();
1843         result.__dir__ *= -1;
1844       }
1845       return result;
1846     }
1847
1848     /**
1849      * Extracts the unwrapped value from its lazy wrapper.
1850      *
1851      * @private
1852      * @name value
1853      * @memberOf LazyWrapper
1854      * @returns {*} Returns the unwrapped value.
1855      */
1856     function lazyValue() {
1857       var array = this.__wrapped__.value(),
1858           dir = this.__dir__,
1859           isArr = isArray(array),
1860           isRight = dir < 0,
1861           arrLength = isArr ? array.length : 0,
1862           view = getView(0, arrLength, this.__views__),
1863           start = view.start,
1864           end = view.end,
1865           length = end - start,
1866           index = isRight ? end : (start - 1),
1867           iteratees = this.__iteratees__,
1868           iterLength = iteratees.length,
1869           resIndex = 0,
1870           takeCount = nativeMin(length, this.__takeCount__);
1871
1872       if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
1873           (arrLength == length && takeCount == length)) {
1874         return baseWrapperValue(array, this.__actions__);
1875       }
1876       var result = [];
1877
1878       outer:
1879       while (length-- && resIndex < takeCount) {
1880         index += dir;
1881
1882         var iterIndex = -1,
1883             value = array[index];
1884
1885         while (++iterIndex < iterLength) {
1886           var data = iteratees[iterIndex],
1887               iteratee = data.iteratee,
1888               type = data.type,
1889               computed = iteratee(value);
1890
1891           if (type == LAZY_MAP_FLAG) {
1892             value = computed;
1893           } else if (!computed) {
1894             if (type == LAZY_FILTER_FLAG) {
1895               continue outer;
1896             } else {
1897               break outer;
1898             }
1899           }
1900         }
1901         result[resIndex++] = value;
1902       }
1903       return result;
1904     }
1905
1906     // Ensure `LazyWrapper` is an instance of `baseLodash`.
1907     LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1908     LazyWrapper.prototype.constructor = LazyWrapper;
1909
1910     /*------------------------------------------------------------------------*/
1911
1912     /**
1913      * Creates a hash object.
1914      *
1915      * @private
1916      * @constructor
1917      * @param {Array} [entries] The key-value pairs to cache.
1918      */
1919     function Hash(entries) {
1920       var index = -1,
1921           length = entries == null ? 0 : entries.length;
1922
1923       this.clear();
1924       while (++index < length) {
1925         var entry = entries[index];
1926         this.set(entry[0], entry[1]);
1927       }
1928     }
1929
1930     /**
1931      * Removes all key-value entries from the hash.
1932      *
1933      * @private
1934      * @name clear
1935      * @memberOf Hash
1936      */
1937     function hashClear() {
1938       this.__data__ = nativeCreate ? nativeCreate(null) : {};
1939       this.size = 0;
1940     }
1941
1942     /**
1943      * Removes `key` and its value from the hash.
1944      *
1945      * @private
1946      * @name delete
1947      * @memberOf Hash
1948      * @param {Object} hash The hash to modify.
1949      * @param {string} key The key of the value to remove.
1950      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1951      */
1952     function hashDelete(key) {
1953       var result = this.has(key) && delete this.__data__[key];
1954       this.size -= result ? 1 : 0;
1955       return result;
1956     }
1957
1958     /**
1959      * Gets the hash value for `key`.
1960      *
1961      * @private
1962      * @name get
1963      * @memberOf Hash
1964      * @param {string} key The key of the value to get.
1965      * @returns {*} Returns the entry value.
1966      */
1967     function hashGet(key) {
1968       var data = this.__data__;
1969       if (nativeCreate) {
1970         var result = data[key];
1971         return result === HASH_UNDEFINED ? undefined : result;
1972       }
1973       return hasOwnProperty.call(data, key) ? data[key] : undefined;
1974     }
1975
1976     /**
1977      * Checks if a hash value for `key` exists.
1978      *
1979      * @private
1980      * @name has
1981      * @memberOf Hash
1982      * @param {string} key The key of the entry to check.
1983      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1984      */
1985     function hashHas(key) {
1986       var data = this.__data__;
1987       return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
1988     }
1989
1990     /**
1991      * Sets the hash `key` to `value`.
1992      *
1993      * @private
1994      * @name set
1995      * @memberOf Hash
1996      * @param {string} key The key of the value to set.
1997      * @param {*} value The value to set.
1998      * @returns {Object} Returns the hash instance.
1999      */
2000     function hashSet(key, value) {
2001       var data = this.__data__;
2002       this.size += this.has(key) ? 0 : 1;
2003       data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
2004       return this;
2005     }
2006
2007     // Add methods to `Hash`.
2008     Hash.prototype.clear = hashClear;
2009     Hash.prototype['delete'] = hashDelete;
2010     Hash.prototype.get = hashGet;
2011     Hash.prototype.has = hashHas;
2012     Hash.prototype.set = hashSet;
2013
2014     /*------------------------------------------------------------------------*/
2015
2016     /**
2017      * Creates an list cache object.
2018      *
2019      * @private
2020      * @constructor
2021      * @param {Array} [entries] The key-value pairs to cache.
2022      */
2023     function ListCache(entries) {
2024       var index = -1,
2025           length = entries == null ? 0 : entries.length;
2026
2027       this.clear();
2028       while (++index < length) {
2029         var entry = entries[index];
2030         this.set(entry[0], entry[1]);
2031       }
2032     }
2033
2034     /**
2035      * Removes all key-value entries from the list cache.
2036      *
2037      * @private
2038      * @name clear
2039      * @memberOf ListCache
2040      */
2041     function listCacheClear() {
2042       this.__data__ = [];
2043       this.size = 0;
2044     }
2045
2046     /**
2047      * Removes `key` and its value from the list cache.
2048      *
2049      * @private
2050      * @name delete
2051      * @memberOf ListCache
2052      * @param {string} key The key of the value to remove.
2053      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2054      */
2055     function listCacheDelete(key) {
2056       var data = this.__data__,
2057           index = assocIndexOf(data, key);
2058
2059       if (index < 0) {
2060         return false;
2061       }
2062       var lastIndex = data.length - 1;
2063       if (index == lastIndex) {
2064         data.pop();
2065       } else {
2066         splice.call(data, index, 1);
2067       }
2068       --this.size;
2069       return true;
2070     }
2071
2072     /**
2073      * Gets the list cache value for `key`.
2074      *
2075      * @private
2076      * @name get
2077      * @memberOf ListCache
2078      * @param {string} key The key of the value to get.
2079      * @returns {*} Returns the entry value.
2080      */
2081     function listCacheGet(key) {
2082       var data = this.__data__,
2083           index = assocIndexOf(data, key);
2084
2085       return index < 0 ? undefined : data[index][1];
2086     }
2087
2088     /**
2089      * Checks if a list cache value for `key` exists.
2090      *
2091      * @private
2092      * @name has
2093      * @memberOf ListCache
2094      * @param {string} key The key of the entry to check.
2095      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2096      */
2097     function listCacheHas(key) {
2098       return assocIndexOf(this.__data__, key) > -1;
2099     }
2100
2101     /**
2102      * Sets the list cache `key` to `value`.
2103      *
2104      * @private
2105      * @name set
2106      * @memberOf ListCache
2107      * @param {string} key The key of the value to set.
2108      * @param {*} value The value to set.
2109      * @returns {Object} Returns the list cache instance.
2110      */
2111     function listCacheSet(key, value) {
2112       var data = this.__data__,
2113           index = assocIndexOf(data, key);
2114
2115       if (index < 0) {
2116         ++this.size;
2117         data.push([key, value]);
2118       } else {
2119         data[index][1] = value;
2120       }
2121       return this;
2122     }
2123
2124     // Add methods to `ListCache`.
2125     ListCache.prototype.clear = listCacheClear;
2126     ListCache.prototype['delete'] = listCacheDelete;
2127     ListCache.prototype.get = listCacheGet;
2128     ListCache.prototype.has = listCacheHas;
2129     ListCache.prototype.set = listCacheSet;
2130
2131     /*------------------------------------------------------------------------*/
2132
2133     /**
2134      * Creates a map cache object to store key-value pairs.
2135      *
2136      * @private
2137      * @constructor
2138      * @param {Array} [entries] The key-value pairs to cache.
2139      */
2140     function MapCache(entries) {
2141       var index = -1,
2142           length = entries == null ? 0 : entries.length;
2143
2144       this.clear();
2145       while (++index < length) {
2146         var entry = entries[index];
2147         this.set(entry[0], entry[1]);
2148       }
2149     }
2150
2151     /**
2152      * Removes all key-value entries from the map.
2153      *
2154      * @private
2155      * @name clear
2156      * @memberOf MapCache
2157      */
2158     function mapCacheClear() {
2159       this.size = 0;
2160       this.__data__ = {
2161         'hash': new Hash,
2162         'map': new (Map || ListCache),
2163         'string': new Hash
2164       };
2165     }
2166
2167     /**
2168      * Removes `key` and its value from the map.
2169      *
2170      * @private
2171      * @name delete
2172      * @memberOf MapCache
2173      * @param {string} key The key of the value to remove.
2174      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2175      */
2176     function mapCacheDelete(key) {
2177       var result = getMapData(this, key)['delete'](key);
2178       this.size -= result ? 1 : 0;
2179       return result;
2180     }
2181
2182     /**
2183      * Gets the map value for `key`.
2184      *
2185      * @private
2186      * @name get
2187      * @memberOf MapCache
2188      * @param {string} key The key of the value to get.
2189      * @returns {*} Returns the entry value.
2190      */
2191     function mapCacheGet(key) {
2192       return getMapData(this, key).get(key);
2193     }
2194
2195     /**
2196      * Checks if a map value for `key` exists.
2197      *
2198      * @private
2199      * @name has
2200      * @memberOf MapCache
2201      * @param {string} key The key of the entry to check.
2202      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2203      */
2204     function mapCacheHas(key) {
2205       return getMapData(this, key).has(key);
2206     }
2207
2208     /**
2209      * Sets the map `key` to `value`.
2210      *
2211      * @private
2212      * @name set
2213      * @memberOf MapCache
2214      * @param {string} key The key of the value to set.
2215      * @param {*} value The value to set.
2216      * @returns {Object} Returns the map cache instance.
2217      */
2218     function mapCacheSet(key, value) {
2219       var data = getMapData(this, key),
2220           size = data.size;
2221
2222       data.set(key, value);
2223       this.size += data.size == size ? 0 : 1;
2224       return this;
2225     }
2226
2227     // Add methods to `MapCache`.
2228     MapCache.prototype.clear = mapCacheClear;
2229     MapCache.prototype['delete'] = mapCacheDelete;
2230     MapCache.prototype.get = mapCacheGet;
2231     MapCache.prototype.has = mapCacheHas;
2232     MapCache.prototype.set = mapCacheSet;
2233
2234     /*------------------------------------------------------------------------*/
2235
2236     /**
2237      *
2238      * Creates an array cache object to store unique values.
2239      *
2240      * @private
2241      * @constructor
2242      * @param {Array} [values] The values to cache.
2243      */
2244     function SetCache(values) {
2245       var index = -1,
2246           length = values == null ? 0 : values.length;
2247
2248       this.__data__ = new MapCache;
2249       while (++index < length) {
2250         this.add(values[index]);
2251       }
2252     }
2253
2254     /**
2255      * Adds `value` to the array cache.
2256      *
2257      * @private
2258      * @name add
2259      * @memberOf SetCache
2260      * @alias push
2261      * @param {*} value The value to cache.
2262      * @returns {Object} Returns the cache instance.
2263      */
2264     function setCacheAdd(value) {
2265       this.__data__.set(value, HASH_UNDEFINED);
2266       return this;
2267     }
2268
2269     /**
2270      * Checks if `value` is in the array cache.
2271      *
2272      * @private
2273      * @name has
2274      * @memberOf SetCache
2275      * @param {*} value The value to search for.
2276      * @returns {number} Returns `true` if `value` is found, else `false`.
2277      */
2278     function setCacheHas(value) {
2279       return this.__data__.has(value);
2280     }
2281
2282     // Add methods to `SetCache`.
2283     SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2284     SetCache.prototype.has = setCacheHas;
2285
2286     /*------------------------------------------------------------------------*/
2287
2288     /**
2289      * Creates a stack cache object to store key-value pairs.
2290      *
2291      * @private
2292      * @constructor
2293      * @param {Array} [entries] The key-value pairs to cache.
2294      */
2295     function Stack(entries) {
2296       var data = this.__data__ = new ListCache(entries);
2297       this.size = data.size;
2298     }
2299
2300     /**
2301      * Removes all key-value entries from the stack.
2302      *
2303      * @private
2304      * @name clear
2305      * @memberOf Stack
2306      */
2307     function stackClear() {
2308       this.__data__ = new ListCache;
2309       this.size = 0;
2310     }
2311
2312     /**
2313      * Removes `key` and its value from the stack.
2314      *
2315      * @private
2316      * @name delete
2317      * @memberOf Stack
2318      * @param {string} key The key of the value to remove.
2319      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2320      */
2321     function stackDelete(key) {
2322       var data = this.__data__,
2323           result = data['delete'](key);
2324
2325       this.size = data.size;
2326       return result;
2327     }
2328
2329     /**
2330      * Gets the stack value for `key`.
2331      *
2332      * @private
2333      * @name get
2334      * @memberOf Stack
2335      * @param {string} key The key of the value to get.
2336      * @returns {*} Returns the entry value.
2337      */
2338     function stackGet(key) {
2339       return this.__data__.get(key);
2340     }
2341
2342     /**
2343      * Checks if a stack value for `key` exists.
2344      *
2345      * @private
2346      * @name has
2347      * @memberOf Stack
2348      * @param {string} key The key of the entry to check.
2349      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2350      */
2351     function stackHas(key) {
2352       return this.__data__.has(key);
2353     }
2354
2355     /**
2356      * Sets the stack `key` to `value`.
2357      *
2358      * @private
2359      * @name set
2360      * @memberOf Stack
2361      * @param {string} key The key of the value to set.
2362      * @param {*} value The value to set.
2363      * @returns {Object} Returns the stack cache instance.
2364      */
2365     function stackSet(key, value) {
2366       var data = this.__data__;
2367       if (data instanceof ListCache) {
2368         var pairs = data.__data__;
2369         if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2370           pairs.push([key, value]);
2371           this.size = ++data.size;
2372           return this;
2373         }
2374         data = this.__data__ = new MapCache(pairs);
2375       }
2376       data.set(key, value);
2377       this.size = data.size;
2378       return this;
2379     }
2380
2381     // Add methods to `Stack`.
2382     Stack.prototype.clear = stackClear;
2383     Stack.prototype['delete'] = stackDelete;
2384     Stack.prototype.get = stackGet;
2385     Stack.prototype.has = stackHas;
2386     Stack.prototype.set = stackSet;
2387
2388     /*------------------------------------------------------------------------*/
2389
2390     /**
2391      * Creates an array of the enumerable property names of the array-like `value`.
2392      *
2393      * @private
2394      * @param {*} value The value to query.
2395      * @param {boolean} inherited Specify returning inherited property names.
2396      * @returns {Array} Returns the array of property names.
2397      */
2398     function arrayLikeKeys(value, inherited) {
2399       var isArr = isArray(value),
2400           isArg = !isArr && isArguments(value),
2401           isBuff = !isArr && !isArg && isBuffer(value),
2402           isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2403           skipIndexes = isArr || isArg || isBuff || isType,
2404           result = skipIndexes ? baseTimes(value.length, String) : [],
2405           length = result.length;
2406
2407       for (var key in value) {
2408         if ((inherited || hasOwnProperty.call(value, key)) &&
2409             !(skipIndexes && (
2410                // Safari 9 has enumerable `arguments.length` in strict mode.
2411                key == 'length' ||
2412                // Node.js 0.10 has enumerable non-index properties on buffers.
2413                (isBuff && (key == 'offset' || key == 'parent')) ||
2414                // PhantomJS 2 has enumerable non-index properties on typed arrays.
2415                (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2416                // Skip index properties.
2417                isIndex(key, length)
2418             ))) {
2419           result.push(key);
2420         }
2421       }
2422       return result;
2423     }
2424
2425     /**
2426      * A specialized version of `_.sample` for arrays.
2427      *
2428      * @private
2429      * @param {Array} array The array to sample.
2430      * @returns {*} Returns the random element.
2431      */
2432     function arraySample(array) {
2433       var length = array.length;
2434       return length ? array[baseRandom(0, length - 1)] : undefined;
2435     }
2436
2437     /**
2438      * A specialized version of `_.sampleSize` for arrays.
2439      *
2440      * @private
2441      * @param {Array} array The array to sample.
2442      * @param {number} n The number of elements to sample.
2443      * @returns {Array} Returns the random elements.
2444      */
2445     function arraySampleSize(array, n) {
2446       return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2447     }
2448
2449     /**
2450      * A specialized version of `_.shuffle` for arrays.
2451      *
2452      * @private
2453      * @param {Array} array The array to shuffle.
2454      * @returns {Array} Returns the new shuffled array.
2455      */
2456     function arrayShuffle(array) {
2457       return shuffleSelf(copyArray(array));
2458     }
2459
2460     /**
2461      * Used by `_.defaults` to customize its `_.assignIn` use.
2462      *
2463      * @private
2464      * @param {*} objValue The destination value.
2465      * @param {*} srcValue The source value.
2466      * @param {string} key The key of the property to assign.
2467      * @param {Object} object The parent object of `objValue`.
2468      * @returns {*} Returns the value to assign.
2469      */
2470     function assignInDefaults(objValue, srcValue, key, object) {
2471       if (objValue === undefined ||
2472           (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
2473         return srcValue;
2474       }
2475       return objValue;
2476     }
2477
2478     /**
2479      * This function is like `assignValue` except that it doesn't assign
2480      * `undefined` values.
2481      *
2482      * @private
2483      * @param {Object} object The object to modify.
2484      * @param {string} key The key of the property to assign.
2485      * @param {*} value The value to assign.
2486      */
2487     function assignMergeValue(object, key, value) {
2488       if ((value !== undefined && !eq(object[key], value)) ||
2489           (value === undefined && !(key in object))) {
2490         baseAssignValue(object, key, value);
2491       }
2492     }
2493
2494     /**
2495      * Assigns `value` to `key` of `object` if the existing value is not equivalent
2496      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2497      * for equality comparisons.
2498      *
2499      * @private
2500      * @param {Object} object The object to modify.
2501      * @param {string} key The key of the property to assign.
2502      * @param {*} value The value to assign.
2503      */
2504     function assignValue(object, key, value) {
2505       var objValue = object[key];
2506       if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2507           (value === undefined && !(key in object))) {
2508         baseAssignValue(object, key, value);
2509       }
2510     }
2511
2512     /**
2513      * Gets the index at which the `key` is found in `array` of key-value pairs.
2514      *
2515      * @private
2516      * @param {Array} array The array to inspect.
2517      * @param {*} key The key to search for.
2518      * @returns {number} Returns the index of the matched value, else `-1`.
2519      */
2520     function assocIndexOf(array, key) {
2521       var length = array.length;
2522       while (length--) {
2523         if (eq(array[length][0], key)) {
2524           return length;
2525         }
2526       }
2527       return -1;
2528     }
2529
2530     /**
2531      * Aggregates elements of `collection` on `accumulator` with keys transformed
2532      * by `iteratee` and values set by `setter`.
2533      *
2534      * @private
2535      * @param {Array|Object} collection The collection to iterate over.
2536      * @param {Function} setter The function to set `accumulator` values.
2537      * @param {Function} iteratee The iteratee to transform keys.
2538      * @param {Object} accumulator The initial aggregated object.
2539      * @returns {Function} Returns `accumulator`.
2540      */
2541     function baseAggregator(collection, setter, iteratee, accumulator) {
2542       baseEach(collection, function(value, key, collection) {
2543         setter(accumulator, value, iteratee(value), collection);
2544       });
2545       return accumulator;
2546     }
2547
2548     /**
2549      * The base implementation of `_.assign` without support for multiple sources
2550      * or `customizer` functions.
2551      *
2552      * @private
2553      * @param {Object} object The destination object.
2554      * @param {Object} source The source object.
2555      * @returns {Object} Returns `object`.
2556      */
2557     function baseAssign(object, source) {
2558       return object && copyObject(source, keys(source), object);
2559     }
2560
2561     /**
2562      * The base implementation of `assignValue` and `assignMergeValue` without
2563      * value checks.
2564      *
2565      * @private
2566      * @param {Object} object The object to modify.
2567      * @param {string} key The key of the property to assign.
2568      * @param {*} value The value to assign.
2569      */
2570     function baseAssignValue(object, key, value) {
2571       if (key == '__proto__' && defineProperty) {
2572         defineProperty(object, key, {
2573           'configurable': true,
2574           'enumerable': true,
2575           'value': value,
2576           'writable': true
2577         });
2578       } else {
2579         object[key] = value;
2580       }
2581     }
2582
2583     /**
2584      * The base implementation of `_.at` without support for individual paths.
2585      *
2586      * @private
2587      * @param {Object} object The object to iterate over.
2588      * @param {string[]} paths The property paths of elements to pick.
2589      * @returns {Array} Returns the picked elements.
2590      */
2591     function baseAt(object, paths) {
2592       var index = -1,
2593           length = paths.length,
2594           result = Array(length),
2595           skip = object == null;
2596
2597       while (++index < length) {
2598         result[index] = skip ? undefined : get(object, paths[index]);
2599       }
2600       return result;
2601     }
2602
2603     /**
2604      * The base implementation of `_.clamp` which doesn't coerce arguments.
2605      *
2606      * @private
2607      * @param {number} number The number to clamp.
2608      * @param {number} [lower] The lower bound.
2609      * @param {number} upper The upper bound.
2610      * @returns {number} Returns the clamped number.
2611      */
2612     function baseClamp(number, lower, upper) {
2613       if (number === number) {
2614         if (upper !== undefined) {
2615           number = number <= upper ? number : upper;
2616         }
2617         if (lower !== undefined) {
2618           number = number >= lower ? number : lower;
2619         }
2620       }
2621       return number;
2622     }
2623
2624     /**
2625      * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2626      * traversed objects.
2627      *
2628      * @private
2629      * @param {*} value The value to clone.
2630      * @param {boolean} [isDeep] Specify a deep clone.
2631      * @param {boolean} [isFull] Specify a clone including symbols.
2632      * @param {Function} [customizer] The function to customize cloning.
2633      * @param {string} [key] The key of `value`.
2634      * @param {Object} [object] The parent object of `value`.
2635      * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2636      * @returns {*} Returns the cloned value.
2637      */
2638     function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
2639       var result;
2640       if (customizer) {
2641         result = object ? customizer(value, key, object, stack) : customizer(value);
2642       }
2643       if (result !== undefined) {
2644         return result;
2645       }
2646       if (!isObject(value)) {
2647         return value;
2648       }
2649       var isArr = isArray(value);
2650       if (isArr) {
2651         result = initCloneArray(value);
2652         if (!isDeep) {
2653           return copyArray(value, result);
2654         }
2655       } else {
2656         var tag = getTag(value),
2657             isFunc = tag == funcTag || tag == genTag;
2658
2659         if (isBuffer(value)) {
2660           return cloneBuffer(value, isDeep);
2661         }
2662         if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2663           result = initCloneObject(isFunc ? {} : value);
2664           if (!isDeep) {
2665             return copySymbols(value, baseAssign(result, value));
2666           }
2667         } else {
2668           if (!cloneableTags[tag]) {
2669             return object ? value : {};
2670           }
2671           result = initCloneByTag(value, tag, baseClone, isDeep);
2672         }
2673       }
2674       // Check for circular references and return its corresponding clone.
2675       stack || (stack = new Stack);
2676       var stacked = stack.get(value);
2677       if (stacked) {
2678         return stacked;
2679       }
2680       stack.set(value, result);
2681
2682       var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);
2683       arrayEach(props || value, function(subValue, key) {
2684         if (props) {
2685           key = subValue;
2686           subValue = value[key];
2687         }
2688         // Recursively populate clone (susceptible to call stack limits).
2689         assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
2690       });
2691       return result;
2692     }
2693
2694     /**
2695      * The base implementation of `_.conforms` which doesn't clone `source`.
2696      *
2697      * @private
2698      * @param {Object} source The object of property predicates to conform to.
2699      * @returns {Function} Returns the new spec function.
2700      */
2701     function baseConforms(source) {
2702       var props = keys(source);
2703       return function(object) {
2704         return baseConformsTo(object, source, props);
2705       };
2706     }
2707
2708     /**
2709      * The base implementation of `_.conformsTo` which accepts `props` to check.
2710      *
2711      * @private
2712      * @param {Object} object The object to inspect.
2713      * @param {Object} source The object of property predicates to conform to.
2714      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
2715      */
2716     function baseConformsTo(object, source, props) {
2717       var length = props.length;
2718       if (object == null) {
2719         return !length;
2720       }
2721       object = Object(object);
2722       while (length--) {
2723         var key = props[length],
2724             predicate = source[key],
2725             value = object[key];
2726
2727         if ((value === undefined && !(key in object)) || !predicate(value)) {
2728           return false;
2729         }
2730       }
2731       return true;
2732     }
2733
2734     /**
2735      * The base implementation of `_.delay` and `_.defer` which accepts `args`
2736      * to provide to `func`.
2737      *
2738      * @private
2739      * @param {Function} func The function to delay.
2740      * @param {number} wait The number of milliseconds to delay invocation.
2741      * @param {Array} args The arguments to provide to `func`.
2742      * @returns {number|Object} Returns the timer id or timeout object.
2743      */
2744     function baseDelay(func, wait, args) {
2745       if (typeof func != 'function') {
2746         throw new TypeError(FUNC_ERROR_TEXT);
2747       }
2748       return setTimeout(function() { func.apply(undefined, args); }, wait);
2749     }
2750
2751     /**
2752      * The base implementation of methods like `_.difference` without support
2753      * for excluding multiple arrays or iteratee shorthands.
2754      *
2755      * @private
2756      * @param {Array} array The array to inspect.
2757      * @param {Array} values The values to exclude.
2758      * @param {Function} [iteratee] The iteratee invoked per element.
2759      * @param {Function} [comparator] The comparator invoked per element.
2760      * @returns {Array} Returns the new array of filtered values.
2761      */
2762     function baseDifference(array, values, iteratee, comparator) {
2763       var index = -1,
2764           includes = arrayIncludes,
2765           isCommon = true,
2766           length = array.length,
2767           result = [],
2768           valuesLength = values.length;
2769
2770       if (!length) {
2771         return result;
2772       }
2773       if (iteratee) {
2774         values = arrayMap(values, baseUnary(iteratee));
2775       }
2776       if (comparator) {
2777         includes = arrayIncludesWith;
2778         isCommon = false;
2779       }
2780       else if (values.length >= LARGE_ARRAY_SIZE) {
2781         includes = cacheHas;
2782         isCommon = false;
2783         values = new SetCache(values);
2784       }
2785       outer:
2786       while (++index < length) {
2787         var value = array[index],
2788             computed = iteratee == null ? value : iteratee(value);
2789
2790         value = (comparator || value !== 0) ? value : 0;
2791         if (isCommon && computed === computed) {
2792           var valuesIndex = valuesLength;
2793           while (valuesIndex--) {
2794             if (values[valuesIndex] === computed) {
2795               continue outer;
2796             }
2797           }
2798           result.push(value);
2799         }
2800         else if (!includes(values, computed, comparator)) {
2801           result.push(value);
2802         }
2803       }
2804       return result;
2805     }
2806
2807     /**
2808      * The base implementation of `_.forEach` without support for iteratee shorthands.
2809      *
2810      * @private
2811      * @param {Array|Object} collection The collection to iterate over.
2812      * @param {Function} iteratee The function invoked per iteration.
2813      * @returns {Array|Object} Returns `collection`.
2814      */
2815     var baseEach = createBaseEach(baseForOwn);
2816
2817     /**
2818      * The base implementation of `_.forEachRight` without support for iteratee shorthands.
2819      *
2820      * @private
2821      * @param {Array|Object} collection The collection to iterate over.
2822      * @param {Function} iteratee The function invoked per iteration.
2823      * @returns {Array|Object} Returns `collection`.
2824      */
2825     var baseEachRight = createBaseEach(baseForOwnRight, true);
2826
2827     /**
2828      * The base implementation of `_.every` without support for iteratee shorthands.
2829      *
2830      * @private
2831      * @param {Array|Object} collection The collection to iterate over.
2832      * @param {Function} predicate The function invoked per iteration.
2833      * @returns {boolean} Returns `true` if all elements pass the predicate check,
2834      *  else `false`
2835      */
2836     function baseEvery(collection, predicate) {
2837       var result = true;
2838       baseEach(collection, function(value, index, collection) {
2839         result = !!predicate(value, index, collection);
2840         return result;
2841       });
2842       return result;
2843     }
2844
2845     /**
2846      * The base implementation of methods like `_.max` and `_.min` which accepts a
2847      * `comparator` to determine the extremum value.
2848      *
2849      * @private
2850      * @param {Array} array The array to iterate over.
2851      * @param {Function} iteratee The iteratee invoked per iteration.
2852      * @param {Function} comparator The comparator used to compare values.
2853      * @returns {*} Returns the extremum value.
2854      */
2855     function baseExtremum(array, iteratee, comparator) {
2856       var index = -1,
2857           length = array.length;
2858
2859       while (++index < length) {
2860         var value = array[index],
2861             current = iteratee(value);
2862
2863         if (current != null && (computed === undefined
2864               ? (current === current && !isSymbol(current))
2865               : comparator(current, computed)
2866             )) {
2867           var computed = current,
2868               result = value;
2869         }
2870       }
2871       return result;
2872     }
2873
2874     /**
2875      * The base implementation of `_.fill` without an iteratee call guard.
2876      *
2877      * @private
2878      * @param {Array} array The array to fill.
2879      * @param {*} value The value to fill `array` with.
2880      * @param {number} [start=0] The start position.
2881      * @param {number} [end=array.length] The end position.
2882      * @returns {Array} Returns `array`.
2883      */
2884     function baseFill(array, value, start, end) {
2885       var length = array.length;
2886
2887       start = toInteger(start);
2888       if (start < 0) {
2889         start = -start > length ? 0 : (length + start);
2890       }
2891       end = (end === undefined || end > length) ? length : toInteger(end);
2892       if (end < 0) {
2893         end += length;
2894       }
2895       end = start > end ? 0 : toLength(end);
2896       while (start < end) {
2897         array[start++] = value;
2898       }
2899       return array;
2900     }
2901
2902     /**
2903      * The base implementation of `_.filter` without support for iteratee shorthands.
2904      *
2905      * @private
2906      * @param {Array|Object} collection The collection to iterate over.
2907      * @param {Function} predicate The function invoked per iteration.
2908      * @returns {Array} Returns the new filtered array.
2909      */
2910     function baseFilter(collection, predicate) {
2911       var result = [];
2912       baseEach(collection, function(value, index, collection) {
2913         if (predicate(value, index, collection)) {
2914           result.push(value);
2915         }
2916       });
2917       return result;
2918     }
2919
2920     /**
2921      * The base implementation of `_.flatten` with support for restricting flattening.
2922      *
2923      * @private
2924      * @param {Array} array The array to flatten.
2925      * @param {number} depth The maximum recursion depth.
2926      * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
2927      * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
2928      * @param {Array} [result=[]] The initial result value.
2929      * @returns {Array} Returns the new flattened array.
2930      */
2931     function baseFlatten(array, depth, predicate, isStrict, result) {
2932       var index = -1,
2933           length = array.length;
2934
2935       predicate || (predicate = isFlattenable);
2936       result || (result = []);
2937
2938       while (++index < length) {
2939         var value = array[index];
2940         if (depth > 0 && predicate(value)) {
2941           if (depth > 1) {
2942             // Recursively flatten arrays (susceptible to call stack limits).
2943             baseFlatten(value, depth - 1, predicate, isStrict, result);
2944           } else {
2945             arrayPush(result, value);
2946           }
2947         } else if (!isStrict) {
2948           result[result.length] = value;
2949         }
2950       }
2951       return result;
2952     }
2953
2954     /**
2955      * The base implementation of `baseForOwn` which iterates over `object`
2956      * properties returned by `keysFunc` and invokes `iteratee` for each property.
2957      * Iteratee functions may exit iteration early by explicitly returning `false`.
2958      *
2959      * @private
2960      * @param {Object} object The object to iterate over.
2961      * @param {Function} iteratee The function invoked per iteration.
2962      * @param {Function} keysFunc The function to get the keys of `object`.
2963      * @returns {Object} Returns `object`.
2964      */
2965     var baseFor = createBaseFor();
2966
2967     /**
2968      * This function is like `baseFor` except that it iterates over properties
2969      * in the opposite order.
2970      *
2971      * @private
2972      * @param {Object} object The object to iterate over.
2973      * @param {Function} iteratee The function invoked per iteration.
2974      * @param {Function} keysFunc The function to get the keys of `object`.
2975      * @returns {Object} Returns `object`.
2976      */
2977     var baseForRight = createBaseFor(true);
2978
2979     /**
2980      * The base implementation of `_.forOwn` without support for iteratee shorthands.
2981      *
2982      * @private
2983      * @param {Object} object The object to iterate over.
2984      * @param {Function} iteratee The function invoked per iteration.
2985      * @returns {Object} Returns `object`.
2986      */
2987     function baseForOwn(object, iteratee) {
2988       return object && baseFor(object, iteratee, keys);
2989     }
2990
2991     /**
2992      * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
2993      *
2994      * @private
2995      * @param {Object} object The object to iterate over.
2996      * @param {Function} iteratee The function invoked per iteration.
2997      * @returns {Object} Returns `object`.
2998      */
2999     function baseForOwnRight(object, iteratee) {
3000       return object && baseForRight(object, iteratee, keys);
3001     }
3002
3003     /**
3004      * The base implementation of `_.functions` which creates an array of
3005      * `object` function property names filtered from `props`.
3006      *
3007      * @private
3008      * @param {Object} object The object to inspect.
3009      * @param {Array} props The property names to filter.
3010      * @returns {Array} Returns the function names.
3011      */
3012     function baseFunctions(object, props) {
3013       return arrayFilter(props, function(key) {
3014         return isFunction(object[key]);
3015       });
3016     }
3017
3018     /**
3019      * The base implementation of `_.get` without support for default values.
3020      *
3021      * @private
3022      * @param {Object} object The object to query.
3023      * @param {Array|string} path The path of the property to get.
3024      * @returns {*} Returns the resolved value.
3025      */
3026     function baseGet(object, path) {
3027       path = isKey(path, object) ? [path] : castPath(path);
3028
3029       var index = 0,
3030           length = path.length;
3031
3032       while (object != null && index < length) {
3033         object = object[toKey(path[index++])];
3034       }
3035       return (index && index == length) ? object : undefined;
3036     }
3037
3038     /**
3039      * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3040      * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3041      * symbols of `object`.
3042      *
3043      * @private
3044      * @param {Object} object The object to query.
3045      * @param {Function} keysFunc The function to get the keys of `object`.
3046      * @param {Function} symbolsFunc The function to get the symbols of `object`.
3047      * @returns {Array} Returns the array of property names and symbols.
3048      */
3049     function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3050       var result = keysFunc(object);
3051       return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3052     }
3053
3054     /**
3055      * The base implementation of `getTag` without fallbacks for buggy environments.
3056      *
3057      * @private
3058      * @param {*} value The value to query.
3059      * @returns {string} Returns the `toStringTag`.
3060      */
3061     function baseGetTag(value) {
3062       if (value == null) {
3063         return value === undefined ? undefinedTag : nullTag;
3064       }
3065       value = Object(value);
3066       return (symToStringTag && symToStringTag in value)
3067         ? getRawTag(value)
3068         : objectToString(value);
3069     }
3070
3071     /**
3072      * The base implementation of `_.gt` which doesn't coerce arguments.
3073      *
3074      * @private
3075      * @param {*} value The value to compare.
3076      * @param {*} other The other value to compare.
3077      * @returns {boolean} Returns `true` if `value` is greater than `other`,
3078      *  else `false`.
3079      */
3080     function baseGt(value, other) {
3081       return value > other;
3082     }
3083
3084     /**
3085      * The base implementation of `_.has` without support for deep paths.
3086      *
3087      * @private
3088      * @param {Object} [object] The object to query.
3089      * @param {Array|string} key The key to check.
3090      * @returns {boolean} Returns `true` if `key` exists, else `false`.
3091      */
3092     function baseHas(object, key) {
3093       return object != null && hasOwnProperty.call(object, key);
3094     }
3095
3096     /**
3097      * The base implementation of `_.hasIn` without support for deep paths.
3098      *
3099      * @private
3100      * @param {Object} [object] The object to query.
3101      * @param {Array|string} key The key to check.
3102      * @returns {boolean} Returns `true` if `key` exists, else `false`.
3103      */
3104     function baseHasIn(object, key) {
3105       return object != null && key in Object(object);
3106     }
3107
3108     /**
3109      * The base implementation of `_.inRange` which doesn't coerce arguments.
3110      *
3111      * @private
3112      * @param {number} number The number to check.
3113      * @param {number} start The start of the range.
3114      * @param {number} end The end of the range.
3115      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
3116      */
3117     function baseInRange(number, start, end) {
3118       return number >= nativeMin(start, end) && number < nativeMax(start, end);
3119     }
3120
3121     /**
3122      * The base implementation of methods like `_.intersection`, without support
3123      * for iteratee shorthands, that accepts an array of arrays to inspect.
3124      *
3125      * @private
3126      * @param {Array} arrays The arrays to inspect.
3127      * @param {Function} [iteratee] The iteratee invoked per element.
3128      * @param {Function} [comparator] The comparator invoked per element.
3129      * @returns {Array} Returns the new array of shared values.
3130      */
3131     function baseIntersection(arrays, iteratee, comparator) {
3132       var includes = comparator ? arrayIncludesWith : arrayIncludes,
3133           length = arrays[0].length,
3134           othLength = arrays.length,
3135           othIndex = othLength,
3136           caches = Array(othLength),
3137           maxLength = Infinity,
3138           result = [];
3139
3140       while (othIndex--) {
3141         var array = arrays[othIndex];
3142         if (othIndex && iteratee) {
3143           array = arrayMap(array, baseUnary(iteratee));
3144         }
3145         maxLength = nativeMin(array.length, maxLength);
3146         caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3147           ? new SetCache(othIndex && array)
3148           : undefined;
3149       }
3150       array = arrays[0];
3151
3152       var index = -1,
3153           seen = caches[0];
3154
3155       outer:
3156       while (++index < length && result.length < maxLength) {
3157         var value = array[index],
3158             computed = iteratee ? iteratee(value) : value;
3159
3160         value = (comparator || value !== 0) ? value : 0;
3161         if (!(seen
3162               ? cacheHas(seen, computed)
3163               : includes(result, computed, comparator)
3164             )) {
3165           othIndex = othLength;
3166           while (--othIndex) {
3167             var cache = caches[othIndex];
3168             if (!(cache
3169                   ? cacheHas(cache, computed)
3170                   : includes(arrays[othIndex], computed, comparator))
3171                 ) {
3172               continue outer;
3173             }
3174           }
3175           if (seen) {
3176             seen.push(computed);
3177           }
3178           result.push(value);
3179         }
3180       }
3181       return result;
3182     }
3183
3184     /**
3185      * The base implementation of `_.invert` and `_.invertBy` which inverts
3186      * `object` with values transformed by `iteratee` and set by `setter`.
3187      *
3188      * @private
3189      * @param {Object} object The object to iterate over.
3190      * @param {Function} setter The function to set `accumulator` values.
3191      * @param {Function} iteratee The iteratee to transform values.
3192      * @param {Object} accumulator The initial inverted object.
3193      * @returns {Function} Returns `accumulator`.
3194      */
3195     function baseInverter(object, setter, iteratee, accumulator) {
3196       baseForOwn(object, function(value, key, object) {
3197         setter(accumulator, iteratee(value), key, object);
3198       });
3199       return accumulator;
3200     }
3201
3202     /**
3203      * The base implementation of `_.invoke` without support for individual
3204      * method arguments.
3205      *
3206      * @private
3207      * @param {Object} object The object to query.
3208      * @param {Array|string} path The path of the method to invoke.
3209      * @param {Array} args The arguments to invoke the method with.
3210      * @returns {*} Returns the result of the invoked method.
3211      */
3212     function baseInvoke(object, path, args) {
3213       if (!isKey(path, object)) {
3214         path = castPath(path);
3215         object = parent(object, path);
3216         path = last(path);
3217       }
3218       var func = object == null ? object : object[toKey(path)];
3219       return func == null ? undefined : apply(func, object, args);
3220     }
3221
3222     /**
3223      * The base implementation of `_.isArguments`.
3224      *
3225      * @private
3226      * @param {*} value The value to check.
3227      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3228      */
3229     function baseIsArguments(value) {
3230       return isObjectLike(value) && baseGetTag(value) == argsTag;
3231     }
3232
3233     /**
3234      * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3235      *
3236      * @private
3237      * @param {*} value The value to check.
3238      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3239      */
3240     function baseIsArrayBuffer(value) {
3241       return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3242     }
3243
3244     /**
3245      * The base implementation of `_.isDate` without Node.js optimizations.
3246      *
3247      * @private
3248      * @param {*} value The value to check.
3249      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3250      */
3251     function baseIsDate(value) {
3252       return isObjectLike(value) && baseGetTag(value) == dateTag;
3253     }
3254
3255     /**
3256      * The base implementation of `_.isEqual` which supports partial comparisons
3257      * and tracks traversed objects.
3258      *
3259      * @private
3260      * @param {*} value The value to compare.
3261      * @param {*} other The other value to compare.
3262      * @param {Function} [customizer] The function to customize comparisons.
3263      * @param {boolean} [bitmask] The bitmask of comparison flags.
3264      *  The bitmask may be composed of the following flags:
3265      *     1 - Unordered comparison
3266      *     2 - Partial comparison
3267      * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3268      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3269      */
3270     function baseIsEqual(value, other, customizer, bitmask, stack) {
3271       if (value === other) {
3272         return true;
3273       }
3274       if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
3275         return value !== value && other !== other;
3276       }
3277       return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
3278     }
3279
3280     /**
3281      * A specialized version of `baseIsEqual` for arrays and objects which performs
3282      * deep comparisons and tracks traversed objects enabling objects with circular
3283      * references to be compared.
3284      *
3285      * @private
3286      * @param {Object} object The object to compare.
3287      * @param {Object} other The other object to compare.
3288      * @param {Function} equalFunc The function to determine equivalents of values.
3289      * @param {Function} [customizer] The function to customize comparisons.
3290      * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
3291      *  for more details.
3292      * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3293      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3294      */
3295     function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
3296       var objIsArr = isArray(object),
3297           othIsArr = isArray(other),
3298           objTag = arrayTag,
3299           othTag = arrayTag;
3300
3301       if (!objIsArr) {
3302         objTag = getTag(object);
3303         objTag = objTag == argsTag ? objectTag : objTag;
3304       }
3305       if (!othIsArr) {
3306         othTag = getTag(other);
3307         othTag = othTag == argsTag ? objectTag : othTag;
3308       }
3309       var objIsObj = objTag == objectTag,
3310           othIsObj = othTag == objectTag,
3311           isSameTag = objTag == othTag;
3312
3313       if (isSameTag && isBuffer(object)) {
3314         if (!isBuffer(other)) {
3315           return false;
3316         }
3317         objIsArr = true;
3318         objIsObj = false;
3319       }
3320       if (isSameTag && !objIsObj) {
3321         stack || (stack = new Stack);
3322         return (objIsArr || isTypedArray(object))
3323           ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
3324           : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
3325       }
3326       if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
3327         var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3328             othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3329
3330         if (objIsWrapped || othIsWrapped) {
3331           var objUnwrapped = objIsWrapped ? object.value() : object,
3332               othUnwrapped = othIsWrapped ? other.value() : other;
3333
3334           stack || (stack = new Stack);
3335           return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
3336         }
3337       }
3338       if (!isSameTag) {
3339         return false;
3340       }
3341       stack || (stack = new Stack);
3342       return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
3343     }
3344
3345     /**
3346      * The base implementation of `_.isMap` without Node.js optimizations.
3347      *
3348      * @private
3349      * @param {*} value The value to check.
3350      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3351      */
3352     function baseIsMap(value) {
3353       return isObjectLike(value) && getTag(value) == mapTag;
3354     }
3355
3356     /**
3357      * The base implementation of `_.isMatch` without support for iteratee shorthands.
3358      *
3359      * @private
3360      * @param {Object} object The object to inspect.
3361      * @param {Object} source The object of property values to match.
3362      * @param {Array} matchData The property names, values, and compare flags to match.
3363      * @param {Function} [customizer] The function to customize comparisons.
3364      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3365      */
3366     function baseIsMatch(object, source, matchData, customizer) {
3367       var index = matchData.length,
3368           length = index,
3369           noCustomizer = !customizer;
3370
3371       if (object == null) {
3372         return !length;
3373       }
3374       object = Object(object);
3375       while (index--) {
3376         var data = matchData[index];
3377         if ((noCustomizer && data[2])
3378               ? data[1] !== object[data[0]]
3379               : !(data[0] in object)
3380             ) {
3381           return false;
3382         }
3383       }
3384       while (++index < length) {
3385         data = matchData[index];
3386         var key = data[0],
3387             objValue = object[key],
3388             srcValue = data[1];
3389
3390         if (noCustomizer && data[2]) {
3391           if (objValue === undefined && !(key in object)) {
3392             return false;
3393           }
3394         } else {
3395           var stack = new Stack;
3396           if (customizer) {
3397             var result = customizer(objValue, srcValue, key, object, source, stack);
3398           }
3399           if (!(result === undefined
3400                 ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
3401                 : result
3402               )) {
3403             return false;
3404           }
3405         }
3406       }
3407       return true;
3408     }
3409
3410     /**
3411      * The base implementation of `_.isNative` without bad shim checks.
3412      *
3413      * @private
3414      * @param {*} value The value to check.
3415      * @returns {boolean} Returns `true` if `value` is a native function,
3416      *  else `false`.
3417      */
3418     function baseIsNative(value) {
3419       if (!isObject(value) || isMasked(value)) {
3420         return false;
3421       }
3422       var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3423       return pattern.test(toSource(value));
3424     }
3425
3426     /**
3427      * The base implementation of `_.isRegExp` without Node.js optimizations.
3428      *
3429      * @private
3430      * @param {*} value The value to check.
3431      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3432      */
3433     function baseIsRegExp(value) {
3434       return isObjectLike(value) && baseGetTag(value) == regexpTag;
3435     }
3436
3437     /**
3438      * The base implementation of `_.isSet` without Node.js optimizations.
3439      *
3440      * @private
3441      * @param {*} value The value to check.
3442      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3443      */
3444     function baseIsSet(value) {
3445       return isObjectLike(value) && getTag(value) == setTag;
3446     }
3447
3448     /**
3449      * The base implementation of `_.isTypedArray` without Node.js optimizations.
3450      *
3451      * @private
3452      * @param {*} value The value to check.
3453      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3454      */
3455     function baseIsTypedArray(value) {
3456       return isObjectLike(value) &&
3457         isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3458     }
3459
3460     /**
3461      * The base implementation of `_.iteratee`.
3462      *
3463      * @private
3464      * @param {*} [value=_.identity] The value to convert to an iteratee.
3465      * @returns {Function} Returns the iteratee.
3466      */
3467     function baseIteratee(value) {
3468       // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3469       // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3470       if (typeof value == 'function') {
3471         return value;
3472       }
3473       if (value == null) {
3474         return identity;
3475       }
3476       if (typeof value == 'object') {
3477         return isArray(value)
3478           ? baseMatchesProperty(value[0], value[1])
3479           : baseMatches(value);
3480       }
3481       return property(value);
3482     }
3483
3484     /**
3485      * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3486      *
3487      * @private
3488      * @param {Object} object The object to query.
3489      * @returns {Array} Returns the array of property names.
3490      */
3491     function baseKeys(object) {
3492       if (!isPrototype(object)) {
3493         return nativeKeys(object);
3494       }
3495       var result = [];
3496       for (var key in Object(object)) {
3497         if (hasOwnProperty.call(object, key) && key != 'constructor') {
3498           result.push(key);
3499         }
3500       }
3501       return result;
3502     }
3503
3504     /**
3505      * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3506      *
3507      * @private
3508      * @param {Object} object The object to query.
3509      * @returns {Array} Returns the array of property names.
3510      */
3511     function baseKeysIn(object) {
3512       if (!isObject(object)) {
3513         return nativeKeysIn(object);
3514       }
3515       var isProto = isPrototype(object),
3516           result = [];
3517
3518       for (var key in object) {
3519         if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3520           result.push(key);
3521         }
3522       }
3523       return result;
3524     }
3525
3526     /**
3527      * The base implementation of `_.lt` which doesn't coerce arguments.
3528      *
3529      * @private
3530      * @param {*} value The value to compare.
3531      * @param {*} other The other value to compare.
3532      * @returns {boolean} Returns `true` if `value` is less than `other`,
3533      *  else `false`.
3534      */
3535     function baseLt(value, other) {
3536       return value < other;
3537     }
3538
3539     /**
3540      * The base implementation of `_.map` without support for iteratee shorthands.
3541      *
3542      * @private
3543      * @param {Array|Object} collection The collection to iterate over.
3544      * @param {Function} iteratee The function invoked per iteration.
3545      * @returns {Array} Returns the new mapped array.
3546      */
3547     function baseMap(collection, iteratee) {
3548       var index = -1,
3549           result = isArrayLike(collection) ? Array(collection.length) : [];
3550
3551       baseEach(collection, function(value, key, collection) {
3552         result[++index] = iteratee(value, key, collection);
3553       });
3554       return result;
3555     }
3556
3557     /**
3558      * The base implementation of `_.matches` which doesn't clone `source`.
3559      *
3560      * @private
3561      * @param {Object} source The object of property values to match.
3562      * @returns {Function} Returns the new spec function.
3563      */
3564     function baseMatches(source) {
3565       var matchData = getMatchData(source);
3566       if (matchData.length == 1 && matchData[0][2]) {
3567         return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3568       }
3569       return function(object) {
3570         return object === source || baseIsMatch(object, source, matchData);
3571       };
3572     }
3573
3574     /**
3575      * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3576      *
3577      * @private
3578      * @param {string} path The path of the property to get.
3579      * @param {*} srcValue The value to match.
3580      * @returns {Function} Returns the new spec function.
3581      */
3582     function baseMatchesProperty(path, srcValue) {
3583       if (isKey(path) && isStrictComparable(srcValue)) {
3584         return matchesStrictComparable(toKey(path), srcValue);
3585       }
3586       return function(object) {
3587         var objValue = get(object, path);
3588         return (objValue === undefined && objValue === srcValue)
3589           ? hasIn(object, path)
3590           : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
3591       };
3592     }
3593
3594     /**
3595      * The base implementation of `_.merge` without support for multiple sources.
3596      *
3597      * @private
3598      * @param {Object} object The destination object.
3599      * @param {Object} source The source object.
3600      * @param {number} srcIndex The index of `source`.
3601      * @param {Function} [customizer] The function to customize merged values.
3602      * @param {Object} [stack] Tracks traversed source values and their merged
3603      *  counterparts.
3604      */
3605     function baseMerge(object, source, srcIndex, customizer, stack) {
3606       if (object === source) {
3607         return;
3608       }
3609       baseFor(source, function(srcValue, key) {
3610         if (isObject(srcValue)) {
3611           stack || (stack = new Stack);
3612           baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3613         }
3614         else {
3615           var newValue = customizer
3616             ? customizer(object[key], srcValue, (key + ''), object, source, stack)
3617             : undefined;
3618
3619           if (newValue === undefined) {
3620             newValue = srcValue;
3621           }
3622           assignMergeValue(object, key, newValue);
3623         }
3624       }, keysIn);
3625     }
3626
3627     /**
3628      * A specialized version of `baseMerge` for arrays and objects which performs
3629      * deep merges and tracks traversed objects enabling objects with circular
3630      * references to be merged.
3631      *
3632      * @private
3633      * @param {Object} object The destination object.
3634      * @param {Object} source The source object.
3635      * @param {string} key The key of the value to merge.
3636      * @param {number} srcIndex The index of `source`.
3637      * @param {Function} mergeFunc The function to merge values.
3638      * @param {Function} [customizer] The function to customize assigned values.
3639      * @param {Object} [stack] Tracks traversed source values and their merged
3640      *  counterparts.
3641      */
3642     function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3643       var objValue = object[key],
3644           srcValue = source[key],
3645           stacked = stack.get(srcValue);
3646
3647       if (stacked) {
3648         assignMergeValue(object, key, stacked);
3649         return;
3650       }
3651       var newValue = customizer
3652         ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3653         : undefined;
3654
3655       var isCommon = newValue === undefined;
3656
3657       if (isCommon) {
3658         var isArr = isArray(srcValue),
3659             isBuff = !isArr && isBuffer(srcValue),
3660             isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3661
3662         newValue = srcValue;
3663         if (isArr || isBuff || isTyped) {
3664           if (isArray(objValue)) {
3665             newValue = objValue;
3666           }
3667           else if (isArrayLikeObject(objValue)) {
3668             newValue = copyArray(objValue);
3669           }
3670           else if (isBuff) {
3671             isCommon = false;
3672             newValue = cloneBuffer(srcValue, true);
3673           }
3674           else if (isTyped) {
3675             isCommon = false;
3676             newValue = cloneTypedArray(srcValue, true);
3677           }
3678           else {
3679             newValue = [];
3680           }
3681         }
3682         else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3683           newValue = objValue;
3684           if (isArguments(objValue)) {
3685             newValue = toPlainObject(objValue);
3686           }
3687           else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
3688             newValue = initCloneObject(srcValue);
3689           }
3690         }
3691         else {
3692           isCommon = false;
3693         }
3694       }
3695       if (isCommon) {
3696         // Recursively merge objects and arrays (susceptible to call stack limits).
3697         stack.set(srcValue, newValue);
3698         mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3699         stack['delete'](srcValue);
3700       }
3701       assignMergeValue(object, key, newValue);
3702     }
3703
3704     /**
3705      * The base implementation of `_.nth` which doesn't coerce arguments.
3706      *
3707      * @private
3708      * @param {Array} array The array to query.
3709      * @param {number} n The index of the element to return.
3710      * @returns {*} Returns the nth element of `array`.
3711      */
3712     function baseNth(array, n) {
3713       var length = array.length;
3714       if (!length) {
3715         return;
3716       }
3717       n += n < 0 ? length : 0;
3718       return isIndex(n, length) ? array[n] : undefined;
3719     }
3720
3721     /**
3722      * The base implementation of `_.orderBy` without param guards.
3723      *
3724      * @private
3725      * @param {Array|Object} collection The collection to iterate over.
3726      * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
3727      * @param {string[]} orders The sort orders of `iteratees`.
3728      * @returns {Array} Returns the new sorted array.
3729      */
3730     function baseOrderBy(collection, iteratees, orders) {
3731       var index = -1;
3732       iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
3733
3734       var result = baseMap(collection, function(value, key, collection) {
3735         var criteria = arrayMap(iteratees, function(iteratee) {
3736           return iteratee(value);
3737         });
3738         return { 'criteria': criteria, 'index': ++index, 'value': value };
3739       });
3740
3741       return baseSortBy(result, function(object, other) {
3742         return compareMultiple(object, other, orders);
3743       });
3744     }
3745
3746     /**
3747      * The base implementation of `_.pick` without support for individual
3748      * property identifiers.
3749      *
3750      * @private
3751      * @param {Object} object The source object.
3752      * @param {string[]} props The property identifiers to pick.
3753      * @returns {Object} Returns the new object.
3754      */
3755     function basePick(object, props) {
3756       object = Object(object);
3757       return basePickBy(object, props, function(value, key) {
3758         return key in object;
3759       });
3760     }
3761
3762     /**
3763      * The base implementation of  `_.pickBy` without support for iteratee shorthands.
3764      *
3765      * @private
3766      * @param {Object} object The source object.
3767      * @param {string[]} props The property identifiers to pick from.
3768      * @param {Function} predicate The function invoked per property.
3769      * @returns {Object} Returns the new object.
3770      */
3771     function basePickBy(object, props, predicate) {
3772       var index = -1,
3773           length = props.length,
3774           result = {};
3775
3776       while (++index < length) {
3777         var key = props[index],
3778             value = object[key];
3779
3780         if (predicate(value, key)) {
3781           baseAssignValue(result, key, value);
3782         }
3783       }
3784       return result;
3785     }
3786
3787     /**
3788      * A specialized version of `baseProperty` which supports deep paths.
3789      *
3790      * @private
3791      * @param {Array|string} path The path of the property to get.
3792      * @returns {Function} Returns the new accessor function.
3793      */
3794     function basePropertyDeep(path) {
3795       return function(object) {
3796         return baseGet(object, path);
3797       };
3798     }
3799
3800     /**
3801      * The base implementation of `_.pullAllBy` without support for iteratee
3802      * shorthands.
3803      *
3804      * @private
3805      * @param {Array} array The array to modify.
3806      * @param {Array} values The values to remove.
3807      * @param {Function} [iteratee] The iteratee invoked per element.
3808      * @param {Function} [comparator] The comparator invoked per element.
3809      * @returns {Array} Returns `array`.
3810      */
3811     function basePullAll(array, values, iteratee, comparator) {
3812       var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3813           index = -1,
3814           length = values.length,
3815           seen = array;
3816
3817       if (array === values) {
3818         values = copyArray(values);
3819       }
3820       if (iteratee) {
3821         seen = arrayMap(array, baseUnary(iteratee));
3822       }
3823       while (++index < length) {
3824         var fromIndex = 0,
3825             value = values[index],
3826             computed = iteratee ? iteratee(value) : value;
3827
3828         while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3829           if (seen !== array) {
3830             splice.call(seen, fromIndex, 1);
3831           }
3832           splice.call(array, fromIndex, 1);
3833         }
3834       }
3835       return array;
3836     }
3837
3838     /**
3839      * The base implementation of `_.pullAt` without support for individual
3840      * indexes or capturing the removed elements.
3841      *
3842      * @private
3843      * @param {Array} array The array to modify.
3844      * @param {number[]} indexes The indexes of elements to remove.
3845      * @returns {Array} Returns `array`.
3846      */
3847     function basePullAt(array, indexes) {
3848       var length = array ? indexes.length : 0,
3849           lastIndex = length - 1;
3850
3851       while (length--) {
3852         var index = indexes[length];
3853         if (length == lastIndex || index !== previous) {
3854           var previous = index;
3855           if (isIndex(index)) {
3856             splice.call(array, index, 1);
3857           }
3858           else if (!isKey(index, array)) {
3859             var path = castPath(index),
3860                 object = parent(array, path);
3861
3862             if (object != null) {
3863               delete object[toKey(last(path))];
3864             }
3865           }
3866           else {
3867             delete array[toKey(index)];
3868           }
3869         }
3870       }
3871       return array;
3872     }
3873
3874     /**
3875      * The base implementation of `_.random` without support for returning
3876      * floating-point numbers.
3877      *
3878      * @private
3879      * @param {number} lower The lower bound.
3880      * @param {number} upper The upper bound.
3881      * @returns {number} Returns the random number.
3882      */
3883     function baseRandom(lower, upper) {
3884       return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
3885     }
3886
3887     /**
3888      * The base implementation of `_.range` and `_.rangeRight` which doesn't
3889      * coerce arguments.
3890      *
3891      * @private
3892      * @param {number} start The start of the range.
3893      * @param {number} end The end of the range.
3894      * @param {number} step The value to increment or decrement by.
3895      * @param {boolean} [fromRight] Specify iterating from right to left.
3896      * @returns {Array} Returns the range of numbers.
3897      */
3898     function baseRange(start, end, step, fromRight) {
3899       var index = -1,
3900           length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
3901           result = Array(length);
3902
3903       while (length--) {
3904         result[fromRight ? length : ++index] = start;
3905         start += step;
3906       }
3907       return result;
3908     }
3909
3910     /**
3911      * The base implementation of `_.repeat` which doesn't coerce arguments.
3912      *
3913      * @private
3914      * @param {string} string The string to repeat.
3915      * @param {number} n The number of times to repeat the string.
3916      * @returns {string} Returns the repeated string.
3917      */
3918     function baseRepeat(string, n) {
3919       var result = '';
3920       if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
3921         return result;
3922       }
3923       // Leverage the exponentiation by squaring algorithm for a faster repeat.
3924       // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
3925       do {
3926         if (n % 2) {
3927           result += string;
3928         }
3929         n = nativeFloor(n / 2);
3930         if (n) {
3931           string += string;
3932         }
3933       } while (n);
3934
3935       return result;
3936     }
3937
3938     /**
3939      * The base implementation of `_.rest` which doesn't validate or coerce arguments.
3940      *
3941      * @private
3942      * @param {Function} func The function to apply a rest parameter to.
3943      * @param {number} [start=func.length-1] The start position of the rest parameter.
3944      * @returns {Function} Returns the new function.
3945      */
3946     function baseRest(func, start) {
3947       return setToString(overRest(func, start, identity), func + '');
3948     }
3949
3950     /**
3951      * The base implementation of `_.sample`.
3952      *
3953      * @private
3954      * @param {Array|Object} collection The collection to sample.
3955      * @returns {*} Returns the random element.
3956      */
3957     function baseSample(collection) {
3958       return arraySample(values(collection));
3959     }
3960
3961     /**
3962      * The base implementation of `_.sampleSize` without param guards.
3963      *
3964      * @private
3965      * @param {Array|Object} collection The collection to sample.
3966      * @param {number} n The number of elements to sample.
3967      * @returns {Array} Returns the random elements.
3968      */
3969     function baseSampleSize(collection, n) {
3970       var array = values(collection);
3971       return shuffleSelf(array, baseClamp(n, 0, array.length));
3972     }
3973
3974     /**
3975      * The base implementation of `_.set`.
3976      *
3977      * @private
3978      * @param {Object} object The object to modify.
3979      * @param {Array|string} path The path of the property to set.
3980      * @param {*} value The value to set.
3981      * @param {Function} [customizer] The function to customize path creation.
3982      * @returns {Object} Returns `object`.
3983      */
3984     function baseSet(object, path, value, customizer) {
3985       if (!isObject(object)) {
3986         return object;
3987       }
3988       path = isKey(path, object) ? [path] : castPath(path);
3989
3990       var index = -1,
3991           length = path.length,
3992           lastIndex = length - 1,
3993           nested = object;
3994
3995       while (nested != null && ++index < length) {
3996         var key = toKey(path[index]),
3997             newValue = value;
3998
3999         if (index != lastIndex) {
4000           var objValue = nested[key];
4001           newValue = customizer ? customizer(objValue, key, nested) : undefined;
4002           if (newValue === undefined) {
4003             newValue = isObject(objValue)
4004               ? objValue
4005               : (isIndex(path[index + 1]) ? [] : {});
4006           }
4007         }
4008         assignValue(nested, key, newValue);
4009         nested = nested[key];
4010       }
4011       return object;
4012     }
4013
4014     /**
4015      * The base implementation of `setData` without support for hot loop shorting.
4016      *
4017      * @private
4018      * @param {Function} func The function to associate metadata with.
4019      * @param {*} data The metadata.
4020      * @returns {Function} Returns `func`.
4021      */
4022     var baseSetData = !metaMap ? identity : function(func, data) {
4023       metaMap.set(func, data);
4024       return func;
4025     };
4026
4027     /**
4028      * The base implementation of `setToString` without support for hot loop shorting.
4029      *
4030      * @private
4031      * @param {Function} func The function to modify.
4032      * @param {Function} string The `toString` result.
4033      * @returns {Function} Returns `func`.
4034      */
4035     var baseSetToString = !defineProperty ? identity : function(func, string) {
4036       return defineProperty(func, 'toString', {
4037         'configurable': true,
4038         'enumerable': false,
4039         'value': constant(string),
4040         'writable': true
4041       });
4042     };
4043
4044     /**
4045      * The base implementation of `_.shuffle`.
4046      *
4047      * @private
4048      * @param {Array|Object} collection The collection to shuffle.
4049      * @returns {Array} Returns the new shuffled array.
4050      */
4051     function baseShuffle(collection) {
4052       return shuffleSelf(values(collection));
4053     }
4054
4055     /**
4056      * The base implementation of `_.slice` without an iteratee call guard.
4057      *
4058      * @private
4059      * @param {Array} array The array to slice.
4060      * @param {number} [start=0] The start position.
4061      * @param {number} [end=array.length] The end position.
4062      * @returns {Array} Returns the slice of `array`.
4063      */
4064     function baseSlice(array, start, end) {
4065       var index = -1,
4066           length = array.length;
4067
4068       if (start < 0) {
4069         start = -start > length ? 0 : (length + start);
4070       }
4071       end = end > length ? length : end;
4072       if (end < 0) {
4073         end += length;
4074       }
4075       length = start > end ? 0 : ((end - start) >>> 0);
4076       start >>>= 0;
4077
4078       var result = Array(length);
4079       while (++index < length) {
4080         result[index] = array[index + start];
4081       }
4082       return result;
4083     }
4084
4085     /**
4086      * The base implementation of `_.some` without support for iteratee shorthands.
4087      *
4088      * @private
4089      * @param {Array|Object} collection The collection to iterate over.
4090      * @param {Function} predicate The function invoked per iteration.
4091      * @returns {boolean} Returns `true` if any element passes the predicate check,
4092      *  else `false`.
4093      */
4094     function baseSome(collection, predicate) {
4095       var result;
4096
4097       baseEach(collection, function(value, index, collection) {
4098         result = predicate(value, index, collection);
4099         return !result;
4100       });
4101       return !!result;
4102     }
4103
4104     /**
4105      * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
4106      * performs a binary search of `array` to determine the index at which `value`
4107      * should be inserted into `array` in order to maintain its sort order.
4108      *
4109      * @private
4110      * @param {Array} array The sorted array to inspect.
4111      * @param {*} value The value to evaluate.
4112      * @param {boolean} [retHighest] Specify returning the highest qualified index.
4113      * @returns {number} Returns the index at which `value` should be inserted
4114      *  into `array`.
4115      */
4116     function baseSortedIndex(array, value, retHighest) {
4117       var low = 0,
4118           high = array == null ? low : array.length;
4119
4120       if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4121         while (low < high) {
4122           var mid = (low + high) >>> 1,
4123               computed = array[mid];
4124
4125           if (computed !== null && !isSymbol(computed) &&
4126               (retHighest ? (computed <= value) : (computed < value))) {
4127             low = mid + 1;
4128           } else {
4129             high = mid;
4130           }
4131         }
4132         return high;
4133       }
4134       return baseSortedIndexBy(array, value, identity, retHighest);
4135     }
4136
4137     /**
4138      * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
4139      * which invokes `iteratee` for `value` and each element of `array` to compute
4140      * their sort ranking. The iteratee is invoked with one argument; (value).
4141      *
4142      * @private
4143      * @param {Array} array The sorted array to inspect.
4144      * @param {*} value The value to evaluate.
4145      * @param {Function} iteratee The iteratee invoked per element.
4146      * @param {boolean} [retHighest] Specify returning the highest qualified index.
4147      * @returns {number} Returns the index at which `value` should be inserted
4148      *  into `array`.
4149      */
4150     function baseSortedIndexBy(array, value, iteratee, retHighest) {
4151       value = iteratee(value);
4152
4153       var low = 0,
4154           high = array == null ? 0 : array.length,
4155           valIsNaN = value !== value,
4156           valIsNull = value === null,
4157           valIsSymbol = isSymbol(value),
4158           valIsUndefined = value === undefined;
4159
4160       while (low < high) {
4161         var mid = nativeFloor((low + high) / 2),
4162             computed = iteratee(array[mid]),
4163             othIsDefined = computed !== undefined,
4164             othIsNull = computed === null,
4165             othIsReflexive = computed === computed,
4166             othIsSymbol = isSymbol(computed);
4167
4168         if (valIsNaN) {
4169           var setLow = retHighest || othIsReflexive;
4170         } else if (valIsUndefined) {
4171           setLow = othIsReflexive && (retHighest || othIsDefined);
4172         } else if (valIsNull) {
4173           setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
4174         } else if (valIsSymbol) {
4175           setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
4176         } else if (othIsNull || othIsSymbol) {
4177           setLow = false;
4178         } else {
4179           setLow = retHighest ? (computed <= value) : (computed < value);
4180         }
4181         if (setLow) {
4182           low = mid + 1;
4183         } else {
4184           high = mid;
4185         }
4186       }
4187       return nativeMin(high, MAX_ARRAY_INDEX);
4188     }
4189
4190     /**
4191      * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4192      * support for iteratee shorthands.
4193      *
4194      * @private
4195      * @param {Array} array The array to inspect.
4196      * @param {Function} [iteratee] The iteratee invoked per element.
4197      * @returns {Array} Returns the new duplicate free array.
4198      */
4199     function baseSortedUniq(array, iteratee) {
4200       var index = -1,
4201           length = array.length,
4202           resIndex = 0,
4203           result = [];
4204
4205       while (++index < length) {
4206         var value = array[index],
4207             computed = iteratee ? iteratee(value) : value;
4208
4209         if (!index || !eq(computed, seen)) {
4210           var seen = computed;
4211           result[resIndex++] = value === 0 ? 0 : value;
4212         }
4213       }
4214       return result;
4215     }
4216
4217     /**
4218      * The base implementation of `_.toNumber` which doesn't ensure correct
4219      * conversions of binary, hexadecimal, or octal string values.
4220      *
4221      * @private
4222      * @param {*} value The value to process.
4223      * @returns {number} Returns the number.
4224      */
4225     function baseToNumber(value) {
4226       if (typeof value == 'number') {
4227         return value;
4228       }
4229       if (isSymbol(value)) {
4230         return NAN;
4231       }
4232       return +value;
4233     }
4234
4235     /**
4236      * The base implementation of `_.toString` which doesn't convert nullish
4237      * values to empty strings.
4238      *
4239      * @private
4240      * @param {*} value The value to process.
4241      * @returns {string} Returns the string.
4242      */
4243     function baseToString(value) {
4244       // Exit early for strings to avoid a performance hit in some environments.
4245       if (typeof value == 'string') {
4246         return value;
4247       }
4248       if (isArray(value)) {
4249         // Recursively convert values (susceptible to call stack limits).
4250         return arrayMap(value, baseToString) + '';
4251       }
4252       if (isSymbol(value)) {
4253         return symbolToString ? symbolToString.call(value) : '';
4254       }
4255       var result = (value + '');
4256       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4257     }
4258
4259     /**
4260      * The base implementation of `_.uniqBy` without support for iteratee shorthands.
4261      *
4262      * @private
4263      * @param {Array} array The array to inspect.
4264      * @param {Function} [iteratee] The iteratee invoked per element.
4265      * @param {Function} [comparator] The comparator invoked per element.
4266      * @returns {Array} Returns the new duplicate free array.
4267      */
4268     function baseUniq(array, iteratee, comparator) {
4269       var index = -1,
4270           includes = arrayIncludes,
4271           length = array.length,
4272           isCommon = true,
4273           result = [],
4274           seen = result;
4275
4276       if (comparator) {
4277         isCommon = false;
4278         includes = arrayIncludesWith;
4279       }
4280       else if (length >= LARGE_ARRAY_SIZE) {
4281         var set = iteratee ? null : createSet(array);
4282         if (set) {
4283           return setToArray(set);
4284         }
4285         isCommon = false;
4286         includes = cacheHas;
4287         seen = new SetCache;
4288       }
4289       else {
4290         seen = iteratee ? [] : result;
4291       }
4292       outer:
4293       while (++index < length) {
4294         var value = array[index],
4295             computed = iteratee ? iteratee(value) : value;
4296
4297         value = (comparator || value !== 0) ? value : 0;
4298         if (isCommon && computed === computed) {
4299           var seenIndex = seen.length;
4300           while (seenIndex--) {
4301             if (seen[seenIndex] === computed) {
4302               continue outer;
4303             }
4304           }
4305           if (iteratee) {
4306             seen.push(computed);
4307           }
4308           result.push(value);
4309         }
4310         else if (!includes(seen, computed, comparator)) {
4311           if (seen !== result) {
4312             seen.push(computed);
4313           }
4314           result.push(value);
4315         }
4316       }
4317       return result;
4318     }
4319
4320     /**
4321      * The base implementation of `_.unset`.
4322      *
4323      * @private
4324      * @param {Object} object The object to modify.
4325      * @param {Array|string} path The path of the property to unset.
4326      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
4327      */
4328     function baseUnset(object, path) {
4329       path = isKey(path, object) ? [path] : castPath(path);
4330       object = parent(object, path);
4331
4332       var key = toKey(last(path));
4333       return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
4334     }
4335
4336     /**
4337      * The base implementation of `_.update`.
4338      *
4339      * @private
4340      * @param {Object} object The object to modify.
4341      * @param {Array|string} path The path of the property to update.
4342      * @param {Function} updater The function to produce the updated value.
4343      * @param {Function} [customizer] The function to customize path creation.
4344      * @returns {Object} Returns `object`.
4345      */
4346     function baseUpdate(object, path, updater, customizer) {
4347       return baseSet(object, path, updater(baseGet(object, path)), customizer);
4348     }
4349
4350     /**
4351      * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4352      * without support for iteratee shorthands.
4353      *
4354      * @private
4355      * @param {Array} array The array to query.
4356      * @param {Function} predicate The function invoked per iteration.
4357      * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
4358      * @param {boolean} [fromRight] Specify iterating from right to left.
4359      * @returns {Array} Returns the slice of `array`.
4360      */
4361     function baseWhile(array, predicate, isDrop, fromRight) {
4362       var length = array.length,
4363           index = fromRight ? length : -1;
4364
4365       while ((fromRight ? index-- : ++index < length) &&
4366         predicate(array[index], index, array)) {}
4367
4368       return isDrop
4369         ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
4370         : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
4371     }
4372
4373     /**
4374      * The base implementation of `wrapperValue` which returns the result of
4375      * performing a sequence of actions on the unwrapped `value`, where each
4376      * successive action is supplied the return value of the previous.
4377      *
4378      * @private
4379      * @param {*} value The unwrapped value.
4380      * @param {Array} actions Actions to perform to resolve the unwrapped value.
4381      * @returns {*} Returns the resolved value.
4382      */
4383     function baseWrapperValue(value, actions) {
4384       var result = value;
4385       if (result instanceof LazyWrapper) {
4386         result = result.value();
4387       }
4388       return arrayReduce(actions, function(result, action) {
4389         return action.func.apply(action.thisArg, arrayPush([result], action.args));
4390       }, result);
4391     }
4392
4393     /**
4394      * The base implementation of methods like `_.xor`, without support for
4395      * iteratee shorthands, that accepts an array of arrays to inspect.
4396      *
4397      * @private
4398      * @param {Array} arrays The arrays to inspect.
4399      * @param {Function} [iteratee] The iteratee invoked per element.
4400      * @param {Function} [comparator] The comparator invoked per element.
4401      * @returns {Array} Returns the new array of values.
4402      */
4403     function baseXor(arrays, iteratee, comparator) {
4404       var length = arrays.length;
4405       if (length < 2) {
4406         return length ? baseUniq(arrays[0]) : [];
4407       }
4408       var index = -1,
4409           result = Array(length);
4410
4411       while (++index < length) {
4412         var array = arrays[index],
4413             othIndex = -1;
4414
4415         while (++othIndex < length) {
4416           if (othIndex != index) {
4417             result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4418           }
4419         }
4420       }
4421       return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4422     }
4423
4424     /**
4425      * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
4426      *
4427      * @private
4428      * @param {Array} props The property identifiers.
4429      * @param {Array} values The property values.
4430      * @param {Function} assignFunc The function to assign values.
4431      * @returns {Object} Returns the new object.
4432      */
4433     function baseZipObject(props, values, assignFunc) {
4434       var index = -1,
4435           length = props.length,
4436           valsLength = values.length,
4437           result = {};
4438
4439       while (++index < length) {
4440         var value = index < valsLength ? values[index] : undefined;
4441         assignFunc(result, props[index], value);
4442       }
4443       return result;
4444     }
4445
4446     /**
4447      * Casts `value` to an empty array if it's not an array like object.
4448      *
4449      * @private
4450      * @param {*} value The value to inspect.
4451      * @returns {Array|Object} Returns the cast array-like object.
4452      */
4453     function castArrayLikeObject(value) {
4454       return isArrayLikeObject(value) ? value : [];
4455     }
4456
4457     /**
4458      * Casts `value` to `identity` if it's not a function.
4459      *
4460      * @private
4461      * @param {*} value The value to inspect.
4462      * @returns {Function} Returns cast function.
4463      */
4464     function castFunction(value) {
4465       return typeof value == 'function' ? value : identity;
4466     }
4467
4468     /**
4469      * Casts `value` to a path array if it's not one.
4470      *
4471      * @private
4472      * @param {*} value The value to inspect.
4473      * @returns {Array} Returns the cast property path array.
4474      */
4475     function castPath(value) {
4476       return isArray(value) ? value : stringToPath(value);
4477     }
4478
4479     /**
4480      * A `baseRest` alias which can be replaced with `identity` by module
4481      * replacement plugins.
4482      *
4483      * @private
4484      * @type {Function}
4485      * @param {Function} func The function to apply a rest parameter to.
4486      * @returns {Function} Returns the new function.
4487      */
4488     var castRest = baseRest;
4489
4490     /**
4491      * Casts `array` to a slice if it's needed.
4492      *
4493      * @private
4494      * @param {Array} array The array to inspect.
4495      * @param {number} start The start position.
4496      * @param {number} [end=array.length] The end position.
4497      * @returns {Array} Returns the cast slice.
4498      */
4499     function castSlice(array, start, end) {
4500       var length = array.length;
4501       end = end === undefined ? length : end;
4502       return (!start && end >= length) ? array : baseSlice(array, start, end);
4503     }
4504
4505     /**
4506      * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4507      *
4508      * @private
4509      * @param {number|Object} id The timer id or timeout object of the timer to clear.
4510      */
4511     var clearTimeout = ctxClearTimeout || function(id) {
4512       return root.clearTimeout(id);
4513     };
4514
4515     /**
4516      * Creates a clone of  `buffer`.
4517      *
4518      * @private
4519      * @param {Buffer} buffer The buffer to clone.
4520      * @param {boolean} [isDeep] Specify a deep clone.
4521      * @returns {Buffer} Returns the cloned buffer.
4522      */
4523     function cloneBuffer(buffer, isDeep) {
4524       if (isDeep) {
4525         return buffer.slice();
4526       }
4527       var length = buffer.length,
4528           result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4529
4530       buffer.copy(result);
4531       return result;
4532     }
4533
4534     /**
4535      * Creates a clone of `arrayBuffer`.
4536      *
4537      * @private
4538      * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4539      * @returns {ArrayBuffer} Returns the cloned array buffer.
4540      */
4541     function cloneArrayBuffer(arrayBuffer) {
4542       var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4543       new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4544       return result;
4545     }
4546
4547     /**
4548      * Creates a clone of `dataView`.
4549      *
4550      * @private
4551      * @param {Object} dataView The data view to clone.
4552      * @param {boolean} [isDeep] Specify a deep clone.
4553      * @returns {Object} Returns the cloned data view.
4554      */
4555     function cloneDataView(dataView, isDeep) {
4556       var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4557       return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4558     }
4559
4560     /**
4561      * Creates a clone of `map`.
4562      *
4563      * @private
4564      * @param {Object} map The map to clone.
4565      * @param {Function} cloneFunc The function to clone values.
4566      * @param {boolean} [isDeep] Specify a deep clone.
4567      * @returns {Object} Returns the cloned map.
4568      */
4569     function cloneMap(map, isDeep, cloneFunc) {
4570       var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
4571       return arrayReduce(array, addMapEntry, new map.constructor);
4572     }
4573
4574     /**
4575      * Creates a clone of `regexp`.
4576      *
4577      * @private
4578      * @param {Object} regexp The regexp to clone.
4579      * @returns {Object} Returns the cloned regexp.
4580      */
4581     function cloneRegExp(regexp) {
4582       var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4583       result.lastIndex = regexp.lastIndex;
4584       return result;
4585     }
4586
4587     /**
4588      * Creates a clone of `set`.
4589      *
4590      * @private
4591      * @param {Object} set The set to clone.
4592      * @param {Function} cloneFunc The function to clone values.
4593      * @param {boolean} [isDeep] Specify a deep clone.
4594      * @returns {Object} Returns the cloned set.
4595      */
4596     function cloneSet(set, isDeep, cloneFunc) {
4597       var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
4598       return arrayReduce(array, addSetEntry, new set.constructor);
4599     }
4600
4601     /**
4602      * Creates a clone of the `symbol` object.
4603      *
4604      * @private
4605      * @param {Object} symbol The symbol object to clone.
4606      * @returns {Object} Returns the cloned symbol object.
4607      */
4608     function cloneSymbol(symbol) {
4609       return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4610     }
4611
4612     /**
4613      * Creates a clone of `typedArray`.
4614      *
4615      * @private
4616      * @param {Object} typedArray The typed array to clone.
4617      * @param {boolean} [isDeep] Specify a deep clone.
4618      * @returns {Object} Returns the cloned typed array.
4619      */
4620     function cloneTypedArray(typedArray, isDeep) {
4621       var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4622       return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4623     }
4624
4625     /**
4626      * Compares values to sort them in ascending order.
4627      *
4628      * @private
4629      * @param {*} value The value to compare.
4630      * @param {*} other The other value to compare.
4631      * @returns {number} Returns the sort order indicator for `value`.
4632      */
4633     function compareAscending(value, other) {
4634       if (value !== other) {
4635         var valIsDefined = value !== undefined,
4636             valIsNull = value === null,
4637             valIsReflexive = value === value,
4638             valIsSymbol = isSymbol(value);
4639
4640         var othIsDefined = other !== undefined,
4641             othIsNull = other === null,
4642             othIsReflexive = other === other,
4643             othIsSymbol = isSymbol(other);
4644
4645         if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4646             (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4647             (valIsNull && othIsDefined && othIsReflexive) ||
4648             (!valIsDefined && othIsReflexive) ||
4649             !valIsReflexive) {
4650           return 1;
4651         }
4652         if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4653             (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4654             (othIsNull && valIsDefined && valIsReflexive) ||
4655             (!othIsDefined && valIsReflexive) ||
4656             !othIsReflexive) {
4657           return -1;
4658         }
4659       }
4660       return 0;
4661     }
4662
4663     /**
4664      * Used by `_.orderBy` to compare multiple properties of a value to another
4665      * and stable sort them.
4666      *
4667      * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4668      * specify an order of "desc" for descending or "asc" for ascending sort order
4669      * of corresponding values.
4670      *
4671      * @private
4672      * @param {Object} object The object to compare.
4673      * @param {Object} other The other object to compare.
4674      * @param {boolean[]|string[]} orders The order to sort by for each property.
4675      * @returns {number} Returns the sort order indicator for `object`.
4676      */
4677     function compareMultiple(object, other, orders) {
4678       var index = -1,
4679           objCriteria = object.criteria,
4680           othCriteria = other.criteria,
4681           length = objCriteria.length,
4682           ordersLength = orders.length;
4683
4684       while (++index < length) {
4685         var result = compareAscending(objCriteria[index], othCriteria[index]);
4686         if (result) {
4687           if (index >= ordersLength) {
4688             return result;
4689           }
4690           var order = orders[index];
4691           return result * (order == 'desc' ? -1 : 1);
4692         }
4693       }
4694       // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
4695       // that causes it, under certain circumstances, to provide the same value for
4696       // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
4697       // for more details.
4698       //
4699       // This also ensures a stable sort in V8 and other engines.
4700       // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
4701       return object.index - other.index;
4702     }
4703
4704     /**
4705      * Creates an array that is the composition of partially applied arguments,
4706      * placeholders, and provided arguments into a single array of arguments.
4707      *
4708      * @private
4709      * @param {Array} args The provided arguments.
4710      * @param {Array} partials The arguments to prepend to those provided.
4711      * @param {Array} holders The `partials` placeholder indexes.
4712      * @params {boolean} [isCurried] Specify composing for a curried function.
4713      * @returns {Array} Returns the new array of composed arguments.
4714      */
4715     function composeArgs(args, partials, holders, isCurried) {
4716       var argsIndex = -1,
4717           argsLength = args.length,
4718           holdersLength = holders.length,
4719           leftIndex = -1,
4720           leftLength = partials.length,
4721           rangeLength = nativeMax(argsLength - holdersLength, 0),
4722           result = Array(leftLength + rangeLength),
4723           isUncurried = !isCurried;
4724
4725       while (++leftIndex < leftLength) {
4726         result[leftIndex] = partials[leftIndex];
4727       }
4728       while (++argsIndex < holdersLength) {
4729         if (isUncurried || argsIndex < argsLength) {
4730           result[holders[argsIndex]] = args[argsIndex];
4731         }
4732       }
4733       while (rangeLength--) {
4734         result[leftIndex++] = args[argsIndex++];
4735       }
4736       return result;
4737     }
4738
4739     /**
4740      * This function is like `composeArgs` except that the arguments composition
4741      * is tailored for `_.partialRight`.
4742      *
4743      * @private
4744      * @param {Array} args The provided arguments.
4745      * @param {Array} partials The arguments to append to those provided.
4746      * @param {Array} holders The `partials` placeholder indexes.
4747      * @params {boolean} [isCurried] Specify composing for a curried function.
4748      * @returns {Array} Returns the new array of composed arguments.
4749      */
4750     function composeArgsRight(args, partials, holders, isCurried) {
4751       var argsIndex = -1,
4752           argsLength = args.length,
4753           holdersIndex = -1,
4754           holdersLength = holders.length,
4755           rightIndex = -1,
4756           rightLength = partials.length,
4757           rangeLength = nativeMax(argsLength - holdersLength, 0),
4758           result = Array(rangeLength + rightLength),
4759           isUncurried = !isCurried;
4760
4761       while (++argsIndex < rangeLength) {
4762         result[argsIndex] = args[argsIndex];
4763       }
4764       var offset = argsIndex;
4765       while (++rightIndex < rightLength) {
4766         result[offset + rightIndex] = partials[rightIndex];
4767       }
4768       while (++holdersIndex < holdersLength) {
4769         if (isUncurried || argsIndex < argsLength) {
4770           result[offset + holders[holdersIndex]] = args[argsIndex++];
4771         }
4772       }
4773       return result;
4774     }
4775
4776     /**
4777      * Copies the values of `source` to `array`.
4778      *
4779      * @private
4780      * @param {Array} source The array to copy values from.
4781      * @param {Array} [array=[]] The array to copy values to.
4782      * @returns {Array} Returns `array`.
4783      */
4784     function copyArray(source, array) {
4785       var index = -1,
4786           length = source.length;
4787
4788       array || (array = Array(length));
4789       while (++index < length) {
4790         array[index] = source[index];
4791       }
4792       return array;
4793     }
4794
4795     /**
4796      * Copies properties of `source` to `object`.
4797      *
4798      * @private
4799      * @param {Object} source The object to copy properties from.
4800      * @param {Array} props The property identifiers to copy.
4801      * @param {Object} [object={}] The object to copy properties to.
4802      * @param {Function} [customizer] The function to customize copied values.
4803      * @returns {Object} Returns `object`.
4804      */
4805     function copyObject(source, props, object, customizer) {
4806       var isNew = !object;
4807       object || (object = {});
4808
4809       var index = -1,
4810           length = props.length;
4811
4812       while (++index < length) {
4813         var key = props[index];
4814
4815         var newValue = customizer
4816           ? customizer(object[key], source[key], key, object, source)
4817           : undefined;
4818
4819         if (newValue === undefined) {
4820           newValue = source[key];
4821         }
4822         if (isNew) {
4823           baseAssignValue(object, key, newValue);
4824         } else {
4825           assignValue(object, key, newValue);
4826         }
4827       }
4828       return object;
4829     }
4830
4831     /**
4832      * Copies own symbol properties of `source` to `object`.
4833      *
4834      * @private
4835      * @param {Object} source The object to copy symbols from.
4836      * @param {Object} [object={}] The object to copy symbols to.
4837      * @returns {Object} Returns `object`.
4838      */
4839     function copySymbols(source, object) {
4840       return copyObject(source, getSymbols(source), object);
4841     }
4842
4843     /**
4844      * Creates a function like `_.groupBy`.
4845      *
4846      * @private
4847      * @param {Function} setter The function to set accumulator values.
4848      * @param {Function} [initializer] The accumulator object initializer.
4849      * @returns {Function} Returns the new aggregator function.
4850      */
4851     function createAggregator(setter, initializer) {
4852       return function(collection, iteratee) {
4853         var func = isArray(collection) ? arrayAggregator : baseAggregator,
4854             accumulator = initializer ? initializer() : {};
4855
4856         return func(collection, setter, getIteratee(iteratee, 2), accumulator);
4857       };
4858     }
4859
4860     /**
4861      * Creates a function like `_.assign`.
4862      *
4863      * @private
4864      * @param {Function} assigner The function to assign values.
4865      * @returns {Function} Returns the new assigner function.
4866      */
4867     function createAssigner(assigner) {
4868       return baseRest(function(object, sources) {
4869         var index = -1,
4870             length = sources.length,
4871             customizer = length > 1 ? sources[length - 1] : undefined,
4872             guard = length > 2 ? sources[2] : undefined;
4873
4874         customizer = (assigner.length > 3 && typeof customizer == 'function')
4875           ? (length--, customizer)
4876           : undefined;
4877
4878         if (guard && isIterateeCall(sources[0], sources[1], guard)) {
4879           customizer = length < 3 ? undefined : customizer;
4880           length = 1;
4881         }
4882         object = Object(object);
4883         while (++index < length) {
4884           var source = sources[index];
4885           if (source) {
4886             assigner(object, source, index, customizer);
4887           }
4888         }
4889         return object;
4890       });
4891     }
4892
4893     /**
4894      * Creates a `baseEach` or `baseEachRight` function.
4895      *
4896      * @private
4897      * @param {Function} eachFunc The function to iterate over a collection.
4898      * @param {boolean} [fromRight] Specify iterating from right to left.
4899      * @returns {Function} Returns the new base function.
4900      */
4901     function createBaseEach(eachFunc, fromRight) {
4902       return function(collection, iteratee) {
4903         if (collection == null) {
4904           return collection;
4905         }
4906         if (!isArrayLike(collection)) {
4907           return eachFunc(collection, iteratee);
4908         }
4909         var length = collection.length,
4910             index = fromRight ? length : -1,
4911             iterable = Object(collection);
4912
4913         while ((fromRight ? index-- : ++index < length)) {
4914           if (iteratee(iterable[index], index, iterable) === false) {
4915             break;
4916           }
4917         }
4918         return collection;
4919       };
4920     }
4921
4922     /**
4923      * Creates a base function for methods like `_.forIn` and `_.forOwn`.
4924      *
4925      * @private
4926      * @param {boolean} [fromRight] Specify iterating from right to left.
4927      * @returns {Function} Returns the new base function.
4928      */
4929     function createBaseFor(fromRight) {
4930       return function(object, iteratee, keysFunc) {
4931         var index = -1,
4932             iterable = Object(object),
4933             props = keysFunc(object),
4934             length = props.length;
4935
4936         while (length--) {
4937           var key = props[fromRight ? length : ++index];
4938           if (iteratee(iterable[key], key, iterable) === false) {
4939             break;
4940           }
4941         }
4942         return object;
4943       };
4944     }
4945
4946     /**
4947      * Creates a function that wraps `func` to invoke it with the optional `this`
4948      * binding of `thisArg`.
4949      *
4950      * @private
4951      * @param {Function} func The function to wrap.
4952      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
4953      * @param {*} [thisArg] The `this` binding of `func`.
4954      * @returns {Function} Returns the new wrapped function.
4955      */
4956     function createBind(func, bitmask, thisArg) {
4957       var isBind = bitmask & BIND_FLAG,
4958           Ctor = createCtor(func);
4959
4960       function wrapper() {
4961         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4962         return fn.apply(isBind ? thisArg : this, arguments);
4963       }
4964       return wrapper;
4965     }
4966
4967     /**
4968      * Creates a function like `_.lowerFirst`.
4969      *
4970      * @private
4971      * @param {string} methodName The name of the `String` case method to use.
4972      * @returns {Function} Returns the new case function.
4973      */
4974     function createCaseFirst(methodName) {
4975       return function(string) {
4976         string = toString(string);
4977
4978         var strSymbols = hasUnicode(string)
4979           ? stringToArray(string)
4980           : undefined;
4981
4982         var chr = strSymbols
4983           ? strSymbols[0]
4984           : string.charAt(0);
4985
4986         var trailing = strSymbols
4987           ? castSlice(strSymbols, 1).join('')
4988           : string.slice(1);
4989
4990         return chr[methodName]() + trailing;
4991       };
4992     }
4993
4994     /**
4995      * Creates a function like `_.camelCase`.
4996      *
4997      * @private
4998      * @param {Function} callback The function to combine each word.
4999      * @returns {Function} Returns the new compounder function.
5000      */
5001     function createCompounder(callback) {
5002       return function(string) {
5003         return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
5004       };
5005     }
5006
5007     /**
5008      * Creates a function that produces an instance of `Ctor` regardless of
5009      * whether it was invoked as part of a `new` expression or by `call` or `apply`.
5010      *
5011      * @private
5012      * @param {Function} Ctor The constructor to wrap.
5013      * @returns {Function} Returns the new wrapped function.
5014      */
5015     function createCtor(Ctor) {
5016       return function() {
5017         // Use a `switch` statement to work with class constructors. See
5018         // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
5019         // for more details.
5020         var args = arguments;
5021         switch (args.length) {
5022           case 0: return new Ctor;
5023           case 1: return new Ctor(args[0]);
5024           case 2: return new Ctor(args[0], args[1]);
5025           case 3: return new Ctor(args[0], args[1], args[2]);
5026           case 4: return new Ctor(args[0], args[1], args[2], args[3]);
5027           case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5028           case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5029           case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5030         }
5031         var thisBinding = baseCreate(Ctor.prototype),
5032             result = Ctor.apply(thisBinding, args);
5033
5034         // Mimic the constructor's `return` behavior.
5035         // See https://es5.github.io/#x13.2.2 for more details.
5036         return isObject(result) ? result : thisBinding;
5037       };
5038     }
5039
5040     /**
5041      * Creates a function that wraps `func` to enable currying.
5042      *
5043      * @private
5044      * @param {Function} func The function to wrap.
5045      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5046      * @param {number} arity The arity of `func`.
5047      * @returns {Function} Returns the new wrapped function.
5048      */
5049     function createCurry(func, bitmask, arity) {
5050       var Ctor = createCtor(func);
5051
5052       function wrapper() {
5053         var length = arguments.length,
5054             args = Array(length),
5055             index = length,
5056             placeholder = getHolder(wrapper);
5057
5058         while (index--) {
5059           args[index] = arguments[index];
5060         }
5061         var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5062           ? []
5063           : replaceHolders(args, placeholder);
5064
5065         length -= holders.length;
5066         if (length < arity) {
5067           return createRecurry(
5068             func, bitmask, createHybrid, wrapper.placeholder, undefined,
5069             args, holders, undefined, undefined, arity - length);
5070         }
5071         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5072         return apply(fn, this, args);
5073       }
5074       return wrapper;
5075     }
5076
5077     /**
5078      * Creates a `_.find` or `_.findLast` function.
5079      *
5080      * @private
5081      * @param {Function} findIndexFunc The function to find the collection index.
5082      * @returns {Function} Returns the new find function.
5083      */
5084     function createFind(findIndexFunc) {
5085       return function(collection, predicate, fromIndex) {
5086         var iterable = Object(collection);
5087         if (!isArrayLike(collection)) {
5088           var iteratee = getIteratee(predicate, 3);
5089           collection = keys(collection);
5090           predicate = function(key) { return iteratee(iterable[key], key, iterable); };
5091         }
5092         var index = findIndexFunc(collection, predicate, fromIndex);
5093         return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
5094       };
5095     }
5096
5097     /**
5098      * Creates a `_.flow` or `_.flowRight` function.
5099      *
5100      * @private
5101      * @param {boolean} [fromRight] Specify iterating from right to left.
5102      * @returns {Function} Returns the new flow function.
5103      */
5104     function createFlow(fromRight) {
5105       return flatRest(function(funcs) {
5106         var length = funcs.length,
5107             index = length,
5108             prereq = LodashWrapper.prototype.thru;
5109
5110         if (fromRight) {
5111           funcs.reverse();
5112         }
5113         while (index--) {
5114           var func = funcs[index];
5115           if (typeof func != 'function') {
5116             throw new TypeError(FUNC_ERROR_TEXT);
5117           }
5118           if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5119             var wrapper = new LodashWrapper([], true);
5120           }
5121         }
5122         index = wrapper ? index : length;
5123         while (++index < length) {
5124           func = funcs[index];
5125
5126           var funcName = getFuncName(func),
5127               data = funcName == 'wrapper' ? getData(func) : undefined;
5128
5129           if (data && isLaziable(data[0]) &&
5130                 data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
5131                 !data[4].length && data[9] == 1
5132               ) {
5133             wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5134           } else {
5135             wrapper = (func.length == 1 && isLaziable(func))
5136               ? wrapper[funcName]()
5137               : wrapper.thru(func);
5138           }
5139         }
5140         return function() {
5141           var args = arguments,
5142               value = args[0];
5143
5144           if (wrapper && args.length == 1 &&
5145               isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
5146             return wrapper.plant(value).value();
5147           }
5148           var index = 0,
5149               result = length ? funcs[index].apply(this, args) : value;
5150
5151           while (++index < length) {
5152             result = funcs[index].call(this, result);
5153           }
5154           return result;
5155         };
5156       });
5157     }
5158
5159     /**
5160      * Creates a function that wraps `func` to invoke it with optional `this`
5161      * binding of `thisArg`, partial application, and currying.
5162      *
5163      * @private
5164      * @param {Function|string} func The function or method name to wrap.
5165      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5166      * @param {*} [thisArg] The `this` binding of `func`.
5167      * @param {Array} [partials] The arguments to prepend to those provided to
5168      *  the new function.
5169      * @param {Array} [holders] The `partials` placeholder indexes.
5170      * @param {Array} [partialsRight] The arguments to append to those provided
5171      *  to the new function.
5172      * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
5173      * @param {Array} [argPos] The argument positions of the new function.
5174      * @param {number} [ary] The arity cap of `func`.
5175      * @param {number} [arity] The arity of `func`.
5176      * @returns {Function} Returns the new wrapped function.
5177      */
5178     function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5179       var isAry = bitmask & ARY_FLAG,
5180           isBind = bitmask & BIND_FLAG,
5181           isBindKey = bitmask & BIND_KEY_FLAG,
5182           isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
5183           isFlip = bitmask & FLIP_FLAG,
5184           Ctor = isBindKey ? undefined : createCtor(func);
5185
5186       function wrapper() {
5187         var length = arguments.length,
5188             args = Array(length),
5189             index = length;
5190
5191         while (index--) {
5192           args[index] = arguments[index];
5193         }
5194         if (isCurried) {
5195           var placeholder = getHolder(wrapper),
5196               holdersCount = countHolders(args, placeholder);
5197         }
5198         if (partials) {
5199           args = composeArgs(args, partials, holders, isCurried);
5200         }
5201         if (partialsRight) {
5202           args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
5203         }
5204         length -= holdersCount;
5205         if (isCurried && length < arity) {
5206           var newHolders = replaceHolders(args, placeholder);
5207           return createRecurry(
5208             func, bitmask, createHybrid, wrapper.placeholder, thisArg,
5209             args, newHolders, argPos, ary, arity - length
5210           );
5211         }
5212         var thisBinding = isBind ? thisArg : this,
5213             fn = isBindKey ? thisBinding[func] : func;
5214
5215         length = args.length;
5216         if (argPos) {
5217           args = reorder(args, argPos);
5218         } else if (isFlip && length > 1) {
5219           args.reverse();
5220         }
5221         if (isAry && ary < length) {
5222           args.length = ary;
5223         }
5224         if (this && this !== root && this instanceof wrapper) {
5225           fn = Ctor || createCtor(fn);
5226         }
5227         return fn.apply(thisBinding, args);
5228       }
5229       return wrapper;
5230     }
5231
5232     /**
5233      * Creates a function like `_.invertBy`.
5234      *
5235      * @private
5236      * @param {Function} setter The function to set accumulator values.
5237      * @param {Function} toIteratee The function to resolve iteratees.
5238      * @returns {Function} Returns the new inverter function.
5239      */
5240     function createInverter(setter, toIteratee) {
5241       return function(object, iteratee) {
5242         return baseInverter(object, setter, toIteratee(iteratee), {});
5243       };
5244     }
5245
5246     /**
5247      * Creates a function that performs a mathematical operation on two values.
5248      *
5249      * @private
5250      * @param {Function} operator The function to perform the operation.
5251      * @param {number} [defaultValue] The value used for `undefined` arguments.
5252      * @returns {Function} Returns the new mathematical operation function.
5253      */
5254     function createMathOperation(operator, defaultValue) {
5255       return function(value, other) {
5256         var result;
5257         if (value === undefined && other === undefined) {
5258           return defaultValue;
5259         }
5260         if (value !== undefined) {
5261           result = value;
5262         }
5263         if (other !== undefined) {
5264           if (result === undefined) {
5265             return other;
5266           }
5267           if (typeof value == 'string' || typeof other == 'string') {
5268             value = baseToString(value);
5269             other = baseToString(other);
5270           } else {
5271             value = baseToNumber(value);
5272             other = baseToNumber(other);
5273           }
5274           result = operator(value, other);
5275         }
5276         return result;
5277       };
5278     }
5279
5280     /**
5281      * Creates a function like `_.over`.
5282      *
5283      * @private
5284      * @param {Function} arrayFunc The function to iterate over iteratees.
5285      * @returns {Function} Returns the new over function.
5286      */
5287     function createOver(arrayFunc) {
5288       return flatRest(function(iteratees) {
5289         iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5290         return baseRest(function(args) {
5291           var thisArg = this;
5292           return arrayFunc(iteratees, function(iteratee) {
5293             return apply(iteratee, thisArg, args);
5294           });
5295         });
5296       });
5297     }
5298
5299     /**
5300      * Creates the padding for `string` based on `length`. The `chars` string
5301      * is truncated if the number of characters exceeds `length`.
5302      *
5303      * @private
5304      * @param {number} length The padding length.
5305      * @param {string} [chars=' '] The string used as padding.
5306      * @returns {string} Returns the padding for `string`.
5307      */
5308     function createPadding(length, chars) {
5309       chars = chars === undefined ? ' ' : baseToString(chars);
5310
5311       var charsLength = chars.length;
5312       if (charsLength < 2) {
5313         return charsLength ? baseRepeat(chars, length) : chars;
5314       }
5315       var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
5316       return hasUnicode(chars)
5317         ? castSlice(stringToArray(result), 0, length).join('')
5318         : result.slice(0, length);
5319     }
5320
5321     /**
5322      * Creates a function that wraps `func` to invoke it with the `this` binding
5323      * of `thisArg` and `partials` prepended to the arguments it receives.
5324      *
5325      * @private
5326      * @param {Function} func The function to wrap.
5327      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5328      * @param {*} thisArg The `this` binding of `func`.
5329      * @param {Array} partials The arguments to prepend to those provided to
5330      *  the new function.
5331      * @returns {Function} Returns the new wrapped function.
5332      */
5333     function createPartial(func, bitmask, thisArg, partials) {
5334       var isBind = bitmask & BIND_FLAG,
5335           Ctor = createCtor(func);
5336
5337       function wrapper() {
5338         var argsIndex = -1,
5339             argsLength = arguments.length,
5340             leftIndex = -1,
5341             leftLength = partials.length,
5342             args = Array(leftLength + argsLength),
5343             fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5344
5345         while (++leftIndex < leftLength) {
5346           args[leftIndex] = partials[leftIndex];
5347         }
5348         while (argsLength--) {
5349           args[leftIndex++] = arguments[++argsIndex];
5350         }
5351         return apply(fn, isBind ? thisArg : this, args);
5352       }
5353       return wrapper;
5354     }
5355
5356     /**
5357      * Creates a `_.range` or `_.rangeRight` function.
5358      *
5359      * @private
5360      * @param {boolean} [fromRight] Specify iterating from right to left.
5361      * @returns {Function} Returns the new range function.
5362      */
5363     function createRange(fromRight) {
5364       return function(start, end, step) {
5365         if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5366           end = step = undefined;
5367         }
5368         // Ensure the sign of `-0` is preserved.
5369         start = toFinite(start);
5370         if (end === undefined) {
5371           end = start;
5372           start = 0;
5373         } else {
5374           end = toFinite(end);
5375         }
5376         step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
5377         return baseRange(start, end, step, fromRight);
5378       };
5379     }
5380
5381     /**
5382      * Creates a function that performs a relational operation on two values.
5383      *
5384      * @private
5385      * @param {Function} operator The function to perform the operation.
5386      * @returns {Function} Returns the new relational operation function.
5387      */
5388     function createRelationalOperation(operator) {
5389       return function(value, other) {
5390         if (!(typeof value == 'string' && typeof other == 'string')) {
5391           value = toNumber(value);
5392           other = toNumber(other);
5393         }
5394         return operator(value, other);
5395       };
5396     }
5397
5398     /**
5399      * Creates a function that wraps `func` to continue currying.
5400      *
5401      * @private
5402      * @param {Function} func The function to wrap.
5403      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5404      * @param {Function} wrapFunc The function to create the `func` wrapper.
5405      * @param {*} placeholder The placeholder value.
5406      * @param {*} [thisArg] The `this` binding of `func`.
5407      * @param {Array} [partials] The arguments to prepend to those provided to
5408      *  the new function.
5409      * @param {Array} [holders] The `partials` placeholder indexes.
5410      * @param {Array} [argPos] The argument positions of the new function.
5411      * @param {number} [ary] The arity cap of `func`.
5412      * @param {number} [arity] The arity of `func`.
5413      * @returns {Function} Returns the new wrapped function.
5414      */
5415     function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
5416       var isCurry = bitmask & CURRY_FLAG,
5417           newHolders = isCurry ? holders : undefined,
5418           newHoldersRight = isCurry ? undefined : holders,
5419           newPartials = isCurry ? partials : undefined,
5420           newPartialsRight = isCurry ? undefined : partials;
5421
5422       bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
5423       bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
5424
5425       if (!(bitmask & CURRY_BOUND_FLAG)) {
5426         bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
5427       }
5428       var newData = [
5429         func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5430         newHoldersRight, argPos, ary, arity
5431       ];
5432
5433       var result = wrapFunc.apply(undefined, newData);
5434       if (isLaziable(func)) {
5435         setData(result, newData);
5436       }
5437       result.placeholder = placeholder;
5438       return setWrapToString(result, func, bitmask);
5439     }
5440
5441     /**
5442      * Creates a function like `_.round`.
5443      *
5444      * @private
5445      * @param {string} methodName The name of the `Math` method to use when rounding.
5446      * @returns {Function} Returns the new round function.
5447      */
5448     function createRound(methodName) {
5449       var func = Math[methodName];
5450       return function(number, precision) {
5451         number = toNumber(number);
5452         precision = nativeMin(toInteger(precision), 292);
5453         if (precision) {
5454           // Shift with exponential notation to avoid floating-point issues.
5455           // See [MDN](https://mdn.io/round#Examples) for more details.
5456           var pair = (toString(number) + 'e').split('e'),
5457               value = func(pair[0] + 'e' + (+pair[1] + precision));
5458
5459           pair = (toString(value) + 'e').split('e');
5460           return +(pair[0] + 'e' + (+pair[1] - precision));
5461         }
5462         return func(number);
5463       };
5464     }
5465
5466     /**
5467      * Creates a set object of `values`.
5468      *
5469      * @private
5470      * @param {Array} values The values to add to the set.
5471      * @returns {Object} Returns the new set.
5472      */
5473     var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
5474       return new Set(values);
5475     };
5476
5477     /**
5478      * Creates a `_.toPairs` or `_.toPairsIn` function.
5479      *
5480      * @private
5481      * @param {Function} keysFunc The function to get the keys of a given object.
5482      * @returns {Function} Returns the new pairs function.
5483      */
5484     function createToPairs(keysFunc) {
5485       return function(object) {
5486         var tag = getTag(object);
5487         if (tag == mapTag) {
5488           return mapToArray(object);
5489         }
5490         if (tag == setTag) {
5491           return setToPairs(object);
5492         }
5493         return baseToPairs(object, keysFunc(object));
5494       };
5495     }
5496
5497     /**
5498      * Creates a function that either curries or invokes `func` with optional
5499      * `this` binding and partially applied arguments.
5500      *
5501      * @private
5502      * @param {Function|string} func The function or method name to wrap.
5503      * @param {number} bitmask The bitmask flags.
5504      *  The bitmask may be composed of the following flags:
5505      *     1 - `_.bind`
5506      *     2 - `_.bindKey`
5507      *     4 - `_.curry` or `_.curryRight` of a bound function
5508      *     8 - `_.curry`
5509      *    16 - `_.curryRight`
5510      *    32 - `_.partial`
5511      *    64 - `_.partialRight`
5512      *   128 - `_.rearg`
5513      *   256 - `_.ary`
5514      *   512 - `_.flip`
5515      * @param {*} [thisArg] The `this` binding of `func`.
5516      * @param {Array} [partials] The arguments to be partially applied.
5517      * @param {Array} [holders] The `partials` placeholder indexes.
5518      * @param {Array} [argPos] The argument positions of the new function.
5519      * @param {number} [ary] The arity cap of `func`.
5520      * @param {number} [arity] The arity of `func`.
5521      * @returns {Function} Returns the new wrapped function.
5522      */
5523     function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5524       var isBindKey = bitmask & BIND_KEY_FLAG;
5525       if (!isBindKey && typeof func != 'function') {
5526         throw new TypeError(FUNC_ERROR_TEXT);
5527       }
5528       var length = partials ? partials.length : 0;
5529       if (!length) {
5530         bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
5531         partials = holders = undefined;
5532       }
5533       ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
5534       arity = arity === undefined ? arity : toInteger(arity);
5535       length -= holders ? holders.length : 0;
5536
5537       if (bitmask & PARTIAL_RIGHT_FLAG) {
5538         var partialsRight = partials,
5539             holdersRight = holders;
5540
5541         partials = holders = undefined;
5542       }
5543       var data = isBindKey ? undefined : getData(func);
5544
5545       var newData = [
5546         func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5547         argPos, ary, arity
5548       ];
5549
5550       if (data) {
5551         mergeData(newData, data);
5552       }
5553       func = newData[0];
5554       bitmask = newData[1];
5555       thisArg = newData[2];
5556       partials = newData[3];
5557       holders = newData[4];
5558       arity = newData[9] = newData[9] == null
5559         ? (isBindKey ? 0 : func.length)
5560         : nativeMax(newData[9] - length, 0);
5561
5562       if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) {
5563         bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG);
5564       }
5565       if (!bitmask || bitmask == BIND_FLAG) {
5566         var result = createBind(func, bitmask, thisArg);
5567       } else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) {
5568         result = createCurry(func, bitmask, arity);
5569       } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) {
5570         result = createPartial(func, bitmask, thisArg, partials);
5571       } else {
5572         result = createHybrid.apply(undefined, newData);
5573       }
5574       var setter = data ? baseSetData : setData;
5575       return setWrapToString(setter(result, newData), func, bitmask);
5576     }
5577
5578     /**
5579      * A specialized version of `baseIsEqualDeep` for arrays with support for
5580      * partial deep comparisons.
5581      *
5582      * @private
5583      * @param {Array} array The array to compare.
5584      * @param {Array} other The other array to compare.
5585      * @param {Function} equalFunc The function to determine equivalents of values.
5586      * @param {Function} customizer The function to customize comparisons.
5587      * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
5588      *  for more details.
5589      * @param {Object} stack Tracks traversed `array` and `other` objects.
5590      * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
5591      */
5592     function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
5593       var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
5594           arrLength = array.length,
5595           othLength = other.length;
5596
5597       if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5598         return false;
5599       }
5600       // Assume cyclic values are equal.
5601       var stacked = stack.get(array);
5602       if (stacked && stack.get(other)) {
5603         return stacked == other;
5604       }
5605       var index = -1,
5606           result = true,
5607           seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
5608
5609       stack.set(array, other);
5610       stack.set(other, array);
5611
5612       // Ignore non-index properties.
5613       while (++index < arrLength) {
5614         var arrValue = array[index],
5615             othValue = other[index];
5616
5617         if (customizer) {
5618           var compared = isPartial
5619             ? customizer(othValue, arrValue, index, other, array, stack)
5620             : customizer(arrValue, othValue, index, array, other, stack);
5621         }
5622         if (compared !== undefined) {
5623           if (compared) {
5624             continue;
5625           }
5626           result = false;
5627           break;
5628         }
5629         // Recursively compare arrays (susceptible to call stack limits).
5630         if (seen) {
5631           if (!arraySome(other, function(othValue, othIndex) {
5632                 if (!cacheHas(seen, othIndex) &&
5633                     (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
5634                   return seen.push(othIndex);
5635                 }
5636               })) {
5637             result = false;
5638             break;
5639           }
5640         } else if (!(
5641               arrValue === othValue ||
5642                 equalFunc(arrValue, othValue, customizer, bitmask, stack)
5643             )) {
5644           result = false;
5645           break;
5646         }
5647       }
5648       stack['delete'](array);
5649       stack['delete'](other);
5650       return result;
5651     }
5652
5653     /**
5654      * A specialized version of `baseIsEqualDeep` for comparing objects of
5655      * the same `toStringTag`.
5656      *
5657      * **Note:** This function only supports comparing values with tags of
5658      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5659      *
5660      * @private
5661      * @param {Object} object The object to compare.
5662      * @param {Object} other The other object to compare.
5663      * @param {string} tag The `toStringTag` of the objects to compare.
5664      * @param {Function} equalFunc The function to determine equivalents of values.
5665      * @param {Function} customizer The function to customize comparisons.
5666      * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
5667      *  for more details.
5668      * @param {Object} stack Tracks traversed `object` and `other` objects.
5669      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5670      */
5671     function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
5672       switch (tag) {
5673         case dataViewTag:
5674           if ((object.byteLength != other.byteLength) ||
5675               (object.byteOffset != other.byteOffset)) {
5676             return false;
5677           }
5678           object = object.buffer;
5679           other = other.buffer;
5680
5681         case arrayBufferTag:
5682           if ((object.byteLength != other.byteLength) ||
5683               !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5684             return false;
5685           }
5686           return true;
5687
5688         case boolTag:
5689         case dateTag:
5690         case numberTag:
5691           // Coerce booleans to `1` or `0` and dates to milliseconds.
5692           // Invalid dates are coerced to `NaN`.
5693           return eq(+object, +other);
5694
5695         case errorTag:
5696           return object.name == other.name && object.message == other.message;
5697
5698         case regexpTag:
5699         case stringTag:
5700           // Coerce regexes to strings and treat strings, primitives and objects,
5701           // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
5702           // for more details.
5703           return object == (other + '');
5704
5705         case mapTag:
5706           var convert = mapToArray;
5707
5708         case setTag:
5709           var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
5710           convert || (convert = setToArray);
5711
5712           if (object.size != other.size && !isPartial) {
5713             return false;
5714           }
5715           // Assume cyclic values are equal.
5716           var stacked = stack.get(object);
5717           if (stacked) {
5718             return stacked == other;
5719           }
5720           bitmask |= UNORDERED_COMPARE_FLAG;
5721
5722           // Recursively compare objects (susceptible to call stack limits).
5723           stack.set(object, other);
5724           var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
5725           stack['delete'](object);
5726           return result;
5727
5728         case symbolTag:
5729           if (symbolValueOf) {
5730             return symbolValueOf.call(object) == symbolValueOf.call(other);
5731           }
5732       }
5733       return false;
5734     }
5735
5736     /**
5737      * A specialized version of `baseIsEqualDeep` for objects with support for
5738      * partial deep comparisons.
5739      *
5740      * @private
5741      * @param {Object} object The object to compare.
5742      * @param {Object} other The other object to compare.
5743      * @param {Function} equalFunc The function to determine equivalents of values.
5744      * @param {Function} customizer The function to customize comparisons.
5745      * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
5746      *  for more details.
5747      * @param {Object} stack Tracks traversed `object` and `other` objects.
5748      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5749      */
5750     function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
5751       var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
5752           objProps = keys(object),
5753           objLength = objProps.length,
5754           othProps = keys(other),
5755           othLength = othProps.length;
5756
5757       if (objLength != othLength && !isPartial) {
5758         return false;
5759       }
5760       var index = objLength;
5761       while (index--) {
5762         var key = objProps[index];
5763         if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
5764           return false;
5765         }
5766       }
5767       // Assume cyclic values are equal.
5768       var stacked = stack.get(object);
5769       if (stacked && stack.get(other)) {
5770         return stacked == other;
5771       }
5772       var result = true;
5773       stack.set(object, other);
5774       stack.set(other, object);
5775
5776       var skipCtor = isPartial;
5777       while (++index < objLength) {
5778         key = objProps[index];
5779         var objValue = object[key],
5780             othValue = other[key];
5781
5782         if (customizer) {
5783           var compared = isPartial
5784             ? customizer(othValue, objValue, key, other, object, stack)
5785             : customizer(objValue, othValue, key, object, other, stack);
5786         }
5787         // Recursively compare objects (susceptible to call stack limits).
5788         if (!(compared === undefined
5789               ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
5790               : compared
5791             )) {
5792           result = false;
5793           break;
5794         }
5795         skipCtor || (skipCtor = key == 'constructor');
5796       }
5797       if (result && !skipCtor) {
5798         var objCtor = object.constructor,
5799             othCtor = other.constructor;
5800
5801         // Non `Object` object instances with different constructors are not equal.
5802         if (objCtor != othCtor &&
5803             ('constructor' in object && 'constructor' in other) &&
5804             !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
5805               typeof othCtor == 'function' && othCtor instanceof othCtor)) {
5806           result = false;
5807         }
5808       }
5809       stack['delete'](object);
5810       stack['delete'](other);
5811       return result;
5812     }
5813
5814     /**
5815      * A specialized version of `baseRest` which flattens the rest array.
5816      *
5817      * @private
5818      * @param {Function} func The function to apply a rest parameter to.
5819      * @returns {Function} Returns the new function.
5820      */
5821     function flatRest(func) {
5822       return setToString(overRest(func, undefined, flatten), func + '');
5823     }
5824
5825     /**
5826      * Creates an array of own enumerable property names and symbols of `object`.
5827      *
5828      * @private
5829      * @param {Object} object The object to query.
5830      * @returns {Array} Returns the array of property names and symbols.
5831      */
5832     function getAllKeys(object) {
5833       return baseGetAllKeys(object, keys, getSymbols);
5834     }
5835
5836     /**
5837      * Creates an array of own and inherited enumerable property names and
5838      * symbols of `object`.
5839      *
5840      * @private
5841      * @param {Object} object The object to query.
5842      * @returns {Array} Returns the array of property names and symbols.
5843      */
5844     function getAllKeysIn(object) {
5845       return baseGetAllKeys(object, keysIn, getSymbolsIn);
5846     }
5847
5848     /**
5849      * Gets metadata for `func`.
5850      *
5851      * @private
5852      * @param {Function} func The function to query.
5853      * @returns {*} Returns the metadata for `func`.
5854      */
5855     var getData = !metaMap ? noop : function(func) {
5856       return metaMap.get(func);
5857     };
5858
5859     /**
5860      * Gets the name of `func`.
5861      *
5862      * @private
5863      * @param {Function} func The function to query.
5864      * @returns {string} Returns the function name.
5865      */
5866     function getFuncName(func) {
5867       var result = (func.name + ''),
5868           array = realNames[result],
5869           length = hasOwnProperty.call(realNames, result) ? array.length : 0;
5870
5871       while (length--) {
5872         var data = array[length],
5873             otherFunc = data.func;
5874         if (otherFunc == null || otherFunc == func) {
5875           return data.name;
5876         }
5877       }
5878       return result;
5879     }
5880
5881     /**
5882      * Gets the argument placeholder value for `func`.
5883      *
5884      * @private
5885      * @param {Function} func The function to inspect.
5886      * @returns {*} Returns the placeholder value.
5887      */
5888     function getHolder(func) {
5889       var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
5890       return object.placeholder;
5891     }
5892
5893     /**
5894      * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
5895      * this function returns the custom method, otherwise it returns `baseIteratee`.
5896      * If arguments are provided, the chosen function is invoked with them and
5897      * its result is returned.
5898      *
5899      * @private
5900      * @param {*} [value] The value to convert to an iteratee.
5901      * @param {number} [arity] The arity of the created iteratee.
5902      * @returns {Function} Returns the chosen function or its result.
5903      */
5904     function getIteratee() {
5905       var result = lodash.iteratee || iteratee;
5906       result = result === iteratee ? baseIteratee : result;
5907       return arguments.length ? result(arguments[0], arguments[1]) : result;
5908     }
5909
5910     /**
5911      * Gets the data for `map`.
5912      *
5913      * @private
5914      * @param {Object} map The map to query.
5915      * @param {string} key The reference key.
5916      * @returns {*} Returns the map data.
5917      */
5918     function getMapData(map, key) {
5919       var data = map.__data__;
5920       return isKeyable(key)
5921         ? data[typeof key == 'string' ? 'string' : 'hash']
5922         : data.map;
5923     }
5924
5925     /**
5926      * Gets the property names, values, and compare flags of `object`.
5927      *
5928      * @private
5929      * @param {Object} object The object to query.
5930      * @returns {Array} Returns the match data of `object`.
5931      */
5932     function getMatchData(object) {
5933       var result = keys(object),
5934           length = result.length;
5935
5936       while (length--) {
5937         var key = result[length],
5938             value = object[key];
5939
5940         result[length] = [key, value, isStrictComparable(value)];
5941       }
5942       return result;
5943     }
5944
5945     /**
5946      * Gets the native function at `key` of `object`.
5947      *
5948      * @private
5949      * @param {Object} object The object to query.
5950      * @param {string} key The key of the method to get.
5951      * @returns {*} Returns the function if it's native, else `undefined`.
5952      */
5953     function getNative(object, key) {
5954       var value = getValue(object, key);
5955       return baseIsNative(value) ? value : undefined;
5956     }
5957
5958     /**
5959      * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
5960      *
5961      * @private
5962      * @param {*} value The value to query.
5963      * @returns {string} Returns the raw `toStringTag`.
5964      */
5965     function getRawTag(value) {
5966       var isOwn = hasOwnProperty.call(value, symToStringTag),
5967           tag = value[symToStringTag];
5968
5969       try {
5970         value[symToStringTag] = undefined;
5971         var unmasked = true;
5972       } catch (e) {}
5973
5974       var result = nativeObjectToString.call(value);
5975       if (unmasked) {
5976         if (isOwn) {
5977           value[symToStringTag] = tag;
5978         } else {
5979           delete value[symToStringTag];
5980         }
5981       }
5982       return result;
5983     }
5984
5985     /**
5986      * Creates an array of the own enumerable symbol properties of `object`.
5987      *
5988      * @private
5989      * @param {Object} object The object to query.
5990      * @returns {Array} Returns the array of symbols.
5991      */
5992     var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
5993
5994     /**
5995      * Creates an array of the own and inherited enumerable symbol properties
5996      * of `object`.
5997      *
5998      * @private
5999      * @param {Object} object The object to query.
6000      * @returns {Array} Returns the array of symbols.
6001      */
6002     var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6003       var result = [];
6004       while (object) {
6005         arrayPush(result, getSymbols(object));
6006         object = getPrototype(object);
6007       }
6008       return result;
6009     };
6010
6011     /**
6012      * Gets the `toStringTag` of `value`.
6013      *
6014      * @private
6015      * @param {*} value The value to query.
6016      * @returns {string} Returns the `toStringTag`.
6017      */
6018     var getTag = baseGetTag;
6019
6020     // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
6021     if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
6022         (Map && getTag(new Map) != mapTag) ||
6023         (Promise && getTag(Promise.resolve()) != promiseTag) ||
6024         (Set && getTag(new Set) != setTag) ||
6025         (WeakMap && getTag(new WeakMap) != weakMapTag)) {
6026       getTag = function(value) {
6027         var result = baseGetTag(value),
6028             Ctor = result == objectTag ? value.constructor : undefined,
6029             ctorString = Ctor ? toSource(Ctor) : '';
6030
6031         if (ctorString) {
6032           switch (ctorString) {
6033             case dataViewCtorString: return dataViewTag;
6034             case mapCtorString: return mapTag;
6035             case promiseCtorString: return promiseTag;
6036             case setCtorString: return setTag;
6037             case weakMapCtorString: return weakMapTag;
6038           }
6039         }
6040         return result;
6041       };
6042     }
6043
6044     /**
6045      * Gets the view, applying any `transforms` to the `start` and `end` positions.
6046      *
6047      * @private
6048      * @param {number} start The start of the view.
6049      * @param {number} end The end of the view.
6050      * @param {Array} transforms The transformations to apply to the view.
6051      * @returns {Object} Returns an object containing the `start` and `end`
6052      *  positions of the view.
6053      */
6054     function getView(start, end, transforms) {
6055       var index = -1,
6056           length = transforms.length;
6057
6058       while (++index < length) {
6059         var data = transforms[index],
6060             size = data.size;
6061
6062         switch (data.type) {
6063           case 'drop':      start += size; break;
6064           case 'dropRight': end -= size; break;
6065           case 'take':      end = nativeMin(end, start + size); break;
6066           case 'takeRight': start = nativeMax(start, end - size); break;
6067         }
6068       }
6069       return { 'start': start, 'end': end };
6070     }
6071
6072     /**
6073      * Extracts wrapper details from the `source` body comment.
6074      *
6075      * @private
6076      * @param {string} source The source to inspect.
6077      * @returns {Array} Returns the wrapper details.
6078      */
6079     function getWrapDetails(source) {
6080       var match = source.match(reWrapDetails);
6081       return match ? match[1].split(reSplitDetails) : [];
6082     }
6083
6084     /**
6085      * Checks if `path` exists on `object`.
6086      *
6087      * @private
6088      * @param {Object} object The object to query.
6089      * @param {Array|string} path The path to check.
6090      * @param {Function} hasFunc The function to check properties.
6091      * @returns {boolean} Returns `true` if `path` exists, else `false`.
6092      */
6093     function hasPath(object, path, hasFunc) {
6094       path = isKey(path, object) ? [path] : castPath(path);
6095
6096       var index = -1,
6097           length = path.length,
6098           result = false;
6099
6100       while (++index < length) {
6101         var key = toKey(path[index]);
6102         if (!(result = object != null && hasFunc(object, key))) {
6103           break;
6104         }
6105         object = object[key];
6106       }
6107       if (result || ++index != length) {
6108         return result;
6109       }
6110       length = object == null ? 0 : object.length;
6111       return !!length && isLength(length) && isIndex(key, length) &&
6112         (isArray(object) || isArguments(object));
6113     }
6114
6115     /**
6116      * Initializes an array clone.
6117      *
6118      * @private
6119      * @param {Array} array The array to clone.
6120      * @returns {Array} Returns the initialized clone.
6121      */
6122     function initCloneArray(array) {
6123       var length = array.length,
6124           result = array.constructor(length);
6125
6126       // Add properties assigned by `RegExp#exec`.
6127       if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
6128         result.index = array.index;
6129         result.input = array.input;
6130       }
6131       return result;
6132     }
6133
6134     /**
6135      * Initializes an object clone.
6136      *
6137      * @private
6138      * @param {Object} object The object to clone.
6139      * @returns {Object} Returns the initialized clone.
6140      */
6141     function initCloneObject(object) {
6142       return (typeof object.constructor == 'function' && !isPrototype(object))
6143         ? baseCreate(getPrototype(object))
6144         : {};
6145     }
6146
6147     /**
6148      * Initializes an object clone based on its `toStringTag`.
6149      *
6150      * **Note:** This function only supports cloning values with tags of
6151      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
6152      *
6153      * @private
6154      * @param {Object} object The object to clone.
6155      * @param {string} tag The `toStringTag` of the object to clone.
6156      * @param {Function} cloneFunc The function to clone values.
6157      * @param {boolean} [isDeep] Specify a deep clone.
6158      * @returns {Object} Returns the initialized clone.
6159      */
6160     function initCloneByTag(object, tag, cloneFunc, isDeep) {
6161       var Ctor = object.constructor;
6162       switch (tag) {
6163         case arrayBufferTag:
6164           return cloneArrayBuffer(object);
6165
6166         case boolTag:
6167         case dateTag:
6168           return new Ctor(+object);
6169
6170         case dataViewTag:
6171           return cloneDataView(object, isDeep);
6172
6173         case float32Tag: case float64Tag:
6174         case int8Tag: case int16Tag: case int32Tag:
6175         case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
6176           return cloneTypedArray(object, isDeep);
6177
6178         case mapTag:
6179           return cloneMap(object, isDeep, cloneFunc);
6180
6181         case numberTag:
6182         case stringTag:
6183           return new Ctor(object);
6184
6185         case regexpTag:
6186           return cloneRegExp(object);
6187
6188         case setTag:
6189           return cloneSet(object, isDeep, cloneFunc);
6190
6191         case symbolTag:
6192           return cloneSymbol(object);
6193       }
6194     }
6195
6196     /**
6197      * Inserts wrapper `details` in a comment at the top of the `source` body.
6198      *
6199      * @private
6200      * @param {string} source The source to modify.
6201      * @returns {Array} details The details to insert.
6202      * @returns {string} Returns the modified source.
6203      */
6204     function insertWrapDetails(source, details) {
6205       var length = details.length;
6206       if (!length) {
6207         return source;
6208       }
6209       var lastIndex = length - 1;
6210       details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
6211       details = details.join(length > 2 ? ', ' : ' ');
6212       return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
6213     }
6214
6215     /**
6216      * Checks if `value` is a flattenable `arguments` object or array.
6217      *
6218      * @private
6219      * @param {*} value The value to check.
6220      * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6221      */
6222     function isFlattenable(value) {
6223       return isArray(value) || isArguments(value) ||
6224         !!(spreadableSymbol && value && value[spreadableSymbol]);
6225     }
6226
6227     /**
6228      * Checks if `value` is a valid array-like index.
6229      *
6230      * @private
6231      * @param {*} value The value to check.
6232      * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
6233      * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
6234      */
6235     function isIndex(value, length) {
6236       length = length == null ? MAX_SAFE_INTEGER : length;
6237       return !!length &&
6238         (typeof value == 'number' || reIsUint.test(value)) &&
6239         (value > -1 && value % 1 == 0 && value < length);
6240     }
6241
6242     /**
6243      * Checks if the given arguments are from an iteratee call.
6244      *
6245      * @private
6246      * @param {*} value The potential iteratee value argument.
6247      * @param {*} index The potential iteratee index or key argument.
6248      * @param {*} object The potential iteratee object argument.
6249      * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
6250      *  else `false`.
6251      */
6252     function isIterateeCall(value, index, object) {
6253       if (!isObject(object)) {
6254         return false;
6255       }
6256       var type = typeof index;
6257       if (type == 'number'
6258             ? (isArrayLike(object) && isIndex(index, object.length))
6259             : (type == 'string' && index in object)
6260           ) {
6261         return eq(object[index], value);
6262       }
6263       return false;
6264     }
6265
6266     /**
6267      * Checks if `value` is a property name and not a property path.
6268      *
6269      * @private
6270      * @param {*} value The value to check.
6271      * @param {Object} [object] The object to query keys on.
6272      * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
6273      */
6274     function isKey(value, object) {
6275       if (isArray(value)) {
6276         return false;
6277       }
6278       var type = typeof value;
6279       if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6280           value == null || isSymbol(value)) {
6281         return true;
6282       }
6283       return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6284         (object != null && value in Object(object));
6285     }
6286
6287     /**
6288      * Checks if `value` is suitable for use as unique object key.
6289      *
6290      * @private
6291      * @param {*} value The value to check.
6292      * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6293      */
6294     function isKeyable(value) {
6295       var type = typeof value;
6296       return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
6297         ? (value !== '__proto__')
6298         : (value === null);
6299     }
6300
6301     /**
6302      * Checks if `func` has a lazy counterpart.
6303      *
6304      * @private
6305      * @param {Function} func The function to check.
6306      * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6307      *  else `false`.
6308      */
6309     function isLaziable(func) {
6310       var funcName = getFuncName(func),
6311           other = lodash[funcName];
6312
6313       if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6314         return false;
6315       }
6316       if (func === other) {
6317         return true;
6318       }
6319       var data = getData(other);
6320       return !!data && func === data[0];
6321     }
6322
6323     /**
6324      * Checks if `func` has its source masked.
6325      *
6326      * @private
6327      * @param {Function} func The function to check.
6328      * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6329      */
6330     function isMasked(func) {
6331       return !!maskSrcKey && (maskSrcKey in func);
6332     }
6333
6334     /**
6335      * Checks if `func` is capable of being masked.
6336      *
6337      * @private
6338      * @param {*} value The value to check.
6339      * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6340      */
6341     var isMaskable = coreJsData ? isFunction : stubFalse;
6342
6343     /**
6344      * Checks if `value` is likely a prototype object.
6345      *
6346      * @private
6347      * @param {*} value The value to check.
6348      * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6349      */
6350     function isPrototype(value) {
6351       var Ctor = value && value.constructor,
6352           proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6353
6354       return value === proto;
6355     }
6356
6357     /**
6358      * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6359      *
6360      * @private
6361      * @param {*} value The value to check.
6362      * @returns {boolean} Returns `true` if `value` if suitable for strict
6363      *  equality comparisons, else `false`.
6364      */
6365     function isStrictComparable(value) {
6366       return value === value && !isObject(value);
6367     }
6368
6369     /**
6370      * A specialized version of `matchesProperty` for source values suitable
6371      * for strict equality comparisons, i.e. `===`.
6372      *
6373      * @private
6374      * @param {string} key The key of the property to get.
6375      * @param {*} srcValue The value to match.
6376      * @returns {Function} Returns the new spec function.
6377      */
6378     function matchesStrictComparable(key, srcValue) {
6379       return function(object) {
6380         if (object == null) {
6381           return false;
6382         }
6383         return object[key] === srcValue &&
6384           (srcValue !== undefined || (key in Object(object)));
6385       };
6386     }
6387
6388     /**
6389      * A specialized version of `_.memoize` which clears the memoized function's
6390      * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6391      *
6392      * @private
6393      * @param {Function} func The function to have its output memoized.
6394      * @returns {Function} Returns the new memoized function.
6395      */
6396     function memoizeCapped(func) {
6397       var result = memoize(func, function(key) {
6398         if (cache.size === MAX_MEMOIZE_SIZE) {
6399           cache.clear();
6400         }
6401         return key;
6402       });
6403
6404       var cache = result.cache;
6405       return result;
6406     }
6407
6408     /**
6409      * Merges the function metadata of `source` into `data`.
6410      *
6411      * Merging metadata reduces the number of wrappers used to invoke a function.
6412      * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
6413      * may be applied regardless of execution order. Methods like `_.ary` and
6414      * `_.rearg` modify function arguments, making the order in which they are
6415      * executed important, preventing the merging of metadata. However, we make
6416      * an exception for a safe combined case where curried functions have `_.ary`
6417      * and or `_.rearg` applied.
6418      *
6419      * @private
6420      * @param {Array} data The destination metadata.
6421      * @param {Array} source The source metadata.
6422      * @returns {Array} Returns `data`.
6423      */
6424     function mergeData(data, source) {
6425       var bitmask = data[1],
6426           srcBitmask = source[1],
6427           newBitmask = bitmask | srcBitmask,
6428           isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
6429
6430       var isCombo =
6431         ((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
6432         ((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
6433         ((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
6434
6435       // Exit early if metadata can't be merged.
6436       if (!(isCommon || isCombo)) {
6437         return data;
6438       }
6439       // Use source `thisArg` if available.
6440       if (srcBitmask & BIND_FLAG) {
6441         data[2] = source[2];
6442         // Set when currying a bound function.
6443         newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
6444       }
6445       // Compose partial arguments.
6446       var value = source[3];
6447       if (value) {
6448         var partials = data[3];
6449         data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6450         data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6451       }
6452       // Compose partial right arguments.
6453       value = source[5];
6454       if (value) {
6455         partials = data[5];
6456         data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6457         data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6458       }
6459       // Use source `argPos` if available.
6460       value = source[7];
6461       if (value) {
6462         data[7] = value;
6463       }
6464       // Use source `ary` if it's smaller.
6465       if (srcBitmask & ARY_FLAG) {
6466         data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
6467       }
6468       // Use source `arity` if one is not provided.
6469       if (data[9] == null) {
6470         data[9] = source[9];
6471       }
6472       // Use source `func` and merge bitmasks.
6473       data[0] = source[0];
6474       data[1] = newBitmask;
6475
6476       return data;
6477     }
6478
6479     /**
6480      * Used by `_.defaultsDeep` to customize its `_.merge` use.
6481      *
6482      * @private
6483      * @param {*} objValue The destination value.
6484      * @param {*} srcValue The source value.
6485      * @param {string} key The key of the property to merge.
6486      * @param {Object} object The parent object of `objValue`.
6487      * @param {Object} source The parent object of `srcValue`.
6488      * @param {Object} [stack] Tracks traversed source values and their merged
6489      *  counterparts.
6490      * @returns {*} Returns the value to assign.
6491      */
6492     function mergeDefaults(objValue, srcValue, key, object, source, stack) {
6493       if (isObject(objValue) && isObject(srcValue)) {
6494         // Recursively merge objects and arrays (susceptible to call stack limits).
6495         stack.set(srcValue, objValue);
6496         baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
6497         stack['delete'](srcValue);
6498       }
6499       return objValue;
6500     }
6501
6502     /**
6503      * This function is like
6504      * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
6505      * except that it includes inherited enumerable properties.
6506      *
6507      * @private
6508      * @param {Object} object The object to query.
6509      * @returns {Array} Returns the array of property names.
6510      */
6511     function nativeKeysIn(object) {
6512       var result = [];
6513       if (object != null) {
6514         for (var key in Object(object)) {
6515           result.push(key);
6516         }
6517       }
6518       return result;
6519     }
6520
6521     /**
6522      * Converts `value` to a string using `Object.prototype.toString`.
6523      *
6524      * @private
6525      * @param {*} value The value to convert.
6526      * @returns {string} Returns the converted string.
6527      */
6528     function objectToString(value) {
6529       return nativeObjectToString.call(value);
6530     }
6531
6532     /**
6533      * A specialized version of `baseRest` which transforms the rest array.
6534      *
6535      * @private
6536      * @param {Function} func The function to apply a rest parameter to.
6537      * @param {number} [start=func.length-1] The start position of the rest parameter.
6538      * @param {Function} transform The rest array transform.
6539      * @returns {Function} Returns the new function.
6540      */
6541     function overRest(func, start, transform) {
6542       start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
6543       return function() {
6544         var args = arguments,
6545             index = -1,
6546             length = nativeMax(args.length - start, 0),
6547             array = Array(length);
6548
6549         while (++index < length) {
6550           array[index] = args[start + index];
6551         }
6552         index = -1;
6553         var otherArgs = Array(start + 1);
6554         while (++index < start) {
6555           otherArgs[index] = args[index];
6556         }
6557         otherArgs[start] = transform(array);
6558         return apply(func, this, otherArgs);
6559       };
6560     }
6561
6562     /**
6563      * Gets the parent value at `path` of `object`.
6564      *
6565      * @private
6566      * @param {Object} object The object to query.
6567      * @param {Array} path The path to get the parent value of.
6568      * @returns {*} Returns the parent value.
6569      */
6570     function parent(object, path) {
6571       return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
6572     }
6573
6574     /**
6575      * Reorder `array` according to the specified indexes where the element at
6576      * the first index is assigned as the first element, the element at
6577      * the second index is assigned as the second element, and so on.
6578      *
6579      * @private
6580      * @param {Array} array The array to reorder.
6581      * @param {Array} indexes The arranged array indexes.
6582      * @returns {Array} Returns `array`.
6583      */
6584     function reorder(array, indexes) {
6585       var arrLength = array.length,
6586           length = nativeMin(indexes.length, arrLength),
6587           oldArray = copyArray(array);
6588
6589       while (length--) {
6590         var index = indexes[length];
6591         array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
6592       }
6593       return array;
6594     }
6595
6596     /**
6597      * Sets metadata for `func`.
6598      *
6599      * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
6600      * period of time, it will trip its breaker and transition to an identity
6601      * function to avoid garbage collection pauses in V8. See
6602      * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
6603      * for more details.
6604      *
6605      * @private
6606      * @param {Function} func The function to associate metadata with.
6607      * @param {*} data The metadata.
6608      * @returns {Function} Returns `func`.
6609      */
6610     var setData = shortOut(baseSetData);
6611
6612     /**
6613      * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
6614      *
6615      * @private
6616      * @param {Function} func The function to delay.
6617      * @param {number} wait The number of milliseconds to delay invocation.
6618      * @returns {number|Object} Returns the timer id or timeout object.
6619      */
6620     var setTimeout = ctxSetTimeout || function(func, wait) {
6621       return root.setTimeout(func, wait);
6622     };
6623
6624     /**
6625      * Sets the `toString` method of `func` to return `string`.
6626      *
6627      * @private
6628      * @param {Function} func The function to modify.
6629      * @param {Function} string The `toString` result.
6630      * @returns {Function} Returns `func`.
6631      */
6632     var setToString = shortOut(baseSetToString);
6633
6634     /**
6635      * Sets the `toString` method of `wrapper` to mimic the source of `reference`
6636      * with wrapper details in a comment at the top of the source body.
6637      *
6638      * @private
6639      * @param {Function} wrapper The function to modify.
6640      * @param {Function} reference The reference function.
6641      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6642      * @returns {Function} Returns `wrapper`.
6643      */
6644     function setWrapToString(wrapper, reference, bitmask) {
6645       var source = (reference + '');
6646       return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6647     }
6648
6649     /**
6650      * Creates a function that'll short out and invoke `identity` instead
6651      * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
6652      * milliseconds.
6653      *
6654      * @private
6655      * @param {Function} func The function to restrict.
6656      * @returns {Function} Returns the new shortable function.
6657      */
6658     function shortOut(func) {
6659       var count = 0,
6660           lastCalled = 0;
6661
6662       return function() {
6663         var stamp = nativeNow(),
6664             remaining = HOT_SPAN - (stamp - lastCalled);
6665
6666         lastCalled = stamp;
6667         if (remaining > 0) {
6668           if (++count >= HOT_COUNT) {
6669             return arguments[0];
6670           }
6671         } else {
6672           count = 0;
6673         }
6674         return func.apply(undefined, arguments);
6675       };
6676     }
6677
6678     /**
6679      * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
6680      *
6681      * @private
6682      * @param {Array} array The array to shuffle.
6683      * @param {number} [size=array.length] The size of `array`.
6684      * @returns {Array} Returns `array`.
6685      */
6686     function shuffleSelf(array, size) {
6687       var index = -1,
6688           length = array.length,
6689           lastIndex = length - 1;
6690
6691       size = size === undefined ? length : size;
6692       while (++index < size) {
6693         var rand = baseRandom(index, lastIndex),
6694             value = array[rand];
6695
6696         array[rand] = array[index];
6697         array[index] = value;
6698       }
6699       array.length = size;
6700       return array;
6701     }
6702
6703     /**
6704      * Converts `string` to a property path array.
6705      *
6706      * @private
6707      * @param {string} string The string to convert.
6708      * @returns {Array} Returns the property path array.
6709      */
6710     var stringToPath = memoizeCapped(function(string) {
6711       string = toString(string);
6712
6713       var result = [];
6714       if (reLeadingDot.test(string)) {
6715         result.push('');
6716       }
6717       string.replace(rePropName, function(match, number, quote, string) {
6718         result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
6719       });
6720       return result;
6721     });
6722
6723     /**
6724      * Converts `value` to a string key if it's not a string or symbol.
6725      *
6726      * @private
6727      * @param {*} value The value to inspect.
6728      * @returns {string|symbol} Returns the key.
6729      */
6730     function toKey(value) {
6731       if (typeof value == 'string' || isSymbol(value)) {
6732         return value;
6733       }
6734       var result = (value + '');
6735       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
6736     }
6737
6738     /**
6739      * Converts `func` to its source code.
6740      *
6741      * @private
6742      * @param {Function} func The function to convert.
6743      * @returns {string} Returns the source code.
6744      */
6745     function toSource(func) {
6746       if (func != null) {
6747         try {
6748           return funcToString.call(func);
6749         } catch (e) {}
6750         try {
6751           return (func + '');
6752         } catch (e) {}
6753       }
6754       return '';
6755     }
6756
6757     /**
6758      * Updates wrapper `details` based on `bitmask` flags.
6759      *
6760      * @private
6761      * @returns {Array} details The details to modify.
6762      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6763      * @returns {Array} Returns `details`.
6764      */
6765     function updateWrapDetails(details, bitmask) {
6766       arrayEach(wrapFlags, function(pair) {
6767         var value = '_.' + pair[0];
6768         if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
6769           details.push(value);
6770         }
6771       });
6772       return details.sort();
6773     }
6774
6775     /**
6776      * Creates a clone of `wrapper`.
6777      *
6778      * @private
6779      * @param {Object} wrapper The wrapper to clone.
6780      * @returns {Object} Returns the cloned wrapper.
6781      */
6782     function wrapperClone(wrapper) {
6783       if (wrapper instanceof LazyWrapper) {
6784         return wrapper.clone();
6785       }
6786       var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6787       result.__actions__ = copyArray(wrapper.__actions__);
6788       result.__index__  = wrapper.__index__;
6789       result.__values__ = wrapper.__values__;
6790       return result;
6791     }
6792
6793     /*------------------------------------------------------------------------*/
6794
6795     /**
6796      * Creates an array of elements split into groups the length of `size`.
6797      * If `array` can't be split evenly, the final chunk will be the remaining
6798      * elements.
6799      *
6800      * @static
6801      * @memberOf _
6802      * @since 3.0.0
6803      * @category Array
6804      * @param {Array} array The array to process.
6805      * @param {number} [size=1] The length of each chunk
6806      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
6807      * @returns {Array} Returns the new array of chunks.
6808      * @example
6809      *
6810      * _.chunk(['a', 'b', 'c', 'd'], 2);
6811      * // => [['a', 'b'], ['c', 'd']]
6812      *
6813      * _.chunk(['a', 'b', 'c', 'd'], 3);
6814      * // => [['a', 'b', 'c'], ['d']]
6815      */
6816     function chunk(array, size, guard) {
6817       if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
6818         size = 1;
6819       } else {
6820         size = nativeMax(toInteger(size), 0);
6821       }
6822       var length = array == null ? 0 : array.length;
6823       if (!length || size < 1) {
6824         return [];
6825       }
6826       var index = 0,
6827           resIndex = 0,
6828           result = Array(nativeCeil(length / size));
6829
6830       while (index < length) {
6831         result[resIndex++] = baseSlice(array, index, (index += size));
6832       }
6833       return result;
6834     }
6835
6836     /**
6837      * Creates an array with all falsey values removed. The values `false`, `null`,
6838      * `0`, `""`, `undefined`, and `NaN` are falsey.
6839      *
6840      * @static
6841      * @memberOf _
6842      * @since 0.1.0
6843      * @category Array
6844      * @param {Array} array The array to compact.
6845      * @returns {Array} Returns the new array of filtered values.
6846      * @example
6847      *
6848      * _.compact([0, 1, false, 2, '', 3]);
6849      * // => [1, 2, 3]
6850      */
6851     function compact(array) {
6852       var index = -1,
6853           length = array == null ? 0 : array.length,
6854           resIndex = 0,
6855           result = [];
6856
6857       while (++index < length) {
6858         var value = array[index];
6859         if (value) {
6860           result[resIndex++] = value;
6861         }
6862       }
6863       return result;
6864     }
6865
6866     /**
6867      * Creates a new array concatenating `array` with any additional arrays
6868      * and/or values.
6869      *
6870      * @static
6871      * @memberOf _
6872      * @since 4.0.0
6873      * @category Array
6874      * @param {Array} array The array to concatenate.
6875      * @param {...*} [values] The values to concatenate.
6876      * @returns {Array} Returns the new concatenated array.
6877      * @example
6878      *
6879      * var array = [1];
6880      * var other = _.concat(array, 2, [3], [[4]]);
6881      *
6882      * console.log(other);
6883      * // => [1, 2, 3, [4]]
6884      *
6885      * console.log(array);
6886      * // => [1]
6887      */
6888     function concat() {
6889       var length = arguments.length;
6890       if (!length) {
6891         return [];
6892       }
6893       var args = Array(length - 1),
6894           array = arguments[0],
6895           index = length;
6896
6897       while (index--) {
6898         args[index - 1] = arguments[index];
6899       }
6900       return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
6901     }
6902
6903     /**
6904      * Creates an array of `array` values not included in the other given arrays
6905      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
6906      * for equality comparisons. The order and references of result values are
6907      * determined by the first array.
6908      *
6909      * **Note:** Unlike `_.pullAll`, this method returns a new array.
6910      *
6911      * @static
6912      * @memberOf _
6913      * @since 0.1.0
6914      * @category Array
6915      * @param {Array} array The array to inspect.
6916      * @param {...Array} [values] The values to exclude.
6917      * @returns {Array} Returns the new array of filtered values.
6918      * @see _.without, _.xor
6919      * @example
6920      *
6921      * _.difference([2, 1], [2, 3]);
6922      * // => [1]
6923      */
6924     var difference = baseRest(function(array, values) {
6925       return isArrayLikeObject(array)
6926         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
6927         : [];
6928     });
6929
6930     /**
6931      * This method is like `_.difference` except that it accepts `iteratee` which
6932      * is invoked for each element of `array` and `values` to generate the criterion
6933      * by which they're compared. The order and references of result values are
6934      * determined by the first array. The iteratee is invoked with one argument:
6935      * (value).
6936      *
6937      * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
6938      *
6939      * @static
6940      * @memberOf _
6941      * @since 4.0.0
6942      * @category Array
6943      * @param {Array} array The array to inspect.
6944      * @param {...Array} [values] The values to exclude.
6945      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
6946      * @returns {Array} Returns the new array of filtered values.
6947      * @example
6948      *
6949      * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
6950      * // => [1.2]
6951      *
6952      * // The `_.property` iteratee shorthand.
6953      * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
6954      * // => [{ 'x': 2 }]
6955      */
6956     var differenceBy = baseRest(function(array, values) {
6957       var iteratee = last(values);
6958       if (isArrayLikeObject(iteratee)) {
6959         iteratee = undefined;
6960       }
6961       return isArrayLikeObject(array)
6962         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
6963         : [];
6964     });
6965
6966     /**
6967      * This method is like `_.difference` except that it accepts `comparator`
6968      * which is invoked to compare elements of `array` to `values`. The order and
6969      * references of result values are determined by the first array. The comparator
6970      * is invoked with two arguments: (arrVal, othVal).
6971      *
6972      * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
6973      *
6974      * @static
6975      * @memberOf _
6976      * @since 4.0.0
6977      * @category Array
6978      * @param {Array} array The array to inspect.
6979      * @param {...Array} [values] The values to exclude.
6980      * @param {Function} [comparator] The comparator invoked per element.
6981      * @returns {Array} Returns the new array of filtered values.
6982      * @example
6983      *
6984      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
6985      *
6986      * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
6987      * // => [{ 'x': 2, 'y': 1 }]
6988      */
6989     var differenceWith = baseRest(function(array, values) {
6990       var comparator = last(values);
6991       if (isArrayLikeObject(comparator)) {
6992         comparator = undefined;
6993       }
6994       return isArrayLikeObject(array)
6995         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
6996         : [];
6997     });
6998
6999     /**
7000      * Creates a slice of `array` with `n` elements dropped from the beginning.
7001      *
7002      * @static
7003      * @memberOf _
7004      * @since 0.5.0
7005      * @category Array
7006      * @param {Array} array The array to query.
7007      * @param {number} [n=1] The number of elements to drop.
7008      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7009      * @returns {Array} Returns the slice of `array`.
7010      * @example
7011      *
7012      * _.drop([1, 2, 3]);
7013      * // => [2, 3]
7014      *
7015      * _.drop([1, 2, 3], 2);
7016      * // => [3]
7017      *
7018      * _.drop([1, 2, 3], 5);
7019      * // => []
7020      *
7021      * _.drop([1, 2, 3], 0);
7022      * // => [1, 2, 3]
7023      */
7024     function drop(array, n, guard) {
7025       var length = array == null ? 0 : array.length;
7026       if (!length) {
7027         return [];
7028       }
7029       n = (guard || n === undefined) ? 1 : toInteger(n);
7030       return baseSlice(array, n < 0 ? 0 : n, length);
7031     }
7032
7033     /**
7034      * Creates a slice of `array` with `n` elements dropped from the end.
7035      *
7036      * @static
7037      * @memberOf _
7038      * @since 3.0.0
7039      * @category Array
7040      * @param {Array} array The array to query.
7041      * @param {number} [n=1] The number of elements to drop.
7042      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7043      * @returns {Array} Returns the slice of `array`.
7044      * @example
7045      *
7046      * _.dropRight([1, 2, 3]);
7047      * // => [1, 2]
7048      *
7049      * _.dropRight([1, 2, 3], 2);
7050      * // => [1]
7051      *
7052      * _.dropRight([1, 2, 3], 5);
7053      * // => []
7054      *
7055      * _.dropRight([1, 2, 3], 0);
7056      * // => [1, 2, 3]
7057      */
7058     function dropRight(array, n, guard) {
7059       var length = array == null ? 0 : array.length;
7060       if (!length) {
7061         return [];
7062       }
7063       n = (guard || n === undefined) ? 1 : toInteger(n);
7064       n = length - n;
7065       return baseSlice(array, 0, n < 0 ? 0 : n);
7066     }
7067
7068     /**
7069      * Creates a slice of `array` excluding elements dropped from the end.
7070      * Elements are dropped until `predicate` returns falsey. The predicate is
7071      * invoked with three arguments: (value, index, array).
7072      *
7073      * @static
7074      * @memberOf _
7075      * @since 3.0.0
7076      * @category Array
7077      * @param {Array} array The array to query.
7078      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7079      * @returns {Array} Returns the slice of `array`.
7080      * @example
7081      *
7082      * var users = [
7083      *   { 'user': 'barney',  'active': true },
7084      *   { 'user': 'fred',    'active': false },
7085      *   { 'user': 'pebbles', 'active': false }
7086      * ];
7087      *
7088      * _.dropRightWhile(users, function(o) { return !o.active; });
7089      * // => objects for ['barney']
7090      *
7091      * // The `_.matches` iteratee shorthand.
7092      * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7093      * // => objects for ['barney', 'fred']
7094      *
7095      * // The `_.matchesProperty` iteratee shorthand.
7096      * _.dropRightWhile(users, ['active', false]);
7097      * // => objects for ['barney']
7098      *
7099      * // The `_.property` iteratee shorthand.
7100      * _.dropRightWhile(users, 'active');
7101      * // => objects for ['barney', 'fred', 'pebbles']
7102      */
7103     function dropRightWhile(array, predicate) {
7104       return (array && array.length)
7105         ? baseWhile(array, getIteratee(predicate, 3), true, true)
7106         : [];
7107     }
7108
7109     /**
7110      * Creates a slice of `array` excluding elements dropped from the beginning.
7111      * Elements are dropped until `predicate` returns falsey. The predicate is
7112      * invoked with three arguments: (value, index, array).
7113      *
7114      * @static
7115      * @memberOf _
7116      * @since 3.0.0
7117      * @category Array
7118      * @param {Array} array The array to query.
7119      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7120      * @returns {Array} Returns the slice of `array`.
7121      * @example
7122      *
7123      * var users = [
7124      *   { 'user': 'barney',  'active': false },
7125      *   { 'user': 'fred',    'active': false },
7126      *   { 'user': 'pebbles', 'active': true }
7127      * ];
7128      *
7129      * _.dropWhile(users, function(o) { return !o.active; });
7130      * // => objects for ['pebbles']
7131      *
7132      * // The `_.matches` iteratee shorthand.
7133      * _.dropWhile(users, { 'user': 'barney', 'active': false });
7134      * // => objects for ['fred', 'pebbles']
7135      *
7136      * // The `_.matchesProperty` iteratee shorthand.
7137      * _.dropWhile(users, ['active', false]);
7138      * // => objects for ['pebbles']
7139      *
7140      * // The `_.property` iteratee shorthand.
7141      * _.dropWhile(users, 'active');
7142      * // => objects for ['barney', 'fred', 'pebbles']
7143      */
7144     function dropWhile(array, predicate) {
7145       return (array && array.length)
7146         ? baseWhile(array, getIteratee(predicate, 3), true)
7147         : [];
7148     }
7149
7150     /**
7151      * Fills elements of `array` with `value` from `start` up to, but not
7152      * including, `end`.
7153      *
7154      * **Note:** This method mutates `array`.
7155      *
7156      * @static
7157      * @memberOf _
7158      * @since 3.2.0
7159      * @category Array
7160      * @param {Array} array The array to fill.
7161      * @param {*} value The value to fill `array` with.
7162      * @param {number} [start=0] The start position.
7163      * @param {number} [end=array.length] The end position.
7164      * @returns {Array} Returns `array`.
7165      * @example
7166      *
7167      * var array = [1, 2, 3];
7168      *
7169      * _.fill(array, 'a');
7170      * console.log(array);
7171      * // => ['a', 'a', 'a']
7172      *
7173      * _.fill(Array(3), 2);
7174      * // => [2, 2, 2]
7175      *
7176      * _.fill([4, 6, 8, 10], '*', 1, 3);
7177      * // => [4, '*', '*', 10]
7178      */
7179     function fill(array, value, start, end) {
7180       var length = array == null ? 0 : array.length;
7181       if (!length) {
7182         return [];
7183       }
7184       if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7185         start = 0;
7186         end = length;
7187       }
7188       return baseFill(array, value, start, end);
7189     }
7190
7191     /**
7192      * This method is like `_.find` except that it returns the index of the first
7193      * element `predicate` returns truthy for instead of the element itself.
7194      *
7195      * @static
7196      * @memberOf _
7197      * @since 1.1.0
7198      * @category Array
7199      * @param {Array} array The array to inspect.
7200      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7201      * @param {number} [fromIndex=0] The index to search from.
7202      * @returns {number} Returns the index of the found element, else `-1`.
7203      * @example
7204      *
7205      * var users = [
7206      *   { 'user': 'barney',  'active': false },
7207      *   { 'user': 'fred',    'active': false },
7208      *   { 'user': 'pebbles', 'active': true }
7209      * ];
7210      *
7211      * _.findIndex(users, function(o) { return o.user == 'barney'; });
7212      * // => 0
7213      *
7214      * // The `_.matches` iteratee shorthand.
7215      * _.findIndex(users, { 'user': 'fred', 'active': false });
7216      * // => 1
7217      *
7218      * // The `_.matchesProperty` iteratee shorthand.
7219      * _.findIndex(users, ['active', false]);
7220      * // => 0
7221      *
7222      * // The `_.property` iteratee shorthand.
7223      * _.findIndex(users, 'active');
7224      * // => 2
7225      */
7226     function findIndex(array, predicate, fromIndex) {
7227       var length = array == null ? 0 : array.length;
7228       if (!length) {
7229         return -1;
7230       }
7231       var index = fromIndex == null ? 0 : toInteger(fromIndex);
7232       if (index < 0) {
7233         index = nativeMax(length + index, 0);
7234       }
7235       return baseFindIndex(array, getIteratee(predicate, 3), index);
7236     }
7237
7238     /**
7239      * This method is like `_.findIndex` except that it iterates over elements
7240      * of `collection` from right to left.
7241      *
7242      * @static
7243      * @memberOf _
7244      * @since 2.0.0
7245      * @category Array
7246      * @param {Array} array The array to inspect.
7247      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7248      * @param {number} [fromIndex=array.length-1] The index to search from.
7249      * @returns {number} Returns the index of the found element, else `-1`.
7250      * @example
7251      *
7252      * var users = [
7253      *   { 'user': 'barney',  'active': true },
7254      *   { 'user': 'fred',    'active': false },
7255      *   { 'user': 'pebbles', 'active': false }
7256      * ];
7257      *
7258      * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7259      * // => 2
7260      *
7261      * // The `_.matches` iteratee shorthand.
7262      * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7263      * // => 0
7264      *
7265      * // The `_.matchesProperty` iteratee shorthand.
7266      * _.findLastIndex(users, ['active', false]);
7267      * // => 2
7268      *
7269      * // The `_.property` iteratee shorthand.
7270      * _.findLastIndex(users, 'active');
7271      * // => 0
7272      */
7273     function findLastIndex(array, predicate, fromIndex) {
7274       var length = array == null ? 0 : array.length;
7275       if (!length) {
7276         return -1;
7277       }
7278       var index = length - 1;
7279       if (fromIndex !== undefined) {
7280         index = toInteger(fromIndex);
7281         index = fromIndex < 0
7282           ? nativeMax(length + index, 0)
7283           : nativeMin(index, length - 1);
7284       }
7285       return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7286     }
7287
7288     /**
7289      * Flattens `array` a single level deep.
7290      *
7291      * @static
7292      * @memberOf _
7293      * @since 0.1.0
7294      * @category Array
7295      * @param {Array} array The array to flatten.
7296      * @returns {Array} Returns the new flattened array.
7297      * @example
7298      *
7299      * _.flatten([1, [2, [3, [4]], 5]]);
7300      * // => [1, 2, [3, [4]], 5]
7301      */
7302     function flatten(array) {
7303       var length = array == null ? 0 : array.length;
7304       return length ? baseFlatten(array, 1) : [];
7305     }
7306
7307     /**
7308      * Recursively flattens `array`.
7309      *
7310      * @static
7311      * @memberOf _
7312      * @since 3.0.0
7313      * @category Array
7314      * @param {Array} array The array to flatten.
7315      * @returns {Array} Returns the new flattened array.
7316      * @example
7317      *
7318      * _.flattenDeep([1, [2, [3, [4]], 5]]);
7319      * // => [1, 2, 3, 4, 5]
7320      */
7321     function flattenDeep(array) {
7322       var length = array == null ? 0 : array.length;
7323       return length ? baseFlatten(array, INFINITY) : [];
7324     }
7325
7326     /**
7327      * Recursively flatten `array` up to `depth` times.
7328      *
7329      * @static
7330      * @memberOf _
7331      * @since 4.4.0
7332      * @category Array
7333      * @param {Array} array The array to flatten.
7334      * @param {number} [depth=1] The maximum recursion depth.
7335      * @returns {Array} Returns the new flattened array.
7336      * @example
7337      *
7338      * var array = [1, [2, [3, [4]], 5]];
7339      *
7340      * _.flattenDepth(array, 1);
7341      * // => [1, 2, [3, [4]], 5]
7342      *
7343      * _.flattenDepth(array, 2);
7344      * // => [1, 2, 3, [4], 5]
7345      */
7346     function flattenDepth(array, depth) {
7347       var length = array == null ? 0 : array.length;
7348       if (!length) {
7349         return [];
7350       }
7351       depth = depth === undefined ? 1 : toInteger(depth);
7352       return baseFlatten(array, depth);
7353     }
7354
7355     /**
7356      * The inverse of `_.toPairs`; this method returns an object composed
7357      * from key-value `pairs`.
7358      *
7359      * @static
7360      * @memberOf _
7361      * @since 4.0.0
7362      * @category Array
7363      * @param {Array} pairs The key-value pairs.
7364      * @returns {Object} Returns the new object.
7365      * @example
7366      *
7367      * _.fromPairs([['a', 1], ['b', 2]]);
7368      * // => { 'a': 1, 'b': 2 }
7369      */
7370     function fromPairs(pairs) {
7371       var index = -1,
7372           length = pairs == null ? 0 : pairs.length,
7373           result = {};
7374
7375       while (++index < length) {
7376         var pair = pairs[index];
7377         result[pair[0]] = pair[1];
7378       }
7379       return result;
7380     }
7381
7382     /**
7383      * Gets the first element of `array`.
7384      *
7385      * @static
7386      * @memberOf _
7387      * @since 0.1.0
7388      * @alias first
7389      * @category Array
7390      * @param {Array} array The array to query.
7391      * @returns {*} Returns the first element of `array`.
7392      * @example
7393      *
7394      * _.head([1, 2, 3]);
7395      * // => 1
7396      *
7397      * _.head([]);
7398      * // => undefined
7399      */
7400     function head(array) {
7401       return (array && array.length) ? array[0] : undefined;
7402     }
7403
7404     /**
7405      * Gets the index at which the first occurrence of `value` is found in `array`
7406      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7407      * for equality comparisons. If `fromIndex` is negative, it's used as the
7408      * offset from the end of `array`.
7409      *
7410      * @static
7411      * @memberOf _
7412      * @since 0.1.0
7413      * @category Array
7414      * @param {Array} array The array to inspect.
7415      * @param {*} value The value to search for.
7416      * @param {number} [fromIndex=0] The index to search from.
7417      * @returns {number} Returns the index of the matched value, else `-1`.
7418      * @example
7419      *
7420      * _.indexOf([1, 2, 1, 2], 2);
7421      * // => 1
7422      *
7423      * // Search from the `fromIndex`.
7424      * _.indexOf([1, 2, 1, 2], 2, 2);
7425      * // => 3
7426      */
7427     function indexOf(array, value, fromIndex) {
7428       var length = array == null ? 0 : array.length;
7429       if (!length) {
7430         return -1;
7431       }
7432       var index = fromIndex == null ? 0 : toInteger(fromIndex);
7433       if (index < 0) {
7434         index = nativeMax(length + index, 0);
7435       }
7436       return baseIndexOf(array, value, index);
7437     }
7438
7439     /**
7440      * Gets all but the last element of `array`.
7441      *
7442      * @static
7443      * @memberOf _
7444      * @since 0.1.0
7445      * @category Array
7446      * @param {Array} array The array to query.
7447      * @returns {Array} Returns the slice of `array`.
7448      * @example
7449      *
7450      * _.initial([1, 2, 3]);
7451      * // => [1, 2]
7452      */
7453     function initial(array) {
7454       var length = array == null ? 0 : array.length;
7455       return length ? baseSlice(array, 0, -1) : [];
7456     }
7457
7458     /**
7459      * Creates an array of unique values that are included in all given arrays
7460      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7461      * for equality comparisons. The order and references of result values are
7462      * determined by the first array.
7463      *
7464      * @static
7465      * @memberOf _
7466      * @since 0.1.0
7467      * @category Array
7468      * @param {...Array} [arrays] The arrays to inspect.
7469      * @returns {Array} Returns the new array of intersecting values.
7470      * @example
7471      *
7472      * _.intersection([2, 1], [2, 3]);
7473      * // => [2]
7474      */
7475     var intersection = baseRest(function(arrays) {
7476       var mapped = arrayMap(arrays, castArrayLikeObject);
7477       return (mapped.length && mapped[0] === arrays[0])
7478         ? baseIntersection(mapped)
7479         : [];
7480     });
7481
7482     /**
7483      * This method is like `_.intersection` except that it accepts `iteratee`
7484      * which is invoked for each element of each `arrays` to generate the criterion
7485      * by which they're compared. The order and references of result values are
7486      * determined by the first array. The iteratee is invoked with one argument:
7487      * (value).
7488      *
7489      * @static
7490      * @memberOf _
7491      * @since 4.0.0
7492      * @category Array
7493      * @param {...Array} [arrays] The arrays to inspect.
7494      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7495      * @returns {Array} Returns the new array of intersecting values.
7496      * @example
7497      *
7498      * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7499      * // => [2.1]
7500      *
7501      * // The `_.property` iteratee shorthand.
7502      * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7503      * // => [{ 'x': 1 }]
7504      */
7505     var intersectionBy = baseRest(function(arrays) {
7506       var iteratee = last(arrays),
7507           mapped = arrayMap(arrays, castArrayLikeObject);
7508
7509       if (iteratee === last(mapped)) {
7510         iteratee = undefined;
7511       } else {
7512         mapped.pop();
7513       }
7514       return (mapped.length && mapped[0] === arrays[0])
7515         ? baseIntersection(mapped, getIteratee(iteratee, 2))
7516         : [];
7517     });
7518
7519     /**
7520      * This method is like `_.intersection` except that it accepts `comparator`
7521      * which is invoked to compare elements of `arrays`. The order and references
7522      * of result values are determined by the first array. The comparator is
7523      * invoked with two arguments: (arrVal, othVal).
7524      *
7525      * @static
7526      * @memberOf _
7527      * @since 4.0.0
7528      * @category Array
7529      * @param {...Array} [arrays] The arrays to inspect.
7530      * @param {Function} [comparator] The comparator invoked per element.
7531      * @returns {Array} Returns the new array of intersecting values.
7532      * @example
7533      *
7534      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7535      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7536      *
7537      * _.intersectionWith(objects, others, _.isEqual);
7538      * // => [{ 'x': 1, 'y': 2 }]
7539      */
7540     var intersectionWith = baseRest(function(arrays) {
7541       var comparator = last(arrays),
7542           mapped = arrayMap(arrays, castArrayLikeObject);
7543
7544       comparator = typeof comparator == 'function' ? comparator : undefined;
7545       if (comparator) {
7546         mapped.pop();
7547       }
7548       return (mapped.length && mapped[0] === arrays[0])
7549         ? baseIntersection(mapped, undefined, comparator)
7550         : [];
7551     });
7552
7553     /**
7554      * Converts all elements in `array` into a string separated by `separator`.
7555      *
7556      * @static
7557      * @memberOf _
7558      * @since 4.0.0
7559      * @category Array
7560      * @param {Array} array The array to convert.
7561      * @param {string} [separator=','] The element separator.
7562      * @returns {string} Returns the joined string.
7563      * @example
7564      *
7565      * _.join(['a', 'b', 'c'], '~');
7566      * // => 'a~b~c'
7567      */
7568     function join(array, separator) {
7569       return array == null ? '' : nativeJoin.call(array, separator);
7570     }
7571
7572     /**
7573      * Gets the last element of `array`.
7574      *
7575      * @static
7576      * @memberOf _
7577      * @since 0.1.0
7578      * @category Array
7579      * @param {Array} array The array to query.
7580      * @returns {*} Returns the last element of `array`.
7581      * @example
7582      *
7583      * _.last([1, 2, 3]);
7584      * // => 3
7585      */
7586     function last(array) {
7587       var length = array == null ? 0 : array.length;
7588       return length ? array[length - 1] : undefined;
7589     }
7590
7591     /**
7592      * This method is like `_.indexOf` except that it iterates over elements of
7593      * `array` from right to left.
7594      *
7595      * @static
7596      * @memberOf _
7597      * @since 0.1.0
7598      * @category Array
7599      * @param {Array} array The array to inspect.
7600      * @param {*} value The value to search for.
7601      * @param {number} [fromIndex=array.length-1] The index to search from.
7602      * @returns {number} Returns the index of the matched value, else `-1`.
7603      * @example
7604      *
7605      * _.lastIndexOf([1, 2, 1, 2], 2);
7606      * // => 3
7607      *
7608      * // Search from the `fromIndex`.
7609      * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7610      * // => 1
7611      */
7612     function lastIndexOf(array, value, fromIndex) {
7613       var length = array == null ? 0 : array.length;
7614       if (!length) {
7615         return -1;
7616       }
7617       var index = length;
7618       if (fromIndex !== undefined) {
7619         index = toInteger(fromIndex);
7620         index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7621       }
7622       return value === value
7623         ? strictLastIndexOf(array, value, index)
7624         : baseFindIndex(array, baseIsNaN, index, true);
7625     }
7626
7627     /**
7628      * Gets the element at index `n` of `array`. If `n` is negative, the nth
7629      * element from the end is returned.
7630      *
7631      * @static
7632      * @memberOf _
7633      * @since 4.11.0
7634      * @category Array
7635      * @param {Array} array The array to query.
7636      * @param {number} [n=0] The index of the element to return.
7637      * @returns {*} Returns the nth element of `array`.
7638      * @example
7639      *
7640      * var array = ['a', 'b', 'c', 'd'];
7641      *
7642      * _.nth(array, 1);
7643      * // => 'b'
7644      *
7645      * _.nth(array, -2);
7646      * // => 'c';
7647      */
7648     function nth(array, n) {
7649       return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
7650     }
7651
7652     /**
7653      * Removes all given values from `array` using
7654      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7655      * for equality comparisons.
7656      *
7657      * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
7658      * to remove elements from an array by predicate.
7659      *
7660      * @static
7661      * @memberOf _
7662      * @since 2.0.0
7663      * @category Array
7664      * @param {Array} array The array to modify.
7665      * @param {...*} [values] The values to remove.
7666      * @returns {Array} Returns `array`.
7667      * @example
7668      *
7669      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7670      *
7671      * _.pull(array, 'a', 'c');
7672      * console.log(array);
7673      * // => ['b', 'b']
7674      */
7675     var pull = baseRest(pullAll);
7676
7677     /**
7678      * This method is like `_.pull` except that it accepts an array of values to remove.
7679      *
7680      * **Note:** Unlike `_.difference`, this method mutates `array`.
7681      *
7682      * @static
7683      * @memberOf _
7684      * @since 4.0.0
7685      * @category Array
7686      * @param {Array} array The array to modify.
7687      * @param {Array} values The values to remove.
7688      * @returns {Array} Returns `array`.
7689      * @example
7690      *
7691      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7692      *
7693      * _.pullAll(array, ['a', 'c']);
7694      * console.log(array);
7695      * // => ['b', 'b']
7696      */
7697     function pullAll(array, values) {
7698       return (array && array.length && values && values.length)
7699         ? basePullAll(array, values)
7700         : array;
7701     }
7702
7703     /**
7704      * This method is like `_.pullAll` except that it accepts `iteratee` which is
7705      * invoked for each element of `array` and `values` to generate the criterion
7706      * by which they're compared. The iteratee is invoked with one argument: (value).
7707      *
7708      * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
7709      *
7710      * @static
7711      * @memberOf _
7712      * @since 4.0.0
7713      * @category Array
7714      * @param {Array} array The array to modify.
7715      * @param {Array} values The values to remove.
7716      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7717      * @returns {Array} Returns `array`.
7718      * @example
7719      *
7720      * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
7721      *
7722      * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
7723      * console.log(array);
7724      * // => [{ 'x': 2 }]
7725      */
7726     function pullAllBy(array, values, iteratee) {
7727       return (array && array.length && values && values.length)
7728         ? basePullAll(array, values, getIteratee(iteratee, 2))
7729         : array;
7730     }
7731
7732     /**
7733      * This method is like `_.pullAll` except that it accepts `comparator` which
7734      * is invoked to compare elements of `array` to `values`. The comparator is
7735      * invoked with two arguments: (arrVal, othVal).
7736      *
7737      * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
7738      *
7739      * @static
7740      * @memberOf _
7741      * @since 4.6.0
7742      * @category Array
7743      * @param {Array} array The array to modify.
7744      * @param {Array} values The values to remove.
7745      * @param {Function} [comparator] The comparator invoked per element.
7746      * @returns {Array} Returns `array`.
7747      * @example
7748      *
7749      * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
7750      *
7751      * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
7752      * console.log(array);
7753      * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
7754      */
7755     function pullAllWith(array, values, comparator) {
7756       return (array && array.length && values && values.length)
7757         ? basePullAll(array, values, undefined, comparator)
7758         : array;
7759     }
7760
7761     /**
7762      * Removes elements from `array` corresponding to `indexes` and returns an
7763      * array of removed elements.
7764      *
7765      * **Note:** Unlike `_.at`, this method mutates `array`.
7766      *
7767      * @static
7768      * @memberOf _
7769      * @since 3.0.0
7770      * @category Array
7771      * @param {Array} array The array to modify.
7772      * @param {...(number|number[])} [indexes] The indexes of elements to remove.
7773      * @returns {Array} Returns the new array of removed elements.
7774      * @example
7775      *
7776      * var array = ['a', 'b', 'c', 'd'];
7777      * var pulled = _.pullAt(array, [1, 3]);
7778      *
7779      * console.log(array);
7780      * // => ['a', 'c']
7781      *
7782      * console.log(pulled);
7783      * // => ['b', 'd']
7784      */
7785     var pullAt = flatRest(function(array, indexes) {
7786       var length = array == null ? 0 : array.length,
7787           result = baseAt(array, indexes);
7788
7789       basePullAt(array, arrayMap(indexes, function(index) {
7790         return isIndex(index, length) ? +index : index;
7791       }).sort(compareAscending));
7792
7793       return result;
7794     });
7795
7796     /**
7797      * Removes all elements from `array` that `predicate` returns truthy for
7798      * and returns an array of the removed elements. The predicate is invoked
7799      * with three arguments: (value, index, array).
7800      *
7801      * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
7802      * to pull elements from an array by value.
7803      *
7804      * @static
7805      * @memberOf _
7806      * @since 2.0.0
7807      * @category Array
7808      * @param {Array} array The array to modify.
7809      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7810      * @returns {Array} Returns the new array of removed elements.
7811      * @example
7812      *
7813      * var array = [1, 2, 3, 4];
7814      * var evens = _.remove(array, function(n) {
7815      *   return n % 2 == 0;
7816      * });
7817      *
7818      * console.log(array);
7819      * // => [1, 3]
7820      *
7821      * console.log(evens);
7822      * // => [2, 4]
7823      */
7824     function remove(array, predicate) {
7825       var result = [];
7826       if (!(array && array.length)) {
7827         return result;
7828       }
7829       var index = -1,
7830           indexes = [],
7831           length = array.length;
7832
7833       predicate = getIteratee(predicate, 3);
7834       while (++index < length) {
7835         var value = array[index];
7836         if (predicate(value, index, array)) {
7837           result.push(value);
7838           indexes.push(index);
7839         }
7840       }
7841       basePullAt(array, indexes);
7842       return result;
7843     }
7844
7845     /**
7846      * Reverses `array` so that the first element becomes the last, the second
7847      * element becomes the second to last, and so on.
7848      *
7849      * **Note:** This method mutates `array` and is based on
7850      * [`Array#reverse`](https://mdn.io/Array/reverse).
7851      *
7852      * @static
7853      * @memberOf _
7854      * @since 4.0.0
7855      * @category Array
7856      * @param {Array} array The array to modify.
7857      * @returns {Array} Returns `array`.
7858      * @example
7859      *
7860      * var array = [1, 2, 3];
7861      *
7862      * _.reverse(array);
7863      * // => [3, 2, 1]
7864      *
7865      * console.log(array);
7866      * // => [3, 2, 1]
7867      */
7868     function reverse(array) {
7869       return array == null ? array : nativeReverse.call(array);
7870     }
7871
7872     /**
7873      * Creates a slice of `array` from `start` up to, but not including, `end`.
7874      *
7875      * **Note:** This method is used instead of
7876      * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
7877      * returned.
7878      *
7879      * @static
7880      * @memberOf _
7881      * @since 3.0.0
7882      * @category Array
7883      * @param {Array} array The array to slice.
7884      * @param {number} [start=0] The start position.
7885      * @param {number} [end=array.length] The end position.
7886      * @returns {Array} Returns the slice of `array`.
7887      */
7888     function slice(array, start, end) {
7889       var length = array == null ? 0 : array.length;
7890       if (!length) {
7891         return [];
7892       }
7893       if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
7894         start = 0;
7895         end = length;
7896       }
7897       else {
7898         start = start == null ? 0 : toInteger(start);
7899         end = end === undefined ? length : toInteger(end);
7900       }
7901       return baseSlice(array, start, end);
7902     }
7903
7904     /**
7905      * Uses a binary search to determine the lowest index at which `value`
7906      * should be inserted into `array` in order to maintain its sort order.
7907      *
7908      * @static
7909      * @memberOf _
7910      * @since 0.1.0
7911      * @category Array
7912      * @param {Array} array The sorted array to inspect.
7913      * @param {*} value The value to evaluate.
7914      * @returns {number} Returns the index at which `value` should be inserted
7915      *  into `array`.
7916      * @example
7917      *
7918      * _.sortedIndex([30, 50], 40);
7919      * // => 1
7920      */
7921     function sortedIndex(array, value) {
7922       return baseSortedIndex(array, value);
7923     }
7924
7925     /**
7926      * This method is like `_.sortedIndex` except that it accepts `iteratee`
7927      * which is invoked for `value` and each element of `array` to compute their
7928      * sort ranking. The iteratee is invoked with one argument: (value).
7929      *
7930      * @static
7931      * @memberOf _
7932      * @since 4.0.0
7933      * @category Array
7934      * @param {Array} array The sorted array to inspect.
7935      * @param {*} value The value to evaluate.
7936      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7937      * @returns {number} Returns the index at which `value` should be inserted
7938      *  into `array`.
7939      * @example
7940      *
7941      * var objects = [{ 'x': 4 }, { 'x': 5 }];
7942      *
7943      * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
7944      * // => 0
7945      *
7946      * // The `_.property` iteratee shorthand.
7947      * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
7948      * // => 0
7949      */
7950     function sortedIndexBy(array, value, iteratee) {
7951       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
7952     }
7953
7954     /**
7955      * This method is like `_.indexOf` except that it performs a binary
7956      * search on a sorted `array`.
7957      *
7958      * @static
7959      * @memberOf _
7960      * @since 4.0.0
7961      * @category Array
7962      * @param {Array} array The array to inspect.
7963      * @param {*} value The value to search for.
7964      * @returns {number} Returns the index of the matched value, else `-1`.
7965      * @example
7966      *
7967      * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
7968      * // => 1
7969      */
7970     function sortedIndexOf(array, value) {
7971       var length = array == null ? 0 : array.length;
7972       if (length) {
7973         var index = baseSortedIndex(array, value);
7974         if (index < length && eq(array[index], value)) {
7975           return index;
7976         }
7977       }
7978       return -1;
7979     }
7980
7981     /**
7982      * This method is like `_.sortedIndex` except that it returns the highest
7983      * index at which `value` should be inserted into `array` in order to
7984      * maintain its sort order.
7985      *
7986      * @static
7987      * @memberOf _
7988      * @since 3.0.0
7989      * @category Array
7990      * @param {Array} array The sorted array to inspect.
7991      * @param {*} value The value to evaluate.
7992      * @returns {number} Returns the index at which `value` should be inserted
7993      *  into `array`.
7994      * @example
7995      *
7996      * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
7997      * // => 4
7998      */
7999     function sortedLastIndex(array, value) {
8000       return baseSortedIndex(array, value, true);
8001     }
8002
8003     /**
8004      * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
8005      * which is invoked for `value` and each element of `array` to compute their
8006      * sort ranking. The iteratee is invoked with one argument: (value).
8007      *
8008      * @static
8009      * @memberOf _
8010      * @since 4.0.0
8011      * @category Array
8012      * @param {Array} array The sorted array to inspect.
8013      * @param {*} value The value to evaluate.
8014      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8015      * @returns {number} Returns the index at which `value` should be inserted
8016      *  into `array`.
8017      * @example
8018      *
8019      * var objects = [{ 'x': 4 }, { 'x': 5 }];
8020      *
8021      * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8022      * // => 1
8023      *
8024      * // The `_.property` iteratee shorthand.
8025      * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8026      * // => 1
8027      */
8028     function sortedLastIndexBy(array, value, iteratee) {
8029       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8030     }
8031
8032     /**
8033      * This method is like `_.lastIndexOf` except that it performs a binary
8034      * search on a sorted `array`.
8035      *
8036      * @static
8037      * @memberOf _
8038      * @since 4.0.0
8039      * @category Array
8040      * @param {Array} array The array to inspect.
8041      * @param {*} value The value to search for.
8042      * @returns {number} Returns the index of the matched value, else `-1`.
8043      * @example
8044      *
8045      * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8046      * // => 3
8047      */
8048     function sortedLastIndexOf(array, value) {
8049       var length = array == null ? 0 : array.length;
8050       if (length) {
8051         var index = baseSortedIndex(array, value, true) - 1;
8052         if (eq(array[index], value)) {
8053           return index;
8054         }
8055       }
8056       return -1;
8057     }
8058
8059     /**
8060      * This method is like `_.uniq` except that it's designed and optimized
8061      * for sorted arrays.
8062      *
8063      * @static
8064      * @memberOf _
8065      * @since 4.0.0
8066      * @category Array
8067      * @param {Array} array The array to inspect.
8068      * @returns {Array} Returns the new duplicate free array.
8069      * @example
8070      *
8071      * _.sortedUniq([1, 1, 2]);
8072      * // => [1, 2]
8073      */
8074     function sortedUniq(array) {
8075       return (array && array.length)
8076         ? baseSortedUniq(array)
8077         : [];
8078     }
8079
8080     /**
8081      * This method is like `_.uniqBy` except that it's designed and optimized
8082      * for sorted arrays.
8083      *
8084      * @static
8085      * @memberOf _
8086      * @since 4.0.0
8087      * @category Array
8088      * @param {Array} array The array to inspect.
8089      * @param {Function} [iteratee] The iteratee invoked per element.
8090      * @returns {Array} Returns the new duplicate free array.
8091      * @example
8092      *
8093      * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8094      * // => [1.1, 2.3]
8095      */
8096     function sortedUniqBy(array, iteratee) {
8097       return (array && array.length)
8098         ? baseSortedUniq(array, getIteratee(iteratee, 2))
8099         : [];
8100     }
8101
8102     /**
8103      * Gets all but the first element of `array`.
8104      *
8105      * @static
8106      * @memberOf _
8107      * @since 4.0.0
8108      * @category Array
8109      * @param {Array} array The array to query.
8110      * @returns {Array} Returns the slice of `array`.
8111      * @example
8112      *
8113      * _.tail([1, 2, 3]);
8114      * // => [2, 3]
8115      */
8116     function tail(array) {
8117       var length = array == null ? 0 : array.length;
8118       return length ? baseSlice(array, 1, length) : [];
8119     }
8120
8121     /**
8122      * Creates a slice of `array` with `n` elements taken from the beginning.
8123      *
8124      * @static
8125      * @memberOf _
8126      * @since 0.1.0
8127      * @category Array
8128      * @param {Array} array The array to query.
8129      * @param {number} [n=1] The number of elements to take.
8130      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8131      * @returns {Array} Returns the slice of `array`.
8132      * @example
8133      *
8134      * _.take([1, 2, 3]);
8135      * // => [1]
8136      *
8137      * _.take([1, 2, 3], 2);
8138      * // => [1, 2]
8139      *
8140      * _.take([1, 2, 3], 5);
8141      * // => [1, 2, 3]
8142      *
8143      * _.take([1, 2, 3], 0);
8144      * // => []
8145      */
8146     function take(array, n, guard) {
8147       if (!(array && array.length)) {
8148         return [];
8149       }
8150       n = (guard || n === undefined) ? 1 : toInteger(n);
8151       return baseSlice(array, 0, n < 0 ? 0 : n);
8152     }
8153
8154     /**
8155      * Creates a slice of `array` with `n` elements taken from the end.
8156      *
8157      * @static
8158      * @memberOf _
8159      * @since 3.0.0
8160      * @category Array
8161      * @param {Array} array The array to query.
8162      * @param {number} [n=1] The number of elements to take.
8163      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8164      * @returns {Array} Returns the slice of `array`.
8165      * @example
8166      *
8167      * _.takeRight([1, 2, 3]);
8168      * // => [3]
8169      *
8170      * _.takeRight([1, 2, 3], 2);
8171      * // => [2, 3]
8172      *
8173      * _.takeRight([1, 2, 3], 5);
8174      * // => [1, 2, 3]
8175      *
8176      * _.takeRight([1, 2, 3], 0);
8177      * // => []
8178      */
8179     function takeRight(array, n, guard) {
8180       var length = array == null ? 0 : array.length;
8181       if (!length) {
8182         return [];
8183       }
8184       n = (guard || n === undefined) ? 1 : toInteger(n);
8185       n = length - n;
8186       return baseSlice(array, n < 0 ? 0 : n, length);
8187     }
8188
8189     /**
8190      * Creates a slice of `array` with elements taken from the end. Elements are
8191      * taken until `predicate` returns falsey. The predicate is invoked with
8192      * three arguments: (value, index, array).
8193      *
8194      * @static
8195      * @memberOf _
8196      * @since 3.0.0
8197      * @category Array
8198      * @param {Array} array The array to query.
8199      * @param {Function} [predicate=_.identity] The function invoked per iteration.
8200      * @returns {Array} Returns the slice of `array`.
8201      * @example
8202      *
8203      * var users = [
8204      *   { 'user': 'barney',  'active': true },
8205      *   { 'user': 'fred',    'active': false },
8206      *   { 'user': 'pebbles', 'active': false }
8207      * ];
8208      *
8209      * _.takeRightWhile(users, function(o) { return !o.active; });
8210      * // => objects for ['fred', 'pebbles']
8211      *
8212      * // The `_.matches` iteratee shorthand.
8213      * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8214      * // => objects for ['pebbles']
8215      *
8216      * // The `_.matchesProperty` iteratee shorthand.
8217      * _.takeRightWhile(users, ['active', false]);
8218      * // => objects for ['fred', 'pebbles']
8219      *
8220      * // The `_.property` iteratee shorthand.
8221      * _.takeRightWhile(users, 'active');
8222      * // => []
8223      */
8224     function takeRightWhile(array, predicate) {
8225       return (array && array.length)
8226         ? baseWhile(array, getIteratee(predicate, 3), false, true)
8227         : [];
8228     }
8229
8230     /**
8231      * Creates a slice of `array` with elements taken from the beginning. Elements
8232      * are taken until `predicate` returns falsey. The predicate is invoked with
8233      * three arguments: (value, index, array).
8234      *
8235      * @static
8236      * @memberOf _
8237      * @since 3.0.0
8238      * @category Array
8239      * @param {Array} array The array to query.
8240      * @param {Function} [predicate=_.identity] The function invoked per iteration.
8241      * @returns {Array} Returns the slice of `array`.
8242      * @example
8243      *
8244      * var users = [
8245      *   { 'user': 'barney',  'active': false },
8246      *   { 'user': 'fred',    'active': false},
8247      *   { 'user': 'pebbles', 'active': true }
8248      * ];
8249      *
8250      * _.takeWhile(users, function(o) { return !o.active; });
8251      * // => objects for ['barney', 'fred']
8252      *
8253      * // The `_.matches` iteratee shorthand.
8254      * _.takeWhile(users, { 'user': 'barney', 'active': false });
8255      * // => objects for ['barney']
8256      *
8257      * // The `_.matchesProperty` iteratee shorthand.
8258      * _.takeWhile(users, ['active', false]);
8259      * // => objects for ['barney', 'fred']
8260      *
8261      * // The `_.property` iteratee shorthand.
8262      * _.takeWhile(users, 'active');
8263      * // => []
8264      */
8265     function takeWhile(array, predicate) {
8266       return (array && array.length)
8267         ? baseWhile(array, getIteratee(predicate, 3))
8268         : [];
8269     }
8270
8271     /**
8272      * Creates an array of unique values, in order, from all given arrays using
8273      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8274      * for equality comparisons.
8275      *
8276      * @static
8277      * @memberOf _
8278      * @since 0.1.0
8279      * @category Array
8280      * @param {...Array} [arrays] The arrays to inspect.
8281      * @returns {Array} Returns the new array of combined values.
8282      * @example
8283      *
8284      * _.union([2], [1, 2]);
8285      * // => [2, 1]
8286      */
8287     var union = baseRest(function(arrays) {
8288       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8289     });
8290
8291     /**
8292      * This method is like `_.union` except that it accepts `iteratee` which is
8293      * invoked for each element of each `arrays` to generate the criterion by
8294      * which uniqueness is computed. Result values are chosen from the first
8295      * array in which the value occurs. The iteratee is invoked with one argument:
8296      * (value).
8297      *
8298      * @static
8299      * @memberOf _
8300      * @since 4.0.0
8301      * @category Array
8302      * @param {...Array} [arrays] The arrays to inspect.
8303      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8304      * @returns {Array} Returns the new array of combined values.
8305      * @example
8306      *
8307      * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8308      * // => [2.1, 1.2]
8309      *
8310      * // The `_.property` iteratee shorthand.
8311      * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8312      * // => [{ 'x': 1 }, { 'x': 2 }]
8313      */
8314     var unionBy = baseRest(function(arrays) {
8315       var iteratee = last(arrays);
8316       if (isArrayLikeObject(iteratee)) {
8317         iteratee = undefined;
8318       }
8319       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
8320     });
8321
8322     /**
8323      * This method is like `_.union` except that it accepts `comparator` which
8324      * is invoked to compare elements of `arrays`. Result values are chosen from
8325      * the first array in which the value occurs. The comparator is invoked
8326      * with two arguments: (arrVal, othVal).
8327      *
8328      * @static
8329      * @memberOf _
8330      * @since 4.0.0
8331      * @category Array
8332      * @param {...Array} [arrays] The arrays to inspect.
8333      * @param {Function} [comparator] The comparator invoked per element.
8334      * @returns {Array} Returns the new array of combined values.
8335      * @example
8336      *
8337      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8338      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8339      *
8340      * _.unionWith(objects, others, _.isEqual);
8341      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8342      */
8343     var unionWith = baseRest(function(arrays) {
8344       var comparator = last(arrays);
8345       comparator = typeof comparator == 'function' ? comparator : undefined;
8346       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
8347     });
8348
8349     /**
8350      * Creates a duplicate-free version of an array, using
8351      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8352      * for equality comparisons, in which only the first occurrence of each element
8353      * is kept. The order of result values is determined by the order they occur
8354      * in the array.
8355      *
8356      * @static
8357      * @memberOf _
8358      * @since 0.1.0
8359      * @category Array
8360      * @param {Array} array The array to inspect.
8361      * @returns {Array} Returns the new duplicate free array.
8362      * @example
8363      *
8364      * _.uniq([2, 1, 2]);
8365      * // => [2, 1]
8366      */
8367     function uniq(array) {
8368       return (array && array.length) ? baseUniq(array) : [];
8369     }
8370
8371     /**
8372      * This method is like `_.uniq` except that it accepts `iteratee` which is
8373      * invoked for each element in `array` to generate the criterion by which
8374      * uniqueness is computed. The order of result values is determined by the
8375      * order they occur in the array. The iteratee is invoked with one argument:
8376      * (value).
8377      *
8378      * @static
8379      * @memberOf _
8380      * @since 4.0.0
8381      * @category Array
8382      * @param {Array} array The array to inspect.
8383      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8384      * @returns {Array} Returns the new duplicate free array.
8385      * @example
8386      *
8387      * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8388      * // => [2.1, 1.2]
8389      *
8390      * // The `_.property` iteratee shorthand.
8391      * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8392      * // => [{ 'x': 1 }, { 'x': 2 }]
8393      */
8394     function uniqBy(array, iteratee) {
8395       return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
8396     }
8397
8398     /**
8399      * This method is like `_.uniq` except that it accepts `comparator` which
8400      * is invoked to compare elements of `array`. The order of result values is
8401      * determined by the order they occur in the array.The comparator is invoked
8402      * with two arguments: (arrVal, othVal).
8403      *
8404      * @static
8405      * @memberOf _
8406      * @since 4.0.0
8407      * @category Array
8408      * @param {Array} array The array to inspect.
8409      * @param {Function} [comparator] The comparator invoked per element.
8410      * @returns {Array} Returns the new duplicate free array.
8411      * @example
8412      *
8413      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8414      *
8415      * _.uniqWith(objects, _.isEqual);
8416      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8417      */
8418     function uniqWith(array, comparator) {
8419       comparator = typeof comparator == 'function' ? comparator : undefined;
8420       return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
8421     }
8422
8423     /**
8424      * This method is like `_.zip` except that it accepts an array of grouped
8425      * elements and creates an array regrouping the elements to their pre-zip
8426      * configuration.
8427      *
8428      * @static
8429      * @memberOf _
8430      * @since 1.2.0
8431      * @category Array
8432      * @param {Array} array The array of grouped elements to process.
8433      * @returns {Array} Returns the new array of regrouped elements.
8434      * @example
8435      *
8436      * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8437      * // => [['a', 1, true], ['b', 2, false]]
8438      *
8439      * _.unzip(zipped);
8440      * // => [['a', 'b'], [1, 2], [true, false]]
8441      */
8442     function unzip(array) {
8443       if (!(array && array.length)) {
8444         return [];
8445       }
8446       var length = 0;
8447       array = arrayFilter(array, function(group) {
8448         if (isArrayLikeObject(group)) {
8449           length = nativeMax(group.length, length);
8450           return true;
8451         }
8452       });
8453       return baseTimes(length, function(index) {
8454         return arrayMap(array, baseProperty(index));
8455       });
8456     }
8457
8458     /**
8459      * This method is like `_.unzip` except that it accepts `iteratee` to specify
8460      * how regrouped values should be combined. The iteratee is invoked with the
8461      * elements of each group: (...group).
8462      *
8463      * @static
8464      * @memberOf _
8465      * @since 3.8.0
8466      * @category Array
8467      * @param {Array} array The array of grouped elements to process.
8468      * @param {Function} [iteratee=_.identity] The function to combine
8469      *  regrouped values.
8470      * @returns {Array} Returns the new array of regrouped elements.
8471      * @example
8472      *
8473      * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8474      * // => [[1, 10, 100], [2, 20, 200]]
8475      *
8476      * _.unzipWith(zipped, _.add);
8477      * // => [3, 30, 300]
8478      */
8479     function unzipWith(array, iteratee) {
8480       if (!(array && array.length)) {
8481         return [];
8482       }
8483       var result = unzip(array);
8484       if (iteratee == null) {
8485         return result;
8486       }
8487       return arrayMap(result, function(group) {
8488         return apply(iteratee, undefined, group);
8489       });
8490     }
8491
8492     /**
8493      * Creates an array excluding all given values using
8494      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8495      * for equality comparisons.
8496      *
8497      * **Note:** Unlike `_.pull`, this method returns a new array.
8498      *
8499      * @static
8500      * @memberOf _
8501      * @since 0.1.0
8502      * @category Array
8503      * @param {Array} array The array to inspect.
8504      * @param {...*} [values] The values to exclude.
8505      * @returns {Array} Returns the new array of filtered values.
8506      * @see _.difference, _.xor
8507      * @example
8508      *
8509      * _.without([2, 1, 2, 3], 1, 2);
8510      * // => [3]
8511      */
8512     var without = baseRest(function(array, values) {
8513       return isArrayLikeObject(array)
8514         ? baseDifference(array, values)
8515         : [];
8516     });
8517
8518     /**
8519      * Creates an array of unique values that is the
8520      * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
8521      * of the given arrays. The order of result values is determined by the order
8522      * they occur in the arrays.
8523      *
8524      * @static
8525      * @memberOf _
8526      * @since 2.4.0
8527      * @category Array
8528      * @param {...Array} [arrays] The arrays to inspect.
8529      * @returns {Array} Returns the new array of filtered values.
8530      * @see _.difference, _.without
8531      * @example
8532      *
8533      * _.xor([2, 1], [2, 3]);
8534      * // => [1, 3]
8535      */
8536     var xor = baseRest(function(arrays) {
8537       return baseXor(arrayFilter(arrays, isArrayLikeObject));
8538     });
8539
8540     /**
8541      * This method is like `_.xor` except that it accepts `iteratee` which is
8542      * invoked for each element of each `arrays` to generate the criterion by
8543      * which by which they're compared. The order of result values is determined
8544      * by the order they occur in the arrays. The iteratee is invoked with one
8545      * argument: (value).
8546      *
8547      * @static
8548      * @memberOf _
8549      * @since 4.0.0
8550      * @category Array
8551      * @param {...Array} [arrays] The arrays to inspect.
8552      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8553      * @returns {Array} Returns the new array of filtered values.
8554      * @example
8555      *
8556      * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8557      * // => [1.2, 3.4]
8558      *
8559      * // The `_.property` iteratee shorthand.
8560      * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8561      * // => [{ 'x': 2 }]
8562      */
8563     var xorBy = baseRest(function(arrays) {
8564       var iteratee = last(arrays);
8565       if (isArrayLikeObject(iteratee)) {
8566         iteratee = undefined;
8567       }
8568       return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
8569     });
8570
8571     /**
8572      * This method is like `_.xor` except that it accepts `comparator` which is
8573      * invoked to compare elements of `arrays`. The order of result values is
8574      * determined by the order they occur in the arrays. The comparator is invoked
8575      * with two arguments: (arrVal, othVal).
8576      *
8577      * @static
8578      * @memberOf _
8579      * @since 4.0.0
8580      * @category Array
8581      * @param {...Array} [arrays] The arrays to inspect.
8582      * @param {Function} [comparator] The comparator invoked per element.
8583      * @returns {Array} Returns the new array of filtered values.
8584      * @example
8585      *
8586      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8587      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8588      *
8589      * _.xorWith(objects, others, _.isEqual);
8590      * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8591      */
8592     var xorWith = baseRest(function(arrays) {
8593       var comparator = last(arrays);
8594       comparator = typeof comparator == 'function' ? comparator : undefined;
8595       return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
8596     });
8597
8598     /**
8599      * Creates an array of grouped elements, the first of which contains the
8600      * first elements of the given arrays, the second of which contains the
8601      * second elements of the given arrays, and so on.
8602      *
8603      * @static
8604      * @memberOf _
8605      * @since 0.1.0
8606      * @category Array
8607      * @param {...Array} [arrays] The arrays to process.
8608      * @returns {Array} Returns the new array of grouped elements.
8609      * @example
8610      *
8611      * _.zip(['a', 'b'], [1, 2], [true, false]);
8612      * // => [['a', 1, true], ['b', 2, false]]
8613      */
8614     var zip = baseRest(unzip);
8615
8616     /**
8617      * This method is like `_.fromPairs` except that it accepts two arrays,
8618      * one of property identifiers and one of corresponding values.
8619      *
8620      * @static
8621      * @memberOf _
8622      * @since 0.4.0
8623      * @category Array
8624      * @param {Array} [props=[]] The property identifiers.
8625      * @param {Array} [values=[]] The property values.
8626      * @returns {Object} Returns the new object.
8627      * @example
8628      *
8629      * _.zipObject(['a', 'b'], [1, 2]);
8630      * // => { 'a': 1, 'b': 2 }
8631      */
8632     function zipObject(props, values) {
8633       return baseZipObject(props || [], values || [], assignValue);
8634     }
8635
8636     /**
8637      * This method is like `_.zipObject` except that it supports property paths.
8638      *
8639      * @static
8640      * @memberOf _
8641      * @since 4.1.0
8642      * @category Array
8643      * @param {Array} [props=[]] The property identifiers.
8644      * @param {Array} [values=[]] The property values.
8645      * @returns {Object} Returns the new object.
8646      * @example
8647      *
8648      * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
8649      * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
8650      */
8651     function zipObjectDeep(props, values) {
8652       return baseZipObject(props || [], values || [], baseSet);
8653     }
8654
8655     /**
8656      * This method is like `_.zip` except that it accepts `iteratee` to specify
8657      * how grouped 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} [arrays] The arrays to process.
8665      * @param {Function} [iteratee=_.identity] The function to combine
8666      *  grouped values.
8667      * @returns {Array} Returns the new array of grouped elements.
8668      * @example
8669      *
8670      * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
8671      *   return a + b + c;
8672      * });
8673      * // => [111, 222]
8674      */
8675     var zipWith = baseRest(function(arrays) {
8676       var length = arrays.length,
8677           iteratee = length > 1 ? arrays[length - 1] : undefined;
8678
8679       iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
8680       return unzipWith(arrays, iteratee);
8681     });
8682
8683     /*------------------------------------------------------------------------*/
8684
8685     /**
8686      * Creates a `lodash` wrapper instance that wraps `value` with explicit method
8687      * chain sequences enabled. The result of such sequences must be unwrapped
8688      * with `_#value`.
8689      *
8690      * @static
8691      * @memberOf _
8692      * @since 1.3.0
8693      * @category Seq
8694      * @param {*} value The value to wrap.
8695      * @returns {Object} Returns the new `lodash` wrapper instance.
8696      * @example
8697      *
8698      * var users = [
8699      *   { 'user': 'barney',  'age': 36 },
8700      *   { 'user': 'fred',    'age': 40 },
8701      *   { 'user': 'pebbles', 'age': 1 }
8702      * ];
8703      *
8704      * var youngest = _
8705      *   .chain(users)
8706      *   .sortBy('age')
8707      *   .map(function(o) {
8708      *     return o.user + ' is ' + o.age;
8709      *   })
8710      *   .head()
8711      *   .value();
8712      * // => 'pebbles is 1'
8713      */
8714     function chain(value) {
8715       var result = lodash(value);
8716       result.__chain__ = true;
8717       return result;
8718     }
8719
8720     /**
8721      * This method invokes `interceptor` and returns `value`. The interceptor
8722      * is invoked with one argument; (value). The purpose of this method is to
8723      * "tap into" a method chain sequence in order to modify intermediate results.
8724      *
8725      * @static
8726      * @memberOf _
8727      * @since 0.1.0
8728      * @category Seq
8729      * @param {*} value The value to provide to `interceptor`.
8730      * @param {Function} interceptor The function to invoke.
8731      * @returns {*} Returns `value`.
8732      * @example
8733      *
8734      * _([1, 2, 3])
8735      *  .tap(function(array) {
8736      *    // Mutate input array.
8737      *    array.pop();
8738      *  })
8739      *  .reverse()
8740      *  .value();
8741      * // => [2, 1]
8742      */
8743     function tap(value, interceptor) {
8744       interceptor(value);
8745       return value;
8746     }
8747
8748     /**
8749      * This method is like `_.tap` except that it returns the result of `interceptor`.
8750      * The purpose of this method is to "pass thru" values replacing intermediate
8751      * results in a method chain sequence.
8752      *
8753      * @static
8754      * @memberOf _
8755      * @since 3.0.0
8756      * @category Seq
8757      * @param {*} value The value to provide to `interceptor`.
8758      * @param {Function} interceptor The function to invoke.
8759      * @returns {*} Returns the result of `interceptor`.
8760      * @example
8761      *
8762      * _('  abc  ')
8763      *  .chain()
8764      *  .trim()
8765      *  .thru(function(value) {
8766      *    return [value];
8767      *  })
8768      *  .value();
8769      * // => ['abc']
8770      */
8771     function thru(value, interceptor) {
8772       return interceptor(value);
8773     }
8774
8775     /**
8776      * This method is the wrapper version of `_.at`.
8777      *
8778      * @name at
8779      * @memberOf _
8780      * @since 1.0.0
8781      * @category Seq
8782      * @param {...(string|string[])} [paths] The property paths of elements to pick.
8783      * @returns {Object} Returns the new `lodash` wrapper instance.
8784      * @example
8785      *
8786      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
8787      *
8788      * _(object).at(['a[0].b.c', 'a[1]']).value();
8789      * // => [3, 4]
8790      */
8791     var wrapperAt = flatRest(function(paths) {
8792       var length = paths.length,
8793           start = length ? paths[0] : 0,
8794           value = this.__wrapped__,
8795           interceptor = function(object) { return baseAt(object, paths); };
8796
8797       if (length > 1 || this.__actions__.length ||
8798           !(value instanceof LazyWrapper) || !isIndex(start)) {
8799         return this.thru(interceptor);
8800       }
8801       value = value.slice(start, +start + (length ? 1 : 0));
8802       value.__actions__.push({
8803         'func': thru,
8804         'args': [interceptor],
8805         'thisArg': undefined
8806       });
8807       return new LodashWrapper(value, this.__chain__).thru(function(array) {
8808         if (length && !array.length) {
8809           array.push(undefined);
8810         }
8811         return array;
8812       });
8813     });
8814
8815     /**
8816      * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
8817      *
8818      * @name chain
8819      * @memberOf _
8820      * @since 0.1.0
8821      * @category Seq
8822      * @returns {Object} Returns the new `lodash` wrapper instance.
8823      * @example
8824      *
8825      * var users = [
8826      *   { 'user': 'barney', 'age': 36 },
8827      *   { 'user': 'fred',   'age': 40 }
8828      * ];
8829      *
8830      * // A sequence without explicit chaining.
8831      * _(users).head();
8832      * // => { 'user': 'barney', 'age': 36 }
8833      *
8834      * // A sequence with explicit chaining.
8835      * _(users)
8836      *   .chain()
8837      *   .head()
8838      *   .pick('user')
8839      *   .value();
8840      * // => { 'user': 'barney' }
8841      */
8842     function wrapperChain() {
8843       return chain(this);
8844     }
8845
8846     /**
8847      * Executes the chain sequence and returns the wrapped result.
8848      *
8849      * @name commit
8850      * @memberOf _
8851      * @since 3.2.0
8852      * @category Seq
8853      * @returns {Object} Returns the new `lodash` wrapper instance.
8854      * @example
8855      *
8856      * var array = [1, 2];
8857      * var wrapped = _(array).push(3);
8858      *
8859      * console.log(array);
8860      * // => [1, 2]
8861      *
8862      * wrapped = wrapped.commit();
8863      * console.log(array);
8864      * // => [1, 2, 3]
8865      *
8866      * wrapped.last();
8867      * // => 3
8868      *
8869      * console.log(array);
8870      * // => [1, 2, 3]
8871      */
8872     function wrapperCommit() {
8873       return new LodashWrapper(this.value(), this.__chain__);
8874     }
8875
8876     /**
8877      * Gets the next value on a wrapped object following the
8878      * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
8879      *
8880      * @name next
8881      * @memberOf _
8882      * @since 4.0.0
8883      * @category Seq
8884      * @returns {Object} Returns the next iterator value.
8885      * @example
8886      *
8887      * var wrapped = _([1, 2]);
8888      *
8889      * wrapped.next();
8890      * // => { 'done': false, 'value': 1 }
8891      *
8892      * wrapped.next();
8893      * // => { 'done': false, 'value': 2 }
8894      *
8895      * wrapped.next();
8896      * // => { 'done': true, 'value': undefined }
8897      */
8898     function wrapperNext() {
8899       if (this.__values__ === undefined) {
8900         this.__values__ = toArray(this.value());
8901       }
8902       var done = this.__index__ >= this.__values__.length,
8903           value = done ? undefined : this.__values__[this.__index__++];
8904
8905       return { 'done': done, 'value': value };
8906     }
8907
8908     /**
8909      * Enables the wrapper to be iterable.
8910      *
8911      * @name Symbol.iterator
8912      * @memberOf _
8913      * @since 4.0.0
8914      * @category Seq
8915      * @returns {Object} Returns the wrapper object.
8916      * @example
8917      *
8918      * var wrapped = _([1, 2]);
8919      *
8920      * wrapped[Symbol.iterator]() === wrapped;
8921      * // => true
8922      *
8923      * Array.from(wrapped);
8924      * // => [1, 2]
8925      */
8926     function wrapperToIterator() {
8927       return this;
8928     }
8929
8930     /**
8931      * Creates a clone of the chain sequence planting `value` as the wrapped value.
8932      *
8933      * @name plant
8934      * @memberOf _
8935      * @since 3.2.0
8936      * @category Seq
8937      * @param {*} value The value to plant.
8938      * @returns {Object} Returns the new `lodash` wrapper instance.
8939      * @example
8940      *
8941      * function square(n) {
8942      *   return n * n;
8943      * }
8944      *
8945      * var wrapped = _([1, 2]).map(square);
8946      * var other = wrapped.plant([3, 4]);
8947      *
8948      * other.value();
8949      * // => [9, 16]
8950      *
8951      * wrapped.value();
8952      * // => [1, 4]
8953      */
8954     function wrapperPlant(value) {
8955       var result,
8956           parent = this;
8957
8958       while (parent instanceof baseLodash) {
8959         var clone = wrapperClone(parent);
8960         clone.__index__ = 0;
8961         clone.__values__ = undefined;
8962         if (result) {
8963           previous.__wrapped__ = clone;
8964         } else {
8965           result = clone;
8966         }
8967         var previous = clone;
8968         parent = parent.__wrapped__;
8969       }
8970       previous.__wrapped__ = value;
8971       return result;
8972     }
8973
8974     /**
8975      * This method is the wrapper version of `_.reverse`.
8976      *
8977      * **Note:** This method mutates the wrapped array.
8978      *
8979      * @name reverse
8980      * @memberOf _
8981      * @since 0.1.0
8982      * @category Seq
8983      * @returns {Object} Returns the new `lodash` wrapper instance.
8984      * @example
8985      *
8986      * var array = [1, 2, 3];
8987      *
8988      * _(array).reverse().value()
8989      * // => [3, 2, 1]
8990      *
8991      * console.log(array);
8992      * // => [3, 2, 1]
8993      */
8994     function wrapperReverse() {
8995       var value = this.__wrapped__;
8996       if (value instanceof LazyWrapper) {
8997         var wrapped = value;
8998         if (this.__actions__.length) {
8999           wrapped = new LazyWrapper(this);
9000         }
9001         wrapped = wrapped.reverse();
9002         wrapped.__actions__.push({
9003           'func': thru,
9004           'args': [reverse],
9005           'thisArg': undefined
9006         });
9007         return new LodashWrapper(wrapped, this.__chain__);
9008       }
9009       return this.thru(reverse);
9010     }
9011
9012     /**
9013      * Executes the chain sequence to resolve the unwrapped value.
9014      *
9015      * @name value
9016      * @memberOf _
9017      * @since 0.1.0
9018      * @alias toJSON, valueOf
9019      * @category Seq
9020      * @returns {*} Returns the resolved unwrapped value.
9021      * @example
9022      *
9023      * _([1, 2, 3]).value();
9024      * // => [1, 2, 3]
9025      */
9026     function wrapperValue() {
9027       return baseWrapperValue(this.__wrapped__, this.__actions__);
9028     }
9029
9030     /*------------------------------------------------------------------------*/
9031
9032     /**
9033      * Creates an object composed of keys generated from the results of running
9034      * each element of `collection` thru `iteratee`. The corresponding value of
9035      * each key is the number of times the key was returned by `iteratee`. The
9036      * iteratee is invoked with one argument: (value).
9037      *
9038      * @static
9039      * @memberOf _
9040      * @since 0.5.0
9041      * @category Collection
9042      * @param {Array|Object} collection The collection to iterate over.
9043      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9044      * @returns {Object} Returns the composed aggregate object.
9045      * @example
9046      *
9047      * _.countBy([6.1, 4.2, 6.3], Math.floor);
9048      * // => { '4': 1, '6': 2 }
9049      *
9050      * // The `_.property` iteratee shorthand.
9051      * _.countBy(['one', 'two', 'three'], 'length');
9052      * // => { '3': 2, '5': 1 }
9053      */
9054     var countBy = createAggregator(function(result, value, key) {
9055       if (hasOwnProperty.call(result, key)) {
9056         ++result[key];
9057       } else {
9058         baseAssignValue(result, key, 1);
9059       }
9060     });
9061
9062     /**
9063      * Checks if `predicate` returns truthy for **all** elements of `collection`.
9064      * Iteration is stopped once `predicate` returns falsey. The predicate is
9065      * invoked with three arguments: (value, index|key, collection).
9066      *
9067      * **Note:** This method returns `true` for
9068      * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
9069      * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
9070      * elements of empty collections.
9071      *
9072      * @static
9073      * @memberOf _
9074      * @since 0.1.0
9075      * @category Collection
9076      * @param {Array|Object} collection The collection to iterate over.
9077      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9078      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9079      * @returns {boolean} Returns `true` if all elements pass the predicate check,
9080      *  else `false`.
9081      * @example
9082      *
9083      * _.every([true, 1, null, 'yes'], Boolean);
9084      * // => false
9085      *
9086      * var users = [
9087      *   { 'user': 'barney', 'age': 36, 'active': false },
9088      *   { 'user': 'fred',   'age': 40, 'active': false }
9089      * ];
9090      *
9091      * // The `_.matches` iteratee shorthand.
9092      * _.every(users, { 'user': 'barney', 'active': false });
9093      * // => false
9094      *
9095      * // The `_.matchesProperty` iteratee shorthand.
9096      * _.every(users, ['active', false]);
9097      * // => true
9098      *
9099      * // The `_.property` iteratee shorthand.
9100      * _.every(users, 'active');
9101      * // => false
9102      */
9103     function every(collection, predicate, guard) {
9104       var func = isArray(collection) ? arrayEvery : baseEvery;
9105       if (guard && isIterateeCall(collection, predicate, guard)) {
9106         predicate = undefined;
9107       }
9108       return func(collection, getIteratee(predicate, 3));
9109     }
9110
9111     /**
9112      * Iterates over elements of `collection`, returning an array of all elements
9113      * `predicate` returns truthy for. The predicate is invoked with three
9114      * arguments: (value, index|key, collection).
9115      *
9116      * **Note:** Unlike `_.remove`, this method returns a new array.
9117      *
9118      * @static
9119      * @memberOf _
9120      * @since 0.1.0
9121      * @category Collection
9122      * @param {Array|Object} collection The collection to iterate over.
9123      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9124      * @returns {Array} Returns the new filtered array.
9125      * @see _.reject
9126      * @example
9127      *
9128      * var users = [
9129      *   { 'user': 'barney', 'age': 36, 'active': true },
9130      *   { 'user': 'fred',   'age': 40, 'active': false }
9131      * ];
9132      *
9133      * _.filter(users, function(o) { return !o.active; });
9134      * // => objects for ['fred']
9135      *
9136      * // The `_.matches` iteratee shorthand.
9137      * _.filter(users, { 'age': 36, 'active': true });
9138      * // => objects for ['barney']
9139      *
9140      * // The `_.matchesProperty` iteratee shorthand.
9141      * _.filter(users, ['active', false]);
9142      * // => objects for ['fred']
9143      *
9144      * // The `_.property` iteratee shorthand.
9145      * _.filter(users, 'active');
9146      * // => objects for ['barney']
9147      */
9148     function filter(collection, predicate) {
9149       var func = isArray(collection) ? arrayFilter : baseFilter;
9150       return func(collection, getIteratee(predicate, 3));
9151     }
9152
9153     /**
9154      * Iterates over elements of `collection`, returning the first element
9155      * `predicate` returns truthy for. The predicate is invoked with three
9156      * arguments: (value, index|key, collection).
9157      *
9158      * @static
9159      * @memberOf _
9160      * @since 0.1.0
9161      * @category Collection
9162      * @param {Array|Object} collection The collection to inspect.
9163      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9164      * @param {number} [fromIndex=0] The index to search from.
9165      * @returns {*} Returns the matched element, else `undefined`.
9166      * @example
9167      *
9168      * var users = [
9169      *   { 'user': 'barney',  'age': 36, 'active': true },
9170      *   { 'user': 'fred',    'age': 40, 'active': false },
9171      *   { 'user': 'pebbles', 'age': 1,  'active': true }
9172      * ];
9173      *
9174      * _.find(users, function(o) { return o.age < 40; });
9175      * // => object for 'barney'
9176      *
9177      * // The `_.matches` iteratee shorthand.
9178      * _.find(users, { 'age': 1, 'active': true });
9179      * // => object for 'pebbles'
9180      *
9181      * // The `_.matchesProperty` iteratee shorthand.
9182      * _.find(users, ['active', false]);
9183      * // => object for 'fred'
9184      *
9185      * // The `_.property` iteratee shorthand.
9186      * _.find(users, 'active');
9187      * // => object for 'barney'
9188      */
9189     var find = createFind(findIndex);
9190
9191     /**
9192      * This method is like `_.find` except that it iterates over elements of
9193      * `collection` from right to left.
9194      *
9195      * @static
9196      * @memberOf _
9197      * @since 2.0.0
9198      * @category Collection
9199      * @param {Array|Object} collection The collection to inspect.
9200      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9201      * @param {number} [fromIndex=collection.length-1] The index to search from.
9202      * @returns {*} Returns the matched element, else `undefined`.
9203      * @example
9204      *
9205      * _.findLast([1, 2, 3, 4], function(n) {
9206      *   return n % 2 == 1;
9207      * });
9208      * // => 3
9209      */
9210     var findLast = createFind(findLastIndex);
9211
9212     /**
9213      * Creates a flattened array of values by running each element in `collection`
9214      * thru `iteratee` and flattening the mapped results. The iteratee is invoked
9215      * with three arguments: (value, index|key, collection).
9216      *
9217      * @static
9218      * @memberOf _
9219      * @since 4.0.0
9220      * @category Collection
9221      * @param {Array|Object} collection The collection to iterate over.
9222      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9223      * @returns {Array} Returns the new flattened array.
9224      * @example
9225      *
9226      * function duplicate(n) {
9227      *   return [n, n];
9228      * }
9229      *
9230      * _.flatMap([1, 2], duplicate);
9231      * // => [1, 1, 2, 2]
9232      */
9233     function flatMap(collection, iteratee) {
9234       return baseFlatten(map(collection, iteratee), 1);
9235     }
9236
9237     /**
9238      * This method is like `_.flatMap` except that it recursively flattens the
9239      * mapped results.
9240      *
9241      * @static
9242      * @memberOf _
9243      * @since 4.7.0
9244      * @category Collection
9245      * @param {Array|Object} collection The collection to iterate over.
9246      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9247      * @returns {Array} Returns the new flattened array.
9248      * @example
9249      *
9250      * function duplicate(n) {
9251      *   return [[[n, n]]];
9252      * }
9253      *
9254      * _.flatMapDeep([1, 2], duplicate);
9255      * // => [1, 1, 2, 2]
9256      */
9257     function flatMapDeep(collection, iteratee) {
9258       return baseFlatten(map(collection, iteratee), INFINITY);
9259     }
9260
9261     /**
9262      * This method is like `_.flatMap` except that it recursively flattens the
9263      * mapped results up to `depth` times.
9264      *
9265      * @static
9266      * @memberOf _
9267      * @since 4.7.0
9268      * @category Collection
9269      * @param {Array|Object} collection The collection to iterate over.
9270      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9271      * @param {number} [depth=1] The maximum recursion depth.
9272      * @returns {Array} Returns the new flattened array.
9273      * @example
9274      *
9275      * function duplicate(n) {
9276      *   return [[[n, n]]];
9277      * }
9278      *
9279      * _.flatMapDepth([1, 2], duplicate, 2);
9280      * // => [[1, 1], [2, 2]]
9281      */
9282     function flatMapDepth(collection, iteratee, depth) {
9283       depth = depth === undefined ? 1 : toInteger(depth);
9284       return baseFlatten(map(collection, iteratee), depth);
9285     }
9286
9287     /**
9288      * Iterates over elements of `collection` and invokes `iteratee` for each element.
9289      * The iteratee is invoked with three arguments: (value, index|key, collection).
9290      * Iteratee functions may exit iteration early by explicitly returning `false`.
9291      *
9292      * **Note:** As with other "Collections" methods, objects with a "length"
9293      * property are iterated like arrays. To avoid this behavior use `_.forIn`
9294      * or `_.forOwn` for object iteration.
9295      *
9296      * @static
9297      * @memberOf _
9298      * @since 0.1.0
9299      * @alias each
9300      * @category Collection
9301      * @param {Array|Object} collection The collection to iterate over.
9302      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9303      * @returns {Array|Object} Returns `collection`.
9304      * @see _.forEachRight
9305      * @example
9306      *
9307      * _.forEach([1, 2], function(value) {
9308      *   console.log(value);
9309      * });
9310      * // => Logs `1` then `2`.
9311      *
9312      * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9313      *   console.log(key);
9314      * });
9315      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9316      */
9317     function forEach(collection, iteratee) {
9318       var func = isArray(collection) ? arrayEach : baseEach;
9319       return func(collection, getIteratee(iteratee, 3));
9320     }
9321
9322     /**
9323      * This method is like `_.forEach` except that it iterates over elements of
9324      * `collection` from right to left.
9325      *
9326      * @static
9327      * @memberOf _
9328      * @since 2.0.0
9329      * @alias eachRight
9330      * @category Collection
9331      * @param {Array|Object} collection The collection to iterate over.
9332      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9333      * @returns {Array|Object} Returns `collection`.
9334      * @see _.forEach
9335      * @example
9336      *
9337      * _.forEachRight([1, 2], function(value) {
9338      *   console.log(value);
9339      * });
9340      * // => Logs `2` then `1`.
9341      */
9342     function forEachRight(collection, iteratee) {
9343       var func = isArray(collection) ? arrayEachRight : baseEachRight;
9344       return func(collection, getIteratee(iteratee, 3));
9345     }
9346
9347     /**
9348      * Creates an object composed of keys generated from the results of running
9349      * each element of `collection` thru `iteratee`. The order of grouped values
9350      * is determined by the order they occur in `collection`. The corresponding
9351      * value of each key is an array of elements responsible for generating the
9352      * key. The iteratee is invoked with one argument: (value).
9353      *
9354      * @static
9355      * @memberOf _
9356      * @since 0.1.0
9357      * @category Collection
9358      * @param {Array|Object} collection The collection to iterate over.
9359      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9360      * @returns {Object} Returns the composed aggregate object.
9361      * @example
9362      *
9363      * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9364      * // => { '4': [4.2], '6': [6.1, 6.3] }
9365      *
9366      * // The `_.property` iteratee shorthand.
9367      * _.groupBy(['one', 'two', 'three'], 'length');
9368      * // => { '3': ['one', 'two'], '5': ['three'] }
9369      */
9370     var groupBy = createAggregator(function(result, value, key) {
9371       if (hasOwnProperty.call(result, key)) {
9372         result[key].push(value);
9373       } else {
9374         baseAssignValue(result, key, [value]);
9375       }
9376     });
9377
9378     /**
9379      * Checks if `value` is in `collection`. If `collection` is a string, it's
9380      * checked for a substring of `value`, otherwise
9381      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9382      * is used for equality comparisons. If `fromIndex` is negative, it's used as
9383      * the offset from the end of `collection`.
9384      *
9385      * @static
9386      * @memberOf _
9387      * @since 0.1.0
9388      * @category Collection
9389      * @param {Array|Object|string} collection The collection to inspect.
9390      * @param {*} value The value to search for.
9391      * @param {number} [fromIndex=0] The index to search from.
9392      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9393      * @returns {boolean} Returns `true` if `value` is found, else `false`.
9394      * @example
9395      *
9396      * _.includes([1, 2, 3], 1);
9397      * // => true
9398      *
9399      * _.includes([1, 2, 3], 1, 2);
9400      * // => false
9401      *
9402      * _.includes({ 'a': 1, 'b': 2 }, 1);
9403      * // => true
9404      *
9405      * _.includes('abcd', 'bc');
9406      * // => true
9407      */
9408     function includes(collection, value, fromIndex, guard) {
9409       collection = isArrayLike(collection) ? collection : values(collection);
9410       fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9411
9412       var length = collection.length;
9413       if (fromIndex < 0) {
9414         fromIndex = nativeMax(length + fromIndex, 0);
9415       }
9416       return isString(collection)
9417         ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9418         : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9419     }
9420
9421     /**
9422      * Invokes the method at `path` of each element in `collection`, returning
9423      * an array of the results of each invoked method. Any additional arguments
9424      * are provided to each invoked method. If `path` is a function, it's invoked
9425      * for, and `this` bound to, each element in `collection`.
9426      *
9427      * @static
9428      * @memberOf _
9429      * @since 4.0.0
9430      * @category Collection
9431      * @param {Array|Object} collection The collection to iterate over.
9432      * @param {Array|Function|string} path The path of the method to invoke or
9433      *  the function invoked per iteration.
9434      * @param {...*} [args] The arguments to invoke each method with.
9435      * @returns {Array} Returns the array of results.
9436      * @example
9437      *
9438      * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9439      * // => [[1, 5, 7], [1, 2, 3]]
9440      *
9441      * _.invokeMap([123, 456], String.prototype.split, '');
9442      * // => [['1', '2', '3'], ['4', '5', '6']]
9443      */
9444     var invokeMap = baseRest(function(collection, path, args) {
9445       var index = -1,
9446           isFunc = typeof path == 'function',
9447           isProp = isKey(path),
9448           result = isArrayLike(collection) ? Array(collection.length) : [];
9449
9450       baseEach(collection, function(value) {
9451         var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
9452         result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);
9453       });
9454       return result;
9455     });
9456
9457     /**
9458      * Creates an object composed of keys generated from the results of running
9459      * each element of `collection` thru `iteratee`. The corresponding value of
9460      * each key is the last element responsible for generating the key. The
9461      * iteratee is invoked with one argument: (value).
9462      *
9463      * @static
9464      * @memberOf _
9465      * @since 4.0.0
9466      * @category Collection
9467      * @param {Array|Object} collection The collection to iterate over.
9468      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9469      * @returns {Object} Returns the composed aggregate object.
9470      * @example
9471      *
9472      * var array = [
9473      *   { 'dir': 'left', 'code': 97 },
9474      *   { 'dir': 'right', 'code': 100 }
9475      * ];
9476      *
9477      * _.keyBy(array, function(o) {
9478      *   return String.fromCharCode(o.code);
9479      * });
9480      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9481      *
9482      * _.keyBy(array, 'dir');
9483      * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9484      */
9485     var keyBy = createAggregator(function(result, value, key) {
9486       baseAssignValue(result, key, value);
9487     });
9488
9489     /**
9490      * Creates an array of values by running each element in `collection` thru
9491      * `iteratee`. The iteratee is invoked with three arguments:
9492      * (value, index|key, collection).
9493      *
9494      * Many lodash methods are guarded to work as iteratees for methods like
9495      * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9496      *
9497      * The guarded methods are:
9498      * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9499      * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9500      * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9501      * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9502      *
9503      * @static
9504      * @memberOf _
9505      * @since 0.1.0
9506      * @category Collection
9507      * @param {Array|Object} collection The collection to iterate over.
9508      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9509      * @returns {Array} Returns the new mapped array.
9510      * @example
9511      *
9512      * function square(n) {
9513      *   return n * n;
9514      * }
9515      *
9516      * _.map([4, 8], square);
9517      * // => [16, 64]
9518      *
9519      * _.map({ 'a': 4, 'b': 8 }, square);
9520      * // => [16, 64] (iteration order is not guaranteed)
9521      *
9522      * var users = [
9523      *   { 'user': 'barney' },
9524      *   { 'user': 'fred' }
9525      * ];
9526      *
9527      * // The `_.property` iteratee shorthand.
9528      * _.map(users, 'user');
9529      * // => ['barney', 'fred']
9530      */
9531     function map(collection, iteratee) {
9532       var func = isArray(collection) ? arrayMap : baseMap;
9533       return func(collection, getIteratee(iteratee, 3));
9534     }
9535
9536     /**
9537      * This method is like `_.sortBy` except that it allows specifying the sort
9538      * orders of the iteratees to sort by. If `orders` is unspecified, all values
9539      * are sorted in ascending order. Otherwise, specify an order of "desc" for
9540      * descending or "asc" for ascending sort order of corresponding values.
9541      *
9542      * @static
9543      * @memberOf _
9544      * @since 4.0.0
9545      * @category Collection
9546      * @param {Array|Object} collection The collection to iterate over.
9547      * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
9548      *  The iteratees to sort by.
9549      * @param {string[]} [orders] The sort orders of `iteratees`.
9550      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9551      * @returns {Array} Returns the new sorted array.
9552      * @example
9553      *
9554      * var users = [
9555      *   { 'user': 'fred',   'age': 48 },
9556      *   { 'user': 'barney', 'age': 34 },
9557      *   { 'user': 'fred',   'age': 40 },
9558      *   { 'user': 'barney', 'age': 36 }
9559      * ];
9560      *
9561      * // Sort by `user` in ascending order and by `age` in descending order.
9562      * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
9563      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9564      */
9565     function orderBy(collection, iteratees, orders, guard) {
9566       if (collection == null) {
9567         return [];
9568       }
9569       if (!isArray(iteratees)) {
9570         iteratees = iteratees == null ? [] : [iteratees];
9571       }
9572       orders = guard ? undefined : orders;
9573       if (!isArray(orders)) {
9574         orders = orders == null ? [] : [orders];
9575       }
9576       return baseOrderBy(collection, iteratees, orders);
9577     }
9578
9579     /**
9580      * Creates an array of elements split into two groups, the first of which
9581      * contains elements `predicate` returns truthy for, the second of which
9582      * contains elements `predicate` returns falsey for. The predicate is
9583      * invoked with one argument: (value).
9584      *
9585      * @static
9586      * @memberOf _
9587      * @since 3.0.0
9588      * @category Collection
9589      * @param {Array|Object} collection The collection to iterate over.
9590      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9591      * @returns {Array} Returns the array of grouped elements.
9592      * @example
9593      *
9594      * var users = [
9595      *   { 'user': 'barney',  'age': 36, 'active': false },
9596      *   { 'user': 'fred',    'age': 40, 'active': true },
9597      *   { 'user': 'pebbles', 'age': 1,  'active': false }
9598      * ];
9599      *
9600      * _.partition(users, function(o) { return o.active; });
9601      * // => objects for [['fred'], ['barney', 'pebbles']]
9602      *
9603      * // The `_.matches` iteratee shorthand.
9604      * _.partition(users, { 'age': 1, 'active': false });
9605      * // => objects for [['pebbles'], ['barney', 'fred']]
9606      *
9607      * // The `_.matchesProperty` iteratee shorthand.
9608      * _.partition(users, ['active', false]);
9609      * // => objects for [['barney', 'pebbles'], ['fred']]
9610      *
9611      * // The `_.property` iteratee shorthand.
9612      * _.partition(users, 'active');
9613      * // => objects for [['fred'], ['barney', 'pebbles']]
9614      */
9615     var partition = createAggregator(function(result, value, key) {
9616       result[key ? 0 : 1].push(value);
9617     }, function() { return [[], []]; });
9618
9619     /**
9620      * Reduces `collection` to a value which is the accumulated result of running
9621      * each element in `collection` thru `iteratee`, where each successive
9622      * invocation is supplied the return value of the previous. If `accumulator`
9623      * is not given, the first element of `collection` is used as the initial
9624      * value. The iteratee is invoked with four arguments:
9625      * (accumulator, value, index|key, collection).
9626      *
9627      * Many lodash methods are guarded to work as iteratees for methods like
9628      * `_.reduce`, `_.reduceRight`, and `_.transform`.
9629      *
9630      * The guarded methods are:
9631      * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
9632      * and `sortBy`
9633      *
9634      * @static
9635      * @memberOf _
9636      * @since 0.1.0
9637      * @category Collection
9638      * @param {Array|Object} collection The collection to iterate over.
9639      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9640      * @param {*} [accumulator] The initial value.
9641      * @returns {*} Returns the accumulated value.
9642      * @see _.reduceRight
9643      * @example
9644      *
9645      * _.reduce([1, 2], function(sum, n) {
9646      *   return sum + n;
9647      * }, 0);
9648      * // => 3
9649      *
9650      * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
9651      *   (result[value] || (result[value] = [])).push(key);
9652      *   return result;
9653      * }, {});
9654      * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
9655      */
9656     function reduce(collection, iteratee, accumulator) {
9657       var func = isArray(collection) ? arrayReduce : baseReduce,
9658           initAccum = arguments.length < 3;
9659
9660       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
9661     }
9662
9663     /**
9664      * This method is like `_.reduce` except that it iterates over elements of
9665      * `collection` from right to left.
9666      *
9667      * @static
9668      * @memberOf _
9669      * @since 0.1.0
9670      * @category Collection
9671      * @param {Array|Object} collection The collection to iterate over.
9672      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9673      * @param {*} [accumulator] The initial value.
9674      * @returns {*} Returns the accumulated value.
9675      * @see _.reduce
9676      * @example
9677      *
9678      * var array = [[0, 1], [2, 3], [4, 5]];
9679      *
9680      * _.reduceRight(array, function(flattened, other) {
9681      *   return flattened.concat(other);
9682      * }, []);
9683      * // => [4, 5, 2, 3, 0, 1]
9684      */
9685     function reduceRight(collection, iteratee, accumulator) {
9686       var func = isArray(collection) ? arrayReduceRight : baseReduce,
9687           initAccum = arguments.length < 3;
9688
9689       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
9690     }
9691
9692     /**
9693      * The opposite of `_.filter`; this method returns the elements of `collection`
9694      * that `predicate` does **not** return truthy for.
9695      *
9696      * @static
9697      * @memberOf _
9698      * @since 0.1.0
9699      * @category Collection
9700      * @param {Array|Object} collection The collection to iterate over.
9701      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9702      * @returns {Array} Returns the new filtered array.
9703      * @see _.filter
9704      * @example
9705      *
9706      * var users = [
9707      *   { 'user': 'barney', 'age': 36, 'active': false },
9708      *   { 'user': 'fred',   'age': 40, 'active': true }
9709      * ];
9710      *
9711      * _.reject(users, function(o) { return !o.active; });
9712      * // => objects for ['fred']
9713      *
9714      * // The `_.matches` iteratee shorthand.
9715      * _.reject(users, { 'age': 40, 'active': true });
9716      * // => objects for ['barney']
9717      *
9718      * // The `_.matchesProperty` iteratee shorthand.
9719      * _.reject(users, ['active', false]);
9720      * // => objects for ['fred']
9721      *
9722      * // The `_.property` iteratee shorthand.
9723      * _.reject(users, 'active');
9724      * // => objects for ['barney']
9725      */
9726     function reject(collection, predicate) {
9727       var func = isArray(collection) ? arrayFilter : baseFilter;
9728       return func(collection, negate(getIteratee(predicate, 3)));
9729     }
9730
9731     /**
9732      * Gets a random element from `collection`.
9733      *
9734      * @static
9735      * @memberOf _
9736      * @since 2.0.0
9737      * @category Collection
9738      * @param {Array|Object} collection The collection to sample.
9739      * @returns {*} Returns the random element.
9740      * @example
9741      *
9742      * _.sample([1, 2, 3, 4]);
9743      * // => 2
9744      */
9745     function sample(collection) {
9746       var func = isArray(collection) ? arraySample : baseSample;
9747       return func(collection);
9748     }
9749
9750     /**
9751      * Gets `n` random elements at unique keys from `collection` up to the
9752      * size of `collection`.
9753      *
9754      * @static
9755      * @memberOf _
9756      * @since 4.0.0
9757      * @category Collection
9758      * @param {Array|Object} collection The collection to sample.
9759      * @param {number} [n=1] The number of elements to sample.
9760      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9761      * @returns {Array} Returns the random elements.
9762      * @example
9763      *
9764      * _.sampleSize([1, 2, 3], 2);
9765      * // => [3, 1]
9766      *
9767      * _.sampleSize([1, 2, 3], 4);
9768      * // => [2, 3, 1]
9769      */
9770     function sampleSize(collection, n, guard) {
9771       if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
9772         n = 1;
9773       } else {
9774         n = toInteger(n);
9775       }
9776       var func = isArray(collection) ? arraySampleSize : baseSampleSize;
9777       return func(collection, n);
9778     }
9779
9780     /**
9781      * Creates an array of shuffled values, using a version of the
9782      * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9783      *
9784      * @static
9785      * @memberOf _
9786      * @since 0.1.0
9787      * @category Collection
9788      * @param {Array|Object} collection The collection to shuffle.
9789      * @returns {Array} Returns the new shuffled array.
9790      * @example
9791      *
9792      * _.shuffle([1, 2, 3, 4]);
9793      * // => [4, 1, 3, 2]
9794      */
9795     function shuffle(collection) {
9796       var func = isArray(collection) ? arrayShuffle : baseShuffle;
9797       return func(collection);
9798     }
9799
9800     /**
9801      * Gets the size of `collection` by returning its length for array-like
9802      * values or the number of own enumerable string keyed properties for objects.
9803      *
9804      * @static
9805      * @memberOf _
9806      * @since 0.1.0
9807      * @category Collection
9808      * @param {Array|Object|string} collection The collection to inspect.
9809      * @returns {number} Returns the collection size.
9810      * @example
9811      *
9812      * _.size([1, 2, 3]);
9813      * // => 3
9814      *
9815      * _.size({ 'a': 1, 'b': 2 });
9816      * // => 2
9817      *
9818      * _.size('pebbles');
9819      * // => 7
9820      */
9821     function size(collection) {
9822       if (collection == null) {
9823         return 0;
9824       }
9825       if (isArrayLike(collection)) {
9826         return isString(collection) ? stringSize(collection) : collection.length;
9827       }
9828       var tag = getTag(collection);
9829       if (tag == mapTag || tag == setTag) {
9830         return collection.size;
9831       }
9832       return baseKeys(collection).length;
9833     }
9834
9835     /**
9836      * Checks if `predicate` returns truthy for **any** element of `collection`.
9837      * Iteration is stopped once `predicate` returns truthy. The predicate is
9838      * invoked with three arguments: (value, index|key, collection).
9839      *
9840      * @static
9841      * @memberOf _
9842      * @since 0.1.0
9843      * @category Collection
9844      * @param {Array|Object} collection The collection to iterate over.
9845      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9846      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9847      * @returns {boolean} Returns `true` if any element passes the predicate check,
9848      *  else `false`.
9849      * @example
9850      *
9851      * _.some([null, 0, 'yes', false], Boolean);
9852      * // => true
9853      *
9854      * var users = [
9855      *   { 'user': 'barney', 'active': true },
9856      *   { 'user': 'fred',   'active': false }
9857      * ];
9858      *
9859      * // The `_.matches` iteratee shorthand.
9860      * _.some(users, { 'user': 'barney', 'active': false });
9861      * // => false
9862      *
9863      * // The `_.matchesProperty` iteratee shorthand.
9864      * _.some(users, ['active', false]);
9865      * // => true
9866      *
9867      * // The `_.property` iteratee shorthand.
9868      * _.some(users, 'active');
9869      * // => true
9870      */
9871     function some(collection, predicate, guard) {
9872       var func = isArray(collection) ? arraySome : baseSome;
9873       if (guard && isIterateeCall(collection, predicate, guard)) {
9874         predicate = undefined;
9875       }
9876       return func(collection, getIteratee(predicate, 3));
9877     }
9878
9879     /**
9880      * Creates an array of elements, sorted in ascending order by the results of
9881      * running each element in a collection thru each iteratee. This method
9882      * performs a stable sort, that is, it preserves the original sort order of
9883      * equal elements. The iteratees are invoked with one argument: (value).
9884      *
9885      * @static
9886      * @memberOf _
9887      * @since 0.1.0
9888      * @category Collection
9889      * @param {Array|Object} collection The collection to iterate over.
9890      * @param {...(Function|Function[])} [iteratees=[_.identity]]
9891      *  The iteratees to sort by.
9892      * @returns {Array} Returns the new sorted array.
9893      * @example
9894      *
9895      * var users = [
9896      *   { 'user': 'fred',   'age': 48 },
9897      *   { 'user': 'barney', 'age': 36 },
9898      *   { 'user': 'fred',   'age': 40 },
9899      *   { 'user': 'barney', 'age': 34 }
9900      * ];
9901      *
9902      * _.sortBy(users, [function(o) { return o.user; }]);
9903      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9904      *
9905      * _.sortBy(users, ['user', 'age']);
9906      * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
9907      */
9908     var sortBy = baseRest(function(collection, iteratees) {
9909       if (collection == null) {
9910         return [];
9911       }
9912       var length = iteratees.length;
9913       if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
9914         iteratees = [];
9915       } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
9916         iteratees = [iteratees[0]];
9917       }
9918       return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
9919     });
9920
9921     /*------------------------------------------------------------------------*/
9922
9923     /**
9924      * Gets the timestamp of the number of milliseconds that have elapsed since
9925      * the Unix epoch (1 January 1970 00:00:00 UTC).
9926      *
9927      * @static
9928      * @memberOf _
9929      * @since 2.4.0
9930      * @category Date
9931      * @returns {number} Returns the timestamp.
9932      * @example
9933      *
9934      * _.defer(function(stamp) {
9935      *   console.log(_.now() - stamp);
9936      * }, _.now());
9937      * // => Logs the number of milliseconds it took for the deferred invocation.
9938      */
9939     var now = ctxNow || function() {
9940       return root.Date.now();
9941     };
9942
9943     /*------------------------------------------------------------------------*/
9944
9945     /**
9946      * The opposite of `_.before`; this method creates a function that invokes
9947      * `func` once it's called `n` or more times.
9948      *
9949      * @static
9950      * @memberOf _
9951      * @since 0.1.0
9952      * @category Function
9953      * @param {number} n The number of calls before `func` is invoked.
9954      * @param {Function} func The function to restrict.
9955      * @returns {Function} Returns the new restricted function.
9956      * @example
9957      *
9958      * var saves = ['profile', 'settings'];
9959      *
9960      * var done = _.after(saves.length, function() {
9961      *   console.log('done saving!');
9962      * });
9963      *
9964      * _.forEach(saves, function(type) {
9965      *   asyncSave({ 'type': type, 'complete': done });
9966      * });
9967      * // => Logs 'done saving!' after the two async saves have completed.
9968      */
9969     function after(n, func) {
9970       if (typeof func != 'function') {
9971         throw new TypeError(FUNC_ERROR_TEXT);
9972       }
9973       n = toInteger(n);
9974       return function() {
9975         if (--n < 1) {
9976           return func.apply(this, arguments);
9977         }
9978       };
9979     }
9980
9981     /**
9982      * Creates a function that invokes `func`, with up to `n` arguments,
9983      * ignoring any additional arguments.
9984      *
9985      * @static
9986      * @memberOf _
9987      * @since 3.0.0
9988      * @category Function
9989      * @param {Function} func The function to cap arguments for.
9990      * @param {number} [n=func.length] The arity cap.
9991      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9992      * @returns {Function} Returns the new capped function.
9993      * @example
9994      *
9995      * _.map(['6', '8', '10'], _.ary(parseInt, 1));
9996      * // => [6, 8, 10]
9997      */
9998     function ary(func, n, guard) {
9999       n = guard ? undefined : n;
10000       n = (func && n == null) ? func.length : n;
10001       return createWrap(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
10002     }
10003
10004     /**
10005      * Creates a function that invokes `func`, with the `this` binding and arguments
10006      * of the created function, while it's called less than `n` times. Subsequent
10007      * calls to the created function return the result of the last `func` invocation.
10008      *
10009      * @static
10010      * @memberOf _
10011      * @since 3.0.0
10012      * @category Function
10013      * @param {number} n The number of calls at which `func` is no longer invoked.
10014      * @param {Function} func The function to restrict.
10015      * @returns {Function} Returns the new restricted function.
10016      * @example
10017      *
10018      * jQuery(element).on('click', _.before(5, addContactToList));
10019      * // => Allows adding up to 4 contacts to the list.
10020      */
10021     function before(n, func) {
10022       var result;
10023       if (typeof func != 'function') {
10024         throw new TypeError(FUNC_ERROR_TEXT);
10025       }
10026       n = toInteger(n);
10027       return function() {
10028         if (--n > 0) {
10029           result = func.apply(this, arguments);
10030         }
10031         if (n <= 1) {
10032           func = undefined;
10033         }
10034         return result;
10035       };
10036     }
10037
10038     /**
10039      * Creates a function that invokes `func` with the `this` binding of `thisArg`
10040      * and `partials` prepended to the arguments it receives.
10041      *
10042      * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10043      * may be used as a placeholder for partially applied arguments.
10044      *
10045      * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10046      * property of bound functions.
10047      *
10048      * @static
10049      * @memberOf _
10050      * @since 0.1.0
10051      * @category Function
10052      * @param {Function} func The function to bind.
10053      * @param {*} thisArg The `this` binding of `func`.
10054      * @param {...*} [partials] The arguments to be partially applied.
10055      * @returns {Function} Returns the new bound function.
10056      * @example
10057      *
10058      * function greet(greeting, punctuation) {
10059      *   return greeting + ' ' + this.user + punctuation;
10060      * }
10061      *
10062      * var object = { 'user': 'fred' };
10063      *
10064      * var bound = _.bind(greet, object, 'hi');
10065      * bound('!');
10066      * // => 'hi fred!'
10067      *
10068      * // Bound with placeholders.
10069      * var bound = _.bind(greet, object, _, '!');
10070      * bound('hi');
10071      * // => 'hi fred!'
10072      */
10073     var bind = baseRest(function(func, thisArg, partials) {
10074       var bitmask = BIND_FLAG;
10075       if (partials.length) {
10076         var holders = replaceHolders(partials, getHolder(bind));
10077         bitmask |= PARTIAL_FLAG;
10078       }
10079       return createWrap(func, bitmask, thisArg, partials, holders);
10080     });
10081
10082     /**
10083      * Creates a function that invokes the method at `object[key]` with `partials`
10084      * prepended to the arguments it receives.
10085      *
10086      * This method differs from `_.bind` by allowing bound functions to reference
10087      * methods that may be redefined or don't yet exist. See
10088      * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
10089      * for more details.
10090      *
10091      * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10092      * builds, may be used as a placeholder for partially applied arguments.
10093      *
10094      * @static
10095      * @memberOf _
10096      * @since 0.10.0
10097      * @category Function
10098      * @param {Object} object The object to invoke the method on.
10099      * @param {string} key The key of the method.
10100      * @param {...*} [partials] The arguments to be partially applied.
10101      * @returns {Function} Returns the new bound function.
10102      * @example
10103      *
10104      * var object = {
10105      *   'user': 'fred',
10106      *   'greet': function(greeting, punctuation) {
10107      *     return greeting + ' ' + this.user + punctuation;
10108      *   }
10109      * };
10110      *
10111      * var bound = _.bindKey(object, 'greet', 'hi');
10112      * bound('!');
10113      * // => 'hi fred!'
10114      *
10115      * object.greet = function(greeting, punctuation) {
10116      *   return greeting + 'ya ' + this.user + punctuation;
10117      * };
10118      *
10119      * bound('!');
10120      * // => 'hiya fred!'
10121      *
10122      * // Bound with placeholders.
10123      * var bound = _.bindKey(object, 'greet', _, '!');
10124      * bound('hi');
10125      * // => 'hiya fred!'
10126      */
10127     var bindKey = baseRest(function(object, key, partials) {
10128       var bitmask = BIND_FLAG | BIND_KEY_FLAG;
10129       if (partials.length) {
10130         var holders = replaceHolders(partials, getHolder(bindKey));
10131         bitmask |= PARTIAL_FLAG;
10132       }
10133       return createWrap(key, bitmask, object, partials, holders);
10134     });
10135
10136     /**
10137      * Creates a function that accepts arguments of `func` and either invokes
10138      * `func` returning its result, if at least `arity` number of arguments have
10139      * been provided, or returns a function that accepts the remaining `func`
10140      * arguments, and so on. The arity of `func` may be specified if `func.length`
10141      * is not sufficient.
10142      *
10143      * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10144      * may be used as a placeholder for provided arguments.
10145      *
10146      * **Note:** This method doesn't set the "length" property of curried functions.
10147      *
10148      * @static
10149      * @memberOf _
10150      * @since 2.0.0
10151      * @category Function
10152      * @param {Function} func The function to curry.
10153      * @param {number} [arity=func.length] The arity of `func`.
10154      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10155      * @returns {Function} Returns the new curried function.
10156      * @example
10157      *
10158      * var abc = function(a, b, c) {
10159      *   return [a, b, c];
10160      * };
10161      *
10162      * var curried = _.curry(abc);
10163      *
10164      * curried(1)(2)(3);
10165      * // => [1, 2, 3]
10166      *
10167      * curried(1, 2)(3);
10168      * // => [1, 2, 3]
10169      *
10170      * curried(1, 2, 3);
10171      * // => [1, 2, 3]
10172      *
10173      * // Curried with placeholders.
10174      * curried(1)(_, 3)(2);
10175      * // => [1, 2, 3]
10176      */
10177     function curry(func, arity, guard) {
10178       arity = guard ? undefined : arity;
10179       var result = createWrap(func, CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10180       result.placeholder = curry.placeholder;
10181       return result;
10182     }
10183
10184     /**
10185      * This method is like `_.curry` except that arguments are applied to `func`
10186      * in the manner of `_.partialRight` instead of `_.partial`.
10187      *
10188      * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10189      * builds, may be used as a placeholder for provided arguments.
10190      *
10191      * **Note:** This method doesn't set the "length" property of curried functions.
10192      *
10193      * @static
10194      * @memberOf _
10195      * @since 3.0.0
10196      * @category Function
10197      * @param {Function} func The function to curry.
10198      * @param {number} [arity=func.length] The arity of `func`.
10199      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10200      * @returns {Function} Returns the new curried function.
10201      * @example
10202      *
10203      * var abc = function(a, b, c) {
10204      *   return [a, b, c];
10205      * };
10206      *
10207      * var curried = _.curryRight(abc);
10208      *
10209      * curried(3)(2)(1);
10210      * // => [1, 2, 3]
10211      *
10212      * curried(2, 3)(1);
10213      * // => [1, 2, 3]
10214      *
10215      * curried(1, 2, 3);
10216      * // => [1, 2, 3]
10217      *
10218      * // Curried with placeholders.
10219      * curried(3)(1, _)(2);
10220      * // => [1, 2, 3]
10221      */
10222     function curryRight(func, arity, guard) {
10223       arity = guard ? undefined : arity;
10224       var result = createWrap(func, CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10225       result.placeholder = curryRight.placeholder;
10226       return result;
10227     }
10228
10229     /**
10230      * Creates a debounced function that delays invoking `func` until after `wait`
10231      * milliseconds have elapsed since the last time the debounced function was
10232      * invoked. The debounced function comes with a `cancel` method to cancel
10233      * delayed `func` invocations and a `flush` method to immediately invoke them.
10234      * Provide `options` to indicate whether `func` should be invoked on the
10235      * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
10236      * with the last arguments provided to the debounced function. Subsequent
10237      * calls to the debounced function return the result of the last `func`
10238      * invocation.
10239      *
10240      * **Note:** If `leading` and `trailing` options are `true`, `func` is
10241      * invoked on the trailing edge of the timeout only if the debounced function
10242      * is invoked more than once during the `wait` timeout.
10243      *
10244      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10245      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10246      *
10247      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10248      * for details over the differences between `_.debounce` and `_.throttle`.
10249      *
10250      * @static
10251      * @memberOf _
10252      * @since 0.1.0
10253      * @category Function
10254      * @param {Function} func The function to debounce.
10255      * @param {number} [wait=0] The number of milliseconds to delay.
10256      * @param {Object} [options={}] The options object.
10257      * @param {boolean} [options.leading=false]
10258      *  Specify invoking on the leading edge of the timeout.
10259      * @param {number} [options.maxWait]
10260      *  The maximum time `func` is allowed to be delayed before it's invoked.
10261      * @param {boolean} [options.trailing=true]
10262      *  Specify invoking on the trailing edge of the timeout.
10263      * @returns {Function} Returns the new debounced function.
10264      * @example
10265      *
10266      * // Avoid costly calculations while the window size is in flux.
10267      * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10268      *
10269      * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10270      * jQuery(element).on('click', _.debounce(sendMail, 300, {
10271      *   'leading': true,
10272      *   'trailing': false
10273      * }));
10274      *
10275      * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
10276      * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
10277      * var source = new EventSource('/stream');
10278      * jQuery(source).on('message', debounced);
10279      *
10280      * // Cancel the trailing debounced invocation.
10281      * jQuery(window).on('popstate', debounced.cancel);
10282      */
10283     function debounce(func, wait, options) {
10284       var lastArgs,
10285           lastThis,
10286           maxWait,
10287           result,
10288           timerId,
10289           lastCallTime,
10290           lastInvokeTime = 0,
10291           leading = false,
10292           maxing = false,
10293           trailing = true;
10294
10295       if (typeof func != 'function') {
10296         throw new TypeError(FUNC_ERROR_TEXT);
10297       }
10298       wait = toNumber(wait) || 0;
10299       if (isObject(options)) {
10300         leading = !!options.leading;
10301         maxing = 'maxWait' in options;
10302         maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
10303         trailing = 'trailing' in options ? !!options.trailing : trailing;
10304       }
10305
10306       function invokeFunc(time) {
10307         var args = lastArgs,
10308             thisArg = lastThis;
10309
10310         lastArgs = lastThis = undefined;
10311         lastInvokeTime = time;
10312         result = func.apply(thisArg, args);
10313         return result;
10314       }
10315
10316       function leadingEdge(time) {
10317         // Reset any `maxWait` timer.
10318         lastInvokeTime = time;
10319         // Start the timer for the trailing edge.
10320         timerId = setTimeout(timerExpired, wait);
10321         // Invoke the leading edge.
10322         return leading ? invokeFunc(time) : result;
10323       }
10324
10325       function remainingWait(time) {
10326         var timeSinceLastCall = time - lastCallTime,
10327             timeSinceLastInvoke = time - lastInvokeTime,
10328             result = wait - timeSinceLastCall;
10329
10330         return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
10331       }
10332
10333       function shouldInvoke(time) {
10334         var timeSinceLastCall = time - lastCallTime,
10335             timeSinceLastInvoke = time - lastInvokeTime;
10336
10337         // Either this is the first call, activity has stopped and we're at the
10338         // trailing edge, the system time has gone backwards and we're treating
10339         // it as the trailing edge, or we've hit the `maxWait` limit.
10340         return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
10341           (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
10342       }
10343
10344       function timerExpired() {
10345         var time = now();
10346         if (shouldInvoke(time)) {
10347           return trailingEdge(time);
10348         }
10349         // Restart the timer.
10350         timerId = setTimeout(timerExpired, remainingWait(time));
10351       }
10352
10353       function trailingEdge(time) {
10354         timerId = undefined;
10355
10356         // Only invoke if we have `lastArgs` which means `func` has been
10357         // debounced at least once.
10358         if (trailing && lastArgs) {
10359           return invokeFunc(time);
10360         }
10361         lastArgs = lastThis = undefined;
10362         return result;
10363       }
10364
10365       function cancel() {
10366         if (timerId !== undefined) {
10367           clearTimeout(timerId);
10368         }
10369         lastInvokeTime = 0;
10370         lastArgs = lastCallTime = lastThis = timerId = undefined;
10371       }
10372
10373       function flush() {
10374         return timerId === undefined ? result : trailingEdge(now());
10375       }
10376
10377       function debounced() {
10378         var time = now(),
10379             isInvoking = shouldInvoke(time);
10380
10381         lastArgs = arguments;
10382         lastThis = this;
10383         lastCallTime = time;
10384
10385         if (isInvoking) {
10386           if (timerId === undefined) {
10387             return leadingEdge(lastCallTime);
10388           }
10389           if (maxing) {
10390             // Handle invocations in a tight loop.
10391             timerId = setTimeout(timerExpired, wait);
10392             return invokeFunc(lastCallTime);
10393           }
10394         }
10395         if (timerId === undefined) {
10396           timerId = setTimeout(timerExpired, wait);
10397         }
10398         return result;
10399       }
10400       debounced.cancel = cancel;
10401       debounced.flush = flush;
10402       return debounced;
10403     }
10404
10405     /**
10406      * Defers invoking the `func` until the current call stack has cleared. Any
10407      * additional arguments are provided to `func` when it's invoked.
10408      *
10409      * @static
10410      * @memberOf _
10411      * @since 0.1.0
10412      * @category Function
10413      * @param {Function} func The function to defer.
10414      * @param {...*} [args] The arguments to invoke `func` with.
10415      * @returns {number} Returns the timer id.
10416      * @example
10417      *
10418      * _.defer(function(text) {
10419      *   console.log(text);
10420      * }, 'deferred');
10421      * // => Logs 'deferred' after one millisecond.
10422      */
10423     var defer = baseRest(function(func, args) {
10424       return baseDelay(func, 1, args);
10425     });
10426
10427     /**
10428      * Invokes `func` after `wait` milliseconds. Any additional arguments are
10429      * provided to `func` when it's invoked.
10430      *
10431      * @static
10432      * @memberOf _
10433      * @since 0.1.0
10434      * @category Function
10435      * @param {Function} func The function to delay.
10436      * @param {number} wait The number of milliseconds to delay invocation.
10437      * @param {...*} [args] The arguments to invoke `func` with.
10438      * @returns {number} Returns the timer id.
10439      * @example
10440      *
10441      * _.delay(function(text) {
10442      *   console.log(text);
10443      * }, 1000, 'later');
10444      * // => Logs 'later' after one second.
10445      */
10446     var delay = baseRest(function(func, wait, args) {
10447       return baseDelay(func, toNumber(wait) || 0, args);
10448     });
10449
10450     /**
10451      * Creates a function that invokes `func` with arguments reversed.
10452      *
10453      * @static
10454      * @memberOf _
10455      * @since 4.0.0
10456      * @category Function
10457      * @param {Function} func The function to flip arguments for.
10458      * @returns {Function} Returns the new flipped function.
10459      * @example
10460      *
10461      * var flipped = _.flip(function() {
10462      *   return _.toArray(arguments);
10463      * });
10464      *
10465      * flipped('a', 'b', 'c', 'd');
10466      * // => ['d', 'c', 'b', 'a']
10467      */
10468     function flip(func) {
10469       return createWrap(func, FLIP_FLAG);
10470     }
10471
10472     /**
10473      * Creates a function that memoizes the result of `func`. If `resolver` is
10474      * provided, it determines the cache key for storing the result based on the
10475      * arguments provided to the memoized function. By default, the first argument
10476      * provided to the memoized function is used as the map cache key. The `func`
10477      * is invoked with the `this` binding of the memoized function.
10478      *
10479      * **Note:** The cache is exposed as the `cache` property on the memoized
10480      * function. Its creation may be customized by replacing the `_.memoize.Cache`
10481      * constructor with one whose instances implement the
10482      * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
10483      * method interface of `clear`, `delete`, `get`, `has`, and `set`.
10484      *
10485      * @static
10486      * @memberOf _
10487      * @since 0.1.0
10488      * @category Function
10489      * @param {Function} func The function to have its output memoized.
10490      * @param {Function} [resolver] The function to resolve the cache key.
10491      * @returns {Function} Returns the new memoized function.
10492      * @example
10493      *
10494      * var object = { 'a': 1, 'b': 2 };
10495      * var other = { 'c': 3, 'd': 4 };
10496      *
10497      * var values = _.memoize(_.values);
10498      * values(object);
10499      * // => [1, 2]
10500      *
10501      * values(other);
10502      * // => [3, 4]
10503      *
10504      * object.a = 2;
10505      * values(object);
10506      * // => [1, 2]
10507      *
10508      * // Modify the result cache.
10509      * values.cache.set(object, ['a', 'b']);
10510      * values(object);
10511      * // => ['a', 'b']
10512      *
10513      * // Replace `_.memoize.Cache`.
10514      * _.memoize.Cache = WeakMap;
10515      */
10516     function memoize(func, resolver) {
10517       if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10518         throw new TypeError(FUNC_ERROR_TEXT);
10519       }
10520       var memoized = function() {
10521         var args = arguments,
10522             key = resolver ? resolver.apply(this, args) : args[0],
10523             cache = memoized.cache;
10524
10525         if (cache.has(key)) {
10526           return cache.get(key);
10527         }
10528         var result = func.apply(this, args);
10529         memoized.cache = cache.set(key, result) || cache;
10530         return result;
10531       };
10532       memoized.cache = new (memoize.Cache || MapCache);
10533       return memoized;
10534     }
10535
10536     // Expose `MapCache`.
10537     memoize.Cache = MapCache;
10538
10539     /**
10540      * Creates a function that negates the result of the predicate `func`. The
10541      * `func` predicate is invoked with the `this` binding and arguments of the
10542      * created function.
10543      *
10544      * @static
10545      * @memberOf _
10546      * @since 3.0.0
10547      * @category Function
10548      * @param {Function} predicate The predicate to negate.
10549      * @returns {Function} Returns the new negated function.
10550      * @example
10551      *
10552      * function isEven(n) {
10553      *   return n % 2 == 0;
10554      * }
10555      *
10556      * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10557      * // => [1, 3, 5]
10558      */
10559     function negate(predicate) {
10560       if (typeof predicate != 'function') {
10561         throw new TypeError(FUNC_ERROR_TEXT);
10562       }
10563       return function() {
10564         var args = arguments;
10565         switch (args.length) {
10566           case 0: return !predicate.call(this);
10567           case 1: return !predicate.call(this, args[0]);
10568           case 2: return !predicate.call(this, args[0], args[1]);
10569           case 3: return !predicate.call(this, args[0], args[1], args[2]);
10570         }
10571         return !predicate.apply(this, args);
10572       };
10573     }
10574
10575     /**
10576      * Creates a function that is restricted to invoking `func` once. Repeat calls
10577      * to the function return the value of the first invocation. The `func` is
10578      * invoked with the `this` binding and arguments of the created function.
10579      *
10580      * @static
10581      * @memberOf _
10582      * @since 0.1.0
10583      * @category Function
10584      * @param {Function} func The function to restrict.
10585      * @returns {Function} Returns the new restricted function.
10586      * @example
10587      *
10588      * var initialize = _.once(createApplication);
10589      * initialize();
10590      * initialize();
10591      * // => `createApplication` is invoked once
10592      */
10593     function once(func) {
10594       return before(2, func);
10595     }
10596
10597     /**
10598      * Creates a function that invokes `func` with its arguments transformed.
10599      *
10600      * @static
10601      * @since 4.0.0
10602      * @memberOf _
10603      * @category Function
10604      * @param {Function} func The function to wrap.
10605      * @param {...(Function|Function[])} [transforms=[_.identity]]
10606      *  The argument transforms.
10607      * @returns {Function} Returns the new function.
10608      * @example
10609      *
10610      * function doubled(n) {
10611      *   return n * 2;
10612      * }
10613      *
10614      * function square(n) {
10615      *   return n * n;
10616      * }
10617      *
10618      * var func = _.overArgs(function(x, y) {
10619      *   return [x, y];
10620      * }, [square, doubled]);
10621      *
10622      * func(9, 3);
10623      * // => [81, 6]
10624      *
10625      * func(10, 5);
10626      * // => [100, 10]
10627      */
10628     var overArgs = castRest(function(func, transforms) {
10629       transforms = (transforms.length == 1 && isArray(transforms[0]))
10630         ? arrayMap(transforms[0], baseUnary(getIteratee()))
10631         : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
10632
10633       var funcsLength = transforms.length;
10634       return baseRest(function(args) {
10635         var index = -1,
10636             length = nativeMin(args.length, funcsLength);
10637
10638         while (++index < length) {
10639           args[index] = transforms[index].call(this, args[index]);
10640         }
10641         return apply(func, this, args);
10642       });
10643     });
10644
10645     /**
10646      * Creates a function that invokes `func` with `partials` prepended to the
10647      * arguments it receives. This method is like `_.bind` except it does **not**
10648      * alter the `this` binding.
10649      *
10650      * The `_.partial.placeholder` value, which defaults to `_` in monolithic
10651      * builds, may be used as a placeholder for partially applied arguments.
10652      *
10653      * **Note:** This method doesn't set the "length" property of partially
10654      * applied functions.
10655      *
10656      * @static
10657      * @memberOf _
10658      * @since 0.2.0
10659      * @category Function
10660      * @param {Function} func The function to partially apply arguments to.
10661      * @param {...*} [partials] The arguments to be partially applied.
10662      * @returns {Function} Returns the new partially applied function.
10663      * @example
10664      *
10665      * function greet(greeting, name) {
10666      *   return greeting + ' ' + name;
10667      * }
10668      *
10669      * var sayHelloTo = _.partial(greet, 'hello');
10670      * sayHelloTo('fred');
10671      * // => 'hello fred'
10672      *
10673      * // Partially applied with placeholders.
10674      * var greetFred = _.partial(greet, _, 'fred');
10675      * greetFred('hi');
10676      * // => 'hi fred'
10677      */
10678     var partial = baseRest(function(func, partials) {
10679       var holders = replaceHolders(partials, getHolder(partial));
10680       return createWrap(func, PARTIAL_FLAG, undefined, partials, holders);
10681     });
10682
10683     /**
10684      * This method is like `_.partial` except that partially applied arguments
10685      * are appended to the arguments it receives.
10686      *
10687      * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
10688      * builds, may be used as a placeholder for partially applied arguments.
10689      *
10690      * **Note:** This method doesn't set the "length" property of partially
10691      * applied functions.
10692      *
10693      * @static
10694      * @memberOf _
10695      * @since 1.0.0
10696      * @category Function
10697      * @param {Function} func The function to partially apply arguments to.
10698      * @param {...*} [partials] The arguments to be partially applied.
10699      * @returns {Function} Returns the new partially applied function.
10700      * @example
10701      *
10702      * function greet(greeting, name) {
10703      *   return greeting + ' ' + name;
10704      * }
10705      *
10706      * var greetFred = _.partialRight(greet, 'fred');
10707      * greetFred('hi');
10708      * // => 'hi fred'
10709      *
10710      * // Partially applied with placeholders.
10711      * var sayHelloTo = _.partialRight(greet, 'hello', _);
10712      * sayHelloTo('fred');
10713      * // => 'hello fred'
10714      */
10715     var partialRight = baseRest(function(func, partials) {
10716       var holders = replaceHolders(partials, getHolder(partialRight));
10717       return createWrap(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders);
10718     });
10719
10720     /**
10721      * Creates a function that invokes `func` with arguments arranged according
10722      * to the specified `indexes` where the argument value at the first index is
10723      * provided as the first argument, the argument value at the second index is
10724      * provided as the second argument, and so on.
10725      *
10726      * @static
10727      * @memberOf _
10728      * @since 3.0.0
10729      * @category Function
10730      * @param {Function} func The function to rearrange arguments for.
10731      * @param {...(number|number[])} indexes The arranged argument indexes.
10732      * @returns {Function} Returns the new function.
10733      * @example
10734      *
10735      * var rearged = _.rearg(function(a, b, c) {
10736      *   return [a, b, c];
10737      * }, [2, 0, 1]);
10738      *
10739      * rearged('b', 'c', 'a')
10740      * // => ['a', 'b', 'c']
10741      */
10742     var rearg = flatRest(function(func, indexes) {
10743       return createWrap(func, REARG_FLAG, undefined, undefined, undefined, indexes);
10744     });
10745
10746     /**
10747      * Creates a function that invokes `func` with the `this` binding of the
10748      * created function and arguments from `start` and beyond provided as
10749      * an array.
10750      *
10751      * **Note:** This method is based on the
10752      * [rest parameter](https://mdn.io/rest_parameters).
10753      *
10754      * @static
10755      * @memberOf _
10756      * @since 4.0.0
10757      * @category Function
10758      * @param {Function} func The function to apply a rest parameter to.
10759      * @param {number} [start=func.length-1] The start position of the rest parameter.
10760      * @returns {Function} Returns the new function.
10761      * @example
10762      *
10763      * var say = _.rest(function(what, names) {
10764      *   return what + ' ' + _.initial(names).join(', ') +
10765      *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
10766      * });
10767      *
10768      * say('hello', 'fred', 'barney', 'pebbles');
10769      * // => 'hello fred, barney, & pebbles'
10770      */
10771     function rest(func, start) {
10772       if (typeof func != 'function') {
10773         throw new TypeError(FUNC_ERROR_TEXT);
10774       }
10775       start = start === undefined ? start : toInteger(start);
10776       return baseRest(func, start);
10777     }
10778
10779     /**
10780      * Creates a function that invokes `func` with the `this` binding of the
10781      * create function and an array of arguments much like
10782      * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
10783      *
10784      * **Note:** This method is based on the
10785      * [spread operator](https://mdn.io/spread_operator).
10786      *
10787      * @static
10788      * @memberOf _
10789      * @since 3.2.0
10790      * @category Function
10791      * @param {Function} func The function to spread arguments over.
10792      * @param {number} [start=0] The start position of the spread.
10793      * @returns {Function} Returns the new function.
10794      * @example
10795      *
10796      * var say = _.spread(function(who, what) {
10797      *   return who + ' says ' + what;
10798      * });
10799      *
10800      * say(['fred', 'hello']);
10801      * // => 'fred says hello'
10802      *
10803      * var numbers = Promise.all([
10804      *   Promise.resolve(40),
10805      *   Promise.resolve(36)
10806      * ]);
10807      *
10808      * numbers.then(_.spread(function(x, y) {
10809      *   return x + y;
10810      * }));
10811      * // => a Promise of 76
10812      */
10813     function spread(func, start) {
10814       if (typeof func != 'function') {
10815         throw new TypeError(FUNC_ERROR_TEXT);
10816       }
10817       start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
10818       return baseRest(function(args) {
10819         var array = args[start],
10820             otherArgs = castSlice(args, 0, start);
10821
10822         if (array) {
10823           arrayPush(otherArgs, array);
10824         }
10825         return apply(func, this, otherArgs);
10826       });
10827     }
10828
10829     /**
10830      * Creates a throttled function that only invokes `func` at most once per
10831      * every `wait` milliseconds. The throttled function comes with a `cancel`
10832      * method to cancel delayed `func` invocations and a `flush` method to
10833      * immediately invoke them. Provide `options` to indicate whether `func`
10834      * should be invoked on the leading and/or trailing edge of the `wait`
10835      * timeout. The `func` is invoked with the last arguments provided to the
10836      * throttled function. Subsequent calls to the throttled function return the
10837      * result of the last `func` invocation.
10838      *
10839      * **Note:** If `leading` and `trailing` options are `true`, `func` is
10840      * invoked on the trailing edge of the timeout only if the throttled function
10841      * is invoked more than once during the `wait` timeout.
10842      *
10843      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10844      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10845      *
10846      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10847      * for details over the differences between `_.throttle` and `_.debounce`.
10848      *
10849      * @static
10850      * @memberOf _
10851      * @since 0.1.0
10852      * @category Function
10853      * @param {Function} func The function to throttle.
10854      * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
10855      * @param {Object} [options={}] The options object.
10856      * @param {boolean} [options.leading=true]
10857      *  Specify invoking on the leading edge of the timeout.
10858      * @param {boolean} [options.trailing=true]
10859      *  Specify invoking on the trailing edge of the timeout.
10860      * @returns {Function} Returns the new throttled function.
10861      * @example
10862      *
10863      * // Avoid excessively updating the position while scrolling.
10864      * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
10865      *
10866      * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
10867      * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
10868      * jQuery(element).on('click', throttled);
10869      *
10870      * // Cancel the trailing throttled invocation.
10871      * jQuery(window).on('popstate', throttled.cancel);
10872      */
10873     function throttle(func, wait, options) {
10874       var leading = true,
10875           trailing = true;
10876
10877       if (typeof func != 'function') {
10878         throw new TypeError(FUNC_ERROR_TEXT);
10879       }
10880       if (isObject(options)) {
10881         leading = 'leading' in options ? !!options.leading : leading;
10882         trailing = 'trailing' in options ? !!options.trailing : trailing;
10883       }
10884       return debounce(func, wait, {
10885         'leading': leading,
10886         'maxWait': wait,
10887         'trailing': trailing
10888       });
10889     }
10890
10891     /**
10892      * Creates a function that accepts up to one argument, ignoring any
10893      * additional arguments.
10894      *
10895      * @static
10896      * @memberOf _
10897      * @since 4.0.0
10898      * @category Function
10899      * @param {Function} func The function to cap arguments for.
10900      * @returns {Function} Returns the new capped function.
10901      * @example
10902      *
10903      * _.map(['6', '8', '10'], _.unary(parseInt));
10904      * // => [6, 8, 10]
10905      */
10906     function unary(func) {
10907       return ary(func, 1);
10908     }
10909
10910     /**
10911      * Creates a function that provides `value` to `wrapper` as its first
10912      * argument. Any additional arguments provided to the function are appended
10913      * to those provided to the `wrapper`. The wrapper is invoked with the `this`
10914      * binding of the created function.
10915      *
10916      * @static
10917      * @memberOf _
10918      * @since 0.1.0
10919      * @category Function
10920      * @param {*} value The value to wrap.
10921      * @param {Function} [wrapper=identity] The wrapper function.
10922      * @returns {Function} Returns the new function.
10923      * @example
10924      *
10925      * var p = _.wrap(_.escape, function(func, text) {
10926      *   return '<p>' + func(text) + '</p>';
10927      * });
10928      *
10929      * p('fred, barney, & pebbles');
10930      * // => '<p>fred, barney, &amp; pebbles</p>'
10931      */
10932     function wrap(value, wrapper) {
10933       return partial(castFunction(wrapper), value);
10934     }
10935
10936     /*------------------------------------------------------------------------*/
10937
10938     /**
10939      * Casts `value` as an array if it's not one.
10940      *
10941      * @static
10942      * @memberOf _
10943      * @since 4.4.0
10944      * @category Lang
10945      * @param {*} value The value to inspect.
10946      * @returns {Array} Returns the cast array.
10947      * @example
10948      *
10949      * _.castArray(1);
10950      * // => [1]
10951      *
10952      * _.castArray({ 'a': 1 });
10953      * // => [{ 'a': 1 }]
10954      *
10955      * _.castArray('abc');
10956      * // => ['abc']
10957      *
10958      * _.castArray(null);
10959      * // => [null]
10960      *
10961      * _.castArray(undefined);
10962      * // => [undefined]
10963      *
10964      * _.castArray();
10965      * // => []
10966      *
10967      * var array = [1, 2, 3];
10968      * console.log(_.castArray(array) === array);
10969      * // => true
10970      */
10971     function castArray() {
10972       if (!arguments.length) {
10973         return [];
10974       }
10975       var value = arguments[0];
10976       return isArray(value) ? value : [value];
10977     }
10978
10979     /**
10980      * Creates a shallow clone of `value`.
10981      *
10982      * **Note:** This method is loosely based on the
10983      * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
10984      * and supports cloning arrays, array buffers, booleans, date objects, maps,
10985      * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
10986      * arrays. The own enumerable properties of `arguments` objects are cloned
10987      * as plain objects. An empty object is returned for uncloneable values such
10988      * as error objects, functions, DOM nodes, and WeakMaps.
10989      *
10990      * @static
10991      * @memberOf _
10992      * @since 0.1.0
10993      * @category Lang
10994      * @param {*} value The value to clone.
10995      * @returns {*} Returns the cloned value.
10996      * @see _.cloneDeep
10997      * @example
10998      *
10999      * var objects = [{ 'a': 1 }, { 'b': 2 }];
11000      *
11001      * var shallow = _.clone(objects);
11002      * console.log(shallow[0] === objects[0]);
11003      * // => true
11004      */
11005     function clone(value) {
11006       return baseClone(value, false, true);
11007     }
11008
11009     /**
11010      * This method is like `_.clone` except that it accepts `customizer` which
11011      * is invoked to produce the cloned value. If `customizer` returns `undefined`,
11012      * cloning is handled by the method instead. The `customizer` is invoked with
11013      * up to four arguments; (value [, index|key, object, stack]).
11014      *
11015      * @static
11016      * @memberOf _
11017      * @since 4.0.0
11018      * @category Lang
11019      * @param {*} value The value to clone.
11020      * @param {Function} [customizer] The function to customize cloning.
11021      * @returns {*} Returns the cloned value.
11022      * @see _.cloneDeepWith
11023      * @example
11024      *
11025      * function customizer(value) {
11026      *   if (_.isElement(value)) {
11027      *     return value.cloneNode(false);
11028      *   }
11029      * }
11030      *
11031      * var el = _.cloneWith(document.body, customizer);
11032      *
11033      * console.log(el === document.body);
11034      * // => false
11035      * console.log(el.nodeName);
11036      * // => 'BODY'
11037      * console.log(el.childNodes.length);
11038      * // => 0
11039      */
11040     function cloneWith(value, customizer) {
11041       customizer = typeof customizer == 'function' ? customizer : undefined;
11042       return baseClone(value, false, true, customizer);
11043     }
11044
11045     /**
11046      * This method is like `_.clone` except that it recursively clones `value`.
11047      *
11048      * @static
11049      * @memberOf _
11050      * @since 1.0.0
11051      * @category Lang
11052      * @param {*} value The value to recursively clone.
11053      * @returns {*} Returns the deep cloned value.
11054      * @see _.clone
11055      * @example
11056      *
11057      * var objects = [{ 'a': 1 }, { 'b': 2 }];
11058      *
11059      * var deep = _.cloneDeep(objects);
11060      * console.log(deep[0] === objects[0]);
11061      * // => false
11062      */
11063     function cloneDeep(value) {
11064       return baseClone(value, true, true);
11065     }
11066
11067     /**
11068      * This method is like `_.cloneWith` except that it recursively clones `value`.
11069      *
11070      * @static
11071      * @memberOf _
11072      * @since 4.0.0
11073      * @category Lang
11074      * @param {*} value The value to recursively clone.
11075      * @param {Function} [customizer] The function to customize cloning.
11076      * @returns {*} Returns the deep cloned value.
11077      * @see _.cloneWith
11078      * @example
11079      *
11080      * function customizer(value) {
11081      *   if (_.isElement(value)) {
11082      *     return value.cloneNode(true);
11083      *   }
11084      * }
11085      *
11086      * var el = _.cloneDeepWith(document.body, customizer);
11087      *
11088      * console.log(el === document.body);
11089      * // => false
11090      * console.log(el.nodeName);
11091      * // => 'BODY'
11092      * console.log(el.childNodes.length);
11093      * // => 20
11094      */
11095     function cloneDeepWith(value, customizer) {
11096       customizer = typeof customizer == 'function' ? customizer : undefined;
11097       return baseClone(value, true, true, customizer);
11098     }
11099
11100     /**
11101      * Checks if `object` conforms to `source` by invoking the predicate
11102      * properties of `source` with the corresponding property values of `object`.
11103      *
11104      * **Note:** This method is equivalent to `_.conforms` when `source` is
11105      * partially applied.
11106      *
11107      * @static
11108      * @memberOf _
11109      * @since 4.14.0
11110      * @category Lang
11111      * @param {Object} object The object to inspect.
11112      * @param {Object} source The object of property predicates to conform to.
11113      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
11114      * @example
11115      *
11116      * var object = { 'a': 1, 'b': 2 };
11117      *
11118      * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11119      * // => true
11120      *
11121      * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11122      * // => false
11123      */
11124     function conformsTo(object, source) {
11125       return source == null || baseConformsTo(object, source, keys(source));
11126     }
11127
11128     /**
11129      * Performs a
11130      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11131      * comparison between two values to determine if they are equivalent.
11132      *
11133      * @static
11134      * @memberOf _
11135      * @since 4.0.0
11136      * @category Lang
11137      * @param {*} value The value to compare.
11138      * @param {*} other The other value to compare.
11139      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11140      * @example
11141      *
11142      * var object = { 'a': 1 };
11143      * var other = { 'a': 1 };
11144      *
11145      * _.eq(object, object);
11146      * // => true
11147      *
11148      * _.eq(object, other);
11149      * // => false
11150      *
11151      * _.eq('a', 'a');
11152      * // => true
11153      *
11154      * _.eq('a', Object('a'));
11155      * // => false
11156      *
11157      * _.eq(NaN, NaN);
11158      * // => true
11159      */
11160     function eq(value, other) {
11161       return value === other || (value !== value && other !== other);
11162     }
11163
11164     /**
11165      * Checks if `value` is greater than `other`.
11166      *
11167      * @static
11168      * @memberOf _
11169      * @since 3.9.0
11170      * @category Lang
11171      * @param {*} value The value to compare.
11172      * @param {*} other The other value to compare.
11173      * @returns {boolean} Returns `true` if `value` is greater than `other`,
11174      *  else `false`.
11175      * @see _.lt
11176      * @example
11177      *
11178      * _.gt(3, 1);
11179      * // => true
11180      *
11181      * _.gt(3, 3);
11182      * // => false
11183      *
11184      * _.gt(1, 3);
11185      * // => false
11186      */
11187     var gt = createRelationalOperation(baseGt);
11188
11189     /**
11190      * Checks if `value` is greater than or equal to `other`.
11191      *
11192      * @static
11193      * @memberOf _
11194      * @since 3.9.0
11195      * @category Lang
11196      * @param {*} value The value to compare.
11197      * @param {*} other The other value to compare.
11198      * @returns {boolean} Returns `true` if `value` is greater than or equal to
11199      *  `other`, else `false`.
11200      * @see _.lte
11201      * @example
11202      *
11203      * _.gte(3, 1);
11204      * // => true
11205      *
11206      * _.gte(3, 3);
11207      * // => true
11208      *
11209      * _.gte(1, 3);
11210      * // => false
11211      */
11212     var gte = createRelationalOperation(function(value, other) {
11213       return value >= other;
11214     });
11215
11216     /**
11217      * Checks if `value` is likely an `arguments` object.
11218      *
11219      * @static
11220      * @memberOf _
11221      * @since 0.1.0
11222      * @category Lang
11223      * @param {*} value The value to check.
11224      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11225      *  else `false`.
11226      * @example
11227      *
11228      * _.isArguments(function() { return arguments; }());
11229      * // => true
11230      *
11231      * _.isArguments([1, 2, 3]);
11232      * // => false
11233      */
11234     var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11235       return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11236         !propertyIsEnumerable.call(value, 'callee');
11237     };
11238
11239     /**
11240      * Checks if `value` is classified as an `Array` object.
11241      *
11242      * @static
11243      * @memberOf _
11244      * @since 0.1.0
11245      * @category Lang
11246      * @param {*} value The value to check.
11247      * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11248      * @example
11249      *
11250      * _.isArray([1, 2, 3]);
11251      * // => true
11252      *
11253      * _.isArray(document.body.children);
11254      * // => false
11255      *
11256      * _.isArray('abc');
11257      * // => false
11258      *
11259      * _.isArray(_.noop);
11260      * // => false
11261      */
11262     var isArray = Array.isArray;
11263
11264     /**
11265      * Checks if `value` is classified as an `ArrayBuffer` object.
11266      *
11267      * @static
11268      * @memberOf _
11269      * @since 4.3.0
11270      * @category Lang
11271      * @param {*} value The value to check.
11272      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11273      * @example
11274      *
11275      * _.isArrayBuffer(new ArrayBuffer(2));
11276      * // => true
11277      *
11278      * _.isArrayBuffer(new Array(2));
11279      * // => false
11280      */
11281     var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
11282
11283     /**
11284      * Checks if `value` is array-like. A value is considered array-like if it's
11285      * not a function and has a `value.length` that's an integer greater than or
11286      * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
11287      *
11288      * @static
11289      * @memberOf _
11290      * @since 4.0.0
11291      * @category Lang
11292      * @param {*} value The value to check.
11293      * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11294      * @example
11295      *
11296      * _.isArrayLike([1, 2, 3]);
11297      * // => true
11298      *
11299      * _.isArrayLike(document.body.children);
11300      * // => true
11301      *
11302      * _.isArrayLike('abc');
11303      * // => true
11304      *
11305      * _.isArrayLike(_.noop);
11306      * // => false
11307      */
11308     function isArrayLike(value) {
11309       return value != null && isLength(value.length) && !isFunction(value);
11310     }
11311
11312     /**
11313      * This method is like `_.isArrayLike` except that it also checks if `value`
11314      * is an object.
11315      *
11316      * @static
11317      * @memberOf _
11318      * @since 4.0.0
11319      * @category Lang
11320      * @param {*} value The value to check.
11321      * @returns {boolean} Returns `true` if `value` is an array-like object,
11322      *  else `false`.
11323      * @example
11324      *
11325      * _.isArrayLikeObject([1, 2, 3]);
11326      * // => true
11327      *
11328      * _.isArrayLikeObject(document.body.children);
11329      * // => true
11330      *
11331      * _.isArrayLikeObject('abc');
11332      * // => false
11333      *
11334      * _.isArrayLikeObject(_.noop);
11335      * // => false
11336      */
11337     function isArrayLikeObject(value) {
11338       return isObjectLike(value) && isArrayLike(value);
11339     }
11340
11341     /**
11342      * Checks if `value` is classified as a boolean primitive or object.
11343      *
11344      * @static
11345      * @memberOf _
11346      * @since 0.1.0
11347      * @category Lang
11348      * @param {*} value The value to check.
11349      * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11350      * @example
11351      *
11352      * _.isBoolean(false);
11353      * // => true
11354      *
11355      * _.isBoolean(null);
11356      * // => false
11357      */
11358     function isBoolean(value) {
11359       return value === true || value === false ||
11360         (isObjectLike(value) && baseGetTag(value) == boolTag);
11361     }
11362
11363     /**
11364      * Checks if `value` is a buffer.
11365      *
11366      * @static
11367      * @memberOf _
11368      * @since 4.3.0
11369      * @category Lang
11370      * @param {*} value The value to check.
11371      * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11372      * @example
11373      *
11374      * _.isBuffer(new Buffer(2));
11375      * // => true
11376      *
11377      * _.isBuffer(new Uint8Array(2));
11378      * // => false
11379      */
11380     var isBuffer = nativeIsBuffer || stubFalse;
11381
11382     /**
11383      * Checks if `value` is classified as a `Date` object.
11384      *
11385      * @static
11386      * @memberOf _
11387      * @since 0.1.0
11388      * @category Lang
11389      * @param {*} value The value to check.
11390      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11391      * @example
11392      *
11393      * _.isDate(new Date);
11394      * // => true
11395      *
11396      * _.isDate('Mon April 23 2012');
11397      * // => false
11398      */
11399     var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11400
11401     /**
11402      * Checks if `value` is likely a DOM element.
11403      *
11404      * @static
11405      * @memberOf _
11406      * @since 0.1.0
11407      * @category Lang
11408      * @param {*} value The value to check.
11409      * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11410      * @example
11411      *
11412      * _.isElement(document.body);
11413      * // => true
11414      *
11415      * _.isElement('<body>');
11416      * // => false
11417      */
11418     function isElement(value) {
11419       return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11420     }
11421
11422     /**
11423      * Checks if `value` is an empty object, collection, map, or set.
11424      *
11425      * Objects are considered empty if they have no own enumerable string keyed
11426      * properties.
11427      *
11428      * Array-like values such as `arguments` objects, arrays, buffers, strings, or
11429      * jQuery-like collections are considered empty if they have a `length` of `0`.
11430      * Similarly, maps and sets are considered empty if they have a `size` of `0`.
11431      *
11432      * @static
11433      * @memberOf _
11434      * @since 0.1.0
11435      * @category Lang
11436      * @param {*} value The value to check.
11437      * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11438      * @example
11439      *
11440      * _.isEmpty(null);
11441      * // => true
11442      *
11443      * _.isEmpty(true);
11444      * // => true
11445      *
11446      * _.isEmpty(1);
11447      * // => true
11448      *
11449      * _.isEmpty([1, 2, 3]);
11450      * // => false
11451      *
11452      * _.isEmpty({ 'a': 1 });
11453      * // => false
11454      */
11455     function isEmpty(value) {
11456       if (value == null) {
11457         return true;
11458       }
11459       if (isArrayLike(value) &&
11460           (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
11461             isBuffer(value) || isTypedArray(value) || isArguments(value))) {
11462         return !value.length;
11463       }
11464       var tag = getTag(value);
11465       if (tag == mapTag || tag == setTag) {
11466         return !value.size;
11467       }
11468       if (isPrototype(value)) {
11469         return !baseKeys(value).length;
11470       }
11471       for (var key in value) {
11472         if (hasOwnProperty.call(value, key)) {
11473           return false;
11474         }
11475       }
11476       return true;
11477     }
11478
11479     /**
11480      * Performs a deep comparison between two values to determine if they are
11481      * equivalent.
11482      *
11483      * **Note:** This method supports comparing arrays, array buffers, booleans,
11484      * date objects, error objects, maps, numbers, `Object` objects, regexes,
11485      * sets, strings, symbols, and typed arrays. `Object` objects are compared
11486      * by their own, not inherited, enumerable properties. Functions and DOM
11487      * nodes are **not** supported.
11488      *
11489      * @static
11490      * @memberOf _
11491      * @since 0.1.0
11492      * @category Lang
11493      * @param {*} value The value to compare.
11494      * @param {*} other The other value to compare.
11495      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11496      * @example
11497      *
11498      * var object = { 'a': 1 };
11499      * var other = { 'a': 1 };
11500      *
11501      * _.isEqual(object, other);
11502      * // => true
11503      *
11504      * object === other;
11505      * // => false
11506      */
11507     function isEqual(value, other) {
11508       return baseIsEqual(value, other);
11509     }
11510
11511     /**
11512      * This method is like `_.isEqual` except that it accepts `customizer` which
11513      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11514      * are handled by the method instead. The `customizer` is invoked with up to
11515      * six arguments: (objValue, othValue [, index|key, object, other, stack]).
11516      *
11517      * @static
11518      * @memberOf _
11519      * @since 4.0.0
11520      * @category Lang
11521      * @param {*} value The value to compare.
11522      * @param {*} other The other value to compare.
11523      * @param {Function} [customizer] The function to customize comparisons.
11524      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11525      * @example
11526      *
11527      * function isGreeting(value) {
11528      *   return /^h(?:i|ello)$/.test(value);
11529      * }
11530      *
11531      * function customizer(objValue, othValue) {
11532      *   if (isGreeting(objValue) && isGreeting(othValue)) {
11533      *     return true;
11534      *   }
11535      * }
11536      *
11537      * var array = ['hello', 'goodbye'];
11538      * var other = ['hi', 'goodbye'];
11539      *
11540      * _.isEqualWith(array, other, customizer);
11541      * // => true
11542      */
11543     function isEqualWith(value, other, customizer) {
11544       customizer = typeof customizer == 'function' ? customizer : undefined;
11545       var result = customizer ? customizer(value, other) : undefined;
11546       return result === undefined ? baseIsEqual(value, other, customizer) : !!result;
11547     }
11548
11549     /**
11550      * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11551      * `SyntaxError`, `TypeError`, or `URIError` object.
11552      *
11553      * @static
11554      * @memberOf _
11555      * @since 3.0.0
11556      * @category Lang
11557      * @param {*} value The value to check.
11558      * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11559      * @example
11560      *
11561      * _.isError(new Error);
11562      * // => true
11563      *
11564      * _.isError(Error);
11565      * // => false
11566      */
11567     function isError(value) {
11568       if (!isObjectLike(value)) {
11569         return false;
11570       }
11571       var tag = baseGetTag(value);
11572       return tag == errorTag || tag == domExcTag ||
11573         (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11574     }
11575
11576     /**
11577      * Checks if `value` is a finite primitive number.
11578      *
11579      * **Note:** This method is based on
11580      * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11581      *
11582      * @static
11583      * @memberOf _
11584      * @since 0.1.0
11585      * @category Lang
11586      * @param {*} value The value to check.
11587      * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11588      * @example
11589      *
11590      * _.isFinite(3);
11591      * // => true
11592      *
11593      * _.isFinite(Number.MIN_VALUE);
11594      * // => true
11595      *
11596      * _.isFinite(Infinity);
11597      * // => false
11598      *
11599      * _.isFinite('3');
11600      * // => false
11601      */
11602     function isFinite(value) {
11603       return typeof value == 'number' && nativeIsFinite(value);
11604     }
11605
11606     /**
11607      * Checks if `value` is classified as a `Function` object.
11608      *
11609      * @static
11610      * @memberOf _
11611      * @since 0.1.0
11612      * @category Lang
11613      * @param {*} value The value to check.
11614      * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11615      * @example
11616      *
11617      * _.isFunction(_);
11618      * // => true
11619      *
11620      * _.isFunction(/abc/);
11621      * // => false
11622      */
11623     function isFunction(value) {
11624       if (!isObject(value)) {
11625         return false;
11626       }
11627       // The use of `Object#toString` avoids issues with the `typeof` operator
11628       // in Safari 9 which returns 'object' for typed arrays and other constructors.
11629       var tag = baseGetTag(value);
11630       return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11631     }
11632
11633     /**
11634      * Checks if `value` is an integer.
11635      *
11636      * **Note:** This method is based on
11637      * [`Number.isInteger`](https://mdn.io/Number/isInteger).
11638      *
11639      * @static
11640      * @memberOf _
11641      * @since 4.0.0
11642      * @category Lang
11643      * @param {*} value The value to check.
11644      * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
11645      * @example
11646      *
11647      * _.isInteger(3);
11648      * // => true
11649      *
11650      * _.isInteger(Number.MIN_VALUE);
11651      * // => false
11652      *
11653      * _.isInteger(Infinity);
11654      * // => false
11655      *
11656      * _.isInteger('3');
11657      * // => false
11658      */
11659     function isInteger(value) {
11660       return typeof value == 'number' && value == toInteger(value);
11661     }
11662
11663     /**
11664      * Checks if `value` is a valid array-like length.
11665      *
11666      * **Note:** This method is loosely based on
11667      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
11668      *
11669      * @static
11670      * @memberOf _
11671      * @since 4.0.0
11672      * @category Lang
11673      * @param {*} value The value to check.
11674      * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11675      * @example
11676      *
11677      * _.isLength(3);
11678      * // => true
11679      *
11680      * _.isLength(Number.MIN_VALUE);
11681      * // => false
11682      *
11683      * _.isLength(Infinity);
11684      * // => false
11685      *
11686      * _.isLength('3');
11687      * // => false
11688      */
11689     function isLength(value) {
11690       return typeof value == 'number' &&
11691         value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
11692     }
11693
11694     /**
11695      * Checks if `value` is the
11696      * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11697      * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11698      *
11699      * @static
11700      * @memberOf _
11701      * @since 0.1.0
11702      * @category Lang
11703      * @param {*} value The value to check.
11704      * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11705      * @example
11706      *
11707      * _.isObject({});
11708      * // => true
11709      *
11710      * _.isObject([1, 2, 3]);
11711      * // => true
11712      *
11713      * _.isObject(_.noop);
11714      * // => true
11715      *
11716      * _.isObject(null);
11717      * // => false
11718      */
11719     function isObject(value) {
11720       var type = typeof value;
11721       return value != null && (type == 'object' || type == 'function');
11722     }
11723
11724     /**
11725      * Checks if `value` is object-like. A value is object-like if it's not `null`
11726      * and has a `typeof` result of "object".
11727      *
11728      * @static
11729      * @memberOf _
11730      * @since 4.0.0
11731      * @category Lang
11732      * @param {*} value The value to check.
11733      * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11734      * @example
11735      *
11736      * _.isObjectLike({});
11737      * // => true
11738      *
11739      * _.isObjectLike([1, 2, 3]);
11740      * // => true
11741      *
11742      * _.isObjectLike(_.noop);
11743      * // => false
11744      *
11745      * _.isObjectLike(null);
11746      * // => false
11747      */
11748     function isObjectLike(value) {
11749       return value != null && typeof value == 'object';
11750     }
11751
11752     /**
11753      * Checks if `value` is classified as a `Map` object.
11754      *
11755      * @static
11756      * @memberOf _
11757      * @since 4.3.0
11758      * @category Lang
11759      * @param {*} value The value to check.
11760      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
11761      * @example
11762      *
11763      * _.isMap(new Map);
11764      * // => true
11765      *
11766      * _.isMap(new WeakMap);
11767      * // => false
11768      */
11769     var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
11770
11771     /**
11772      * Performs a partial deep comparison between `object` and `source` to
11773      * determine if `object` contains equivalent property values.
11774      *
11775      * **Note:** This method is equivalent to `_.matches` when `source` is
11776      * partially applied.
11777      *
11778      * Partial comparisons will match empty array and empty object `source`
11779      * values against any array or object value, respectively. See `_.isEqual`
11780      * for a list of supported value comparisons.
11781      *
11782      * @static
11783      * @memberOf _
11784      * @since 3.0.0
11785      * @category Lang
11786      * @param {Object} object The object to inspect.
11787      * @param {Object} source The object of property values to match.
11788      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11789      * @example
11790      *
11791      * var object = { 'a': 1, 'b': 2 };
11792      *
11793      * _.isMatch(object, { 'b': 2 });
11794      * // => true
11795      *
11796      * _.isMatch(object, { 'b': 1 });
11797      * // => false
11798      */
11799     function isMatch(object, source) {
11800       return object === source || baseIsMatch(object, source, getMatchData(source));
11801     }
11802
11803     /**
11804      * This method is like `_.isMatch` except that it accepts `customizer` which
11805      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11806      * are handled by the method instead. The `customizer` is invoked with five
11807      * arguments: (objValue, srcValue, index|key, object, source).
11808      *
11809      * @static
11810      * @memberOf _
11811      * @since 4.0.0
11812      * @category Lang
11813      * @param {Object} object The object to inspect.
11814      * @param {Object} source The object of property values to match.
11815      * @param {Function} [customizer] The function to customize comparisons.
11816      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11817      * @example
11818      *
11819      * function isGreeting(value) {
11820      *   return /^h(?:i|ello)$/.test(value);
11821      * }
11822      *
11823      * function customizer(objValue, srcValue) {
11824      *   if (isGreeting(objValue) && isGreeting(srcValue)) {
11825      *     return true;
11826      *   }
11827      * }
11828      *
11829      * var object = { 'greeting': 'hello' };
11830      * var source = { 'greeting': 'hi' };
11831      *
11832      * _.isMatchWith(object, source, customizer);
11833      * // => true
11834      */
11835     function isMatchWith(object, source, customizer) {
11836       customizer = typeof customizer == 'function' ? customizer : undefined;
11837       return baseIsMatch(object, source, getMatchData(source), customizer);
11838     }
11839
11840     /**
11841      * Checks if `value` is `NaN`.
11842      *
11843      * **Note:** This method is based on
11844      * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
11845      * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
11846      * `undefined` and other non-number values.
11847      *
11848      * @static
11849      * @memberOf _
11850      * @since 0.1.0
11851      * @category Lang
11852      * @param {*} value The value to check.
11853      * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
11854      * @example
11855      *
11856      * _.isNaN(NaN);
11857      * // => true
11858      *
11859      * _.isNaN(new Number(NaN));
11860      * // => true
11861      *
11862      * isNaN(undefined);
11863      * // => true
11864      *
11865      * _.isNaN(undefined);
11866      * // => false
11867      */
11868     function isNaN(value) {
11869       // An `NaN` primitive is the only value that is not equal to itself.
11870       // Perform the `toStringTag` check first to avoid errors with some
11871       // ActiveX objects in IE.
11872       return isNumber(value) && value != +value;
11873     }
11874
11875     /**
11876      * Checks if `value` is a pristine native function.
11877      *
11878      * **Note:** This method can't reliably detect native functions in the presence
11879      * of the core-js package because core-js circumvents this kind of detection.
11880      * Despite multiple requests, the core-js maintainer has made it clear: any
11881      * attempt to fix the detection will be obstructed. As a result, we're left
11882      * with little choice but to throw an error. Unfortunately, this also affects
11883      * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
11884      * which rely on core-js.
11885      *
11886      * @static
11887      * @memberOf _
11888      * @since 3.0.0
11889      * @category Lang
11890      * @param {*} value The value to check.
11891      * @returns {boolean} Returns `true` if `value` is a native function,
11892      *  else `false`.
11893      * @example
11894      *
11895      * _.isNative(Array.prototype.push);
11896      * // => true
11897      *
11898      * _.isNative(_);
11899      * // => false
11900      */
11901     function isNative(value) {
11902       if (isMaskable(value)) {
11903         throw new Error(CORE_ERROR_TEXT);
11904       }
11905       return baseIsNative(value);
11906     }
11907
11908     /**
11909      * Checks if `value` is `null`.
11910      *
11911      * @static
11912      * @memberOf _
11913      * @since 0.1.0
11914      * @category Lang
11915      * @param {*} value The value to check.
11916      * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
11917      * @example
11918      *
11919      * _.isNull(null);
11920      * // => true
11921      *
11922      * _.isNull(void 0);
11923      * // => false
11924      */
11925     function isNull(value) {
11926       return value === null;
11927     }
11928
11929     /**
11930      * Checks if `value` is `null` or `undefined`.
11931      *
11932      * @static
11933      * @memberOf _
11934      * @since 4.0.0
11935      * @category Lang
11936      * @param {*} value The value to check.
11937      * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
11938      * @example
11939      *
11940      * _.isNil(null);
11941      * // => true
11942      *
11943      * _.isNil(void 0);
11944      * // => true
11945      *
11946      * _.isNil(NaN);
11947      * // => false
11948      */
11949     function isNil(value) {
11950       return value == null;
11951     }
11952
11953     /**
11954      * Checks if `value` is classified as a `Number` primitive or object.
11955      *
11956      * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
11957      * classified as numbers, use the `_.isFinite` method.
11958      *
11959      * @static
11960      * @memberOf _
11961      * @since 0.1.0
11962      * @category Lang
11963      * @param {*} value The value to check.
11964      * @returns {boolean} Returns `true` if `value` is a number, else `false`.
11965      * @example
11966      *
11967      * _.isNumber(3);
11968      * // => true
11969      *
11970      * _.isNumber(Number.MIN_VALUE);
11971      * // => true
11972      *
11973      * _.isNumber(Infinity);
11974      * // => true
11975      *
11976      * _.isNumber('3');
11977      * // => false
11978      */
11979     function isNumber(value) {
11980       return typeof value == 'number' ||
11981         (isObjectLike(value) && baseGetTag(value) == numberTag);
11982     }
11983
11984     /**
11985      * Checks if `value` is a plain object, that is, an object created by the
11986      * `Object` constructor or one with a `[[Prototype]]` of `null`.
11987      *
11988      * @static
11989      * @memberOf _
11990      * @since 0.8.0
11991      * @category Lang
11992      * @param {*} value The value to check.
11993      * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
11994      * @example
11995      *
11996      * function Foo() {
11997      *   this.a = 1;
11998      * }
11999      *
12000      * _.isPlainObject(new Foo);
12001      * // => false
12002      *
12003      * _.isPlainObject([1, 2, 3]);
12004      * // => false
12005      *
12006      * _.isPlainObject({ 'x': 0, 'y': 0 });
12007      * // => true
12008      *
12009      * _.isPlainObject(Object.create(null));
12010      * // => true
12011      */
12012     function isPlainObject(value) {
12013       if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12014         return false;
12015       }
12016       var proto = getPrototype(value);
12017       if (proto === null) {
12018         return true;
12019       }
12020       var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12021       return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12022         funcToString.call(Ctor) == objectCtorString;
12023     }
12024
12025     /**
12026      * Checks if `value` is classified as a `RegExp` object.
12027      *
12028      * @static
12029      * @memberOf _
12030      * @since 0.1.0
12031      * @category Lang
12032      * @param {*} value The value to check.
12033      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12034      * @example
12035      *
12036      * _.isRegExp(/abc/);
12037      * // => true
12038      *
12039      * _.isRegExp('/abc/');
12040      * // => false
12041      */
12042     var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
12043
12044     /**
12045      * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
12046      * double precision number which isn't the result of a rounded unsafe integer.
12047      *
12048      * **Note:** This method is based on
12049      * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12050      *
12051      * @static
12052      * @memberOf _
12053      * @since 4.0.0
12054      * @category Lang
12055      * @param {*} value The value to check.
12056      * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12057      * @example
12058      *
12059      * _.isSafeInteger(3);
12060      * // => true
12061      *
12062      * _.isSafeInteger(Number.MIN_VALUE);
12063      * // => false
12064      *
12065      * _.isSafeInteger(Infinity);
12066      * // => false
12067      *
12068      * _.isSafeInteger('3');
12069      * // => false
12070      */
12071     function isSafeInteger(value) {
12072       return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12073     }
12074
12075     /**
12076      * Checks if `value` is classified as a `Set` object.
12077      *
12078      * @static
12079      * @memberOf _
12080      * @since 4.3.0
12081      * @category Lang
12082      * @param {*} value The value to check.
12083      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12084      * @example
12085      *
12086      * _.isSet(new Set);
12087      * // => true
12088      *
12089      * _.isSet(new WeakSet);
12090      * // => false
12091      */
12092     var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12093
12094     /**
12095      * Checks if `value` is classified as a `String` primitive or object.
12096      *
12097      * @static
12098      * @since 0.1.0
12099      * @memberOf _
12100      * @category Lang
12101      * @param {*} value The value to check.
12102      * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12103      * @example
12104      *
12105      * _.isString('abc');
12106      * // => true
12107      *
12108      * _.isString(1);
12109      * // => false
12110      */
12111     function isString(value) {
12112       return typeof value == 'string' ||
12113         (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12114     }
12115
12116     /**
12117      * Checks if `value` is classified as a `Symbol` primitive or object.
12118      *
12119      * @static
12120      * @memberOf _
12121      * @since 4.0.0
12122      * @category Lang
12123      * @param {*} value The value to check.
12124      * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12125      * @example
12126      *
12127      * _.isSymbol(Symbol.iterator);
12128      * // => true
12129      *
12130      * _.isSymbol('abc');
12131      * // => false
12132      */
12133     function isSymbol(value) {
12134       return typeof value == 'symbol' ||
12135         (isObjectLike(value) && baseGetTag(value) == symbolTag);
12136     }
12137
12138     /**
12139      * Checks if `value` is classified as a typed array.
12140      *
12141      * @static
12142      * @memberOf _
12143      * @since 3.0.0
12144      * @category Lang
12145      * @param {*} value The value to check.
12146      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12147      * @example
12148      *
12149      * _.isTypedArray(new Uint8Array);
12150      * // => true
12151      *
12152      * _.isTypedArray([]);
12153      * // => false
12154      */
12155     var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12156
12157     /**
12158      * Checks if `value` is `undefined`.
12159      *
12160      * @static
12161      * @since 0.1.0
12162      * @memberOf _
12163      * @category Lang
12164      * @param {*} value The value to check.
12165      * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12166      * @example
12167      *
12168      * _.isUndefined(void 0);
12169      * // => true
12170      *
12171      * _.isUndefined(null);
12172      * // => false
12173      */
12174     function isUndefined(value) {
12175       return value === undefined;
12176     }
12177
12178     /**
12179      * Checks if `value` is classified as a `WeakMap` object.
12180      *
12181      * @static
12182      * @memberOf _
12183      * @since 4.3.0
12184      * @category Lang
12185      * @param {*} value The value to check.
12186      * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12187      * @example
12188      *
12189      * _.isWeakMap(new WeakMap);
12190      * // => true
12191      *
12192      * _.isWeakMap(new Map);
12193      * // => false
12194      */
12195     function isWeakMap(value) {
12196       return isObjectLike(value) && getTag(value) == weakMapTag;
12197     }
12198
12199     /**
12200      * Checks if `value` is classified as a `WeakSet` object.
12201      *
12202      * @static
12203      * @memberOf _
12204      * @since 4.3.0
12205      * @category Lang
12206      * @param {*} value The value to check.
12207      * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12208      * @example
12209      *
12210      * _.isWeakSet(new WeakSet);
12211      * // => true
12212      *
12213      * _.isWeakSet(new Set);
12214      * // => false
12215      */
12216     function isWeakSet(value) {
12217       return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12218     }
12219
12220     /**
12221      * Checks if `value` is less than `other`.
12222      *
12223      * @static
12224      * @memberOf _
12225      * @since 3.9.0
12226      * @category Lang
12227      * @param {*} value The value to compare.
12228      * @param {*} other The other value to compare.
12229      * @returns {boolean} Returns `true` if `value` is less than `other`,
12230      *  else `false`.
12231      * @see _.gt
12232      * @example
12233      *
12234      * _.lt(1, 3);
12235      * // => true
12236      *
12237      * _.lt(3, 3);
12238      * // => false
12239      *
12240      * _.lt(3, 1);
12241      * // => false
12242      */
12243     var lt = createRelationalOperation(baseLt);
12244
12245     /**
12246      * Checks if `value` is less than or equal to `other`.
12247      *
12248      * @static
12249      * @memberOf _
12250      * @since 3.9.0
12251      * @category Lang
12252      * @param {*} value The value to compare.
12253      * @param {*} other The other value to compare.
12254      * @returns {boolean} Returns `true` if `value` is less than or equal to
12255      *  `other`, else `false`.
12256      * @see _.gte
12257      * @example
12258      *
12259      * _.lte(1, 3);
12260      * // => true
12261      *
12262      * _.lte(3, 3);
12263      * // => true
12264      *
12265      * _.lte(3, 1);
12266      * // => false
12267      */
12268     var lte = createRelationalOperation(function(value, other) {
12269       return value <= other;
12270     });
12271
12272     /**
12273      * Converts `value` to an array.
12274      *
12275      * @static
12276      * @since 0.1.0
12277      * @memberOf _
12278      * @category Lang
12279      * @param {*} value The value to convert.
12280      * @returns {Array} Returns the converted array.
12281      * @example
12282      *
12283      * _.toArray({ 'a': 1, 'b': 2 });
12284      * // => [1, 2]
12285      *
12286      * _.toArray('abc');
12287      * // => ['a', 'b', 'c']
12288      *
12289      * _.toArray(1);
12290      * // => []
12291      *
12292      * _.toArray(null);
12293      * // => []
12294      */
12295     function toArray(value) {
12296       if (!value) {
12297         return [];
12298       }
12299       if (isArrayLike(value)) {
12300         return isString(value) ? stringToArray(value) : copyArray(value);
12301       }
12302       if (symIterator && value[symIterator]) {
12303         return iteratorToArray(value[symIterator]());
12304       }
12305       var tag = getTag(value),
12306           func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12307
12308       return func(value);
12309     }
12310
12311     /**
12312      * Converts `value` to a finite number.
12313      *
12314      * @static
12315      * @memberOf _
12316      * @since 4.12.0
12317      * @category Lang
12318      * @param {*} value The value to convert.
12319      * @returns {number} Returns the converted number.
12320      * @example
12321      *
12322      * _.toFinite(3.2);
12323      * // => 3.2
12324      *
12325      * _.toFinite(Number.MIN_VALUE);
12326      * // => 5e-324
12327      *
12328      * _.toFinite(Infinity);
12329      * // => 1.7976931348623157e+308
12330      *
12331      * _.toFinite('3.2');
12332      * // => 3.2
12333      */
12334     function toFinite(value) {
12335       if (!value) {
12336         return value === 0 ? value : 0;
12337       }
12338       value = toNumber(value);
12339       if (value === INFINITY || value === -INFINITY) {
12340         var sign = (value < 0 ? -1 : 1);
12341         return sign * MAX_INTEGER;
12342       }
12343       return value === value ? value : 0;
12344     }
12345
12346     /**
12347      * Converts `value` to an integer.
12348      *
12349      * **Note:** This method is loosely based on
12350      * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12351      *
12352      * @static
12353      * @memberOf _
12354      * @since 4.0.0
12355      * @category Lang
12356      * @param {*} value The value to convert.
12357      * @returns {number} Returns the converted integer.
12358      * @example
12359      *
12360      * _.toInteger(3.2);
12361      * // => 3
12362      *
12363      * _.toInteger(Number.MIN_VALUE);
12364      * // => 0
12365      *
12366      * _.toInteger(Infinity);
12367      * // => 1.7976931348623157e+308
12368      *
12369      * _.toInteger('3.2');
12370      * // => 3
12371      */
12372     function toInteger(value) {
12373       var result = toFinite(value),
12374           remainder = result % 1;
12375
12376       return result === result ? (remainder ? result - remainder : result) : 0;
12377     }
12378
12379     /**
12380      * Converts `value` to an integer suitable for use as the length of an
12381      * array-like object.
12382      *
12383      * **Note:** This method is based on
12384      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12385      *
12386      * @static
12387      * @memberOf _
12388      * @since 4.0.0
12389      * @category Lang
12390      * @param {*} value The value to convert.
12391      * @returns {number} Returns the converted integer.
12392      * @example
12393      *
12394      * _.toLength(3.2);
12395      * // => 3
12396      *
12397      * _.toLength(Number.MIN_VALUE);
12398      * // => 0
12399      *
12400      * _.toLength(Infinity);
12401      * // => 4294967295
12402      *
12403      * _.toLength('3.2');
12404      * // => 3
12405      */
12406     function toLength(value) {
12407       return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12408     }
12409
12410     /**
12411      * Converts `value` to a number.
12412      *
12413      * @static
12414      * @memberOf _
12415      * @since 4.0.0
12416      * @category Lang
12417      * @param {*} value The value to process.
12418      * @returns {number} Returns the number.
12419      * @example
12420      *
12421      * _.toNumber(3.2);
12422      * // => 3.2
12423      *
12424      * _.toNumber(Number.MIN_VALUE);
12425      * // => 5e-324
12426      *
12427      * _.toNumber(Infinity);
12428      * // => Infinity
12429      *
12430      * _.toNumber('3.2');
12431      * // => 3.2
12432      */
12433     function toNumber(value) {
12434       if (typeof value == 'number') {
12435         return value;
12436       }
12437       if (isSymbol(value)) {
12438         return NAN;
12439       }
12440       if (isObject(value)) {
12441         var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12442         value = isObject(other) ? (other + '') : other;
12443       }
12444       if (typeof value != 'string') {
12445         return value === 0 ? value : +value;
12446       }
12447       value = value.replace(reTrim, '');
12448       var isBinary = reIsBinary.test(value);
12449       return (isBinary || reIsOctal.test(value))
12450         ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
12451         : (reIsBadHex.test(value) ? NAN : +value);
12452     }
12453
12454     /**
12455      * Converts `value` to a plain object flattening inherited enumerable string
12456      * keyed properties of `value` to own properties of the plain object.
12457      *
12458      * @static
12459      * @memberOf _
12460      * @since 3.0.0
12461      * @category Lang
12462      * @param {*} value The value to convert.
12463      * @returns {Object} Returns the converted plain object.
12464      * @example
12465      *
12466      * function Foo() {
12467      *   this.b = 2;
12468      * }
12469      *
12470      * Foo.prototype.c = 3;
12471      *
12472      * _.assign({ 'a': 1 }, new Foo);
12473      * // => { 'a': 1, 'b': 2 }
12474      *
12475      * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12476      * // => { 'a': 1, 'b': 2, 'c': 3 }
12477      */
12478     function toPlainObject(value) {
12479       return copyObject(value, keysIn(value));
12480     }
12481
12482     /**
12483      * Converts `value` to a safe integer. A safe integer can be compared and
12484      * represented correctly.
12485      *
12486      * @static
12487      * @memberOf _
12488      * @since 4.0.0
12489      * @category Lang
12490      * @param {*} value The value to convert.
12491      * @returns {number} Returns the converted integer.
12492      * @example
12493      *
12494      * _.toSafeInteger(3.2);
12495      * // => 3
12496      *
12497      * _.toSafeInteger(Number.MIN_VALUE);
12498      * // => 0
12499      *
12500      * _.toSafeInteger(Infinity);
12501      * // => 9007199254740991
12502      *
12503      * _.toSafeInteger('3.2');
12504      * // => 3
12505      */
12506     function toSafeInteger(value) {
12507       return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
12508     }
12509
12510     /**
12511      * Converts `value` to a string. An empty string is returned for `null`
12512      * and `undefined` values. The sign of `-0` is preserved.
12513      *
12514      * @static
12515      * @memberOf _
12516      * @since 4.0.0
12517      * @category Lang
12518      * @param {*} value The value to convert.
12519      * @returns {string} Returns the converted string.
12520      * @example
12521      *
12522      * _.toString(null);
12523      * // => ''
12524      *
12525      * _.toString(-0);
12526      * // => '-0'
12527      *
12528      * _.toString([1, 2, 3]);
12529      * // => '1,2,3'
12530      */
12531     function toString(value) {
12532       return value == null ? '' : baseToString(value);
12533     }
12534
12535     /*------------------------------------------------------------------------*/
12536
12537     /**
12538      * Assigns own enumerable string keyed properties of source objects to the
12539      * destination object. Source objects are applied from left to right.
12540      * Subsequent sources overwrite property assignments of previous sources.
12541      *
12542      * **Note:** This method mutates `object` and is loosely based on
12543      * [`Object.assign`](https://mdn.io/Object/assign).
12544      *
12545      * @static
12546      * @memberOf _
12547      * @since 0.10.0
12548      * @category Object
12549      * @param {Object} object The destination object.
12550      * @param {...Object} [sources] The source objects.
12551      * @returns {Object} Returns `object`.
12552      * @see _.assignIn
12553      * @example
12554      *
12555      * function Foo() {
12556      *   this.a = 1;
12557      * }
12558      *
12559      * function Bar() {
12560      *   this.c = 3;
12561      * }
12562      *
12563      * Foo.prototype.b = 2;
12564      * Bar.prototype.d = 4;
12565      *
12566      * _.assign({ 'a': 0 }, new Foo, new Bar);
12567      * // => { 'a': 1, 'c': 3 }
12568      */
12569     var assign = createAssigner(function(object, source) {
12570       if (isPrototype(source) || isArrayLike(source)) {
12571         copyObject(source, keys(source), object);
12572         return;
12573       }
12574       for (var key in source) {
12575         if (hasOwnProperty.call(source, key)) {
12576           assignValue(object, key, source[key]);
12577         }
12578       }
12579     });
12580
12581     /**
12582      * This method is like `_.assign` except that it iterates over own and
12583      * inherited source properties.
12584      *
12585      * **Note:** This method mutates `object`.
12586      *
12587      * @static
12588      * @memberOf _
12589      * @since 4.0.0
12590      * @alias extend
12591      * @category Object
12592      * @param {Object} object The destination object.
12593      * @param {...Object} [sources] The source objects.
12594      * @returns {Object} Returns `object`.
12595      * @see _.assign
12596      * @example
12597      *
12598      * function Foo() {
12599      *   this.a = 1;
12600      * }
12601      *
12602      * function Bar() {
12603      *   this.c = 3;
12604      * }
12605      *
12606      * Foo.prototype.b = 2;
12607      * Bar.prototype.d = 4;
12608      *
12609      * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12610      * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12611      */
12612     var assignIn = createAssigner(function(object, source) {
12613       copyObject(source, keysIn(source), object);
12614     });
12615
12616     /**
12617      * This method is like `_.assignIn` except that it accepts `customizer`
12618      * which is invoked to produce the assigned values. If `customizer` returns
12619      * `undefined`, assignment is handled by the method instead. The `customizer`
12620      * is invoked with five arguments: (objValue, srcValue, key, object, source).
12621      *
12622      * **Note:** This method mutates `object`.
12623      *
12624      * @static
12625      * @memberOf _
12626      * @since 4.0.0
12627      * @alias extendWith
12628      * @category Object
12629      * @param {Object} object The destination object.
12630      * @param {...Object} sources The source objects.
12631      * @param {Function} [customizer] The function to customize assigned values.
12632      * @returns {Object} Returns `object`.
12633      * @see _.assignWith
12634      * @example
12635      *
12636      * function customizer(objValue, srcValue) {
12637      *   return _.isUndefined(objValue) ? srcValue : objValue;
12638      * }
12639      *
12640      * var defaults = _.partialRight(_.assignInWith, customizer);
12641      *
12642      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12643      * // => { 'a': 1, 'b': 2 }
12644      */
12645     var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
12646       copyObject(source, keysIn(source), object, customizer);
12647     });
12648
12649     /**
12650      * This method is like `_.assign` except that it accepts `customizer`
12651      * which is invoked to produce the assigned values. If `customizer` returns
12652      * `undefined`, assignment is handled by the method instead. The `customizer`
12653      * is invoked with five arguments: (objValue, srcValue, key, object, source).
12654      *
12655      * **Note:** This method mutates `object`.
12656      *
12657      * @static
12658      * @memberOf _
12659      * @since 4.0.0
12660      * @category Object
12661      * @param {Object} object The destination object.
12662      * @param {...Object} sources The source objects.
12663      * @param {Function} [customizer] The function to customize assigned values.
12664      * @returns {Object} Returns `object`.
12665      * @see _.assignInWith
12666      * @example
12667      *
12668      * function customizer(objValue, srcValue) {
12669      *   return _.isUndefined(objValue) ? srcValue : objValue;
12670      * }
12671      *
12672      * var defaults = _.partialRight(_.assignWith, customizer);
12673      *
12674      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12675      * // => { 'a': 1, 'b': 2 }
12676      */
12677     var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
12678       copyObject(source, keys(source), object, customizer);
12679     });
12680
12681     /**
12682      * Creates an array of values corresponding to `paths` of `object`.
12683      *
12684      * @static
12685      * @memberOf _
12686      * @since 1.0.0
12687      * @category Object
12688      * @param {Object} object The object to iterate over.
12689      * @param {...(string|string[])} [paths] The property paths of elements to pick.
12690      * @returns {Array} Returns the picked values.
12691      * @example
12692      *
12693      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
12694      *
12695      * _.at(object, ['a[0].b.c', 'a[1]']);
12696      * // => [3, 4]
12697      */
12698     var at = flatRest(baseAt);
12699
12700     /**
12701      * Creates an object that inherits from the `prototype` object. If a
12702      * `properties` object is given, its own enumerable string keyed properties
12703      * are assigned to the created object.
12704      *
12705      * @static
12706      * @memberOf _
12707      * @since 2.3.0
12708      * @category Object
12709      * @param {Object} prototype The object to inherit from.
12710      * @param {Object} [properties] The properties to assign to the object.
12711      * @returns {Object} Returns the new object.
12712      * @example
12713      *
12714      * function Shape() {
12715      *   this.x = 0;
12716      *   this.y = 0;
12717      * }
12718      *
12719      * function Circle() {
12720      *   Shape.call(this);
12721      * }
12722      *
12723      * Circle.prototype = _.create(Shape.prototype, {
12724      *   'constructor': Circle
12725      * });
12726      *
12727      * var circle = new Circle;
12728      * circle instanceof Circle;
12729      * // => true
12730      *
12731      * circle instanceof Shape;
12732      * // => true
12733      */
12734     function create(prototype, properties) {
12735       var result = baseCreate(prototype);
12736       return properties == null ? result : baseAssign(result, properties);
12737     }
12738
12739     /**
12740      * Assigns own and inherited enumerable string keyed properties of source
12741      * objects to the destination object for all destination properties that
12742      * resolve to `undefined`. Source objects are applied from left to right.
12743      * Once a property is set, additional values of the same property are ignored.
12744      *
12745      * **Note:** This method mutates `object`.
12746      *
12747      * @static
12748      * @since 0.1.0
12749      * @memberOf _
12750      * @category Object
12751      * @param {Object} object The destination object.
12752      * @param {...Object} [sources] The source objects.
12753      * @returns {Object} Returns `object`.
12754      * @see _.defaultsDeep
12755      * @example
12756      *
12757      * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12758      * // => { 'a': 1, 'b': 2 }
12759      */
12760     var defaults = baseRest(function(args) {
12761       args.push(undefined, assignInDefaults);
12762       return apply(assignInWith, undefined, args);
12763     });
12764
12765     /**
12766      * This method is like `_.defaults` except that it recursively assigns
12767      * default properties.
12768      *
12769      * **Note:** This method mutates `object`.
12770      *
12771      * @static
12772      * @memberOf _
12773      * @since 3.10.0
12774      * @category Object
12775      * @param {Object} object The destination object.
12776      * @param {...Object} [sources] The source objects.
12777      * @returns {Object} Returns `object`.
12778      * @see _.defaults
12779      * @example
12780      *
12781      * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
12782      * // => { 'a': { 'b': 2, 'c': 3 } }
12783      */
12784     var defaultsDeep = baseRest(function(args) {
12785       args.push(undefined, mergeDefaults);
12786       return apply(mergeWith, undefined, args);
12787     });
12788
12789     /**
12790      * This method is like `_.find` except that it returns the key of the first
12791      * element `predicate` returns truthy for instead of the element itself.
12792      *
12793      * @static
12794      * @memberOf _
12795      * @since 1.1.0
12796      * @category Object
12797      * @param {Object} object The object to inspect.
12798      * @param {Function} [predicate=_.identity] The function invoked per iteration.
12799      * @returns {string|undefined} Returns the key of the matched element,
12800      *  else `undefined`.
12801      * @example
12802      *
12803      * var users = {
12804      *   'barney':  { 'age': 36, 'active': true },
12805      *   'fred':    { 'age': 40, 'active': false },
12806      *   'pebbles': { 'age': 1,  'active': true }
12807      * };
12808      *
12809      * _.findKey(users, function(o) { return o.age < 40; });
12810      * // => 'barney' (iteration order is not guaranteed)
12811      *
12812      * // The `_.matches` iteratee shorthand.
12813      * _.findKey(users, { 'age': 1, 'active': true });
12814      * // => 'pebbles'
12815      *
12816      * // The `_.matchesProperty` iteratee shorthand.
12817      * _.findKey(users, ['active', false]);
12818      * // => 'fred'
12819      *
12820      * // The `_.property` iteratee shorthand.
12821      * _.findKey(users, 'active');
12822      * // => 'barney'
12823      */
12824     function findKey(object, predicate) {
12825       return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
12826     }
12827
12828     /**
12829      * This method is like `_.findKey` except that it iterates over elements of
12830      * a collection in the opposite order.
12831      *
12832      * @static
12833      * @memberOf _
12834      * @since 2.0.0
12835      * @category Object
12836      * @param {Object} object The object to inspect.
12837      * @param {Function} [predicate=_.identity] The function invoked per iteration.
12838      * @returns {string|undefined} Returns the key of the matched element,
12839      *  else `undefined`.
12840      * @example
12841      *
12842      * var users = {
12843      *   'barney':  { 'age': 36, 'active': true },
12844      *   'fred':    { 'age': 40, 'active': false },
12845      *   'pebbles': { 'age': 1,  'active': true }
12846      * };
12847      *
12848      * _.findLastKey(users, function(o) { return o.age < 40; });
12849      * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
12850      *
12851      * // The `_.matches` iteratee shorthand.
12852      * _.findLastKey(users, { 'age': 36, 'active': true });
12853      * // => 'barney'
12854      *
12855      * // The `_.matchesProperty` iteratee shorthand.
12856      * _.findLastKey(users, ['active', false]);
12857      * // => 'fred'
12858      *
12859      * // The `_.property` iteratee shorthand.
12860      * _.findLastKey(users, 'active');
12861      * // => 'pebbles'
12862      */
12863     function findLastKey(object, predicate) {
12864       return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
12865     }
12866
12867     /**
12868      * Iterates over own and inherited enumerable string keyed properties of an
12869      * object and invokes `iteratee` for each property. The iteratee is invoked
12870      * with three arguments: (value, key, object). Iteratee functions may exit
12871      * iteration early by explicitly returning `false`.
12872      *
12873      * @static
12874      * @memberOf _
12875      * @since 0.3.0
12876      * @category Object
12877      * @param {Object} object The object to iterate over.
12878      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12879      * @returns {Object} Returns `object`.
12880      * @see _.forInRight
12881      * @example
12882      *
12883      * function Foo() {
12884      *   this.a = 1;
12885      *   this.b = 2;
12886      * }
12887      *
12888      * Foo.prototype.c = 3;
12889      *
12890      * _.forIn(new Foo, function(value, key) {
12891      *   console.log(key);
12892      * });
12893      * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
12894      */
12895     function forIn(object, iteratee) {
12896       return object == null
12897         ? object
12898         : baseFor(object, getIteratee(iteratee, 3), keysIn);
12899     }
12900
12901     /**
12902      * This method is like `_.forIn` except that it iterates over properties of
12903      * `object` in the opposite order.
12904      *
12905      * @static
12906      * @memberOf _
12907      * @since 2.0.0
12908      * @category Object
12909      * @param {Object} object The object to iterate over.
12910      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12911      * @returns {Object} Returns `object`.
12912      * @see _.forIn
12913      * @example
12914      *
12915      * function Foo() {
12916      *   this.a = 1;
12917      *   this.b = 2;
12918      * }
12919      *
12920      * Foo.prototype.c = 3;
12921      *
12922      * _.forInRight(new Foo, function(value, key) {
12923      *   console.log(key);
12924      * });
12925      * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
12926      */
12927     function forInRight(object, iteratee) {
12928       return object == null
12929         ? object
12930         : baseForRight(object, getIteratee(iteratee, 3), keysIn);
12931     }
12932
12933     /**
12934      * Iterates over own enumerable string keyed properties of an object and
12935      * invokes `iteratee` for each property. The iteratee is invoked with three
12936      * arguments: (value, key, object). Iteratee functions may exit iteration
12937      * early by explicitly returning `false`.
12938      *
12939      * @static
12940      * @memberOf _
12941      * @since 0.3.0
12942      * @category Object
12943      * @param {Object} object The object to iterate over.
12944      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12945      * @returns {Object} Returns `object`.
12946      * @see _.forOwnRight
12947      * @example
12948      *
12949      * function Foo() {
12950      *   this.a = 1;
12951      *   this.b = 2;
12952      * }
12953      *
12954      * Foo.prototype.c = 3;
12955      *
12956      * _.forOwn(new Foo, function(value, key) {
12957      *   console.log(key);
12958      * });
12959      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
12960      */
12961     function forOwn(object, iteratee) {
12962       return object && baseForOwn(object, getIteratee(iteratee, 3));
12963     }
12964
12965     /**
12966      * This method is like `_.forOwn` except that it iterates over properties of
12967      * `object` in the opposite order.
12968      *
12969      * @static
12970      * @memberOf _
12971      * @since 2.0.0
12972      * @category Object
12973      * @param {Object} object The object to iterate over.
12974      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12975      * @returns {Object} Returns `object`.
12976      * @see _.forOwn
12977      * @example
12978      *
12979      * function Foo() {
12980      *   this.a = 1;
12981      *   this.b = 2;
12982      * }
12983      *
12984      * Foo.prototype.c = 3;
12985      *
12986      * _.forOwnRight(new Foo, function(value, key) {
12987      *   console.log(key);
12988      * });
12989      * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
12990      */
12991     function forOwnRight(object, iteratee) {
12992       return object && baseForOwnRight(object, getIteratee(iteratee, 3));
12993     }
12994
12995     /**
12996      * Creates an array of function property names from own enumerable properties
12997      * of `object`.
12998      *
12999      * @static
13000      * @since 0.1.0
13001      * @memberOf _
13002      * @category Object
13003      * @param {Object} object The object to inspect.
13004      * @returns {Array} Returns the function names.
13005      * @see _.functionsIn
13006      * @example
13007      *
13008      * function Foo() {
13009      *   this.a = _.constant('a');
13010      *   this.b = _.constant('b');
13011      * }
13012      *
13013      * Foo.prototype.c = _.constant('c');
13014      *
13015      * _.functions(new Foo);
13016      * // => ['a', 'b']
13017      */
13018     function functions(object) {
13019       return object == null ? [] : baseFunctions(object, keys(object));
13020     }
13021
13022     /**
13023      * Creates an array of function property names from own and inherited
13024      * enumerable properties of `object`.
13025      *
13026      * @static
13027      * @memberOf _
13028      * @since 4.0.0
13029      * @category Object
13030      * @param {Object} object The object to inspect.
13031      * @returns {Array} Returns the function names.
13032      * @see _.functions
13033      * @example
13034      *
13035      * function Foo() {
13036      *   this.a = _.constant('a');
13037      *   this.b = _.constant('b');
13038      * }
13039      *
13040      * Foo.prototype.c = _.constant('c');
13041      *
13042      * _.functionsIn(new Foo);
13043      * // => ['a', 'b', 'c']
13044      */
13045     function functionsIn(object) {
13046       return object == null ? [] : baseFunctions(object, keysIn(object));
13047     }
13048
13049     /**
13050      * Gets the value at `path` of `object`. If the resolved value is
13051      * `undefined`, the `defaultValue` is returned in its place.
13052      *
13053      * @static
13054      * @memberOf _
13055      * @since 3.7.0
13056      * @category Object
13057      * @param {Object} object The object to query.
13058      * @param {Array|string} path The path of the property to get.
13059      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13060      * @returns {*} Returns the resolved value.
13061      * @example
13062      *
13063      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13064      *
13065      * _.get(object, 'a[0].b.c');
13066      * // => 3
13067      *
13068      * _.get(object, ['a', '0', 'b', 'c']);
13069      * // => 3
13070      *
13071      * _.get(object, 'a.b.c', 'default');
13072      * // => 'default'
13073      */
13074     function get(object, path, defaultValue) {
13075       var result = object == null ? undefined : baseGet(object, path);
13076       return result === undefined ? defaultValue : result;
13077     }
13078
13079     /**
13080      * Checks if `path` is a direct property of `object`.
13081      *
13082      * @static
13083      * @since 0.1.0
13084      * @memberOf _
13085      * @category Object
13086      * @param {Object} object The object to query.
13087      * @param {Array|string} path The path to check.
13088      * @returns {boolean} Returns `true` if `path` exists, else `false`.
13089      * @example
13090      *
13091      * var object = { 'a': { 'b': 2 } };
13092      * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13093      *
13094      * _.has(object, 'a');
13095      * // => true
13096      *
13097      * _.has(object, 'a.b');
13098      * // => true
13099      *
13100      * _.has(object, ['a', 'b']);
13101      * // => true
13102      *
13103      * _.has(other, 'a');
13104      * // => false
13105      */
13106     function has(object, path) {
13107       return object != null && hasPath(object, path, baseHas);
13108     }
13109
13110     /**
13111      * Checks if `path` is a direct or inherited property of `object`.
13112      *
13113      * @static
13114      * @memberOf _
13115      * @since 4.0.0
13116      * @category Object
13117      * @param {Object} object The object to query.
13118      * @param {Array|string} path The path to check.
13119      * @returns {boolean} Returns `true` if `path` exists, else `false`.
13120      * @example
13121      *
13122      * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13123      *
13124      * _.hasIn(object, 'a');
13125      * // => true
13126      *
13127      * _.hasIn(object, 'a.b');
13128      * // => true
13129      *
13130      * _.hasIn(object, ['a', 'b']);
13131      * // => true
13132      *
13133      * _.hasIn(object, 'b');
13134      * // => false
13135      */
13136     function hasIn(object, path) {
13137       return object != null && hasPath(object, path, baseHasIn);
13138     }
13139
13140     /**
13141      * Creates an object composed of the inverted keys and values of `object`.
13142      * If `object` contains duplicate values, subsequent values overwrite
13143      * property assignments of previous values.
13144      *
13145      * @static
13146      * @memberOf _
13147      * @since 0.7.0
13148      * @category Object
13149      * @param {Object} object The object to invert.
13150      * @returns {Object} Returns the new inverted object.
13151      * @example
13152      *
13153      * var object = { 'a': 1, 'b': 2, 'c': 1 };
13154      *
13155      * _.invert(object);
13156      * // => { '1': 'c', '2': 'b' }
13157      */
13158     var invert = createInverter(function(result, value, key) {
13159       result[value] = key;
13160     }, constant(identity));
13161
13162     /**
13163      * This method is like `_.invert` except that the inverted object is generated
13164      * from the results of running each element of `object` thru `iteratee`. The
13165      * corresponding inverted value of each inverted key is an array of keys
13166      * responsible for generating the inverted value. The iteratee is invoked
13167      * with one argument: (value).
13168      *
13169      * @static
13170      * @memberOf _
13171      * @since 4.1.0
13172      * @category Object
13173      * @param {Object} object The object to invert.
13174      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
13175      * @returns {Object} Returns the new inverted object.
13176      * @example
13177      *
13178      * var object = { 'a': 1, 'b': 2, 'c': 1 };
13179      *
13180      * _.invertBy(object);
13181      * // => { '1': ['a', 'c'], '2': ['b'] }
13182      *
13183      * _.invertBy(object, function(value) {
13184      *   return 'group' + value;
13185      * });
13186      * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13187      */
13188     var invertBy = createInverter(function(result, value, key) {
13189       if (hasOwnProperty.call(result, value)) {
13190         result[value].push(key);
13191       } else {
13192         result[value] = [key];
13193       }
13194     }, getIteratee);
13195
13196     /**
13197      * Invokes the method at `path` of `object`.
13198      *
13199      * @static
13200      * @memberOf _
13201      * @since 4.0.0
13202      * @category Object
13203      * @param {Object} object The object to query.
13204      * @param {Array|string} path The path of the method to invoke.
13205      * @param {...*} [args] The arguments to invoke the method with.
13206      * @returns {*} Returns the result of the invoked method.
13207      * @example
13208      *
13209      * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13210      *
13211      * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13212      * // => [2, 3]
13213      */
13214     var invoke = baseRest(baseInvoke);
13215
13216     /**
13217      * Creates an array of the own enumerable property names of `object`.
13218      *
13219      * **Note:** Non-object values are coerced to objects. See the
13220      * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
13221      * for more details.
13222      *
13223      * @static
13224      * @since 0.1.0
13225      * @memberOf _
13226      * @category Object
13227      * @param {Object} object The object to query.
13228      * @returns {Array} Returns the array of property names.
13229      * @example
13230      *
13231      * function Foo() {
13232      *   this.a = 1;
13233      *   this.b = 2;
13234      * }
13235      *
13236      * Foo.prototype.c = 3;
13237      *
13238      * _.keys(new Foo);
13239      * // => ['a', 'b'] (iteration order is not guaranteed)
13240      *
13241      * _.keys('hi');
13242      * // => ['0', '1']
13243      */
13244     function keys(object) {
13245       return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13246     }
13247
13248     /**
13249      * Creates an array of the own and inherited enumerable property names of `object`.
13250      *
13251      * **Note:** Non-object values are coerced to objects.
13252      *
13253      * @static
13254      * @memberOf _
13255      * @since 3.0.0
13256      * @category Object
13257      * @param {Object} object The object to query.
13258      * @returns {Array} Returns the array of property names.
13259      * @example
13260      *
13261      * function Foo() {
13262      *   this.a = 1;
13263      *   this.b = 2;
13264      * }
13265      *
13266      * Foo.prototype.c = 3;
13267      *
13268      * _.keysIn(new Foo);
13269      * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13270      */
13271     function keysIn(object) {
13272       return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
13273     }
13274
13275     /**
13276      * The opposite of `_.mapValues`; this method creates an object with the
13277      * same values as `object` and keys generated by running each own enumerable
13278      * string keyed property of `object` thru `iteratee`. The iteratee is invoked
13279      * with three arguments: (value, key, object).
13280      *
13281      * @static
13282      * @memberOf _
13283      * @since 3.8.0
13284      * @category Object
13285      * @param {Object} object The object to iterate over.
13286      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13287      * @returns {Object} Returns the new mapped object.
13288      * @see _.mapValues
13289      * @example
13290      *
13291      * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13292      *   return key + value;
13293      * });
13294      * // => { 'a1': 1, 'b2': 2 }
13295      */
13296     function mapKeys(object, iteratee) {
13297       var result = {};
13298       iteratee = getIteratee(iteratee, 3);
13299
13300       baseForOwn(object, function(value, key, object) {
13301         baseAssignValue(result, iteratee(value, key, object), value);
13302       });
13303       return result;
13304     }
13305
13306     /**
13307      * Creates an object with the same keys as `object` and values generated
13308      * by running each own enumerable string keyed property of `object` thru
13309      * `iteratee`. The iteratee is invoked with three arguments:
13310      * (value, key, object).
13311      *
13312      * @static
13313      * @memberOf _
13314      * @since 2.4.0
13315      * @category Object
13316      * @param {Object} object The object to iterate over.
13317      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13318      * @returns {Object} Returns the new mapped object.
13319      * @see _.mapKeys
13320      * @example
13321      *
13322      * var users = {
13323      *   'fred':    { 'user': 'fred',    'age': 40 },
13324      *   'pebbles': { 'user': 'pebbles', 'age': 1 }
13325      * };
13326      *
13327      * _.mapValues(users, function(o) { return o.age; });
13328      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13329      *
13330      * // The `_.property` iteratee shorthand.
13331      * _.mapValues(users, 'age');
13332      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13333      */
13334     function mapValues(object, iteratee) {
13335       var result = {};
13336       iteratee = getIteratee(iteratee, 3);
13337
13338       baseForOwn(object, function(value, key, object) {
13339         baseAssignValue(result, key, iteratee(value, key, object));
13340       });
13341       return result;
13342     }
13343
13344     /**
13345      * This method is like `_.assign` except that it recursively merges own and
13346      * inherited enumerable string keyed properties of source objects into the
13347      * destination object. Source properties that resolve to `undefined` are
13348      * skipped if a destination value exists. Array and plain object properties
13349      * are merged recursively. Other objects and value types are overridden by
13350      * assignment. Source objects are applied from left to right. Subsequent
13351      * sources overwrite property assignments of previous sources.
13352      *
13353      * **Note:** This method mutates `object`.
13354      *
13355      * @static
13356      * @memberOf _
13357      * @since 0.5.0
13358      * @category Object
13359      * @param {Object} object The destination object.
13360      * @param {...Object} [sources] The source objects.
13361      * @returns {Object} Returns `object`.
13362      * @example
13363      *
13364      * var object = {
13365      *   'a': [{ 'b': 2 }, { 'd': 4 }]
13366      * };
13367      *
13368      * var other = {
13369      *   'a': [{ 'c': 3 }, { 'e': 5 }]
13370      * };
13371      *
13372      * _.merge(object, other);
13373      * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13374      */
13375     var merge = createAssigner(function(object, source, srcIndex) {
13376       baseMerge(object, source, srcIndex);
13377     });
13378
13379     /**
13380      * This method is like `_.merge` except that it accepts `customizer` which
13381      * is invoked to produce the merged values of the destination and source
13382      * properties. If `customizer` returns `undefined`, merging is handled by the
13383      * method instead. The `customizer` is invoked with six arguments:
13384      * (objValue, srcValue, key, object, source, stack).
13385      *
13386      * **Note:** This method mutates `object`.
13387      *
13388      * @static
13389      * @memberOf _
13390      * @since 4.0.0
13391      * @category Object
13392      * @param {Object} object The destination object.
13393      * @param {...Object} sources The source objects.
13394      * @param {Function} customizer The function to customize assigned values.
13395      * @returns {Object} Returns `object`.
13396      * @example
13397      *
13398      * function customizer(objValue, srcValue) {
13399      *   if (_.isArray(objValue)) {
13400      *     return objValue.concat(srcValue);
13401      *   }
13402      * }
13403      *
13404      * var object = { 'a': [1], 'b': [2] };
13405      * var other = { 'a': [3], 'b': [4] };
13406      *
13407      * _.mergeWith(object, other, customizer);
13408      * // => { 'a': [1, 3], 'b': [2, 4] }
13409      */
13410     var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13411       baseMerge(object, source, srcIndex, customizer);
13412     });
13413
13414     /**
13415      * The opposite of `_.pick`; this method creates an object composed of the
13416      * own and inherited enumerable string keyed properties of `object` that are
13417      * not omitted.
13418      *
13419      * @static
13420      * @since 0.1.0
13421      * @memberOf _
13422      * @category Object
13423      * @param {Object} object The source object.
13424      * @param {...(string|string[])} [props] The property identifiers to omit.
13425      * @returns {Object} Returns the new object.
13426      * @example
13427      *
13428      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13429      *
13430      * _.omit(object, ['a', 'c']);
13431      * // => { 'b': '2' }
13432      */
13433     var omit = flatRest(function(object, props) {
13434       if (object == null) {
13435         return {};
13436       }
13437       props = arrayMap(props, toKey);
13438       return basePick(object, baseDifference(getAllKeysIn(object), props));
13439     });
13440
13441     /**
13442      * The opposite of `_.pickBy`; this method creates an object composed of
13443      * the own and inherited enumerable string keyed properties of `object` that
13444      * `predicate` doesn't return truthy for. The predicate is invoked with two
13445      * arguments: (value, key).
13446      *
13447      * @static
13448      * @memberOf _
13449      * @since 4.0.0
13450      * @category Object
13451      * @param {Object} object The source object.
13452      * @param {Function} [predicate=_.identity] The function invoked per property.
13453      * @returns {Object} Returns the new object.
13454      * @example
13455      *
13456      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13457      *
13458      * _.omitBy(object, _.isNumber);
13459      * // => { 'b': '2' }
13460      */
13461     function omitBy(object, predicate) {
13462       return pickBy(object, negate(getIteratee(predicate)));
13463     }
13464
13465     /**
13466      * Creates an object composed of the picked `object` properties.
13467      *
13468      * @static
13469      * @since 0.1.0
13470      * @memberOf _
13471      * @category Object
13472      * @param {Object} object The source object.
13473      * @param {...(string|string[])} [props] The property identifiers to pick.
13474      * @returns {Object} Returns the new object.
13475      * @example
13476      *
13477      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13478      *
13479      * _.pick(object, ['a', 'c']);
13480      * // => { 'a': 1, 'c': 3 }
13481      */
13482     var pick = flatRest(function(object, props) {
13483       return object == null ? {} : basePick(object, arrayMap(props, toKey));
13484     });
13485
13486     /**
13487      * Creates an object composed of the `object` properties `predicate` returns
13488      * truthy for. The predicate is invoked with two arguments: (value, key).
13489      *
13490      * @static
13491      * @memberOf _
13492      * @since 4.0.0
13493      * @category Object
13494      * @param {Object} object The source object.
13495      * @param {Function} [predicate=_.identity] The function invoked per property.
13496      * @returns {Object} Returns the new object.
13497      * @example
13498      *
13499      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13500      *
13501      * _.pickBy(object, _.isNumber);
13502      * // => { 'a': 1, 'c': 3 }
13503      */
13504     function pickBy(object, predicate) {
13505       return object == null ? {} : basePickBy(object, getAllKeysIn(object), getIteratee(predicate));
13506     }
13507
13508     /**
13509      * This method is like `_.get` except that if the resolved value is a
13510      * function it's invoked with the `this` binding of its parent object and
13511      * its result is returned.
13512      *
13513      * @static
13514      * @since 0.1.0
13515      * @memberOf _
13516      * @category Object
13517      * @param {Object} object The object to query.
13518      * @param {Array|string} path The path of the property to resolve.
13519      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13520      * @returns {*} Returns the resolved value.
13521      * @example
13522      *
13523      * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13524      *
13525      * _.result(object, 'a[0].b.c1');
13526      * // => 3
13527      *
13528      * _.result(object, 'a[0].b.c2');
13529      * // => 4
13530      *
13531      * _.result(object, 'a[0].b.c3', 'default');
13532      * // => 'default'
13533      *
13534      * _.result(object, 'a[0].b.c3', _.constant('default'));
13535      * // => 'default'
13536      */
13537     function result(object, path, defaultValue) {
13538       path = isKey(path, object) ? [path] : castPath(path);
13539
13540       var index = -1,
13541           length = path.length;
13542
13543       // Ensure the loop is entered when path is empty.
13544       if (!length) {
13545         object = undefined;
13546         length = 1;
13547       }
13548       while (++index < length) {
13549         var value = object == null ? undefined : object[toKey(path[index])];
13550         if (value === undefined) {
13551           index = length;
13552           value = defaultValue;
13553         }
13554         object = isFunction(value) ? value.call(object) : value;
13555       }
13556       return object;
13557     }
13558
13559     /**
13560      * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
13561      * it's created. Arrays are created for missing index properties while objects
13562      * are created for all other missing properties. Use `_.setWith` to customize
13563      * `path` creation.
13564      *
13565      * **Note:** This method mutates `object`.
13566      *
13567      * @static
13568      * @memberOf _
13569      * @since 3.7.0
13570      * @category Object
13571      * @param {Object} object The object to modify.
13572      * @param {Array|string} path The path of the property to set.
13573      * @param {*} value The value to set.
13574      * @returns {Object} Returns `object`.
13575      * @example
13576      *
13577      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13578      *
13579      * _.set(object, 'a[0].b.c', 4);
13580      * console.log(object.a[0].b.c);
13581      * // => 4
13582      *
13583      * _.set(object, ['x', '0', 'y', 'z'], 5);
13584      * console.log(object.x[0].y.z);
13585      * // => 5
13586      */
13587     function set(object, path, value) {
13588       return object == null ? object : baseSet(object, path, value);
13589     }
13590
13591     /**
13592      * This method is like `_.set` except that it accepts `customizer` which is
13593      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13594      * path creation is handled by the method instead. The `customizer` is invoked
13595      * with three arguments: (nsValue, key, nsObject).
13596      *
13597      * **Note:** This method mutates `object`.
13598      *
13599      * @static
13600      * @memberOf _
13601      * @since 4.0.0
13602      * @category Object
13603      * @param {Object} object The object to modify.
13604      * @param {Array|string} path The path of the property to set.
13605      * @param {*} value The value to set.
13606      * @param {Function} [customizer] The function to customize assigned values.
13607      * @returns {Object} Returns `object`.
13608      * @example
13609      *
13610      * var object = {};
13611      *
13612      * _.setWith(object, '[0][1]', 'a', Object);
13613      * // => { '0': { '1': 'a' } }
13614      */
13615     function setWith(object, path, value, customizer) {
13616       customizer = typeof customizer == 'function' ? customizer : undefined;
13617       return object == null ? object : baseSet(object, path, value, customizer);
13618     }
13619
13620     /**
13621      * Creates an array of own enumerable string keyed-value pairs for `object`
13622      * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
13623      * entries are returned.
13624      *
13625      * @static
13626      * @memberOf _
13627      * @since 4.0.0
13628      * @alias entries
13629      * @category Object
13630      * @param {Object} object The object to query.
13631      * @returns {Array} Returns the key-value pairs.
13632      * @example
13633      *
13634      * function Foo() {
13635      *   this.a = 1;
13636      *   this.b = 2;
13637      * }
13638      *
13639      * Foo.prototype.c = 3;
13640      *
13641      * _.toPairs(new Foo);
13642      * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
13643      */
13644     var toPairs = createToPairs(keys);
13645
13646     /**
13647      * Creates an array of own and inherited enumerable string keyed-value pairs
13648      * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
13649      * or set, its entries are returned.
13650      *
13651      * @static
13652      * @memberOf _
13653      * @since 4.0.0
13654      * @alias entriesIn
13655      * @category Object
13656      * @param {Object} object The object to query.
13657      * @returns {Array} Returns the key-value pairs.
13658      * @example
13659      *
13660      * function Foo() {
13661      *   this.a = 1;
13662      *   this.b = 2;
13663      * }
13664      *
13665      * Foo.prototype.c = 3;
13666      *
13667      * _.toPairsIn(new Foo);
13668      * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
13669      */
13670     var toPairsIn = createToPairs(keysIn);
13671
13672     /**
13673      * An alternative to `_.reduce`; this method transforms `object` to a new
13674      * `accumulator` object which is the result of running each of its own
13675      * enumerable string keyed properties thru `iteratee`, with each invocation
13676      * potentially mutating the `accumulator` object. If `accumulator` is not
13677      * provided, a new object with the same `[[Prototype]]` will be used. The
13678      * iteratee is invoked with four arguments: (accumulator, value, key, object).
13679      * Iteratee functions may exit iteration early by explicitly returning `false`.
13680      *
13681      * @static
13682      * @memberOf _
13683      * @since 1.3.0
13684      * @category Object
13685      * @param {Object} object The object to iterate over.
13686      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13687      * @param {*} [accumulator] The custom accumulator value.
13688      * @returns {*} Returns the accumulated value.
13689      * @example
13690      *
13691      * _.transform([2, 3, 4], function(result, n) {
13692      *   result.push(n *= n);
13693      *   return n % 2 == 0;
13694      * }, []);
13695      * // => [4, 9]
13696      *
13697      * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
13698      *   (result[value] || (result[value] = [])).push(key);
13699      * }, {});
13700      * // => { '1': ['a', 'c'], '2': ['b'] }
13701      */
13702     function transform(object, iteratee, accumulator) {
13703       var isArr = isArray(object),
13704           isArrLike = isArr || isBuffer(object) || isTypedArray(object);
13705
13706       iteratee = getIteratee(iteratee, 4);
13707       if (accumulator == null) {
13708         var Ctor = object && object.constructor;
13709         if (isArrLike) {
13710           accumulator = isArr ? new Ctor : [];
13711         }
13712         else if (isObject(object)) {
13713           accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
13714         }
13715         else {
13716           accumulator = {};
13717         }
13718       }
13719       (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
13720         return iteratee(accumulator, value, index, object);
13721       });
13722       return accumulator;
13723     }
13724
13725     /**
13726      * Removes the property at `path` of `object`.
13727      *
13728      * **Note:** This method mutates `object`.
13729      *
13730      * @static
13731      * @memberOf _
13732      * @since 4.0.0
13733      * @category Object
13734      * @param {Object} object The object to modify.
13735      * @param {Array|string} path The path of the property to unset.
13736      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
13737      * @example
13738      *
13739      * var object = { 'a': [{ 'b': { 'c': 7 } }] };
13740      * _.unset(object, 'a[0].b.c');
13741      * // => true
13742      *
13743      * console.log(object);
13744      * // => { 'a': [{ 'b': {} }] };
13745      *
13746      * _.unset(object, ['a', '0', 'b', 'c']);
13747      * // => true
13748      *
13749      * console.log(object);
13750      * // => { 'a': [{ 'b': {} }] };
13751      */
13752     function unset(object, path) {
13753       return object == null ? true : baseUnset(object, path);
13754     }
13755
13756     /**
13757      * This method is like `_.set` except that accepts `updater` to produce the
13758      * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
13759      * is invoked with one argument: (value).
13760      *
13761      * **Note:** This method mutates `object`.
13762      *
13763      * @static
13764      * @memberOf _
13765      * @since 4.6.0
13766      * @category Object
13767      * @param {Object} object The object to modify.
13768      * @param {Array|string} path The path of the property to set.
13769      * @param {Function} updater The function to produce the updated value.
13770      * @returns {Object} Returns `object`.
13771      * @example
13772      *
13773      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13774      *
13775      * _.update(object, 'a[0].b.c', function(n) { return n * n; });
13776      * console.log(object.a[0].b.c);
13777      * // => 9
13778      *
13779      * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
13780      * console.log(object.x[0].y.z);
13781      * // => 0
13782      */
13783     function update(object, path, updater) {
13784       return object == null ? object : baseUpdate(object, path, castFunction(updater));
13785     }
13786
13787     /**
13788      * This method is like `_.update` except that it accepts `customizer` which is
13789      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13790      * path creation is handled by the method instead. The `customizer` is invoked
13791      * with three arguments: (nsValue, key, nsObject).
13792      *
13793      * **Note:** This method mutates `object`.
13794      *
13795      * @static
13796      * @memberOf _
13797      * @since 4.6.0
13798      * @category Object
13799      * @param {Object} object The object to modify.
13800      * @param {Array|string} path The path of the property to set.
13801      * @param {Function} updater The function to produce the updated value.
13802      * @param {Function} [customizer] The function to customize assigned values.
13803      * @returns {Object} Returns `object`.
13804      * @example
13805      *
13806      * var object = {};
13807      *
13808      * _.updateWith(object, '[0][1]', _.constant('a'), Object);
13809      * // => { '0': { '1': 'a' } }
13810      */
13811     function updateWith(object, path, updater, customizer) {
13812       customizer = typeof customizer == 'function' ? customizer : undefined;
13813       return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
13814     }
13815
13816     /**
13817      * Creates an array of the own enumerable string keyed property values of `object`.
13818      *
13819      * **Note:** Non-object values are coerced to objects.
13820      *
13821      * @static
13822      * @since 0.1.0
13823      * @memberOf _
13824      * @category Object
13825      * @param {Object} object The object to query.
13826      * @returns {Array} Returns the array of property values.
13827      * @example
13828      *
13829      * function Foo() {
13830      *   this.a = 1;
13831      *   this.b = 2;
13832      * }
13833      *
13834      * Foo.prototype.c = 3;
13835      *
13836      * _.values(new Foo);
13837      * // => [1, 2] (iteration order is not guaranteed)
13838      *
13839      * _.values('hi');
13840      * // => ['h', 'i']
13841      */
13842     function values(object) {
13843       return object == null ? [] : baseValues(object, keys(object));
13844     }
13845
13846     /**
13847      * Creates an array of the own and inherited enumerable string keyed property
13848      * values of `object`.
13849      *
13850      * **Note:** Non-object values are coerced to objects.
13851      *
13852      * @static
13853      * @memberOf _
13854      * @since 3.0.0
13855      * @category Object
13856      * @param {Object} object The object to query.
13857      * @returns {Array} Returns the array of property values.
13858      * @example
13859      *
13860      * function Foo() {
13861      *   this.a = 1;
13862      *   this.b = 2;
13863      * }
13864      *
13865      * Foo.prototype.c = 3;
13866      *
13867      * _.valuesIn(new Foo);
13868      * // => [1, 2, 3] (iteration order is not guaranteed)
13869      */
13870     function valuesIn(object) {
13871       return object == null ? [] : baseValues(object, keysIn(object));
13872     }
13873
13874     /*------------------------------------------------------------------------*/
13875
13876     /**
13877      * Clamps `number` within the inclusive `lower` and `upper` bounds.
13878      *
13879      * @static
13880      * @memberOf _
13881      * @since 4.0.0
13882      * @category Number
13883      * @param {number} number The number to clamp.
13884      * @param {number} [lower] The lower bound.
13885      * @param {number} upper The upper bound.
13886      * @returns {number} Returns the clamped number.
13887      * @example
13888      *
13889      * _.clamp(-10, -5, 5);
13890      * // => -5
13891      *
13892      * _.clamp(10, -5, 5);
13893      * // => 5
13894      */
13895     function clamp(number, lower, upper) {
13896       if (upper === undefined) {
13897         upper = lower;
13898         lower = undefined;
13899       }
13900       if (upper !== undefined) {
13901         upper = toNumber(upper);
13902         upper = upper === upper ? upper : 0;
13903       }
13904       if (lower !== undefined) {
13905         lower = toNumber(lower);
13906         lower = lower === lower ? lower : 0;
13907       }
13908       return baseClamp(toNumber(number), lower, upper);
13909     }
13910
13911     /**
13912      * Checks if `n` is between `start` and up to, but not including, `end`. If
13913      * `end` is not specified, it's set to `start` with `start` then set to `0`.
13914      * If `start` is greater than `end` the params are swapped to support
13915      * negative ranges.
13916      *
13917      * @static
13918      * @memberOf _
13919      * @since 3.3.0
13920      * @category Number
13921      * @param {number} number The number to check.
13922      * @param {number} [start=0] The start of the range.
13923      * @param {number} end The end of the range.
13924      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
13925      * @see _.range, _.rangeRight
13926      * @example
13927      *
13928      * _.inRange(3, 2, 4);
13929      * // => true
13930      *
13931      * _.inRange(4, 8);
13932      * // => true
13933      *
13934      * _.inRange(4, 2);
13935      * // => false
13936      *
13937      * _.inRange(2, 2);
13938      * // => false
13939      *
13940      * _.inRange(1.2, 2);
13941      * // => true
13942      *
13943      * _.inRange(5.2, 4);
13944      * // => false
13945      *
13946      * _.inRange(-3, -2, -6);
13947      * // => true
13948      */
13949     function inRange(number, start, end) {
13950       start = toFinite(start);
13951       if (end === undefined) {
13952         end = start;
13953         start = 0;
13954       } else {
13955         end = toFinite(end);
13956       }
13957       number = toNumber(number);
13958       return baseInRange(number, start, end);
13959     }
13960
13961     /**
13962      * Produces a random number between the inclusive `lower` and `upper` bounds.
13963      * If only one argument is provided a number between `0` and the given number
13964      * is returned. If `floating` is `true`, or either `lower` or `upper` are
13965      * floats, a floating-point number is returned instead of an integer.
13966      *
13967      * **Note:** JavaScript follows the IEEE-754 standard for resolving
13968      * floating-point values which can produce unexpected results.
13969      *
13970      * @static
13971      * @memberOf _
13972      * @since 0.7.0
13973      * @category Number
13974      * @param {number} [lower=0] The lower bound.
13975      * @param {number} [upper=1] The upper bound.
13976      * @param {boolean} [floating] Specify returning a floating-point number.
13977      * @returns {number} Returns the random number.
13978      * @example
13979      *
13980      * _.random(0, 5);
13981      * // => an integer between 0 and 5
13982      *
13983      * _.random(5);
13984      * // => also an integer between 0 and 5
13985      *
13986      * _.random(5, true);
13987      * // => a floating-point number between 0 and 5
13988      *
13989      * _.random(1.2, 5.2);
13990      * // => a floating-point number between 1.2 and 5.2
13991      */
13992     function random(lower, upper, floating) {
13993       if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
13994         upper = floating = undefined;
13995       }
13996       if (floating === undefined) {
13997         if (typeof upper == 'boolean') {
13998           floating = upper;
13999           upper = undefined;
14000         }
14001         else if (typeof lower == 'boolean') {
14002           floating = lower;
14003           lower = undefined;
14004         }
14005       }
14006       if (lower === undefined && upper === undefined) {
14007         lower = 0;
14008         upper = 1;
14009       }
14010       else {
14011         lower = toFinite(lower);
14012         if (upper === undefined) {
14013           upper = lower;
14014           lower = 0;
14015         } else {
14016           upper = toFinite(upper);
14017         }
14018       }
14019       if (lower > upper) {
14020         var temp = lower;
14021         lower = upper;
14022         upper = temp;
14023       }
14024       if (floating || lower % 1 || upper % 1) {
14025         var rand = nativeRandom();
14026         return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14027       }
14028       return baseRandom(lower, upper);
14029     }
14030
14031     /*------------------------------------------------------------------------*/
14032
14033     /**
14034      * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14035      *
14036      * @static
14037      * @memberOf _
14038      * @since 3.0.0
14039      * @category String
14040      * @param {string} [string=''] The string to convert.
14041      * @returns {string} Returns the camel cased string.
14042      * @example
14043      *
14044      * _.camelCase('Foo Bar');
14045      * // => 'fooBar'
14046      *
14047      * _.camelCase('--foo-bar--');
14048      * // => 'fooBar'
14049      *
14050      * _.camelCase('__FOO_BAR__');
14051      * // => 'fooBar'
14052      */
14053     var camelCase = createCompounder(function(result, word, index) {
14054       word = word.toLowerCase();
14055       return result + (index ? capitalize(word) : word);
14056     });
14057
14058     /**
14059      * Converts the first character of `string` to upper case and the remaining
14060      * to lower case.
14061      *
14062      * @static
14063      * @memberOf _
14064      * @since 3.0.0
14065      * @category String
14066      * @param {string} [string=''] The string to capitalize.
14067      * @returns {string} Returns the capitalized string.
14068      * @example
14069      *
14070      * _.capitalize('FRED');
14071      * // => 'Fred'
14072      */
14073     function capitalize(string) {
14074       return upperFirst(toString(string).toLowerCase());
14075     }
14076
14077     /**
14078      * Deburrs `string` by converting
14079      * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
14080      * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
14081      * letters to basic Latin letters and removing
14082      * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
14083      *
14084      * @static
14085      * @memberOf _
14086      * @since 3.0.0
14087      * @category String
14088      * @param {string} [string=''] The string to deburr.
14089      * @returns {string} Returns the deburred string.
14090      * @example
14091      *
14092      * _.deburr('déjà vu');
14093      * // => 'deja vu'
14094      */
14095     function deburr(string) {
14096       string = toString(string);
14097       return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14098     }
14099
14100     /**
14101      * Checks if `string` ends with the given target string.
14102      *
14103      * @static
14104      * @memberOf _
14105      * @since 3.0.0
14106      * @category String
14107      * @param {string} [string=''] The string to inspect.
14108      * @param {string} [target] The string to search for.
14109      * @param {number} [position=string.length] The position to search up to.
14110      * @returns {boolean} Returns `true` if `string` ends with `target`,
14111      *  else `false`.
14112      * @example
14113      *
14114      * _.endsWith('abc', 'c');
14115      * // => true
14116      *
14117      * _.endsWith('abc', 'b');
14118      * // => false
14119      *
14120      * _.endsWith('abc', 'b', 2);
14121      * // => true
14122      */
14123     function endsWith(string, target, position) {
14124       string = toString(string);
14125       target = baseToString(target);
14126
14127       var length = string.length;
14128       position = position === undefined
14129         ? length
14130         : baseClamp(toInteger(position), 0, length);
14131
14132       var end = position;
14133       position -= target.length;
14134       return position >= 0 && string.slice(position, end) == target;
14135     }
14136
14137     /**
14138      * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14139      * corresponding HTML entities.
14140      *
14141      * **Note:** No other characters are escaped. To escape additional
14142      * characters use a third-party library like [_he_](https://mths.be/he).
14143      *
14144      * Though the ">" character is escaped for symmetry, characters like
14145      * ">" and "/" don't need escaping in HTML and have no special meaning
14146      * unless they're part of a tag or unquoted attribute value. See
14147      * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
14148      * (under "semi-related fun fact") for more details.
14149      *
14150      * When working with HTML you should always
14151      * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14152      * XSS vectors.
14153      *
14154      * @static
14155      * @since 0.1.0
14156      * @memberOf _
14157      * @category String
14158      * @param {string} [string=''] The string to escape.
14159      * @returns {string} Returns the escaped string.
14160      * @example
14161      *
14162      * _.escape('fred, barney, & pebbles');
14163      * // => 'fred, barney, &amp; pebbles'
14164      */
14165     function escape(string) {
14166       string = toString(string);
14167       return (string && reHasUnescapedHtml.test(string))
14168         ? string.replace(reUnescapedHtml, escapeHtmlChar)
14169         : string;
14170     }
14171
14172     /**
14173      * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14174      * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14175      *
14176      * @static
14177      * @memberOf _
14178      * @since 3.0.0
14179      * @category String
14180      * @param {string} [string=''] The string to escape.
14181      * @returns {string} Returns the escaped string.
14182      * @example
14183      *
14184      * _.escapeRegExp('[lodash](https://lodash.com/)');
14185      * // => '\[lodash\]\(https://lodash\.com/\)'
14186      */
14187     function escapeRegExp(string) {
14188       string = toString(string);
14189       return (string && reHasRegExpChar.test(string))
14190         ? string.replace(reRegExpChar, '\\$&')
14191         : string;
14192     }
14193
14194     /**
14195      * Converts `string` to
14196      * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14197      *
14198      * @static
14199      * @memberOf _
14200      * @since 3.0.0
14201      * @category String
14202      * @param {string} [string=''] The string to convert.
14203      * @returns {string} Returns the kebab cased string.
14204      * @example
14205      *
14206      * _.kebabCase('Foo Bar');
14207      * // => 'foo-bar'
14208      *
14209      * _.kebabCase('fooBar');
14210      * // => 'foo-bar'
14211      *
14212      * _.kebabCase('__FOO_BAR__');
14213      * // => 'foo-bar'
14214      */
14215     var kebabCase = createCompounder(function(result, word, index) {
14216       return result + (index ? '-' : '') + word.toLowerCase();
14217     });
14218
14219     /**
14220      * Converts `string`, as space separated words, to lower case.
14221      *
14222      * @static
14223      * @memberOf _
14224      * @since 4.0.0
14225      * @category String
14226      * @param {string} [string=''] The string to convert.
14227      * @returns {string} Returns the lower cased string.
14228      * @example
14229      *
14230      * _.lowerCase('--Foo-Bar--');
14231      * // => 'foo bar'
14232      *
14233      * _.lowerCase('fooBar');
14234      * // => 'foo bar'
14235      *
14236      * _.lowerCase('__FOO_BAR__');
14237      * // => 'foo bar'
14238      */
14239     var lowerCase = createCompounder(function(result, word, index) {
14240       return result + (index ? ' ' : '') + word.toLowerCase();
14241     });
14242
14243     /**
14244      * Converts the first character of `string` to lower case.
14245      *
14246      * @static
14247      * @memberOf _
14248      * @since 4.0.0
14249      * @category String
14250      * @param {string} [string=''] The string to convert.
14251      * @returns {string} Returns the converted string.
14252      * @example
14253      *
14254      * _.lowerFirst('Fred');
14255      * // => 'fred'
14256      *
14257      * _.lowerFirst('FRED');
14258      * // => 'fRED'
14259      */
14260     var lowerFirst = createCaseFirst('toLowerCase');
14261
14262     /**
14263      * Pads `string` on the left and right sides if it's shorter than `length`.
14264      * Padding characters are truncated if they can't be evenly divided by `length`.
14265      *
14266      * @static
14267      * @memberOf _
14268      * @since 3.0.0
14269      * @category String
14270      * @param {string} [string=''] The string to pad.
14271      * @param {number} [length=0] The padding length.
14272      * @param {string} [chars=' '] The string used as padding.
14273      * @returns {string} Returns the padded string.
14274      * @example
14275      *
14276      * _.pad('abc', 8);
14277      * // => '  abc   '
14278      *
14279      * _.pad('abc', 8, '_-');
14280      * // => '_-abc_-_'
14281      *
14282      * _.pad('abc', 3);
14283      * // => 'abc'
14284      */
14285     function pad(string, length, chars) {
14286       string = toString(string);
14287       length = toInteger(length);
14288
14289       var strLength = length ? stringSize(string) : 0;
14290       if (!length || strLength >= length) {
14291         return string;
14292       }
14293       var mid = (length - strLength) / 2;
14294       return (
14295         createPadding(nativeFloor(mid), chars) +
14296         string +
14297         createPadding(nativeCeil(mid), chars)
14298       );
14299     }
14300
14301     /**
14302      * Pads `string` on the right side if it's shorter than `length`. Padding
14303      * characters are truncated if they exceed `length`.
14304      *
14305      * @static
14306      * @memberOf _
14307      * @since 4.0.0
14308      * @category String
14309      * @param {string} [string=''] The string to pad.
14310      * @param {number} [length=0] The padding length.
14311      * @param {string} [chars=' '] The string used as padding.
14312      * @returns {string} Returns the padded string.
14313      * @example
14314      *
14315      * _.padEnd('abc', 6);
14316      * // => 'abc   '
14317      *
14318      * _.padEnd('abc', 6, '_-');
14319      * // => 'abc_-_'
14320      *
14321      * _.padEnd('abc', 3);
14322      * // => 'abc'
14323      */
14324     function padEnd(string, length, chars) {
14325       string = toString(string);
14326       length = toInteger(length);
14327
14328       var strLength = length ? stringSize(string) : 0;
14329       return (length && strLength < length)
14330         ? (string + createPadding(length - strLength, chars))
14331         : string;
14332     }
14333
14334     /**
14335      * Pads `string` on the left side if it's shorter than `length`. Padding
14336      * characters are truncated if they exceed `length`.
14337      *
14338      * @static
14339      * @memberOf _
14340      * @since 4.0.0
14341      * @category String
14342      * @param {string} [string=''] The string to pad.
14343      * @param {number} [length=0] The padding length.
14344      * @param {string} [chars=' '] The string used as padding.
14345      * @returns {string} Returns the padded string.
14346      * @example
14347      *
14348      * _.padStart('abc', 6);
14349      * // => '   abc'
14350      *
14351      * _.padStart('abc', 6, '_-');
14352      * // => '_-_abc'
14353      *
14354      * _.padStart('abc', 3);
14355      * // => 'abc'
14356      */
14357     function padStart(string, length, chars) {
14358       string = toString(string);
14359       length = toInteger(length);
14360
14361       var strLength = length ? stringSize(string) : 0;
14362       return (length && strLength < length)
14363         ? (createPadding(length - strLength, chars) + string)
14364         : string;
14365     }
14366
14367     /**
14368      * Converts `string` to an integer of the specified radix. If `radix` is
14369      * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
14370      * hexadecimal, in which case a `radix` of `16` is used.
14371      *
14372      * **Note:** This method aligns with the
14373      * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
14374      *
14375      * @static
14376      * @memberOf _
14377      * @since 1.1.0
14378      * @category String
14379      * @param {string} string The string to convert.
14380      * @param {number} [radix=10] The radix to interpret `value` by.
14381      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14382      * @returns {number} Returns the converted integer.
14383      * @example
14384      *
14385      * _.parseInt('08');
14386      * // => 8
14387      *
14388      * _.map(['6', '08', '10'], _.parseInt);
14389      * // => [6, 8, 10]
14390      */
14391     function parseInt(string, radix, guard) {
14392       if (guard || radix == null) {
14393         radix = 0;
14394       } else if (radix) {
14395         radix = +radix;
14396       }
14397       return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14398     }
14399
14400     /**
14401      * Repeats the given string `n` times.
14402      *
14403      * @static
14404      * @memberOf _
14405      * @since 3.0.0
14406      * @category String
14407      * @param {string} [string=''] The string to repeat.
14408      * @param {number} [n=1] The number of times to repeat the string.
14409      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14410      * @returns {string} Returns the repeated string.
14411      * @example
14412      *
14413      * _.repeat('*', 3);
14414      * // => '***'
14415      *
14416      * _.repeat('abc', 2);
14417      * // => 'abcabc'
14418      *
14419      * _.repeat('abc', 0);
14420      * // => ''
14421      */
14422     function repeat(string, n, guard) {
14423       if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
14424         n = 1;
14425       } else {
14426         n = toInteger(n);
14427       }
14428       return baseRepeat(toString(string), n);
14429     }
14430
14431     /**
14432      * Replaces matches for `pattern` in `string` with `replacement`.
14433      *
14434      * **Note:** This method is based on
14435      * [`String#replace`](https://mdn.io/String/replace).
14436      *
14437      * @static
14438      * @memberOf _
14439      * @since 4.0.0
14440      * @category String
14441      * @param {string} [string=''] The string to modify.
14442      * @param {RegExp|string} pattern The pattern to replace.
14443      * @param {Function|string} replacement The match replacement.
14444      * @returns {string} Returns the modified string.
14445      * @example
14446      *
14447      * _.replace('Hi Fred', 'Fred', 'Barney');
14448      * // => 'Hi Barney'
14449      */
14450     function replace() {
14451       var args = arguments,
14452           string = toString(args[0]);
14453
14454       return args.length < 3 ? string : string.replace(args[1], args[2]);
14455     }
14456
14457     /**
14458      * Converts `string` to
14459      * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14460      *
14461      * @static
14462      * @memberOf _
14463      * @since 3.0.0
14464      * @category String
14465      * @param {string} [string=''] The string to convert.
14466      * @returns {string} Returns the snake cased string.
14467      * @example
14468      *
14469      * _.snakeCase('Foo Bar');
14470      * // => 'foo_bar'
14471      *
14472      * _.snakeCase('fooBar');
14473      * // => 'foo_bar'
14474      *
14475      * _.snakeCase('--FOO-BAR--');
14476      * // => 'foo_bar'
14477      */
14478     var snakeCase = createCompounder(function(result, word, index) {
14479       return result + (index ? '_' : '') + word.toLowerCase();
14480     });
14481
14482     /**
14483      * Splits `string` by `separator`.
14484      *
14485      * **Note:** This method is based on
14486      * [`String#split`](https://mdn.io/String/split).
14487      *
14488      * @static
14489      * @memberOf _
14490      * @since 4.0.0
14491      * @category String
14492      * @param {string} [string=''] The string to split.
14493      * @param {RegExp|string} separator The separator pattern to split by.
14494      * @param {number} [limit] The length to truncate results to.
14495      * @returns {Array} Returns the string segments.
14496      * @example
14497      *
14498      * _.split('a-b-c', '-', 2);
14499      * // => ['a', 'b']
14500      */
14501     function split(string, separator, limit) {
14502       if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14503         separator = limit = undefined;
14504       }
14505       limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
14506       if (!limit) {
14507         return [];
14508       }
14509       string = toString(string);
14510       if (string && (
14511             typeof separator == 'string' ||
14512             (separator != null && !isRegExp(separator))
14513           )) {
14514         separator = baseToString(separator);
14515         if (!separator && hasUnicode(string)) {
14516           return castSlice(stringToArray(string), 0, limit);
14517         }
14518       }
14519       return string.split(separator, limit);
14520     }
14521
14522     /**
14523      * Converts `string` to
14524      * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14525      *
14526      * @static
14527      * @memberOf _
14528      * @since 3.1.0
14529      * @category String
14530      * @param {string} [string=''] The string to convert.
14531      * @returns {string} Returns the start cased string.
14532      * @example
14533      *
14534      * _.startCase('--foo-bar--');
14535      * // => 'Foo Bar'
14536      *
14537      * _.startCase('fooBar');
14538      * // => 'Foo Bar'
14539      *
14540      * _.startCase('__FOO_BAR__');
14541      * // => 'FOO BAR'
14542      */
14543     var startCase = createCompounder(function(result, word, index) {
14544       return result + (index ? ' ' : '') + upperFirst(word);
14545     });
14546
14547     /**
14548      * Checks if `string` starts with the given target string.
14549      *
14550      * @static
14551      * @memberOf _
14552      * @since 3.0.0
14553      * @category String
14554      * @param {string} [string=''] The string to inspect.
14555      * @param {string} [target] The string to search for.
14556      * @param {number} [position=0] The position to search from.
14557      * @returns {boolean} Returns `true` if `string` starts with `target`,
14558      *  else `false`.
14559      * @example
14560      *
14561      * _.startsWith('abc', 'a');
14562      * // => true
14563      *
14564      * _.startsWith('abc', 'b');
14565      * // => false
14566      *
14567      * _.startsWith('abc', 'b', 1);
14568      * // => true
14569      */
14570     function startsWith(string, target, position) {
14571       string = toString(string);
14572       position = baseClamp(toInteger(position), 0, string.length);
14573       target = baseToString(target);
14574       return string.slice(position, position + target.length) == target;
14575     }
14576
14577     /**
14578      * Creates a compiled template function that can interpolate data properties
14579      * in "interpolate" delimiters, HTML-escape interpolated data properties in
14580      * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
14581      * properties may be accessed as free variables in the template. If a setting
14582      * object is given, it takes precedence over `_.templateSettings` values.
14583      *
14584      * **Note:** In the development build `_.template` utilizes
14585      * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
14586      * for easier debugging.
14587      *
14588      * For more information on precompiling templates see
14589      * [lodash's custom builds documentation](https://lodash.com/custom-builds).
14590      *
14591      * For more information on Chrome extension sandboxes see
14592      * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
14593      *
14594      * @static
14595      * @since 0.1.0
14596      * @memberOf _
14597      * @category String
14598      * @param {string} [string=''] The template string.
14599      * @param {Object} [options={}] The options object.
14600      * @param {RegExp} [options.escape=_.templateSettings.escape]
14601      *  The HTML "escape" delimiter.
14602      * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
14603      *  The "evaluate" delimiter.
14604      * @param {Object} [options.imports=_.templateSettings.imports]
14605      *  An object to import into the template as free variables.
14606      * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
14607      *  The "interpolate" delimiter.
14608      * @param {string} [options.sourceURL='lodash.templateSources[n]']
14609      *  The sourceURL of the compiled template.
14610      * @param {string} [options.variable='obj']
14611      *  The data object variable name.
14612      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14613      * @returns {Function} Returns the compiled template function.
14614      * @example
14615      *
14616      * // Use the "interpolate" delimiter to create a compiled template.
14617      * var compiled = _.template('hello <%= user %>!');
14618      * compiled({ 'user': 'fred' });
14619      * // => 'hello fred!'
14620      *
14621      * // Use the HTML "escape" delimiter to escape data property values.
14622      * var compiled = _.template('<b><%- value %></b>');
14623      * compiled({ 'value': '<script>' });
14624      * // => '<b>&lt;script&gt;</b>'
14625      *
14626      * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
14627      * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
14628      * compiled({ 'users': ['fred', 'barney'] });
14629      * // => '<li>fred</li><li>barney</li>'
14630      *
14631      * // Use the internal `print` function in "evaluate" delimiters.
14632      * var compiled = _.template('<% print("hello " + user); %>!');
14633      * compiled({ 'user': 'barney' });
14634      * // => 'hello barney!'
14635      *
14636      * // Use the ES template literal delimiter as an "interpolate" delimiter.
14637      * // Disable support by replacing the "interpolate" delimiter.
14638      * var compiled = _.template('hello ${ user }!');
14639      * compiled({ 'user': 'pebbles' });
14640      * // => 'hello pebbles!'
14641      *
14642      * // Use backslashes to treat delimiters as plain text.
14643      * var compiled = _.template('<%= "\\<%- value %\\>" %>');
14644      * compiled({ 'value': 'ignored' });
14645      * // => '<%- value %>'
14646      *
14647      * // Use the `imports` option to import `jQuery` as `jq`.
14648      * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
14649      * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
14650      * compiled({ 'users': ['fred', 'barney'] });
14651      * // => '<li>fred</li><li>barney</li>'
14652      *
14653      * // Use the `sourceURL` option to specify a custom sourceURL for the template.
14654      * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
14655      * compiled(data);
14656      * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
14657      *
14658      * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
14659      * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
14660      * compiled.source;
14661      * // => function(data) {
14662      * //   var __t, __p = '';
14663      * //   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
14664      * //   return __p;
14665      * // }
14666      *
14667      * // Use custom template delimiters.
14668      * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
14669      * var compiled = _.template('hello {{ user }}!');
14670      * compiled({ 'user': 'mustache' });
14671      * // => 'hello mustache!'
14672      *
14673      * // Use the `source` property to inline compiled templates for meaningful
14674      * // line numbers in error messages and stack traces.
14675      * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
14676      *   var JST = {\
14677      *     "main": ' + _.template(mainText).source + '\
14678      *   };\
14679      * ');
14680      */
14681     function template(string, options, guard) {
14682       // Based on John Resig's `tmpl` implementation
14683       // (http://ejohn.org/blog/javascript-micro-templating/)
14684       // and Laura Doktorova's doT.js (https://github.com/olado/doT).
14685       var settings = lodash.templateSettings;
14686
14687       if (guard && isIterateeCall(string, options, guard)) {
14688         options = undefined;
14689       }
14690       string = toString(string);
14691       options = assignInWith({}, options, settings, assignInDefaults);
14692
14693       var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),
14694           importsKeys = keys(imports),
14695           importsValues = baseValues(imports, importsKeys);
14696
14697       var isEscaping,
14698           isEvaluating,
14699           index = 0,
14700           interpolate = options.interpolate || reNoMatch,
14701           source = "__p += '";
14702
14703       // Compile the regexp to match each delimiter.
14704       var reDelimiters = RegExp(
14705         (options.escape || reNoMatch).source + '|' +
14706         interpolate.source + '|' +
14707         (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
14708         (options.evaluate || reNoMatch).source + '|$'
14709       , 'g');
14710
14711       // Use a sourceURL for easier debugging.
14712       var sourceURL = '//# sourceURL=' +
14713         ('sourceURL' in options
14714           ? options.sourceURL
14715           : ('lodash.templateSources[' + (++templateCounter) + ']')
14716         ) + '\n';
14717
14718       string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
14719         interpolateValue || (interpolateValue = esTemplateValue);
14720
14721         // Escape characters that can't be included in string literals.
14722         source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
14723
14724         // Replace delimiters with snippets.
14725         if (escapeValue) {
14726           isEscaping = true;
14727           source += "' +\n__e(" + escapeValue + ") +\n'";
14728         }
14729         if (evaluateValue) {
14730           isEvaluating = true;
14731           source += "';\n" + evaluateValue + ";\n__p += '";
14732         }
14733         if (interpolateValue) {
14734           source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
14735         }
14736         index = offset + match.length;
14737
14738         // The JS engine embedded in Adobe products needs `match` returned in
14739         // order to produce the correct `offset` value.
14740         return match;
14741       });
14742
14743       source += "';\n";
14744
14745       // If `variable` is not specified wrap a with-statement around the generated
14746       // code to add the data object to the top of the scope chain.
14747       var variable = options.variable;
14748       if (!variable) {
14749         source = 'with (obj) {\n' + source + '\n}\n';
14750       }
14751       // Cleanup code by stripping empty strings.
14752       source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
14753         .replace(reEmptyStringMiddle, '$1')
14754         .replace(reEmptyStringTrailing, '$1;');
14755
14756       // Frame code as the function body.
14757       source = 'function(' + (variable || 'obj') + ') {\n' +
14758         (variable
14759           ? ''
14760           : 'obj || (obj = {});\n'
14761         ) +
14762         "var __t, __p = ''" +
14763         (isEscaping
14764            ? ', __e = _.escape'
14765            : ''
14766         ) +
14767         (isEvaluating
14768           ? ', __j = Array.prototype.join;\n' +
14769             "function print() { __p += __j.call(arguments, '') }\n"
14770           : ';\n'
14771         ) +
14772         source +
14773         'return __p\n}';
14774
14775       var result = attempt(function() {
14776         return Function(importsKeys, sourceURL + 'return ' + source)
14777           .apply(undefined, importsValues);
14778       });
14779
14780       // Provide the compiled function's source by its `toString` method or
14781       // the `source` property as a convenience for inlining compiled templates.
14782       result.source = source;
14783       if (isError(result)) {
14784         throw result;
14785       }
14786       return result;
14787     }
14788
14789     /**
14790      * Converts `string`, as a whole, to lower case just like
14791      * [String#toLowerCase](https://mdn.io/toLowerCase).
14792      *
14793      * @static
14794      * @memberOf _
14795      * @since 4.0.0
14796      * @category String
14797      * @param {string} [string=''] The string to convert.
14798      * @returns {string} Returns the lower cased string.
14799      * @example
14800      *
14801      * _.toLower('--Foo-Bar--');
14802      * // => '--foo-bar--'
14803      *
14804      * _.toLower('fooBar');
14805      * // => 'foobar'
14806      *
14807      * _.toLower('__FOO_BAR__');
14808      * // => '__foo_bar__'
14809      */
14810     function toLower(value) {
14811       return toString(value).toLowerCase();
14812     }
14813
14814     /**
14815      * Converts `string`, as a whole, to upper case just like
14816      * [String#toUpperCase](https://mdn.io/toUpperCase).
14817      *
14818      * @static
14819      * @memberOf _
14820      * @since 4.0.0
14821      * @category String
14822      * @param {string} [string=''] The string to convert.
14823      * @returns {string} Returns the upper cased string.
14824      * @example
14825      *
14826      * _.toUpper('--foo-bar--');
14827      * // => '--FOO-BAR--'
14828      *
14829      * _.toUpper('fooBar');
14830      * // => 'FOOBAR'
14831      *
14832      * _.toUpper('__foo_bar__');
14833      * // => '__FOO_BAR__'
14834      */
14835     function toUpper(value) {
14836       return toString(value).toUpperCase();
14837     }
14838
14839     /**
14840      * Removes leading and trailing whitespace or specified characters from `string`.
14841      *
14842      * @static
14843      * @memberOf _
14844      * @since 3.0.0
14845      * @category String
14846      * @param {string} [string=''] The string to trim.
14847      * @param {string} [chars=whitespace] The characters to trim.
14848      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14849      * @returns {string} Returns the trimmed string.
14850      * @example
14851      *
14852      * _.trim('  abc  ');
14853      * // => 'abc'
14854      *
14855      * _.trim('-_-abc-_-', '_-');
14856      * // => 'abc'
14857      *
14858      * _.map(['  foo  ', '  bar  '], _.trim);
14859      * // => ['foo', 'bar']
14860      */
14861     function trim(string, chars, guard) {
14862       string = toString(string);
14863       if (string && (guard || chars === undefined)) {
14864         return string.replace(reTrim, '');
14865       }
14866       if (!string || !(chars = baseToString(chars))) {
14867         return string;
14868       }
14869       var strSymbols = stringToArray(string),
14870           chrSymbols = stringToArray(chars),
14871           start = charsStartIndex(strSymbols, chrSymbols),
14872           end = charsEndIndex(strSymbols, chrSymbols) + 1;
14873
14874       return castSlice(strSymbols, start, end).join('');
14875     }
14876
14877     /**
14878      * Removes trailing whitespace or specified characters from `string`.
14879      *
14880      * @static
14881      * @memberOf _
14882      * @since 4.0.0
14883      * @category String
14884      * @param {string} [string=''] The string to trim.
14885      * @param {string} [chars=whitespace] The characters to trim.
14886      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14887      * @returns {string} Returns the trimmed string.
14888      * @example
14889      *
14890      * _.trimEnd('  abc  ');
14891      * // => '  abc'
14892      *
14893      * _.trimEnd('-_-abc-_-', '_-');
14894      * // => '-_-abc'
14895      */
14896     function trimEnd(string, chars, guard) {
14897       string = toString(string);
14898       if (string && (guard || chars === undefined)) {
14899         return string.replace(reTrimEnd, '');
14900       }
14901       if (!string || !(chars = baseToString(chars))) {
14902         return string;
14903       }
14904       var strSymbols = stringToArray(string),
14905           end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
14906
14907       return castSlice(strSymbols, 0, end).join('');
14908     }
14909
14910     /**
14911      * Removes leading whitespace or specified characters from `string`.
14912      *
14913      * @static
14914      * @memberOf _
14915      * @since 4.0.0
14916      * @category String
14917      * @param {string} [string=''] The string to trim.
14918      * @param {string} [chars=whitespace] The characters to trim.
14919      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14920      * @returns {string} Returns the trimmed string.
14921      * @example
14922      *
14923      * _.trimStart('  abc  ');
14924      * // => 'abc  '
14925      *
14926      * _.trimStart('-_-abc-_-', '_-');
14927      * // => 'abc-_-'
14928      */
14929     function trimStart(string, chars, guard) {
14930       string = toString(string);
14931       if (string && (guard || chars === undefined)) {
14932         return string.replace(reTrimStart, '');
14933       }
14934       if (!string || !(chars = baseToString(chars))) {
14935         return string;
14936       }
14937       var strSymbols = stringToArray(string),
14938           start = charsStartIndex(strSymbols, stringToArray(chars));
14939
14940       return castSlice(strSymbols, start).join('');
14941     }
14942
14943     /**
14944      * Truncates `string` if it's longer than the given maximum string length.
14945      * The last characters of the truncated string are replaced with the omission
14946      * string which defaults to "...".
14947      *
14948      * @static
14949      * @memberOf _
14950      * @since 4.0.0
14951      * @category String
14952      * @param {string} [string=''] The string to truncate.
14953      * @param {Object} [options={}] The options object.
14954      * @param {number} [options.length=30] The maximum string length.
14955      * @param {string} [options.omission='...'] The string to indicate text is omitted.
14956      * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
14957      * @returns {string} Returns the truncated string.
14958      * @example
14959      *
14960      * _.truncate('hi-diddly-ho there, neighborino');
14961      * // => 'hi-diddly-ho there, neighbo...'
14962      *
14963      * _.truncate('hi-diddly-ho there, neighborino', {
14964      *   'length': 24,
14965      *   'separator': ' '
14966      * });
14967      * // => 'hi-diddly-ho there,...'
14968      *
14969      * _.truncate('hi-diddly-ho there, neighborino', {
14970      *   'length': 24,
14971      *   'separator': /,? +/
14972      * });
14973      * // => 'hi-diddly-ho there...'
14974      *
14975      * _.truncate('hi-diddly-ho there, neighborino', {
14976      *   'omission': ' [...]'
14977      * });
14978      * // => 'hi-diddly-ho there, neig [...]'
14979      */
14980     function truncate(string, options) {
14981       var length = DEFAULT_TRUNC_LENGTH,
14982           omission = DEFAULT_TRUNC_OMISSION;
14983
14984       if (isObject(options)) {
14985         var separator = 'separator' in options ? options.separator : separator;
14986         length = 'length' in options ? toInteger(options.length) : length;
14987         omission = 'omission' in options ? baseToString(options.omission) : omission;
14988       }
14989       string = toString(string);
14990
14991       var strLength = string.length;
14992       if (hasUnicode(string)) {
14993         var strSymbols = stringToArray(string);
14994         strLength = strSymbols.length;
14995       }
14996       if (length >= strLength) {
14997         return string;
14998       }
14999       var end = length - stringSize(omission);
15000       if (end < 1) {
15001         return omission;
15002       }
15003       var result = strSymbols
15004         ? castSlice(strSymbols, 0, end).join('')
15005         : string.slice(0, end);
15006
15007       if (separator === undefined) {
15008         return result + omission;
15009       }
15010       if (strSymbols) {
15011         end += (result.length - end);
15012       }
15013       if (isRegExp(separator)) {
15014         if (string.slice(end).search(separator)) {
15015           var match,
15016               substring = result;
15017
15018           if (!separator.global) {
15019             separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15020           }
15021           separator.lastIndex = 0;
15022           while ((match = separator.exec(substring))) {
15023             var newEnd = match.index;
15024           }
15025           result = result.slice(0, newEnd === undefined ? end : newEnd);
15026         }
15027       } else if (string.indexOf(baseToString(separator), end) != end) {
15028         var index = result.lastIndexOf(separator);
15029         if (index > -1) {
15030           result = result.slice(0, index);
15031         }
15032       }
15033       return result + omission;
15034     }
15035
15036     /**
15037      * The inverse of `_.escape`; this method converts the HTML entities
15038      * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
15039      * their corresponding characters.
15040      *
15041      * **Note:** No other HTML entities are unescaped. To unescape additional
15042      * HTML entities use a third-party library like [_he_](https://mths.be/he).
15043      *
15044      * @static
15045      * @memberOf _
15046      * @since 0.6.0
15047      * @category String
15048      * @param {string} [string=''] The string to unescape.
15049      * @returns {string} Returns the unescaped string.
15050      * @example
15051      *
15052      * _.unescape('fred, barney, &amp; pebbles');
15053      * // => 'fred, barney, & pebbles'
15054      */
15055     function unescape(string) {
15056       string = toString(string);
15057       return (string && reHasEscapedHtml.test(string))
15058         ? string.replace(reEscapedHtml, unescapeHtmlChar)
15059         : string;
15060     }
15061
15062     /**
15063      * Converts `string`, as space separated words, to upper case.
15064      *
15065      * @static
15066      * @memberOf _
15067      * @since 4.0.0
15068      * @category String
15069      * @param {string} [string=''] The string to convert.
15070      * @returns {string} Returns the upper cased string.
15071      * @example
15072      *
15073      * _.upperCase('--foo-bar');
15074      * // => 'FOO BAR'
15075      *
15076      * _.upperCase('fooBar');
15077      * // => 'FOO BAR'
15078      *
15079      * _.upperCase('__foo_bar__');
15080      * // => 'FOO BAR'
15081      */
15082     var upperCase = createCompounder(function(result, word, index) {
15083       return result + (index ? ' ' : '') + word.toUpperCase();
15084     });
15085
15086     /**
15087      * Converts the first character of `string` to upper case.
15088      *
15089      * @static
15090      * @memberOf _
15091      * @since 4.0.0
15092      * @category String
15093      * @param {string} [string=''] The string to convert.
15094      * @returns {string} Returns the converted string.
15095      * @example
15096      *
15097      * _.upperFirst('fred');
15098      * // => 'Fred'
15099      *
15100      * _.upperFirst('FRED');
15101      * // => 'FRED'
15102      */
15103     var upperFirst = createCaseFirst('toUpperCase');
15104
15105     /**
15106      * Splits `string` into an array of its words.
15107      *
15108      * @static
15109      * @memberOf _
15110      * @since 3.0.0
15111      * @category String
15112      * @param {string} [string=''] The string to inspect.
15113      * @param {RegExp|string} [pattern] The pattern to match words.
15114      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15115      * @returns {Array} Returns the words of `string`.
15116      * @example
15117      *
15118      * _.words('fred, barney, & pebbles');
15119      * // => ['fred', 'barney', 'pebbles']
15120      *
15121      * _.words('fred, barney, & pebbles', /[^, ]+/g);
15122      * // => ['fred', 'barney', '&', 'pebbles']
15123      */
15124     function words(string, pattern, guard) {
15125       string = toString(string);
15126       pattern = guard ? undefined : pattern;
15127
15128       if (pattern === undefined) {
15129         return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15130       }
15131       return string.match(pattern) || [];
15132     }
15133
15134     /*------------------------------------------------------------------------*/
15135
15136     /**
15137      * Attempts to invoke `func`, returning either the result or the caught error
15138      * object. Any additional arguments are provided to `func` when it's invoked.
15139      *
15140      * @static
15141      * @memberOf _
15142      * @since 3.0.0
15143      * @category Util
15144      * @param {Function} func The function to attempt.
15145      * @param {...*} [args] The arguments to invoke `func` with.
15146      * @returns {*} Returns the `func` result or error object.
15147      * @example
15148      *
15149      * // Avoid throwing errors for invalid selectors.
15150      * var elements = _.attempt(function(selector) {
15151      *   return document.querySelectorAll(selector);
15152      * }, '>_>');
15153      *
15154      * if (_.isError(elements)) {
15155      *   elements = [];
15156      * }
15157      */
15158     var attempt = baseRest(function(func, args) {
15159       try {
15160         return apply(func, undefined, args);
15161       } catch (e) {
15162         return isError(e) ? e : new Error(e);
15163       }
15164     });
15165
15166     /**
15167      * Binds methods of an object to the object itself, overwriting the existing
15168      * method.
15169      *
15170      * **Note:** This method doesn't set the "length" property of bound functions.
15171      *
15172      * @static
15173      * @since 0.1.0
15174      * @memberOf _
15175      * @category Util
15176      * @param {Object} object The object to bind and assign the bound methods to.
15177      * @param {...(string|string[])} methodNames The object method names to bind.
15178      * @returns {Object} Returns `object`.
15179      * @example
15180      *
15181      * var view = {
15182      *   'label': 'docs',
15183      *   'click': function() {
15184      *     console.log('clicked ' + this.label);
15185      *   }
15186      * };
15187      *
15188      * _.bindAll(view, ['click']);
15189      * jQuery(element).on('click', view.click);
15190      * // => Logs 'clicked docs' when clicked.
15191      */
15192     var bindAll = flatRest(function(object, methodNames) {
15193       arrayEach(methodNames, function(key) {
15194         key = toKey(key);
15195         baseAssignValue(object, key, bind(object[key], object));
15196       });
15197       return object;
15198     });
15199
15200     /**
15201      * Creates a function that iterates over `pairs` and invokes the corresponding
15202      * function of the first predicate to return truthy. The predicate-function
15203      * pairs are invoked with the `this` binding and arguments of the created
15204      * function.
15205      *
15206      * @static
15207      * @memberOf _
15208      * @since 4.0.0
15209      * @category Util
15210      * @param {Array} pairs The predicate-function pairs.
15211      * @returns {Function} Returns the new composite function.
15212      * @example
15213      *
15214      * var func = _.cond([
15215      *   [_.matches({ 'a': 1 }),           _.constant('matches A')],
15216      *   [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15217      *   [_.stubTrue,                      _.constant('no match')]
15218      * ]);
15219      *
15220      * func({ 'a': 1, 'b': 2 });
15221      * // => 'matches A'
15222      *
15223      * func({ 'a': 0, 'b': 1 });
15224      * // => 'matches B'
15225      *
15226      * func({ 'a': '1', 'b': '2' });
15227      * // => 'no match'
15228      */
15229     function cond(pairs) {
15230       var length = pairs == null ? 0 : pairs.length,
15231           toIteratee = getIteratee();
15232
15233       pairs = !length ? [] : arrayMap(pairs, function(pair) {
15234         if (typeof pair[1] != 'function') {
15235           throw new TypeError(FUNC_ERROR_TEXT);
15236         }
15237         return [toIteratee(pair[0]), pair[1]];
15238       });
15239
15240       return baseRest(function(args) {
15241         var index = -1;
15242         while (++index < length) {
15243           var pair = pairs[index];
15244           if (apply(pair[0], this, args)) {
15245             return apply(pair[1], this, args);
15246           }
15247         }
15248       });
15249     }
15250
15251     /**
15252      * Creates a function that invokes the predicate properties of `source` with
15253      * the corresponding property values of a given object, returning `true` if
15254      * all predicates return truthy, else `false`.
15255      *
15256      * **Note:** The created function is equivalent to `_.conformsTo` with
15257      * `source` partially applied.
15258      *
15259      * @static
15260      * @memberOf _
15261      * @since 4.0.0
15262      * @category Util
15263      * @param {Object} source The object of property predicates to conform to.
15264      * @returns {Function} Returns the new spec function.
15265      * @example
15266      *
15267      * var objects = [
15268      *   { 'a': 2, 'b': 1 },
15269      *   { 'a': 1, 'b': 2 }
15270      * ];
15271      *
15272      * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15273      * // => [{ 'a': 1, 'b': 2 }]
15274      */
15275     function conforms(source) {
15276       return baseConforms(baseClone(source, true));
15277     }
15278
15279     /**
15280      * Creates a function that returns `value`.
15281      *
15282      * @static
15283      * @memberOf _
15284      * @since 2.4.0
15285      * @category Util
15286      * @param {*} value The value to return from the new function.
15287      * @returns {Function} Returns the new constant function.
15288      * @example
15289      *
15290      * var objects = _.times(2, _.constant({ 'a': 1 }));
15291      *
15292      * console.log(objects);
15293      * // => [{ 'a': 1 }, { 'a': 1 }]
15294      *
15295      * console.log(objects[0] === objects[1]);
15296      * // => true
15297      */
15298     function constant(value) {
15299       return function() {
15300         return value;
15301       };
15302     }
15303
15304     /**
15305      * Checks `value` to determine whether a default value should be returned in
15306      * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
15307      * or `undefined`.
15308      *
15309      * @static
15310      * @memberOf _
15311      * @since 4.14.0
15312      * @category Util
15313      * @param {*} value The value to check.
15314      * @param {*} defaultValue The default value.
15315      * @returns {*} Returns the resolved value.
15316      * @example
15317      *
15318      * _.defaultTo(1, 10);
15319      * // => 1
15320      *
15321      * _.defaultTo(undefined, 10);
15322      * // => 10
15323      */
15324     function defaultTo(value, defaultValue) {
15325       return (value == null || value !== value) ? defaultValue : value;
15326     }
15327
15328     /**
15329      * Creates a function that returns the result of invoking the given functions
15330      * with the `this` binding of the created function, where each successive
15331      * invocation is supplied the return value of the previous.
15332      *
15333      * @static
15334      * @memberOf _
15335      * @since 3.0.0
15336      * @category Util
15337      * @param {...(Function|Function[])} [funcs] The functions to invoke.
15338      * @returns {Function} Returns the new composite function.
15339      * @see _.flowRight
15340      * @example
15341      *
15342      * function square(n) {
15343      *   return n * n;
15344      * }
15345      *
15346      * var addSquare = _.flow([_.add, square]);
15347      * addSquare(1, 2);
15348      * // => 9
15349      */
15350     var flow = createFlow();
15351
15352     /**
15353      * This method is like `_.flow` except that it creates a function that
15354      * invokes the given functions from right to left.
15355      *
15356      * @static
15357      * @since 3.0.0
15358      * @memberOf _
15359      * @category Util
15360      * @param {...(Function|Function[])} [funcs] The functions to invoke.
15361      * @returns {Function} Returns the new composite function.
15362      * @see _.flow
15363      * @example
15364      *
15365      * function square(n) {
15366      *   return n * n;
15367      * }
15368      *
15369      * var addSquare = _.flowRight([square, _.add]);
15370      * addSquare(1, 2);
15371      * // => 9
15372      */
15373     var flowRight = createFlow(true);
15374
15375     /**
15376      * This method returns the first argument it receives.
15377      *
15378      * @static
15379      * @since 0.1.0
15380      * @memberOf _
15381      * @category Util
15382      * @param {*} value Any value.
15383      * @returns {*} Returns `value`.
15384      * @example
15385      *
15386      * var object = { 'a': 1 };
15387      *
15388      * console.log(_.identity(object) === object);
15389      * // => true
15390      */
15391     function identity(value) {
15392       return value;
15393     }
15394
15395     /**
15396      * Creates a function that invokes `func` with the arguments of the created
15397      * function. If `func` is a property name, the created function returns the
15398      * property value for a given element. If `func` is an array or object, the
15399      * created function returns `true` for elements that contain the equivalent
15400      * source properties, otherwise it returns `false`.
15401      *
15402      * @static
15403      * @since 4.0.0
15404      * @memberOf _
15405      * @category Util
15406      * @param {*} [func=_.identity] The value to convert to a callback.
15407      * @returns {Function} Returns the callback.
15408      * @example
15409      *
15410      * var users = [
15411      *   { 'user': 'barney', 'age': 36, 'active': true },
15412      *   { 'user': 'fred',   'age': 40, 'active': false }
15413      * ];
15414      *
15415      * // The `_.matches` iteratee shorthand.
15416      * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15417      * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15418      *
15419      * // The `_.matchesProperty` iteratee shorthand.
15420      * _.filter(users, _.iteratee(['user', 'fred']));
15421      * // => [{ 'user': 'fred', 'age': 40 }]
15422      *
15423      * // The `_.property` iteratee shorthand.
15424      * _.map(users, _.iteratee('user'));
15425      * // => ['barney', 'fred']
15426      *
15427      * // Create custom iteratee shorthands.
15428      * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
15429      *   return !_.isRegExp(func) ? iteratee(func) : function(string) {
15430      *     return func.test(string);
15431      *   };
15432      * });
15433      *
15434      * _.filter(['abc', 'def'], /ef/);
15435      * // => ['def']
15436      */
15437     function iteratee(func) {
15438       return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
15439     }
15440
15441     /**
15442      * Creates a function that performs a partial deep comparison between a given
15443      * object and `source`, returning `true` if the given object has equivalent
15444      * property values, else `false`.
15445      *
15446      * **Note:** The created function is equivalent to `_.isMatch` with `source`
15447      * partially applied.
15448      *
15449      * Partial comparisons will match empty array and empty object `source`
15450      * values against any array or object value, respectively. See `_.isEqual`
15451      * for a list of supported value comparisons.
15452      *
15453      * @static
15454      * @memberOf _
15455      * @since 3.0.0
15456      * @category Util
15457      * @param {Object} source The object of property values to match.
15458      * @returns {Function} Returns the new spec function.
15459      * @example
15460      *
15461      * var objects = [
15462      *   { 'a': 1, 'b': 2, 'c': 3 },
15463      *   { 'a': 4, 'b': 5, 'c': 6 }
15464      * ];
15465      *
15466      * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15467      * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15468      */
15469     function matches(source) {
15470       return baseMatches(baseClone(source, true));
15471     }
15472
15473     /**
15474      * Creates a function that performs a partial deep comparison between the
15475      * value at `path` of a given object to `srcValue`, returning `true` if the
15476      * object value is equivalent, else `false`.
15477      *
15478      * **Note:** Partial comparisons will match empty array and empty object
15479      * `srcValue` values against any array or object value, respectively. See
15480      * `_.isEqual` for a list of supported value comparisons.
15481      *
15482      * @static
15483      * @memberOf _
15484      * @since 3.2.0
15485      * @category Util
15486      * @param {Array|string} path The path of the property to get.
15487      * @param {*} srcValue The value to match.
15488      * @returns {Function} Returns the new spec function.
15489      * @example
15490      *
15491      * var objects = [
15492      *   { 'a': 1, 'b': 2, 'c': 3 },
15493      *   { 'a': 4, 'b': 5, 'c': 6 }
15494      * ];
15495      *
15496      * _.find(objects, _.matchesProperty('a', 4));
15497      * // => { 'a': 4, 'b': 5, 'c': 6 }
15498      */
15499     function matchesProperty(path, srcValue) {
15500       return baseMatchesProperty(path, baseClone(srcValue, true));
15501     }
15502
15503     /**
15504      * Creates a function that invokes the method at `path` of a given object.
15505      * Any additional arguments are provided to the invoked method.
15506      *
15507      * @static
15508      * @memberOf _
15509      * @since 3.7.0
15510      * @category Util
15511      * @param {Array|string} path The path of the method to invoke.
15512      * @param {...*} [args] The arguments to invoke the method with.
15513      * @returns {Function} Returns the new invoker function.
15514      * @example
15515      *
15516      * var objects = [
15517      *   { 'a': { 'b': _.constant(2) } },
15518      *   { 'a': { 'b': _.constant(1) } }
15519      * ];
15520      *
15521      * _.map(objects, _.method('a.b'));
15522      * // => [2, 1]
15523      *
15524      * _.map(objects, _.method(['a', 'b']));
15525      * // => [2, 1]
15526      */
15527     var method = baseRest(function(path, args) {
15528       return function(object) {
15529         return baseInvoke(object, path, args);
15530       };
15531     });
15532
15533     /**
15534      * The opposite of `_.method`; this method creates a function that invokes
15535      * the method at a given path of `object`. Any additional arguments are
15536      * provided to the invoked method.
15537      *
15538      * @static
15539      * @memberOf _
15540      * @since 3.7.0
15541      * @category Util
15542      * @param {Object} object The object to query.
15543      * @param {...*} [args] The arguments to invoke the method with.
15544      * @returns {Function} Returns the new invoker function.
15545      * @example
15546      *
15547      * var array = _.times(3, _.constant),
15548      *     object = { 'a': array, 'b': array, 'c': array };
15549      *
15550      * _.map(['a[2]', 'c[0]'], _.methodOf(object));
15551      * // => [2, 0]
15552      *
15553      * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
15554      * // => [2, 0]
15555      */
15556     var methodOf = baseRest(function(object, args) {
15557       return function(path) {
15558         return baseInvoke(object, path, args);
15559       };
15560     });
15561
15562     /**
15563      * Adds all own enumerable string keyed function properties of a source
15564      * object to the destination object. If `object` is a function, then methods
15565      * are added to its prototype as well.
15566      *
15567      * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
15568      * avoid conflicts caused by modifying the original.
15569      *
15570      * @static
15571      * @since 0.1.0
15572      * @memberOf _
15573      * @category Util
15574      * @param {Function|Object} [object=lodash] The destination object.
15575      * @param {Object} source The object of functions to add.
15576      * @param {Object} [options={}] The options object.
15577      * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
15578      * @returns {Function|Object} Returns `object`.
15579      * @example
15580      *
15581      * function vowels(string) {
15582      *   return _.filter(string, function(v) {
15583      *     return /[aeiou]/i.test(v);
15584      *   });
15585      * }
15586      *
15587      * _.mixin({ 'vowels': vowels });
15588      * _.vowels('fred');
15589      * // => ['e']
15590      *
15591      * _('fred').vowels().value();
15592      * // => ['e']
15593      *
15594      * _.mixin({ 'vowels': vowels }, { 'chain': false });
15595      * _('fred').vowels();
15596      * // => ['e']
15597      */
15598     function mixin(object, source, options) {
15599       var props = keys(source),
15600           methodNames = baseFunctions(source, props);
15601
15602       if (options == null &&
15603           !(isObject(source) && (methodNames.length || !props.length))) {
15604         options = source;
15605         source = object;
15606         object = this;
15607         methodNames = baseFunctions(source, keys(source));
15608       }
15609       var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
15610           isFunc = isFunction(object);
15611
15612       arrayEach(methodNames, function(methodName) {
15613         var func = source[methodName];
15614         object[methodName] = func;
15615         if (isFunc) {
15616           object.prototype[methodName] = function() {
15617             var chainAll = this.__chain__;
15618             if (chain || chainAll) {
15619               var result = object(this.__wrapped__),
15620                   actions = result.__actions__ = copyArray(this.__actions__);
15621
15622               actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
15623               result.__chain__ = chainAll;
15624               return result;
15625             }
15626             return func.apply(object, arrayPush([this.value()], arguments));
15627           };
15628         }
15629       });
15630
15631       return object;
15632     }
15633
15634     /**
15635      * Reverts the `_` variable to its previous value and returns a reference to
15636      * the `lodash` function.
15637      *
15638      * @static
15639      * @since 0.1.0
15640      * @memberOf _
15641      * @category Util
15642      * @returns {Function} Returns the `lodash` function.
15643      * @example
15644      *
15645      * var lodash = _.noConflict();
15646      */
15647     function noConflict() {
15648       if (root._ === this) {
15649         root._ = oldDash;
15650       }
15651       return this;
15652     }
15653
15654     /**
15655      * This method returns `undefined`.
15656      *
15657      * @static
15658      * @memberOf _
15659      * @since 2.3.0
15660      * @category Util
15661      * @example
15662      *
15663      * _.times(2, _.noop);
15664      * // => [undefined, undefined]
15665      */
15666     function noop() {
15667       // No operation performed.
15668     }
15669
15670     /**
15671      * Creates a function that gets the argument at index `n`. If `n` is negative,
15672      * the nth argument from the end is returned.
15673      *
15674      * @static
15675      * @memberOf _
15676      * @since 4.0.0
15677      * @category Util
15678      * @param {number} [n=0] The index of the argument to return.
15679      * @returns {Function} Returns the new pass-thru function.
15680      * @example
15681      *
15682      * var func = _.nthArg(1);
15683      * func('a', 'b', 'c', 'd');
15684      * // => 'b'
15685      *
15686      * var func = _.nthArg(-2);
15687      * func('a', 'b', 'c', 'd');
15688      * // => 'c'
15689      */
15690     function nthArg(n) {
15691       n = toInteger(n);
15692       return baseRest(function(args) {
15693         return baseNth(args, n);
15694       });
15695     }
15696
15697     /**
15698      * Creates a function that invokes `iteratees` with the arguments it receives
15699      * and returns their results.
15700      *
15701      * @static
15702      * @memberOf _
15703      * @since 4.0.0
15704      * @category Util
15705      * @param {...(Function|Function[])} [iteratees=[_.identity]]
15706      *  The iteratees to invoke.
15707      * @returns {Function} Returns the new function.
15708      * @example
15709      *
15710      * var func = _.over([Math.max, Math.min]);
15711      *
15712      * func(1, 2, 3, 4);
15713      * // => [4, 1]
15714      */
15715     var over = createOver(arrayMap);
15716
15717     /**
15718      * Creates a function that checks if **all** of the `predicates` return
15719      * truthy when invoked with the arguments it receives.
15720      *
15721      * @static
15722      * @memberOf _
15723      * @since 4.0.0
15724      * @category Util
15725      * @param {...(Function|Function[])} [predicates=[_.identity]]
15726      *  The predicates to check.
15727      * @returns {Function} Returns the new function.
15728      * @example
15729      *
15730      * var func = _.overEvery([Boolean, isFinite]);
15731      *
15732      * func('1');
15733      * // => true
15734      *
15735      * func(null);
15736      * // => false
15737      *
15738      * func(NaN);
15739      * // => false
15740      */
15741     var overEvery = createOver(arrayEvery);
15742
15743     /**
15744      * Creates a function that checks if **any** of the `predicates` return
15745      * truthy when invoked with the arguments it receives.
15746      *
15747      * @static
15748      * @memberOf _
15749      * @since 4.0.0
15750      * @category Util
15751      * @param {...(Function|Function[])} [predicates=[_.identity]]
15752      *  The predicates to check.
15753      * @returns {Function} Returns the new function.
15754      * @example
15755      *
15756      * var func = _.overSome([Boolean, isFinite]);
15757      *
15758      * func('1');
15759      * // => true
15760      *
15761      * func(null);
15762      * // => true
15763      *
15764      * func(NaN);
15765      * // => false
15766      */
15767     var overSome = createOver(arraySome);
15768
15769     /**
15770      * Creates a function that returns the value at `path` of a given object.
15771      *
15772      * @static
15773      * @memberOf _
15774      * @since 2.4.0
15775      * @category Util
15776      * @param {Array|string} path The path of the property to get.
15777      * @returns {Function} Returns the new accessor function.
15778      * @example
15779      *
15780      * var objects = [
15781      *   { 'a': { 'b': 2 } },
15782      *   { 'a': { 'b': 1 } }
15783      * ];
15784      *
15785      * _.map(objects, _.property('a.b'));
15786      * // => [2, 1]
15787      *
15788      * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
15789      * // => [1, 2]
15790      */
15791     function property(path) {
15792       return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
15793     }
15794
15795     /**
15796      * The opposite of `_.property`; this method creates a function that returns
15797      * the value at a given path of `object`.
15798      *
15799      * @static
15800      * @memberOf _
15801      * @since 3.0.0
15802      * @category Util
15803      * @param {Object} object The object to query.
15804      * @returns {Function} Returns the new accessor function.
15805      * @example
15806      *
15807      * var array = [0, 1, 2],
15808      *     object = { 'a': array, 'b': array, 'c': array };
15809      *
15810      * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
15811      * // => [2, 0]
15812      *
15813      * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
15814      * // => [2, 0]
15815      */
15816     function propertyOf(object) {
15817       return function(path) {
15818         return object == null ? undefined : baseGet(object, path);
15819       };
15820     }
15821
15822     /**
15823      * Creates an array of numbers (positive and/or negative) progressing from
15824      * `start` up to, but not including, `end`. A step of `-1` is used if a negative
15825      * `start` is specified without an `end` or `step`. If `end` is not specified,
15826      * it's set to `start` with `start` then set to `0`.
15827      *
15828      * **Note:** JavaScript follows the IEEE-754 standard for resolving
15829      * floating-point values which can produce unexpected results.
15830      *
15831      * @static
15832      * @since 0.1.0
15833      * @memberOf _
15834      * @category Util
15835      * @param {number} [start=0] The start of the range.
15836      * @param {number} end The end of the range.
15837      * @param {number} [step=1] The value to increment or decrement by.
15838      * @returns {Array} Returns the range of numbers.
15839      * @see _.inRange, _.rangeRight
15840      * @example
15841      *
15842      * _.range(4);
15843      * // => [0, 1, 2, 3]
15844      *
15845      * _.range(-4);
15846      * // => [0, -1, -2, -3]
15847      *
15848      * _.range(1, 5);
15849      * // => [1, 2, 3, 4]
15850      *
15851      * _.range(0, 20, 5);
15852      * // => [0, 5, 10, 15]
15853      *
15854      * _.range(0, -4, -1);
15855      * // => [0, -1, -2, -3]
15856      *
15857      * _.range(1, 4, 0);
15858      * // => [1, 1, 1]
15859      *
15860      * _.range(0);
15861      * // => []
15862      */
15863     var range = createRange();
15864
15865     /**
15866      * This method is like `_.range` except that it populates values in
15867      * descending order.
15868      *
15869      * @static
15870      * @memberOf _
15871      * @since 4.0.0
15872      * @category Util
15873      * @param {number} [start=0] The start of the range.
15874      * @param {number} end The end of the range.
15875      * @param {number} [step=1] The value to increment or decrement by.
15876      * @returns {Array} Returns the range of numbers.
15877      * @see _.inRange, _.range
15878      * @example
15879      *
15880      * _.rangeRight(4);
15881      * // => [3, 2, 1, 0]
15882      *
15883      * _.rangeRight(-4);
15884      * // => [-3, -2, -1, 0]
15885      *
15886      * _.rangeRight(1, 5);
15887      * // => [4, 3, 2, 1]
15888      *
15889      * _.rangeRight(0, 20, 5);
15890      * // => [15, 10, 5, 0]
15891      *
15892      * _.rangeRight(0, -4, -1);
15893      * // => [-3, -2, -1, 0]
15894      *
15895      * _.rangeRight(1, 4, 0);
15896      * // => [1, 1, 1]
15897      *
15898      * _.rangeRight(0);
15899      * // => []
15900      */
15901     var rangeRight = createRange(true);
15902
15903     /**
15904      * This method returns a new empty array.
15905      *
15906      * @static
15907      * @memberOf _
15908      * @since 4.13.0
15909      * @category Util
15910      * @returns {Array} Returns the new empty array.
15911      * @example
15912      *
15913      * var arrays = _.times(2, _.stubArray);
15914      *
15915      * console.log(arrays);
15916      * // => [[], []]
15917      *
15918      * console.log(arrays[0] === arrays[1]);
15919      * // => false
15920      */
15921     function stubArray() {
15922       return [];
15923     }
15924
15925     /**
15926      * This method returns `false`.
15927      *
15928      * @static
15929      * @memberOf _
15930      * @since 4.13.0
15931      * @category Util
15932      * @returns {boolean} Returns `false`.
15933      * @example
15934      *
15935      * _.times(2, _.stubFalse);
15936      * // => [false, false]
15937      */
15938     function stubFalse() {
15939       return false;
15940     }
15941
15942     /**
15943      * This method returns a new empty object.
15944      *
15945      * @static
15946      * @memberOf _
15947      * @since 4.13.0
15948      * @category Util
15949      * @returns {Object} Returns the new empty object.
15950      * @example
15951      *
15952      * var objects = _.times(2, _.stubObject);
15953      *
15954      * console.log(objects);
15955      * // => [{}, {}]
15956      *
15957      * console.log(objects[0] === objects[1]);
15958      * // => false
15959      */
15960     function stubObject() {
15961       return {};
15962     }
15963
15964     /**
15965      * This method returns an empty string.
15966      *
15967      * @static
15968      * @memberOf _
15969      * @since 4.13.0
15970      * @category Util
15971      * @returns {string} Returns the empty string.
15972      * @example
15973      *
15974      * _.times(2, _.stubString);
15975      * // => ['', '']
15976      */
15977     function stubString() {
15978       return '';
15979     }
15980
15981     /**
15982      * This method returns `true`.
15983      *
15984      * @static
15985      * @memberOf _
15986      * @since 4.13.0
15987      * @category Util
15988      * @returns {boolean} Returns `true`.
15989      * @example
15990      *
15991      * _.times(2, _.stubTrue);
15992      * // => [true, true]
15993      */
15994     function stubTrue() {
15995       return true;
15996     }
15997
15998     /**
15999      * Invokes the iteratee `n` times, returning an array of the results of
16000      * each invocation. The iteratee is invoked with one argument; (index).
16001      *
16002      * @static
16003      * @since 0.1.0
16004      * @memberOf _
16005      * @category Util
16006      * @param {number} n The number of times to invoke `iteratee`.
16007      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16008      * @returns {Array} Returns the array of results.
16009      * @example
16010      *
16011      * _.times(3, String);
16012      * // => ['0', '1', '2']
16013      *
16014      *  _.times(4, _.constant(0));
16015      * // => [0, 0, 0, 0]
16016      */
16017     function times(n, iteratee) {
16018       n = toInteger(n);
16019       if (n < 1 || n > MAX_SAFE_INTEGER) {
16020         return [];
16021       }
16022       var index = MAX_ARRAY_LENGTH,
16023           length = nativeMin(n, MAX_ARRAY_LENGTH);
16024
16025       iteratee = getIteratee(iteratee);
16026       n -= MAX_ARRAY_LENGTH;
16027
16028       var result = baseTimes(length, iteratee);
16029       while (++index < n) {
16030         iteratee(index);
16031       }
16032       return result;
16033     }
16034
16035     /**
16036      * Converts `value` to a property path array.
16037      *
16038      * @static
16039      * @memberOf _
16040      * @since 4.0.0
16041      * @category Util
16042      * @param {*} value The value to convert.
16043      * @returns {Array} Returns the new property path array.
16044      * @example
16045      *
16046      * _.toPath('a.b.c');
16047      * // => ['a', 'b', 'c']
16048      *
16049      * _.toPath('a[0].b.c');
16050      * // => ['a', '0', 'b', 'c']
16051      */
16052     function toPath(value) {
16053       if (isArray(value)) {
16054         return arrayMap(value, toKey);
16055       }
16056       return isSymbol(value) ? [value] : copyArray(stringToPath(value));
16057     }
16058
16059     /**
16060      * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16061      *
16062      * @static
16063      * @since 0.1.0
16064      * @memberOf _
16065      * @category Util
16066      * @param {string} [prefix=''] The value to prefix the ID with.
16067      * @returns {string} Returns the unique ID.
16068      * @example
16069      *
16070      * _.uniqueId('contact_');
16071      * // => 'contact_104'
16072      *
16073      * _.uniqueId();
16074      * // => '105'
16075      */
16076     function uniqueId(prefix) {
16077       var id = ++idCounter;
16078       return toString(prefix) + id;
16079     }
16080
16081     /*------------------------------------------------------------------------*/
16082
16083     /**
16084      * Adds two numbers.
16085      *
16086      * @static
16087      * @memberOf _
16088      * @since 3.4.0
16089      * @category Math
16090      * @param {number} augend The first number in an addition.
16091      * @param {number} addend The second number in an addition.
16092      * @returns {number} Returns the total.
16093      * @example
16094      *
16095      * _.add(6, 4);
16096      * // => 10
16097      */
16098     var add = createMathOperation(function(augend, addend) {
16099       return augend + addend;
16100     }, 0);
16101
16102     /**
16103      * Computes `number` rounded up to `precision`.
16104      *
16105      * @static
16106      * @memberOf _
16107      * @since 3.10.0
16108      * @category Math
16109      * @param {number} number The number to round up.
16110      * @param {number} [precision=0] The precision to round up to.
16111      * @returns {number} Returns the rounded up number.
16112      * @example
16113      *
16114      * _.ceil(4.006);
16115      * // => 5
16116      *
16117      * _.ceil(6.004, 2);
16118      * // => 6.01
16119      *
16120      * _.ceil(6040, -2);
16121      * // => 6100
16122      */
16123     var ceil = createRound('ceil');
16124
16125     /**
16126      * Divide two numbers.
16127      *
16128      * @static
16129      * @memberOf _
16130      * @since 4.7.0
16131      * @category Math
16132      * @param {number} dividend The first number in a division.
16133      * @param {number} divisor The second number in a division.
16134      * @returns {number} Returns the quotient.
16135      * @example
16136      *
16137      * _.divide(6, 4);
16138      * // => 1.5
16139      */
16140     var divide = createMathOperation(function(dividend, divisor) {
16141       return dividend / divisor;
16142     }, 1);
16143
16144     /**
16145      * Computes `number` rounded down to `precision`.
16146      *
16147      * @static
16148      * @memberOf _
16149      * @since 3.10.0
16150      * @category Math
16151      * @param {number} number The number to round down.
16152      * @param {number} [precision=0] The precision to round down to.
16153      * @returns {number} Returns the rounded down number.
16154      * @example
16155      *
16156      * _.floor(4.006);
16157      * // => 4
16158      *
16159      * _.floor(0.046, 2);
16160      * // => 0.04
16161      *
16162      * _.floor(4060, -2);
16163      * // => 4000
16164      */
16165     var floor = createRound('floor');
16166
16167     /**
16168      * Computes the maximum value of `array`. If `array` is empty or falsey,
16169      * `undefined` is returned.
16170      *
16171      * @static
16172      * @since 0.1.0
16173      * @memberOf _
16174      * @category Math
16175      * @param {Array} array The array to iterate over.
16176      * @returns {*} Returns the maximum value.
16177      * @example
16178      *
16179      * _.max([4, 2, 8, 6]);
16180      * // => 8
16181      *
16182      * _.max([]);
16183      * // => undefined
16184      */
16185     function max(array) {
16186       return (array && array.length)
16187         ? baseExtremum(array, identity, baseGt)
16188         : undefined;
16189     }
16190
16191     /**
16192      * This method is like `_.max` except that it accepts `iteratee` which is
16193      * invoked for each element in `array` to generate the criterion by which
16194      * the value is ranked. The iteratee is invoked with one argument: (value).
16195      *
16196      * @static
16197      * @memberOf _
16198      * @since 4.0.0
16199      * @category Math
16200      * @param {Array} array The array to iterate over.
16201      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16202      * @returns {*} Returns the maximum value.
16203      * @example
16204      *
16205      * var objects = [{ 'n': 1 }, { 'n': 2 }];
16206      *
16207      * _.maxBy(objects, function(o) { return o.n; });
16208      * // => { 'n': 2 }
16209      *
16210      * // The `_.property` iteratee shorthand.
16211      * _.maxBy(objects, 'n');
16212      * // => { 'n': 2 }
16213      */
16214     function maxBy(array, iteratee) {
16215       return (array && array.length)
16216         ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
16217         : undefined;
16218     }
16219
16220     /**
16221      * Computes the mean of the values in `array`.
16222      *
16223      * @static
16224      * @memberOf _
16225      * @since 4.0.0
16226      * @category Math
16227      * @param {Array} array The array to iterate over.
16228      * @returns {number} Returns the mean.
16229      * @example
16230      *
16231      * _.mean([4, 2, 8, 6]);
16232      * // => 5
16233      */
16234     function mean(array) {
16235       return baseMean(array, identity);
16236     }
16237
16238     /**
16239      * This method is like `_.mean` except that it accepts `iteratee` which is
16240      * invoked for each element in `array` to generate the value to be averaged.
16241      * The iteratee is invoked with one argument: (value).
16242      *
16243      * @static
16244      * @memberOf _
16245      * @since 4.7.0
16246      * @category Math
16247      * @param {Array} array The array to iterate over.
16248      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16249      * @returns {number} Returns the mean.
16250      * @example
16251      *
16252      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16253      *
16254      * _.meanBy(objects, function(o) { return o.n; });
16255      * // => 5
16256      *
16257      * // The `_.property` iteratee shorthand.
16258      * _.meanBy(objects, 'n');
16259      * // => 5
16260      */
16261     function meanBy(array, iteratee) {
16262       return baseMean(array, getIteratee(iteratee, 2));
16263     }
16264
16265     /**
16266      * Computes the minimum value of `array`. If `array` is empty or falsey,
16267      * `undefined` is returned.
16268      *
16269      * @static
16270      * @since 0.1.0
16271      * @memberOf _
16272      * @category Math
16273      * @param {Array} array The array to iterate over.
16274      * @returns {*} Returns the minimum value.
16275      * @example
16276      *
16277      * _.min([4, 2, 8, 6]);
16278      * // => 2
16279      *
16280      * _.min([]);
16281      * // => undefined
16282      */
16283     function min(array) {
16284       return (array && array.length)
16285         ? baseExtremum(array, identity, baseLt)
16286         : undefined;
16287     }
16288
16289     /**
16290      * This method is like `_.min` except that it accepts `iteratee` which is
16291      * invoked for each element in `array` to generate the criterion by which
16292      * the value is ranked. The iteratee is invoked with one argument: (value).
16293      *
16294      * @static
16295      * @memberOf _
16296      * @since 4.0.0
16297      * @category Math
16298      * @param {Array} array The array to iterate over.
16299      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16300      * @returns {*} Returns the minimum value.
16301      * @example
16302      *
16303      * var objects = [{ 'n': 1 }, { 'n': 2 }];
16304      *
16305      * _.minBy(objects, function(o) { return o.n; });
16306      * // => { 'n': 1 }
16307      *
16308      * // The `_.property` iteratee shorthand.
16309      * _.minBy(objects, 'n');
16310      * // => { 'n': 1 }
16311      */
16312     function minBy(array, iteratee) {
16313       return (array && array.length)
16314         ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
16315         : undefined;
16316     }
16317
16318     /**
16319      * Multiply two numbers.
16320      *
16321      * @static
16322      * @memberOf _
16323      * @since 4.7.0
16324      * @category Math
16325      * @param {number} multiplier The first number in a multiplication.
16326      * @param {number} multiplicand The second number in a multiplication.
16327      * @returns {number} Returns the product.
16328      * @example
16329      *
16330      * _.multiply(6, 4);
16331      * // => 24
16332      */
16333     var multiply = createMathOperation(function(multiplier, multiplicand) {
16334       return multiplier * multiplicand;
16335     }, 1);
16336
16337     /**
16338      * Computes `number` rounded to `precision`.
16339      *
16340      * @static
16341      * @memberOf _
16342      * @since 3.10.0
16343      * @category Math
16344      * @param {number} number The number to round.
16345      * @param {number} [precision=0] The precision to round to.
16346      * @returns {number} Returns the rounded number.
16347      * @example
16348      *
16349      * _.round(4.006);
16350      * // => 4
16351      *
16352      * _.round(4.006, 2);
16353      * // => 4.01
16354      *
16355      * _.round(4060, -2);
16356      * // => 4100
16357      */
16358     var round = createRound('round');
16359
16360     /**
16361      * Subtract two numbers.
16362      *
16363      * @static
16364      * @memberOf _
16365      * @since 4.0.0
16366      * @category Math
16367      * @param {number} minuend The first number in a subtraction.
16368      * @param {number} subtrahend The second number in a subtraction.
16369      * @returns {number} Returns the difference.
16370      * @example
16371      *
16372      * _.subtract(6, 4);
16373      * // => 2
16374      */
16375     var subtract = createMathOperation(function(minuend, subtrahend) {
16376       return minuend - subtrahend;
16377     }, 0);
16378
16379     /**
16380      * Computes the sum of the values in `array`.
16381      *
16382      * @static
16383      * @memberOf _
16384      * @since 3.4.0
16385      * @category Math
16386      * @param {Array} array The array to iterate over.
16387      * @returns {number} Returns the sum.
16388      * @example
16389      *
16390      * _.sum([4, 2, 8, 6]);
16391      * // => 20
16392      */
16393     function sum(array) {
16394       return (array && array.length)
16395         ? baseSum(array, identity)
16396         : 0;
16397     }
16398
16399     /**
16400      * This method is like `_.sum` except that it accepts `iteratee` which is
16401      * invoked for each element in `array` to generate the value to be summed.
16402      * The iteratee is invoked with one argument: (value).
16403      *
16404      * @static
16405      * @memberOf _
16406      * @since 4.0.0
16407      * @category Math
16408      * @param {Array} array The array to iterate over.
16409      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16410      * @returns {number} Returns the sum.
16411      * @example
16412      *
16413      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16414      *
16415      * _.sumBy(objects, function(o) { return o.n; });
16416      * // => 20
16417      *
16418      * // The `_.property` iteratee shorthand.
16419      * _.sumBy(objects, 'n');
16420      * // => 20
16421      */
16422     function sumBy(array, iteratee) {
16423       return (array && array.length)
16424         ? baseSum(array, getIteratee(iteratee, 2))
16425         : 0;
16426     }
16427
16428     /*------------------------------------------------------------------------*/
16429
16430     // Add methods that return wrapped values in chain sequences.
16431     lodash.after = after;
16432     lodash.ary = ary;
16433     lodash.assign = assign;
16434     lodash.assignIn = assignIn;
16435     lodash.assignInWith = assignInWith;
16436     lodash.assignWith = assignWith;
16437     lodash.at = at;
16438     lodash.before = before;
16439     lodash.bind = bind;
16440     lodash.bindAll = bindAll;
16441     lodash.bindKey = bindKey;
16442     lodash.castArray = castArray;
16443     lodash.chain = chain;
16444     lodash.chunk = chunk;
16445     lodash.compact = compact;
16446     lodash.concat = concat;
16447     lodash.cond = cond;
16448     lodash.conforms = conforms;
16449     lodash.constant = constant;
16450     lodash.countBy = countBy;
16451     lodash.create = create;
16452     lodash.curry = curry;
16453     lodash.curryRight = curryRight;
16454     lodash.debounce = debounce;
16455     lodash.defaults = defaults;
16456     lodash.defaultsDeep = defaultsDeep;
16457     lodash.defer = defer;
16458     lodash.delay = delay;
16459     lodash.difference = difference;
16460     lodash.differenceBy = differenceBy;
16461     lodash.differenceWith = differenceWith;
16462     lodash.drop = drop;
16463     lodash.dropRight = dropRight;
16464     lodash.dropRightWhile = dropRightWhile;
16465     lodash.dropWhile = dropWhile;
16466     lodash.fill = fill;
16467     lodash.filter = filter;
16468     lodash.flatMap = flatMap;
16469     lodash.flatMapDeep = flatMapDeep;
16470     lodash.flatMapDepth = flatMapDepth;
16471     lodash.flatten = flatten;
16472     lodash.flattenDeep = flattenDeep;
16473     lodash.flattenDepth = flattenDepth;
16474     lodash.flip = flip;
16475     lodash.flow = flow;
16476     lodash.flowRight = flowRight;
16477     lodash.fromPairs = fromPairs;
16478     lodash.functions = functions;
16479     lodash.functionsIn = functionsIn;
16480     lodash.groupBy = groupBy;
16481     lodash.initial = initial;
16482     lodash.intersection = intersection;
16483     lodash.intersectionBy = intersectionBy;
16484     lodash.intersectionWith = intersectionWith;
16485     lodash.invert = invert;
16486     lodash.invertBy = invertBy;
16487     lodash.invokeMap = invokeMap;
16488     lodash.iteratee = iteratee;
16489     lodash.keyBy = keyBy;
16490     lodash.keys = keys;
16491     lodash.keysIn = keysIn;
16492     lodash.map = map;
16493     lodash.mapKeys = mapKeys;
16494     lodash.mapValues = mapValues;
16495     lodash.matches = matches;
16496     lodash.matchesProperty = matchesProperty;
16497     lodash.memoize = memoize;
16498     lodash.merge = merge;
16499     lodash.mergeWith = mergeWith;
16500     lodash.method = method;
16501     lodash.methodOf = methodOf;
16502     lodash.mixin = mixin;
16503     lodash.negate = negate;
16504     lodash.nthArg = nthArg;
16505     lodash.omit = omit;
16506     lodash.omitBy = omitBy;
16507     lodash.once = once;
16508     lodash.orderBy = orderBy;
16509     lodash.over = over;
16510     lodash.overArgs = overArgs;
16511     lodash.overEvery = overEvery;
16512     lodash.overSome = overSome;
16513     lodash.partial = partial;
16514     lodash.partialRight = partialRight;
16515     lodash.partition = partition;
16516     lodash.pick = pick;
16517     lodash.pickBy = pickBy;
16518     lodash.property = property;
16519     lodash.propertyOf = propertyOf;
16520     lodash.pull = pull;
16521     lodash.pullAll = pullAll;
16522     lodash.pullAllBy = pullAllBy;
16523     lodash.pullAllWith = pullAllWith;
16524     lodash.pullAt = pullAt;
16525     lodash.range = range;
16526     lodash.rangeRight = rangeRight;
16527     lodash.rearg = rearg;
16528     lodash.reject = reject;
16529     lodash.remove = remove;
16530     lodash.rest = rest;
16531     lodash.reverse = reverse;
16532     lodash.sampleSize = sampleSize;
16533     lodash.set = set;
16534     lodash.setWith = setWith;
16535     lodash.shuffle = shuffle;
16536     lodash.slice = slice;
16537     lodash.sortBy = sortBy;
16538     lodash.sortedUniq = sortedUniq;
16539     lodash.sortedUniqBy = sortedUniqBy;
16540     lodash.split = split;
16541     lodash.spread = spread;
16542     lodash.tail = tail;
16543     lodash.take = take;
16544     lodash.takeRight = takeRight;
16545     lodash.takeRightWhile = takeRightWhile;
16546     lodash.takeWhile = takeWhile;
16547     lodash.tap = tap;
16548     lodash.throttle = throttle;
16549     lodash.thru = thru;
16550     lodash.toArray = toArray;
16551     lodash.toPairs = toPairs;
16552     lodash.toPairsIn = toPairsIn;
16553     lodash.toPath = toPath;
16554     lodash.toPlainObject = toPlainObject;
16555     lodash.transform = transform;
16556     lodash.unary = unary;
16557     lodash.union = union;
16558     lodash.unionBy = unionBy;
16559     lodash.unionWith = unionWith;
16560     lodash.uniq = uniq;
16561     lodash.uniqBy = uniqBy;
16562     lodash.uniqWith = uniqWith;
16563     lodash.unset = unset;
16564     lodash.unzip = unzip;
16565     lodash.unzipWith = unzipWith;
16566     lodash.update = update;
16567     lodash.updateWith = updateWith;
16568     lodash.values = values;
16569     lodash.valuesIn = valuesIn;
16570     lodash.without = without;
16571     lodash.words = words;
16572     lodash.wrap = wrap;
16573     lodash.xor = xor;
16574     lodash.xorBy = xorBy;
16575     lodash.xorWith = xorWith;
16576     lodash.zip = zip;
16577     lodash.zipObject = zipObject;
16578     lodash.zipObjectDeep = zipObjectDeep;
16579     lodash.zipWith = zipWith;
16580
16581     // Add aliases.
16582     lodash.entries = toPairs;
16583     lodash.entriesIn = toPairsIn;
16584     lodash.extend = assignIn;
16585     lodash.extendWith = assignInWith;
16586
16587     // Add methods to `lodash.prototype`.
16588     mixin(lodash, lodash);
16589
16590     /*------------------------------------------------------------------------*/
16591
16592     // Add methods that return unwrapped values in chain sequences.
16593     lodash.add = add;
16594     lodash.attempt = attempt;
16595     lodash.camelCase = camelCase;
16596     lodash.capitalize = capitalize;
16597     lodash.ceil = ceil;
16598     lodash.clamp = clamp;
16599     lodash.clone = clone;
16600     lodash.cloneDeep = cloneDeep;
16601     lodash.cloneDeepWith = cloneDeepWith;
16602     lodash.cloneWith = cloneWith;
16603     lodash.conformsTo = conformsTo;
16604     lodash.deburr = deburr;
16605     lodash.defaultTo = defaultTo;
16606     lodash.divide = divide;
16607     lodash.endsWith = endsWith;
16608     lodash.eq = eq;
16609     lodash.escape = escape;
16610     lodash.escapeRegExp = escapeRegExp;
16611     lodash.every = every;
16612     lodash.find = find;
16613     lodash.findIndex = findIndex;
16614     lodash.findKey = findKey;
16615     lodash.findLast = findLast;
16616     lodash.findLastIndex = findLastIndex;
16617     lodash.findLastKey = findLastKey;
16618     lodash.floor = floor;
16619     lodash.forEach = forEach;
16620     lodash.forEachRight = forEachRight;
16621     lodash.forIn = forIn;
16622     lodash.forInRight = forInRight;
16623     lodash.forOwn = forOwn;
16624     lodash.forOwnRight = forOwnRight;
16625     lodash.get = get;
16626     lodash.gt = gt;
16627     lodash.gte = gte;
16628     lodash.has = has;
16629     lodash.hasIn = hasIn;
16630     lodash.head = head;
16631     lodash.identity = identity;
16632     lodash.includes = includes;
16633     lodash.indexOf = indexOf;
16634     lodash.inRange = inRange;
16635     lodash.invoke = invoke;
16636     lodash.isArguments = isArguments;
16637     lodash.isArray = isArray;
16638     lodash.isArrayBuffer = isArrayBuffer;
16639     lodash.isArrayLike = isArrayLike;
16640     lodash.isArrayLikeObject = isArrayLikeObject;
16641     lodash.isBoolean = isBoolean;
16642     lodash.isBuffer = isBuffer;
16643     lodash.isDate = isDate;
16644     lodash.isElement = isElement;
16645     lodash.isEmpty = isEmpty;
16646     lodash.isEqual = isEqual;
16647     lodash.isEqualWith = isEqualWith;
16648     lodash.isError = isError;
16649     lodash.isFinite = isFinite;
16650     lodash.isFunction = isFunction;
16651     lodash.isInteger = isInteger;
16652     lodash.isLength = isLength;
16653     lodash.isMap = isMap;
16654     lodash.isMatch = isMatch;
16655     lodash.isMatchWith = isMatchWith;
16656     lodash.isNaN = isNaN;
16657     lodash.isNative = isNative;
16658     lodash.isNil = isNil;
16659     lodash.isNull = isNull;
16660     lodash.isNumber = isNumber;
16661     lodash.isObject = isObject;
16662     lodash.isObjectLike = isObjectLike;
16663     lodash.isPlainObject = isPlainObject;
16664     lodash.isRegExp = isRegExp;
16665     lodash.isSafeInteger = isSafeInteger;
16666     lodash.isSet = isSet;
16667     lodash.isString = isString;
16668     lodash.isSymbol = isSymbol;
16669     lodash.isTypedArray = isTypedArray;
16670     lodash.isUndefined = isUndefined;
16671     lodash.isWeakMap = isWeakMap;
16672     lodash.isWeakSet = isWeakSet;
16673     lodash.join = join;
16674     lodash.kebabCase = kebabCase;
16675     lodash.last = last;
16676     lodash.lastIndexOf = lastIndexOf;
16677     lodash.lowerCase = lowerCase;
16678     lodash.lowerFirst = lowerFirst;
16679     lodash.lt = lt;
16680     lodash.lte = lte;
16681     lodash.max = max;
16682     lodash.maxBy = maxBy;
16683     lodash.mean = mean;
16684     lodash.meanBy = meanBy;
16685     lodash.min = min;
16686     lodash.minBy = minBy;
16687     lodash.stubArray = stubArray;
16688     lodash.stubFalse = stubFalse;
16689     lodash.stubObject = stubObject;
16690     lodash.stubString = stubString;
16691     lodash.stubTrue = stubTrue;
16692     lodash.multiply = multiply;
16693     lodash.nth = nth;
16694     lodash.noConflict = noConflict;
16695     lodash.noop = noop;
16696     lodash.now = now;
16697     lodash.pad = pad;
16698     lodash.padEnd = padEnd;
16699     lodash.padStart = padStart;
16700     lodash.parseInt = parseInt;
16701     lodash.random = random;
16702     lodash.reduce = reduce;
16703     lodash.reduceRight = reduceRight;
16704     lodash.repeat = repeat;
16705     lodash.replace = replace;
16706     lodash.result = result;
16707     lodash.round = round;
16708     lodash.runInContext = runInContext;
16709     lodash.sample = sample;
16710     lodash.size = size;
16711     lodash.snakeCase = snakeCase;
16712     lodash.some = some;
16713     lodash.sortedIndex = sortedIndex;
16714     lodash.sortedIndexBy = sortedIndexBy;
16715     lodash.sortedIndexOf = sortedIndexOf;
16716     lodash.sortedLastIndex = sortedLastIndex;
16717     lodash.sortedLastIndexBy = sortedLastIndexBy;
16718     lodash.sortedLastIndexOf = sortedLastIndexOf;
16719     lodash.startCase = startCase;
16720     lodash.startsWith = startsWith;
16721     lodash.subtract = subtract;
16722     lodash.sum = sum;
16723     lodash.sumBy = sumBy;
16724     lodash.template = template;
16725     lodash.times = times;
16726     lodash.toFinite = toFinite;
16727     lodash.toInteger = toInteger;
16728     lodash.toLength = toLength;
16729     lodash.toLower = toLower;
16730     lodash.toNumber = toNumber;
16731     lodash.toSafeInteger = toSafeInteger;
16732     lodash.toString = toString;
16733     lodash.toUpper = toUpper;
16734     lodash.trim = trim;
16735     lodash.trimEnd = trimEnd;
16736     lodash.trimStart = trimStart;
16737     lodash.truncate = truncate;
16738     lodash.unescape = unescape;
16739     lodash.uniqueId = uniqueId;
16740     lodash.upperCase = upperCase;
16741     lodash.upperFirst = upperFirst;
16742
16743     // Add aliases.
16744     lodash.each = forEach;
16745     lodash.eachRight = forEachRight;
16746     lodash.first = head;
16747
16748     mixin(lodash, (function() {
16749       var source = {};
16750       baseForOwn(lodash, function(func, methodName) {
16751         if (!hasOwnProperty.call(lodash.prototype, methodName)) {
16752           source[methodName] = func;
16753         }
16754       });
16755       return source;
16756     }()), { 'chain': false });
16757
16758     /*------------------------------------------------------------------------*/
16759
16760     /**
16761      * The semantic version number.
16762      *
16763      * @static
16764      * @memberOf _
16765      * @type {string}
16766      */
16767     lodash.VERSION = VERSION;
16768
16769     // Assign default placeholders.
16770     arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
16771       lodash[methodName].placeholder = lodash;
16772     });
16773
16774     // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
16775     arrayEach(['drop', 'take'], function(methodName, index) {
16776       LazyWrapper.prototype[methodName] = function(n) {
16777         var filtered = this.__filtered__;
16778         if (filtered && !index) {
16779           return new LazyWrapper(this);
16780         }
16781         n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
16782
16783         var result = this.clone();
16784         if (filtered) {
16785           result.__takeCount__ = nativeMin(n, result.__takeCount__);
16786         } else {
16787           result.__views__.push({
16788             'size': nativeMin(n, MAX_ARRAY_LENGTH),
16789             'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
16790           });
16791         }
16792         return result;
16793       };
16794
16795       LazyWrapper.prototype[methodName + 'Right'] = function(n) {
16796         return this.reverse()[methodName](n).reverse();
16797       };
16798     });
16799
16800     // Add `LazyWrapper` methods that accept an `iteratee` value.
16801     arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
16802       var type = index + 1,
16803           isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
16804
16805       LazyWrapper.prototype[methodName] = function(iteratee) {
16806         var result = this.clone();
16807         result.__iteratees__.push({
16808           'iteratee': getIteratee(iteratee, 3),
16809           'type': type
16810         });
16811         result.__filtered__ = result.__filtered__ || isFilter;
16812         return result;
16813       };
16814     });
16815
16816     // Add `LazyWrapper` methods for `_.head` and `_.last`.
16817     arrayEach(['head', 'last'], function(methodName, index) {
16818       var takeName = 'take' + (index ? 'Right' : '');
16819
16820       LazyWrapper.prototype[methodName] = function() {
16821         return this[takeName](1).value()[0];
16822       };
16823     });
16824
16825     // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
16826     arrayEach(['initial', 'tail'], function(methodName, index) {
16827       var dropName = 'drop' + (index ? '' : 'Right');
16828
16829       LazyWrapper.prototype[methodName] = function() {
16830         return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
16831       };
16832     });
16833
16834     LazyWrapper.prototype.compact = function() {
16835       return this.filter(identity);
16836     };
16837
16838     LazyWrapper.prototype.find = function(predicate) {
16839       return this.filter(predicate).head();
16840     };
16841
16842     LazyWrapper.prototype.findLast = function(predicate) {
16843       return this.reverse().find(predicate);
16844     };
16845
16846     LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
16847       if (typeof path == 'function') {
16848         return new LazyWrapper(this);
16849       }
16850       return this.map(function(value) {
16851         return baseInvoke(value, path, args);
16852       });
16853     });
16854
16855     LazyWrapper.prototype.reject = function(predicate) {
16856       return this.filter(negate(getIteratee(predicate)));
16857     };
16858
16859     LazyWrapper.prototype.slice = function(start, end) {
16860       start = toInteger(start);
16861
16862       var result = this;
16863       if (result.__filtered__ && (start > 0 || end < 0)) {
16864         return new LazyWrapper(result);
16865       }
16866       if (start < 0) {
16867         result = result.takeRight(-start);
16868       } else if (start) {
16869         result = result.drop(start);
16870       }
16871       if (end !== undefined) {
16872         end = toInteger(end);
16873         result = end < 0 ? result.dropRight(-end) : result.take(end - start);
16874       }
16875       return result;
16876     };
16877
16878     LazyWrapper.prototype.takeRightWhile = function(predicate) {
16879       return this.reverse().takeWhile(predicate).reverse();
16880     };
16881
16882     LazyWrapper.prototype.toArray = function() {
16883       return this.take(MAX_ARRAY_LENGTH);
16884     };
16885
16886     // Add `LazyWrapper` methods to `lodash.prototype`.
16887     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
16888       var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
16889           isTaker = /^(?:head|last)$/.test(methodName),
16890           lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
16891           retUnwrapped = isTaker || /^find/.test(methodName);
16892
16893       if (!lodashFunc) {
16894         return;
16895       }
16896       lodash.prototype[methodName] = function() {
16897         var value = this.__wrapped__,
16898             args = isTaker ? [1] : arguments,
16899             isLazy = value instanceof LazyWrapper,
16900             iteratee = args[0],
16901             useLazy = isLazy || isArray(value);
16902
16903         var interceptor = function(value) {
16904           var result = lodashFunc.apply(lodash, arrayPush([value], args));
16905           return (isTaker && chainAll) ? result[0] : result;
16906         };
16907
16908         if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
16909           // Avoid lazy use if the iteratee has a "length" value other than `1`.
16910           isLazy = useLazy = false;
16911         }
16912         var chainAll = this.__chain__,
16913             isHybrid = !!this.__actions__.length,
16914             isUnwrapped = retUnwrapped && !chainAll,
16915             onlyLazy = isLazy && !isHybrid;
16916
16917         if (!retUnwrapped && useLazy) {
16918           value = onlyLazy ? value : new LazyWrapper(this);
16919           var result = func.apply(value, args);
16920           result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
16921           return new LodashWrapper(result, chainAll);
16922         }
16923         if (isUnwrapped && onlyLazy) {
16924           return func.apply(this, args);
16925         }
16926         result = this.thru(interceptor);
16927         return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
16928       };
16929     });
16930
16931     // Add `Array` methods to `lodash.prototype`.
16932     arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
16933       var func = arrayProto[methodName],
16934           chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
16935           retUnwrapped = /^(?:pop|shift)$/.test(methodName);
16936
16937       lodash.prototype[methodName] = function() {
16938         var args = arguments;
16939         if (retUnwrapped && !this.__chain__) {
16940           var value = this.value();
16941           return func.apply(isArray(value) ? value : [], args);
16942         }
16943         return this[chainName](function(value) {
16944           return func.apply(isArray(value) ? value : [], args);
16945         });
16946       };
16947     });
16948
16949     // Map minified method names to their real names.
16950     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
16951       var lodashFunc = lodash[methodName];
16952       if (lodashFunc) {
16953         var key = (lodashFunc.name + ''),
16954             names = realNames[key] || (realNames[key] = []);
16955
16956         names.push({ 'name': methodName, 'func': lodashFunc });
16957       }
16958     });
16959
16960     realNames[createHybrid(undefined, BIND_KEY_FLAG).name] = [{
16961       'name': 'wrapper',
16962       'func': undefined
16963     }];
16964
16965     // Add methods to `LazyWrapper`.
16966     LazyWrapper.prototype.clone = lazyClone;
16967     LazyWrapper.prototype.reverse = lazyReverse;
16968     LazyWrapper.prototype.value = lazyValue;
16969
16970     // Add chain sequence methods to the `lodash` wrapper.
16971     lodash.prototype.at = wrapperAt;
16972     lodash.prototype.chain = wrapperChain;
16973     lodash.prototype.commit = wrapperCommit;
16974     lodash.prototype.next = wrapperNext;
16975     lodash.prototype.plant = wrapperPlant;
16976     lodash.prototype.reverse = wrapperReverse;
16977     lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
16978
16979     // Add lazy aliases.
16980     lodash.prototype.first = lodash.prototype.head;
16981
16982     if (symIterator) {
16983       lodash.prototype[symIterator] = wrapperToIterator;
16984     }
16985     return lodash;
16986   });
16987
16988   /*--------------------------------------------------------------------------*/
16989
16990   // Export lodash.
16991   var _ = runInContext();
16992
16993   // Some AMD build optimizers, like r.js, check for condition patterns like:
16994   if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
16995     // Expose Lodash on the global object to prevent errors when Lodash is
16996     // loaded by a script tag in the presence of an AMD loader.
16997     // See http://requirejs.org/docs/errors.html#mismatch for more details.
16998     // Use `_.noConflict` to remove Lodash from the global object.
16999     root._ = _;
17000
17001     // Define as an anonymous module so, through path mapping, it can be
17002     // referenced as the "underscore" module.
17003     define(function() {
17004       return _;
17005     });
17006   }
17007   // Check for `exports` after `define` in case a build optimizer adds it.
17008   else if (freeModule) {
17009     // Export for Node.js.
17010     (freeModule.exports = _)._ = _;
17011     // Export for CommonJS support.
17012     freeExports._ = _;
17013   }
17014   else {
17015     // Export to the global object.
17016     root._ = _;
17017   }
17018 }.call(this));