1/**
2 * @license
3 * Lodash <https://lodash.com/>
4 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5 * Released under MIT license <https://lodash.com/license>
6 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8 */
9;(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.17.15';
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://npms.io/search?q=ponyfill.',
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 cloning. */
34  var CLONE_DEEP_FLAG = 1,
35      CLONE_FLAT_FLAG = 2,
36      CLONE_SYMBOLS_FLAG = 4;
37
38  /** Used to compose bitmasks for value comparisons. */
39  var COMPARE_PARTIAL_FLAG = 1,
40      COMPARE_UNORDERED_FLAG = 2;
41
42  /** Used to compose bitmasks for function metadata. */
43  var WRAP_BIND_FLAG = 1,
44      WRAP_BIND_KEY_FLAG = 2,
45      WRAP_CURRY_BOUND_FLAG = 4,
46      WRAP_CURRY_FLAG = 8,
47      WRAP_CURRY_RIGHT_FLAG = 16,
48      WRAP_PARTIAL_FLAG = 32,
49      WRAP_PARTIAL_RIGHT_FLAG = 64,
50      WRAP_ARY_FLAG = 128,
51      WRAP_REARG_FLAG = 256,
52      WRAP_FLIP_FLAG = 512;
53
54  /** Used as default options for `_.truncate`. */
55  var DEFAULT_TRUNC_LENGTH = 30,
56      DEFAULT_TRUNC_OMISSION = '...';
57
58  /** Used to detect hot functions by number of calls within a span of milliseconds. */
59  var HOT_COUNT = 800,
60      HOT_SPAN = 16;
61
62  /** Used to indicate the type of lazy iteratees. */
63  var LAZY_FILTER_FLAG = 1,
64      LAZY_MAP_FLAG = 2,
65      LAZY_WHILE_FLAG = 3;
66
67  /** Used as references for various `Number` constants. */
68  var INFINITY = 1 / 0,
69      MAX_SAFE_INTEGER = 9007199254740991,
70      MAX_INTEGER = 1.7976931348623157e+308,
71      NAN = 0 / 0;
72
73  /** Used as references for the maximum length and index of an array. */
74  var MAX_ARRAY_LENGTH = 4294967295,
75      MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
76      HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
77
78  /** Used to associate wrap methods with their bit flags. */
79  var wrapFlags = [
80    ['ary', WRAP_ARY_FLAG],
81    ['bind', WRAP_BIND_FLAG],
82    ['bindKey', WRAP_BIND_KEY_FLAG],
83    ['curry', WRAP_CURRY_FLAG],
84    ['curryRight', WRAP_CURRY_RIGHT_FLAG],
85    ['flip', WRAP_FLIP_FLAG],
86    ['partial', WRAP_PARTIAL_FLAG],
87    ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
88    ['rearg', WRAP_REARG_FLAG]
89  ];
90
91  /** `Object#toString` result references. */
92  var argsTag = '[object Arguments]',
93      arrayTag = '[object Array]',
94      asyncTag = '[object AsyncFunction]',
95      boolTag = '[object Boolean]',
96      dateTag = '[object Date]',
97      domExcTag = '[object DOMException]',
98      errorTag = '[object Error]',
99      funcTag = '[object Function]',
100      genTag = '[object GeneratorFunction]',
101      mapTag = '[object Map]',
102      numberTag = '[object Number]',
103      nullTag = '[object Null]',
104      objectTag = '[object Object]',
105      promiseTag = '[object Promise]',
106      proxyTag = '[object Proxy]',
107      regexpTag = '[object RegExp]',
108      setTag = '[object Set]',
109      stringTag = '[object String]',
110      symbolTag = '[object Symbol]',
111      undefinedTag = '[object Undefined]',
112      weakMapTag = '[object WeakMap]',
113      weakSetTag = '[object WeakSet]';
114
115  var arrayBufferTag = '[object ArrayBuffer]',
116      dataViewTag = '[object DataView]',
117      float32Tag = '[object Float32Array]',
118      float64Tag = '[object Float64Array]',
119      int8Tag = '[object Int8Array]',
120      int16Tag = '[object Int16Array]',
121      int32Tag = '[object Int32Array]',
122      uint8Tag = '[object Uint8Array]',
123      uint8ClampedTag = '[object Uint8ClampedArray]',
124      uint16Tag = '[object Uint16Array]',
125      uint32Tag = '[object Uint32Array]';
126
127  /** Used to match empty string literals in compiled template source. */
128  var reEmptyStringLeading = /\b__p \+= '';/g,
129      reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
130      reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
131
132  /** Used to match HTML entities and HTML characters. */
133  var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
134      reUnescapedHtml = /[&<>"']/g,
135      reHasEscapedHtml = RegExp(reEscapedHtml.source),
136      reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
137
138  /** Used to match template delimiters. */
139  var reEscape = /<%-([\s\S]+?)%>/g,
140      reEvaluate = /<%([\s\S]+?)%>/g,
141      reInterpolate = /<%=([\s\S]+?)%>/g;
142
143  /** Used to match property names within property paths. */
144  var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
145      reIsPlainProp = /^\w*$/,
146      rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
147
148  /**
149   * Used to match `RegExp`
150   * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
151   */
152  var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
153      reHasRegExpChar = RegExp(reRegExpChar.source);
154
155  /** Used to match leading and trailing whitespace. */
156  var reTrim = /^\s+|\s+$/g,
157      reTrimStart = /^\s+/,
158      reTrimEnd = /\s+$/;
159
160  /** Used to match wrap detail comments. */
161  var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
162      reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
163      reSplitDetails = /,? & /;
164
165  /** Used to match words composed of alphanumeric characters. */
166  var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
167
168  /** Used to match backslashes in property paths. */
169  var reEscapeChar = /\\(\\)?/g;
170
171  /**
172   * Used to match
173   * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
174   */
175  var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
176
177  /** Used to match `RegExp` flags from their coerced string values. */
178  var reFlags = /\w*$/;
179
180  /** Used to detect bad signed hexadecimal string values. */
181  var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
182
183  /** Used to detect binary string values. */
184  var reIsBinary = /^0b[01]+$/i;
185
186  /** Used to detect host constructors (Safari). */
187  var reIsHostCtor = /^\[object .+?Constructor\]$/;
188
189  /** Used to detect octal string values. */
190  var reIsOctal = /^0o[0-7]+$/i;
191
192  /** Used to detect unsigned integer values. */
193  var reIsUint = /^(?:0|[1-9]\d*)$/;
194
195  /** Used to match Latin Unicode letters (excluding mathematical operators). */
196  var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
197
198  /** Used to ensure capturing order of template delimiters. */
199  var reNoMatch = /($^)/;
200
201  /** Used to match unescaped characters in compiled string literals. */
202  var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
203
204  /** Used to compose unicode character classes. */
205  var rsAstralRange = '\\ud800-\\udfff',
206      rsComboMarksRange = '\\u0300-\\u036f',
207      reComboHalfMarksRange = '\\ufe20-\\ufe2f',
208      rsComboSymbolsRange = '\\u20d0-\\u20ff',
209      rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
210      rsDingbatRange = '\\u2700-\\u27bf',
211      rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
212      rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
213      rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
214      rsPunctuationRange = '\\u2000-\\u206f',
215      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',
216      rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
217      rsVarRange = '\\ufe0e\\ufe0f',
218      rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
219
220  /** Used to compose unicode capture groups. */
221  var rsApos = "['\u2019]",
222      rsAstral = '[' + rsAstralRange + ']',
223      rsBreak = '[' + rsBreakRange + ']',
224      rsCombo = '[' + rsComboRange + ']',
225      rsDigits = '\\d+',
226      rsDingbat = '[' + rsDingbatRange + ']',
227      rsLower = '[' + rsLowerRange + ']',
228      rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
229      rsFitz = '\\ud83c[\\udffb-\\udfff]',
230      rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
231      rsNonAstral = '[^' + rsAstralRange + ']',
232      rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
233      rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
234      rsUpper = '[' + rsUpperRange + ']',
235      rsZWJ = '\\u200d';
236
237  /** Used to compose unicode regexes. */
238  var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
239      rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
240      rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
241      rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
242      reOptMod = rsModifier + '?',
243      rsOptVar = '[' + rsVarRange + ']?',
244      rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
245      rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
246      rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
247      rsSeq = rsOptVar + reOptMod + rsOptJoin,
248      rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
249      rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
250
251  /** Used to match apostrophes. */
252  var reApos = RegExp(rsApos, 'g');
253
254  /**
255   * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
256   * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
257   */
258  var reComboMark = RegExp(rsCombo, 'g');
259
260  /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
261  var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
262
263  /** Used to match complex or compound words. */
264  var reUnicodeWord = RegExp([
265    rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
266    rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
267    rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
268    rsUpper + '+' + rsOptContrUpper,
269    rsOrdUpper,
270    rsOrdLower,
271    rsDigits,
272    rsEmoji
273  ].join('|'), 'g');
274
275  /** 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/). */
276  var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange  + rsComboRange + rsVarRange + ']');
277
278  /** Used to detect strings that need a more robust regexp to match words. */
279  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 ]/;
280
281  /** Used to assign default `context` object properties. */
282  var contextProps = [
283    'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
284    'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
285    'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
286    'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
287    '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
288  ];
289
290  /** Used to make template sourceURLs easier to identify. */
291  var templateCounter = -1;
292
293  /** Used to identify `toStringTag` values of typed arrays. */
294  var typedArrayTags = {};
295  typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
296  typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
297  typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
298  typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
299  typedArrayTags[uint32Tag] = true;
300  typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
301  typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
302  typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
303  typedArrayTags[errorTag] = typedArrayTags[funcTag] =
304  typedArrayTags[mapTag] = typedArrayTags[numberTag] =
305  typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
306  typedArrayTags[setTag] = typedArrayTags[stringTag] =
307  typedArrayTags[weakMapTag] = false;
308
309  /** Used to identify `toStringTag` values supported by `_.clone`. */
310  var cloneableTags = {};
311  cloneableTags[argsTag] = cloneableTags[arrayTag] =
312  cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
313  cloneableTags[boolTag] = cloneableTags[dateTag] =
314  cloneableTags[float32Tag] = cloneableTags[float64Tag] =
315  cloneableTags[int8Tag] = cloneableTags[int16Tag] =
316  cloneableTags[int32Tag] = cloneableTags[mapTag] =
317  cloneableTags[numberTag] = cloneableTags[objectTag] =
318  cloneableTags[regexpTag] = cloneableTags[setTag] =
319  cloneableTags[stringTag] = cloneableTags[symbolTag] =
320  cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
321  cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
322  cloneableTags[errorTag] = cloneableTags[funcTag] =
323  cloneableTags[weakMapTag] = false;
324
325  /** Used to map Latin Unicode letters to basic Latin letters. */
326  var deburredLetters = {
327    // Latin-1 Supplement block.
328    '\xc0': 'A',  '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
329    '\xe0': 'a',  '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
330    '\xc7': 'C',  '\xe7': 'c',
331    '\xd0': 'D',  '\xf0': 'd',
332    '\xc8': 'E',  '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
333    '\xe8': 'e',  '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
334    '\xcc': 'I',  '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
335    '\xec': 'i',  '\xed': 'i', '\xee': 'i', '\xef': 'i',
336    '\xd1': 'N',  '\xf1': 'n',
337    '\xd2': 'O',  '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
338    '\xf2': 'o',  '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
339    '\xd9': 'U',  '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
340    '\xf9': 'u',  '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
341    '\xdd': 'Y',  '\xfd': 'y', '\xff': 'y',
342    '\xc6': 'Ae', '\xe6': 'ae',
343    '\xde': 'Th', '\xfe': 'th',
344    '\xdf': 'ss',
345    // Latin Extended-A block.
346    '\u0100': 'A',  '\u0102': 'A', '\u0104': 'A',
347    '\u0101': 'a',  '\u0103': 'a', '\u0105': 'a',
348    '\u0106': 'C',  '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
349    '\u0107': 'c',  '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
350    '\u010e': 'D',  '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
351    '\u0112': 'E',  '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
352    '\u0113': 'e',  '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
353    '\u011c': 'G',  '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
354    '\u011d': 'g',  '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
355    '\u0124': 'H',  '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
356    '\u0128': 'I',  '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
357    '\u0129': 'i',  '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
358    '\u0134': 'J',  '\u0135': 'j',
359    '\u0136': 'K',  '\u0137': 'k', '\u0138': 'k',
360    '\u0139': 'L',  '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
361    '\u013a': 'l',  '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
362    '\u0143': 'N',  '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
363    '\u0144': 'n',  '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
364    '\u014c': 'O',  '\u014e': 'O', '\u0150': 'O',
365    '\u014d': 'o',  '\u014f': 'o', '\u0151': 'o',
366    '\u0154': 'R',  '\u0156': 'R', '\u0158': 'R',
367    '\u0155': 'r',  '\u0157': 'r', '\u0159': 'r',
368    '\u015a': 'S',  '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
369    '\u015b': 's',  '\u015d': 's', '\u015f': 's', '\u0161': 's',
370    '\u0162': 'T',  '\u0164': 'T', '\u0166': 'T',
371    '\u0163': 't',  '\u0165': 't', '\u0167': 't',
372    '\u0168': 'U',  '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
373    '\u0169': 'u',  '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
374    '\u0174': 'W',  '\u0175': 'w',
375    '\u0176': 'Y',  '\u0177': 'y', '\u0178': 'Y',
376    '\u0179': 'Z',  '\u017b': 'Z', '\u017d': 'Z',
377    '\u017a': 'z',  '\u017c': 'z', '\u017e': 'z',
378    '\u0132': 'IJ', '\u0133': 'ij',
379    '\u0152': 'Oe', '\u0153': 'oe',
380    '\u0149': "'n", '\u017f': 's'
381  };
382
383  /** Used to map characters to HTML entities. */
384  var htmlEscapes = {
385    '&': '&amp;',
386    '<': '&lt;',
387    '>': '&gt;',
388    '"': '&quot;',
389    "'": '&#39;'
390  };
391
392  /** Used to map HTML entities to characters. */
393  var htmlUnescapes = {
394    '&amp;': '&',
395    '&lt;': '<',
396    '&gt;': '>',
397    '&quot;': '"',
398    '&#39;': "'"
399  };
400
401  /** Used to escape characters for inclusion in compiled string literals. */
402  var stringEscapes = {
403    '\\': '\\',
404    "'": "'",
405    '\n': 'n',
406    '\r': 'r',
407    '\u2028': 'u2028',
408    '\u2029': 'u2029'
409  };
410
411  /** Built-in method references without a dependency on `root`. */
412  var freeParseFloat = parseFloat,
413      freeParseInt = parseInt;
414
415  /** Detect free variable `global` from Node.js. */
416  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
417
418  /** Detect free variable `self`. */
419  var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
420
421  /** Used as a reference to the global object. */
422  var root = freeGlobal || freeSelf || Function('return this')();
423
424  /** Detect free variable `exports`. */
425  var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
426
427  /** Detect free variable `module`. */
428  var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
429
430  /** Detect the popular CommonJS extension `module.exports`. */
431  var moduleExports = freeModule && freeModule.exports === freeExports;
432
433  /** Detect free variable `process` from Node.js. */
434  var freeProcess = moduleExports && freeGlobal.process;
435
436  /** Used to access faster Node.js helpers. */
437  var nodeUtil = (function() {
438    try {
439      // Use `util.types` for Node.js 10+.
440      var types = freeModule && freeModule.require && freeModule.require('util').types;
441
442      if (types) {
443        return types;
444      }
445
446      // Legacy `process.binding('util')` for Node.js < 10.
447      return freeProcess && freeProcess.binding && freeProcess.binding('util');
448    } catch (e) {}
449  }());
450
451  /* Node.js helper references. */
452  var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
453      nodeIsDate = nodeUtil && nodeUtil.isDate,
454      nodeIsMap = nodeUtil && nodeUtil.isMap,
455      nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
456      nodeIsSet = nodeUtil && nodeUtil.isSet,
457      nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
458
459  /*--------------------------------------------------------------------------*/
460
461  /**
462   * A faster alternative to `Function#apply`, this function invokes `func`
463   * with the `this` binding of `thisArg` and the arguments of `args`.
464   *
465   * @private
466   * @param {Function} func The function to invoke.
467   * @param {*} thisArg The `this` binding of `func`.
468   * @param {Array} args The arguments to invoke `func` with.
469   * @returns {*} Returns the result of `func`.
470   */
471  function apply(func, thisArg, args) {
472    switch (args.length) {
473      case 0: return func.call(thisArg);
474      case 1: return func.call(thisArg, args[0]);
475      case 2: return func.call(thisArg, args[0], args[1]);
476      case 3: return func.call(thisArg, args[0], args[1], args[2]);
477    }
478    return func.apply(thisArg, args);
479  }
480
481  /**
482   * A specialized version of `baseAggregator` for arrays.
483   *
484   * @private
485   * @param {Array} [array] The array to iterate over.
486   * @param {Function} setter The function to set `accumulator` values.
487   * @param {Function} iteratee The iteratee to transform keys.
488   * @param {Object} accumulator The initial aggregated object.
489   * @returns {Function} Returns `accumulator`.
490   */
491  function arrayAggregator(array, setter, iteratee, accumulator) {
492    var index = -1,
493        length = array == null ? 0 : array.length;
494
495    while (++index < length) {
496      var value = array[index];
497      setter(accumulator, value, iteratee(value), array);
498    }
499    return accumulator;
500  }
501
502  /**
503   * A specialized version of `_.forEach` for arrays without support for
504   * iteratee shorthands.
505   *
506   * @private
507   * @param {Array} [array] The array to iterate over.
508   * @param {Function} iteratee The function invoked per iteration.
509   * @returns {Array} Returns `array`.
510   */
511  function arrayEach(array, iteratee) {
512    var index = -1,
513        length = array == null ? 0 : array.length;
514
515    while (++index < length) {
516      if (iteratee(array[index], index, array) === false) {
517        break;
518      }
519    }
520    return array;
521  }
522
523  /**
524   * A specialized version of `_.forEachRight` for arrays without support for
525   * iteratee shorthands.
526   *
527   * @private
528   * @param {Array} [array] The array to iterate over.
529   * @param {Function} iteratee The function invoked per iteration.
530   * @returns {Array} Returns `array`.
531   */
532  function arrayEachRight(array, iteratee) {
533    var length = array == null ? 0 : array.length;
534
535    while (length--) {
536      if (iteratee(array[length], length, array) === false) {
537        break;
538      }
539    }
540    return array;
541  }
542
543  /**
544   * A specialized version of `_.every` for arrays without support for
545   * iteratee shorthands.
546   *
547   * @private
548   * @param {Array} [array] The array to iterate over.
549   * @param {Function} predicate The function invoked per iteration.
550   * @returns {boolean} Returns `true` if all elements pass the predicate check,
551   *  else `false`.
552   */
553  function arrayEvery(array, predicate) {
554    var index = -1,
555        length = array == null ? 0 : array.length;
556
557    while (++index < length) {
558      if (!predicate(array[index], index, array)) {
559        return false;
560      }
561    }
562    return true;
563  }
564
565  /**
566   * A specialized version of `_.filter` for arrays without support for
567   * iteratee shorthands.
568   *
569   * @private
570   * @param {Array} [array] The array to iterate over.
571   * @param {Function} predicate The function invoked per iteration.
572   * @returns {Array} Returns the new filtered array.
573   */
574  function arrayFilter(array, predicate) {
575    var index = -1,
576        length = array == null ? 0 : array.length,
577        resIndex = 0,
578        result = [];
579
580    while (++index < length) {
581      var value = array[index];
582      if (predicate(value, index, array)) {
583        result[resIndex++] = value;
584      }
585    }
586    return result;
587  }
588
589  /**
590   * A specialized version of `_.includes` for arrays without support for
591   * specifying an index to search from.
592   *
593   * @private
594   * @param {Array} [array] The array to inspect.
595   * @param {*} target The value to search for.
596   * @returns {boolean} Returns `true` if `target` is found, else `false`.
597   */
598  function arrayIncludes(array, value) {
599    var length = array == null ? 0 : array.length;
600    return !!length && baseIndexOf(array, value, 0) > -1;
601  }
602
603  /**
604   * This function is like `arrayIncludes` except that it accepts a comparator.
605   *
606   * @private
607   * @param {Array} [array] The array to inspect.
608   * @param {*} target The value to search for.
609   * @param {Function} comparator The comparator invoked per element.
610   * @returns {boolean} Returns `true` if `target` is found, else `false`.
611   */
612  function arrayIncludesWith(array, value, comparator) {
613    var index = -1,
614        length = array == null ? 0 : array.length;
615
616    while (++index < length) {
617      if (comparator(value, array[index])) {
618        return true;
619      }
620    }
621    return false;
622  }
623
624  /**
625   * A specialized version of `_.map` for arrays without support for iteratee
626   * shorthands.
627   *
628   * @private
629   * @param {Array} [array] The array to iterate over.
630   * @param {Function} iteratee The function invoked per iteration.
631   * @returns {Array} Returns the new mapped array.
632   */
633  function arrayMap(array, iteratee) {
634    var index = -1,
635        length = array == null ? 0 : array.length,
636        result = Array(length);
637
638    while (++index < length) {
639      result[index] = iteratee(array[index], index, array);
640    }
641    return result;
642  }
643
644  /**
645   * Appends the elements of `values` to `array`.
646   *
647   * @private
648   * @param {Array} array The array to modify.
649   * @param {Array} values The values to append.
650   * @returns {Array} Returns `array`.
651   */
652  function arrayPush(array, values) {
653    var index = -1,
654        length = values.length,
655        offset = array.length;
656
657    while (++index < length) {
658      array[offset + index] = values[index];
659    }
660    return array;
661  }
662
663  /**
664   * A specialized version of `_.reduce` for arrays without support for
665   * iteratee shorthands.
666   *
667   * @private
668   * @param {Array} [array] The array to iterate over.
669   * @param {Function} iteratee The function invoked per iteration.
670   * @param {*} [accumulator] The initial value.
671   * @param {boolean} [initAccum] Specify using the first element of `array` as
672   *  the initial value.
673   * @returns {*} Returns the accumulated value.
674   */
675  function arrayReduce(array, iteratee, accumulator, initAccum) {
676    var index = -1,
677        length = array == null ? 0 : array.length;
678
679    if (initAccum && length) {
680      accumulator = array[++index];
681    }
682    while (++index < length) {
683      accumulator = iteratee(accumulator, array[index], index, array);
684    }
685    return accumulator;
686  }
687
688  /**
689   * A specialized version of `_.reduceRight` for arrays without support for
690   * iteratee shorthands.
691   *
692   * @private
693   * @param {Array} [array] The array to iterate over.
694   * @param {Function} iteratee The function invoked per iteration.
695   * @param {*} [accumulator] The initial value.
696   * @param {boolean} [initAccum] Specify using the last element of `array` as
697   *  the initial value.
698   * @returns {*} Returns the accumulated value.
699   */
700  function arrayReduceRight(array, iteratee, accumulator, initAccum) {
701    var length = array == null ? 0 : array.length;
702    if (initAccum && length) {
703      accumulator = array[--length];
704    }
705    while (length--) {
706      accumulator = iteratee(accumulator, array[length], length, array);
707    }
708    return accumulator;
709  }
710
711  /**
712   * A specialized version of `_.some` for arrays without support for iteratee
713   * shorthands.
714   *
715   * @private
716   * @param {Array} [array] The array to iterate over.
717   * @param {Function} predicate The function invoked per iteration.
718   * @returns {boolean} Returns `true` if any element passes the predicate check,
719   *  else `false`.
720   */
721  function arraySome(array, predicate) {
722    var index = -1,
723        length = array == null ? 0 : array.length;
724
725    while (++index < length) {
726      if (predicate(array[index], index, array)) {
727        return true;
728      }
729    }
730    return false;
731  }
732
733  /**
734   * Gets the size of an ASCII `string`.
735   *
736   * @private
737   * @param {string} string The string inspect.
738   * @returns {number} Returns the string size.
739   */
740  var asciiSize = baseProperty('length');
741
742  /**
743   * Converts an ASCII `string` to an array.
744   *
745   * @private
746   * @param {string} string The string to convert.
747   * @returns {Array} Returns the converted array.
748   */
749  function asciiToArray(string) {
750    return string.split('');
751  }
752
753  /**
754   * Splits an ASCII `string` into an array of its words.
755   *
756   * @private
757   * @param {string} The string to inspect.
758   * @returns {Array} Returns the words of `string`.
759   */
760  function asciiWords(string) {
761    return string.match(reAsciiWord) || [];
762  }
763
764  /**
765   * The base implementation of methods like `_.findKey` and `_.findLastKey`,
766   * without support for iteratee shorthands, which iterates over `collection`
767   * using `eachFunc`.
768   *
769   * @private
770   * @param {Array|Object} collection The collection to inspect.
771   * @param {Function} predicate The function invoked per iteration.
772   * @param {Function} eachFunc The function to iterate over `collection`.
773   * @returns {*} Returns the found element or its key, else `undefined`.
774   */
775  function baseFindKey(collection, predicate, eachFunc) {
776    var result;
777    eachFunc(collection, function(value, key, collection) {
778      if (predicate(value, key, collection)) {
779        result = key;
780        return false;
781      }
782    });
783    return result;
784  }
785
786  /**
787   * The base implementation of `_.findIndex` and `_.findLastIndex` without
788   * support for iteratee shorthands.
789   *
790   * @private
791   * @param {Array} array The array to inspect.
792   * @param {Function} predicate The function invoked per iteration.
793   * @param {number} fromIndex The index to search from.
794   * @param {boolean} [fromRight] Specify iterating from right to left.
795   * @returns {number} Returns the index of the matched value, else `-1`.
796   */
797  function baseFindIndex(array, predicate, fromIndex, fromRight) {
798    var length = array.length,
799        index = fromIndex + (fromRight ? 1 : -1);
800
801    while ((fromRight ? index-- : ++index < length)) {
802      if (predicate(array[index], index, array)) {
803        return index;
804      }
805    }
806    return -1;
807  }
808
809  /**
810   * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
811   *
812   * @private
813   * @param {Array} array The array to inspect.
814   * @param {*} value The value to search for.
815   * @param {number} fromIndex The index to search from.
816   * @returns {number} Returns the index of the matched value, else `-1`.
817   */
818  function baseIndexOf(array, value, fromIndex) {
819    return value === value
820      ? strictIndexOf(array, value, fromIndex)
821      : baseFindIndex(array, baseIsNaN, fromIndex);
822  }
823
824  /**
825   * This function is like `baseIndexOf` except that it accepts a comparator.
826   *
827   * @private
828   * @param {Array} array The array to inspect.
829   * @param {*} value The value to search for.
830   * @param {number} fromIndex The index to search from.
831   * @param {Function} comparator The comparator invoked per element.
832   * @returns {number} Returns the index of the matched value, else `-1`.
833   */
834  function baseIndexOfWith(array, value, fromIndex, comparator) {
835    var index = fromIndex - 1,
836        length = array.length;
837
838    while (++index < length) {
839      if (comparator(array[index], value)) {
840        return index;
841      }
842    }
843    return -1;
844  }
845
846  /**
847   * The base implementation of `_.isNaN` without support for number objects.
848   *
849   * @private
850   * @param {*} value The value to check.
851   * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
852   */
853  function baseIsNaN(value) {
854    return value !== value;
855  }
856
857  /**
858   * The base implementation of `_.mean` and `_.meanBy` without support for
859   * iteratee shorthands.
860   *
861   * @private
862   * @param {Array} array The array to iterate over.
863   * @param {Function} iteratee The function invoked per iteration.
864   * @returns {number} Returns the mean.
865   */
866  function baseMean(array, iteratee) {
867    var length = array == null ? 0 : array.length;
868    return length ? (baseSum(array, iteratee) / length) : NAN;
869  }
870
871  /**
872   * The base implementation of `_.property` without support for deep paths.
873   *
874   * @private
875   * @param {string} key The key of the property to get.
876   * @returns {Function} Returns the new accessor function.
877   */
878  function baseProperty(key) {
879    return function(object) {
880      return object == null ? undefined : object[key];
881    };
882  }
883
884  /**
885   * The base implementation of `_.propertyOf` without support for deep paths.
886   *
887   * @private
888   * @param {Object} object The object to query.
889   * @returns {Function} Returns the new accessor function.
890   */
891  function basePropertyOf(object) {
892    return function(key) {
893      return object == null ? undefined : object[key];
894    };
895  }
896
897  /**
898   * The base implementation of `_.reduce` and `_.reduceRight`, without support
899   * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
900   *
901   * @private
902   * @param {Array|Object} collection The collection to iterate over.
903   * @param {Function} iteratee The function invoked per iteration.
904   * @param {*} accumulator The initial value.
905   * @param {boolean} initAccum Specify using the first or last element of
906   *  `collection` as the initial value.
907   * @param {Function} eachFunc The function to iterate over `collection`.
908   * @returns {*} Returns the accumulated value.
909   */
910  function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
911    eachFunc(collection, function(value, index, collection) {
912      accumulator = initAccum
913        ? (initAccum = false, value)
914        : iteratee(accumulator, value, index, collection);
915    });
916    return accumulator;
917  }
918
919  /**
920   * The base implementation of `_.sortBy` which uses `comparer` to define the
921   * sort order of `array` and replaces criteria objects with their corresponding
922   * values.
923   *
924   * @private
925   * @param {Array} array The array to sort.
926   * @param {Function} comparer The function to define sort order.
927   * @returns {Array} Returns `array`.
928   */
929  function baseSortBy(array, comparer) {
930    var length = array.length;
931
932    array.sort(comparer);
933    while (length--) {
934      array[length] = array[length].value;
935    }
936    return array;
937  }
938
939  /**
940   * The base implementation of `_.sum` and `_.sumBy` without support for
941   * iteratee shorthands.
942   *
943   * @private
944   * @param {Array} array The array to iterate over.
945   * @param {Function} iteratee The function invoked per iteration.
946   * @returns {number} Returns the sum.
947   */
948  function baseSum(array, iteratee) {
949    var result,
950        index = -1,
951        length = array.length;
952
953    while (++index < length) {
954      var current = iteratee(array[index]);
955      if (current !== undefined) {
956        result = result === undefined ? current : (result + current);
957      }
958    }
959    return result;
960  }
961
962  /**
963   * The base implementation of `_.times` without support for iteratee shorthands
964   * or max array length checks.
965   *
966   * @private
967   * @param {number} n The number of times to invoke `iteratee`.
968   * @param {Function} iteratee The function invoked per iteration.
969   * @returns {Array} Returns the array of results.
970   */
971  function baseTimes(n, iteratee) {
972    var index = -1,
973        result = Array(n);
974
975    while (++index < n) {
976      result[index] = iteratee(index);
977    }
978    return result;
979  }
980
981  /**
982   * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
983   * of key-value pairs for `object` corresponding to the property names of `props`.
984   *
985   * @private
986   * @param {Object} object The object to query.
987   * @param {Array} props The property names to get values for.
988   * @returns {Object} Returns the key-value pairs.
989   */
990  function baseToPairs(object, props) {
991    return arrayMap(props, function(key) {
992      return [key, object[key]];
993    });
994  }
995
996  /**
997   * The base implementation of `_.unary` without support for storing metadata.
998   *
999   * @private
1000   * @param {Function} func The function to cap arguments for.
1001   * @returns {Function} Returns the new capped function.
1002   */
1003  function baseUnary(func) {
1004    return function(value) {
1005      return func(value);
1006    };
1007  }
1008
1009  /**
1010   * The base implementation of `_.values` and `_.valuesIn` which creates an
1011   * array of `object` property values corresponding to the property names
1012   * of `props`.
1013   *
1014   * @private
1015   * @param {Object} object The object to query.
1016   * @param {Array} props The property names to get values for.
1017   * @returns {Object} Returns the array of property values.
1018   */
1019  function baseValues(object, props) {
1020    return arrayMap(props, function(key) {
1021      return object[key];
1022    });
1023  }
1024
1025  /**
1026   * Checks if a `cache` value for `key` exists.
1027   *
1028   * @private
1029   * @param {Object} cache The cache to query.
1030   * @param {string} key The key of the entry to check.
1031   * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1032   */
1033  function cacheHas(cache, key) {
1034    return cache.has(key);
1035  }
1036
1037  /**
1038   * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1039   * that is not found in the character symbols.
1040   *
1041   * @private
1042   * @param {Array} strSymbols The string symbols to inspect.
1043   * @param {Array} chrSymbols The character symbols to find.
1044   * @returns {number} Returns the index of the first unmatched string symbol.
1045   */
1046  function charsStartIndex(strSymbols, chrSymbols) {
1047    var index = -1,
1048        length = strSymbols.length;
1049
1050    while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1051    return index;
1052  }
1053
1054  /**
1055   * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1056   * that is not found in the character symbols.
1057   *
1058   * @private
1059   * @param {Array} strSymbols The string symbols to inspect.
1060   * @param {Array} chrSymbols The character symbols to find.
1061   * @returns {number} Returns the index of the last unmatched string symbol.
1062   */
1063  function charsEndIndex(strSymbols, chrSymbols) {
1064    var index = strSymbols.length;
1065
1066    while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1067    return index;
1068  }
1069
1070  /**
1071   * Gets the number of `placeholder` occurrences in `array`.
1072   *
1073   * @private
1074   * @param {Array} array The array to inspect.
1075   * @param {*} placeholder The placeholder to search for.
1076   * @returns {number} Returns the placeholder count.
1077   */
1078  function countHolders(array, placeholder) {
1079    var length = array.length,
1080        result = 0;
1081
1082    while (length--) {
1083      if (array[length] === placeholder) {
1084        ++result;
1085      }
1086    }
1087    return result;
1088  }
1089
1090  /**
1091   * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1092   * letters to basic Latin letters.
1093   *
1094   * @private
1095   * @param {string} letter The matched letter to deburr.
1096   * @returns {string} Returns the deburred letter.
1097   */
1098  var deburrLetter = basePropertyOf(deburredLetters);
1099
1100  /**
1101   * Used by `_.escape` to convert characters to HTML entities.
1102   *
1103   * @private
1104   * @param {string} chr The matched character to escape.
1105   * @returns {string} Returns the escaped character.
1106   */
1107  var escapeHtmlChar = basePropertyOf(htmlEscapes);
1108
1109  /**
1110   * Used by `_.template` to escape characters for inclusion in compiled string literals.
1111   *
1112   * @private
1113   * @param {string} chr The matched character to escape.
1114   * @returns {string} Returns the escaped character.
1115   */
1116  function escapeStringChar(chr) {
1117    return '\\' + stringEscapes[chr];
1118  }
1119
1120  /**
1121   * Gets the value at `key` of `object`.
1122   *
1123   * @private
1124   * @param {Object} [object] The object to query.
1125   * @param {string} key The key of the property to get.
1126   * @returns {*} Returns the property value.
1127   */
1128  function getValue(object, key) {
1129    return object == null ? undefined : object[key];
1130  }
1131
1132  /**
1133   * Checks if `string` contains Unicode symbols.
1134   *
1135   * @private
1136   * @param {string} string The string to inspect.
1137   * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1138   */
1139  function hasUnicode(string) {
1140    return reHasUnicode.test(string);
1141  }
1142
1143  /**
1144   * Checks if `string` contains a word composed of Unicode symbols.
1145   *
1146   * @private
1147   * @param {string} string The string to inspect.
1148   * @returns {boolean} Returns `true` if a word is found, else `false`.
1149   */
1150  function hasUnicodeWord(string) {
1151    return reHasUnicodeWord.test(string);
1152  }
1153
1154  /**
1155   * Converts `iterator` to an array.
1156   *
1157   * @private
1158   * @param {Object} iterator The iterator to convert.
1159   * @returns {Array} Returns the converted array.
1160   */
1161  function iteratorToArray(iterator) {
1162    var data,
1163        result = [];
1164
1165    while (!(data = iterator.next()).done) {
1166      result.push(data.value);
1167    }
1168    return result;
1169  }
1170
1171  /**
1172   * Converts `map` to its key-value pairs.
1173   *
1174   * @private
1175   * @param {Object} map The map to convert.
1176   * @returns {Array} Returns the key-value pairs.
1177   */
1178  function mapToArray(map) {
1179    var index = -1,
1180        result = Array(map.size);
1181
1182    map.forEach(function(value, key) {
1183      result[++index] = [key, value];
1184    });
1185    return result;
1186  }
1187
1188  /**
1189   * Creates a unary function that invokes `func` with its argument transformed.
1190   *
1191   * @private
1192   * @param {Function} func The function to wrap.
1193   * @param {Function} transform The argument transform.
1194   * @returns {Function} Returns the new function.
1195   */
1196  function overArg(func, transform) {
1197    return function(arg) {
1198      return func(transform(arg));
1199    };
1200  }
1201
1202  /**
1203   * Replaces all `placeholder` elements in `array` with an internal placeholder
1204   * and returns an array of their indexes.
1205   *
1206   * @private
1207   * @param {Array} array The array to modify.
1208   * @param {*} placeholder The placeholder to replace.
1209   * @returns {Array} Returns the new array of placeholder indexes.
1210   */
1211  function replaceHolders(array, placeholder) {
1212    var index = -1,
1213        length = array.length,
1214        resIndex = 0,
1215        result = [];
1216
1217    while (++index < length) {
1218      var value = array[index];
1219      if (value === placeholder || value === PLACEHOLDER) {
1220        array[index] = PLACEHOLDER;
1221        result[resIndex++] = index;
1222      }
1223    }
1224    return result;
1225  }
1226
1227  /**
1228   * Converts `set` to an array of its values.
1229   *
1230   * @private
1231   * @param {Object} set The set to convert.
1232   * @returns {Array} Returns the values.
1233   */
1234  function setToArray(set) {
1235    var index = -1,
1236        result = Array(set.size);
1237
1238    set.forEach(function(value) {
1239      result[++index] = value;
1240    });
1241    return result;
1242  }
1243
1244  /**
1245   * Converts `set` to its value-value pairs.
1246   *
1247   * @private
1248   * @param {Object} set The set to convert.
1249   * @returns {Array} Returns the value-value pairs.
1250   */
1251  function setToPairs(set) {
1252    var index = -1,
1253        result = Array(set.size);
1254
1255    set.forEach(function(value) {
1256      result[++index] = [value, value];
1257    });
1258    return result;
1259  }
1260
1261  /**
1262   * A specialized version of `_.indexOf` which performs strict equality
1263   * comparisons of values, i.e. `===`.
1264   *
1265   * @private
1266   * @param {Array} array The array to inspect.
1267   * @param {*} value The value to search for.
1268   * @param {number} fromIndex The index to search from.
1269   * @returns {number} Returns the index of the matched value, else `-1`.
1270   */
1271  function strictIndexOf(array, value, fromIndex) {
1272    var index = fromIndex - 1,
1273        length = array.length;
1274
1275    while (++index < length) {
1276      if (array[index] === value) {
1277        return index;
1278      }
1279    }
1280    return -1;
1281  }
1282
1283  /**
1284   * A specialized version of `_.lastIndexOf` which performs strict equality
1285   * comparisons of values, i.e. `===`.
1286   *
1287   * @private
1288   * @param {Array} array The array to inspect.
1289   * @param {*} value The value to search for.
1290   * @param {number} fromIndex The index to search from.
1291   * @returns {number} Returns the index of the matched value, else `-1`.
1292   */
1293  function strictLastIndexOf(array, value, fromIndex) {
1294    var index = fromIndex + 1;
1295    while (index--) {
1296      if (array[index] === value) {
1297        return index;
1298      }
1299    }
1300    return index;
1301  }
1302
1303  /**
1304   * Gets the number of symbols in `string`.
1305   *
1306   * @private
1307   * @param {string} string The string to inspect.
1308   * @returns {number} Returns the string size.
1309   */
1310  function stringSize(string) {
1311    return hasUnicode(string)
1312      ? unicodeSize(string)
1313      : asciiSize(string);
1314  }
1315
1316  /**
1317   * Converts `string` to an array.
1318   *
1319   * @private
1320   * @param {string} string The string to convert.
1321   * @returns {Array} Returns the converted array.
1322   */
1323  function stringToArray(string) {
1324    return hasUnicode(string)
1325      ? unicodeToArray(string)
1326      : asciiToArray(string);
1327  }
1328
1329  /**
1330   * Used by `_.unescape` to convert HTML entities to characters.
1331   *
1332   * @private
1333   * @param {string} chr The matched character to unescape.
1334   * @returns {string} Returns the unescaped character.
1335   */
1336  var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1337
1338  /**
1339   * Gets the size of a Unicode `string`.
1340   *
1341   * @private
1342   * @param {string} string The string inspect.
1343   * @returns {number} Returns the string size.
1344   */
1345  function unicodeSize(string) {
1346    var result = reUnicode.lastIndex = 0;
1347    while (reUnicode.test(string)) {
1348      ++result;
1349    }
1350    return result;
1351  }
1352
1353  /**
1354   * Converts a Unicode `string` to an array.
1355   *
1356   * @private
1357   * @param {string} string The string to convert.
1358   * @returns {Array} Returns the converted array.
1359   */
1360  function unicodeToArray(string) {
1361    return string.match(reUnicode) || [];
1362  }
1363
1364  /**
1365   * Splits a Unicode `string` into an array of its words.
1366   *
1367   * @private
1368   * @param {string} The string to inspect.
1369   * @returns {Array} Returns the words of `string`.
1370   */
1371  function unicodeWords(string) {
1372    return string.match(reUnicodeWord) || [];
1373  }
1374
1375  /*--------------------------------------------------------------------------*/
1376
1377  /**
1378   * Create a new pristine `lodash` function using the `context` object.
1379   *
1380   * @static
1381   * @memberOf _
1382   * @since 1.1.0
1383   * @category Util
1384   * @param {Object} [context=root] The context object.
1385   * @returns {Function} Returns a new `lodash` function.
1386   * @example
1387   *
1388   * _.mixin({ 'foo': _.constant('foo') });
1389   *
1390   * var lodash = _.runInContext();
1391   * lodash.mixin({ 'bar': lodash.constant('bar') });
1392   *
1393   * _.isFunction(_.foo);
1394   * // => true
1395   * _.isFunction(_.bar);
1396   * // => false
1397   *
1398   * lodash.isFunction(lodash.foo);
1399   * // => false
1400   * lodash.isFunction(lodash.bar);
1401   * // => true
1402   *
1403   * // Create a suped-up `defer` in Node.js.
1404   * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1405   */
1406  var runInContext = (function runInContext(context) {
1407    context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1408
1409    /** Built-in constructor references. */
1410    var Array = context.Array,
1411        Date = context.Date,
1412        Error = context.Error,
1413        Function = context.Function,
1414        Math = context.Math,
1415        Object = context.Object,
1416        RegExp = context.RegExp,
1417        String = context.String,
1418        TypeError = context.TypeError;
1419
1420    /** Used for built-in method references. */
1421    var arrayProto = Array.prototype,
1422        funcProto = Function.prototype,
1423        objectProto = Object.prototype;
1424
1425    /** Used to detect overreaching core-js shims. */
1426    var coreJsData = context['__core-js_shared__'];
1427
1428    /** Used to resolve the decompiled source of functions. */
1429    var funcToString = funcProto.toString;
1430
1431    /** Used to check objects for own properties. */
1432    var hasOwnProperty = objectProto.hasOwnProperty;
1433
1434    /** Used to generate unique IDs. */
1435    var idCounter = 0;
1436
1437    /** Used to detect methods masquerading as native. */
1438    var maskSrcKey = (function() {
1439      var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1440      return uid ? ('Symbol(src)_1.' + uid) : '';
1441    }());
1442
1443    /**
1444     * Used to resolve the
1445     * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1446     * of values.
1447     */
1448    var nativeObjectToString = objectProto.toString;
1449
1450    /** Used to infer the `Object` constructor. */
1451    var objectCtorString = funcToString.call(Object);
1452
1453    /** Used to restore the original `_` reference in `_.noConflict`. */
1454    var oldDash = root._;
1455
1456    /** Used to detect if a method is native. */
1457    var reIsNative = RegExp('^' +
1458      funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1459      .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1460    );
1461
1462    /** Built-in value references. */
1463    var Buffer = moduleExports ? context.Buffer : undefined,
1464        Symbol = context.Symbol,
1465        Uint8Array = context.Uint8Array,
1466        allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
1467        getPrototype = overArg(Object.getPrototypeOf, Object),
1468        objectCreate = Object.create,
1469        propertyIsEnumerable = objectProto.propertyIsEnumerable,
1470        splice = arrayProto.splice,
1471        spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
1472        symIterator = Symbol ? Symbol.iterator : undefined,
1473        symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1474
1475    var defineProperty = (function() {
1476      try {
1477        var func = getNative(Object, 'defineProperty');
1478        func({}, '', {});
1479        return func;
1480      } catch (e) {}
1481    }());
1482
1483    /** Mocked built-ins. */
1484    var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
1485        ctxNow = Date && Date.now !== root.Date.now && Date.now,
1486        ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1487
1488    /* Built-in method references for those with the same name as other `lodash` methods. */
1489    var nativeCeil = Math.ceil,
1490        nativeFloor = Math.floor,
1491        nativeGetSymbols = Object.getOwnPropertySymbols,
1492        nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
1493        nativeIsFinite = context.isFinite,
1494        nativeJoin = arrayProto.join,
1495        nativeKeys = overArg(Object.keys, Object),
1496        nativeMax = Math.max,
1497        nativeMin = Math.min,
1498        nativeNow = Date.now,
1499        nativeParseInt = context.parseInt,
1500        nativeRandom = Math.random,
1501        nativeReverse = arrayProto.reverse;
1502
1503    /* Built-in method references that are verified to be native. */
1504    var DataView = getNative(context, 'DataView'),
1505        Map = getNative(context, 'Map'),
1506        Promise = getNative(context, 'Promise'),
1507        Set = getNative(context, 'Set'),
1508        WeakMap = getNative(context, 'WeakMap'),
1509        nativeCreate = getNative(Object, 'create');
1510
1511    /** Used to store function metadata. */
1512    var metaMap = WeakMap && new WeakMap;
1513
1514    /** Used to lookup unminified function names. */
1515    var realNames = {};
1516
1517    /** Used to detect maps, sets, and weakmaps. */
1518    var dataViewCtorString = toSource(DataView),
1519        mapCtorString = toSource(Map),
1520        promiseCtorString = toSource(Promise),
1521        setCtorString = toSource(Set),
1522        weakMapCtorString = toSource(WeakMap);
1523
1524    /** Used to convert symbols to primitives and strings. */
1525    var symbolProto = Symbol ? Symbol.prototype : undefined,
1526        symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
1527        symbolToString = symbolProto ? symbolProto.toString : undefined;
1528
1529    /*------------------------------------------------------------------------*/
1530
1531    /**
1532     * Creates a `lodash` object which wraps `value` to enable implicit method
1533     * chain sequences. Methods that operate on and return arrays, collections,
1534     * and functions can be chained together. Methods that retrieve a single value
1535     * or may return a primitive value will automatically end the chain sequence
1536     * and return the unwrapped value. Otherwise, the value must be unwrapped
1537     * with `_#value`.
1538     *
1539     * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1540     * enabled using `_.chain`.
1541     *
1542     * The execution of chained methods is lazy, that is, it's deferred until
1543     * `_#value` is implicitly or explicitly called.
1544     *
1545     * Lazy evaluation allows several methods to support shortcut fusion.
1546     * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1547     * the creation of intermediate arrays and can greatly reduce the number of
1548     * iteratee executions. Sections of a chain sequence qualify for shortcut
1549     * fusion if the section is applied to an array and iteratees accept only
1550     * one argument. The heuristic for whether a section qualifies for shortcut
1551     * fusion is subject to change.
1552     *
1553     * Chaining is supported in custom builds as long as the `_#value` method is
1554     * directly or indirectly included in the build.
1555     *
1556     * In addition to lodash methods, wrappers have `Array` and `String` methods.
1557     *
1558     * The wrapper `Array` methods are:
1559     * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1560     *
1561     * The wrapper `String` methods are:
1562     * `replace` and `split`
1563     *
1564     * The wrapper methods that support shortcut fusion are:
1565     * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1566     * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1567     * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1568     *
1569     * The chainable wrapper methods are:
1570     * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1571     * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1572     * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1573     * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1574     * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1575     * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1576     * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1577     * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1578     * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1579     * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1580     * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1581     * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1582     * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1583     * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1584     * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1585     * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1586     * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1587     * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1588     * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1589     * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1590     * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1591     * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1592     * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1593     * `zipObject`, `zipObjectDeep`, and `zipWith`
1594     *
1595     * The wrapper methods that are **not** chainable by default are:
1596     * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1597     * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
1598     * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
1599     * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
1600     * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
1601     * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
1602     * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
1603     * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
1604     * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
1605     * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
1606     * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
1607     * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
1608     * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
1609     * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
1610     * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
1611     * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
1612     * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
1613     * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
1614     * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
1615     * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
1616     * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
1617     * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
1618     * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
1619     * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
1620     * `upperFirst`, `value`, and `words`
1621     *
1622     * @name _
1623     * @constructor
1624     * @category Seq
1625     * @param {*} value The value to wrap in a `lodash` instance.
1626     * @returns {Object} Returns the new `lodash` wrapper instance.
1627     * @example
1628     *
1629     * function square(n) {
1630     *   return n * n;
1631     * }
1632     *
1633     * var wrapped = _([1, 2, 3]);
1634     *
1635     * // Returns an unwrapped value.
1636     * wrapped.reduce(_.add);
1637     * // => 6
1638     *
1639     * // Returns a wrapped value.
1640     * var squares = wrapped.map(square);
1641     *
1642     * _.isArray(squares);
1643     * // => false
1644     *
1645     * _.isArray(squares.value());
1646     * // => true
1647     */
1648    function lodash(value) {
1649      if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1650        if (value instanceof LodashWrapper) {
1651          return value;
1652        }
1653        if (hasOwnProperty.call(value, '__wrapped__')) {
1654          return wrapperClone(value);
1655        }
1656      }
1657      return new LodashWrapper(value);
1658    }
1659
1660    /**
1661     * The base implementation of `_.create` without support for assigning
1662     * properties to the created object.
1663     *
1664     * @private
1665     * @param {Object} proto The object to inherit from.
1666     * @returns {Object} Returns the new object.
1667     */
1668    var baseCreate = (function() {
1669      function object() {}
1670      return function(proto) {
1671        if (!isObject(proto)) {
1672          return {};
1673        }
1674        if (objectCreate) {
1675          return objectCreate(proto);
1676        }
1677        object.prototype = proto;
1678        var result = new object;
1679        object.prototype = undefined;
1680        return result;
1681      };
1682    }());
1683
1684    /**
1685     * The function whose prototype chain sequence wrappers inherit from.
1686     *
1687     * @private
1688     */
1689    function baseLodash() {
1690      // No operation performed.
1691    }
1692
1693    /**
1694     * The base constructor for creating `lodash` wrapper objects.
1695     *
1696     * @private
1697     * @param {*} value The value to wrap.
1698     * @param {boolean} [chainAll] Enable explicit method chain sequences.
1699     */
1700    function LodashWrapper(value, chainAll) {
1701      this.__wrapped__ = value;
1702      this.__actions__ = [];
1703      this.__chain__ = !!chainAll;
1704      this.__index__ = 0;
1705      this.__values__ = undefined;
1706    }
1707
1708    /**
1709     * By default, the template delimiters used by lodash are like those in
1710     * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1711     * following template settings to use alternative delimiters.
1712     *
1713     * @static
1714     * @memberOf _
1715     * @type {Object}
1716     */
1717    lodash.templateSettings = {
1718
1719      /**
1720       * Used to detect `data` property values to be HTML-escaped.
1721       *
1722       * @memberOf _.templateSettings
1723       * @type {RegExp}
1724       */
1725      'escape': reEscape,
1726
1727      /**
1728       * Used to detect code to be evaluated.
1729       *
1730       * @memberOf _.templateSettings
1731       * @type {RegExp}
1732       */
1733      'evaluate': reEvaluate,
1734
1735      /**
1736       * Used to detect `data` property values to inject.
1737       *
1738       * @memberOf _.templateSettings
1739       * @type {RegExp}
1740       */
1741      'interpolate': reInterpolate,
1742
1743      /**
1744       * Used to reference the data object in the template text.
1745       *
1746       * @memberOf _.templateSettings
1747       * @type {string}
1748       */
1749      'variable': '',
1750
1751      /**
1752       * Used to import variables into the compiled template.
1753       *
1754       * @memberOf _.templateSettings
1755       * @type {Object}
1756       */
1757      'imports': {
1758
1759        /**
1760         * A reference to the `lodash` function.
1761         *
1762         * @memberOf _.templateSettings.imports
1763         * @type {Function}
1764         */
1765        '_': lodash
1766      }
1767    };
1768
1769    // Ensure wrappers are instances of `baseLodash`.
1770    lodash.prototype = baseLodash.prototype;
1771    lodash.prototype.constructor = lodash;
1772
1773    LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1774    LodashWrapper.prototype.constructor = LodashWrapper;
1775
1776    /*------------------------------------------------------------------------*/
1777
1778    /**
1779     * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1780     *
1781     * @private
1782     * @constructor
1783     * @param {*} value The value to wrap.
1784     */
1785    function LazyWrapper(value) {
1786      this.__wrapped__ = value;
1787      this.__actions__ = [];
1788      this.__dir__ = 1;
1789      this.__filtered__ = false;
1790      this.__iteratees__ = [];
1791      this.__takeCount__ = MAX_ARRAY_LENGTH;
1792      this.__views__ = [];
1793    }
1794
1795    /**
1796     * Creates a clone of the lazy wrapper object.
1797     *
1798     * @private
1799     * @name clone
1800     * @memberOf LazyWrapper
1801     * @returns {Object} Returns the cloned `LazyWrapper` object.
1802     */
1803    function lazyClone() {
1804      var result = new LazyWrapper(this.__wrapped__);
1805      result.__actions__ = copyArray(this.__actions__);
1806      result.__dir__ = this.__dir__;
1807      result.__filtered__ = this.__filtered__;
1808      result.__iteratees__ = copyArray(this.__iteratees__);
1809      result.__takeCount__ = this.__takeCount__;
1810      result.__views__ = copyArray(this.__views__);
1811      return result;
1812    }
1813
1814    /**
1815     * Reverses the direction of lazy iteration.
1816     *
1817     * @private
1818     * @name reverse
1819     * @memberOf LazyWrapper
1820     * @returns {Object} Returns the new reversed `LazyWrapper` object.
1821     */
1822    function lazyReverse() {
1823      if (this.__filtered__) {
1824        var result = new LazyWrapper(this);
1825        result.__dir__ = -1;
1826        result.__filtered__ = true;
1827      } else {
1828        result = this.clone();
1829        result.__dir__ *= -1;
1830      }
1831      return result;
1832    }
1833
1834    /**
1835     * Extracts the unwrapped value from its lazy wrapper.
1836     *
1837     * @private
1838     * @name value
1839     * @memberOf LazyWrapper
1840     * @returns {*} Returns the unwrapped value.
1841     */
1842    function lazyValue() {
1843      var array = this.__wrapped__.value(),
1844          dir = this.__dir__,
1845          isArr = isArray(array),
1846          isRight = dir < 0,
1847          arrLength = isArr ? array.length : 0,
1848          view = getView(0, arrLength, this.__views__),
1849          start = view.start,
1850          end = view.end,
1851          length = end - start,
1852          index = isRight ? end : (start - 1),
1853          iteratees = this.__iteratees__,
1854          iterLength = iteratees.length,
1855          resIndex = 0,
1856          takeCount = nativeMin(length, this.__takeCount__);
1857
1858      if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
1859        return baseWrapperValue(array, this.__actions__);
1860      }
1861      var result = [];
1862
1863      outer:
1864      while (length-- && resIndex < takeCount) {
1865        index += dir;
1866
1867        var iterIndex = -1,
1868            value = array[index];
1869
1870        while (++iterIndex < iterLength) {
1871          var data = iteratees[iterIndex],
1872              iteratee = data.iteratee,
1873              type = data.type,
1874              computed = iteratee(value);
1875
1876          if (type == LAZY_MAP_FLAG) {
1877            value = computed;
1878          } else if (!computed) {
1879            if (type == LAZY_FILTER_FLAG) {
1880              continue outer;
1881            } else {
1882              break outer;
1883            }
1884          }
1885        }
1886        result[resIndex++] = value;
1887      }
1888      return result;
1889    }
1890
1891    // Ensure `LazyWrapper` is an instance of `baseLodash`.
1892    LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1893    LazyWrapper.prototype.constructor = LazyWrapper;
1894
1895    /*------------------------------------------------------------------------*/
1896
1897    /**
1898     * Creates a hash object.
1899     *
1900     * @private
1901     * @constructor
1902     * @param {Array} [entries] The key-value pairs to cache.
1903     */
1904    function Hash(entries) {
1905      var index = -1,
1906          length = entries == null ? 0 : entries.length;
1907
1908      this.clear();
1909      while (++index < length) {
1910        var entry = entries[index];
1911        this.set(entry[0], entry[1]);
1912      }
1913    }
1914
1915    /**
1916     * Removes all key-value entries from the hash.
1917     *
1918     * @private
1919     * @name clear
1920     * @memberOf Hash
1921     */
1922    function hashClear() {
1923      this.__data__ = nativeCreate ? nativeCreate(null) : {};
1924      this.size = 0;
1925    }
1926
1927    /**
1928     * Removes `key` and its value from the hash.
1929     *
1930     * @private
1931     * @name delete
1932     * @memberOf Hash
1933     * @param {Object} hash The hash to modify.
1934     * @param {string} key The key of the value to remove.
1935     * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1936     */
1937    function hashDelete(key) {
1938      var result = this.has(key) && delete this.__data__[key];
1939      this.size -= result ? 1 : 0;
1940      return result;
1941    }
1942
1943    /**
1944     * Gets the hash value for `key`.
1945     *
1946     * @private
1947     * @name get
1948     * @memberOf Hash
1949     * @param {string} key The key of the value to get.
1950     * @returns {*} Returns the entry value.
1951     */
1952    function hashGet(key) {
1953      var data = this.__data__;
1954      if (nativeCreate) {
1955        var result = data[key];
1956        return result === HASH_UNDEFINED ? undefined : result;
1957      }
1958      return hasOwnProperty.call(data, key) ? data[key] : undefined;
1959    }
1960
1961    /**
1962     * Checks if a hash value for `key` exists.
1963     *
1964     * @private
1965     * @name has
1966     * @memberOf Hash
1967     * @param {string} key The key of the entry to check.
1968     * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1969     */
1970    function hashHas(key) {
1971      var data = this.__data__;
1972      return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
1973    }
1974
1975    /**
1976     * Sets the hash `key` to `value`.
1977     *
1978     * @private
1979     * @name set
1980     * @memberOf Hash
1981     * @param {string} key The key of the value to set.
1982     * @param {*} value The value to set.
1983     * @returns {Object} Returns the hash instance.
1984     */
1985    function hashSet(key, value) {
1986      var data = this.__data__;
1987      this.size += this.has(key) ? 0 : 1;
1988      data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1989      return this;
1990    }
1991
1992    // Add methods to `Hash`.
1993    Hash.prototype.clear = hashClear;
1994    Hash.prototype['delete'] = hashDelete;
1995    Hash.prototype.get = hashGet;
1996    Hash.prototype.has = hashHas;
1997    Hash.prototype.set = hashSet;
1998
1999    /*------------------------------------------------------------------------*/
2000
2001    /**
2002     * Creates an list cache object.
2003     *
2004     * @private
2005     * @constructor
2006     * @param {Array} [entries] The key-value pairs to cache.
2007     */
2008    function ListCache(entries) {
2009      var index = -1,
2010          length = entries == null ? 0 : entries.length;
2011
2012      this.clear();
2013      while (++index < length) {
2014        var entry = entries[index];
2015        this.set(entry[0], entry[1]);
2016      }
2017    }
2018
2019    /**
2020     * Removes all key-value entries from the list cache.
2021     *
2022     * @private
2023     * @name clear
2024     * @memberOf ListCache
2025     */
2026    function listCacheClear() {
2027      this.__data__ = [];
2028      this.size = 0;
2029    }
2030
2031    /**
2032     * Removes `key` and its value from the list cache.
2033     *
2034     * @private
2035     * @name delete
2036     * @memberOf ListCache
2037     * @param {string} key The key of the value to remove.
2038     * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2039     */
2040    function listCacheDelete(key) {
2041      var data = this.__data__,
2042          index = assocIndexOf(data, key);
2043
2044      if (index < 0) {
2045        return false;
2046      }
2047      var lastIndex = data.length - 1;
2048      if (index == lastIndex) {
2049        data.pop();
2050      } else {
2051        splice.call(data, index, 1);
2052      }
2053      --this.size;
2054      return true;
2055    }
2056
2057    /**
2058     * Gets the list cache value for `key`.
2059     *
2060     * @private
2061     * @name get
2062     * @memberOf ListCache
2063     * @param {string} key The key of the value to get.
2064     * @returns {*} Returns the entry value.
2065     */
2066    function listCacheGet(key) {
2067      var data = this.__data__,
2068          index = assocIndexOf(data, key);
2069
2070      return index < 0 ? undefined : data[index][1];
2071    }
2072
2073    /**
2074     * Checks if a list cache value for `key` exists.
2075     *
2076     * @private
2077     * @name has
2078     * @memberOf ListCache
2079     * @param {string} key The key of the entry to check.
2080     * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2081     */
2082    function listCacheHas(key) {
2083      return assocIndexOf(this.__data__, key) > -1;
2084    }
2085
2086    /**
2087     * Sets the list cache `key` to `value`.
2088     *
2089     * @private
2090     * @name set
2091     * @memberOf ListCache
2092     * @param {string} key The key of the value to set.
2093     * @param {*} value The value to set.
2094     * @returns {Object} Returns the list cache instance.
2095     */
2096    function listCacheSet(key, value) {
2097      var data = this.__data__,
2098          index = assocIndexOf(data, key);
2099
2100      if (index < 0) {
2101        ++this.size;
2102        data.push([key, value]);
2103      } else {
2104        data[index][1] = value;
2105      }
2106      return this;
2107    }
2108
2109    // Add methods to `ListCache`.
2110    ListCache.prototype.clear = listCacheClear;
2111    ListCache.prototype['delete'] = listCacheDelete;
2112    ListCache.prototype.get = listCacheGet;
2113    ListCache.prototype.has = listCacheHas;
2114    ListCache.prototype.set = listCacheSet;
2115
2116    /*------------------------------------------------------------------------*/
2117
2118    /**
2119     * Creates a map cache object to store key-value pairs.
2120     *
2121     * @private
2122     * @constructor
2123     * @param {Array} [entries] The key-value pairs to cache.
2124     */
2125    function MapCache(entries) {
2126      var index = -1,
2127          length = entries == null ? 0 : entries.length;
2128
2129      this.clear();
2130      while (++index < length) {
2131        var entry = entries[index];
2132        this.set(entry[0], entry[1]);
2133      }
2134    }
2135
2136    /**
2137     * Removes all key-value entries from the map.
2138     *
2139     * @private
2140     * @name clear
2141     * @memberOf MapCache
2142     */
2143    function mapCacheClear() {
2144      this.size = 0;
2145      this.__data__ = {
2146        'hash': new Hash,
2147        'map': new (Map || ListCache),
2148        'string': new Hash
2149      };
2150    }
2151
2152    /**
2153     * Removes `key` and its value from the map.
2154     *
2155     * @private
2156     * @name delete
2157     * @memberOf MapCache
2158     * @param {string} key The key of the value to remove.
2159     * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2160     */
2161    function mapCacheDelete(key) {
2162      var result = getMapData(this, key)['delete'](key);
2163      this.size -= result ? 1 : 0;
2164      return result;
2165    }
2166
2167    /**
2168     * Gets the map value for `key`.
2169     *
2170     * @private
2171     * @name get
2172     * @memberOf MapCache
2173     * @param {string} key The key of the value to get.
2174     * @returns {*} Returns the entry value.
2175     */
2176    function mapCacheGet(key) {
2177      return getMapData(this, key).get(key);
2178    }
2179
2180    /**
2181     * Checks if a map value for `key` exists.
2182     *
2183     * @private
2184     * @name has
2185     * @memberOf MapCache
2186     * @param {string} key The key of the entry to check.
2187     * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2188     */
2189    function mapCacheHas(key) {
2190      return getMapData(this, key).has(key);
2191    }
2192
2193    /**
2194     * Sets the map `key` to `value`.
2195     *
2196     * @private
2197     * @name set
2198     * @memberOf MapCache
2199     * @param {string} key The key of the value to set.
2200     * @param {*} value The value to set.
2201     * @returns {Object} Returns the map cache instance.
2202     */
2203    function mapCacheSet(key, value) {
2204      var data = getMapData(this, key),
2205          size = data.size;
2206
2207      data.set(key, value);
2208      this.size += data.size == size ? 0 : 1;
2209      return this;
2210    }
2211
2212    // Add methods to `MapCache`.
2213    MapCache.prototype.clear = mapCacheClear;
2214    MapCache.prototype['delete'] = mapCacheDelete;
2215    MapCache.prototype.get = mapCacheGet;
2216    MapCache.prototype.has = mapCacheHas;
2217    MapCache.prototype.set = mapCacheSet;
2218
2219    /*------------------------------------------------------------------------*/
2220
2221    /**
2222     *
2223     * Creates an array cache object to store unique values.
2224     *
2225     * @private
2226     * @constructor
2227     * @param {Array} [values] The values to cache.
2228     */
2229    function SetCache(values) {
2230      var index = -1,
2231          length = values == null ? 0 : values.length;
2232
2233      this.__data__ = new MapCache;
2234      while (++index < length) {
2235        this.add(values[index]);
2236      }
2237    }
2238
2239    /**
2240     * Adds `value` to the array cache.
2241     *
2242     * @private
2243     * @name add
2244     * @memberOf SetCache
2245     * @alias push
2246     * @param {*} value The value to cache.
2247     * @returns {Object} Returns the cache instance.
2248     */
2249    function setCacheAdd(value) {
2250      this.__data__.set(value, HASH_UNDEFINED);
2251      return this;
2252    }
2253
2254    /**
2255     * Checks if `value` is in the array cache.
2256     *
2257     * @private
2258     * @name has
2259     * @memberOf SetCache
2260     * @param {*} value The value to search for.
2261     * @returns {number} Returns `true` if `value` is found, else `false`.
2262     */
2263    function setCacheHas(value) {
2264      return this.__data__.has(value);
2265    }
2266
2267    // Add methods to `SetCache`.
2268    SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2269    SetCache.prototype.has = setCacheHas;
2270
2271    /*------------------------------------------------------------------------*/
2272
2273    /**
2274     * Creates a stack cache object to store key-value pairs.
2275     *
2276     * @private
2277     * @constructor
2278     * @param {Array} [entries] The key-value pairs to cache.
2279     */
2280    function Stack(entries) {
2281      var data = this.__data__ = new ListCache(entries);
2282      this.size = data.size;
2283    }
2284
2285    /**
2286     * Removes all key-value entries from the stack.
2287     *
2288     * @private
2289     * @name clear
2290     * @memberOf Stack
2291     */
2292    function stackClear() {
2293      this.__data__ = new ListCache;
2294      this.size = 0;
2295    }
2296
2297    /**
2298     * Removes `key` and its value from the stack.
2299     *
2300     * @private
2301     * @name delete
2302     * @memberOf Stack
2303     * @param {string} key The key of the value to remove.
2304     * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2305     */
2306    function stackDelete(key) {
2307      var data = this.__data__,
2308          result = data['delete'](key);
2309
2310      this.size = data.size;
2311      return result;
2312    }
2313
2314    /**
2315     * Gets the stack value for `key`.
2316     *
2317     * @private
2318     * @name get
2319     * @memberOf Stack
2320     * @param {string} key The key of the value to get.
2321     * @returns {*} Returns the entry value.
2322     */
2323    function stackGet(key) {
2324      return this.__data__.get(key);
2325    }
2326
2327    /**
2328     * Checks if a stack value for `key` exists.
2329     *
2330     * @private
2331     * @name has
2332     * @memberOf Stack
2333     * @param {string} key The key of the entry to check.
2334     * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2335     */
2336    function stackHas(key) {
2337      return this.__data__.has(key);
2338    }
2339
2340    /**
2341     * Sets the stack `key` to `value`.
2342     *
2343     * @private
2344     * @name set
2345     * @memberOf Stack
2346     * @param {string} key The key of the value to set.
2347     * @param {*} value The value to set.
2348     * @returns {Object} Returns the stack cache instance.
2349     */
2350    function stackSet(key, value) {
2351      var data = this.__data__;
2352      if (data instanceof ListCache) {
2353        var pairs = data.__data__;
2354        if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2355          pairs.push([key, value]);
2356          this.size = ++data.size;
2357          return this;
2358        }
2359        data = this.__data__ = new MapCache(pairs);
2360      }
2361      data.set(key, value);
2362      this.size = data.size;
2363      return this;
2364    }
2365
2366    // Add methods to `Stack`.
2367    Stack.prototype.clear = stackClear;
2368    Stack.prototype['delete'] = stackDelete;
2369    Stack.prototype.get = stackGet;
2370    Stack.prototype.has = stackHas;
2371    Stack.prototype.set = stackSet;
2372
2373    /*------------------------------------------------------------------------*/
2374
2375    /**
2376     * Creates an array of the enumerable property names of the array-like `value`.
2377     *
2378     * @private
2379     * @param {*} value The value to query.
2380     * @param {boolean} inherited Specify returning inherited property names.
2381     * @returns {Array} Returns the array of property names.
2382     */
2383    function arrayLikeKeys(value, inherited) {
2384      var isArr = isArray(value),
2385          isArg = !isArr && isArguments(value),
2386          isBuff = !isArr && !isArg && isBuffer(value),
2387          isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2388          skipIndexes = isArr || isArg || isBuff || isType,
2389          result = skipIndexes ? baseTimes(value.length, String) : [],
2390          length = result.length;
2391
2392      for (var key in value) {
2393        if ((inherited || hasOwnProperty.call(value, key)) &&
2394            !(skipIndexes && (
2395               // Safari 9 has enumerable `arguments.length` in strict mode.
2396               key == 'length' ||
2397               // Node.js 0.10 has enumerable non-index properties on buffers.
2398               (isBuff && (key == 'offset' || key == 'parent')) ||
2399               // PhantomJS 2 has enumerable non-index properties on typed arrays.
2400               (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2401               // Skip index properties.
2402               isIndex(key, length)
2403            ))) {
2404          result.push(key);
2405        }
2406      }
2407      return result;
2408    }
2409
2410    /**
2411     * A specialized version of `_.sample` for arrays.
2412     *
2413     * @private
2414     * @param {Array} array The array to sample.
2415     * @returns {*} Returns the random element.
2416     */
2417    function arraySample(array) {
2418      var length = array.length;
2419      return length ? array[baseRandom(0, length - 1)] : undefined;
2420    }
2421
2422    /**
2423     * A specialized version of `_.sampleSize` for arrays.
2424     *
2425     * @private
2426     * @param {Array} array The array to sample.
2427     * @param {number} n The number of elements to sample.
2428     * @returns {Array} Returns the random elements.
2429     */
2430    function arraySampleSize(array, n) {
2431      return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2432    }
2433
2434    /**
2435     * A specialized version of `_.shuffle` for arrays.
2436     *
2437     * @private
2438     * @param {Array} array The array to shuffle.
2439     * @returns {Array} Returns the new shuffled array.
2440     */
2441    function arrayShuffle(array) {
2442      return shuffleSelf(copyArray(array));
2443    }
2444
2445    /**
2446     * This function is like `assignValue` except that it doesn't assign
2447     * `undefined` values.
2448     *
2449     * @private
2450     * @param {Object} object The object to modify.
2451     * @param {string} key The key of the property to assign.
2452     * @param {*} value The value to assign.
2453     */
2454    function assignMergeValue(object, key, value) {
2455      if ((value !== undefined && !eq(object[key], value)) ||
2456          (value === undefined && !(key in object))) {
2457        baseAssignValue(object, key, value);
2458      }
2459    }
2460
2461    /**
2462     * Assigns `value` to `key` of `object` if the existing value is not equivalent
2463     * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2464     * for equality comparisons.
2465     *
2466     * @private
2467     * @param {Object} object The object to modify.
2468     * @param {string} key The key of the property to assign.
2469     * @param {*} value The value to assign.
2470     */
2471    function assignValue(object, key, value) {
2472      var objValue = object[key];
2473      if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2474          (value === undefined && !(key in object))) {
2475        baseAssignValue(object, key, value);
2476      }
2477    }
2478
2479    /**
2480     * Gets the index at which the `key` is found in `array` of key-value pairs.
2481     *
2482     * @private
2483     * @param {Array} array The array to inspect.
2484     * @param {*} key The key to search for.
2485     * @returns {number} Returns the index of the matched value, else `-1`.
2486     */
2487    function assocIndexOf(array, key) {
2488      var length = array.length;
2489      while (length--) {
2490        if (eq(array[length][0], key)) {
2491          return length;
2492        }
2493      }
2494      return -1;
2495    }
2496
2497    /**
2498     * Aggregates elements of `collection` on `accumulator` with keys transformed
2499     * by `iteratee` and values set by `setter`.
2500     *
2501     * @private
2502     * @param {Array|Object} collection The collection to iterate over.
2503     * @param {Function} setter The function to set `accumulator` values.
2504     * @param {Function} iteratee The iteratee to transform keys.
2505     * @param {Object} accumulator The initial aggregated object.
2506     * @returns {Function} Returns `accumulator`.
2507     */
2508    function baseAggregator(collection, setter, iteratee, accumulator) {
2509      baseEach(collection, function(value, key, collection) {
2510        setter(accumulator, value, iteratee(value), collection);
2511      });
2512      return accumulator;
2513    }
2514
2515    /**
2516     * The base implementation of `_.assign` without support for multiple sources
2517     * or `customizer` functions.
2518     *
2519     * @private
2520     * @param {Object} object The destination object.
2521     * @param {Object} source The source object.
2522     * @returns {Object} Returns `object`.
2523     */
2524    function baseAssign(object, source) {
2525      return object && copyObject(source, keys(source), object);
2526    }
2527
2528    /**
2529     * The base implementation of `_.assignIn` without support for multiple sources
2530     * or `customizer` functions.
2531     *
2532     * @private
2533     * @param {Object} object The destination object.
2534     * @param {Object} source The source object.
2535     * @returns {Object} Returns `object`.
2536     */
2537    function baseAssignIn(object, source) {
2538      return object && copyObject(source, keysIn(source), object);
2539    }
2540
2541    /**
2542     * The base implementation of `assignValue` and `assignMergeValue` without
2543     * value checks.
2544     *
2545     * @private
2546     * @param {Object} object The object to modify.
2547     * @param {string} key The key of the property to assign.
2548     * @param {*} value The value to assign.
2549     */
2550    function baseAssignValue(object, key, value) {
2551      if (key == '__proto__' && defineProperty) {
2552        defineProperty(object, key, {
2553          'configurable': true,
2554          'enumerable': true,
2555          'value': value,
2556          'writable': true
2557        });
2558      } else {
2559        object[key] = value;
2560      }
2561    }
2562
2563    /**
2564     * The base implementation of `_.at` without support for individual paths.
2565     *
2566     * @private
2567     * @param {Object} object The object to iterate over.
2568     * @param {string[]} paths The property paths to pick.
2569     * @returns {Array} Returns the picked elements.
2570     */
2571    function baseAt(object, paths) {
2572      var index = -1,
2573          length = paths.length,
2574          result = Array(length),
2575          skip = object == null;
2576
2577      while (++index < length) {
2578        result[index] = skip ? undefined : get(object, paths[index]);
2579      }
2580      return result;
2581    }
2582
2583    /**
2584     * The base implementation of `_.clamp` which doesn't coerce arguments.
2585     *
2586     * @private
2587     * @param {number} number The number to clamp.
2588     * @param {number} [lower] The lower bound.
2589     * @param {number} upper The upper bound.
2590     * @returns {number} Returns the clamped number.
2591     */
2592    function baseClamp(number, lower, upper) {
2593      if (number === number) {
2594        if (upper !== undefined) {
2595          number = number <= upper ? number : upper;
2596        }
2597        if (lower !== undefined) {
2598          number = number >= lower ? number : lower;
2599        }
2600      }
2601      return number;
2602    }
2603
2604    /**
2605     * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2606     * traversed objects.
2607     *
2608     * @private
2609     * @param {*} value The value to clone.
2610     * @param {boolean} bitmask The bitmask flags.
2611     *  1 - Deep clone
2612     *  2 - Flatten inherited properties
2613     *  4 - Clone symbols
2614     * @param {Function} [customizer] The function to customize cloning.
2615     * @param {string} [key] The key of `value`.
2616     * @param {Object} [object] The parent object of `value`.
2617     * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2618     * @returns {*} Returns the cloned value.
2619     */
2620    function baseClone(value, bitmask, customizer, key, object, stack) {
2621      var result,
2622          isDeep = bitmask & CLONE_DEEP_FLAG,
2623          isFlat = bitmask & CLONE_FLAT_FLAG,
2624          isFull = bitmask & CLONE_SYMBOLS_FLAG;
2625
2626      if (customizer) {
2627        result = object ? customizer(value, key, object, stack) : customizer(value);
2628      }
2629      if (result !== undefined) {
2630        return result;
2631      }
2632      if (!isObject(value)) {
2633        return value;
2634      }
2635      var isArr = isArray(value);
2636      if (isArr) {
2637        result = initCloneArray(value);
2638        if (!isDeep) {
2639          return copyArray(value, result);
2640        }
2641      } else {
2642        var tag = getTag(value),
2643            isFunc = tag == funcTag || tag == genTag;
2644
2645        if (isBuffer(value)) {
2646          return cloneBuffer(value, isDeep);
2647        }
2648        if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2649          result = (isFlat || isFunc) ? {} : initCloneObject(value);
2650          if (!isDeep) {
2651            return isFlat
2652              ? copySymbolsIn(value, baseAssignIn(result, value))
2653              : copySymbols(value, baseAssign(result, value));
2654          }
2655        } else {
2656          if (!cloneableTags[tag]) {
2657            return object ? value : {};
2658          }
2659          result = initCloneByTag(value, tag, isDeep);
2660        }
2661      }
2662      // Check for circular references and return its corresponding clone.
2663      stack || (stack = new Stack);
2664      var stacked = stack.get(value);
2665      if (stacked) {
2666        return stacked;
2667      }
2668      stack.set(value, result);
2669
2670      if (isSet(value)) {
2671        value.forEach(function(subValue) {
2672          result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2673        });
2674      } else if (isMap(value)) {
2675        value.forEach(function(subValue, key) {
2676          result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
2677        });
2678      }
2679
2680      var keysFunc = isFull
2681        ? (isFlat ? getAllKeysIn : getAllKeys)
2682        : (isFlat ? keysIn : keys);
2683
2684      var props = isArr ? undefined : keysFunc(value);
2685      arrayEach(props || value, function(subValue, key) {
2686        if (props) {
2687          key = subValue;
2688          subValue = value[key];
2689        }
2690        // Recursively populate clone (susceptible to call stack limits).
2691        assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
2692      });
2693      return result;
2694    }
2695
2696    /**
2697     * The base implementation of `_.conforms` which doesn't clone `source`.
2698     *
2699     * @private
2700     * @param {Object} source The object of property predicates to conform to.
2701     * @returns {Function} Returns the new spec function.
2702     */
2703    function baseConforms(source) {
2704      var props = keys(source);
2705      return function(object) {
2706        return baseConformsTo(object, source, props);
2707      };
2708    }
2709
2710    /**
2711     * The base implementation of `_.conformsTo` which accepts `props` to check.
2712     *
2713     * @private
2714     * @param {Object} object The object to inspect.
2715     * @param {Object} source The object of property predicates to conform to.
2716     * @returns {boolean} Returns `true` if `object` conforms, else `false`.
2717     */
2718    function baseConformsTo(object, source, props) {
2719      var length = props.length;
2720      if (object == null) {
2721        return !length;
2722      }
2723      object = Object(object);
2724      while (length--) {
2725        var key = props[length],
2726            predicate = source[key],
2727            value = object[key];
2728
2729        if ((value === undefined && !(key in object)) || !predicate(value)) {
2730          return false;
2731        }
2732      }
2733      return true;
2734    }
2735
2736    /**
2737     * The base implementation of `_.delay` and `_.defer` which accepts `args`
2738     * to provide to `func`.
2739     *
2740     * @private
2741     * @param {Function} func The function to delay.
2742     * @param {number} wait The number of milliseconds to delay invocation.
2743     * @param {Array} args The arguments to provide to `func`.
2744     * @returns {number|Object} Returns the timer id or timeout object.
2745     */
2746    function baseDelay(func, wait, args) {
2747      if (typeof func != 'function') {
2748        throw new TypeError(FUNC_ERROR_TEXT);
2749      }
2750      return setTimeout(function() { func.apply(undefined, args); }, wait);
2751    }
2752
2753    /**
2754     * The base implementation of methods like `_.difference` without support
2755     * for excluding multiple arrays or iteratee shorthands.
2756     *
2757     * @private
2758     * @param {Array} array The array to inspect.
2759     * @param {Array} values The values to exclude.
2760     * @param {Function} [iteratee] The iteratee invoked per element.
2761     * @param {Function} [comparator] The comparator invoked per element.
2762     * @returns {Array} Returns the new array of filtered values.
2763     */
2764    function baseDifference(array, values, iteratee, comparator) {
2765      var index = -1,
2766          includes = arrayIncludes,
2767          isCommon = true,
2768          length = array.length,
2769          result = [],
2770          valuesLength = values.length;
2771
2772      if (!length) {
2773        return result;
2774      }
2775      if (iteratee) {
2776        values = arrayMap(values, baseUnary(iteratee));
2777      }
2778      if (comparator) {
2779        includes = arrayIncludesWith;
2780        isCommon = false;
2781      }
2782      else if (values.length >= LARGE_ARRAY_SIZE) {
2783        includes = cacheHas;
2784        isCommon = false;
2785        values = new SetCache(values);
2786      }
2787      outer:
2788      while (++index < length) {
2789        var value = array[index],
2790            computed = iteratee == null ? value : iteratee(value);
2791
2792        value = (comparator || value !== 0) ? value : 0;
2793        if (isCommon && computed === computed) {
2794          var valuesIndex = valuesLength;
2795          while (valuesIndex--) {
2796            if (values[valuesIndex] === computed) {
2797              continue outer;
2798            }
2799          }
2800          result.push(value);
2801        }
2802        else if (!includes(values, computed, comparator)) {
2803          result.push(value);
2804        }
2805      }
2806      return result;
2807    }
2808
2809    /**
2810     * The base implementation of `_.forEach` without support for iteratee shorthands.
2811     *
2812     * @private
2813     * @param {Array|Object} collection The collection to iterate over.
2814     * @param {Function} iteratee The function invoked per iteration.
2815     * @returns {Array|Object} Returns `collection`.
2816     */
2817    var baseEach = createBaseEach(baseForOwn);
2818
2819    /**
2820     * The base implementation of `_.forEachRight` without support for iteratee shorthands.
2821     *
2822     * @private
2823     * @param {Array|Object} collection The collection to iterate over.
2824     * @param {Function} iteratee The function invoked per iteration.
2825     * @returns {Array|Object} Returns `collection`.
2826     */
2827    var baseEachRight = createBaseEach(baseForOwnRight, true);
2828
2829    /**
2830     * The base implementation of `_.every` without support for iteratee shorthands.
2831     *
2832     * @private
2833     * @param {Array|Object} collection The collection to iterate over.
2834     * @param {Function} predicate The function invoked per iteration.
2835     * @returns {boolean} Returns `true` if all elements pass the predicate check,
2836     *  else `false`
2837     */
2838    function baseEvery(collection, predicate) {
2839      var result = true;
2840      baseEach(collection, function(value, index, collection) {
2841        result = !!predicate(value, index, collection);
2842        return result;
2843      });
2844      return result;
2845    }
2846
2847    /**
2848     * The base implementation of methods like `_.max` and `_.min` which accepts a
2849     * `comparator` to determine the extremum value.
2850     *
2851     * @private
2852     * @param {Array} array The array to iterate over.
2853     * @param {Function} iteratee The iteratee invoked per iteration.
2854     * @param {Function} comparator The comparator used to compare values.
2855     * @returns {*} Returns the extremum value.
2856     */
2857    function baseExtremum(array, iteratee, comparator) {
2858      var index = -1,
2859          length = array.length;
2860
2861      while (++index < length) {
2862        var value = array[index],
2863            current = iteratee(value);
2864
2865        if (current != null && (computed === undefined
2866              ? (current === current && !isSymbol(current))
2867              : comparator(current, computed)
2868            )) {
2869          var computed = current,
2870              result = value;
2871        }
2872      }
2873      return result;
2874    }
2875
2876    /**
2877     * The base implementation of `_.fill` without an iteratee call guard.
2878     *
2879     * @private
2880     * @param {Array} array The array to fill.
2881     * @param {*} value The value to fill `array` with.
2882     * @param {number} [start=0] The start position.
2883     * @param {number} [end=array.length] The end position.
2884     * @returns {Array} Returns `array`.
2885     */
2886    function baseFill(array, value, start, end) {
2887      var length = array.length;
2888
2889      start = toInteger(start);
2890      if (start < 0) {
2891        start = -start > length ? 0 : (length + start);
2892      }
2893      end = (end === undefined || end > length) ? length : toInteger(end);
2894      if (end < 0) {
2895        end += length;
2896      }
2897      end = start > end ? 0 : toLength(end);
2898      while (start < end) {
2899        array[start++] = value;
2900      }
2901      return array;
2902    }
2903
2904    /**
2905     * The base implementation of `_.filter` without support for iteratee shorthands.
2906     *
2907     * @private
2908     * @param {Array|Object} collection The collection to iterate over.
2909     * @param {Function} predicate The function invoked per iteration.
2910     * @returns {Array} Returns the new filtered array.
2911     */
2912    function baseFilter(collection, predicate) {
2913      var result = [];
2914      baseEach(collection, function(value, index, collection) {
2915        if (predicate(value, index, collection)) {
2916          result.push(value);
2917        }
2918      });
2919      return result;
2920    }
2921
2922    /**
2923     * The base implementation of `_.flatten` with support for restricting flattening.
2924     *
2925     * @private
2926     * @param {Array} array The array to flatten.
2927     * @param {number} depth The maximum recursion depth.
2928     * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
2929     * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
2930     * @param {Array} [result=[]] The initial result value.
2931     * @returns {Array} Returns the new flattened array.
2932     */
2933    function baseFlatten(array, depth, predicate, isStrict, result) {
2934      var index = -1,
2935          length = array.length;
2936
2937      predicate || (predicate = isFlattenable);
2938      result || (result = []);
2939
2940      while (++index < length) {
2941        var value = array[index];
2942        if (depth > 0 && predicate(value)) {
2943          if (depth > 1) {
2944            // Recursively flatten arrays (susceptible to call stack limits).
2945            baseFlatten(value, depth - 1, predicate, isStrict, result);
2946          } else {
2947            arrayPush(result, value);
2948          }
2949        } else if (!isStrict) {
2950          result[result.length] = value;
2951        }
2952      }
2953      return result;
2954    }
2955
2956    /**
2957     * The base implementation of `baseForOwn` which iterates over `object`
2958     * properties returned by `keysFunc` and invokes `iteratee` for each property.
2959     * Iteratee functions may exit iteration early by explicitly returning `false`.
2960     *
2961     * @private
2962     * @param {Object} object The object to iterate over.
2963     * @param {Function} iteratee The function invoked per iteration.
2964     * @param {Function} keysFunc The function to get the keys of `object`.
2965     * @returns {Object} Returns `object`.
2966     */
2967    var baseFor = createBaseFor();
2968
2969    /**
2970     * This function is like `baseFor` except that it iterates over properties
2971     * in the opposite order.
2972     *
2973     * @private
2974     * @param {Object} object The object to iterate over.
2975     * @param {Function} iteratee The function invoked per iteration.
2976     * @param {Function} keysFunc The function to get the keys of `object`.
2977     * @returns {Object} Returns `object`.
2978     */
2979    var baseForRight = createBaseFor(true);
2980
2981    /**
2982     * The base implementation of `_.forOwn` without support for iteratee shorthands.
2983     *
2984     * @private
2985     * @param {Object} object The object to iterate over.
2986     * @param {Function} iteratee The function invoked per iteration.
2987     * @returns {Object} Returns `object`.
2988     */
2989    function baseForOwn(object, iteratee) {
2990      return object && baseFor(object, iteratee, keys);
2991    }
2992
2993    /**
2994     * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
2995     *
2996     * @private
2997     * @param {Object} object The object to iterate over.
2998     * @param {Function} iteratee The function invoked per iteration.
2999     * @returns {Object} Returns `object`.
3000     */
3001    function baseForOwnRight(object, iteratee) {
3002      return object && baseForRight(object, iteratee, keys);
3003    }
3004
3005    /**
3006     * The base implementation of `_.functions` which creates an array of
3007     * `object` function property names filtered from `props`.
3008     *
3009     * @private
3010     * @param {Object} object The object to inspect.
3011     * @param {Array} props The property names to filter.
3012     * @returns {Array} Returns the function names.
3013     */
3014    function baseFunctions(object, props) {
3015      return arrayFilter(props, function(key) {
3016        return isFunction(object[key]);
3017      });
3018    }
3019
3020    /**
3021     * The base implementation of `_.get` without support for default values.
3022     *
3023     * @private
3024     * @param {Object} object The object to query.
3025     * @param {Array|string} path The path of the property to get.
3026     * @returns {*} Returns the resolved value.
3027     */
3028    function baseGet(object, path) {
3029      path = castPath(path, object);
3030
3031      var index = 0,
3032          length = path.length;
3033
3034      while (object != null && index < length) {
3035        object = object[toKey(path[index++])];
3036      }
3037      return (index && index == length) ? object : undefined;
3038    }
3039
3040    /**
3041     * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3042     * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3043     * symbols of `object`.
3044     *
3045     * @private
3046     * @param {Object} object The object to query.
3047     * @param {Function} keysFunc The function to get the keys of `object`.
3048     * @param {Function} symbolsFunc The function to get the symbols of `object`.
3049     * @returns {Array} Returns the array of property names and symbols.
3050     */
3051    function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3052      var result = keysFunc(object);
3053      return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3054    }
3055
3056    /**
3057     * The base implementation of `getTag` without fallbacks for buggy environments.
3058     *
3059     * @private
3060     * @param {*} value The value to query.
3061     * @returns {string} Returns the `toStringTag`.
3062     */
3063    function baseGetTag(value) {
3064      if (value == null) {
3065        return value === undefined ? undefinedTag : nullTag;
3066      }
3067      return (symToStringTag && symToStringTag in Object(value))
3068        ? getRawTag(value)
3069        : objectToString(value);
3070    }
3071
3072    /**
3073     * The base implementation of `_.gt` which doesn't coerce arguments.
3074     *
3075     * @private
3076     * @param {*} value The value to compare.
3077     * @param {*} other The other value to compare.
3078     * @returns {boolean} Returns `true` if `value` is greater than `other`,
3079     *  else `false`.
3080     */
3081    function baseGt(value, other) {
3082      return value > other;
3083    }
3084
3085    /**
3086     * The base implementation of `_.has` without support for deep paths.
3087     *
3088     * @private
3089     * @param {Object} [object] The object to query.
3090     * @param {Array|string} key The key to check.
3091     * @returns {boolean} Returns `true` if `key` exists, else `false`.
3092     */
3093    function baseHas(object, key) {
3094      return object != null && hasOwnProperty.call(object, key);
3095    }
3096
3097    /**
3098     * The base implementation of `_.hasIn` without support for deep paths.
3099     *
3100     * @private
3101     * @param {Object} [object] The object to query.
3102     * @param {Array|string} key The key to check.
3103     * @returns {boolean} Returns `true` if `key` exists, else `false`.
3104     */
3105    function baseHasIn(object, key) {
3106      return object != null && key in Object(object);
3107    }
3108
3109    /**
3110     * The base implementation of `_.inRange` which doesn't coerce arguments.
3111     *
3112     * @private
3113     * @param {number} number The number to check.
3114     * @param {number} start The start of the range.
3115     * @param {number} end The end of the range.
3116     * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
3117     */
3118    function baseInRange(number, start, end) {
3119      return number >= nativeMin(start, end) && number < nativeMax(start, end);
3120    }
3121
3122    /**
3123     * The base implementation of methods like `_.intersection`, without support
3124     * for iteratee shorthands, that accepts an array of arrays to inspect.
3125     *
3126     * @private
3127     * @param {Array} arrays The arrays to inspect.
3128     * @param {Function} [iteratee] The iteratee invoked per element.
3129     * @param {Function} [comparator] The comparator invoked per element.
3130     * @returns {Array} Returns the new array of shared values.
3131     */
3132    function baseIntersection(arrays, iteratee, comparator) {
3133      var includes = comparator ? arrayIncludesWith : arrayIncludes,
3134          length = arrays[0].length,
3135          othLength = arrays.length,
3136          othIndex = othLength,
3137          caches = Array(othLength),
3138          maxLength = Infinity,
3139          result = [];
3140
3141      while (othIndex--) {
3142        var array = arrays[othIndex];
3143        if (othIndex && iteratee) {
3144          array = arrayMap(array, baseUnary(iteratee));
3145        }
3146        maxLength = nativeMin(array.length, maxLength);
3147        caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3148          ? new SetCache(othIndex && array)
3149          : undefined;
3150      }
3151      array = arrays[0];
3152
3153      var index = -1,
3154          seen = caches[0];
3155
3156      outer:
3157      while (++index < length && result.length < maxLength) {
3158        var value = array[index],
3159            computed = iteratee ? iteratee(value) : value;
3160
3161        value = (comparator || value !== 0) ? value : 0;
3162        if (!(seen
3163              ? cacheHas(seen, computed)
3164              : includes(result, computed, comparator)
3165            )) {
3166          othIndex = othLength;
3167          while (--othIndex) {
3168            var cache = caches[othIndex];
3169            if (!(cache
3170                  ? cacheHas(cache, computed)
3171                  : includes(arrays[othIndex], computed, comparator))
3172                ) {
3173              continue outer;
3174            }
3175          }
3176          if (seen) {
3177            seen.push(computed);
3178          }
3179          result.push(value);
3180        }
3181      }
3182      return result;
3183    }
3184
3185    /**
3186     * The base implementation of `_.invert` and `_.invertBy` which inverts
3187     * `object` with values transformed by `iteratee` and set by `setter`.
3188     *
3189     * @private
3190     * @param {Object} object The object to iterate over.
3191     * @param {Function} setter The function to set `accumulator` values.
3192     * @param {Function} iteratee The iteratee to transform values.
3193     * @param {Object} accumulator The initial inverted object.
3194     * @returns {Function} Returns `accumulator`.
3195     */
3196    function baseInverter(object, setter, iteratee, accumulator) {
3197      baseForOwn(object, function(value, key, object) {
3198        setter(accumulator, iteratee(value), key, object);
3199      });
3200      return accumulator;
3201    }
3202
3203    /**
3204     * The base implementation of `_.invoke` without support for individual
3205     * method arguments.
3206     *
3207     * @private
3208     * @param {Object} object The object to query.
3209     * @param {Array|string} path The path of the method to invoke.
3210     * @param {Array} args The arguments to invoke the method with.
3211     * @returns {*} Returns the result of the invoked method.
3212     */
3213    function baseInvoke(object, path, args) {
3214      path = castPath(path, object);
3215      object = parent(object, path);
3216      var func = object == null ? object : object[toKey(last(path))];
3217      return func == null ? undefined : apply(func, object, args);
3218    }
3219
3220    /**
3221     * The base implementation of `_.isArguments`.
3222     *
3223     * @private
3224     * @param {*} value The value to check.
3225     * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3226     */
3227    function baseIsArguments(value) {
3228      return isObjectLike(value) && baseGetTag(value) == argsTag;
3229    }
3230
3231    /**
3232     * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3233     *
3234     * @private
3235     * @param {*} value The value to check.
3236     * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3237     */
3238    function baseIsArrayBuffer(value) {
3239      return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3240    }
3241
3242    /**
3243     * The base implementation of `_.isDate` without Node.js optimizations.
3244     *
3245     * @private
3246     * @param {*} value The value to check.
3247     * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3248     */
3249    function baseIsDate(value) {
3250      return isObjectLike(value) && baseGetTag(value) == dateTag;
3251    }
3252
3253    /**
3254     * The base implementation of `_.isEqual` which supports partial comparisons
3255     * and tracks traversed objects.
3256     *
3257     * @private
3258     * @param {*} value The value to compare.
3259     * @param {*} other The other value to compare.
3260     * @param {boolean} bitmask The bitmask flags.
3261     *  1 - Unordered comparison
3262     *  2 - Partial comparison
3263     * @param {Function} [customizer] The function to customize comparisons.
3264     * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3265     * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3266     */
3267    function baseIsEqual(value, other, bitmask, customizer, stack) {
3268      if (value === other) {
3269        return true;
3270      }
3271      if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3272        return value !== value && other !== other;
3273      }
3274      return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3275    }
3276
3277    /**
3278     * A specialized version of `baseIsEqual` for arrays and objects which performs
3279     * deep comparisons and tracks traversed objects enabling objects with circular
3280     * references to be compared.
3281     *
3282     * @private
3283     * @param {Object} object The object to compare.
3284     * @param {Object} other The other object to compare.
3285     * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3286     * @param {Function} customizer The function to customize comparisons.
3287     * @param {Function} equalFunc The function to determine equivalents of values.
3288     * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3289     * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3290     */
3291    function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3292      var objIsArr = isArray(object),
3293          othIsArr = isArray(other),
3294          objTag = objIsArr ? arrayTag : getTag(object),
3295          othTag = othIsArr ? arrayTag : getTag(other);
3296
3297      objTag = objTag == argsTag ? objectTag : objTag;
3298      othTag = othTag == argsTag ? objectTag : othTag;
3299
3300      var objIsObj = objTag == objectTag,
3301          othIsObj = othTag == objectTag,
3302          isSameTag = objTag == othTag;
3303
3304      if (isSameTag && isBuffer(object)) {
3305        if (!isBuffer(other)) {
3306          return false;
3307        }
3308        objIsArr = true;
3309        objIsObj = false;
3310      }
3311      if (isSameTag && !objIsObj) {
3312        stack || (stack = new Stack);
3313        return (objIsArr || isTypedArray(object))
3314          ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3315          : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3316      }
3317      if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3318        var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3319            othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3320
3321        if (objIsWrapped || othIsWrapped) {
3322          var objUnwrapped = objIsWrapped ? object.value() : object,
3323              othUnwrapped = othIsWrapped ? other.value() : other;
3324
3325          stack || (stack = new Stack);
3326          return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3327        }
3328      }
3329      if (!isSameTag) {
3330        return false;
3331      }
3332      stack || (stack = new Stack);
3333      return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3334    }
3335
3336    /**
3337     * The base implementation of `_.isMap` without Node.js optimizations.
3338     *
3339     * @private
3340     * @param {*} value The value to check.
3341     * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3342     */
3343    function baseIsMap(value) {
3344      return isObjectLike(value) && getTag(value) == mapTag;
3345    }
3346
3347    /**
3348     * The base implementation of `_.isMatch` without support for iteratee shorthands.
3349     *
3350     * @private
3351     * @param {Object} object The object to inspect.
3352     * @param {Object} source The object of property values to match.
3353     * @param {Array} matchData The property names, values, and compare flags to match.
3354     * @param {Function} [customizer] The function to customize comparisons.
3355     * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3356     */
3357    function baseIsMatch(object, source, matchData, customizer) {
3358      var index = matchData.length,
3359          length = index,
3360          noCustomizer = !customizer;
3361
3362      if (object == null) {
3363        return !length;
3364      }
3365      object = Object(object);
3366      while (index--) {
3367        var data = matchData[index];
3368        if ((noCustomizer && data[2])
3369              ? data[1] !== object[data[0]]
3370              : !(data[0] in object)
3371            ) {
3372          return false;
3373        }
3374      }
3375      while (++index < length) {
3376        data = matchData[index];
3377        var key = data[0],
3378            objValue = object[key],
3379            srcValue = data[1];
3380
3381        if (noCustomizer && data[2]) {
3382          if (objValue === undefined && !(key in object)) {
3383            return false;
3384          }
3385        } else {
3386          var stack = new Stack;
3387          if (customizer) {
3388            var result = customizer(objValue, srcValue, key, object, source, stack);
3389          }
3390          if (!(result === undefined
3391                ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
3392                : result
3393              )) {
3394            return false;
3395          }
3396        }
3397      }
3398      return true;
3399    }
3400
3401    /**
3402     * The base implementation of `_.isNative` without bad shim checks.
3403     *
3404     * @private
3405     * @param {*} value The value to check.
3406     * @returns {boolean} Returns `true` if `value` is a native function,
3407     *  else `false`.
3408     */
3409    function baseIsNative(value) {
3410      if (!isObject(value) || isMasked(value)) {
3411        return false;
3412      }
3413      var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3414      return pattern.test(toSource(value));
3415    }
3416
3417    /**
3418     * The base implementation of `_.isRegExp` without Node.js optimizations.
3419     *
3420     * @private
3421     * @param {*} value The value to check.
3422     * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3423     */
3424    function baseIsRegExp(value) {
3425      return isObjectLike(value) && baseGetTag(value) == regexpTag;
3426    }
3427
3428    /**
3429     * The base implementation of `_.isSet` without Node.js optimizations.
3430     *
3431     * @private
3432     * @param {*} value The value to check.
3433     * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3434     */
3435    function baseIsSet(value) {
3436      return isObjectLike(value) && getTag(value) == setTag;
3437    }
3438
3439    /**
3440     * The base implementation of `_.isTypedArray` without Node.js optimizations.
3441     *
3442     * @private
3443     * @param {*} value The value to check.
3444     * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3445     */
3446    function baseIsTypedArray(value) {
3447      return isObjectLike(value) &&
3448        isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3449    }
3450
3451    /**
3452     * The base implementation of `_.iteratee`.
3453     *
3454     * @private
3455     * @param {*} [value=_.identity] The value to convert to an iteratee.
3456     * @returns {Function} Returns the iteratee.
3457     */
3458    function baseIteratee(value) {
3459      // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3460      // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3461      if (typeof value == 'function') {
3462        return value;
3463      }
3464      if (value == null) {
3465        return identity;
3466      }
3467      if (typeof value == 'object') {
3468        return isArray(value)
3469          ? baseMatchesProperty(value[0], value[1])
3470          : baseMatches(value);
3471      }
3472      return property(value);
3473    }
3474
3475    /**
3476     * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3477     *
3478     * @private
3479     * @param {Object} object The object to query.
3480     * @returns {Array} Returns the array of property names.
3481     */
3482    function baseKeys(object) {
3483      if (!isPrototype(object)) {
3484        return nativeKeys(object);
3485      }
3486      var result = [];
3487      for (var key in Object(object)) {
3488        if (hasOwnProperty.call(object, key) && key != 'constructor') {
3489          result.push(key);
3490        }
3491      }
3492      return result;
3493    }
3494
3495    /**
3496     * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3497     *
3498     * @private
3499     * @param {Object} object The object to query.
3500     * @returns {Array} Returns the array of property names.
3501     */
3502    function baseKeysIn(object) {
3503      if (!isObject(object)) {
3504        return nativeKeysIn(object);
3505      }
3506      var isProto = isPrototype(object),
3507          result = [];
3508
3509      for (var key in object) {
3510        if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3511          result.push(key);
3512        }
3513      }
3514      return result;
3515    }
3516
3517    /**
3518     * The base implementation of `_.lt` which doesn't coerce arguments.
3519     *
3520     * @private
3521     * @param {*} value The value to compare.
3522     * @param {*} other The other value to compare.
3523     * @returns {boolean} Returns `true` if `value` is less than `other`,
3524     *  else `false`.
3525     */
3526    function baseLt(value, other) {
3527      return value < other;
3528    }
3529
3530    /**
3531     * The base implementation of `_.map` without support for iteratee shorthands.
3532     *
3533     * @private
3534     * @param {Array|Object} collection The collection to iterate over.
3535     * @param {Function} iteratee The function invoked per iteration.
3536     * @returns {Array} Returns the new mapped array.
3537     */
3538    function baseMap(collection, iteratee) {
3539      var index = -1,
3540          result = isArrayLike(collection) ? Array(collection.length) : [];
3541
3542      baseEach(collection, function(value, key, collection) {
3543        result[++index] = iteratee(value, key, collection);
3544      });
3545      return result;
3546    }
3547
3548    /**
3549     * The base implementation of `_.matches` which doesn't clone `source`.
3550     *
3551     * @private
3552     * @param {Object} source The object of property values to match.
3553     * @returns {Function} Returns the new spec function.
3554     */
3555    function baseMatches(source) {
3556      var matchData = getMatchData(source);
3557      if (matchData.length == 1 && matchData[0][2]) {
3558        return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3559      }
3560      return function(object) {
3561        return object === source || baseIsMatch(object, source, matchData);
3562      };
3563    }
3564
3565    /**
3566     * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3567     *
3568     * @private
3569     * @param {string} path The path of the property to get.
3570     * @param {*} srcValue The value to match.
3571     * @returns {Function} Returns the new spec function.
3572     */
3573    function baseMatchesProperty(path, srcValue) {
3574      if (isKey(path) && isStrictComparable(srcValue)) {
3575        return matchesStrictComparable(toKey(path), srcValue);
3576      }
3577      return function(object) {
3578        var objValue = get(object, path);
3579        return (objValue === undefined && objValue === srcValue)
3580          ? hasIn(object, path)
3581          : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3582      };
3583    }
3584
3585    /**
3586     * The base implementation of `_.merge` without support for multiple sources.
3587     *
3588     * @private
3589     * @param {Object} object The destination object.
3590     * @param {Object} source The source object.
3591     * @param {number} srcIndex The index of `source`.
3592     * @param {Function} [customizer] The function to customize merged values.
3593     * @param {Object} [stack] Tracks traversed source values and their merged
3594     *  counterparts.
3595     */
3596    function baseMerge(object, source, srcIndex, customizer, stack) {
3597      if (object === source) {
3598        return;
3599      }
3600      baseFor(source, function(srcValue, key) {
3601        stack || (stack = new Stack);
3602        if (isObject(srcValue)) {
3603          baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3604        }
3605        else {
3606          var newValue = customizer
3607            ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
3608            : undefined;
3609
3610          if (newValue === undefined) {
3611            newValue = srcValue;
3612          }
3613          assignMergeValue(object, key, newValue);
3614        }
3615      }, keysIn);
3616    }
3617
3618    /**
3619     * A specialized version of `baseMerge` for arrays and objects which performs
3620     * deep merges and tracks traversed objects enabling objects with circular
3621     * references to be merged.
3622     *
3623     * @private
3624     * @param {Object} object The destination object.
3625     * @param {Object} source The source object.
3626     * @param {string} key The key of the value to merge.
3627     * @param {number} srcIndex The index of `source`.
3628     * @param {Function} mergeFunc The function to merge values.
3629     * @param {Function} [customizer] The function to customize assigned values.
3630     * @param {Object} [stack] Tracks traversed source values and their merged
3631     *  counterparts.
3632     */
3633    function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3634      var objValue = safeGet(object, key),
3635          srcValue = safeGet(source, key),
3636          stacked = stack.get(srcValue);
3637
3638      if (stacked) {
3639        assignMergeValue(object, key, stacked);
3640        return;
3641      }
3642      var newValue = customizer
3643        ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3644        : undefined;
3645
3646      var isCommon = newValue === undefined;
3647
3648      if (isCommon) {
3649        var isArr = isArray(srcValue),
3650            isBuff = !isArr && isBuffer(srcValue),
3651            isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3652
3653        newValue = srcValue;
3654        if (isArr || isBuff || isTyped) {
3655          if (isArray(objValue)) {
3656            newValue = objValue;
3657          }
3658          else if (isArrayLikeObject(objValue)) {
3659            newValue = copyArray(objValue);
3660          }
3661          else if (isBuff) {
3662            isCommon = false;
3663            newValue = cloneBuffer(srcValue, true);
3664          }
3665          else if (isTyped) {
3666            isCommon = false;
3667            newValue = cloneTypedArray(srcValue, true);
3668          }
3669          else {
3670            newValue = [];
3671          }
3672        }
3673        else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3674          newValue = objValue;
3675          if (isArguments(objValue)) {
3676            newValue = toPlainObject(objValue);
3677          }
3678          else if (!isObject(objValue) || isFunction(objValue)) {
3679            newValue = initCloneObject(srcValue);
3680          }
3681        }
3682        else {
3683          isCommon = false;
3684        }
3685      }
3686      if (isCommon) {
3687        // Recursively merge objects and arrays (susceptible to call stack limits).
3688        stack.set(srcValue, newValue);
3689        mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3690        stack['delete'](srcValue);
3691      }
3692      assignMergeValue(object, key, newValue);
3693    }
3694
3695    /**
3696     * The base implementation of `_.nth` which doesn't coerce arguments.
3697     *
3698     * @private
3699     * @param {Array} array The array to query.
3700     * @param {number} n The index of the element to return.
3701     * @returns {*} Returns the nth element of `array`.
3702     */
3703    function baseNth(array, n) {
3704      var length = array.length;
3705      if (!length) {
3706        return;
3707      }
3708      n += n < 0 ? length : 0;
3709      return isIndex(n, length) ? array[n] : undefined;
3710    }
3711
3712    /**
3713     * The base implementation of `_.orderBy` without param guards.
3714     *
3715     * @private
3716     * @param {Array|Object} collection The collection to iterate over.
3717     * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
3718     * @param {string[]} orders The sort orders of `iteratees`.
3719     * @returns {Array} Returns the new sorted array.
3720     */
3721    function baseOrderBy(collection, iteratees, orders) {
3722      var index = -1;
3723      iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
3724
3725      var result = baseMap(collection, function(value, key, collection) {
3726        var criteria = arrayMap(iteratees, function(iteratee) {
3727          return iteratee(value);
3728        });
3729        return { 'criteria': criteria, 'index': ++index, 'value': value };
3730      });
3731
3732      return baseSortBy(result, function(object, other) {
3733        return compareMultiple(object, other, orders);
3734      });
3735    }
3736
3737    /**
3738     * The base implementation of `_.pick` without support for individual
3739     * property identifiers.
3740     *
3741     * @private
3742     * @param {Object} object The source object.
3743     * @param {string[]} paths The property paths to pick.
3744     * @returns {Object} Returns the new object.
3745     */
3746    function basePick(object, paths) {
3747      return basePickBy(object, paths, function(value, path) {
3748        return hasIn(object, path);
3749      });
3750    }
3751
3752    /**
3753     * The base implementation of  `_.pickBy` without support for iteratee shorthands.
3754     *
3755     * @private
3756     * @param {Object} object The source object.
3757     * @param {string[]} paths The property paths to pick.
3758     * @param {Function} predicate The function invoked per property.
3759     * @returns {Object} Returns the new object.
3760     */
3761    function basePickBy(object, paths, predicate) {
3762      var index = -1,
3763          length = paths.length,
3764          result = {};
3765
3766      while (++index < length) {
3767        var path = paths[index],
3768            value = baseGet(object, path);
3769
3770        if (predicate(value, path)) {
3771          baseSet(result, castPath(path, object), value);
3772        }
3773      }
3774      return result;
3775    }
3776
3777    /**
3778     * A specialized version of `baseProperty` which supports deep paths.
3779     *
3780     * @private
3781     * @param {Array|string} path The path of the property to get.
3782     * @returns {Function} Returns the new accessor function.
3783     */
3784    function basePropertyDeep(path) {
3785      return function(object) {
3786        return baseGet(object, path);
3787      };
3788    }
3789
3790    /**
3791     * The base implementation of `_.pullAllBy` without support for iteratee
3792     * shorthands.
3793     *
3794     * @private
3795     * @param {Array} array The array to modify.
3796     * @param {Array} values The values to remove.
3797     * @param {Function} [iteratee] The iteratee invoked per element.
3798     * @param {Function} [comparator] The comparator invoked per element.
3799     * @returns {Array} Returns `array`.
3800     */
3801    function basePullAll(array, values, iteratee, comparator) {
3802      var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3803          index = -1,
3804          length = values.length,
3805          seen = array;
3806
3807      if (array === values) {
3808        values = copyArray(values);
3809      }
3810      if (iteratee) {
3811        seen = arrayMap(array, baseUnary(iteratee));
3812      }
3813      while (++index < length) {
3814        var fromIndex = 0,
3815            value = values[index],
3816            computed = iteratee ? iteratee(value) : value;
3817
3818        while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3819          if (seen !== array) {
3820            splice.call(seen, fromIndex, 1);
3821          }
3822          splice.call(array, fromIndex, 1);
3823        }
3824      }
3825      return array;
3826    }
3827
3828    /**
3829     * The base implementation of `_.pullAt` without support for individual
3830     * indexes or capturing the removed elements.
3831     *
3832     * @private
3833     * @param {Array} array The array to modify.
3834     * @param {number[]} indexes The indexes of elements to remove.
3835     * @returns {Array} Returns `array`.
3836     */
3837    function basePullAt(array, indexes) {
3838      var length = array ? indexes.length : 0,
3839          lastIndex = length - 1;
3840
3841      while (length--) {
3842        var index = indexes[length];
3843        if (length == lastIndex || index !== previous) {
3844          var previous = index;
3845          if (isIndex(index)) {
3846            splice.call(array, index, 1);
3847          } else {
3848            baseUnset(array, index);
3849          }
3850        }
3851      }
3852      return array;
3853    }
3854
3855    /**
3856     * The base implementation of `_.random` without support for returning
3857     * floating-point numbers.
3858     *
3859     * @private
3860     * @param {number} lower The lower bound.
3861     * @param {number} upper The upper bound.
3862     * @returns {number} Returns the random number.
3863     */
3864    function baseRandom(lower, upper) {
3865      return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
3866    }
3867
3868    /**
3869     * The base implementation of `_.range` and `_.rangeRight` which doesn't
3870     * coerce arguments.
3871     *
3872     * @private
3873     * @param {number} start The start of the range.
3874     * @param {number} end The end of the range.
3875     * @param {number} step The value to increment or decrement by.
3876     * @param {boolean} [fromRight] Specify iterating from right to left.
3877     * @returns {Array} Returns the range of numbers.
3878     */
3879    function baseRange(start, end, step, fromRight) {
3880      var index = -1,
3881          length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
3882          result = Array(length);
3883
3884      while (length--) {
3885        result[fromRight ? length : ++index] = start;
3886        start += step;
3887      }
3888      return result;
3889    }
3890
3891    /**
3892     * The base implementation of `_.repeat` which doesn't coerce arguments.
3893     *
3894     * @private
3895     * @param {string} string The string to repeat.
3896     * @param {number} n The number of times to repeat the string.
3897     * @returns {string} Returns the repeated string.
3898     */
3899    function baseRepeat(string, n) {
3900      var result = '';
3901      if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
3902        return result;
3903      }
3904      // Leverage the exponentiation by squaring algorithm for a faster repeat.
3905      // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
3906      do {
3907        if (n % 2) {
3908          result += string;
3909        }
3910        n = nativeFloor(n / 2);
3911        if (n) {
3912          string += string;
3913        }
3914      } while (n);
3915
3916      return result;
3917    }
3918
3919    /**
3920     * The base implementation of `_.rest` which doesn't validate or coerce arguments.
3921     *
3922     * @private
3923     * @param {Function} func The function to apply a rest parameter to.
3924     * @param {number} [start=func.length-1] The start position of the rest parameter.
3925     * @returns {Function} Returns the new function.
3926     */
3927    function baseRest(func, start) {
3928      return setToString(overRest(func, start, identity), func + '');
3929    }
3930
3931    /**
3932     * The base implementation of `_.sample`.
3933     *
3934     * @private
3935     * @param {Array|Object} collection The collection to sample.
3936     * @returns {*} Returns the random element.
3937     */
3938    function baseSample(collection) {
3939      return arraySample(values(collection));
3940    }
3941
3942    /**
3943     * The base implementation of `_.sampleSize` without param guards.
3944     *
3945     * @private
3946     * @param {Array|Object} collection The collection to sample.
3947     * @param {number} n The number of elements to sample.
3948     * @returns {Array} Returns the random elements.
3949     */
3950    function baseSampleSize(collection, n) {
3951      var array = values(collection);
3952      return shuffleSelf(array, baseClamp(n, 0, array.length));
3953    }
3954
3955    /**
3956     * The base implementation of `_.set`.
3957     *
3958     * @private
3959     * @param {Object} object The object to modify.
3960     * @param {Array|string} path The path of the property to set.
3961     * @param {*} value The value to set.
3962     * @param {Function} [customizer] The function to customize path creation.
3963     * @returns {Object} Returns `object`.
3964     */
3965    function baseSet(object, path, value, customizer) {
3966      if (!isObject(object)) {
3967        return object;
3968      }
3969      path = castPath(path, object);
3970
3971      var index = -1,
3972          length = path.length,
3973          lastIndex = length - 1,
3974          nested = object;
3975
3976      while (nested != null && ++index < length) {
3977        var key = toKey(path[index]),
3978            newValue = value;
3979
3980        if (index != lastIndex) {
3981          var objValue = nested[key];
3982          newValue = customizer ? customizer(objValue, key, nested) : undefined;
3983          if (newValue === undefined) {
3984            newValue = isObject(objValue)
3985              ? objValue
3986              : (isIndex(path[index + 1]) ? [] : {});
3987          }
3988        }
3989        assignValue(nested, key, newValue);
3990        nested = nested[key];
3991      }
3992      return object;
3993    }
3994
3995    /**
3996     * The base implementation of `setData` without support for hot loop shorting.
3997     *
3998     * @private
3999     * @param {Function} func The function to associate metadata with.
4000     * @param {*} data The metadata.
4001     * @returns {Function} Returns `func`.
4002     */
4003    var baseSetData = !metaMap ? identity : function(func, data) {
4004      metaMap.set(func, data);
4005      return func;
4006    };
4007
4008    /**
4009     * The base implementation of `setToString` without support for hot loop shorting.
4010     *
4011     * @private
4012     * @param {Function} func The function to modify.
4013     * @param {Function} string The `toString` result.
4014     * @returns {Function} Returns `func`.
4015     */
4016    var baseSetToString = !defineProperty ? identity : function(func, string) {
4017      return defineProperty(func, 'toString', {
4018        'configurable': true,
4019        'enumerable': false,
4020        'value': constant(string),
4021        'writable': true
4022      });
4023    };
4024
4025    /**
4026     * The base implementation of `_.shuffle`.
4027     *
4028     * @private
4029     * @param {Array|Object} collection The collection to shuffle.
4030     * @returns {Array} Returns the new shuffled array.
4031     */
4032    function baseShuffle(collection) {
4033      return shuffleSelf(values(collection));
4034    }
4035
4036    /**
4037     * The base implementation of `_.slice` without an iteratee call guard.
4038     *
4039     * @private
4040     * @param {Array} array The array to slice.
4041     * @param {number} [start=0] The start position.
4042     * @param {number} [end=array.length] The end position.
4043     * @returns {Array} Returns the slice of `array`.
4044     */
4045    function baseSlice(array, start, end) {
4046      var index = -1,
4047          length = array.length;
4048
4049      if (start < 0) {
4050        start = -start > length ? 0 : (length + start);
4051      }
4052      end = end > length ? length : end;
4053      if (end < 0) {
4054        end += length;
4055      }
4056      length = start > end ? 0 : ((end - start) >>> 0);
4057      start >>>= 0;
4058
4059      var result = Array(length);
4060      while (++index < length) {
4061        result[index] = array[index + start];
4062      }
4063      return result;
4064    }
4065
4066    /**
4067     * The base implementation of `_.some` without support for iteratee shorthands.
4068     *
4069     * @private
4070     * @param {Array|Object} collection The collection to iterate over.
4071     * @param {Function} predicate The function invoked per iteration.
4072     * @returns {boolean} Returns `true` if any element passes the predicate check,
4073     *  else `false`.
4074     */
4075    function baseSome(collection, predicate) {
4076      var result;
4077
4078      baseEach(collection, function(value, index, collection) {
4079        result = predicate(value, index, collection);
4080        return !result;
4081      });
4082      return !!result;
4083    }
4084
4085    /**
4086     * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
4087     * performs a binary search of `array` to determine the index at which `value`
4088     * should be inserted into `array` in order to maintain its sort order.
4089     *
4090     * @private
4091     * @param {Array} array The sorted array to inspect.
4092     * @param {*} value The value to evaluate.
4093     * @param {boolean} [retHighest] Specify returning the highest qualified index.
4094     * @returns {number} Returns the index at which `value` should be inserted
4095     *  into `array`.
4096     */
4097    function baseSortedIndex(array, value, retHighest) {
4098      var low = 0,
4099          high = array == null ? low : array.length;
4100
4101      if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4102        while (low < high) {
4103          var mid = (low + high) >>> 1,
4104              computed = array[mid];
4105
4106          if (computed !== null && !isSymbol(computed) &&
4107              (retHighest ? (computed <= value) : (computed < value))) {
4108            low = mid + 1;
4109          } else {
4110            high = mid;
4111          }
4112        }
4113        return high;
4114      }
4115      return baseSortedIndexBy(array, value, identity, retHighest);
4116    }
4117
4118    /**
4119     * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
4120     * which invokes `iteratee` for `value` and each element of `array` to compute
4121     * their sort ranking. The iteratee is invoked with one argument; (value).
4122     *
4123     * @private
4124     * @param {Array} array The sorted array to inspect.
4125     * @param {*} value The value to evaluate.
4126     * @param {Function} iteratee The iteratee invoked per element.
4127     * @param {boolean} [retHighest] Specify returning the highest qualified index.
4128     * @returns {number} Returns the index at which `value` should be inserted
4129     *  into `array`.
4130     */
4131    function baseSortedIndexBy(array, value, iteratee, retHighest) {
4132      value = iteratee(value);
4133
4134      var low = 0,
4135          high = array == null ? 0 : array.length,
4136          valIsNaN = value !== value,
4137          valIsNull = value === null,
4138          valIsSymbol = isSymbol(value),
4139          valIsUndefined = value === undefined;
4140
4141      while (low < high) {
4142        var mid = nativeFloor((low + high) / 2),
4143            computed = iteratee(array[mid]),
4144            othIsDefined = computed !== undefined,
4145            othIsNull = computed === null,
4146            othIsReflexive = computed === computed,
4147            othIsSymbol = isSymbol(computed);
4148
4149        if (valIsNaN) {
4150          var setLow = retHighest || othIsReflexive;
4151        } else if (valIsUndefined) {
4152          setLow = othIsReflexive && (retHighest || othIsDefined);
4153        } else if (valIsNull) {
4154          setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
4155        } else if (valIsSymbol) {
4156          setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
4157        } else if (othIsNull || othIsSymbol) {
4158          setLow = false;
4159        } else {
4160          setLow = retHighest ? (computed <= value) : (computed < value);
4161        }
4162        if (setLow) {
4163          low = mid + 1;
4164        } else {
4165          high = mid;
4166        }
4167      }
4168      return nativeMin(high, MAX_ARRAY_INDEX);
4169    }
4170
4171    /**
4172     * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4173     * support for iteratee shorthands.
4174     *
4175     * @private
4176     * @param {Array} array The array to inspect.
4177     * @param {Function} [iteratee] The iteratee invoked per element.
4178     * @returns {Array} Returns the new duplicate free array.
4179     */
4180    function baseSortedUniq(array, iteratee) {
4181      var index = -1,
4182          length = array.length,
4183          resIndex = 0,
4184          result = [];
4185
4186      while (++index < length) {
4187        var value = array[index],
4188            computed = iteratee ? iteratee(value) : value;
4189
4190        if (!index || !eq(computed, seen)) {
4191          var seen = computed;
4192          result[resIndex++] = value === 0 ? 0 : value;
4193        }
4194      }
4195      return result;
4196    }
4197
4198    /**
4199     * The base implementation of `_.toNumber` which doesn't ensure correct
4200     * conversions of binary, hexadecimal, or octal string values.
4201     *
4202     * @private
4203     * @param {*} value The value to process.
4204     * @returns {number} Returns the number.
4205     */
4206    function baseToNumber(value) {
4207      if (typeof value == 'number') {
4208        return value;
4209      }
4210      if (isSymbol(value)) {
4211        return NAN;
4212      }
4213      return +value;
4214    }
4215
4216    /**
4217     * The base implementation of `_.toString` which doesn't convert nullish
4218     * values to empty strings.
4219     *
4220     * @private
4221     * @param {*} value The value to process.
4222     * @returns {string} Returns the string.
4223     */
4224    function baseToString(value) {
4225      // Exit early for strings to avoid a performance hit in some environments.
4226      if (typeof value == 'string') {
4227        return value;
4228      }
4229      if (isArray(value)) {
4230        // Recursively convert values (susceptible to call stack limits).
4231        return arrayMap(value, baseToString) + '';
4232      }
4233      if (isSymbol(value)) {
4234        return symbolToString ? symbolToString.call(value) : '';
4235      }
4236      var result = (value + '');
4237      return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4238    }
4239
4240    /**
4241     * The base implementation of `_.uniqBy` without support for iteratee shorthands.
4242     *
4243     * @private
4244     * @param {Array} array The array to inspect.
4245     * @param {Function} [iteratee] The iteratee invoked per element.
4246     * @param {Function} [comparator] The comparator invoked per element.
4247     * @returns {Array} Returns the new duplicate free array.
4248     */
4249    function baseUniq(array, iteratee, comparator) {
4250      var index = -1,
4251          includes = arrayIncludes,
4252          length = array.length,
4253          isCommon = true,
4254          result = [],
4255          seen = result;
4256
4257      if (comparator) {
4258        isCommon = false;
4259        includes = arrayIncludesWith;
4260      }
4261      else if (length >= LARGE_ARRAY_SIZE) {
4262        var set = iteratee ? null : createSet(array);
4263        if (set) {
4264          return setToArray(set);
4265        }
4266        isCommon = false;
4267        includes = cacheHas;
4268        seen = new SetCache;
4269      }
4270      else {
4271        seen = iteratee ? [] : result;
4272      }
4273      outer:
4274      while (++index < length) {
4275        var value = array[index],
4276            computed = iteratee ? iteratee(value) : value;
4277
4278        value = (comparator || value !== 0) ? value : 0;
4279        if (isCommon && computed === computed) {
4280          var seenIndex = seen.length;
4281          while (seenIndex--) {
4282            if (seen[seenIndex] === computed) {
4283              continue outer;
4284            }
4285          }
4286          if (iteratee) {
4287            seen.push(computed);
4288          }
4289          result.push(value);
4290        }
4291        else if (!includes(seen, computed, comparator)) {
4292          if (seen !== result) {
4293            seen.push(computed);
4294          }
4295          result.push(value);
4296        }
4297      }
4298      return result;
4299    }
4300
4301    /**
4302     * The base implementation of `_.unset`.
4303     *
4304     * @private
4305     * @param {Object} object The object to modify.
4306     * @param {Array|string} path The property path to unset.
4307     * @returns {boolean} Returns `true` if the property is deleted, else `false`.
4308     */
4309    function baseUnset(object, path) {
4310      path = castPath(path, object);
4311      object = parent(object, path);
4312      return object == null || delete object[toKey(last(path))];
4313    }
4314
4315    /**
4316     * The base implementation of `_.update`.
4317     *
4318     * @private
4319     * @param {Object} object The object to modify.
4320     * @param {Array|string} path The path of the property to update.
4321     * @param {Function} updater The function to produce the updated value.
4322     * @param {Function} [customizer] The function to customize path creation.
4323     * @returns {Object} Returns `object`.
4324     */
4325    function baseUpdate(object, path, updater, customizer) {
4326      return baseSet(object, path, updater(baseGet(object, path)), customizer);
4327    }
4328
4329    /**
4330     * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4331     * without support for iteratee shorthands.
4332     *
4333     * @private
4334     * @param {Array} array The array to query.
4335     * @param {Function} predicate The function invoked per iteration.
4336     * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
4337     * @param {boolean} [fromRight] Specify iterating from right to left.
4338     * @returns {Array} Returns the slice of `array`.
4339     */
4340    function baseWhile(array, predicate, isDrop, fromRight) {
4341      var length = array.length,
4342          index = fromRight ? length : -1;
4343
4344      while ((fromRight ? index-- : ++index < length) &&
4345        predicate(array[index], index, array)) {}
4346
4347      return isDrop
4348        ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
4349        : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
4350    }
4351
4352    /**
4353     * The base implementation of `wrapperValue` which returns the result of
4354     * performing a sequence of actions on the unwrapped `value`, where each
4355     * successive action is supplied the return value of the previous.
4356     *
4357     * @private
4358     * @param {*} value The unwrapped value.
4359     * @param {Array} actions Actions to perform to resolve the unwrapped value.
4360     * @returns {*} Returns the resolved value.
4361     */
4362    function baseWrapperValue(value, actions) {
4363      var result = value;
4364      if (result instanceof LazyWrapper) {
4365        result = result.value();
4366      }
4367      return arrayReduce(actions, function(result, action) {
4368        return action.func.apply(action.thisArg, arrayPush([result], action.args));
4369      }, result);
4370    }
4371
4372    /**
4373     * The base implementation of methods like `_.xor`, without support for
4374     * iteratee shorthands, that accepts an array of arrays to inspect.
4375     *
4376     * @private
4377     * @param {Array} arrays The arrays to inspect.
4378     * @param {Function} [iteratee] The iteratee invoked per element.
4379     * @param {Function} [comparator] The comparator invoked per element.
4380     * @returns {Array} Returns the new array of values.
4381     */
4382    function baseXor(arrays, iteratee, comparator) {
4383      var length = arrays.length;
4384      if (length < 2) {
4385        return length ? baseUniq(arrays[0]) : [];
4386      }
4387      var index = -1,
4388          result = Array(length);
4389
4390      while (++index < length) {
4391        var array = arrays[index],
4392            othIndex = -1;
4393
4394        while (++othIndex < length) {
4395          if (othIndex != index) {
4396            result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4397          }
4398        }
4399      }
4400      return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4401    }
4402
4403    /**
4404     * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
4405     *
4406     * @private
4407     * @param {Array} props The property identifiers.
4408     * @param {Array} values The property values.
4409     * @param {Function} assignFunc The function to assign values.
4410     * @returns {Object} Returns the new object.
4411     */
4412    function baseZipObject(props, values, assignFunc) {
4413      var index = -1,
4414          length = props.length,
4415          valsLength = values.length,
4416          result = {};
4417
4418      while (++index < length) {
4419        var value = index < valsLength ? values[index] : undefined;
4420        assignFunc(result, props[index], value);
4421      }
4422      return result;
4423    }
4424
4425    /**
4426     * Casts `value` to an empty array if it's not an array like object.
4427     *
4428     * @private
4429     * @param {*} value The value to inspect.
4430     * @returns {Array|Object} Returns the cast array-like object.
4431     */
4432    function castArrayLikeObject(value) {
4433      return isArrayLikeObject(value) ? value : [];
4434    }
4435
4436    /**
4437     * Casts `value` to `identity` if it's not a function.
4438     *
4439     * @private
4440     * @param {*} value The value to inspect.
4441     * @returns {Function} Returns cast function.
4442     */
4443    function castFunction(value) {
4444      return typeof value == 'function' ? value : identity;
4445    }
4446
4447    /**
4448     * Casts `value` to a path array if it's not one.
4449     *
4450     * @private
4451     * @param {*} value The value to inspect.
4452     * @param {Object} [object] The object to query keys on.
4453     * @returns {Array} Returns the cast property path array.
4454     */
4455    function castPath(value, object) {
4456      if (isArray(value)) {
4457        return value;
4458      }
4459      return isKey(value, object) ? [value] : stringToPath(toString(value));
4460    }
4461
4462    /**
4463     * A `baseRest` alias which can be replaced with `identity` by module
4464     * replacement plugins.
4465     *
4466     * @private
4467     * @type {Function}
4468     * @param {Function} func The function to apply a rest parameter to.
4469     * @returns {Function} Returns the new function.
4470     */
4471    var castRest = baseRest;
4472
4473    /**
4474     * Casts `array` to a slice if it's needed.
4475     *
4476     * @private
4477     * @param {Array} array The array to inspect.
4478     * @param {number} start The start position.
4479     * @param {number} [end=array.length] The end position.
4480     * @returns {Array} Returns the cast slice.
4481     */
4482    function castSlice(array, start, end) {
4483      var length = array.length;
4484      end = end === undefined ? length : end;
4485      return (!start && end >= length) ? array : baseSlice(array, start, end);
4486    }
4487
4488    /**
4489     * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4490     *
4491     * @private
4492     * @param {number|Object} id The timer id or timeout object of the timer to clear.
4493     */
4494    var clearTimeout = ctxClearTimeout || function(id) {
4495      return root.clearTimeout(id);
4496    };
4497
4498    /**
4499     * Creates a clone of  `buffer`.
4500     *
4501     * @private
4502     * @param {Buffer} buffer The buffer to clone.
4503     * @param {boolean} [isDeep] Specify a deep clone.
4504     * @returns {Buffer} Returns the cloned buffer.
4505     */
4506    function cloneBuffer(buffer, isDeep) {
4507      if (isDeep) {
4508        return buffer.slice();
4509      }
4510      var length = buffer.length,
4511          result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4512
4513      buffer.copy(result);
4514      return result;
4515    }
4516
4517    /**
4518     * Creates a clone of `arrayBuffer`.
4519     *
4520     * @private
4521     * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4522     * @returns {ArrayBuffer} Returns the cloned array buffer.
4523     */
4524    function cloneArrayBuffer(arrayBuffer) {
4525      var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4526      new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4527      return result;
4528    }
4529
4530    /**
4531     * Creates a clone of `dataView`.
4532     *
4533     * @private
4534     * @param {Object} dataView The data view to clone.
4535     * @param {boolean} [isDeep] Specify a deep clone.
4536     * @returns {Object} Returns the cloned data view.
4537     */
4538    function cloneDataView(dataView, isDeep) {
4539      var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4540      return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4541    }
4542
4543    /**
4544     * Creates a clone of `regexp`.
4545     *
4546     * @private
4547     * @param {Object} regexp The regexp to clone.
4548     * @returns {Object} Returns the cloned regexp.
4549     */
4550    function cloneRegExp(regexp) {
4551      var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4552      result.lastIndex = regexp.lastIndex;
4553      return result;
4554    }
4555
4556    /**
4557     * Creates a clone of the `symbol` object.
4558     *
4559     * @private
4560     * @param {Object} symbol The symbol object to clone.
4561     * @returns {Object} Returns the cloned symbol object.
4562     */
4563    function cloneSymbol(symbol) {
4564      return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4565    }
4566
4567    /**
4568     * Creates a clone of `typedArray`.
4569     *
4570     * @private
4571     * @param {Object} typedArray The typed array to clone.
4572     * @param {boolean} [isDeep] Specify a deep clone.
4573     * @returns {Object} Returns the cloned typed array.
4574     */
4575    function cloneTypedArray(typedArray, isDeep) {
4576      var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4577      return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4578    }
4579
4580    /**
4581     * Compares values to sort them in ascending order.
4582     *
4583     * @private
4584     * @param {*} value The value to compare.
4585     * @param {*} other The other value to compare.
4586     * @returns {number} Returns the sort order indicator for `value`.
4587     */
4588    function compareAscending(value, other) {
4589      if (value !== other) {
4590        var valIsDefined = value !== undefined,
4591            valIsNull = value === null,
4592            valIsReflexive = value === value,
4593            valIsSymbol = isSymbol(value);
4594
4595        var othIsDefined = other !== undefined,
4596            othIsNull = other === null,
4597            othIsReflexive = other === other,
4598            othIsSymbol = isSymbol(other);
4599
4600        if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4601            (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4602            (valIsNull && othIsDefined && othIsReflexive) ||
4603            (!valIsDefined && othIsReflexive) ||
4604            !valIsReflexive) {
4605          return 1;
4606        }
4607        if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4608            (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4609            (othIsNull && valIsDefined && valIsReflexive) ||
4610            (!othIsDefined && valIsReflexive) ||
4611            !othIsReflexive) {
4612          return -1;
4613        }
4614      }
4615      return 0;
4616    }
4617
4618    /**
4619     * Used by `_.orderBy` to compare multiple properties of a value to another
4620     * and stable sort them.
4621     *
4622     * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4623     * specify an order of "desc" for descending or "asc" for ascending sort order
4624     * of corresponding values.
4625     *
4626     * @private
4627     * @param {Object} object The object to compare.
4628     * @param {Object} other The other object to compare.
4629     * @param {boolean[]|string[]} orders The order to sort by for each property.
4630     * @returns {number} Returns the sort order indicator for `object`.
4631     */
4632    function compareMultiple(object, other, orders) {
4633      var index = -1,
4634          objCriteria = object.criteria,
4635          othCriteria = other.criteria,
4636          length = objCriteria.length,
4637          ordersLength = orders.length;
4638
4639      while (++index < length) {
4640        var result = compareAscending(objCriteria[index], othCriteria[index]);
4641        if (result) {
4642          if (index >= ordersLength) {
4643            return result;
4644          }
4645          var order = orders[index];
4646          return result * (order == 'desc' ? -1 : 1);
4647        }
4648      }
4649      // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
4650      // that causes it, under certain circumstances, to provide the same value for
4651      // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
4652      // for more details.
4653      //
4654      // This also ensures a stable sort in V8 and other engines.
4655      // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
4656      return object.index - other.index;
4657    }
4658
4659    /**
4660     * Creates an array that is the composition of partially applied arguments,
4661     * placeholders, and provided arguments into a single array of arguments.
4662     *
4663     * @private
4664     * @param {Array} args The provided arguments.
4665     * @param {Array} partials The arguments to prepend to those provided.
4666     * @param {Array} holders The `partials` placeholder indexes.
4667     * @params {boolean} [isCurried] Specify composing for a curried function.
4668     * @returns {Array} Returns the new array of composed arguments.
4669     */
4670    function composeArgs(args, partials, holders, isCurried) {
4671      var argsIndex = -1,
4672          argsLength = args.length,
4673          holdersLength = holders.length,
4674          leftIndex = -1,
4675          leftLength = partials.length,
4676          rangeLength = nativeMax(argsLength - holdersLength, 0),
4677          result = Array(leftLength + rangeLength),
4678          isUncurried = !isCurried;
4679
4680      while (++leftIndex < leftLength) {
4681        result[leftIndex] = partials[leftIndex];
4682      }
4683      while (++argsIndex < holdersLength) {
4684        if (isUncurried || argsIndex < argsLength) {
4685          result[holders[argsIndex]] = args[argsIndex];
4686        }
4687      }
4688      while (rangeLength--) {
4689        result[leftIndex++] = args[argsIndex++];
4690      }
4691      return result;
4692    }
4693
4694    /**
4695     * This function is like `composeArgs` except that the arguments composition
4696     * is tailored for `_.partialRight`.
4697     *
4698     * @private
4699     * @param {Array} args The provided arguments.
4700     * @param {Array} partials The arguments to append to those provided.
4701     * @param {Array} holders The `partials` placeholder indexes.
4702     * @params {boolean} [isCurried] Specify composing for a curried function.
4703     * @returns {Array} Returns the new array of composed arguments.
4704     */
4705    function composeArgsRight(args, partials, holders, isCurried) {
4706      var argsIndex = -1,
4707          argsLength = args.length,
4708          holdersIndex = -1,
4709          holdersLength = holders.length,
4710          rightIndex = -1,
4711          rightLength = partials.length,
4712          rangeLength = nativeMax(argsLength - holdersLength, 0),
4713          result = Array(rangeLength + rightLength),
4714          isUncurried = !isCurried;
4715
4716      while (++argsIndex < rangeLength) {
4717        result[argsIndex] = args[argsIndex];
4718      }
4719      var offset = argsIndex;
4720      while (++rightIndex < rightLength) {
4721        result[offset + rightIndex] = partials[rightIndex];
4722      }
4723      while (++holdersIndex < holdersLength) {
4724        if (isUncurried || argsIndex < argsLength) {
4725          result[offset + holders[holdersIndex]] = args[argsIndex++];
4726        }
4727      }
4728      return result;
4729    }
4730
4731    /**
4732     * Copies the values of `source` to `array`.
4733     *
4734     * @private
4735     * @param {Array} source The array to copy values from.
4736     * @param {Array} [array=[]] The array to copy values to.
4737     * @returns {Array} Returns `array`.
4738     */
4739    function copyArray(source, array) {
4740      var index = -1,
4741          length = source.length;
4742
4743      array || (array = Array(length));
4744      while (++index < length) {
4745        array[index] = source[index];
4746      }
4747      return array;
4748    }
4749
4750    /**
4751     * Copies properties of `source` to `object`.
4752     *
4753     * @private
4754     * @param {Object} source The object to copy properties from.
4755     * @param {Array} props The property identifiers to copy.
4756     * @param {Object} [object={}] The object to copy properties to.
4757     * @param {Function} [customizer] The function to customize copied values.
4758     * @returns {Object} Returns `object`.
4759     */
4760    function copyObject(source, props, object, customizer) {
4761      var isNew = !object;
4762      object || (object = {});
4763
4764      var index = -1,
4765          length = props.length;
4766
4767      while (++index < length) {
4768        var key = props[index];
4769
4770        var newValue = customizer
4771          ? customizer(object[key], source[key], key, object, source)
4772          : undefined;
4773
4774        if (newValue === undefined) {
4775          newValue = source[key];
4776        }
4777        if (isNew) {
4778          baseAssignValue(object, key, newValue);
4779        } else {
4780          assignValue(object, key, newValue);
4781        }
4782      }
4783      return object;
4784    }
4785
4786    /**
4787     * Copies own symbols of `source` to `object`.
4788     *
4789     * @private
4790     * @param {Object} source The object to copy symbols from.
4791     * @param {Object} [object={}] The object to copy symbols to.
4792     * @returns {Object} Returns `object`.
4793     */
4794    function copySymbols(source, object) {
4795      return copyObject(source, getSymbols(source), object);
4796    }
4797
4798    /**
4799     * Copies own and inherited symbols of `source` to `object`.
4800     *
4801     * @private
4802     * @param {Object} source The object to copy symbols from.
4803     * @param {Object} [object={}] The object to copy symbols to.
4804     * @returns {Object} Returns `object`.
4805     */
4806    function copySymbolsIn(source, object) {
4807      return copyObject(source, getSymbolsIn(source), object);
4808    }
4809
4810    /**
4811     * Creates a function like `_.groupBy`.
4812     *
4813     * @private
4814     * @param {Function} setter The function to set accumulator values.
4815     * @param {Function} [initializer] The accumulator object initializer.
4816     * @returns {Function} Returns the new aggregator function.
4817     */
4818    function createAggregator(setter, initializer) {
4819      return function(collection, iteratee) {
4820        var func = isArray(collection) ? arrayAggregator : baseAggregator,
4821            accumulator = initializer ? initializer() : {};
4822
4823        return func(collection, setter, getIteratee(iteratee, 2), accumulator);
4824      };
4825    }
4826
4827    /**
4828     * Creates a function like `_.assign`.
4829     *
4830     * @private
4831     * @param {Function} assigner The function to assign values.
4832     * @returns {Function} Returns the new assigner function.
4833     */
4834    function createAssigner(assigner) {
4835      return baseRest(function(object, sources) {
4836        var index = -1,
4837            length = sources.length,
4838            customizer = length > 1 ? sources[length - 1] : undefined,
4839            guard = length > 2 ? sources[2] : undefined;
4840
4841        customizer = (assigner.length > 3 && typeof customizer == 'function')
4842          ? (length--, customizer)
4843          : undefined;
4844
4845        if (guard && isIterateeCall(sources[0], sources[1], guard)) {
4846          customizer = length < 3 ? undefined : customizer;
4847          length = 1;
4848        }
4849        object = Object(object);
4850        while (++index < length) {
4851          var source = sources[index];
4852          if (source) {
4853            assigner(object, source, index, customizer);
4854          }
4855        }
4856        return object;
4857      });
4858    }
4859
4860    /**
4861     * Creates a `baseEach` or `baseEachRight` function.
4862     *
4863     * @private
4864     * @param {Function} eachFunc The function to iterate over a collection.
4865     * @param {boolean} [fromRight] Specify iterating from right to left.
4866     * @returns {Function} Returns the new base function.
4867     */
4868    function createBaseEach(eachFunc, fromRight) {
4869      return function(collection, iteratee) {
4870        if (collection == null) {
4871          return collection;
4872        }
4873        if (!isArrayLike(collection)) {
4874          return eachFunc(collection, iteratee);
4875        }
4876        var length = collection.length,
4877            index = fromRight ? length : -1,
4878            iterable = Object(collection);
4879
4880        while ((fromRight ? index-- : ++index < length)) {
4881          if (iteratee(iterable[index], index, iterable) === false) {
4882            break;
4883          }
4884        }
4885        return collection;
4886      };
4887    }
4888
4889    /**
4890     * Creates a base function for methods like `_.forIn` and `_.forOwn`.
4891     *
4892     * @private
4893     * @param {boolean} [fromRight] Specify iterating from right to left.
4894     * @returns {Function} Returns the new base function.
4895     */
4896    function createBaseFor(fromRight) {
4897      return function(object, iteratee, keysFunc) {
4898        var index = -1,
4899            iterable = Object(object),
4900            props = keysFunc(object),
4901            length = props.length;
4902
4903        while (length--) {
4904          var key = props[fromRight ? length : ++index];
4905          if (iteratee(iterable[key], key, iterable) === false) {
4906            break;
4907          }
4908        }
4909        return object;
4910      };
4911    }
4912
4913    /**
4914     * Creates a function that wraps `func` to invoke it with the optional `this`
4915     * binding of `thisArg`.
4916     *
4917     * @private
4918     * @param {Function} func The function to wrap.
4919     * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
4920     * @param {*} [thisArg] The `this` binding of `func`.
4921     * @returns {Function} Returns the new wrapped function.
4922     */
4923    function createBind(func, bitmask, thisArg) {
4924      var isBind = bitmask & WRAP_BIND_FLAG,
4925          Ctor = createCtor(func);
4926
4927      function wrapper() {
4928        var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4929        return fn.apply(isBind ? thisArg : this, arguments);
4930      }
4931      return wrapper;
4932    }
4933
4934    /**
4935     * Creates a function like `_.lowerFirst`.
4936     *
4937     * @private
4938     * @param {string} methodName The name of the `String` case method to use.
4939     * @returns {Function} Returns the new case function.
4940     */
4941    function createCaseFirst(methodName) {
4942      return function(string) {
4943        string = toString(string);
4944
4945        var strSymbols = hasUnicode(string)
4946          ? stringToArray(string)
4947          : undefined;
4948
4949        var chr = strSymbols
4950          ? strSymbols[0]
4951          : string.charAt(0);
4952
4953        var trailing = strSymbols
4954          ? castSlice(strSymbols, 1).join('')
4955          : string.slice(1);
4956
4957        return chr[methodName]() + trailing;
4958      };
4959    }
4960
4961    /**
4962     * Creates a function like `_.camelCase`.
4963     *
4964     * @private
4965     * @param {Function} callback The function to combine each word.
4966     * @returns {Function} Returns the new compounder function.
4967     */
4968    function createCompounder(callback) {
4969      return function(string) {
4970        return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
4971      };
4972    }
4973
4974    /**
4975     * Creates a function that produces an instance of `Ctor` regardless of
4976     * whether it was invoked as part of a `new` expression or by `call` or `apply`.
4977     *
4978     * @private
4979     * @param {Function} Ctor The constructor to wrap.
4980     * @returns {Function} Returns the new wrapped function.
4981     */
4982    function createCtor(Ctor) {
4983      return function() {
4984        // Use a `switch` statement to work with class constructors. See
4985        // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
4986        // for more details.
4987        var args = arguments;
4988        switch (args.length) {
4989          case 0: return new Ctor;
4990          case 1: return new Ctor(args[0]);
4991          case 2: return new Ctor(args[0], args[1]);
4992          case 3: return new Ctor(args[0], args[1], args[2]);
4993          case 4: return new Ctor(args[0], args[1], args[2], args[3]);
4994          case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
4995          case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
4996          case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
4997        }
4998        var thisBinding = baseCreate(Ctor.prototype),
4999            result = Ctor.apply(thisBinding, args);
5000
5001        // Mimic the constructor's `return` behavior.
5002        // See https://es5.github.io/#x13.2.2 for more details.
5003        return isObject(result) ? result : thisBinding;
5004      };
5005    }
5006
5007    /**
5008     * Creates a function that wraps `func` to enable currying.
5009     *
5010     * @private
5011     * @param {Function} func The function to wrap.
5012     * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5013     * @param {number} arity The arity of `func`.
5014     * @returns {Function} Returns the new wrapped function.
5015     */
5016    function createCurry(func, bitmask, arity) {
5017      var Ctor = createCtor(func);
5018
5019      function wrapper() {
5020        var length = arguments.length,
5021            args = Array(length),
5022            index = length,
5023            placeholder = getHolder(wrapper);
5024
5025        while (index--) {
5026          args[index] = arguments[index];
5027        }
5028        var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5029          ? []
5030          : replaceHolders(args, placeholder);
5031
5032        length -= holders.length;
5033        if (length < arity) {
5034          return createRecurry(
5035            func, bitmask, createHybrid, wrapper.placeholder, undefined,
5036            args, holders, undefined, undefined, arity - length);
5037        }
5038        var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5039        return apply(fn, this, args);
5040      }
5041      return wrapper;
5042    }
5043
5044    /**
5045     * Creates a `_.find` or `_.findLast` function.
5046     *
5047     * @private
5048     * @param {Function} findIndexFunc The function to find the collection index.
5049     * @returns {Function} Returns the new find function.
5050     */
5051    function createFind(findIndexFunc) {
5052      return function(collection, predicate, fromIndex) {
5053        var iterable = Object(collection);
5054        if (!isArrayLike(collection)) {
5055          var iteratee = getIteratee(predicate, 3);
5056          collection = keys(collection);
5057          predicate = function(key) { return iteratee(iterable[key], key, iterable); };
5058        }
5059        var index = findIndexFunc(collection, predicate, fromIndex);
5060        return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
5061      };
5062    }
5063
5064    /**
5065     * Creates a `_.flow` or `_.flowRight` function.
5066     *
5067     * @private
5068     * @param {boolean} [fromRight] Specify iterating from right to left.
5069     * @returns {Function} Returns the new flow function.
5070     */
5071    function createFlow(fromRight) {
5072      return flatRest(function(funcs) {
5073        var length = funcs.length,
5074            index = length,
5075            prereq = LodashWrapper.prototype.thru;
5076
5077        if (fromRight) {
5078          funcs.reverse();
5079        }
5080        while (index--) {
5081          var func = funcs[index];
5082          if (typeof func != 'function') {
5083            throw new TypeError(FUNC_ERROR_TEXT);
5084          }
5085          if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5086            var wrapper = new LodashWrapper([], true);
5087          }
5088        }
5089        index = wrapper ? index : length;
5090        while (++index < length) {
5091          func = funcs[index];
5092
5093          var funcName = getFuncName(func),
5094              data = funcName == 'wrapper' ? getData(func) : undefined;
5095
5096          if (data && isLaziable(data[0]) &&
5097                data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
5098                !data[4].length && data[9] == 1
5099              ) {
5100            wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5101          } else {
5102            wrapper = (func.length == 1 && isLaziable(func))
5103              ? wrapper[funcName]()
5104              : wrapper.thru(func);
5105          }
5106        }
5107        return function() {
5108          var args = arguments,
5109              value = args[0];
5110
5111          if (wrapper && args.length == 1 && isArray(value)) {
5112            return wrapper.plant(value).value();
5113          }
5114          var index = 0,
5115              result = length ? funcs[index].apply(this, args) : value;
5116
5117          while (++index < length) {
5118            result = funcs[index].call(this, result);
5119          }
5120          return result;
5121        };
5122      });
5123    }
5124
5125    /**
5126     * Creates a function that wraps `func` to invoke it with optional `this`
5127     * binding of `thisArg`, partial application, and currying.
5128     *
5129     * @private
5130     * @param {Function|string} func The function or method name to wrap.
5131     * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5132     * @param {*} [thisArg] The `this` binding of `func`.
5133     * @param {Array} [partials] The arguments to prepend to those provided to
5134     *  the new function.
5135     * @param {Array} [holders] The `partials` placeholder indexes.
5136     * @param {Array} [partialsRight] The arguments to append to those provided
5137     *  to the new function.
5138     * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
5139     * @param {Array} [argPos] The argument positions of the new function.
5140     * @param {number} [ary] The arity cap of `func`.
5141     * @param {number} [arity] The arity of `func`.
5142     * @returns {Function} Returns the new wrapped function.
5143     */
5144    function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5145      var isAry = bitmask & WRAP_ARY_FLAG,
5146          isBind = bitmask & WRAP_BIND_FLAG,
5147          isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
5148          isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
5149          isFlip = bitmask & WRAP_FLIP_FLAG,
5150          Ctor = isBindKey ? undefined : createCtor(func);
5151
5152      function wrapper() {
5153        var length = arguments.length,
5154            args = Array(length),
5155            index = length;
5156
5157        while (index--) {
5158          args[index] = arguments[index];
5159        }
5160        if (isCurried) {
5161          var placeholder = getHolder(wrapper),
5162              holdersCount = countHolders(args, placeholder);
5163        }
5164        if (partials) {
5165          args = composeArgs(args, partials, holders, isCurried);
5166        }
5167        if (partialsRight) {
5168          args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
5169        }
5170        length -= holdersCount;
5171        if (isCurried && length < arity) {
5172          var newHolders = replaceHolders(args, placeholder);
5173          return createRecurry(
5174            func, bitmask, createHybrid, wrapper.placeholder, thisArg,
5175            args, newHolders, argPos, ary, arity - length
5176          );
5177        }
5178        var thisBinding = isBind ? thisArg : this,
5179            fn = isBindKey ? thisBinding[func] : func;
5180
5181        length = args.length;
5182        if (argPos) {
5183          args = reorder(args, argPos);
5184        } else if (isFlip && length > 1) {
5185          args.reverse();
5186        }
5187        if (isAry && ary < length) {
5188          args.length = ary;
5189        }
5190        if (this && this !== root && this instanceof wrapper) {
5191          fn = Ctor || createCtor(fn);
5192        }
5193        return fn.apply(thisBinding, args);
5194      }
5195      return wrapper;
5196    }
5197
5198    /**
5199     * Creates a function like `_.invertBy`.
5200     *
5201     * @private
5202     * @param {Function} setter The function to set accumulator values.
5203     * @param {Function} toIteratee The function to resolve iteratees.
5204     * @returns {Function} Returns the new inverter function.
5205     */
5206    function createInverter(setter, toIteratee) {
5207      return function(object, iteratee) {
5208        return baseInverter(object, setter, toIteratee(iteratee), {});
5209      };
5210    }
5211
5212    /**
5213     * Creates a function that performs a mathematical operation on two values.
5214     *
5215     * @private
5216     * @param {Function} operator The function to perform the operation.
5217     * @param {number} [defaultValue] The value used for `undefined` arguments.
5218     * @returns {Function} Returns the new mathematical operation function.
5219     */
5220    function createMathOperation(operator, defaultValue) {
5221      return function(value, other) {
5222        var result;
5223        if (value === undefined && other === undefined) {
5224          return defaultValue;
5225        }
5226        if (value !== undefined) {
5227          result = value;
5228        }
5229        if (other !== undefined) {
5230          if (result === undefined) {
5231            return other;
5232          }
5233          if (typeof value == 'string' || typeof other == 'string') {
5234            value = baseToString(value);
5235            other = baseToString(other);
5236          } else {
5237            value = baseToNumber(value);
5238            other = baseToNumber(other);
5239          }
5240          result = operator(value, other);
5241        }
5242        return result;
5243      };
5244    }
5245
5246    /**
5247     * Creates a function like `_.over`.
5248     *
5249     * @private
5250     * @param {Function} arrayFunc The function to iterate over iteratees.
5251     * @returns {Function} Returns the new over function.
5252     */
5253    function createOver(arrayFunc) {
5254      return flatRest(function(iteratees) {
5255        iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5256        return baseRest(function(args) {
5257          var thisArg = this;
5258          return arrayFunc(iteratees, function(iteratee) {
5259            return apply(iteratee, thisArg, args);
5260          });
5261        });
5262      });
5263    }
5264
5265    /**
5266     * Creates the padding for `string` based on `length`. The `chars` string
5267     * is truncated if the number of characters exceeds `length`.
5268     *
5269     * @private
5270     * @param {number} length The padding length.
5271     * @param {string} [chars=' '] The string used as padding.
5272     * @returns {string} Returns the padding for `string`.
5273     */
5274    function createPadding(length, chars) {
5275      chars = chars === undefined ? ' ' : baseToString(chars);
5276
5277      var charsLength = chars.length;
5278      if (charsLength < 2) {
5279        return charsLength ? baseRepeat(chars, length) : chars;
5280      }
5281      var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
5282      return hasUnicode(chars)
5283        ? castSlice(stringToArray(result), 0, length).join('')
5284        : result.slice(0, length);
5285    }
5286
5287    /**
5288     * Creates a function that wraps `func` to invoke it with the `this` binding
5289     * of `thisArg` and `partials` prepended to the arguments it receives.
5290     *
5291     * @private
5292     * @param {Function} func The function to wrap.
5293     * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5294     * @param {*} thisArg The `this` binding of `func`.
5295     * @param {Array} partials The arguments to prepend to those provided to
5296     *  the new function.
5297     * @returns {Function} Returns the new wrapped function.
5298     */
5299    function createPartial(func, bitmask, thisArg, partials) {
5300      var isBind = bitmask & WRAP_BIND_FLAG,
5301          Ctor = createCtor(func);
5302
5303      function wrapper() {
5304        var argsIndex = -1,
5305            argsLength = arguments.length,
5306            leftIndex = -1,
5307            leftLength = partials.length,
5308            args = Array(leftLength + argsLength),
5309            fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5310
5311        while (++leftIndex < leftLength) {
5312          args[leftIndex] = partials[leftIndex];
5313        }
5314        while (argsLength--) {
5315          args[leftIndex++] = arguments[++argsIndex];
5316        }
5317        return apply(fn, isBind ? thisArg : this, args);
5318      }
5319      return wrapper;
5320    }
5321
5322    /**
5323     * Creates a `_.range` or `_.rangeRight` function.
5324     *
5325     * @private
5326     * @param {boolean} [fromRight] Specify iterating from right to left.
5327     * @returns {Function} Returns the new range function.
5328     */
5329    function createRange(fromRight) {
5330      return function(start, end, step) {
5331        if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5332          end = step = undefined;
5333        }
5334        // Ensure the sign of `-0` is preserved.
5335        start = toFinite(start);
5336        if (end === undefined) {
5337          end = start;
5338          start = 0;
5339        } else {
5340          end = toFinite(end);
5341        }
5342        step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
5343        return baseRange(start, end, step, fromRight);
5344      };
5345    }
5346
5347    /**
5348     * Creates a function that performs a relational operation on two values.
5349     *
5350     * @private
5351     * @param {Function} operator The function to perform the operation.
5352     * @returns {Function} Returns the new relational operation function.
5353     */
5354    function createRelationalOperation(operator) {
5355      return function(value, other) {
5356        if (!(typeof value == 'string' && typeof other == 'string')) {
5357          value = toNumber(value);
5358          other = toNumber(other);
5359        }
5360        return operator(value, other);
5361      };
5362    }
5363
5364    /**
5365     * Creates a function that wraps `func` to continue currying.
5366     *
5367     * @private
5368     * @param {Function} func The function to wrap.
5369     * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5370     * @param {Function} wrapFunc The function to create the `func` wrapper.
5371     * @param {*} placeholder The placeholder value.
5372     * @param {*} [thisArg] The `this` binding of `func`.
5373     * @param {Array} [partials] The arguments to prepend to those provided to
5374     *  the new function.
5375     * @param {Array} [holders] The `partials` placeholder indexes.
5376     * @param {Array} [argPos] The argument positions of the new function.
5377     * @param {number} [ary] The arity cap of `func`.
5378     * @param {number} [arity] The arity of `func`.
5379     * @returns {Function} Returns the new wrapped function.
5380     */
5381    function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
5382      var isCurry = bitmask & WRAP_CURRY_FLAG,
5383          newHolders = isCurry ? holders : undefined,
5384          newHoldersRight = isCurry ? undefined : holders,
5385          newPartials = isCurry ? partials : undefined,
5386          newPartialsRight = isCurry ? undefined : partials;
5387
5388      bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
5389      bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
5390
5391      if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
5392        bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
5393      }
5394      var newData = [
5395        func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5396        newHoldersRight, argPos, ary, arity
5397      ];
5398
5399      var result = wrapFunc.apply(undefined, newData);
5400      if (isLaziable(func)) {
5401        setData(result, newData);
5402      }
5403      result.placeholder = placeholder;
5404      return setWrapToString(result, func, bitmask);
5405    }
5406
5407    /**
5408     * Creates a function like `_.round`.
5409     *
5410     * @private
5411     * @param {string} methodName The name of the `Math` method to use when rounding.
5412     * @returns {Function} Returns the new round function.
5413     */
5414    function createRound(methodName) {
5415      var func = Math[methodName];
5416      return function(number, precision) {
5417        number = toNumber(number);
5418        precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
5419        if (precision && nativeIsFinite(number)) {
5420          // Shift with exponential notation to avoid floating-point issues.
5421          // See [MDN](https://mdn.io/round#Examples) for more details.
5422          var pair = (toString(number) + 'e').split('e'),
5423              value = func(pair[0] + 'e' + (+pair[1] + precision));
5424
5425          pair = (toString(value) + 'e').split('e');
5426          return +(pair[0] + 'e' + (+pair[1] - precision));
5427        }
5428        return func(number);
5429      };
5430    }
5431
5432    /**
5433     * Creates a set object of `values`.
5434     *
5435     * @private
5436     * @param {Array} values The values to add to the set.
5437     * @returns {Object} Returns the new set.
5438     */
5439    var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
5440      return new Set(values);
5441    };
5442
5443    /**
5444     * Creates a `_.toPairs` or `_.toPairsIn` function.
5445     *
5446     * @private
5447     * @param {Function} keysFunc The function to get the keys of a given object.
5448     * @returns {Function} Returns the new pairs function.
5449     */
5450    function createToPairs(keysFunc) {
5451      return function(object) {
5452        var tag = getTag(object);
5453        if (tag == mapTag) {
5454          return mapToArray(object);
5455        }
5456        if (tag == setTag) {
5457          return setToPairs(object);
5458        }
5459        return baseToPairs(object, keysFunc(object));
5460      };
5461    }
5462
5463    /**
5464     * Creates a function that either curries or invokes `func` with optional
5465     * `this` binding and partially applied arguments.
5466     *
5467     * @private
5468     * @param {Function|string} func The function or method name to wrap.
5469     * @param {number} bitmask The bitmask flags.
5470     *    1 - `_.bind`
5471     *    2 - `_.bindKey`
5472     *    4 - `_.curry` or `_.curryRight` of a bound function
5473     *    8 - `_.curry`
5474     *   16 - `_.curryRight`
5475     *   32 - `_.partial`
5476     *   64 - `_.partialRight`
5477     *  128 - `_.rearg`
5478     *  256 - `_.ary`
5479     *  512 - `_.flip`
5480     * @param {*} [thisArg] The `this` binding of `func`.
5481     * @param {Array} [partials] The arguments to be partially applied.
5482     * @param {Array} [holders] The `partials` placeholder indexes.
5483     * @param {Array} [argPos] The argument positions of the new function.
5484     * @param {number} [ary] The arity cap of `func`.
5485     * @param {number} [arity] The arity of `func`.
5486     * @returns {Function} Returns the new wrapped function.
5487     */
5488    function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5489      var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
5490      if (!isBindKey && typeof func != 'function') {
5491        throw new TypeError(FUNC_ERROR_TEXT);
5492      }
5493      var length = partials ? partials.length : 0;
5494      if (!length) {
5495        bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
5496        partials = holders = undefined;
5497      }
5498      ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
5499      arity = arity === undefined ? arity : toInteger(arity);
5500      length -= holders ? holders.length : 0;
5501
5502      if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
5503        var partialsRight = partials,
5504            holdersRight = holders;
5505
5506        partials = holders = undefined;
5507      }
5508      var data = isBindKey ? undefined : getData(func);
5509
5510      var newData = [
5511        func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5512        argPos, ary, arity
5513      ];
5514
5515      if (data) {
5516        mergeData(newData, data);
5517      }
5518      func = newData[0];
5519      bitmask = newData[1];
5520      thisArg = newData[2];
5521      partials = newData[3];
5522      holders = newData[4];
5523      arity = newData[9] = newData[9] === undefined
5524        ? (isBindKey ? 0 : func.length)
5525        : nativeMax(newData[9] - length, 0);
5526
5527      if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
5528        bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
5529      }
5530      if (!bitmask || bitmask == WRAP_BIND_FLAG) {
5531        var result = createBind(func, bitmask, thisArg);
5532      } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
5533        result = createCurry(func, bitmask, arity);
5534      } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
5535        result = createPartial(func, bitmask, thisArg, partials);
5536      } else {
5537        result = createHybrid.apply(undefined, newData);
5538      }
5539      var setter = data ? baseSetData : setData;
5540      return setWrapToString(setter(result, newData), func, bitmask);
5541    }
5542
5543    /**
5544     * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
5545     * of source objects to the destination object for all destination properties
5546     * that resolve to `undefined`.
5547     *
5548     * @private
5549     * @param {*} objValue The destination value.
5550     * @param {*} srcValue The source value.
5551     * @param {string} key The key of the property to assign.
5552     * @param {Object} object The parent object of `objValue`.
5553     * @returns {*} Returns the value to assign.
5554     */
5555    function customDefaultsAssignIn(objValue, srcValue, key, object) {
5556      if (objValue === undefined ||
5557          (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
5558        return srcValue;
5559      }
5560      return objValue;
5561    }
5562
5563    /**
5564     * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
5565     * objects into destination objects that are passed thru.
5566     *
5567     * @private
5568     * @param {*} objValue The destination value.
5569     * @param {*} srcValue The source value.
5570     * @param {string} key The key of the property to merge.
5571     * @param {Object} object The parent object of `objValue`.
5572     * @param {Object} source The parent object of `srcValue`.
5573     * @param {Object} [stack] Tracks traversed source values and their merged
5574     *  counterparts.
5575     * @returns {*} Returns the value to assign.
5576     */
5577    function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
5578      if (isObject(objValue) && isObject(srcValue)) {
5579        // Recursively merge objects and arrays (susceptible to call stack limits).
5580        stack.set(srcValue, objValue);
5581        baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
5582        stack['delete'](srcValue);
5583      }
5584      return objValue;
5585    }
5586
5587    /**
5588     * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
5589     * objects.
5590     *
5591     * @private
5592     * @param {*} value The value to inspect.
5593     * @param {string} key The key of the property to inspect.
5594     * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
5595     */
5596    function customOmitClone(value) {
5597      return isPlainObject(value) ? undefined : value;
5598    }
5599
5600    /**
5601     * A specialized version of `baseIsEqualDeep` for arrays with support for
5602     * partial deep comparisons.
5603     *
5604     * @private
5605     * @param {Array} array The array to compare.
5606     * @param {Array} other The other array to compare.
5607     * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5608     * @param {Function} customizer The function to customize comparisons.
5609     * @param {Function} equalFunc The function to determine equivalents of values.
5610     * @param {Object} stack Tracks traversed `array` and `other` objects.
5611     * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
5612     */
5613    function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
5614      var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5615          arrLength = array.length,
5616          othLength = other.length;
5617
5618      if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5619        return false;
5620      }
5621      // Assume cyclic values are equal.
5622      var stacked = stack.get(array);
5623      if (stacked && stack.get(other)) {
5624        return stacked == other;
5625      }
5626      var index = -1,
5627          result = true,
5628          seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
5629
5630      stack.set(array, other);
5631      stack.set(other, array);
5632
5633      // Ignore non-index properties.
5634      while (++index < arrLength) {
5635        var arrValue = array[index],
5636            othValue = other[index];
5637
5638        if (customizer) {
5639          var compared = isPartial
5640            ? customizer(othValue, arrValue, index, other, array, stack)
5641            : customizer(arrValue, othValue, index, array, other, stack);
5642        }
5643        if (compared !== undefined) {
5644          if (compared) {
5645            continue;
5646          }
5647          result = false;
5648          break;
5649        }
5650        // Recursively compare arrays (susceptible to call stack limits).
5651        if (seen) {
5652          if (!arraySome(other, function(othValue, othIndex) {
5653                if (!cacheHas(seen, othIndex) &&
5654                    (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
5655                  return seen.push(othIndex);
5656                }
5657              })) {
5658            result = false;
5659            break;
5660          }
5661        } else if (!(
5662              arrValue === othValue ||
5663                equalFunc(arrValue, othValue, bitmask, customizer, stack)
5664            )) {
5665          result = false;
5666          break;
5667        }
5668      }
5669      stack['delete'](array);
5670      stack['delete'](other);
5671      return result;
5672    }
5673
5674    /**
5675     * A specialized version of `baseIsEqualDeep` for comparing objects of
5676     * the same `toStringTag`.
5677     *
5678     * **Note:** This function only supports comparing values with tags of
5679     * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5680     *
5681     * @private
5682     * @param {Object} object The object to compare.
5683     * @param {Object} other The other object to compare.
5684     * @param {string} tag The `toStringTag` of the objects to compare.
5685     * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5686     * @param {Function} customizer The function to customize comparisons.
5687     * @param {Function} equalFunc The function to determine equivalents of values.
5688     * @param {Object} stack Tracks traversed `object` and `other` objects.
5689     * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5690     */
5691    function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
5692      switch (tag) {
5693        case dataViewTag:
5694          if ((object.byteLength != other.byteLength) ||
5695              (object.byteOffset != other.byteOffset)) {
5696            return false;
5697          }
5698          object = object.buffer;
5699          other = other.buffer;
5700
5701        case arrayBufferTag:
5702          if ((object.byteLength != other.byteLength) ||
5703              !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5704            return false;
5705          }
5706          return true;
5707
5708        case boolTag:
5709        case dateTag:
5710        case numberTag:
5711          // Coerce booleans to `1` or `0` and dates to milliseconds.
5712          // Invalid dates are coerced to `NaN`.
5713          return eq(+object, +other);
5714
5715        case errorTag:
5716          return object.name == other.name && object.message == other.message;
5717
5718        case regexpTag:
5719        case stringTag:
5720          // Coerce regexes to strings and treat strings, primitives and objects,
5721          // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
5722          // for more details.
5723          return object == (other + '');
5724
5725        case mapTag:
5726          var convert = mapToArray;
5727
5728        case setTag:
5729          var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
5730          convert || (convert = setToArray);
5731
5732          if (object.size != other.size && !isPartial) {
5733            return false;
5734          }
5735          // Assume cyclic values are equal.
5736          var stacked = stack.get(object);
5737          if (stacked) {
5738            return stacked == other;
5739          }
5740          bitmask |= COMPARE_UNORDERED_FLAG;
5741
5742          // Recursively compare objects (susceptible to call stack limits).
5743          stack.set(object, other);
5744          var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
5745          stack['delete'](object);
5746          return result;
5747
5748        case symbolTag:
5749          if (symbolValueOf) {
5750            return symbolValueOf.call(object) == symbolValueOf.call(other);
5751          }
5752      }
5753      return false;
5754    }
5755
5756    /**
5757     * A specialized version of `baseIsEqualDeep` for objects with support for
5758     * partial deep comparisons.
5759     *
5760     * @private
5761     * @param {Object} object The object to compare.
5762     * @param {Object} other The other object to compare.
5763     * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5764     * @param {Function} customizer The function to customize comparisons.
5765     * @param {Function} equalFunc The function to determine equivalents of values.
5766     * @param {Object} stack Tracks traversed `object` and `other` objects.
5767     * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5768     */
5769    function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
5770      var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5771          objProps = getAllKeys(object),
5772          objLength = objProps.length,
5773          othProps = getAllKeys(other),
5774          othLength = othProps.length;
5775
5776      if (objLength != othLength && !isPartial) {
5777        return false;
5778      }
5779      var index = objLength;
5780      while (index--) {
5781        var key = objProps[index];
5782        if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
5783          return false;
5784        }
5785      }
5786      // Assume cyclic values are equal.
5787      var stacked = stack.get(object);
5788      if (stacked && stack.get(other)) {
5789        return stacked == other;
5790      }
5791      var result = true;
5792      stack.set(object, other);
5793      stack.set(other, object);
5794
5795      var skipCtor = isPartial;
5796      while (++index < objLength) {
5797        key = objProps[index];
5798        var objValue = object[key],
5799            othValue = other[key];
5800
5801        if (customizer) {
5802          var compared = isPartial
5803            ? customizer(othValue, objValue, key, other, object, stack)
5804            : customizer(objValue, othValue, key, object, other, stack);
5805        }
5806        // Recursively compare objects (susceptible to call stack limits).
5807        if (!(compared === undefined
5808              ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
5809              : compared
5810            )) {
5811          result = false;
5812          break;
5813        }
5814        skipCtor || (skipCtor = key == 'constructor');
5815      }
5816      if (result && !skipCtor) {
5817        var objCtor = object.constructor,
5818            othCtor = other.constructor;
5819
5820        // Non `Object` object instances with different constructors are not equal.
5821        if (objCtor != othCtor &&
5822            ('constructor' in object && 'constructor' in other) &&
5823            !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
5824              typeof othCtor == 'function' && othCtor instanceof othCtor)) {
5825          result = false;
5826        }
5827      }
5828      stack['delete'](object);
5829      stack['delete'](other);
5830      return result;
5831    }
5832
5833    /**
5834     * A specialized version of `baseRest` which flattens the rest array.
5835     *
5836     * @private
5837     * @param {Function} func The function to apply a rest parameter to.
5838     * @returns {Function} Returns the new function.
5839     */
5840    function flatRest(func) {
5841      return setToString(overRest(func, undefined, flatten), func + '');
5842    }
5843
5844    /**
5845     * Creates an array of own enumerable property names and symbols of `object`.
5846     *
5847     * @private
5848     * @param {Object} object The object to query.
5849     * @returns {Array} Returns the array of property names and symbols.
5850     */
5851    function getAllKeys(object) {
5852      return baseGetAllKeys(object, keys, getSymbols);
5853    }
5854
5855    /**
5856     * Creates an array of own and inherited enumerable property names and
5857     * symbols of `object`.
5858     *
5859     * @private
5860     * @param {Object} object The object to query.
5861     * @returns {Array} Returns the array of property names and symbols.
5862     */
5863    function getAllKeysIn(object) {
5864      return baseGetAllKeys(object, keysIn, getSymbolsIn);
5865    }
5866
5867    /**
5868     * Gets metadata for `func`.
5869     *
5870     * @private
5871     * @param {Function} func The function to query.
5872     * @returns {*} Returns the metadata for `func`.
5873     */
5874    var getData = !metaMap ? noop : function(func) {
5875      return metaMap.get(func);
5876    };
5877
5878    /**
5879     * Gets the name of `func`.
5880     *
5881     * @private
5882     * @param {Function} func The function to query.
5883     * @returns {string} Returns the function name.
5884     */
5885    function getFuncName(func) {
5886      var result = (func.name + ''),
5887          array = realNames[result],
5888          length = hasOwnProperty.call(realNames, result) ? array.length : 0;
5889
5890      while (length--) {
5891        var data = array[length],
5892            otherFunc = data.func;
5893        if (otherFunc == null || otherFunc == func) {
5894          return data.name;
5895        }
5896      }
5897      return result;
5898    }
5899
5900    /**
5901     * Gets the argument placeholder value for `func`.
5902     *
5903     * @private
5904     * @param {Function} func The function to inspect.
5905     * @returns {*} Returns the placeholder value.
5906     */
5907    function getHolder(func) {
5908      var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
5909      return object.placeholder;
5910    }
5911
5912    /**
5913     * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
5914     * this function returns the custom method, otherwise it returns `baseIteratee`.
5915     * If arguments are provided, the chosen function is invoked with them and
5916     * its result is returned.
5917     *
5918     * @private
5919     * @param {*} [value] The value to convert to an iteratee.
5920     * @param {number} [arity] The arity of the created iteratee.
5921     * @returns {Function} Returns the chosen function or its result.
5922     */
5923    function getIteratee() {
5924      var result = lodash.iteratee || iteratee;
5925      result = result === iteratee ? baseIteratee : result;
5926      return arguments.length ? result(arguments[0], arguments[1]) : result;
5927    }
5928
5929    /**
5930     * Gets the data for `map`.
5931     *
5932     * @private
5933     * @param {Object} map The map to query.
5934     * @param {string} key The reference key.
5935     * @returns {*} Returns the map data.
5936     */
5937    function getMapData(map, key) {
5938      var data = map.__data__;
5939      return isKeyable(key)
5940        ? data[typeof key == 'string' ? 'string' : 'hash']
5941        : data.map;
5942    }
5943
5944    /**
5945     * Gets the property names, values, and compare flags of `object`.
5946     *
5947     * @private
5948     * @param {Object} object The object to query.
5949     * @returns {Array} Returns the match data of `object`.
5950     */
5951    function getMatchData(object) {
5952      var result = keys(object),
5953          length = result.length;
5954
5955      while (length--) {
5956        var key = result[length],
5957            value = object[key];
5958
5959        result[length] = [key, value, isStrictComparable(value)];
5960      }
5961      return result;
5962    }
5963
5964    /**
5965     * Gets the native function at `key` of `object`.
5966     *
5967     * @private
5968     * @param {Object} object The object to query.
5969     * @param {string} key The key of the method to get.
5970     * @returns {*} Returns the function if it's native, else `undefined`.
5971     */
5972    function getNative(object, key) {
5973      var value = getValue(object, key);
5974      return baseIsNative(value) ? value : undefined;
5975    }
5976
5977    /**
5978     * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
5979     *
5980     * @private
5981     * @param {*} value The value to query.
5982     * @returns {string} Returns the raw `toStringTag`.
5983     */
5984    function getRawTag(value) {
5985      var isOwn = hasOwnProperty.call(value, symToStringTag),
5986          tag = value[symToStringTag];
5987
5988      try {
5989        value[symToStringTag] = undefined;
5990        var unmasked = true;
5991      } catch (e) {}
5992
5993      var result = nativeObjectToString.call(value);
5994      if (unmasked) {
5995        if (isOwn) {
5996          value[symToStringTag] = tag;
5997        } else {
5998          delete value[symToStringTag];
5999        }
6000      }
6001      return result;
6002    }
6003
6004    /**
6005     * Creates an array of the own enumerable symbols of `object`.
6006     *
6007     * @private
6008     * @param {Object} object The object to query.
6009     * @returns {Array} Returns the array of symbols.
6010     */
6011    var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
6012      if (object == null) {
6013        return [];
6014      }
6015      object = Object(object);
6016      return arrayFilter(nativeGetSymbols(object), function(symbol) {
6017        return propertyIsEnumerable.call(object, symbol);
6018      });
6019    };
6020
6021    /**
6022     * Creates an array of the own and inherited enumerable symbols of `object`.
6023     *
6024     * @private
6025     * @param {Object} object The object to query.
6026     * @returns {Array} Returns the array of symbols.
6027     */
6028    var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6029      var result = [];
6030      while (object) {
6031        arrayPush(result, getSymbols(object));
6032        object = getPrototype(object);
6033      }
6034      return result;
6035    };
6036
6037    /**
6038     * Gets the `toStringTag` of `value`.
6039     *
6040     * @private
6041     * @param {*} value The value to query.
6042     * @returns {string} Returns the `toStringTag`.
6043     */
6044    var getTag = baseGetTag;
6045
6046    // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
6047    if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
6048        (Map && getTag(new Map) != mapTag) ||
6049        (Promise && getTag(Promise.resolve()) != promiseTag) ||
6050        (Set && getTag(new Set) != setTag) ||
6051        (WeakMap && getTag(new WeakMap) != weakMapTag)) {
6052      getTag = function(value) {
6053        var result = baseGetTag(value),
6054            Ctor = result == objectTag ? value.constructor : undefined,
6055            ctorString = Ctor ? toSource(Ctor) : '';
6056
6057        if (ctorString) {
6058          switch (ctorString) {
6059            case dataViewCtorString: return dataViewTag;
6060            case mapCtorString: return mapTag;
6061            case promiseCtorString: return promiseTag;
6062            case setCtorString: return setTag;
6063            case weakMapCtorString: return weakMapTag;
6064          }
6065        }
6066        return result;
6067      };
6068    }
6069
6070    /**
6071     * Gets the view, applying any `transforms` to the `start` and `end` positions.
6072     *
6073     * @private
6074     * @param {number} start The start of the view.
6075     * @param {number} end The end of the view.
6076     * @param {Array} transforms The transformations to apply to the view.
6077     * @returns {Object} Returns an object containing the `start` and `end`
6078     *  positions of the view.
6079     */
6080    function getView(start, end, transforms) {
6081      var index = -1,
6082          length = transforms.length;
6083
6084      while (++index < length) {
6085        var data = transforms[index],
6086            size = data.size;
6087
6088        switch (data.type) {
6089          case 'drop':      start += size; break;
6090          case 'dropRight': end -= size; break;
6091          case 'take':      end = nativeMin(end, start + size); break;
6092          case 'takeRight': start = nativeMax(start, end - size); break;
6093        }
6094      }
6095      return { 'start': start, 'end': end };
6096    }
6097
6098    /**
6099     * Extracts wrapper details from the `source` body comment.
6100     *
6101     * @private
6102     * @param {string} source The source to inspect.
6103     * @returns {Array} Returns the wrapper details.
6104     */
6105    function getWrapDetails(source) {
6106      var match = source.match(reWrapDetails);
6107      return match ? match[1].split(reSplitDetails) : [];
6108    }
6109
6110    /**
6111     * Checks if `path` exists on `object`.
6112     *
6113     * @private
6114     * @param {Object} object The object to query.
6115     * @param {Array|string} path The path to check.
6116     * @param {Function} hasFunc The function to check properties.
6117     * @returns {boolean} Returns `true` if `path` exists, else `false`.
6118     */
6119    function hasPath(object, path, hasFunc) {
6120      path = castPath(path, object);
6121
6122      var index = -1,
6123          length = path.length,
6124          result = false;
6125
6126      while (++index < length) {
6127        var key = toKey(path[index]);
6128        if (!(result = object != null && hasFunc(object, key))) {
6129          break;
6130        }
6131        object = object[key];
6132      }
6133      if (result || ++index != length) {
6134        return result;
6135      }
6136      length = object == null ? 0 : object.length;
6137      return !!length && isLength(length) && isIndex(key, length) &&
6138        (isArray(object) || isArguments(object));
6139    }
6140
6141    /**
6142     * Initializes an array clone.
6143     *
6144     * @private
6145     * @param {Array} array The array to clone.
6146     * @returns {Array} Returns the initialized clone.
6147     */
6148    function initCloneArray(array) {
6149      var length = array.length,
6150          result = new array.constructor(length);
6151
6152      // Add properties assigned by `RegExp#exec`.
6153      if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
6154        result.index = array.index;
6155        result.input = array.input;
6156      }
6157      return result;
6158    }
6159
6160    /**
6161     * Initializes an object clone.
6162     *
6163     * @private
6164     * @param {Object} object The object to clone.
6165     * @returns {Object} Returns the initialized clone.
6166     */
6167    function initCloneObject(object) {
6168      return (typeof object.constructor == 'function' && !isPrototype(object))
6169        ? baseCreate(getPrototype(object))
6170        : {};
6171    }
6172
6173    /**
6174     * Initializes an object clone based on its `toStringTag`.
6175     *
6176     * **Note:** This function only supports cloning values with tags of
6177     * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
6178     *
6179     * @private
6180     * @param {Object} object The object to clone.
6181     * @param {string} tag The `toStringTag` of the object to clone.
6182     * @param {boolean} [isDeep] Specify a deep clone.
6183     * @returns {Object} Returns the initialized clone.
6184     */
6185    function initCloneByTag(object, tag, isDeep) {
6186      var Ctor = object.constructor;
6187      switch (tag) {
6188        case arrayBufferTag:
6189          return cloneArrayBuffer(object);
6190
6191        case boolTag:
6192        case dateTag:
6193          return new Ctor(+object);
6194
6195        case dataViewTag:
6196          return cloneDataView(object, isDeep);
6197
6198        case float32Tag: case float64Tag:
6199        case int8Tag: case int16Tag: case int32Tag:
6200        case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
6201          return cloneTypedArray(object, isDeep);
6202
6203        case mapTag:
6204          return new Ctor;
6205
6206        case numberTag:
6207        case stringTag:
6208          return new Ctor(object);
6209
6210        case regexpTag:
6211          return cloneRegExp(object);
6212
6213        case setTag:
6214          return new Ctor;
6215
6216        case symbolTag:
6217          return cloneSymbol(object);
6218      }
6219    }
6220
6221    /**
6222     * Inserts wrapper `details` in a comment at the top of the `source` body.
6223     *
6224     * @private
6225     * @param {string} source The source to modify.
6226     * @returns {Array} details The details to insert.
6227     * @returns {string} Returns the modified source.
6228     */
6229    function insertWrapDetails(source, details) {
6230      var length = details.length;
6231      if (!length) {
6232        return source;
6233      }
6234      var lastIndex = length - 1;
6235      details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
6236      details = details.join(length > 2 ? ', ' : ' ');
6237      return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
6238    }
6239
6240    /**
6241     * Checks if `value` is a flattenable `arguments` object or array.
6242     *
6243     * @private
6244     * @param {*} value The value to check.
6245     * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6246     */
6247    function isFlattenable(value) {
6248      return isArray(value) || isArguments(value) ||
6249        !!(spreadableSymbol && value && value[spreadableSymbol]);
6250    }
6251
6252    /**
6253     * Checks if `value` is a valid array-like index.
6254     *
6255     * @private
6256     * @param {*} value The value to check.
6257     * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
6258     * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
6259     */
6260    function isIndex(value, length) {
6261      var type = typeof value;
6262      length = length == null ? MAX_SAFE_INTEGER : length;
6263
6264      return !!length &&
6265        (type == 'number' ||
6266          (type != 'symbol' && reIsUint.test(value))) &&
6267            (value > -1 && value % 1 == 0 && value < length);
6268    }
6269
6270    /**
6271     * Checks if the given arguments are from an iteratee call.
6272     *
6273     * @private
6274     * @param {*} value The potential iteratee value argument.
6275     * @param {*} index The potential iteratee index or key argument.
6276     * @param {*} object The potential iteratee object argument.
6277     * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
6278     *  else `false`.
6279     */
6280    function isIterateeCall(value, index, object) {
6281      if (!isObject(object)) {
6282        return false;
6283      }
6284      var type = typeof index;
6285      if (type == 'number'
6286            ? (isArrayLike(object) && isIndex(index, object.length))
6287            : (type == 'string' && index in object)
6288          ) {
6289        return eq(object[index], value);
6290      }
6291      return false;
6292    }
6293
6294    /**
6295     * Checks if `value` is a property name and not a property path.
6296     *
6297     * @private
6298     * @param {*} value The value to check.
6299     * @param {Object} [object] The object to query keys on.
6300     * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
6301     */
6302    function isKey(value, object) {
6303      if (isArray(value)) {
6304        return false;
6305      }
6306      var type = typeof value;
6307      if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6308          value == null || isSymbol(value)) {
6309        return true;
6310      }
6311      return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6312        (object != null && value in Object(object));
6313    }
6314
6315    /**
6316     * Checks if `value` is suitable for use as unique object key.
6317     *
6318     * @private
6319     * @param {*} value The value to check.
6320     * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6321     */
6322    function isKeyable(value) {
6323      var type = typeof value;
6324      return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
6325        ? (value !== '__proto__')
6326        : (value === null);
6327    }
6328
6329    /**
6330     * Checks if `func` has a lazy counterpart.
6331     *
6332     * @private
6333     * @param {Function} func The function to check.
6334     * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6335     *  else `false`.
6336     */
6337    function isLaziable(func) {
6338      var funcName = getFuncName(func),
6339          other = lodash[funcName];
6340
6341      if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6342        return false;
6343      }
6344      if (func === other) {
6345        return true;
6346      }
6347      var data = getData(other);
6348      return !!data && func === data[0];
6349    }
6350
6351    /**
6352     * Checks if `func` has its source masked.
6353     *
6354     * @private
6355     * @param {Function} func The function to check.
6356     * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6357     */
6358    function isMasked(func) {
6359      return !!maskSrcKey && (maskSrcKey in func);
6360    }
6361
6362    /**
6363     * Checks if `func` is capable of being masked.
6364     *
6365     * @private
6366     * @param {*} value The value to check.
6367     * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6368     */
6369    var isMaskable = coreJsData ? isFunction : stubFalse;
6370
6371    /**
6372     * Checks if `value` is likely a prototype object.
6373     *
6374     * @private
6375     * @param {*} value The value to check.
6376     * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6377     */
6378    function isPrototype(value) {
6379      var Ctor = value && value.constructor,
6380          proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6381
6382      return value === proto;
6383    }
6384
6385    /**
6386     * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6387     *
6388     * @private
6389     * @param {*} value The value to check.
6390     * @returns {boolean} Returns `true` if `value` if suitable for strict
6391     *  equality comparisons, else `false`.
6392     */
6393    function isStrictComparable(value) {
6394      return value === value && !isObject(value);
6395    }
6396
6397    /**
6398     * A specialized version of `matchesProperty` for source values suitable
6399     * for strict equality comparisons, i.e. `===`.
6400     *
6401     * @private
6402     * @param {string} key The key of the property to get.
6403     * @param {*} srcValue The value to match.
6404     * @returns {Function} Returns the new spec function.
6405     */
6406    function matchesStrictComparable(key, srcValue) {
6407      return function(object) {
6408        if (object == null) {
6409          return false;
6410        }
6411        return object[key] === srcValue &&
6412          (srcValue !== undefined || (key in Object(object)));
6413      };
6414    }
6415
6416    /**
6417     * A specialized version of `_.memoize` which clears the memoized function's
6418     * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6419     *
6420     * @private
6421     * @param {Function} func The function to have its output memoized.
6422     * @returns {Function} Returns the new memoized function.
6423     */
6424    function memoizeCapped(func) {
6425      var result = memoize(func, function(key) {
6426        if (cache.size === MAX_MEMOIZE_SIZE) {
6427          cache.clear();
6428        }
6429        return key;
6430      });
6431
6432      var cache = result.cache;
6433      return result;
6434    }
6435
6436    /**
6437     * Merges the function metadata of `source` into `data`.
6438     *
6439     * Merging metadata reduces the number of wrappers used to invoke a function.
6440     * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
6441     * may be applied regardless of execution order. Methods like `_.ary` and
6442     * `_.rearg` modify function arguments, making the order in which they are
6443     * executed important, preventing the merging of metadata. However, we make
6444     * an exception for a safe combined case where curried functions have `_.ary`
6445     * and or `_.rearg` applied.
6446     *
6447     * @private
6448     * @param {Array} data The destination metadata.
6449     * @param {Array} source The source metadata.
6450     * @returns {Array} Returns `data`.
6451     */
6452    function mergeData(data, source) {
6453      var bitmask = data[1],
6454          srcBitmask = source[1],
6455          newBitmask = bitmask | srcBitmask,
6456          isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6457
6458      var isCombo =
6459        ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
6460        ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
6461        ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
6462
6463      // Exit early if metadata can't be merged.
6464      if (!(isCommon || isCombo)) {
6465        return data;
6466      }
6467      // Use source `thisArg` if available.
6468      if (srcBitmask & WRAP_BIND_FLAG) {
6469        data[2] = source[2];
6470        // Set when currying a bound function.
6471        newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6472      }
6473      // Compose partial arguments.
6474      var value = source[3];
6475      if (value) {
6476        var partials = data[3];
6477        data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6478        data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6479      }
6480      // Compose partial right arguments.
6481      value = source[5];
6482      if (value) {
6483        partials = data[5];
6484        data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6485        data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6486      }
6487      // Use source `argPos` if available.
6488      value = source[7];
6489      if (value) {
6490        data[7] = value;
6491      }
6492      // Use source `ary` if it's smaller.
6493      if (srcBitmask & WRAP_ARY_FLAG) {
6494        data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
6495      }
6496      // Use source `arity` if one is not provided.
6497      if (data[9] == null) {
6498        data[9] = source[9];
6499      }
6500      // Use source `func` and merge bitmasks.
6501      data[0] = source[0];
6502      data[1] = newBitmask;
6503
6504      return data;
6505    }
6506
6507    /**
6508     * This function is like
6509     * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
6510     * except that it includes inherited enumerable properties.
6511     *
6512     * @private
6513     * @param {Object} object The object to query.
6514     * @returns {Array} Returns the array of property names.
6515     */
6516    function nativeKeysIn(object) {
6517      var result = [];
6518      if (object != null) {
6519        for (var key in Object(object)) {
6520          result.push(key);
6521        }
6522      }
6523      return result;
6524    }
6525
6526    /**
6527     * Converts `value` to a string using `Object.prototype.toString`.
6528     *
6529     * @private
6530     * @param {*} value The value to convert.
6531     * @returns {string} Returns the converted string.
6532     */
6533    function objectToString(value) {
6534      return nativeObjectToString.call(value);
6535    }
6536
6537    /**
6538     * A specialized version of `baseRest` which transforms the rest array.
6539     *
6540     * @private
6541     * @param {Function} func The function to apply a rest parameter to.
6542     * @param {number} [start=func.length-1] The start position of the rest parameter.
6543     * @param {Function} transform The rest array transform.
6544     * @returns {Function} Returns the new function.
6545     */
6546    function overRest(func, start, transform) {
6547      start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
6548      return function() {
6549        var args = arguments,
6550            index = -1,
6551            length = nativeMax(args.length - start, 0),
6552            array = Array(length);
6553
6554        while (++index < length) {
6555          array[index] = args[start + index];
6556        }
6557        index = -1;
6558        var otherArgs = Array(start + 1);
6559        while (++index < start) {
6560          otherArgs[index] = args[index];
6561        }
6562        otherArgs[start] = transform(array);
6563        return apply(func, this, otherArgs);
6564      };
6565    }
6566
6567    /**
6568     * Gets the parent value at `path` of `object`.
6569     *
6570     * @private
6571     * @param {Object} object The object to query.
6572     * @param {Array} path The path to get the parent value of.
6573     * @returns {*} Returns the parent value.
6574     */
6575    function parent(object, path) {
6576      return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6577    }
6578
6579    /**
6580     * Reorder `array` according to the specified indexes where the element at
6581     * the first index is assigned as the first element, the element at
6582     * the second index is assigned as the second element, and so on.
6583     *
6584     * @private
6585     * @param {Array} array The array to reorder.
6586     * @param {Array} indexes The arranged array indexes.
6587     * @returns {Array} Returns `array`.
6588     */
6589    function reorder(array, indexes) {
6590      var arrLength = array.length,
6591          length = nativeMin(indexes.length, arrLength),
6592          oldArray = copyArray(array);
6593
6594      while (length--) {
6595        var index = indexes[length];
6596        array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
6597      }
6598      return array;
6599    }
6600
6601    /**
6602     * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
6603     *
6604     * @private
6605     * @param {Object} object The object to query.
6606     * @param {string} key The key of the property to get.
6607     * @returns {*} Returns the property value.
6608     */
6609    function safeGet(object, key) {
6610      if (key === 'constructor' && typeof object[key] === 'function') {
6611        return;
6612      }
6613
6614      if (key == '__proto__') {
6615        return;
6616      }
6617
6618      return object[key];
6619    }
6620
6621    /**
6622     * Sets metadata for `func`.
6623     *
6624     * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
6625     * period of time, it will trip its breaker and transition to an identity
6626     * function to avoid garbage collection pauses in V8. See
6627     * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
6628     * for more details.
6629     *
6630     * @private
6631     * @param {Function} func The function to associate metadata with.
6632     * @param {*} data The metadata.
6633     * @returns {Function} Returns `func`.
6634     */
6635    var setData = shortOut(baseSetData);
6636
6637    /**
6638     * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
6639     *
6640     * @private
6641     * @param {Function} func The function to delay.
6642     * @param {number} wait The number of milliseconds to delay invocation.
6643     * @returns {number|Object} Returns the timer id or timeout object.
6644     */
6645    var setTimeout = ctxSetTimeout || function(func, wait) {
6646      return root.setTimeout(func, wait);
6647    };
6648
6649    /**
6650     * Sets the `toString` method of `func` to return `string`.
6651     *
6652     * @private
6653     * @param {Function} func The function to modify.
6654     * @param {Function} string The `toString` result.
6655     * @returns {Function} Returns `func`.
6656     */
6657    var setToString = shortOut(baseSetToString);
6658
6659    /**
6660     * Sets the `toString` method of `wrapper` to mimic the source of `reference`
6661     * with wrapper details in a comment at the top of the source body.
6662     *
6663     * @private
6664     * @param {Function} wrapper The function to modify.
6665     * @param {Function} reference The reference function.
6666     * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6667     * @returns {Function} Returns `wrapper`.
6668     */
6669    function setWrapToString(wrapper, reference, bitmask) {
6670      var source = (reference + '');
6671      return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6672    }
6673
6674    /**
6675     * Creates a function that'll short out and invoke `identity` instead
6676     * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
6677     * milliseconds.
6678     *
6679     * @private
6680     * @param {Function} func The function to restrict.
6681     * @returns {Function} Returns the new shortable function.
6682     */
6683    function shortOut(func) {
6684      var count = 0,
6685          lastCalled = 0;
6686
6687      return function() {
6688        var stamp = nativeNow(),
6689            remaining = HOT_SPAN - (stamp - lastCalled);
6690
6691        lastCalled = stamp;
6692        if (remaining > 0) {
6693          if (++count >= HOT_COUNT) {
6694            return arguments[0];
6695          }
6696        } else {
6697          count = 0;
6698        }
6699        return func.apply(undefined, arguments);
6700      };
6701    }
6702
6703    /**
6704     * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
6705     *
6706     * @private
6707     * @param {Array} array The array to shuffle.
6708     * @param {number} [size=array.length] The size of `array`.
6709     * @returns {Array} Returns `array`.
6710     */
6711    function shuffleSelf(array, size) {
6712      var index = -1,
6713          length = array.length,
6714          lastIndex = length - 1;
6715
6716      size = size === undefined ? length : size;
6717      while (++index < size) {
6718        var rand = baseRandom(index, lastIndex),
6719            value = array[rand];
6720
6721        array[rand] = array[index];
6722        array[index] = value;
6723      }
6724      array.length = size;
6725      return array;
6726    }
6727
6728    /**
6729     * Converts `string` to a property path array.
6730     *
6731     * @private
6732     * @param {string} string The string to convert.
6733     * @returns {Array} Returns the property path array.
6734     */
6735    var stringToPath = memoizeCapped(function(string) {
6736      var result = [];
6737      if (string.charCodeAt(0) === 46 /* . */) {
6738        result.push('');
6739      }
6740      string.replace(rePropName, function(match, number, quote, subString) {
6741        result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
6742      });
6743      return result;
6744    });
6745
6746    /**
6747     * Converts `value` to a string key if it's not a string or symbol.
6748     *
6749     * @private
6750     * @param {*} value The value to inspect.
6751     * @returns {string|symbol} Returns the key.
6752     */
6753    function toKey(value) {
6754      if (typeof value == 'string' || isSymbol(value)) {
6755        return value;
6756      }
6757      var result = (value + '');
6758      return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
6759    }
6760
6761    /**
6762     * Converts `func` to its source code.
6763     *
6764     * @private
6765     * @param {Function} func The function to convert.
6766     * @returns {string} Returns the source code.
6767     */
6768    function toSource(func) {
6769      if (func != null) {
6770        try {
6771          return funcToString.call(func);
6772        } catch (e) {}
6773        try {
6774          return (func + '');
6775        } catch (e) {}
6776      }
6777      return '';
6778    }
6779
6780    /**
6781     * Updates wrapper `details` based on `bitmask` flags.
6782     *
6783     * @private
6784     * @returns {Array} details The details to modify.
6785     * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6786     * @returns {Array} Returns `details`.
6787     */
6788    function updateWrapDetails(details, bitmask) {
6789      arrayEach(wrapFlags, function(pair) {
6790        var value = '_.' + pair[0];
6791        if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
6792          details.push(value);
6793        }
6794      });
6795      return details.sort();
6796    }
6797
6798    /**
6799     * Creates a clone of `wrapper`.
6800     *
6801     * @private
6802     * @param {Object} wrapper The wrapper to clone.
6803     * @returns {Object} Returns the cloned wrapper.
6804     */
6805    function wrapperClone(wrapper) {
6806      if (wrapper instanceof LazyWrapper) {
6807        return wrapper.clone();
6808      }
6809      var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6810      result.__actions__ = copyArray(wrapper.__actions__);
6811      result.__index__  = wrapper.__index__;
6812      result.__values__ = wrapper.__values__;
6813      return result;
6814    }
6815
6816    /*------------------------------------------------------------------------*/
6817
6818    /**
6819     * Creates an array of elements split into groups the length of `size`.
6820     * If `array` can't be split evenly, the final chunk will be the remaining
6821     * elements.
6822     *
6823     * @static
6824     * @memberOf _
6825     * @since 3.0.0
6826     * @category Array
6827     * @param {Array} array The array to process.
6828     * @param {number} [size=1] The length of each chunk
6829     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
6830     * @returns {Array} Returns the new array of chunks.
6831     * @example
6832     *
6833     * _.chunk(['a', 'b', 'c', 'd'], 2);
6834     * // => [['a', 'b'], ['c', 'd']]
6835     *
6836     * _.chunk(['a', 'b', 'c', 'd'], 3);
6837     * // => [['a', 'b', 'c'], ['d']]
6838     */
6839    function chunk(array, size, guard) {
6840      if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
6841        size = 1;
6842      } else {
6843        size = nativeMax(toInteger(size), 0);
6844      }
6845      var length = array == null ? 0 : array.length;
6846      if (!length || size < 1) {
6847        return [];
6848      }
6849      var index = 0,
6850          resIndex = 0,
6851          result = Array(nativeCeil(length / size));
6852
6853      while (index < length) {
6854        result[resIndex++] = baseSlice(array, index, (index += size));
6855      }
6856      return result;
6857    }
6858
6859    /**
6860     * Creates an array with all falsey values removed. The values `false`, `null`,
6861     * `0`, `""`, `undefined`, and `NaN` are falsey.
6862     *
6863     * @static
6864     * @memberOf _
6865     * @since 0.1.0
6866     * @category Array
6867     * @param {Array} array The array to compact.
6868     * @returns {Array} Returns the new array of filtered values.
6869     * @example
6870     *
6871     * _.compact([0, 1, false, 2, '', 3]);
6872     * // => [1, 2, 3]
6873     */
6874    function compact(array) {
6875      var index = -1,
6876          length = array == null ? 0 : array.length,
6877          resIndex = 0,
6878          result = [];
6879
6880      while (++index < length) {
6881        var value = array[index];
6882        if (value) {
6883          result[resIndex++] = value;
6884        }
6885      }
6886      return result;
6887    }
6888
6889    /**
6890     * Creates a new array concatenating `array` with any additional arrays
6891     * and/or values.
6892     *
6893     * @static
6894     * @memberOf _
6895     * @since 4.0.0
6896     * @category Array
6897     * @param {Array} array The array to concatenate.
6898     * @param {...*} [values] The values to concatenate.
6899     * @returns {Array} Returns the new concatenated array.
6900     * @example
6901     *
6902     * var array = [1];
6903     * var other = _.concat(array, 2, [3], [[4]]);
6904     *
6905     * console.log(other);
6906     * // => [1, 2, 3, [4]]
6907     *
6908     * console.log(array);
6909     * // => [1]
6910     */
6911    function concat() {
6912      var length = arguments.length;
6913      if (!length) {
6914        return [];
6915      }
6916      var args = Array(length - 1),
6917          array = arguments[0],
6918          index = length;
6919
6920      while (index--) {
6921        args[index - 1] = arguments[index];
6922      }
6923      return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
6924    }
6925
6926    /**
6927     * Creates an array of `array` values not included in the other given arrays
6928     * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
6929     * for equality comparisons. The order and references of result values are
6930     * determined by the first array.
6931     *
6932     * **Note:** Unlike `_.pullAll`, this method returns a new array.
6933     *
6934     * @static
6935     * @memberOf _
6936     * @since 0.1.0
6937     * @category Array
6938     * @param {Array} array The array to inspect.
6939     * @param {...Array} [values] The values to exclude.
6940     * @returns {Array} Returns the new array of filtered values.
6941     * @see _.without, _.xor
6942     * @example
6943     *
6944     * _.difference([2, 1], [2, 3]);
6945     * // => [1]
6946     */
6947    var difference = baseRest(function(array, values) {
6948      return isArrayLikeObject(array)
6949        ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
6950        : [];
6951    });
6952
6953    /**
6954     * This method is like `_.difference` except that it accepts `iteratee` which
6955     * is invoked for each element of `array` and `values` to generate the criterion
6956     * by which they're compared. The order and references of result values are
6957     * determined by the first array. The iteratee is invoked with one argument:
6958     * (value).
6959     *
6960     * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
6961     *
6962     * @static
6963     * @memberOf _
6964     * @since 4.0.0
6965     * @category Array
6966     * @param {Array} array The array to inspect.
6967     * @param {...Array} [values] The values to exclude.
6968     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
6969     * @returns {Array} Returns the new array of filtered values.
6970     * @example
6971     *
6972     * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
6973     * // => [1.2]
6974     *
6975     * // The `_.property` iteratee shorthand.
6976     * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
6977     * // => [{ 'x': 2 }]
6978     */
6979    var differenceBy = baseRest(function(array, values) {
6980      var iteratee = last(values);
6981      if (isArrayLikeObject(iteratee)) {
6982        iteratee = undefined;
6983      }
6984      return isArrayLikeObject(array)
6985        ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
6986        : [];
6987    });
6988
6989    /**
6990     * This method is like `_.difference` except that it accepts `comparator`
6991     * which is invoked to compare elements of `array` to `values`. The order and
6992     * references of result values are determined by the first array. The comparator
6993     * is invoked with two arguments: (arrVal, othVal).
6994     *
6995     * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
6996     *
6997     * @static
6998     * @memberOf _
6999     * @since 4.0.0
7000     * @category Array
7001     * @param {Array} array The array to inspect.
7002     * @param {...Array} [values] The values to exclude.
7003     * @param {Function} [comparator] The comparator invoked per element.
7004     * @returns {Array} Returns the new array of filtered values.
7005     * @example
7006     *
7007     * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7008     *
7009     * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
7010     * // => [{ 'x': 2, 'y': 1 }]
7011     */
7012    var differenceWith = baseRest(function(array, values) {
7013      var comparator = last(values);
7014      if (isArrayLikeObject(comparator)) {
7015        comparator = undefined;
7016      }
7017      return isArrayLikeObject(array)
7018        ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
7019        : [];
7020    });
7021
7022    /**
7023     * Creates a slice of `array` with `n` elements dropped from the beginning.
7024     *
7025     * @static
7026     * @memberOf _
7027     * @since 0.5.0
7028     * @category Array
7029     * @param {Array} array The array to query.
7030     * @param {number} [n=1] The number of elements to drop.
7031     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7032     * @returns {Array} Returns the slice of `array`.
7033     * @example
7034     *
7035     * _.drop([1, 2, 3]);
7036     * // => [2, 3]
7037     *
7038     * _.drop([1, 2, 3], 2);
7039     * // => [3]
7040     *
7041     * _.drop([1, 2, 3], 5);
7042     * // => []
7043     *
7044     * _.drop([1, 2, 3], 0);
7045     * // => [1, 2, 3]
7046     */
7047    function drop(array, n, guard) {
7048      var length = array == null ? 0 : array.length;
7049      if (!length) {
7050        return [];
7051      }
7052      n = (guard || n === undefined) ? 1 : toInteger(n);
7053      return baseSlice(array, n < 0 ? 0 : n, length);
7054    }
7055
7056    /**
7057     * Creates a slice of `array` with `n` elements dropped from the end.
7058     *
7059     * @static
7060     * @memberOf _
7061     * @since 3.0.0
7062     * @category Array
7063     * @param {Array} array The array to query.
7064     * @param {number} [n=1] The number of elements to drop.
7065     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7066     * @returns {Array} Returns the slice of `array`.
7067     * @example
7068     *
7069     * _.dropRight([1, 2, 3]);
7070     * // => [1, 2]
7071     *
7072     * _.dropRight([1, 2, 3], 2);
7073     * // => [1]
7074     *
7075     * _.dropRight([1, 2, 3], 5);
7076     * // => []
7077     *
7078     * _.dropRight([1, 2, 3], 0);
7079     * // => [1, 2, 3]
7080     */
7081    function dropRight(array, n, guard) {
7082      var length = array == null ? 0 : array.length;
7083      if (!length) {
7084        return [];
7085      }
7086      n = (guard || n === undefined) ? 1 : toInteger(n);
7087      n = length - n;
7088      return baseSlice(array, 0, n < 0 ? 0 : n);
7089    }
7090
7091    /**
7092     * Creates a slice of `array` excluding elements dropped from the end.
7093     * Elements are dropped until `predicate` returns falsey. The predicate is
7094     * invoked with three arguments: (value, index, array).
7095     *
7096     * @static
7097     * @memberOf _
7098     * @since 3.0.0
7099     * @category Array
7100     * @param {Array} array The array to query.
7101     * @param {Function} [predicate=_.identity] The function invoked per iteration.
7102     * @returns {Array} Returns the slice of `array`.
7103     * @example
7104     *
7105     * var users = [
7106     *   { 'user': 'barney',  'active': true },
7107     *   { 'user': 'fred',    'active': false },
7108     *   { 'user': 'pebbles', 'active': false }
7109     * ];
7110     *
7111     * _.dropRightWhile(users, function(o) { return !o.active; });
7112     * // => objects for ['barney']
7113     *
7114     * // The `_.matches` iteratee shorthand.
7115     * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7116     * // => objects for ['barney', 'fred']
7117     *
7118     * // The `_.matchesProperty` iteratee shorthand.
7119     * _.dropRightWhile(users, ['active', false]);
7120     * // => objects for ['barney']
7121     *
7122     * // The `_.property` iteratee shorthand.
7123     * _.dropRightWhile(users, 'active');
7124     * // => objects for ['barney', 'fred', 'pebbles']
7125     */
7126    function dropRightWhile(array, predicate) {
7127      return (array && array.length)
7128        ? baseWhile(array, getIteratee(predicate, 3), true, true)
7129        : [];
7130    }
7131
7132    /**
7133     * Creates a slice of `array` excluding elements dropped from the beginning.
7134     * Elements are dropped until `predicate` returns falsey. The predicate is
7135     * invoked with three arguments: (value, index, array).
7136     *
7137     * @static
7138     * @memberOf _
7139     * @since 3.0.0
7140     * @category Array
7141     * @param {Array} array The array to query.
7142     * @param {Function} [predicate=_.identity] The function invoked per iteration.
7143     * @returns {Array} Returns the slice of `array`.
7144     * @example
7145     *
7146     * var users = [
7147     *   { 'user': 'barney',  'active': false },
7148     *   { 'user': 'fred',    'active': false },
7149     *   { 'user': 'pebbles', 'active': true }
7150     * ];
7151     *
7152     * _.dropWhile(users, function(o) { return !o.active; });
7153     * // => objects for ['pebbles']
7154     *
7155     * // The `_.matches` iteratee shorthand.
7156     * _.dropWhile(users, { 'user': 'barney', 'active': false });
7157     * // => objects for ['fred', 'pebbles']
7158     *
7159     * // The `_.matchesProperty` iteratee shorthand.
7160     * _.dropWhile(users, ['active', false]);
7161     * // => objects for ['pebbles']
7162     *
7163     * // The `_.property` iteratee shorthand.
7164     * _.dropWhile(users, 'active');
7165     * // => objects for ['barney', 'fred', 'pebbles']
7166     */
7167    function dropWhile(array, predicate) {
7168      return (array && array.length)
7169        ? baseWhile(array, getIteratee(predicate, 3), true)
7170        : [];
7171    }
7172
7173    /**
7174     * Fills elements of `array` with `value` from `start` up to, but not
7175     * including, `end`.
7176     *
7177     * **Note:** This method mutates `array`.
7178     *
7179     * @static
7180     * @memberOf _
7181     * @since 3.2.0
7182     * @category Array
7183     * @param {Array} array The array to fill.
7184     * @param {*} value The value to fill `array` with.
7185     * @param {number} [start=0] The start position.
7186     * @param {number} [end=array.length] The end position.
7187     * @returns {Array} Returns `array`.
7188     * @example
7189     *
7190     * var array = [1, 2, 3];
7191     *
7192     * _.fill(array, 'a');
7193     * console.log(array);
7194     * // => ['a', 'a', 'a']
7195     *
7196     * _.fill(Array(3), 2);
7197     * // => [2, 2, 2]
7198     *
7199     * _.fill([4, 6, 8, 10], '*', 1, 3);
7200     * // => [4, '*', '*', 10]
7201     */
7202    function fill(array, value, start, end) {
7203      var length = array == null ? 0 : array.length;
7204      if (!length) {
7205        return [];
7206      }
7207      if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7208        start = 0;
7209        end = length;
7210      }
7211      return baseFill(array, value, start, end);
7212    }
7213
7214    /**
7215     * This method is like `_.find` except that it returns the index of the first
7216     * element `predicate` returns truthy for instead of the element itself.
7217     *
7218     * @static
7219     * @memberOf _
7220     * @since 1.1.0
7221     * @category Array
7222     * @param {Array} array The array to inspect.
7223     * @param {Function} [predicate=_.identity] The function invoked per iteration.
7224     * @param {number} [fromIndex=0] The index to search from.
7225     * @returns {number} Returns the index of the found element, else `-1`.
7226     * @example
7227     *
7228     * var users = [
7229     *   { 'user': 'barney',  'active': false },
7230     *   { 'user': 'fred',    'active': false },
7231     *   { 'user': 'pebbles', 'active': true }
7232     * ];
7233     *
7234     * _.findIndex(users, function(o) { return o.user == 'barney'; });
7235     * // => 0
7236     *
7237     * // The `_.matches` iteratee shorthand.
7238     * _.findIndex(users, { 'user': 'fred', 'active': false });
7239     * // => 1
7240     *
7241     * // The `_.matchesProperty` iteratee shorthand.
7242     * _.findIndex(users, ['active', false]);
7243     * // => 0
7244     *
7245     * // The `_.property` iteratee shorthand.
7246     * _.findIndex(users, 'active');
7247     * // => 2
7248     */
7249    function findIndex(array, predicate, fromIndex) {
7250      var length = array == null ? 0 : array.length;
7251      if (!length) {
7252        return -1;
7253      }
7254      var index = fromIndex == null ? 0 : toInteger(fromIndex);
7255      if (index < 0) {
7256        index = nativeMax(length + index, 0);
7257      }
7258      return baseFindIndex(array, getIteratee(predicate, 3), index);
7259    }
7260
7261    /**
7262     * This method is like `_.findIndex` except that it iterates over elements
7263     * of `collection` from right to left.
7264     *
7265     * @static
7266     * @memberOf _
7267     * @since 2.0.0
7268     * @category Array
7269     * @param {Array} array The array to inspect.
7270     * @param {Function} [predicate=_.identity] The function invoked per iteration.
7271     * @param {number} [fromIndex=array.length-1] The index to search from.
7272     * @returns {number} Returns the index of the found element, else `-1`.
7273     * @example
7274     *
7275     * var users = [
7276     *   { 'user': 'barney',  'active': true },
7277     *   { 'user': 'fred',    'active': false },
7278     *   { 'user': 'pebbles', 'active': false }
7279     * ];
7280     *
7281     * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7282     * // => 2
7283     *
7284     * // The `_.matches` iteratee shorthand.
7285     * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7286     * // => 0
7287     *
7288     * // The `_.matchesProperty` iteratee shorthand.
7289     * _.findLastIndex(users, ['active', false]);
7290     * // => 2
7291     *
7292     * // The `_.property` iteratee shorthand.
7293     * _.findLastIndex(users, 'active');
7294     * // => 0
7295     */
7296    function findLastIndex(array, predicate, fromIndex) {
7297      var length = array == null ? 0 : array.length;
7298      if (!length) {
7299        return -1;
7300      }
7301      var index = length - 1;
7302      if (fromIndex !== undefined) {
7303        index = toInteger(fromIndex);
7304        index = fromIndex < 0
7305          ? nativeMax(length + index, 0)
7306          : nativeMin(index, length - 1);
7307      }
7308      return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7309    }
7310
7311    /**
7312     * Flattens `array` a single level deep.
7313     *
7314     * @static
7315     * @memberOf _
7316     * @since 0.1.0
7317     * @category Array
7318     * @param {Array} array The array to flatten.
7319     * @returns {Array} Returns the new flattened array.
7320     * @example
7321     *
7322     * _.flatten([1, [2, [3, [4]], 5]]);
7323     * // => [1, 2, [3, [4]], 5]
7324     */
7325    function flatten(array) {
7326      var length = array == null ? 0 : array.length;
7327      return length ? baseFlatten(array, 1) : [];
7328    }
7329
7330    /**
7331     * Recursively flattens `array`.
7332     *
7333     * @static
7334     * @memberOf _
7335     * @since 3.0.0
7336     * @category Array
7337     * @param {Array} array The array to flatten.
7338     * @returns {Array} Returns the new flattened array.
7339     * @example
7340     *
7341     * _.flattenDeep([1, [2, [3, [4]], 5]]);
7342     * // => [1, 2, 3, 4, 5]
7343     */
7344    function flattenDeep(array) {
7345      var length = array == null ? 0 : array.length;
7346      return length ? baseFlatten(array, INFINITY) : [];
7347    }
7348
7349    /**
7350     * Recursively flatten `array` up to `depth` times.
7351     *
7352     * @static
7353     * @memberOf _
7354     * @since 4.4.0
7355     * @category Array
7356     * @param {Array} array The array to flatten.
7357     * @param {number} [depth=1] The maximum recursion depth.
7358     * @returns {Array} Returns the new flattened array.
7359     * @example
7360     *
7361     * var array = [1, [2, [3, [4]], 5]];
7362     *
7363     * _.flattenDepth(array, 1);
7364     * // => [1, 2, [3, [4]], 5]
7365     *
7366     * _.flattenDepth(array, 2);
7367     * // => [1, 2, 3, [4], 5]
7368     */
7369    function flattenDepth(array, depth) {
7370      var length = array == null ? 0 : array.length;
7371      if (!length) {
7372        return [];
7373      }
7374      depth = depth === undefined ? 1 : toInteger(depth);
7375      return baseFlatten(array, depth);
7376    }
7377
7378    /**
7379     * The inverse of `_.toPairs`; this method returns an object composed
7380     * from key-value `pairs`.
7381     *
7382     * @static
7383     * @memberOf _
7384     * @since 4.0.0
7385     * @category Array
7386     * @param {Array} pairs The key-value pairs.
7387     * @returns {Object} Returns the new object.
7388     * @example
7389     *
7390     * _.fromPairs([['a', 1], ['b', 2]]);
7391     * // => { 'a': 1, 'b': 2 }
7392     */
7393    function fromPairs(pairs) {
7394      var index = -1,
7395          length = pairs == null ? 0 : pairs.length,
7396          result = {};
7397
7398      while (++index < length) {
7399        var pair = pairs[index];
7400        result[pair[0]] = pair[1];
7401      }
7402      return result;
7403    }
7404
7405    /**
7406     * Gets the first element of `array`.
7407     *
7408     * @static
7409     * @memberOf _
7410     * @since 0.1.0
7411     * @alias first
7412     * @category Array
7413     * @param {Array} array The array to query.
7414     * @returns {*} Returns the first element of `array`.
7415     * @example
7416     *
7417     * _.head([1, 2, 3]);
7418     * // => 1
7419     *
7420     * _.head([]);
7421     * // => undefined
7422     */
7423    function head(array) {
7424      return (array && array.length) ? array[0] : undefined;
7425    }
7426
7427    /**
7428     * Gets the index at which the first occurrence of `value` is found in `array`
7429     * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7430     * for equality comparisons. If `fromIndex` is negative, it's used as the
7431     * offset from the end of `array`.
7432     *
7433     * @static
7434     * @memberOf _
7435     * @since 0.1.0
7436     * @category Array
7437     * @param {Array} array The array to inspect.
7438     * @param {*} value The value to search for.
7439     * @param {number} [fromIndex=0] The index to search from.
7440     * @returns {number} Returns the index of the matched value, else `-1`.
7441     * @example
7442     *
7443     * _.indexOf([1, 2, 1, 2], 2);
7444     * // => 1
7445     *
7446     * // Search from the `fromIndex`.
7447     * _.indexOf([1, 2, 1, 2], 2, 2);
7448     * // => 3
7449     */
7450    function indexOf(array, value, fromIndex) {
7451      var length = array == null ? 0 : array.length;
7452      if (!length) {
7453        return -1;
7454      }
7455      var index = fromIndex == null ? 0 : toInteger(fromIndex);
7456      if (index < 0) {
7457        index = nativeMax(length + index, 0);
7458      }
7459      return baseIndexOf(array, value, index);
7460    }
7461
7462    /**
7463     * Gets all but the last element of `array`.
7464     *
7465     * @static
7466     * @memberOf _
7467     * @since 0.1.0
7468     * @category Array
7469     * @param {Array} array The array to query.
7470     * @returns {Array} Returns the slice of `array`.
7471     * @example
7472     *
7473     * _.initial([1, 2, 3]);
7474     * // => [1, 2]
7475     */
7476    function initial(array) {
7477      var length = array == null ? 0 : array.length;
7478      return length ? baseSlice(array, 0, -1) : [];
7479    }
7480
7481    /**
7482     * Creates an array of unique values that are included in all given arrays
7483     * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7484     * for equality comparisons. The order and references of result values are
7485     * determined by the first array.
7486     *
7487     * @static
7488     * @memberOf _
7489     * @since 0.1.0
7490     * @category Array
7491     * @param {...Array} [arrays] The arrays to inspect.
7492     * @returns {Array} Returns the new array of intersecting values.
7493     * @example
7494     *
7495     * _.intersection([2, 1], [2, 3]);
7496     * // => [2]
7497     */
7498    var intersection = baseRest(function(arrays) {
7499      var mapped = arrayMap(arrays, castArrayLikeObject);
7500      return (mapped.length && mapped[0] === arrays[0])
7501        ? baseIntersection(mapped)
7502        : [];
7503    });
7504
7505    /**
7506     * This method is like `_.intersection` except that it accepts `iteratee`
7507     * which is invoked for each element of each `arrays` to generate the criterion
7508     * by which they're compared. The order and references of result values are
7509     * determined by the first array. The iteratee is invoked with one argument:
7510     * (value).
7511     *
7512     * @static
7513     * @memberOf _
7514     * @since 4.0.0
7515     * @category Array
7516     * @param {...Array} [arrays] The arrays to inspect.
7517     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7518     * @returns {Array} Returns the new array of intersecting values.
7519     * @example
7520     *
7521     * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7522     * // => [2.1]
7523     *
7524     * // The `_.property` iteratee shorthand.
7525     * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7526     * // => [{ 'x': 1 }]
7527     */
7528    var intersectionBy = baseRest(function(arrays) {
7529      var iteratee = last(arrays),
7530          mapped = arrayMap(arrays, castArrayLikeObject);
7531
7532      if (iteratee === last(mapped)) {
7533        iteratee = undefined;
7534      } else {
7535        mapped.pop();
7536      }
7537      return (mapped.length && mapped[0] === arrays[0])
7538        ? baseIntersection(mapped, getIteratee(iteratee, 2))
7539        : [];
7540    });
7541
7542    /**
7543     * This method is like `_.intersection` except that it accepts `comparator`
7544     * which is invoked to compare elements of `arrays`. The order and references
7545     * of result values are determined by the first array. The comparator is
7546     * invoked with two arguments: (arrVal, othVal).
7547     *
7548     * @static
7549     * @memberOf _
7550     * @since 4.0.0
7551     * @category Array
7552     * @param {...Array} [arrays] The arrays to inspect.
7553     * @param {Function} [comparator] The comparator invoked per element.
7554     * @returns {Array} Returns the new array of intersecting values.
7555     * @example
7556     *
7557     * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7558     * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7559     *
7560     * _.intersectionWith(objects, others, _.isEqual);
7561     * // => [{ 'x': 1, 'y': 2 }]
7562     */
7563    var intersectionWith = baseRest(function(arrays) {
7564      var comparator = last(arrays),
7565          mapped = arrayMap(arrays, castArrayLikeObject);
7566
7567      comparator = typeof comparator == 'function' ? comparator : undefined;
7568      if (comparator) {
7569        mapped.pop();
7570      }
7571      return (mapped.length && mapped[0] === arrays[0])
7572        ? baseIntersection(mapped, undefined, comparator)
7573        : [];
7574    });
7575
7576    /**
7577     * Converts all elements in `array` into a string separated by `separator`.
7578     *
7579     * @static
7580     * @memberOf _
7581     * @since 4.0.0
7582     * @category Array
7583     * @param {Array} array The array to convert.
7584     * @param {string} [separator=','] The element separator.
7585     * @returns {string} Returns the joined string.
7586     * @example
7587     *
7588     * _.join(['a', 'b', 'c'], '~');
7589     * // => 'a~b~c'
7590     */
7591    function join(array, separator) {
7592      return array == null ? '' : nativeJoin.call(array, separator);
7593    }
7594
7595    /**
7596     * Gets the last element of `array`.
7597     *
7598     * @static
7599     * @memberOf _
7600     * @since 0.1.0
7601     * @category Array
7602     * @param {Array} array The array to query.
7603     * @returns {*} Returns the last element of `array`.
7604     * @example
7605     *
7606     * _.last([1, 2, 3]);
7607     * // => 3
7608     */
7609    function last(array) {
7610      var length = array == null ? 0 : array.length;
7611      return length ? array[length - 1] : undefined;
7612    }
7613
7614    /**
7615     * This method is like `_.indexOf` except that it iterates over elements of
7616     * `array` from right to left.
7617     *
7618     * @static
7619     * @memberOf _
7620     * @since 0.1.0
7621     * @category Array
7622     * @param {Array} array The array to inspect.
7623     * @param {*} value The value to search for.
7624     * @param {number} [fromIndex=array.length-1] The index to search from.
7625     * @returns {number} Returns the index of the matched value, else `-1`.
7626     * @example
7627     *
7628     * _.lastIndexOf([1, 2, 1, 2], 2);
7629     * // => 3
7630     *
7631     * // Search from the `fromIndex`.
7632     * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7633     * // => 1
7634     */
7635    function lastIndexOf(array, value, fromIndex) {
7636      var length = array == null ? 0 : array.length;
7637      if (!length) {
7638        return -1;
7639      }
7640      var index = length;
7641      if (fromIndex !== undefined) {
7642        index = toInteger(fromIndex);
7643        index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7644      }
7645      return value === value
7646        ? strictLastIndexOf(array, value, index)
7647        : baseFindIndex(array, baseIsNaN, index, true);
7648    }
7649
7650    /**
7651     * Gets the element at index `n` of `array`. If `n` is negative, the nth
7652     * element from the end is returned.
7653     *
7654     * @static
7655     * @memberOf _
7656     * @since 4.11.0
7657     * @category Array
7658     * @param {Array} array The array to query.
7659     * @param {number} [n=0] The index of the element to return.
7660     * @returns {*} Returns the nth element of `array`.
7661     * @example
7662     *
7663     * var array = ['a', 'b', 'c', 'd'];
7664     *
7665     * _.nth(array, 1);
7666     * // => 'b'
7667     *
7668     * _.nth(array, -2);
7669     * // => 'c';
7670     */
7671    function nth(array, n) {
7672      return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
7673    }
7674
7675    /**
7676     * Removes all given values from `array` using
7677     * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7678     * for equality comparisons.
7679     *
7680     * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
7681     * to remove elements from an array by predicate.
7682     *
7683     * @static
7684     * @memberOf _
7685     * @since 2.0.0
7686     * @category Array
7687     * @param {Array} array The array to modify.
7688     * @param {...*} [values] The values to remove.
7689     * @returns {Array} Returns `array`.
7690     * @example
7691     *
7692     * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7693     *
7694     * _.pull(array, 'a', 'c');
7695     * console.log(array);
7696     * // => ['b', 'b']
7697     */
7698    var pull = baseRest(pullAll);
7699
7700    /**
7701     * This method is like `_.pull` except that it accepts an array of values to remove.
7702     *
7703     * **Note:** Unlike `_.difference`, this method mutates `array`.
7704     *
7705     * @static
7706     * @memberOf _
7707     * @since 4.0.0
7708     * @category Array
7709     * @param {Array} array The array to modify.
7710     * @param {Array} values The values to remove.
7711     * @returns {Array} Returns `array`.
7712     * @example
7713     *
7714     * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7715     *
7716     * _.pullAll(array, ['a', 'c']);
7717     * console.log(array);
7718     * // => ['b', 'b']
7719     */
7720    function pullAll(array, values) {
7721      return (array && array.length && values && values.length)
7722        ? basePullAll(array, values)
7723        : array;
7724    }
7725
7726    /**
7727     * This method is like `_.pullAll` except that it accepts `iteratee` which is
7728     * invoked for each element of `array` and `values` to generate the criterion
7729     * by which they're compared. The iteratee is invoked with one argument: (value).
7730     *
7731     * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
7732     *
7733     * @static
7734     * @memberOf _
7735     * @since 4.0.0
7736     * @category Array
7737     * @param {Array} array The array to modify.
7738     * @param {Array} values The values to remove.
7739     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7740     * @returns {Array} Returns `array`.
7741     * @example
7742     *
7743     * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
7744     *
7745     * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
7746     * console.log(array);
7747     * // => [{ 'x': 2 }]
7748     */
7749    function pullAllBy(array, values, iteratee) {
7750      return (array && array.length && values && values.length)
7751        ? basePullAll(array, values, getIteratee(iteratee, 2))
7752        : array;
7753    }
7754
7755    /**
7756     * This method is like `_.pullAll` except that it accepts `comparator` which
7757     * is invoked to compare elements of `array` to `values`. The comparator is
7758     * invoked with two arguments: (arrVal, othVal).
7759     *
7760     * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
7761     *
7762     * @static
7763     * @memberOf _
7764     * @since 4.6.0
7765     * @category Array
7766     * @param {Array} array The array to modify.
7767     * @param {Array} values The values to remove.
7768     * @param {Function} [comparator] The comparator invoked per element.
7769     * @returns {Array} Returns `array`.
7770     * @example
7771     *
7772     * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
7773     *
7774     * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
7775     * console.log(array);
7776     * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
7777     */
7778    function pullAllWith(array, values, comparator) {
7779      return (array && array.length && values && values.length)
7780        ? basePullAll(array, values, undefined, comparator)
7781        : array;
7782    }
7783
7784    /**
7785     * Removes elements from `array` corresponding to `indexes` and returns an
7786     * array of removed elements.
7787     *
7788     * **Note:** Unlike `_.at`, this method mutates `array`.
7789     *
7790     * @static
7791     * @memberOf _
7792     * @since 3.0.0
7793     * @category Array
7794     * @param {Array} array The array to modify.
7795     * @param {...(number|number[])} [indexes] The indexes of elements to remove.
7796     * @returns {Array} Returns the new array of removed elements.
7797     * @example
7798     *
7799     * var array = ['a', 'b', 'c', 'd'];
7800     * var pulled = _.pullAt(array, [1, 3]);
7801     *
7802     * console.log(array);
7803     * // => ['a', 'c']
7804     *
7805     * console.log(pulled);
7806     * // => ['b', 'd']
7807     */
7808    var pullAt = flatRest(function(array, indexes) {
7809      var length = array == null ? 0 : array.length,
7810          result = baseAt(array, indexes);
7811
7812      basePullAt(array, arrayMap(indexes, function(index) {
7813        return isIndex(index, length) ? +index : index;
7814      }).sort(compareAscending));
7815
7816      return result;
7817    });
7818
7819    /**
7820     * Removes all elements from `array` that `predicate` returns truthy for
7821     * and returns an array of the removed elements. The predicate is invoked
7822     * with three arguments: (value, index, array).
7823     *
7824     * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
7825     * to pull elements from an array by value.
7826     *
7827     * @static
7828     * @memberOf _
7829     * @since 2.0.0
7830     * @category Array
7831     * @param {Array} array The array to modify.
7832     * @param {Function} [predicate=_.identity] The function invoked per iteration.
7833     * @returns {Array} Returns the new array of removed elements.
7834     * @example
7835     *
7836     * var array = [1, 2, 3, 4];
7837     * var evens = _.remove(array, function(n) {
7838     *   return n % 2 == 0;
7839     * });
7840     *
7841     * console.log(array);
7842     * // => [1, 3]
7843     *
7844     * console.log(evens);
7845     * // => [2, 4]
7846     */
7847    function remove(array, predicate) {
7848      var result = [];
7849      if (!(array && array.length)) {
7850        return result;
7851      }
7852      var index = -1,
7853          indexes = [],
7854          length = array.length;
7855
7856      predicate = getIteratee(predicate, 3);
7857      while (++index < length) {
7858        var value = array[index];
7859        if (predicate(value, index, array)) {
7860          result.push(value);
7861          indexes.push(index);
7862        }
7863      }
7864      basePullAt(array, indexes);
7865      return result;
7866    }
7867
7868    /**
7869     * Reverses `array` so that the first element becomes the last, the second
7870     * element becomes the second to last, and so on.
7871     *
7872     * **Note:** This method mutates `array` and is based on
7873     * [`Array#reverse`](https://mdn.io/Array/reverse).
7874     *
7875     * @static
7876     * @memberOf _
7877     * @since 4.0.0
7878     * @category Array
7879     * @param {Array} array The array to modify.
7880     * @returns {Array} Returns `array`.
7881     * @example
7882     *
7883     * var array = [1, 2, 3];
7884     *
7885     * _.reverse(array);
7886     * // => [3, 2, 1]
7887     *
7888     * console.log(array);
7889     * // => [3, 2, 1]
7890     */
7891    function reverse(array) {
7892      return array == null ? array : nativeReverse.call(array);
7893    }
7894
7895    /**
7896     * Creates a slice of `array` from `start` up to, but not including, `end`.
7897     *
7898     * **Note:** This method is used instead of
7899     * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
7900     * returned.
7901     *
7902     * @static
7903     * @memberOf _
7904     * @since 3.0.0
7905     * @category Array
7906     * @param {Array} array The array to slice.
7907     * @param {number} [start=0] The start position.
7908     * @param {number} [end=array.length] The end position.
7909     * @returns {Array} Returns the slice of `array`.
7910     */
7911    function slice(array, start, end) {
7912      var length = array == null ? 0 : array.length;
7913      if (!length) {
7914        return [];
7915      }
7916      if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
7917        start = 0;
7918        end = length;
7919      }
7920      else {
7921        start = start == null ? 0 : toInteger(start);
7922        end = end === undefined ? length : toInteger(end);
7923      }
7924      return baseSlice(array, start, end);
7925    }
7926
7927    /**
7928     * Uses a binary search to determine the lowest index at which `value`
7929     * should be inserted into `array` in order to maintain its sort order.
7930     *
7931     * @static
7932     * @memberOf _
7933     * @since 0.1.0
7934     * @category Array
7935     * @param {Array} array The sorted array to inspect.
7936     * @param {*} value The value to evaluate.
7937     * @returns {number} Returns the index at which `value` should be inserted
7938     *  into `array`.
7939     * @example
7940     *
7941     * _.sortedIndex([30, 50], 40);
7942     * // => 1
7943     */
7944    function sortedIndex(array, value) {
7945      return baseSortedIndex(array, value);
7946    }
7947
7948    /**
7949     * This method is like `_.sortedIndex` except that it accepts `iteratee`
7950     * which is invoked for `value` and each element of `array` to compute their
7951     * sort ranking. The iteratee is invoked with one argument: (value).
7952     *
7953     * @static
7954     * @memberOf _
7955     * @since 4.0.0
7956     * @category Array
7957     * @param {Array} array The sorted array to inspect.
7958     * @param {*} value The value to evaluate.
7959     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7960     * @returns {number} Returns the index at which `value` should be inserted
7961     *  into `array`.
7962     * @example
7963     *
7964     * var objects = [{ 'x': 4 }, { 'x': 5 }];
7965     *
7966     * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
7967     * // => 0
7968     *
7969     * // The `_.property` iteratee shorthand.
7970     * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
7971     * // => 0
7972     */
7973    function sortedIndexBy(array, value, iteratee) {
7974      return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
7975    }
7976
7977    /**
7978     * This method is like `_.indexOf` except that it performs a binary
7979     * search on a sorted `array`.
7980     *
7981     * @static
7982     * @memberOf _
7983     * @since 4.0.0
7984     * @category Array
7985     * @param {Array} array The array to inspect.
7986     * @param {*} value The value to search for.
7987     * @returns {number} Returns the index of the matched value, else `-1`.
7988     * @example
7989     *
7990     * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
7991     * // => 1
7992     */
7993    function sortedIndexOf(array, value) {
7994      var length = array == null ? 0 : array.length;
7995      if (length) {
7996        var index = baseSortedIndex(array, value);
7997        if (index < length && eq(array[index], value)) {
7998          return index;
7999        }
8000      }
8001      return -1;
8002    }
8003
8004    /**
8005     * This method is like `_.sortedIndex` except that it returns the highest
8006     * index at which `value` should be inserted into `array` in order to
8007     * maintain its sort order.
8008     *
8009     * @static
8010     * @memberOf _
8011     * @since 3.0.0
8012     * @category Array
8013     * @param {Array} array The sorted array to inspect.
8014     * @param {*} value The value to evaluate.
8015     * @returns {number} Returns the index at which `value` should be inserted
8016     *  into `array`.
8017     * @example
8018     *
8019     * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
8020     * // => 4
8021     */
8022    function sortedLastIndex(array, value) {
8023      return baseSortedIndex(array, value, true);
8024    }
8025
8026    /**
8027     * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
8028     * which is invoked for `value` and each element of `array` to compute their
8029     * sort ranking. The iteratee is invoked with one argument: (value).
8030     *
8031     * @static
8032     * @memberOf _
8033     * @since 4.0.0
8034     * @category Array
8035     * @param {Array} array The sorted array to inspect.
8036     * @param {*} value The value to evaluate.
8037     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8038     * @returns {number} Returns the index at which `value` should be inserted
8039     *  into `array`.
8040     * @example
8041     *
8042     * var objects = [{ 'x': 4 }, { 'x': 5 }];
8043     *
8044     * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8045     * // => 1
8046     *
8047     * // The `_.property` iteratee shorthand.
8048     * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8049     * // => 1
8050     */
8051    function sortedLastIndexBy(array, value, iteratee) {
8052      return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8053    }
8054
8055    /**
8056     * This method is like `_.lastIndexOf` except that it performs a binary
8057     * search on a sorted `array`.
8058     *
8059     * @static
8060     * @memberOf _
8061     * @since 4.0.0
8062     * @category Array
8063     * @param {Array} array The array to inspect.
8064     * @param {*} value The value to search for.
8065     * @returns {number} Returns the index of the matched value, else `-1`.
8066     * @example
8067     *
8068     * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8069     * // => 3
8070     */
8071    function sortedLastIndexOf(array, value) {
8072      var length = array == null ? 0 : array.length;
8073      if (length) {
8074        var index = baseSortedIndex(array, value, true) - 1;
8075        if (eq(array[index], value)) {
8076          return index;
8077        }
8078      }
8079      return -1;
8080    }
8081
8082    /**
8083     * This method is like `_.uniq` except that it's designed and optimized
8084     * for sorted arrays.
8085     *
8086     * @static
8087     * @memberOf _
8088     * @since 4.0.0
8089     * @category Array
8090     * @param {Array} array The array to inspect.
8091     * @returns {Array} Returns the new duplicate free array.
8092     * @example
8093     *
8094     * _.sortedUniq([1, 1, 2]);
8095     * // => [1, 2]
8096     */
8097    function sortedUniq(array) {
8098      return (array && array.length)
8099        ? baseSortedUniq(array)
8100        : [];
8101    }
8102
8103    /**
8104     * This method is like `_.uniqBy` except that it's designed and optimized
8105     * for sorted arrays.
8106     *
8107     * @static
8108     * @memberOf _
8109     * @since 4.0.0
8110     * @category Array
8111     * @param {Array} array The array to inspect.
8112     * @param {Function} [iteratee] The iteratee invoked per element.
8113     * @returns {Array} Returns the new duplicate free array.
8114     * @example
8115     *
8116     * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8117     * // => [1.1, 2.3]
8118     */
8119    function sortedUniqBy(array, iteratee) {
8120      return (array && array.length)
8121        ? baseSortedUniq(array, getIteratee(iteratee, 2))
8122        : [];
8123    }
8124
8125    /**
8126     * Gets all but the first element of `array`.
8127     *
8128     * @static
8129     * @memberOf _
8130     * @since 4.0.0
8131     * @category Array
8132     * @param {Array} array The array to query.
8133     * @returns {Array} Returns the slice of `array`.
8134     * @example
8135     *
8136     * _.tail([1, 2, 3]);
8137     * // => [2, 3]
8138     */
8139    function tail(array) {
8140      var length = array == null ? 0 : array.length;
8141      return length ? baseSlice(array, 1, length) : [];
8142    }
8143
8144    /**
8145     * Creates a slice of `array` with `n` elements taken from the beginning.
8146     *
8147     * @static
8148     * @memberOf _
8149     * @since 0.1.0
8150     * @category Array
8151     * @param {Array} array The array to query.
8152     * @param {number} [n=1] The number of elements to take.
8153     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8154     * @returns {Array} Returns the slice of `array`.
8155     * @example
8156     *
8157     * _.take([1, 2, 3]);
8158     * // => [1]
8159     *
8160     * _.take([1, 2, 3], 2);
8161     * // => [1, 2]
8162     *
8163     * _.take([1, 2, 3], 5);
8164     * // => [1, 2, 3]
8165     *
8166     * _.take([1, 2, 3], 0);
8167     * // => []
8168     */
8169    function take(array, n, guard) {
8170      if (!(array && array.length)) {
8171        return [];
8172      }
8173      n = (guard || n === undefined) ? 1 : toInteger(n);
8174      return baseSlice(array, 0, n < 0 ? 0 : n);
8175    }
8176
8177    /**
8178     * Creates a slice of `array` with `n` elements taken from the end.
8179     *
8180     * @static
8181     * @memberOf _
8182     * @since 3.0.0
8183     * @category Array
8184     * @param {Array} array The array to query.
8185     * @param {number} [n=1] The number of elements to take.
8186     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8187     * @returns {Array} Returns the slice of `array`.
8188     * @example
8189     *
8190     * _.takeRight([1, 2, 3]);
8191     * // => [3]
8192     *
8193     * _.takeRight([1, 2, 3], 2);
8194     * // => [2, 3]
8195     *
8196     * _.takeRight([1, 2, 3], 5);
8197     * // => [1, 2, 3]
8198     *
8199     * _.takeRight([1, 2, 3], 0);
8200     * // => []
8201     */
8202    function takeRight(array, n, guard) {
8203      var length = array == null ? 0 : array.length;
8204      if (!length) {
8205        return [];
8206      }
8207      n = (guard || n === undefined) ? 1 : toInteger(n);
8208      n = length - n;
8209      return baseSlice(array, n < 0 ? 0 : n, length);
8210    }
8211
8212    /**
8213     * Creates a slice of `array` with elements taken from the end. Elements are
8214     * taken until `predicate` returns falsey. The predicate is invoked with
8215     * three arguments: (value, index, array).
8216     *
8217     * @static
8218     * @memberOf _
8219     * @since 3.0.0
8220     * @category Array
8221     * @param {Array} array The array to query.
8222     * @param {Function} [predicate=_.identity] The function invoked per iteration.
8223     * @returns {Array} Returns the slice of `array`.
8224     * @example
8225     *
8226     * var users = [
8227     *   { 'user': 'barney',  'active': true },
8228     *   { 'user': 'fred',    'active': false },
8229     *   { 'user': 'pebbles', 'active': false }
8230     * ];
8231     *
8232     * _.takeRightWhile(users, function(o) { return !o.active; });
8233     * // => objects for ['fred', 'pebbles']
8234     *
8235     * // The `_.matches` iteratee shorthand.
8236     * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8237     * // => objects for ['pebbles']
8238     *
8239     * // The `_.matchesProperty` iteratee shorthand.
8240     * _.takeRightWhile(users, ['active', false]);
8241     * // => objects for ['fred', 'pebbles']
8242     *
8243     * // The `_.property` iteratee shorthand.
8244     * _.takeRightWhile(users, 'active');
8245     * // => []
8246     */
8247    function takeRightWhile(array, predicate) {
8248      return (array && array.length)
8249        ? baseWhile(array, getIteratee(predicate, 3), false, true)
8250        : [];
8251    }
8252
8253    /**
8254     * Creates a slice of `array` with elements taken from the beginning. Elements
8255     * are taken until `predicate` returns falsey. The predicate is invoked with
8256     * three arguments: (value, index, array).
8257     *
8258     * @static
8259     * @memberOf _
8260     * @since 3.0.0
8261     * @category Array
8262     * @param {Array} array The array to query.
8263     * @param {Function} [predicate=_.identity] The function invoked per iteration.
8264     * @returns {Array} Returns the slice of `array`.
8265     * @example
8266     *
8267     * var users = [
8268     *   { 'user': 'barney',  'active': false },
8269     *   { 'user': 'fred',    'active': false },
8270     *   { 'user': 'pebbles', 'active': true }
8271     * ];
8272     *
8273     * _.takeWhile(users, function(o) { return !o.active; });
8274     * // => objects for ['barney', 'fred']
8275     *
8276     * // The `_.matches` iteratee shorthand.
8277     * _.takeWhile(users, { 'user': 'barney', 'active': false });
8278     * // => objects for ['barney']
8279     *
8280     * // The `_.matchesProperty` iteratee shorthand.
8281     * _.takeWhile(users, ['active', false]);
8282     * // => objects for ['barney', 'fred']
8283     *
8284     * // The `_.property` iteratee shorthand.
8285     * _.takeWhile(users, 'active');
8286     * // => []
8287     */
8288    function takeWhile(array, predicate) {
8289      return (array && array.length)
8290        ? baseWhile(array, getIteratee(predicate, 3))
8291        : [];
8292    }
8293
8294    /**
8295     * Creates an array of unique values, in order, from all given arrays using
8296     * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8297     * for equality comparisons.
8298     *
8299     * @static
8300     * @memberOf _
8301     * @since 0.1.0
8302     * @category Array
8303     * @param {...Array} [arrays] The arrays to inspect.
8304     * @returns {Array} Returns the new array of combined values.
8305     * @example
8306     *
8307     * _.union([2], [1, 2]);
8308     * // => [2, 1]
8309     */
8310    var union = baseRest(function(arrays) {
8311      return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8312    });
8313
8314    /**
8315     * This method is like `_.union` except that it accepts `iteratee` which is
8316     * invoked for each element of each `arrays` to generate the criterion by
8317     * which uniqueness is computed. Result values are chosen from the first
8318     * array in which the value occurs. The iteratee is invoked with one argument:
8319     * (value).
8320     *
8321     * @static
8322     * @memberOf _
8323     * @since 4.0.0
8324     * @category Array
8325     * @param {...Array} [arrays] The arrays to inspect.
8326     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8327     * @returns {Array} Returns the new array of combined values.
8328     * @example
8329     *
8330     * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8331     * // => [2.1, 1.2]
8332     *
8333     * // The `_.property` iteratee shorthand.
8334     * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8335     * // => [{ 'x': 1 }, { 'x': 2 }]
8336     */
8337    var unionBy = baseRest(function(arrays) {
8338      var iteratee = last(arrays);
8339      if (isArrayLikeObject(iteratee)) {
8340        iteratee = undefined;
8341      }
8342      return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
8343    });
8344
8345    /**
8346     * This method is like `_.union` except that it accepts `comparator` which
8347     * is invoked to compare elements of `arrays`. Result values are chosen from
8348     * the first array in which the value occurs. The comparator is invoked
8349     * with two arguments: (arrVal, othVal).
8350     *
8351     * @static
8352     * @memberOf _
8353     * @since 4.0.0
8354     * @category Array
8355     * @param {...Array} [arrays] The arrays to inspect.
8356     * @param {Function} [comparator] The comparator invoked per element.
8357     * @returns {Array} Returns the new array of combined values.
8358     * @example
8359     *
8360     * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8361     * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8362     *
8363     * _.unionWith(objects, others, _.isEqual);
8364     * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8365     */
8366    var unionWith = baseRest(function(arrays) {
8367      var comparator = last(arrays);
8368      comparator = typeof comparator == 'function' ? comparator : undefined;
8369      return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
8370    });
8371
8372    /**
8373     * Creates a duplicate-free version of an array, using
8374     * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8375     * for equality comparisons, in which only the first occurrence of each element
8376     * is kept. The order of result values is determined by the order they occur
8377     * in the array.
8378     *
8379     * @static
8380     * @memberOf _
8381     * @since 0.1.0
8382     * @category Array
8383     * @param {Array} array The array to inspect.
8384     * @returns {Array} Returns the new duplicate free array.
8385     * @example
8386     *
8387     * _.uniq([2, 1, 2]);
8388     * // => [2, 1]
8389     */
8390    function uniq(array) {
8391      return (array && array.length) ? baseUniq(array) : [];
8392    }
8393
8394    /**
8395     * This method is like `_.uniq` except that it accepts `iteratee` which is
8396     * invoked for each element in `array` to generate the criterion by which
8397     * uniqueness is computed. The order of result values is determined by the
8398     * order they occur in the array. The iteratee is invoked with one argument:
8399     * (value).
8400     *
8401     * @static
8402     * @memberOf _
8403     * @since 4.0.0
8404     * @category Array
8405     * @param {Array} array The array to inspect.
8406     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8407     * @returns {Array} Returns the new duplicate free array.
8408     * @example
8409     *
8410     * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8411     * // => [2.1, 1.2]
8412     *
8413     * // The `_.property` iteratee shorthand.
8414     * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8415     * // => [{ 'x': 1 }, { 'x': 2 }]
8416     */
8417    function uniqBy(array, iteratee) {
8418      return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
8419    }
8420
8421    /**
8422     * This method is like `_.uniq` except that it accepts `comparator` which
8423     * is invoked to compare elements of `array`. The order of result values is
8424     * determined by the order they occur in the array.The comparator is invoked
8425     * with two arguments: (arrVal, othVal).
8426     *
8427     * @static
8428     * @memberOf _
8429     * @since 4.0.0
8430     * @category Array
8431     * @param {Array} array The array to inspect.
8432     * @param {Function} [comparator] The comparator invoked per element.
8433     * @returns {Array} Returns the new duplicate free array.
8434     * @example
8435     *
8436     * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8437     *
8438     * _.uniqWith(objects, _.isEqual);
8439     * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8440     */
8441    function uniqWith(array, comparator) {
8442      comparator = typeof comparator == 'function' ? comparator : undefined;
8443      return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
8444    }
8445
8446    /**
8447     * This method is like `_.zip` except that it accepts an array of grouped
8448     * elements and creates an array regrouping the elements to their pre-zip
8449     * configuration.
8450     *
8451     * @static
8452     * @memberOf _
8453     * @since 1.2.0
8454     * @category Array
8455     * @param {Array} array The array of grouped elements to process.
8456     * @returns {Array} Returns the new array of regrouped elements.
8457     * @example
8458     *
8459     * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8460     * // => [['a', 1, true], ['b', 2, false]]
8461     *
8462     * _.unzip(zipped);
8463     * // => [['a', 'b'], [1, 2], [true, false]]
8464     */
8465    function unzip(array) {
8466      if (!(array && array.length)) {
8467        return [];
8468      }
8469      var length = 0;
8470      array = arrayFilter(array, function(group) {
8471        if (isArrayLikeObject(group)) {
8472          length = nativeMax(group.length, length);
8473          return true;
8474        }
8475      });
8476      return baseTimes(length, function(index) {
8477        return arrayMap(array, baseProperty(index));
8478      });
8479    }
8480
8481    /**
8482     * This method is like `_.unzip` except that it accepts `iteratee` to specify
8483     * how regrouped values should be combined. The iteratee is invoked with the
8484     * elements of each group: (...group).
8485     *
8486     * @static
8487     * @memberOf _
8488     * @since 3.8.0
8489     * @category Array
8490     * @param {Array} array The array of grouped elements to process.
8491     * @param {Function} [iteratee=_.identity] The function to combine
8492     *  regrouped values.
8493     * @returns {Array} Returns the new array of regrouped elements.
8494     * @example
8495     *
8496     * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8497     * // => [[1, 10, 100], [2, 20, 200]]
8498     *
8499     * _.unzipWith(zipped, _.add);
8500     * // => [3, 30, 300]
8501     */
8502    function unzipWith(array, iteratee) {
8503      if (!(array && array.length)) {
8504        return [];
8505      }
8506      var result = unzip(array);
8507      if (iteratee == null) {
8508        return result;
8509      }
8510      return arrayMap(result, function(group) {
8511        return apply(iteratee, undefined, group);
8512      });
8513    }
8514
8515    /**
8516     * Creates an array excluding all given values using
8517     * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8518     * for equality comparisons.
8519     *
8520     * **Note:** Unlike `_.pull`, this method returns a new array.
8521     *
8522     * @static
8523     * @memberOf _
8524     * @since 0.1.0
8525     * @category Array
8526     * @param {Array} array The array to inspect.
8527     * @param {...*} [values] The values to exclude.
8528     * @returns {Array} Returns the new array of filtered values.
8529     * @see _.difference, _.xor
8530     * @example
8531     *
8532     * _.without([2, 1, 2, 3], 1, 2);
8533     * // => [3]
8534     */
8535    var without = baseRest(function(array, values) {
8536      return isArrayLikeObject(array)
8537        ? baseDifference(array, values)
8538        : [];
8539    });
8540
8541    /**
8542     * Creates an array of unique values that is the
8543     * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
8544     * of the given arrays. The order of result values is determined by the order
8545     * they occur in the arrays.
8546     *
8547     * @static
8548     * @memberOf _
8549     * @since 2.4.0
8550     * @category Array
8551     * @param {...Array} [arrays] The arrays to inspect.
8552     * @returns {Array} Returns the new array of filtered values.
8553     * @see _.difference, _.without
8554     * @example
8555     *
8556     * _.xor([2, 1], [2, 3]);
8557     * // => [1, 3]
8558     */
8559    var xor = baseRest(function(arrays) {
8560      return baseXor(arrayFilter(arrays, isArrayLikeObject));
8561    });
8562
8563    /**
8564     * This method is like `_.xor` except that it accepts `iteratee` which is
8565     * invoked for each element of each `arrays` to generate the criterion by
8566     * which by which they're compared. The order of result values is determined
8567     * by the order they occur in the arrays. The iteratee is invoked with one
8568     * argument: (value).
8569     *
8570     * @static
8571     * @memberOf _
8572     * @since 4.0.0
8573     * @category Array
8574     * @param {...Array} [arrays] The arrays to inspect.
8575     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8576     * @returns {Array} Returns the new array of filtered values.
8577     * @example
8578     *
8579     * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8580     * // => [1.2, 3.4]
8581     *
8582     * // The `_.property` iteratee shorthand.
8583     * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8584     * // => [{ 'x': 2 }]
8585     */
8586    var xorBy = baseRest(function(arrays) {
8587      var iteratee = last(arrays);
8588      if (isArrayLikeObject(iteratee)) {
8589        iteratee = undefined;
8590      }
8591      return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
8592    });
8593
8594    /**
8595     * This method is like `_.xor` except that it accepts `comparator` which is
8596     * invoked to compare elements of `arrays`. The order of result values is
8597     * determined by the order they occur in the arrays. The comparator is invoked
8598     * with two arguments: (arrVal, othVal).
8599     *
8600     * @static
8601     * @memberOf _
8602     * @since 4.0.0
8603     * @category Array
8604     * @param {...Array} [arrays] The arrays to inspect.
8605     * @param {Function} [comparator] The comparator invoked per element.
8606     * @returns {Array} Returns the new array of filtered values.
8607     * @example
8608     *
8609     * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8610     * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8611     *
8612     * _.xorWith(objects, others, _.isEqual);
8613     * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8614     */
8615    var xorWith = baseRest(function(arrays) {
8616      var comparator = last(arrays);
8617      comparator = typeof comparator == 'function' ? comparator : undefined;
8618      return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
8619    });
8620
8621    /**
8622     * Creates an array of grouped elements, the first of which contains the
8623     * first elements of the given arrays, the second of which contains the
8624     * second elements of the given arrays, and so on.
8625     *
8626     * @static
8627     * @memberOf _
8628     * @since 0.1.0
8629     * @category Array
8630     * @param {...Array} [arrays] The arrays to process.
8631     * @returns {Array} Returns the new array of grouped elements.
8632     * @example
8633     *
8634     * _.zip(['a', 'b'], [1, 2], [true, false]);
8635     * // => [['a', 1, true], ['b', 2, false]]
8636     */
8637    var zip = baseRest(unzip);
8638
8639    /**
8640     * This method is like `_.fromPairs` except that it accepts two arrays,
8641     * one of property identifiers and one of corresponding values.
8642     *
8643     * @static
8644     * @memberOf _
8645     * @since 0.4.0
8646     * @category Array
8647     * @param {Array} [props=[]] The property identifiers.
8648     * @param {Array} [values=[]] The property values.
8649     * @returns {Object} Returns the new object.
8650     * @example
8651     *
8652     * _.zipObject(['a', 'b'], [1, 2]);
8653     * // => { 'a': 1, 'b': 2 }
8654     */
8655    function zipObject(props, values) {
8656      return baseZipObject(props || [], values || [], assignValue);
8657    }
8658
8659    /**
8660     * This method is like `_.zipObject` except that it supports property paths.
8661     *
8662     * @static
8663     * @memberOf _
8664     * @since 4.1.0
8665     * @category Array
8666     * @param {Array} [props=[]] The property identifiers.
8667     * @param {Array} [values=[]] The property values.
8668     * @returns {Object} Returns the new object.
8669     * @example
8670     *
8671     * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
8672     * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
8673     */
8674    function zipObjectDeep(props, values) {
8675      return baseZipObject(props || [], values || [], baseSet);
8676    }
8677
8678    /**
8679     * This method is like `_.zip` except that it accepts `iteratee` to specify
8680     * how grouped values should be combined. The iteratee is invoked with the
8681     * elements of each group: (...group).
8682     *
8683     * @static
8684     * @memberOf _
8685     * @since 3.8.0
8686     * @category Array
8687     * @param {...Array} [arrays] The arrays to process.
8688     * @param {Function} [iteratee=_.identity] The function to combine
8689     *  grouped values.
8690     * @returns {Array} Returns the new array of grouped elements.
8691     * @example
8692     *
8693     * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
8694     *   return a + b + c;
8695     * });
8696     * // => [111, 222]
8697     */
8698    var zipWith = baseRest(function(arrays) {
8699      var length = arrays.length,
8700          iteratee = length > 1 ? arrays[length - 1] : undefined;
8701
8702      iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
8703      return unzipWith(arrays, iteratee);
8704    });
8705
8706    /*------------------------------------------------------------------------*/
8707
8708    /**
8709     * Creates a `lodash` wrapper instance that wraps `value` with explicit method
8710     * chain sequences enabled. The result of such sequences must be unwrapped
8711     * with `_#value`.
8712     *
8713     * @static
8714     * @memberOf _
8715     * @since 1.3.0
8716     * @category Seq
8717     * @param {*} value The value to wrap.
8718     * @returns {Object} Returns the new `lodash` wrapper instance.
8719     * @example
8720     *
8721     * var users = [
8722     *   { 'user': 'barney',  'age': 36 },
8723     *   { 'user': 'fred',    'age': 40 },
8724     *   { 'user': 'pebbles', 'age': 1 }
8725     * ];
8726     *
8727     * var youngest = _
8728     *   .chain(users)
8729     *   .sortBy('age')
8730     *   .map(function(o) {
8731     *     return o.user + ' is ' + o.age;
8732     *   })
8733     *   .head()
8734     *   .value();
8735     * // => 'pebbles is 1'
8736     */
8737    function chain(value) {
8738      var result = lodash(value);
8739      result.__chain__ = true;
8740      return result;
8741    }
8742
8743    /**
8744     * This method invokes `interceptor` and returns `value`. The interceptor
8745     * is invoked with one argument; (value). The purpose of this method is to
8746     * "tap into" a method chain sequence in order to modify intermediate results.
8747     *
8748     * @static
8749     * @memberOf _
8750     * @since 0.1.0
8751     * @category Seq
8752     * @param {*} value The value to provide to `interceptor`.
8753     * @param {Function} interceptor The function to invoke.
8754     * @returns {*} Returns `value`.
8755     * @example
8756     *
8757     * _([1, 2, 3])
8758     *  .tap(function(array) {
8759     *    // Mutate input array.
8760     *    array.pop();
8761     *  })
8762     *  .reverse()
8763     *  .value();
8764     * // => [2, 1]
8765     */
8766    function tap(value, interceptor) {
8767      interceptor(value);
8768      return value;
8769    }
8770
8771    /**
8772     * This method is like `_.tap` except that it returns the result of `interceptor`.
8773     * The purpose of this method is to "pass thru" values replacing intermediate
8774     * results in a method chain sequence.
8775     *
8776     * @static
8777     * @memberOf _
8778     * @since 3.0.0
8779     * @category Seq
8780     * @param {*} value The value to provide to `interceptor`.
8781     * @param {Function} interceptor The function to invoke.
8782     * @returns {*} Returns the result of `interceptor`.
8783     * @example
8784     *
8785     * _('  abc  ')
8786     *  .chain()
8787     *  .trim()
8788     *  .thru(function(value) {
8789     *    return [value];
8790     *  })
8791     *  .value();
8792     * // => ['abc']
8793     */
8794    function thru(value, interceptor) {
8795      return interceptor(value);
8796    }
8797
8798    /**
8799     * This method is the wrapper version of `_.at`.
8800     *
8801     * @name at
8802     * @memberOf _
8803     * @since 1.0.0
8804     * @category Seq
8805     * @param {...(string|string[])} [paths] The property paths to pick.
8806     * @returns {Object} Returns the new `lodash` wrapper instance.
8807     * @example
8808     *
8809     * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
8810     *
8811     * _(object).at(['a[0].b.c', 'a[1]']).value();
8812     * // => [3, 4]
8813     */
8814    var wrapperAt = flatRest(function(paths) {
8815      var length = paths.length,
8816          start = length ? paths[0] : 0,
8817          value = this.__wrapped__,
8818          interceptor = function(object) { return baseAt(object, paths); };
8819
8820      if (length > 1 || this.__actions__.length ||
8821          !(value instanceof LazyWrapper) || !isIndex(start)) {
8822        return this.thru(interceptor);
8823      }
8824      value = value.slice(start, +start + (length ? 1 : 0));
8825      value.__actions__.push({
8826        'func': thru,
8827        'args': [interceptor],
8828        'thisArg': undefined
8829      });
8830      return new LodashWrapper(value, this.__chain__).thru(function(array) {
8831        if (length && !array.length) {
8832          array.push(undefined);
8833        }
8834        return array;
8835      });
8836    });
8837
8838    /**
8839     * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
8840     *
8841     * @name chain
8842     * @memberOf _
8843     * @since 0.1.0
8844     * @category Seq
8845     * @returns {Object} Returns the new `lodash` wrapper instance.
8846     * @example
8847     *
8848     * var users = [
8849     *   { 'user': 'barney', 'age': 36 },
8850     *   { 'user': 'fred',   'age': 40 }
8851     * ];
8852     *
8853     * // A sequence without explicit chaining.
8854     * _(users).head();
8855     * // => { 'user': 'barney', 'age': 36 }
8856     *
8857     * // A sequence with explicit chaining.
8858     * _(users)
8859     *   .chain()
8860     *   .head()
8861     *   .pick('user')
8862     *   .value();
8863     * // => { 'user': 'barney' }
8864     */
8865    function wrapperChain() {
8866      return chain(this);
8867    }
8868
8869    /**
8870     * Executes the chain sequence and returns the wrapped result.
8871     *
8872     * @name commit
8873     * @memberOf _
8874     * @since 3.2.0
8875     * @category Seq
8876     * @returns {Object} Returns the new `lodash` wrapper instance.
8877     * @example
8878     *
8879     * var array = [1, 2];
8880     * var wrapped = _(array).push(3);
8881     *
8882     * console.log(array);
8883     * // => [1, 2]
8884     *
8885     * wrapped = wrapped.commit();
8886     * console.log(array);
8887     * // => [1, 2, 3]
8888     *
8889     * wrapped.last();
8890     * // => 3
8891     *
8892     * console.log(array);
8893     * // => [1, 2, 3]
8894     */
8895    function wrapperCommit() {
8896      return new LodashWrapper(this.value(), this.__chain__);
8897    }
8898
8899    /**
8900     * Gets the next value on a wrapped object following the
8901     * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
8902     *
8903     * @name next
8904     * @memberOf _
8905     * @since 4.0.0
8906     * @category Seq
8907     * @returns {Object} Returns the next iterator value.
8908     * @example
8909     *
8910     * var wrapped = _([1, 2]);
8911     *
8912     * wrapped.next();
8913     * // => { 'done': false, 'value': 1 }
8914     *
8915     * wrapped.next();
8916     * // => { 'done': false, 'value': 2 }
8917     *
8918     * wrapped.next();
8919     * // => { 'done': true, 'value': undefined }
8920     */
8921    function wrapperNext() {
8922      if (this.__values__ === undefined) {
8923        this.__values__ = toArray(this.value());
8924      }
8925      var done = this.__index__ >= this.__values__.length,
8926          value = done ? undefined : this.__values__[this.__index__++];
8927
8928      return { 'done': done, 'value': value };
8929    }
8930
8931    /**
8932     * Enables the wrapper to be iterable.
8933     *
8934     * @name Symbol.iterator
8935     * @memberOf _
8936     * @since 4.0.0
8937     * @category Seq
8938     * @returns {Object} Returns the wrapper object.
8939     * @example
8940     *
8941     * var wrapped = _([1, 2]);
8942     *
8943     * wrapped[Symbol.iterator]() === wrapped;
8944     * // => true
8945     *
8946     * Array.from(wrapped);
8947     * // => [1, 2]
8948     */
8949    function wrapperToIterator() {
8950      return this;
8951    }
8952
8953    /**
8954     * Creates a clone of the chain sequence planting `value` as the wrapped value.
8955     *
8956     * @name plant
8957     * @memberOf _
8958     * @since 3.2.0
8959     * @category Seq
8960     * @param {*} value The value to plant.
8961     * @returns {Object} Returns the new `lodash` wrapper instance.
8962     * @example
8963     *
8964     * function square(n) {
8965     *   return n * n;
8966     * }
8967     *
8968     * var wrapped = _([1, 2]).map(square);
8969     * var other = wrapped.plant([3, 4]);
8970     *
8971     * other.value();
8972     * // => [9, 16]
8973     *
8974     * wrapped.value();
8975     * // => [1, 4]
8976     */
8977    function wrapperPlant(value) {
8978      var result,
8979          parent = this;
8980
8981      while (parent instanceof baseLodash) {
8982        var clone = wrapperClone(parent);
8983        clone.__index__ = 0;
8984        clone.__values__ = undefined;
8985        if (result) {
8986          previous.__wrapped__ = clone;
8987        } else {
8988          result = clone;
8989        }
8990        var previous = clone;
8991        parent = parent.__wrapped__;
8992      }
8993      previous.__wrapped__ = value;
8994      return result;
8995    }
8996
8997    /**
8998     * This method is the wrapper version of `_.reverse`.
8999     *
9000     * **Note:** This method mutates the wrapped array.
9001     *
9002     * @name reverse
9003     * @memberOf _
9004     * @since 0.1.0
9005     * @category Seq
9006     * @returns {Object} Returns the new `lodash` wrapper instance.
9007     * @example
9008     *
9009     * var array = [1, 2, 3];
9010     *
9011     * _(array).reverse().value()
9012     * // => [3, 2, 1]
9013     *
9014     * console.log(array);
9015     * // => [3, 2, 1]
9016     */
9017    function wrapperReverse() {
9018      var value = this.__wrapped__;
9019      if (value instanceof LazyWrapper) {
9020        var wrapped = value;
9021        if (this.__actions__.length) {
9022          wrapped = new LazyWrapper(this);
9023        }
9024        wrapped = wrapped.reverse();
9025        wrapped.__actions__.push({
9026          'func': thru,
9027          'args': [reverse],
9028          'thisArg': undefined
9029        });
9030        return new LodashWrapper(wrapped, this.__chain__);
9031      }
9032      return this.thru(reverse);
9033    }
9034
9035    /**
9036     * Executes the chain sequence to resolve the unwrapped value.
9037     *
9038     * @name value
9039     * @memberOf _
9040     * @since 0.1.0
9041     * @alias toJSON, valueOf
9042     * @category Seq
9043     * @returns {*} Returns the resolved unwrapped value.
9044     * @example
9045     *
9046     * _([1, 2, 3]).value();
9047     * // => [1, 2, 3]
9048     */
9049    function wrapperValue() {
9050      return baseWrapperValue(this.__wrapped__, this.__actions__);
9051    }
9052
9053    /*------------------------------------------------------------------------*/
9054
9055    /**
9056     * Creates an object composed of keys generated from the results of running
9057     * each element of `collection` thru `iteratee`. The corresponding value of
9058     * each key is the number of times the key was returned by `iteratee`. The
9059     * iteratee is invoked with one argument: (value).
9060     *
9061     * @static
9062     * @memberOf _
9063     * @since 0.5.0
9064     * @category Collection
9065     * @param {Array|Object} collection The collection to iterate over.
9066     * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9067     * @returns {Object} Returns the composed aggregate object.
9068     * @example
9069     *
9070     * _.countBy([6.1, 4.2, 6.3], Math.floor);
9071     * // => { '4': 1, '6': 2 }
9072     *
9073     * // The `_.property` iteratee shorthand.
9074     * _.countBy(['one', 'two', 'three'], 'length');
9075     * // => { '3': 2, '5': 1 }
9076     */
9077    var countBy = createAggregator(function(result, value, key) {
9078      if (hasOwnProperty.call(result, key)) {
9079        ++result[key];
9080      } else {
9081        baseAssignValue(result, key, 1);
9082      }
9083    });
9084
9085    /**
9086     * Checks if `predicate` returns truthy for **all** elements of `collection`.
9087     * Iteration is stopped once `predicate` returns falsey. The predicate is
9088     * invoked with three arguments: (value, index|key, collection).
9089     *
9090     * **Note:** This method returns `true` for
9091     * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
9092     * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
9093     * elements of empty collections.
9094     *
9095     * @static
9096     * @memberOf _
9097     * @since 0.1.0
9098     * @category Collection
9099     * @param {Array|Object} collection The collection to iterate over.
9100     * @param {Function} [predicate=_.identity] The function invoked per iteration.
9101     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9102     * @returns {boolean} Returns `true` if all elements pass the predicate check,
9103     *  else `false`.
9104     * @example
9105     *
9106     * _.every([true, 1, null, 'yes'], Boolean);
9107     * // => false
9108     *
9109     * var users = [
9110     *   { 'user': 'barney', 'age': 36, 'active': false },
9111     *   { 'user': 'fred',   'age': 40, 'active': false }
9112     * ];
9113     *
9114     * // The `_.matches` iteratee shorthand.
9115     * _.every(users, { 'user': 'barney', 'active': false });
9116     * // => false
9117     *
9118     * // The `_.matchesProperty` iteratee shorthand.
9119     * _.every(users, ['active', false]);
9120     * // => true
9121     *
9122     * // The `_.property` iteratee shorthand.
9123     * _.every(users, 'active');
9124     * // => false
9125     */
9126    function every(collection, predicate, guard) {
9127      var func = isArray(collection) ? arrayEvery : baseEvery;
9128      if (guard && isIterateeCall(collection, predicate, guard)) {
9129        predicate = undefined;
9130      }
9131      return func(collection, getIteratee(predicate, 3));
9132    }
9133
9134    /**
9135     * Iterates over elements of `collection`, returning an array of all elements
9136     * `predicate` returns truthy for. The predicate is invoked with three
9137     * arguments: (value, index|key, collection).
9138     *
9139     * **Note:** Unlike `_.remove`, this method returns a new array.
9140     *
9141     * @static
9142     * @memberOf _
9143     * @since 0.1.0
9144     * @category Collection
9145     * @param {Array|Object} collection The collection to iterate over.
9146     * @param {Function} [predicate=_.identity] The function invoked per iteration.
9147     * @returns {Array} Returns the new filtered array.
9148     * @see _.reject
9149     * @example
9150     *
9151     * var users = [
9152     *   { 'user': 'barney', 'age': 36, 'active': true },
9153     *   { 'user': 'fred',   'age': 40, 'active': false }
9154     * ];
9155     *
9156     * _.filter(users, function(o) { return !o.active; });
9157     * // => objects for ['fred']
9158     *
9159     * // The `_.matches` iteratee shorthand.
9160     * _.filter(users, { 'age': 36, 'active': true });
9161     * // => objects for ['barney']
9162     *
9163     * // The `_.matchesProperty` iteratee shorthand.
9164     * _.filter(users, ['active', false]);
9165     * // => objects for ['fred']
9166     *
9167     * // The `_.property` iteratee shorthand.
9168     * _.filter(users, 'active');
9169     * // => objects for ['barney']
9170     */
9171    function filter(collection, predicate) {
9172      var func = isArray(collection) ? arrayFilter : baseFilter;
9173      return func(collection, getIteratee(predicate, 3));
9174    }
9175
9176    /**
9177     * Iterates over elements of `collection`, returning the first element
9178     * `predicate` returns truthy for. The predicate is invoked with three
9179     * arguments: (value, index|key, collection).
9180     *
9181     * @static
9182     * @memberOf _
9183     * @since 0.1.0
9184     * @category Collection
9185     * @param {Array|Object} collection The collection to inspect.
9186     * @param {Function} [predicate=_.identity] The function invoked per iteration.
9187     * @param {number} [fromIndex=0] The index to search from.
9188     * @returns {*} Returns the matched element, else `undefined`.
9189     * @example
9190     *
9191     * var users = [
9192     *   { 'user': 'barney',  'age': 36, 'active': true },
9193     *   { 'user': 'fred',    'age': 40, 'active': false },
9194     *   { 'user': 'pebbles', 'age': 1,  'active': true }
9195     * ];
9196     *
9197     * _.find(users, function(o) { return o.age < 40; });
9198     * // => object for 'barney'
9199     *
9200     * // The `_.matches` iteratee shorthand.
9201     * _.find(users, { 'age': 1, 'active': true });
9202     * // => object for 'pebbles'
9203     *
9204     * // The `_.matchesProperty` iteratee shorthand.
9205     * _.find(users, ['active', false]);
9206     * // => object for 'fred'
9207     *
9208     * // The `_.property` iteratee shorthand.
9209     * _.find(users, 'active');
9210     * // => object for 'barney'
9211     */
9212    var find = createFind(findIndex);
9213
9214    /**
9215     * This method is like `_.find` except that it iterates over elements of
9216     * `collection` from right to left.
9217     *
9218     * @static
9219     * @memberOf _
9220     * @since 2.0.0
9221     * @category Collection
9222     * @param {Array|Object} collection The collection to inspect.
9223     * @param {Function} [predicate=_.identity] The function invoked per iteration.
9224     * @param {number} [fromIndex=collection.length-1] The index to search from.
9225     * @returns {*} Returns the matched element, else `undefined`.
9226     * @example
9227     *
9228     * _.findLast([1, 2, 3, 4], function(n) {
9229     *   return n % 2 == 1;
9230     * });
9231     * // => 3
9232     */
9233    var findLast = createFind(findLastIndex);
9234
9235    /**
9236     * Creates a flattened array of values by running each element in `collection`
9237     * thru `iteratee` and flattening the mapped results. The iteratee is invoked
9238     * with three arguments: (value, index|key, collection).
9239     *
9240     * @static
9241     * @memberOf _
9242     * @since 4.0.0
9243     * @category Collection
9244     * @param {Array|Object} collection The collection to iterate over.
9245     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9246     * @returns {Array} Returns the new flattened array.
9247     * @example
9248     *
9249     * function duplicate(n) {
9250     *   return [n, n];
9251     * }
9252     *
9253     * _.flatMap([1, 2], duplicate);
9254     * // => [1, 1, 2, 2]
9255     */
9256    function flatMap(collection, iteratee) {
9257      return baseFlatten(map(collection, iteratee), 1);
9258    }
9259
9260    /**
9261     * This method is like `_.flatMap` except that it recursively flattens the
9262     * mapped results.
9263     *
9264     * @static
9265     * @memberOf _
9266     * @since 4.7.0
9267     * @category Collection
9268     * @param {Array|Object} collection The collection to iterate over.
9269     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9270     * @returns {Array} Returns the new flattened array.
9271     * @example
9272     *
9273     * function duplicate(n) {
9274     *   return [[[n, n]]];
9275     * }
9276     *
9277     * _.flatMapDeep([1, 2], duplicate);
9278     * // => [1, 1, 2, 2]
9279     */
9280    function flatMapDeep(collection, iteratee) {
9281      return baseFlatten(map(collection, iteratee), INFINITY);
9282    }
9283
9284    /**
9285     * This method is like `_.flatMap` except that it recursively flattens the
9286     * mapped results up to `depth` times.
9287     *
9288     * @static
9289     * @memberOf _
9290     * @since 4.7.0
9291     * @category Collection
9292     * @param {Array|Object} collection The collection to iterate over.
9293     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9294     * @param {number} [depth=1] The maximum recursion depth.
9295     * @returns {Array} Returns the new flattened array.
9296     * @example
9297     *
9298     * function duplicate(n) {
9299     *   return [[[n, n]]];
9300     * }
9301     *
9302     * _.flatMapDepth([1, 2], duplicate, 2);
9303     * // => [[1, 1], [2, 2]]
9304     */
9305    function flatMapDepth(collection, iteratee, depth) {
9306      depth = depth === undefined ? 1 : toInteger(depth);
9307      return baseFlatten(map(collection, iteratee), depth);
9308    }
9309
9310    /**
9311     * Iterates over elements of `collection` and invokes `iteratee` for each element.
9312     * The iteratee is invoked with three arguments: (value, index|key, collection).
9313     * Iteratee functions may exit iteration early by explicitly returning `false`.
9314     *
9315     * **Note:** As with other "Collections" methods, objects with a "length"
9316     * property are iterated like arrays. To avoid this behavior use `_.forIn`
9317     * or `_.forOwn` for object iteration.
9318     *
9319     * @static
9320     * @memberOf _
9321     * @since 0.1.0
9322     * @alias each
9323     * @category Collection
9324     * @param {Array|Object} collection The collection to iterate over.
9325     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9326     * @returns {Array|Object} Returns `collection`.
9327     * @see _.forEachRight
9328     * @example
9329     *
9330     * _.forEach([1, 2], function(value) {
9331     *   console.log(value);
9332     * });
9333     * // => Logs `1` then `2`.
9334     *
9335     * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9336     *   console.log(key);
9337     * });
9338     * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9339     */
9340    function forEach(collection, iteratee) {
9341      var func = isArray(collection) ? arrayEach : baseEach;
9342      return func(collection, getIteratee(iteratee, 3));
9343    }
9344
9345    /**
9346     * This method is like `_.forEach` except that it iterates over elements of
9347     * `collection` from right to left.
9348     *
9349     * @static
9350     * @memberOf _
9351     * @since 2.0.0
9352     * @alias eachRight
9353     * @category Collection
9354     * @param {Array|Object} collection The collection to iterate over.
9355     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9356     * @returns {Array|Object} Returns `collection`.
9357     * @see _.forEach
9358     * @example
9359     *
9360     * _.forEachRight([1, 2], function(value) {
9361     *   console.log(value);
9362     * });
9363     * // => Logs `2` then `1`.
9364     */
9365    function forEachRight(collection, iteratee) {
9366      var func = isArray(collection) ? arrayEachRight : baseEachRight;
9367      return func(collection, getIteratee(iteratee, 3));
9368    }
9369
9370    /**
9371     * Creates an object composed of keys generated from the results of running
9372     * each element of `collection` thru `iteratee`. The order of grouped values
9373     * is determined by the order they occur in `collection`. The corresponding
9374     * value of each key is an array of elements responsible for generating the
9375     * key. The iteratee is invoked with one argument: (value).
9376     *
9377     * @static
9378     * @memberOf _
9379     * @since 0.1.0
9380     * @category Collection
9381     * @param {Array|Object} collection The collection to iterate over.
9382     * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9383     * @returns {Object} Returns the composed aggregate object.
9384     * @example
9385     *
9386     * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9387     * // => { '4': [4.2], '6': [6.1, 6.3] }
9388     *
9389     * // The `_.property` iteratee shorthand.
9390     * _.groupBy(['one', 'two', 'three'], 'length');
9391     * // => { '3': ['one', 'two'], '5': ['three'] }
9392     */
9393    var groupBy = createAggregator(function(result, value, key) {
9394      if (hasOwnProperty.call(result, key)) {
9395        result[key].push(value);
9396      } else {
9397        baseAssignValue(result, key, [value]);
9398      }
9399    });
9400
9401    /**
9402     * Checks if `value` is in `collection`. If `collection` is a string, it's
9403     * checked for a substring of `value`, otherwise
9404     * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9405     * is used for equality comparisons. If `fromIndex` is negative, it's used as
9406     * the offset from the end of `collection`.
9407     *
9408     * @static
9409     * @memberOf _
9410     * @since 0.1.0
9411     * @category Collection
9412     * @param {Array|Object|string} collection The collection to inspect.
9413     * @param {*} value The value to search for.
9414     * @param {number} [fromIndex=0] The index to search from.
9415     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9416     * @returns {boolean} Returns `true` if `value` is found, else `false`.
9417     * @example
9418     *
9419     * _.includes([1, 2, 3], 1);
9420     * // => true
9421     *
9422     * _.includes([1, 2, 3], 1, 2);
9423     * // => false
9424     *
9425     * _.includes({ 'a': 1, 'b': 2 }, 1);
9426     * // => true
9427     *
9428     * _.includes('abcd', 'bc');
9429     * // => true
9430     */
9431    function includes(collection, value, fromIndex, guard) {
9432      collection = isArrayLike(collection) ? collection : values(collection);
9433      fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9434
9435      var length = collection.length;
9436      if (fromIndex < 0) {
9437        fromIndex = nativeMax(length + fromIndex, 0);
9438      }
9439      return isString(collection)
9440        ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9441        : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9442    }
9443
9444    /**
9445     * Invokes the method at `path` of each element in `collection`, returning
9446     * an array of the results of each invoked method. Any additional arguments
9447     * are provided to each invoked method. If `path` is a function, it's invoked
9448     * for, and `this` bound to, each element in `collection`.
9449     *
9450     * @static
9451     * @memberOf _
9452     * @since 4.0.0
9453     * @category Collection
9454     * @param {Array|Object} collection The collection to iterate over.
9455     * @param {Array|Function|string} path The path of the method to invoke or
9456     *  the function invoked per iteration.
9457     * @param {...*} [args] The arguments to invoke each method with.
9458     * @returns {Array} Returns the array of results.
9459     * @example
9460     *
9461     * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9462     * // => [[1, 5, 7], [1, 2, 3]]
9463     *
9464     * _.invokeMap([123, 456], String.prototype.split, '');
9465     * // => [['1', '2', '3'], ['4', '5', '6']]
9466     */
9467    var invokeMap = baseRest(function(collection, path, args) {
9468      var index = -1,
9469          isFunc = typeof path == 'function',
9470          result = isArrayLike(collection) ? Array(collection.length) : [];
9471
9472      baseEach(collection, function(value) {
9473        result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
9474      });
9475      return result;
9476    });
9477
9478    /**
9479     * Creates an object composed of keys generated from the results of running
9480     * each element of `collection` thru `iteratee`. The corresponding value of
9481     * each key is the last element responsible for generating the key. The
9482     * iteratee is invoked with one argument: (value).
9483     *
9484     * @static
9485     * @memberOf _
9486     * @since 4.0.0
9487     * @category Collection
9488     * @param {Array|Object} collection The collection to iterate over.
9489     * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9490     * @returns {Object} Returns the composed aggregate object.
9491     * @example
9492     *
9493     * var array = [
9494     *   { 'dir': 'left', 'code': 97 },
9495     *   { 'dir': 'right', 'code': 100 }
9496     * ];
9497     *
9498     * _.keyBy(array, function(o) {
9499     *   return String.fromCharCode(o.code);
9500     * });
9501     * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9502     *
9503     * _.keyBy(array, 'dir');
9504     * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9505     */
9506    var keyBy = createAggregator(function(result, value, key) {
9507      baseAssignValue(result, key, value);
9508    });
9509
9510    /**
9511     * Creates an array of values by running each element in `collection` thru
9512     * `iteratee`. The iteratee is invoked with three arguments:
9513     * (value, index|key, collection).
9514     *
9515     * Many lodash methods are guarded to work as iteratees for methods like
9516     * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9517     *
9518     * The guarded methods are:
9519     * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9520     * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9521     * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9522     * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9523     *
9524     * @static
9525     * @memberOf _
9526     * @since 0.1.0
9527     * @category Collection
9528     * @param {Array|Object} collection The collection to iterate over.
9529     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9530     * @returns {Array} Returns the new mapped array.
9531     * @example
9532     *
9533     * function square(n) {
9534     *   return n * n;
9535     * }
9536     *
9537     * _.map([4, 8], square);
9538     * // => [16, 64]
9539     *
9540     * _.map({ 'a': 4, 'b': 8 }, square);
9541     * // => [16, 64] (iteration order is not guaranteed)
9542     *
9543     * var users = [
9544     *   { 'user': 'barney' },
9545     *   { 'user': 'fred' }
9546     * ];
9547     *
9548     * // The `_.property` iteratee shorthand.
9549     * _.map(users, 'user');
9550     * // => ['barney', 'fred']
9551     */
9552    function map(collection, iteratee) {
9553      var func = isArray(collection) ? arrayMap : baseMap;
9554      return func(collection, getIteratee(iteratee, 3));
9555    }
9556
9557    /**
9558     * This method is like `_.sortBy` except that it allows specifying the sort
9559     * orders of the iteratees to sort by. If `orders` is unspecified, all values
9560     * are sorted in ascending order. Otherwise, specify an order of "desc" for
9561     * descending or "asc" for ascending sort order of corresponding values.
9562     *
9563     * @static
9564     * @memberOf _
9565     * @since 4.0.0
9566     * @category Collection
9567     * @param {Array|Object} collection The collection to iterate over.
9568     * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
9569     *  The iteratees to sort by.
9570     * @param {string[]} [orders] The sort orders of `iteratees`.
9571     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9572     * @returns {Array} Returns the new sorted array.
9573     * @example
9574     *
9575     * var users = [
9576     *   { 'user': 'fred',   'age': 48 },
9577     *   { 'user': 'barney', 'age': 34 },
9578     *   { 'user': 'fred',   'age': 40 },
9579     *   { 'user': 'barney', 'age': 36 }
9580     * ];
9581     *
9582     * // Sort by `user` in ascending order and by `age` in descending order.
9583     * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
9584     * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9585     */
9586    function orderBy(collection, iteratees, orders, guard) {
9587      if (collection == null) {
9588        return [];
9589      }
9590      if (!isArray(iteratees)) {
9591        iteratees = iteratees == null ? [] : [iteratees];
9592      }
9593      orders = guard ? undefined : orders;
9594      if (!isArray(orders)) {
9595        orders = orders == null ? [] : [orders];
9596      }
9597      return baseOrderBy(collection, iteratees, orders);
9598    }
9599
9600    /**
9601     * Creates an array of elements split into two groups, the first of which
9602     * contains elements `predicate` returns truthy for, the second of which
9603     * contains elements `predicate` returns falsey for. The predicate is
9604     * invoked with one argument: (value).
9605     *
9606     * @static
9607     * @memberOf _
9608     * @since 3.0.0
9609     * @category Collection
9610     * @param {Array|Object} collection The collection to iterate over.
9611     * @param {Function} [predicate=_.identity] The function invoked per iteration.
9612     * @returns {Array} Returns the array of grouped elements.
9613     * @example
9614     *
9615     * var users = [
9616     *   { 'user': 'barney',  'age': 36, 'active': false },
9617     *   { 'user': 'fred',    'age': 40, 'active': true },
9618     *   { 'user': 'pebbles', 'age': 1,  'active': false }
9619     * ];
9620     *
9621     * _.partition(users, function(o) { return o.active; });
9622     * // => objects for [['fred'], ['barney', 'pebbles']]
9623     *
9624     * // The `_.matches` iteratee shorthand.
9625     * _.partition(users, { 'age': 1, 'active': false });
9626     * // => objects for [['pebbles'], ['barney', 'fred']]
9627     *
9628     * // The `_.matchesProperty` iteratee shorthand.
9629     * _.partition(users, ['active', false]);
9630     * // => objects for [['barney', 'pebbles'], ['fred']]
9631     *
9632     * // The `_.property` iteratee shorthand.
9633     * _.partition(users, 'active');
9634     * // => objects for [['fred'], ['barney', 'pebbles']]
9635     */
9636    var partition = createAggregator(function(result, value, key) {
9637      result[key ? 0 : 1].push(value);
9638    }, function() { return [[], []]; });
9639
9640    /**
9641     * Reduces `collection` to a value which is the accumulated result of running
9642     * each element in `collection` thru `iteratee`, where each successive
9643     * invocation is supplied the return value of the previous. If `accumulator`
9644     * is not given, the first element of `collection` is used as the initial
9645     * value. The iteratee is invoked with four arguments:
9646     * (accumulator, value, index|key, collection).
9647     *
9648     * Many lodash methods are guarded to work as iteratees for methods like
9649     * `_.reduce`, `_.reduceRight`, and `_.transform`.
9650     *
9651     * The guarded methods are:
9652     * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
9653     * and `sortBy`
9654     *
9655     * @static
9656     * @memberOf _
9657     * @since 0.1.0
9658     * @category Collection
9659     * @param {Array|Object} collection The collection to iterate over.
9660     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9661     * @param {*} [accumulator] The initial value.
9662     * @returns {*} Returns the accumulated value.
9663     * @see _.reduceRight
9664     * @example
9665     *
9666     * _.reduce([1, 2], function(sum, n) {
9667     *   return sum + n;
9668     * }, 0);
9669     * // => 3
9670     *
9671     * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
9672     *   (result[value] || (result[value] = [])).push(key);
9673     *   return result;
9674     * }, {});
9675     * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
9676     */
9677    function reduce(collection, iteratee, accumulator) {
9678      var func = isArray(collection) ? arrayReduce : baseReduce,
9679          initAccum = arguments.length < 3;
9680
9681      return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
9682    }
9683
9684    /**
9685     * This method is like `_.reduce` except that it iterates over elements of
9686     * `collection` from right to left.
9687     *
9688     * @static
9689     * @memberOf _
9690     * @since 0.1.0
9691     * @category Collection
9692     * @param {Array|Object} collection The collection to iterate over.
9693     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9694     * @param {*} [accumulator] The initial value.
9695     * @returns {*} Returns the accumulated value.
9696     * @see _.reduce
9697     * @example
9698     *
9699     * var array = [[0, 1], [2, 3], [4, 5]];
9700     *
9701     * _.reduceRight(array, function(flattened, other) {
9702     *   return flattened.concat(other);
9703     * }, []);
9704     * // => [4, 5, 2, 3, 0, 1]
9705     */
9706    function reduceRight(collection, iteratee, accumulator) {
9707      var func = isArray(collection) ? arrayReduceRight : baseReduce,
9708          initAccum = arguments.length < 3;
9709
9710      return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
9711    }
9712
9713    /**
9714     * The opposite of `_.filter`; this method returns the elements of `collection`
9715     * that `predicate` does **not** return truthy for.
9716     *
9717     * @static
9718     * @memberOf _
9719     * @since 0.1.0
9720     * @category Collection
9721     * @param {Array|Object} collection The collection to iterate over.
9722     * @param {Function} [predicate=_.identity] The function invoked per iteration.
9723     * @returns {Array} Returns the new filtered array.
9724     * @see _.filter
9725     * @example
9726     *
9727     * var users = [
9728     *   { 'user': 'barney', 'age': 36, 'active': false },
9729     *   { 'user': 'fred',   'age': 40, 'active': true }
9730     * ];
9731     *
9732     * _.reject(users, function(o) { return !o.active; });
9733     * // => objects for ['fred']
9734     *
9735     * // The `_.matches` iteratee shorthand.
9736     * _.reject(users, { 'age': 40, 'active': true });
9737     * // => objects for ['barney']
9738     *
9739     * // The `_.matchesProperty` iteratee shorthand.
9740     * _.reject(users, ['active', false]);
9741     * // => objects for ['fred']
9742     *
9743     * // The `_.property` iteratee shorthand.
9744     * _.reject(users, 'active');
9745     * // => objects for ['barney']
9746     */
9747    function reject(collection, predicate) {
9748      var func = isArray(collection) ? arrayFilter : baseFilter;
9749      return func(collection, negate(getIteratee(predicate, 3)));
9750    }
9751
9752    /**
9753     * Gets a random element from `collection`.
9754     *
9755     * @static
9756     * @memberOf _
9757     * @since 2.0.0
9758     * @category Collection
9759     * @param {Array|Object} collection The collection to sample.
9760     * @returns {*} Returns the random element.
9761     * @example
9762     *
9763     * _.sample([1, 2, 3, 4]);
9764     * // => 2
9765     */
9766    function sample(collection) {
9767      var func = isArray(collection) ? arraySample : baseSample;
9768      return func(collection);
9769    }
9770
9771    /**
9772     * Gets `n` random elements at unique keys from `collection` up to the
9773     * size of `collection`.
9774     *
9775     * @static
9776     * @memberOf _
9777     * @since 4.0.0
9778     * @category Collection
9779     * @param {Array|Object} collection The collection to sample.
9780     * @param {number} [n=1] The number of elements to sample.
9781     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9782     * @returns {Array} Returns the random elements.
9783     * @example
9784     *
9785     * _.sampleSize([1, 2, 3], 2);
9786     * // => [3, 1]
9787     *
9788     * _.sampleSize([1, 2, 3], 4);
9789     * // => [2, 3, 1]
9790     */
9791    function sampleSize(collection, n, guard) {
9792      if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
9793        n = 1;
9794      } else {
9795        n = toInteger(n);
9796      }
9797      var func = isArray(collection) ? arraySampleSize : baseSampleSize;
9798      return func(collection, n);
9799    }
9800
9801    /**
9802     * Creates an array of shuffled values, using a version of the
9803     * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9804     *
9805     * @static
9806     * @memberOf _
9807     * @since 0.1.0
9808     * @category Collection
9809     * @param {Array|Object} collection The collection to shuffle.
9810     * @returns {Array} Returns the new shuffled array.
9811     * @example
9812     *
9813     * _.shuffle([1, 2, 3, 4]);
9814     * // => [4, 1, 3, 2]
9815     */
9816    function shuffle(collection) {
9817      var func = isArray(collection) ? arrayShuffle : baseShuffle;
9818      return func(collection);
9819    }
9820
9821    /**
9822     * Gets the size of `collection` by returning its length for array-like
9823     * values or the number of own enumerable string keyed properties for objects.
9824     *
9825     * @static
9826     * @memberOf _
9827     * @since 0.1.0
9828     * @category Collection
9829     * @param {Array|Object|string} collection The collection to inspect.
9830     * @returns {number} Returns the collection size.
9831     * @example
9832     *
9833     * _.size([1, 2, 3]);
9834     * // => 3
9835     *
9836     * _.size({ 'a': 1, 'b': 2 });
9837     * // => 2
9838     *
9839     * _.size('pebbles');
9840     * // => 7
9841     */
9842    function size(collection) {
9843      if (collection == null) {
9844        return 0;
9845      }
9846      if (isArrayLike(collection)) {
9847        return isString(collection) ? stringSize(collection) : collection.length;
9848      }
9849      var tag = getTag(collection);
9850      if (tag == mapTag || tag == setTag) {
9851        return collection.size;
9852      }
9853      return baseKeys(collection).length;
9854    }
9855
9856    /**
9857     * Checks if `predicate` returns truthy for **any** element of `collection`.
9858     * Iteration is stopped once `predicate` returns truthy. The predicate is
9859     * invoked with three arguments: (value, index|key, collection).
9860     *
9861     * @static
9862     * @memberOf _
9863     * @since 0.1.0
9864     * @category Collection
9865     * @param {Array|Object} collection The collection to iterate over.
9866     * @param {Function} [predicate=_.identity] The function invoked per iteration.
9867     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9868     * @returns {boolean} Returns `true` if any element passes the predicate check,
9869     *  else `false`.
9870     * @example
9871     *
9872     * _.some([null, 0, 'yes', false], Boolean);
9873     * // => true
9874     *
9875     * var users = [
9876     *   { 'user': 'barney', 'active': true },
9877     *   { 'user': 'fred',   'active': false }
9878     * ];
9879     *
9880     * // The `_.matches` iteratee shorthand.
9881     * _.some(users, { 'user': 'barney', 'active': false });
9882     * // => false
9883     *
9884     * // The `_.matchesProperty` iteratee shorthand.
9885     * _.some(users, ['active', false]);
9886     * // => true
9887     *
9888     * // The `_.property` iteratee shorthand.
9889     * _.some(users, 'active');
9890     * // => true
9891     */
9892    function some(collection, predicate, guard) {
9893      var func = isArray(collection) ? arraySome : baseSome;
9894      if (guard && isIterateeCall(collection, predicate, guard)) {
9895        predicate = undefined;
9896      }
9897      return func(collection, getIteratee(predicate, 3));
9898    }
9899
9900    /**
9901     * Creates an array of elements, sorted in ascending order by the results of
9902     * running each element in a collection thru each iteratee. This method
9903     * performs a stable sort, that is, it preserves the original sort order of
9904     * equal elements. The iteratees are invoked with one argument: (value).
9905     *
9906     * @static
9907     * @memberOf _
9908     * @since 0.1.0
9909     * @category Collection
9910     * @param {Array|Object} collection The collection to iterate over.
9911     * @param {...(Function|Function[])} [iteratees=[_.identity]]
9912     *  The iteratees to sort by.
9913     * @returns {Array} Returns the new sorted array.
9914     * @example
9915     *
9916     * var users = [
9917     *   { 'user': 'fred',   'age': 48 },
9918     *   { 'user': 'barney', 'age': 36 },
9919     *   { 'user': 'fred',   'age': 40 },
9920     *   { 'user': 'barney', 'age': 34 }
9921     * ];
9922     *
9923     * _.sortBy(users, [function(o) { return o.user; }]);
9924     * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9925     *
9926     * _.sortBy(users, ['user', 'age']);
9927     * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
9928     */
9929    var sortBy = baseRest(function(collection, iteratees) {
9930      if (collection == null) {
9931        return [];
9932      }
9933      var length = iteratees.length;
9934      if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
9935        iteratees = [];
9936      } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
9937        iteratees = [iteratees[0]];
9938      }
9939      return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
9940    });
9941
9942    /*------------------------------------------------------------------------*/
9943
9944    /**
9945     * Gets the timestamp of the number of milliseconds that have elapsed since
9946     * the Unix epoch (1 January 1970 00:00:00 UTC).
9947     *
9948     * @static
9949     * @memberOf _
9950     * @since 2.4.0
9951     * @category Date
9952     * @returns {number} Returns the timestamp.
9953     * @example
9954     *
9955     * _.defer(function(stamp) {
9956     *   console.log(_.now() - stamp);
9957     * }, _.now());
9958     * // => Logs the number of milliseconds it took for the deferred invocation.
9959     */
9960    var now = ctxNow || function() {
9961      return root.Date.now();
9962    };
9963
9964    /*------------------------------------------------------------------------*/
9965
9966    /**
9967     * The opposite of `_.before`; this method creates a function that invokes
9968     * `func` once it's called `n` or more times.
9969     *
9970     * @static
9971     * @memberOf _
9972     * @since 0.1.0
9973     * @category Function
9974     * @param {number} n The number of calls before `func` is invoked.
9975     * @param {Function} func The function to restrict.
9976     * @returns {Function} Returns the new restricted function.
9977     * @example
9978     *
9979     * var saves = ['profile', 'settings'];
9980     *
9981     * var done = _.after(saves.length, function() {
9982     *   console.log('done saving!');
9983     * });
9984     *
9985     * _.forEach(saves, function(type) {
9986     *   asyncSave({ 'type': type, 'complete': done });
9987     * });
9988     * // => Logs 'done saving!' after the two async saves have completed.
9989     */
9990    function after(n, func) {
9991      if (typeof func != 'function') {
9992        throw new TypeError(FUNC_ERROR_TEXT);
9993      }
9994      n = toInteger(n);
9995      return function() {
9996        if (--n < 1) {
9997          return func.apply(this, arguments);
9998        }
9999      };
10000    }
10001
10002    /**
10003     * Creates a function that invokes `func`, with up to `n` arguments,
10004     * ignoring any additional arguments.
10005     *
10006     * @static
10007     * @memberOf _
10008     * @since 3.0.0
10009     * @category Function
10010     * @param {Function} func The function to cap arguments for.
10011     * @param {number} [n=func.length] The arity cap.
10012     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10013     * @returns {Function} Returns the new capped function.
10014     * @example
10015     *
10016     * _.map(['6', '8', '10'], _.ary(parseInt, 1));
10017     * // => [6, 8, 10]
10018     */
10019    function ary(func, n, guard) {
10020      n = guard ? undefined : n;
10021      n = (func && n == null) ? func.length : n;
10022      return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
10023    }
10024
10025    /**
10026     * Creates a function that invokes `func`, with the `this` binding and arguments
10027     * of the created function, while it's called less than `n` times. Subsequent
10028     * calls to the created function return the result of the last `func` invocation.
10029     *
10030     * @static
10031     * @memberOf _
10032     * @since 3.0.0
10033     * @category Function
10034     * @param {number} n The number of calls at which `func` is no longer invoked.
10035     * @param {Function} func The function to restrict.
10036     * @returns {Function} Returns the new restricted function.
10037     * @example
10038     *
10039     * jQuery(element).on('click', _.before(5, addContactToList));
10040     * // => Allows adding up to 4 contacts to the list.
10041     */
10042    function before(n, func) {
10043      var result;
10044      if (typeof func != 'function') {
10045        throw new TypeError(FUNC_ERROR_TEXT);
10046      }
10047      n = toInteger(n);
10048      return function() {
10049        if (--n > 0) {
10050          result = func.apply(this, arguments);
10051        }
10052        if (n <= 1) {
10053          func = undefined;
10054        }
10055        return result;
10056      };
10057    }
10058
10059    /**
10060     * Creates a function that invokes `func` with the `this` binding of `thisArg`
10061     * and `partials` prepended to the arguments it receives.
10062     *
10063     * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10064     * may be used as a placeholder for partially applied arguments.
10065     *
10066     * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10067     * property of bound functions.
10068     *
10069     * @static
10070     * @memberOf _
10071     * @since 0.1.0
10072     * @category Function
10073     * @param {Function} func The function to bind.
10074     * @param {*} thisArg The `this` binding of `func`.
10075     * @param {...*} [partials] The arguments to be partially applied.
10076     * @returns {Function} Returns the new bound function.
10077     * @example
10078     *
10079     * function greet(greeting, punctuation) {
10080     *   return greeting + ' ' + this.user + punctuation;
10081     * }
10082     *
10083     * var object = { 'user': 'fred' };
10084     *
10085     * var bound = _.bind(greet, object, 'hi');
10086     * bound('!');
10087     * // => 'hi fred!'
10088     *
10089     * // Bound with placeholders.
10090     * var bound = _.bind(greet, object, _, '!');
10091     * bound('hi');
10092     * // => 'hi fred!'
10093     */
10094    var bind = baseRest(function(func, thisArg, partials) {
10095      var bitmask = WRAP_BIND_FLAG;
10096      if (partials.length) {
10097        var holders = replaceHolders(partials, getHolder(bind));
10098        bitmask |= WRAP_PARTIAL_FLAG;
10099      }
10100      return createWrap(func, bitmask, thisArg, partials, holders);
10101    });
10102
10103    /**
10104     * Creates a function that invokes the method at `object[key]` with `partials`
10105     * prepended to the arguments it receives.
10106     *
10107     * This method differs from `_.bind` by allowing bound functions to reference
10108     * methods that may be redefined or don't yet exist. See
10109     * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
10110     * for more details.
10111     *
10112     * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10113     * builds, may be used as a placeholder for partially applied arguments.
10114     *
10115     * @static
10116     * @memberOf _
10117     * @since 0.10.0
10118     * @category Function
10119     * @param {Object} object The object to invoke the method on.
10120     * @param {string} key The key of the method.
10121     * @param {...*} [partials] The arguments to be partially applied.
10122     * @returns {Function} Returns the new bound function.
10123     * @example
10124     *
10125     * var object = {
10126     *   'user': 'fred',
10127     *   'greet': function(greeting, punctuation) {
10128     *     return greeting + ' ' + this.user + punctuation;
10129     *   }
10130     * };
10131     *
10132     * var bound = _.bindKey(object, 'greet', 'hi');
10133     * bound('!');
10134     * // => 'hi fred!'
10135     *
10136     * object.greet = function(greeting, punctuation) {
10137     *   return greeting + 'ya ' + this.user + punctuation;
10138     * };
10139     *
10140     * bound('!');
10141     * // => 'hiya fred!'
10142     *
10143     * // Bound with placeholders.
10144     * var bound = _.bindKey(object, 'greet', _, '!');
10145     * bound('hi');
10146     * // => 'hiya fred!'
10147     */
10148    var bindKey = baseRest(function(object, key, partials) {
10149      var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
10150      if (partials.length) {
10151        var holders = replaceHolders(partials, getHolder(bindKey));
10152        bitmask |= WRAP_PARTIAL_FLAG;
10153      }
10154      return createWrap(key, bitmask, object, partials, holders);
10155    });
10156
10157    /**
10158     * Creates a function that accepts arguments of `func` and either invokes
10159     * `func` returning its result, if at least `arity` number of arguments have
10160     * been provided, or returns a function that accepts the remaining `func`
10161     * arguments, and so on. The arity of `func` may be specified if `func.length`
10162     * is not sufficient.
10163     *
10164     * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10165     * may be used as a placeholder for provided arguments.
10166     *
10167     * **Note:** This method doesn't set the "length" property of curried functions.
10168     *
10169     * @static
10170     * @memberOf _
10171     * @since 2.0.0
10172     * @category Function
10173     * @param {Function} func The function to curry.
10174     * @param {number} [arity=func.length] The arity of `func`.
10175     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10176     * @returns {Function} Returns the new curried function.
10177     * @example
10178     *
10179     * var abc = function(a, b, c) {
10180     *   return [a, b, c];
10181     * };
10182     *
10183     * var curried = _.curry(abc);
10184     *
10185     * curried(1)(2)(3);
10186     * // => [1, 2, 3]
10187     *
10188     * curried(1, 2)(3);
10189     * // => [1, 2, 3]
10190     *
10191     * curried(1, 2, 3);
10192     * // => [1, 2, 3]
10193     *
10194     * // Curried with placeholders.
10195     * curried(1)(_, 3)(2);
10196     * // => [1, 2, 3]
10197     */
10198    function curry(func, arity, guard) {
10199      arity = guard ? undefined : arity;
10200      var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10201      result.placeholder = curry.placeholder;
10202      return result;
10203    }
10204
10205    /**
10206     * This method is like `_.curry` except that arguments are applied to `func`
10207     * in the manner of `_.partialRight` instead of `_.partial`.
10208     *
10209     * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10210     * builds, may be used as a placeholder for provided arguments.
10211     *
10212     * **Note:** This method doesn't set the "length" property of curried functions.
10213     *
10214     * @static
10215     * @memberOf _
10216     * @since 3.0.0
10217     * @category Function
10218     * @param {Function} func The function to curry.
10219     * @param {number} [arity=func.length] The arity of `func`.
10220     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10221     * @returns {Function} Returns the new curried function.
10222     * @example
10223     *
10224     * var abc = function(a, b, c) {
10225     *   return [a, b, c];
10226     * };
10227     *
10228     * var curried = _.curryRight(abc);
10229     *
10230     * curried(3)(2)(1);
10231     * // => [1, 2, 3]
10232     *
10233     * curried(2, 3)(1);
10234     * // => [1, 2, 3]
10235     *
10236     * curried(1, 2, 3);
10237     * // => [1, 2, 3]
10238     *
10239     * // Curried with placeholders.
10240     * curried(3)(1, _)(2);
10241     * // => [1, 2, 3]
10242     */
10243    function curryRight(func, arity, guard) {
10244      arity = guard ? undefined : arity;
10245      var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10246      result.placeholder = curryRight.placeholder;
10247      return result;
10248    }
10249
10250    /**
10251     * Creates a debounced function that delays invoking `func` until after `wait`
10252     * milliseconds have elapsed since the last time the debounced function was
10253     * invoked. The debounced function comes with a `cancel` method to cancel
10254     * delayed `func` invocations and a `flush` method to immediately invoke them.
10255     * Provide `options` to indicate whether `func` should be invoked on the
10256     * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
10257     * with the last arguments provided to the debounced function. Subsequent
10258     * calls to the debounced function return the result of the last `func`
10259     * invocation.
10260     *
10261     * **Note:** If `leading` and `trailing` options are `true`, `func` is
10262     * invoked on the trailing edge of the timeout only if the debounced function
10263     * is invoked more than once during the `wait` timeout.
10264     *
10265     * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10266     * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10267     *
10268     * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10269     * for details over the differences between `_.debounce` and `_.throttle`.
10270     *
10271     * @static
10272     * @memberOf _
10273     * @since 0.1.0
10274     * @category Function
10275     * @param {Function} func The function to debounce.
10276     * @param {number} [wait=0] The number of milliseconds to delay.
10277     * @param {Object} [options={}] The options object.
10278     * @param {boolean} [options.leading=false]
10279     *  Specify invoking on the leading edge of the timeout.
10280     * @param {number} [options.maxWait]
10281     *  The maximum time `func` is allowed to be delayed before it's invoked.
10282     * @param {boolean} [options.trailing=true]
10283     *  Specify invoking on the trailing edge of the timeout.
10284     * @returns {Function} Returns the new debounced function.
10285     * @example
10286     *
10287     * // Avoid costly calculations while the window size is in flux.
10288     * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10289     *
10290     * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10291     * jQuery(element).on('click', _.debounce(sendMail, 300, {
10292     *   'leading': true,
10293     *   'trailing': false
10294     * }));
10295     *
10296     * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
10297     * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
10298     * var source = new EventSource('/stream');
10299     * jQuery(source).on('message', debounced);
10300     *
10301     * // Cancel the trailing debounced invocation.
10302     * jQuery(window).on('popstate', debounced.cancel);
10303     */
10304    function debounce(func, wait, options) {
10305      var lastArgs,
10306          lastThis,
10307          maxWait,
10308          result,
10309          timerId,
10310          lastCallTime,
10311          lastInvokeTime = 0,
10312          leading = false,
10313          maxing = false,
10314          trailing = true;
10315
10316      if (typeof func != 'function') {
10317        throw new TypeError(FUNC_ERROR_TEXT);
10318      }
10319      wait = toNumber(wait) || 0;
10320      if (isObject(options)) {
10321        leading = !!options.leading;
10322        maxing = 'maxWait' in options;
10323        maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
10324        trailing = 'trailing' in options ? !!options.trailing : trailing;
10325      }
10326
10327      function invokeFunc(time) {
10328        var args = lastArgs,
10329            thisArg = lastThis;
10330
10331        lastArgs = lastThis = undefined;
10332        lastInvokeTime = time;
10333        result = func.apply(thisArg, args);
10334        return result;
10335      }
10336
10337      function leadingEdge(time) {
10338        // Reset any `maxWait` timer.
10339        lastInvokeTime = time;
10340        // Start the timer for the trailing edge.
10341        timerId = setTimeout(timerExpired, wait);
10342        // Invoke the leading edge.
10343        return leading ? invokeFunc(time) : result;
10344      }
10345
10346      function remainingWait(time) {
10347        var timeSinceLastCall = time - lastCallTime,
10348            timeSinceLastInvoke = time - lastInvokeTime,
10349            timeWaiting = wait - timeSinceLastCall;
10350
10351        return maxing
10352          ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
10353          : timeWaiting;
10354      }
10355
10356      function shouldInvoke(time) {
10357        var timeSinceLastCall = time - lastCallTime,
10358            timeSinceLastInvoke = time - lastInvokeTime;
10359
10360        // Either this is the first call, activity has stopped and we're at the
10361        // trailing edge, the system time has gone backwards and we're treating
10362        // it as the trailing edge, or we've hit the `maxWait` limit.
10363        return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
10364          (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
10365      }
10366
10367      function timerExpired() {
10368        var time = now();
10369        if (shouldInvoke(time)) {
10370          return trailingEdge(time);
10371        }
10372        // Restart the timer.
10373        timerId = setTimeout(timerExpired, remainingWait(time));
10374      }
10375
10376      function trailingEdge(time) {
10377        timerId = undefined;
10378
10379        // Only invoke if we have `lastArgs` which means `func` has been
10380        // debounced at least once.
10381        if (trailing && lastArgs) {
10382          return invokeFunc(time);
10383        }
10384        lastArgs = lastThis = undefined;
10385        return result;
10386      }
10387
10388      function cancel() {
10389        if (timerId !== undefined) {
10390          clearTimeout(timerId);
10391        }
10392        lastInvokeTime = 0;
10393        lastArgs = lastCallTime = lastThis = timerId = undefined;
10394      }
10395
10396      function flush() {
10397        return timerId === undefined ? result : trailingEdge(now());
10398      }
10399
10400      function debounced() {
10401        var time = now(),
10402            isInvoking = shouldInvoke(time);
10403
10404        lastArgs = arguments;
10405        lastThis = this;
10406        lastCallTime = time;
10407
10408        if (isInvoking) {
10409          if (timerId === undefined) {
10410            return leadingEdge(lastCallTime);
10411          }
10412          if (maxing) {
10413            // Handle invocations in a tight loop.
10414            clearTimeout(timerId);
10415            timerId = setTimeout(timerExpired, wait);
10416            return invokeFunc(lastCallTime);
10417          }
10418        }
10419        if (timerId === undefined) {
10420          timerId = setTimeout(timerExpired, wait);
10421        }
10422        return result;
10423      }
10424      debounced.cancel = cancel;
10425      debounced.flush = flush;
10426      return debounced;
10427    }
10428
10429    /**
10430     * Defers invoking the `func` until the current call stack has cleared. Any
10431     * additional arguments are provided to `func` when it's invoked.
10432     *
10433     * @static
10434     * @memberOf _
10435     * @since 0.1.0
10436     * @category Function
10437     * @param {Function} func The function to defer.
10438     * @param {...*} [args] The arguments to invoke `func` with.
10439     * @returns {number} Returns the timer id.
10440     * @example
10441     *
10442     * _.defer(function(text) {
10443     *   console.log(text);
10444     * }, 'deferred');
10445     * // => Logs 'deferred' after one millisecond.
10446     */
10447    var defer = baseRest(function(func, args) {
10448      return baseDelay(func, 1, args);
10449    });
10450
10451    /**
10452     * Invokes `func` after `wait` milliseconds. Any additional arguments are
10453     * provided to `func` when it's invoked.
10454     *
10455     * @static
10456     * @memberOf _
10457     * @since 0.1.0
10458     * @category Function
10459     * @param {Function} func The function to delay.
10460     * @param {number} wait The number of milliseconds to delay invocation.
10461     * @param {...*} [args] The arguments to invoke `func` with.
10462     * @returns {number} Returns the timer id.
10463     * @example
10464     *
10465     * _.delay(function(text) {
10466     *   console.log(text);
10467     * }, 1000, 'later');
10468     * // => Logs 'later' after one second.
10469     */
10470    var delay = baseRest(function(func, wait, args) {
10471      return baseDelay(func, toNumber(wait) || 0, args);
10472    });
10473
10474    /**
10475     * Creates a function that invokes `func` with arguments reversed.
10476     *
10477     * @static
10478     * @memberOf _
10479     * @since 4.0.0
10480     * @category Function
10481     * @param {Function} func The function to flip arguments for.
10482     * @returns {Function} Returns the new flipped function.
10483     * @example
10484     *
10485     * var flipped = _.flip(function() {
10486     *   return _.toArray(arguments);
10487     * });
10488     *
10489     * flipped('a', 'b', 'c', 'd');
10490     * // => ['d', 'c', 'b', 'a']
10491     */
10492    function flip(func) {
10493      return createWrap(func, WRAP_FLIP_FLAG);
10494    }
10495
10496    /**
10497     * Creates a function that memoizes the result of `func`. If `resolver` is
10498     * provided, it determines the cache key for storing the result based on the
10499     * arguments provided to the memoized function. By default, the first argument
10500     * provided to the memoized function is used as the map cache key. The `func`
10501     * is invoked with the `this` binding of the memoized function.
10502     *
10503     * **Note:** The cache is exposed as the `cache` property on the memoized
10504     * function. Its creation may be customized by replacing the `_.memoize.Cache`
10505     * constructor with one whose instances implement the
10506     * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
10507     * method interface of `clear`, `delete`, `get`, `has`, and `set`.
10508     *
10509     * @static
10510     * @memberOf _
10511     * @since 0.1.0
10512     * @category Function
10513     * @param {Function} func The function to have its output memoized.
10514     * @param {Function} [resolver] The function to resolve the cache key.
10515     * @returns {Function} Returns the new memoized function.
10516     * @example
10517     *
10518     * var object = { 'a': 1, 'b': 2 };
10519     * var other = { 'c': 3, 'd': 4 };
10520     *
10521     * var values = _.memoize(_.values);
10522     * values(object);
10523     * // => [1, 2]
10524     *
10525     * values(other);
10526     * // => [3, 4]
10527     *
10528     * object.a = 2;
10529     * values(object);
10530     * // => [1, 2]
10531     *
10532     * // Modify the result cache.
10533     * values.cache.set(object, ['a', 'b']);
10534     * values(object);
10535     * // => ['a', 'b']
10536     *
10537     * // Replace `_.memoize.Cache`.
10538     * _.memoize.Cache = WeakMap;
10539     */
10540    function memoize(func, resolver) {
10541      if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10542        throw new TypeError(FUNC_ERROR_TEXT);
10543      }
10544      var memoized = function() {
10545        var args = arguments,
10546            key = resolver ? resolver.apply(this, args) : args[0],
10547            cache = memoized.cache;
10548
10549        if (cache.has(key)) {
10550          return cache.get(key);
10551        }
10552        var result = func.apply(this, args);
10553        memoized.cache = cache.set(key, result) || cache;
10554        return result;
10555      };
10556      memoized.cache = new (memoize.Cache || MapCache);
10557      return memoized;
10558    }
10559
10560    // Expose `MapCache`.
10561    memoize.Cache = MapCache;
10562
10563    /**
10564     * Creates a function that negates the result of the predicate `func`. The
10565     * `func` predicate is invoked with the `this` binding and arguments of the
10566     * created function.
10567     *
10568     * @static
10569     * @memberOf _
10570     * @since 3.0.0
10571     * @category Function
10572     * @param {Function} predicate The predicate to negate.
10573     * @returns {Function} Returns the new negated function.
10574     * @example
10575     *
10576     * function isEven(n) {
10577     *   return n % 2 == 0;
10578     * }
10579     *
10580     * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10581     * // => [1, 3, 5]
10582     */
10583    function negate(predicate) {
10584      if (typeof predicate != 'function') {
10585        throw new TypeError(FUNC_ERROR_TEXT);
10586      }
10587      return function() {
10588        var args = arguments;
10589        switch (args.length) {
10590          case 0: return !predicate.call(this);
10591          case 1: return !predicate.call(this, args[0]);
10592          case 2: return !predicate.call(this, args[0], args[1]);
10593          case 3: return !predicate.call(this, args[0], args[1], args[2]);
10594        }
10595        return !predicate.apply(this, args);
10596      };
10597    }
10598
10599    /**
10600     * Creates a function that is restricted to invoking `func` once. Repeat calls
10601     * to the function return the value of the first invocation. The `func` is
10602     * invoked with the `this` binding and arguments of the created function.
10603     *
10604     * @static
10605     * @memberOf _
10606     * @since 0.1.0
10607     * @category Function
10608     * @param {Function} func The function to restrict.
10609     * @returns {Function} Returns the new restricted function.
10610     * @example
10611     *
10612     * var initialize = _.once(createApplication);
10613     * initialize();
10614     * initialize();
10615     * // => `createApplication` is invoked once
10616     */
10617    function once(func) {
10618      return before(2, func);
10619    }
10620
10621    /**
10622     * Creates a function that invokes `func` with its arguments transformed.
10623     *
10624     * @static
10625     * @since 4.0.0
10626     * @memberOf _
10627     * @category Function
10628     * @param {Function} func The function to wrap.
10629     * @param {...(Function|Function[])} [transforms=[_.identity]]
10630     *  The argument transforms.
10631     * @returns {Function} Returns the new function.
10632     * @example
10633     *
10634     * function doubled(n) {
10635     *   return n * 2;
10636     * }
10637     *
10638     * function square(n) {
10639     *   return n * n;
10640     * }
10641     *
10642     * var func = _.overArgs(function(x, y) {
10643     *   return [x, y];
10644     * }, [square, doubled]);
10645     *
10646     * func(9, 3);
10647     * // => [81, 6]
10648     *
10649     * func(10, 5);
10650     * // => [100, 10]
10651     */
10652    var overArgs = castRest(function(func, transforms) {
10653      transforms = (transforms.length == 1 && isArray(transforms[0]))
10654        ? arrayMap(transforms[0], baseUnary(getIteratee()))
10655        : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
10656
10657      var funcsLength = transforms.length;
10658      return baseRest(function(args) {
10659        var index = -1,
10660            length = nativeMin(args.length, funcsLength);
10661
10662        while (++index < length) {
10663          args[index] = transforms[index].call(this, args[index]);
10664        }
10665        return apply(func, this, args);
10666      });
10667    });
10668
10669    /**
10670     * Creates a function that invokes `func` with `partials` prepended to the
10671     * arguments it receives. This method is like `_.bind` except it does **not**
10672     * alter the `this` binding.
10673     *
10674     * The `_.partial.placeholder` value, which defaults to `_` in monolithic
10675     * builds, may be used as a placeholder for partially applied arguments.
10676     *
10677     * **Note:** This method doesn't set the "length" property of partially
10678     * applied functions.
10679     *
10680     * @static
10681     * @memberOf _
10682     * @since 0.2.0
10683     * @category Function
10684     * @param {Function} func The function to partially apply arguments to.
10685     * @param {...*} [partials] The arguments to be partially applied.
10686     * @returns {Function} Returns the new partially applied function.
10687     * @example
10688     *
10689     * function greet(greeting, name) {
10690     *   return greeting + ' ' + name;
10691     * }
10692     *
10693     * var sayHelloTo = _.partial(greet, 'hello');
10694     * sayHelloTo('fred');
10695     * // => 'hello fred'
10696     *
10697     * // Partially applied with placeholders.
10698     * var greetFred = _.partial(greet, _, 'fred');
10699     * greetFred('hi');
10700     * // => 'hi fred'
10701     */
10702    var partial = baseRest(function(func, partials) {
10703      var holders = replaceHolders(partials, getHolder(partial));
10704      return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
10705    });
10706
10707    /**
10708     * This method is like `_.partial` except that partially applied arguments
10709     * are appended to the arguments it receives.
10710     *
10711     * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
10712     * builds, may be used as a placeholder for partially applied arguments.
10713     *
10714     * **Note:** This method doesn't set the "length" property of partially
10715     * applied functions.
10716     *
10717     * @static
10718     * @memberOf _
10719     * @since 1.0.0
10720     * @category Function
10721     * @param {Function} func The function to partially apply arguments to.
10722     * @param {...*} [partials] The arguments to be partially applied.
10723     * @returns {Function} Returns the new partially applied function.
10724     * @example
10725     *
10726     * function greet(greeting, name) {
10727     *   return greeting + ' ' + name;
10728     * }
10729     *
10730     * var greetFred = _.partialRight(greet, 'fred');
10731     * greetFred('hi');
10732     * // => 'hi fred'
10733     *
10734     * // Partially applied with placeholders.
10735     * var sayHelloTo = _.partialRight(greet, 'hello', _);
10736     * sayHelloTo('fred');
10737     * // => 'hello fred'
10738     */
10739    var partialRight = baseRest(function(func, partials) {
10740      var holders = replaceHolders(partials, getHolder(partialRight));
10741      return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
10742    });
10743
10744    /**
10745     * Creates a function that invokes `func` with arguments arranged according
10746     * to the specified `indexes` where the argument value at the first index is
10747     * provided as the first argument, the argument value at the second index is
10748     * provided as the second argument, and so on.
10749     *
10750     * @static
10751     * @memberOf _
10752     * @since 3.0.0
10753     * @category Function
10754     * @param {Function} func The function to rearrange arguments for.
10755     * @param {...(number|number[])} indexes The arranged argument indexes.
10756     * @returns {Function} Returns the new function.
10757     * @example
10758     *
10759     * var rearged = _.rearg(function(a, b, c) {
10760     *   return [a, b, c];
10761     * }, [2, 0, 1]);
10762     *
10763     * rearged('b', 'c', 'a')
10764     * // => ['a', 'b', 'c']
10765     */
10766    var rearg = flatRest(function(func, indexes) {
10767      return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
10768    });
10769
10770    /**
10771     * Creates a function that invokes `func` with the `this` binding of the
10772     * created function and arguments from `start` and beyond provided as
10773     * an array.
10774     *
10775     * **Note:** This method is based on the
10776     * [rest parameter](https://mdn.io/rest_parameters).
10777     *
10778     * @static
10779     * @memberOf _
10780     * @since 4.0.0
10781     * @category Function
10782     * @param {Function} func The function to apply a rest parameter to.
10783     * @param {number} [start=func.length-1] The start position of the rest parameter.
10784     * @returns {Function} Returns the new function.
10785     * @example
10786     *
10787     * var say = _.rest(function(what, names) {
10788     *   return what + ' ' + _.initial(names).join(', ') +
10789     *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
10790     * });
10791     *
10792     * say('hello', 'fred', 'barney', 'pebbles');
10793     * // => 'hello fred, barney, & pebbles'
10794     */
10795    function rest(func, start) {
10796      if (typeof func != 'function') {
10797        throw new TypeError(FUNC_ERROR_TEXT);
10798      }
10799      start = start === undefined ? start : toInteger(start);
10800      return baseRest(func, start);
10801    }
10802
10803    /**
10804     * Creates a function that invokes `func` with the `this` binding of the
10805     * create function and an array of arguments much like
10806     * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
10807     *
10808     * **Note:** This method is based on the
10809     * [spread operator](https://mdn.io/spread_operator).
10810     *
10811     * @static
10812     * @memberOf _
10813     * @since 3.2.0
10814     * @category Function
10815     * @param {Function} func The function to spread arguments over.
10816     * @param {number} [start=0] The start position of the spread.
10817     * @returns {Function} Returns the new function.
10818     * @example
10819     *
10820     * var say = _.spread(function(who, what) {
10821     *   return who + ' says ' + what;
10822     * });
10823     *
10824     * say(['fred', 'hello']);
10825     * // => 'fred says hello'
10826     *
10827     * var numbers = Promise.all([
10828     *   Promise.resolve(40),
10829     *   Promise.resolve(36)
10830     * ]);
10831     *
10832     * numbers.then(_.spread(function(x, y) {
10833     *   return x + y;
10834     * }));
10835     * // => a Promise of 76
10836     */
10837    function spread(func, start) {
10838      if (typeof func != 'function') {
10839        throw new TypeError(FUNC_ERROR_TEXT);
10840      }
10841      start = start == null ? 0 : nativeMax(toInteger(start), 0);
10842      return baseRest(function(args) {
10843        var array = args[start],
10844            otherArgs = castSlice(args, 0, start);
10845
10846        if (array) {
10847          arrayPush(otherArgs, array);
10848        }
10849        return apply(func, this, otherArgs);
10850      });
10851    }
10852
10853    /**
10854     * Creates a throttled function that only invokes `func` at most once per
10855     * every `wait` milliseconds. The throttled function comes with a `cancel`
10856     * method to cancel delayed `func` invocations and a `flush` method to
10857     * immediately invoke them. Provide `options` to indicate whether `func`
10858     * should be invoked on the leading and/or trailing edge of the `wait`
10859     * timeout. The `func` is invoked with the last arguments provided to the
10860     * throttled function. Subsequent calls to the throttled function return the
10861     * result of the last `func` invocation.
10862     *
10863     * **Note:** If `leading` and `trailing` options are `true`, `func` is
10864     * invoked on the trailing edge of the timeout only if the throttled function
10865     * is invoked more than once during the `wait` timeout.
10866     *
10867     * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10868     * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10869     *
10870     * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10871     * for details over the differences between `_.throttle` and `_.debounce`.
10872     *
10873     * @static
10874     * @memberOf _
10875     * @since 0.1.0
10876     * @category Function
10877     * @param {Function} func The function to throttle.
10878     * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
10879     * @param {Object} [options={}] The options object.
10880     * @param {boolean} [options.leading=true]
10881     *  Specify invoking on the leading edge of the timeout.
10882     * @param {boolean} [options.trailing=true]
10883     *  Specify invoking on the trailing edge of the timeout.
10884     * @returns {Function} Returns the new throttled function.
10885     * @example
10886     *
10887     * // Avoid excessively updating the position while scrolling.
10888     * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
10889     *
10890     * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
10891     * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
10892     * jQuery(element).on('click', throttled);
10893     *
10894     * // Cancel the trailing throttled invocation.
10895     * jQuery(window).on('popstate', throttled.cancel);
10896     */
10897    function throttle(func, wait, options) {
10898      var leading = true,
10899          trailing = true;
10900
10901      if (typeof func != 'function') {
10902        throw new TypeError(FUNC_ERROR_TEXT);
10903      }
10904      if (isObject(options)) {
10905        leading = 'leading' in options ? !!options.leading : leading;
10906        trailing = 'trailing' in options ? !!options.trailing : trailing;
10907      }
10908      return debounce(func, wait, {
10909        'leading': leading,
10910        'maxWait': wait,
10911        'trailing': trailing
10912      });
10913    }
10914
10915    /**
10916     * Creates a function that accepts up to one argument, ignoring any
10917     * additional arguments.
10918     *
10919     * @static
10920     * @memberOf _
10921     * @since 4.0.0
10922     * @category Function
10923     * @param {Function} func The function to cap arguments for.
10924     * @returns {Function} Returns the new capped function.
10925     * @example
10926     *
10927     * _.map(['6', '8', '10'], _.unary(parseInt));
10928     * // => [6, 8, 10]
10929     */
10930    function unary(func) {
10931      return ary(func, 1);
10932    }
10933
10934    /**
10935     * Creates a function that provides `value` to `wrapper` as its first
10936     * argument. Any additional arguments provided to the function are appended
10937     * to those provided to the `wrapper`. The wrapper is invoked with the `this`
10938     * binding of the created function.
10939     *
10940     * @static
10941     * @memberOf _
10942     * @since 0.1.0
10943     * @category Function
10944     * @param {*} value The value to wrap.
10945     * @param {Function} [wrapper=identity] The wrapper function.
10946     * @returns {Function} Returns the new function.
10947     * @example
10948     *
10949     * var p = _.wrap(_.escape, function(func, text) {
10950     *   return '<p>' + func(text) + '</p>';
10951     * });
10952     *
10953     * p('fred, barney, & pebbles');
10954     * // => '<p>fred, barney, &amp; pebbles</p>'
10955     */
10956    function wrap(value, wrapper) {
10957      return partial(castFunction(wrapper), value);
10958    }
10959
10960    /*------------------------------------------------------------------------*/
10961
10962    /**
10963     * Casts `value` as an array if it's not one.
10964     *
10965     * @static
10966     * @memberOf _
10967     * @since 4.4.0
10968     * @category Lang
10969     * @param {*} value The value to inspect.
10970     * @returns {Array} Returns the cast array.
10971     * @example
10972     *
10973     * _.castArray(1);
10974     * // => [1]
10975     *
10976     * _.castArray({ 'a': 1 });
10977     * // => [{ 'a': 1 }]
10978     *
10979     * _.castArray('abc');
10980     * // => ['abc']
10981     *
10982     * _.castArray(null);
10983     * // => [null]
10984     *
10985     * _.castArray(undefined);
10986     * // => [undefined]
10987     *
10988     * _.castArray();
10989     * // => []
10990     *
10991     * var array = [1, 2, 3];
10992     * console.log(_.castArray(array) === array);
10993     * // => true
10994     */
10995    function castArray() {
10996      if (!arguments.length) {
10997        return [];
10998      }
10999      var value = arguments[0];
11000      return isArray(value) ? value : [value];
11001    }
11002
11003    /**
11004     * Creates a shallow clone of `value`.
11005     *
11006     * **Note:** This method is loosely based on the
11007     * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
11008     * and supports cloning arrays, array buffers, booleans, date objects, maps,
11009     * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
11010     * arrays. The own enumerable properties of `arguments` objects are cloned
11011     * as plain objects. An empty object is returned for uncloneable values such
11012     * as error objects, functions, DOM nodes, and WeakMaps.
11013     *
11014     * @static
11015     * @memberOf _
11016     * @since 0.1.0
11017     * @category Lang
11018     * @param {*} value The value to clone.
11019     * @returns {*} Returns the cloned value.
11020     * @see _.cloneDeep
11021     * @example
11022     *
11023     * var objects = [{ 'a': 1 }, { 'b': 2 }];
11024     *
11025     * var shallow = _.clone(objects);
11026     * console.log(shallow[0] === objects[0]);
11027     * // => true
11028     */
11029    function clone(value) {
11030      return baseClone(value, CLONE_SYMBOLS_FLAG);
11031    }
11032
11033    /**
11034     * This method is like `_.clone` except that it accepts `customizer` which
11035     * is invoked to produce the cloned value. If `customizer` returns `undefined`,
11036     * cloning is handled by the method instead. The `customizer` is invoked with
11037     * up to four arguments; (value [, index|key, object, stack]).
11038     *
11039     * @static
11040     * @memberOf _
11041     * @since 4.0.0
11042     * @category Lang
11043     * @param {*} value The value to clone.
11044     * @param {Function} [customizer] The function to customize cloning.
11045     * @returns {*} Returns the cloned value.
11046     * @see _.cloneDeepWith
11047     * @example
11048     *
11049     * function customizer(value) {
11050     *   if (_.isElement(value)) {
11051     *     return value.cloneNode(false);
11052     *   }
11053     * }
11054     *
11055     * var el = _.cloneWith(document.body, customizer);
11056     *
11057     * console.log(el === document.body);
11058     * // => false
11059     * console.log(el.nodeName);
11060     * // => 'BODY'
11061     * console.log(el.childNodes.length);
11062     * // => 0
11063     */
11064    function cloneWith(value, customizer) {
11065      customizer = typeof customizer == 'function' ? customizer : undefined;
11066      return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
11067    }
11068
11069    /**
11070     * This method is like `_.clone` except that it recursively clones `value`.
11071     *
11072     * @static
11073     * @memberOf _
11074     * @since 1.0.0
11075     * @category Lang
11076     * @param {*} value The value to recursively clone.
11077     * @returns {*} Returns the deep cloned value.
11078     * @see _.clone
11079     * @example
11080     *
11081     * var objects = [{ 'a': 1 }, { 'b': 2 }];
11082     *
11083     * var deep = _.cloneDeep(objects);
11084     * console.log(deep[0] === objects[0]);
11085     * // => false
11086     */
11087    function cloneDeep(value) {
11088      return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
11089    }
11090
11091    /**
11092     * This method is like `_.cloneWith` except that it recursively clones `value`.
11093     *
11094     * @static
11095     * @memberOf _
11096     * @since 4.0.0
11097     * @category Lang
11098     * @param {*} value The value to recursively clone.
11099     * @param {Function} [customizer] The function to customize cloning.
11100     * @returns {*} Returns the deep cloned value.
11101     * @see _.cloneWith
11102     * @example
11103     *
11104     * function customizer(value) {
11105     *   if (_.isElement(value)) {
11106     *     return value.cloneNode(true);
11107     *   }
11108     * }
11109     *
11110     * var el = _.cloneDeepWith(document.body, customizer);
11111     *
11112     * console.log(el === document.body);
11113     * // => false
11114     * console.log(el.nodeName);
11115     * // => 'BODY'
11116     * console.log(el.childNodes.length);
11117     * // => 20
11118     */
11119    function cloneDeepWith(value, customizer) {
11120      customizer = typeof customizer == 'function' ? customizer : undefined;
11121      return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
11122    }
11123
11124    /**
11125     * Checks if `object` conforms to `source` by invoking the predicate
11126     * properties of `source` with the corresponding property values of `object`.
11127     *
11128     * **Note:** This method is equivalent to `_.conforms` when `source` is
11129     * partially applied.
11130     *
11131     * @static
11132     * @memberOf _
11133     * @since 4.14.0
11134     * @category Lang
11135     * @param {Object} object The object to inspect.
11136     * @param {Object} source The object of property predicates to conform to.
11137     * @returns {boolean} Returns `true` if `object` conforms, else `false`.
11138     * @example
11139     *
11140     * var object = { 'a': 1, 'b': 2 };
11141     *
11142     * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11143     * // => true
11144     *
11145     * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11146     * // => false
11147     */
11148    function conformsTo(object, source) {
11149      return source == null || baseConformsTo(object, source, keys(source));
11150    }
11151
11152    /**
11153     * Performs a
11154     * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11155     * comparison between two values to determine if they are equivalent.
11156     *
11157     * @static
11158     * @memberOf _
11159     * @since 4.0.0
11160     * @category Lang
11161     * @param {*} value The value to compare.
11162     * @param {*} other The other value to compare.
11163     * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11164     * @example
11165     *
11166     * var object = { 'a': 1 };
11167     * var other = { 'a': 1 };
11168     *
11169     * _.eq(object, object);
11170     * // => true
11171     *
11172     * _.eq(object, other);
11173     * // => false
11174     *
11175     * _.eq('a', 'a');
11176     * // => true
11177     *
11178     * _.eq('a', Object('a'));
11179     * // => false
11180     *
11181     * _.eq(NaN, NaN);
11182     * // => true
11183     */
11184    function eq(value, other) {
11185      return value === other || (value !== value && other !== other);
11186    }
11187
11188    /**
11189     * Checks if `value` is greater than `other`.
11190     *
11191     * @static
11192     * @memberOf _
11193     * @since 3.9.0
11194     * @category Lang
11195     * @param {*} value The value to compare.
11196     * @param {*} other The other value to compare.
11197     * @returns {boolean} Returns `true` if `value` is greater than `other`,
11198     *  else `false`.
11199     * @see _.lt
11200     * @example
11201     *
11202     * _.gt(3, 1);
11203     * // => true
11204     *
11205     * _.gt(3, 3);
11206     * // => false
11207     *
11208     * _.gt(1, 3);
11209     * // => false
11210     */
11211    var gt = createRelationalOperation(baseGt);
11212
11213    /**
11214     * Checks if `value` is greater than or equal to `other`.
11215     *
11216     * @static
11217     * @memberOf _
11218     * @since 3.9.0
11219     * @category Lang
11220     * @param {*} value The value to compare.
11221     * @param {*} other The other value to compare.
11222     * @returns {boolean} Returns `true` if `value` is greater than or equal to
11223     *  `other`, else `false`.
11224     * @see _.lte
11225     * @example
11226     *
11227     * _.gte(3, 1);
11228     * // => true
11229     *
11230     * _.gte(3, 3);
11231     * // => true
11232     *
11233     * _.gte(1, 3);
11234     * // => false
11235     */
11236    var gte = createRelationalOperation(function(value, other) {
11237      return value >= other;
11238    });
11239
11240    /**
11241     * Checks if `value` is likely an `arguments` object.
11242     *
11243     * @static
11244     * @memberOf _
11245     * @since 0.1.0
11246     * @category Lang
11247     * @param {*} value The value to check.
11248     * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11249     *  else `false`.
11250     * @example
11251     *
11252     * _.isArguments(function() { return arguments; }());
11253     * // => true
11254     *
11255     * _.isArguments([1, 2, 3]);
11256     * // => false
11257     */
11258    var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11259      return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11260        !propertyIsEnumerable.call(value, 'callee');
11261    };
11262
11263    /**
11264     * Checks if `value` is classified as an `Array` object.
11265     *
11266     * @static
11267     * @memberOf _
11268     * @since 0.1.0
11269     * @category Lang
11270     * @param {*} value The value to check.
11271     * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11272     * @example
11273     *
11274     * _.isArray([1, 2, 3]);
11275     * // => true
11276     *
11277     * _.isArray(document.body.children);
11278     * // => false
11279     *
11280     * _.isArray('abc');
11281     * // => false
11282     *
11283     * _.isArray(_.noop);
11284     * // => false
11285     */
11286    var isArray = Array.isArray;
11287
11288    /**
11289     * Checks if `value` is classified as an `ArrayBuffer` object.
11290     *
11291     * @static
11292     * @memberOf _
11293     * @since 4.3.0
11294     * @category Lang
11295     * @param {*} value The value to check.
11296     * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11297     * @example
11298     *
11299     * _.isArrayBuffer(new ArrayBuffer(2));
11300     * // => true
11301     *
11302     * _.isArrayBuffer(new Array(2));
11303     * // => false
11304     */
11305    var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
11306
11307    /**
11308     * Checks if `value` is array-like. A value is considered array-like if it's
11309     * not a function and has a `value.length` that's an integer greater than or
11310     * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
11311     *
11312     * @static
11313     * @memberOf _
11314     * @since 4.0.0
11315     * @category Lang
11316     * @param {*} value The value to check.
11317     * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11318     * @example
11319     *
11320     * _.isArrayLike([1, 2, 3]);
11321     * // => true
11322     *
11323     * _.isArrayLike(document.body.children);
11324     * // => true
11325     *
11326     * _.isArrayLike('abc');
11327     * // => true
11328     *
11329     * _.isArrayLike(_.noop);
11330     * // => false
11331     */
11332    function isArrayLike(value) {
11333      return value != null && isLength(value.length) && !isFunction(value);
11334    }
11335
11336    /**
11337     * This method is like `_.isArrayLike` except that it also checks if `value`
11338     * is an object.
11339     *
11340     * @static
11341     * @memberOf _
11342     * @since 4.0.0
11343     * @category Lang
11344     * @param {*} value The value to check.
11345     * @returns {boolean} Returns `true` if `value` is an array-like object,
11346     *  else `false`.
11347     * @example
11348     *
11349     * _.isArrayLikeObject([1, 2, 3]);
11350     * // => true
11351     *
11352     * _.isArrayLikeObject(document.body.children);
11353     * // => true
11354     *
11355     * _.isArrayLikeObject('abc');
11356     * // => false
11357     *
11358     * _.isArrayLikeObject(_.noop);
11359     * // => false
11360     */
11361    function isArrayLikeObject(value) {
11362      return isObjectLike(value) && isArrayLike(value);
11363    }
11364
11365    /**
11366     * Checks if `value` is classified as a boolean primitive or object.
11367     *
11368     * @static
11369     * @memberOf _
11370     * @since 0.1.0
11371     * @category Lang
11372     * @param {*} value The value to check.
11373     * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11374     * @example
11375     *
11376     * _.isBoolean(false);
11377     * // => true
11378     *
11379     * _.isBoolean(null);
11380     * // => false
11381     */
11382    function isBoolean(value) {
11383      return value === true || value === false ||
11384        (isObjectLike(value) && baseGetTag(value) == boolTag);
11385    }
11386
11387    /**
11388     * Checks if `value` is a buffer.
11389     *
11390     * @static
11391     * @memberOf _
11392     * @since 4.3.0
11393     * @category Lang
11394     * @param {*} value The value to check.
11395     * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11396     * @example
11397     *
11398     * _.isBuffer(new Buffer(2));
11399     * // => true
11400     *
11401     * _.isBuffer(new Uint8Array(2));
11402     * // => false
11403     */
11404    var isBuffer = nativeIsBuffer || stubFalse;
11405
11406    /**
11407     * Checks if `value` is classified as a `Date` object.
11408     *
11409     * @static
11410     * @memberOf _
11411     * @since 0.1.0
11412     * @category Lang
11413     * @param {*} value The value to check.
11414     * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11415     * @example
11416     *
11417     * _.isDate(new Date);
11418     * // => true
11419     *
11420     * _.isDate('Mon April 23 2012');
11421     * // => false
11422     */
11423    var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11424
11425    /**
11426     * Checks if `value` is likely a DOM element.
11427     *
11428     * @static
11429     * @memberOf _
11430     * @since 0.1.0
11431     * @category Lang
11432     * @param {*} value The value to check.
11433     * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11434     * @example
11435     *
11436     * _.isElement(document.body);
11437     * // => true
11438     *
11439     * _.isElement('<body>');
11440     * // => false
11441     */
11442    function isElement(value) {
11443      return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11444    }
11445
11446    /**
11447     * Checks if `value` is an empty object, collection, map, or set.
11448     *
11449     * Objects are considered empty if they have no own enumerable string keyed
11450     * properties.
11451     *
11452     * Array-like values such as `arguments` objects, arrays, buffers, strings, or
11453     * jQuery-like collections are considered empty if they have a `length` of `0`.
11454     * Similarly, maps and sets are considered empty if they have a `size` of `0`.
11455     *
11456     * @static
11457     * @memberOf _
11458     * @since 0.1.0
11459     * @category Lang
11460     * @param {*} value The value to check.
11461     * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11462     * @example
11463     *
11464     * _.isEmpty(null);
11465     * // => true
11466     *
11467     * _.isEmpty(true);
11468     * // => true
11469     *
11470     * _.isEmpty(1);
11471     * // => true
11472     *
11473     * _.isEmpty([1, 2, 3]);
11474     * // => false
11475     *
11476     * _.isEmpty({ 'a': 1 });
11477     * // => false
11478     */
11479    function isEmpty(value) {
11480      if (value == null) {
11481        return true;
11482      }
11483      if (isArrayLike(value) &&
11484          (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
11485            isBuffer(value) || isTypedArray(value) || isArguments(value))) {
11486        return !value.length;
11487      }
11488      var tag = getTag(value);
11489      if (tag == mapTag || tag == setTag) {
11490        return !value.size;
11491      }
11492      if (isPrototype(value)) {
11493        return !baseKeys(value).length;
11494      }
11495      for (var key in value) {
11496        if (hasOwnProperty.call(value, key)) {
11497          return false;
11498        }
11499      }
11500      return true;
11501    }
11502
11503    /**
11504     * Performs a deep comparison between two values to determine if they are
11505     * equivalent.
11506     *
11507     * **Note:** This method supports comparing arrays, array buffers, booleans,
11508     * date objects, error objects, maps, numbers, `Object` objects, regexes,
11509     * sets, strings, symbols, and typed arrays. `Object` objects are compared
11510     * by their own, not inherited, enumerable properties. Functions and DOM
11511     * nodes are compared by strict equality, i.e. `===`.
11512     *
11513     * @static
11514     * @memberOf _
11515     * @since 0.1.0
11516     * @category Lang
11517     * @param {*} value The value to compare.
11518     * @param {*} other The other value to compare.
11519     * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11520     * @example
11521     *
11522     * var object = { 'a': 1 };
11523     * var other = { 'a': 1 };
11524     *
11525     * _.isEqual(object, other);
11526     * // => true
11527     *
11528     * object === other;
11529     * // => false
11530     */
11531    function isEqual(value, other) {
11532      return baseIsEqual(value, other);
11533    }
11534
11535    /**
11536     * This method is like `_.isEqual` except that it accepts `customizer` which
11537     * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11538     * are handled by the method instead. The `customizer` is invoked with up to
11539     * six arguments: (objValue, othValue [, index|key, object, other, stack]).
11540     *
11541     * @static
11542     * @memberOf _
11543     * @since 4.0.0
11544     * @category Lang
11545     * @param {*} value The value to compare.
11546     * @param {*} other The other value to compare.
11547     * @param {Function} [customizer] The function to customize comparisons.
11548     * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11549     * @example
11550     *
11551     * function isGreeting(value) {
11552     *   return /^h(?:i|ello)$/.test(value);
11553     * }
11554     *
11555     * function customizer(objValue, othValue) {
11556     *   if (isGreeting(objValue) && isGreeting(othValue)) {
11557     *     return true;
11558     *   }
11559     * }
11560     *
11561     * var array = ['hello', 'goodbye'];
11562     * var other = ['hi', 'goodbye'];
11563     *
11564     * _.isEqualWith(array, other, customizer);
11565     * // => true
11566     */
11567    function isEqualWith(value, other, customizer) {
11568      customizer = typeof customizer == 'function' ? customizer : undefined;
11569      var result = customizer ? customizer(value, other) : undefined;
11570      return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
11571    }
11572
11573    /**
11574     * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11575     * `SyntaxError`, `TypeError`, or `URIError` object.
11576     *
11577     * @static
11578     * @memberOf _
11579     * @since 3.0.0
11580     * @category Lang
11581     * @param {*} value The value to check.
11582     * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11583     * @example
11584     *
11585     * _.isError(new Error);
11586     * // => true
11587     *
11588     * _.isError(Error);
11589     * // => false
11590     */
11591    function isError(value) {
11592      if (!isObjectLike(value)) {
11593        return false;
11594      }
11595      var tag = baseGetTag(value);
11596      return tag == errorTag || tag == domExcTag ||
11597        (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11598    }
11599
11600    /**
11601     * Checks if `value` is a finite primitive number.
11602     *
11603     * **Note:** This method is based on
11604     * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11605     *
11606     * @static
11607     * @memberOf _
11608     * @since 0.1.0
11609     * @category Lang
11610     * @param {*} value The value to check.
11611     * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11612     * @example
11613     *
11614     * _.isFinite(3);
11615     * // => true
11616     *
11617     * _.isFinite(Number.MIN_VALUE);
11618     * // => true
11619     *
11620     * _.isFinite(Infinity);
11621     * // => false
11622     *
11623     * _.isFinite('3');
11624     * // => false
11625     */
11626    function isFinite(value) {
11627      return typeof value == 'number' && nativeIsFinite(value);
11628    }
11629
11630    /**
11631     * Checks if `value` is classified as a `Function` object.
11632     *
11633     * @static
11634     * @memberOf _
11635     * @since 0.1.0
11636     * @category Lang
11637     * @param {*} value The value to check.
11638     * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11639     * @example
11640     *
11641     * _.isFunction(_);
11642     * // => true
11643     *
11644     * _.isFunction(/abc/);
11645     * // => false
11646     */
11647    function isFunction(value) {
11648      if (!isObject(value)) {
11649        return false;
11650      }
11651      // The use of `Object#toString` avoids issues with the `typeof` operator
11652      // in Safari 9 which returns 'object' for typed arrays and other constructors.
11653      var tag = baseGetTag(value);
11654      return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11655    }
11656
11657    /**
11658     * Checks if `value` is an integer.
11659     *
11660     * **Note:** This method is based on
11661     * [`Number.isInteger`](https://mdn.io/Number/isInteger).
11662     *
11663     * @static
11664     * @memberOf _
11665     * @since 4.0.0
11666     * @category Lang
11667     * @param {*} value The value to check.
11668     * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
11669     * @example
11670     *
11671     * _.isInteger(3);
11672     * // => true
11673     *
11674     * _.isInteger(Number.MIN_VALUE);
11675     * // => false
11676     *
11677     * _.isInteger(Infinity);
11678     * // => false
11679     *
11680     * _.isInteger('3');
11681     * // => false
11682     */
11683    function isInteger(value) {
11684      return typeof value == 'number' && value == toInteger(value);
11685    }
11686
11687    /**
11688     * Checks if `value` is a valid array-like length.
11689     *
11690     * **Note:** This method is loosely based on
11691     * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
11692     *
11693     * @static
11694     * @memberOf _
11695     * @since 4.0.0
11696     * @category Lang
11697     * @param {*} value The value to check.
11698     * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11699     * @example
11700     *
11701     * _.isLength(3);
11702     * // => true
11703     *
11704     * _.isLength(Number.MIN_VALUE);
11705     * // => false
11706     *
11707     * _.isLength(Infinity);
11708     * // => false
11709     *
11710     * _.isLength('3');
11711     * // => false
11712     */
11713    function isLength(value) {
11714      return typeof value == 'number' &&
11715        value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
11716    }
11717
11718    /**
11719     * Checks if `value` is the
11720     * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11721     * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11722     *
11723     * @static
11724     * @memberOf _
11725     * @since 0.1.0
11726     * @category Lang
11727     * @param {*} value The value to check.
11728     * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11729     * @example
11730     *
11731     * _.isObject({});
11732     * // => true
11733     *
11734     * _.isObject([1, 2, 3]);
11735     * // => true
11736     *
11737     * _.isObject(_.noop);
11738     * // => true
11739     *
11740     * _.isObject(null);
11741     * // => false
11742     */
11743    function isObject(value) {
11744      var type = typeof value;
11745      return value != null && (type == 'object' || type == 'function');
11746    }
11747
11748    /**
11749     * Checks if `value` is object-like. A value is object-like if it's not `null`
11750     * and has a `typeof` result of "object".
11751     *
11752     * @static
11753     * @memberOf _
11754     * @since 4.0.0
11755     * @category Lang
11756     * @param {*} value The value to check.
11757     * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11758     * @example
11759     *
11760     * _.isObjectLike({});
11761     * // => true
11762     *
11763     * _.isObjectLike([1, 2, 3]);
11764     * // => true
11765     *
11766     * _.isObjectLike(_.noop);
11767     * // => false
11768     *
11769     * _.isObjectLike(null);
11770     * // => false
11771     */
11772    function isObjectLike(value) {
11773      return value != null && typeof value == 'object';
11774    }
11775
11776    /**
11777     * Checks if `value` is classified as a `Map` object.
11778     *
11779     * @static
11780     * @memberOf _
11781     * @since 4.3.0
11782     * @category Lang
11783     * @param {*} value The value to check.
11784     * @returns {boolean} Returns `true` if `value` is a map, else `false`.
11785     * @example
11786     *
11787     * _.isMap(new Map);
11788     * // => true
11789     *
11790     * _.isMap(new WeakMap);
11791     * // => false
11792     */
11793    var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
11794
11795    /**
11796     * Performs a partial deep comparison between `object` and `source` to
11797     * determine if `object` contains equivalent property values.
11798     *
11799     * **Note:** This method is equivalent to `_.matches` when `source` is
11800     * partially applied.
11801     *
11802     * Partial comparisons will match empty array and empty object `source`
11803     * values against any array or object value, respectively. See `_.isEqual`
11804     * for a list of supported value comparisons.
11805     *
11806     * @static
11807     * @memberOf _
11808     * @since 3.0.0
11809     * @category Lang
11810     * @param {Object} object The object to inspect.
11811     * @param {Object} source The object of property values to match.
11812     * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11813     * @example
11814     *
11815     * var object = { 'a': 1, 'b': 2 };
11816     *
11817     * _.isMatch(object, { 'b': 2 });
11818     * // => true
11819     *
11820     * _.isMatch(object, { 'b': 1 });
11821     * // => false
11822     */
11823    function isMatch(object, source) {
11824      return object === source || baseIsMatch(object, source, getMatchData(source));
11825    }
11826
11827    /**
11828     * This method is like `_.isMatch` except that it accepts `customizer` which
11829     * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11830     * are handled by the method instead. The `customizer` is invoked with five
11831     * arguments: (objValue, srcValue, index|key, object, source).
11832     *
11833     * @static
11834     * @memberOf _
11835     * @since 4.0.0
11836     * @category Lang
11837     * @param {Object} object The object to inspect.
11838     * @param {Object} source The object of property values to match.
11839     * @param {Function} [customizer] The function to customize comparisons.
11840     * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11841     * @example
11842     *
11843     * function isGreeting(value) {
11844     *   return /^h(?:i|ello)$/.test(value);
11845     * }
11846     *
11847     * function customizer(objValue, srcValue) {
11848     *   if (isGreeting(objValue) && isGreeting(srcValue)) {
11849     *     return true;
11850     *   }
11851     * }
11852     *
11853     * var object = { 'greeting': 'hello' };
11854     * var source = { 'greeting': 'hi' };
11855     *
11856     * _.isMatchWith(object, source, customizer);
11857     * // => true
11858     */
11859    function isMatchWith(object, source, customizer) {
11860      customizer = typeof customizer == 'function' ? customizer : undefined;
11861      return baseIsMatch(object, source, getMatchData(source), customizer);
11862    }
11863
11864    /**
11865     * Checks if `value` is `NaN`.
11866     *
11867     * **Note:** This method is based on
11868     * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
11869     * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
11870     * `undefined` and other non-number values.
11871     *
11872     * @static
11873     * @memberOf _
11874     * @since 0.1.0
11875     * @category Lang
11876     * @param {*} value The value to check.
11877     * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
11878     * @example
11879     *
11880     * _.isNaN(NaN);
11881     * // => true
11882     *
11883     * _.isNaN(new Number(NaN));
11884     * // => true
11885     *
11886     * isNaN(undefined);
11887     * // => true
11888     *
11889     * _.isNaN(undefined);
11890     * // => false
11891     */
11892    function isNaN(value) {
11893      // An `NaN` primitive is the only value that is not equal to itself.
11894      // Perform the `toStringTag` check first to avoid errors with some
11895      // ActiveX objects in IE.
11896      return isNumber(value) && value != +value;
11897    }
11898
11899    /**
11900     * Checks if `value` is a pristine native function.
11901     *
11902     * **Note:** This method can't reliably detect native functions in the presence
11903     * of the core-js package because core-js circumvents this kind of detection.
11904     * Despite multiple requests, the core-js maintainer has made it clear: any
11905     * attempt to fix the detection will be obstructed. As a result, we're left
11906     * with little choice but to throw an error. Unfortunately, this also affects
11907     * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
11908     * which rely on core-js.
11909     *
11910     * @static
11911     * @memberOf _
11912     * @since 3.0.0
11913     * @category Lang
11914     * @param {*} value The value to check.
11915     * @returns {boolean} Returns `true` if `value` is a native function,
11916     *  else `false`.
11917     * @example
11918     *
11919     * _.isNative(Array.prototype.push);
11920     * // => true
11921     *
11922     * _.isNative(_);
11923     * // => false
11924     */
11925    function isNative(value) {
11926      if (isMaskable(value)) {
11927        throw new Error(CORE_ERROR_TEXT);
11928      }
11929      return baseIsNative(value);
11930    }
11931
11932    /**
11933     * Checks if `value` is `null`.
11934     *
11935     * @static
11936     * @memberOf _
11937     * @since 0.1.0
11938     * @category Lang
11939     * @param {*} value The value to check.
11940     * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
11941     * @example
11942     *
11943     * _.isNull(null);
11944     * // => true
11945     *
11946     * _.isNull(void 0);
11947     * // => false
11948     */
11949    function isNull(value) {
11950      return value === null;
11951    }
11952
11953    /**
11954     * Checks if `value` is `null` or `undefined`.
11955     *
11956     * @static
11957     * @memberOf _
11958     * @since 4.0.0
11959     * @category Lang
11960     * @param {*} value The value to check.
11961     * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
11962     * @example
11963     *
11964     * _.isNil(null);
11965     * // => true
11966     *
11967     * _.isNil(void 0);
11968     * // => true
11969     *
11970     * _.isNil(NaN);
11971     * // => false
11972     */
11973    function isNil(value) {
11974      return value == null;
11975    }
11976
11977    /**
11978     * Checks if `value` is classified as a `Number` primitive or object.
11979     *
11980     * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
11981     * classified as numbers, use the `_.isFinite` method.
11982     *
11983     * @static
11984     * @memberOf _
11985     * @since 0.1.0
11986     * @category Lang
11987     * @param {*} value The value to check.
11988     * @returns {boolean} Returns `true` if `value` is a number, else `false`.
11989     * @example
11990     *
11991     * _.isNumber(3);
11992     * // => true
11993     *
11994     * _.isNumber(Number.MIN_VALUE);
11995     * // => true
11996     *
11997     * _.isNumber(Infinity);
11998     * // => true
11999     *
12000     * _.isNumber('3');
12001     * // => false
12002     */
12003    function isNumber(value) {
12004      return typeof value == 'number' ||
12005        (isObjectLike(value) && baseGetTag(value) == numberTag);
12006    }
12007
12008    /**
12009     * Checks if `value` is a plain object, that is, an object created by the
12010     * `Object` constructor or one with a `[[Prototype]]` of `null`.
12011     *
12012     * @static
12013     * @memberOf _
12014     * @since 0.8.0
12015     * @category Lang
12016     * @param {*} value The value to check.
12017     * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
12018     * @example
12019     *
12020     * function Foo() {
12021     *   this.a = 1;
12022     * }
12023     *
12024     * _.isPlainObject(new Foo);
12025     * // => false
12026     *
12027     * _.isPlainObject([1, 2, 3]);
12028     * // => false
12029     *
12030     * _.isPlainObject({ 'x': 0, 'y': 0 });
12031     * // => true
12032     *
12033     * _.isPlainObject(Object.create(null));
12034     * // => true
12035     */
12036    function isPlainObject(value) {
12037      if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12038        return false;
12039      }
12040      var proto = getPrototype(value);
12041      if (proto === null) {
12042        return true;
12043      }
12044      var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12045      return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12046        funcToString.call(Ctor) == objectCtorString;
12047    }
12048
12049    /**
12050     * Checks if `value` is classified as a `RegExp` object.
12051     *
12052     * @static
12053     * @memberOf _
12054     * @since 0.1.0
12055     * @category Lang
12056     * @param {*} value The value to check.
12057     * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12058     * @example
12059     *
12060     * _.isRegExp(/abc/);
12061     * // => true
12062     *
12063     * _.isRegExp('/abc/');
12064     * // => false
12065     */
12066    var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
12067
12068    /**
12069     * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
12070     * double precision number which isn't the result of a rounded unsafe integer.
12071     *
12072     * **Note:** This method is based on
12073     * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12074     *
12075     * @static
12076     * @memberOf _
12077     * @since 4.0.0
12078     * @category Lang
12079     * @param {*} value The value to check.
12080     * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12081     * @example
12082     *
12083     * _.isSafeInteger(3);
12084     * // => true
12085     *
12086     * _.isSafeInteger(Number.MIN_VALUE);
12087     * // => false
12088     *
12089     * _.isSafeInteger(Infinity);
12090     * // => false
12091     *
12092     * _.isSafeInteger('3');
12093     * // => false
12094     */
12095    function isSafeInteger(value) {
12096      return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12097    }
12098
12099    /**
12100     * Checks if `value` is classified as a `Set` object.
12101     *
12102     * @static
12103     * @memberOf _
12104     * @since 4.3.0
12105     * @category Lang
12106     * @param {*} value The value to check.
12107     * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12108     * @example
12109     *
12110     * _.isSet(new Set);
12111     * // => true
12112     *
12113     * _.isSet(new WeakSet);
12114     * // => false
12115     */
12116    var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12117
12118    /**
12119     * Checks if `value` is classified as a `String` primitive or object.
12120     *
12121     * @static
12122     * @since 0.1.0
12123     * @memberOf _
12124     * @category Lang
12125     * @param {*} value The value to check.
12126     * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12127     * @example
12128     *
12129     * _.isString('abc');
12130     * // => true
12131     *
12132     * _.isString(1);
12133     * // => false
12134     */
12135    function isString(value) {
12136      return typeof value == 'string' ||
12137        (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12138    }
12139
12140    /**
12141     * Checks if `value` is classified as a `Symbol` primitive or object.
12142     *
12143     * @static
12144     * @memberOf _
12145     * @since 4.0.0
12146     * @category Lang
12147     * @param {*} value The value to check.
12148     * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12149     * @example
12150     *
12151     * _.isSymbol(Symbol.iterator);
12152     * // => true
12153     *
12154     * _.isSymbol('abc');
12155     * // => false
12156     */
12157    function isSymbol(value) {
12158      return typeof value == 'symbol' ||
12159        (isObjectLike(value) && baseGetTag(value) == symbolTag);
12160    }
12161
12162    /**
12163     * Checks if `value` is classified as a typed array.
12164     *
12165     * @static
12166     * @memberOf _
12167     * @since 3.0.0
12168     * @category Lang
12169     * @param {*} value The value to check.
12170     * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12171     * @example
12172     *
12173     * _.isTypedArray(new Uint8Array);
12174     * // => true
12175     *
12176     * _.isTypedArray([]);
12177     * // => false
12178     */
12179    var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12180
12181    /**
12182     * Checks if `value` is `undefined`.
12183     *
12184     * @static
12185     * @since 0.1.0
12186     * @memberOf _
12187     * @category Lang
12188     * @param {*} value The value to check.
12189     * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12190     * @example
12191     *
12192     * _.isUndefined(void 0);
12193     * // => true
12194     *
12195     * _.isUndefined(null);
12196     * // => false
12197     */
12198    function isUndefined(value) {
12199      return value === undefined;
12200    }
12201
12202    /**
12203     * Checks if `value` is classified as a `WeakMap` object.
12204     *
12205     * @static
12206     * @memberOf _
12207     * @since 4.3.0
12208     * @category Lang
12209     * @param {*} value The value to check.
12210     * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12211     * @example
12212     *
12213     * _.isWeakMap(new WeakMap);
12214     * // => true
12215     *
12216     * _.isWeakMap(new Map);
12217     * // => false
12218     */
12219    function isWeakMap(value) {
12220      return isObjectLike(value) && getTag(value) == weakMapTag;
12221    }
12222
12223    /**
12224     * Checks if `value` is classified as a `WeakSet` object.
12225     *
12226     * @static
12227     * @memberOf _
12228     * @since 4.3.0
12229     * @category Lang
12230     * @param {*} value The value to check.
12231     * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12232     * @example
12233     *
12234     * _.isWeakSet(new WeakSet);
12235     * // => true
12236     *
12237     * _.isWeakSet(new Set);
12238     * // => false
12239     */
12240    function isWeakSet(value) {
12241      return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12242    }
12243
12244    /**
12245     * Checks if `value` is less than `other`.
12246     *
12247     * @static
12248     * @memberOf _
12249     * @since 3.9.0
12250     * @category Lang
12251     * @param {*} value The value to compare.
12252     * @param {*} other The other value to compare.
12253     * @returns {boolean} Returns `true` if `value` is less than `other`,
12254     *  else `false`.
12255     * @see _.gt
12256     * @example
12257     *
12258     * _.lt(1, 3);
12259     * // => true
12260     *
12261     * _.lt(3, 3);
12262     * // => false
12263     *
12264     * _.lt(3, 1);
12265     * // => false
12266     */
12267    var lt = createRelationalOperation(baseLt);
12268
12269    /**
12270     * Checks if `value` is less than or equal to `other`.
12271     *
12272     * @static
12273     * @memberOf _
12274     * @since 3.9.0
12275     * @category Lang
12276     * @param {*} value The value to compare.
12277     * @param {*} other The other value to compare.
12278     * @returns {boolean} Returns `true` if `value` is less than or equal to
12279     *  `other`, else `false`.
12280     * @see _.gte
12281     * @example
12282     *
12283     * _.lte(1, 3);
12284     * // => true
12285     *
12286     * _.lte(3, 3);
12287     * // => true
12288     *
12289     * _.lte(3, 1);
12290     * // => false
12291     */
12292    var lte = createRelationalOperation(function(value, other) {
12293      return value <= other;
12294    });
12295
12296    /**
12297     * Converts `value` to an array.
12298     *
12299     * @static
12300     * @since 0.1.0
12301     * @memberOf _
12302     * @category Lang
12303     * @param {*} value The value to convert.
12304     * @returns {Array} Returns the converted array.
12305     * @example
12306     *
12307     * _.toArray({ 'a': 1, 'b': 2 });
12308     * // => [1, 2]
12309     *
12310     * _.toArray('abc');
12311     * // => ['a', 'b', 'c']
12312     *
12313     * _.toArray(1);
12314     * // => []
12315     *
12316     * _.toArray(null);
12317     * // => []
12318     */
12319    function toArray(value) {
12320      if (!value) {
12321        return [];
12322      }
12323      if (isArrayLike(value)) {
12324        return isString(value) ? stringToArray(value) : copyArray(value);
12325      }
12326      if (symIterator && value[symIterator]) {
12327        return iteratorToArray(value[symIterator]());
12328      }
12329      var tag = getTag(value),
12330          func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12331
12332      return func(value);
12333    }
12334
12335    /**
12336     * Converts `value` to a finite number.
12337     *
12338     * @static
12339     * @memberOf _
12340     * @since 4.12.0
12341     * @category Lang
12342     * @param {*} value The value to convert.
12343     * @returns {number} Returns the converted number.
12344     * @example
12345     *
12346     * _.toFinite(3.2);
12347     * // => 3.2
12348     *
12349     * _.toFinite(Number.MIN_VALUE);
12350     * // => 5e-324
12351     *
12352     * _.toFinite(Infinity);
12353     * // => 1.7976931348623157e+308
12354     *
12355     * _.toFinite('3.2');
12356     * // => 3.2
12357     */
12358    function toFinite(value) {
12359      if (!value) {
12360        return value === 0 ? value : 0;
12361      }
12362      value = toNumber(value);
12363      if (value === INFINITY || value === -INFINITY) {
12364        var sign = (value < 0 ? -1 : 1);
12365        return sign * MAX_INTEGER;
12366      }
12367      return value === value ? value : 0;
12368    }
12369
12370    /**
12371     * Converts `value` to an integer.
12372     *
12373     * **Note:** This method is loosely based on
12374     * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12375     *
12376     * @static
12377     * @memberOf _
12378     * @since 4.0.0
12379     * @category Lang
12380     * @param {*} value The value to convert.
12381     * @returns {number} Returns the converted integer.
12382     * @example
12383     *
12384     * _.toInteger(3.2);
12385     * // => 3
12386     *
12387     * _.toInteger(Number.MIN_VALUE);
12388     * // => 0
12389     *
12390     * _.toInteger(Infinity);
12391     * // => 1.7976931348623157e+308
12392     *
12393     * _.toInteger('3.2');
12394     * // => 3
12395     */
12396    function toInteger(value) {
12397      var result = toFinite(value),
12398          remainder = result % 1;
12399
12400      return result === result ? (remainder ? result - remainder : result) : 0;
12401    }
12402
12403    /**
12404     * Converts `value` to an integer suitable for use as the length of an
12405     * array-like object.
12406     *
12407     * **Note:** This method is based on
12408     * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12409     *
12410     * @static
12411     * @memberOf _
12412     * @since 4.0.0
12413     * @category Lang
12414     * @param {*} value The value to convert.
12415     * @returns {number} Returns the converted integer.
12416     * @example
12417     *
12418     * _.toLength(3.2);
12419     * // => 3
12420     *
12421     * _.toLength(Number.MIN_VALUE);
12422     * // => 0
12423     *
12424     * _.toLength(Infinity);
12425     * // => 4294967295
12426     *
12427     * _.toLength('3.2');
12428     * // => 3
12429     */
12430    function toLength(value) {
12431      return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12432    }
12433
12434    /**
12435     * Converts `value` to a number.
12436     *
12437     * @static
12438     * @memberOf _
12439     * @since 4.0.0
12440     * @category Lang
12441     * @param {*} value The value to process.
12442     * @returns {number} Returns the number.
12443     * @example
12444     *
12445     * _.toNumber(3.2);
12446     * // => 3.2
12447     *
12448     * _.toNumber(Number.MIN_VALUE);
12449     * // => 5e-324
12450     *
12451     * _.toNumber(Infinity);
12452     * // => Infinity
12453     *
12454     * _.toNumber('3.2');
12455     * // => 3.2
12456     */
12457    function toNumber(value) {
12458      if (typeof value == 'number') {
12459        return value;
12460      }
12461      if (isSymbol(value)) {
12462        return NAN;
12463      }
12464      if (isObject(value)) {
12465        var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12466        value = isObject(other) ? (other + '') : other;
12467      }
12468      if (typeof value != 'string') {
12469        return value === 0 ? value : +value;
12470      }
12471      value = value.replace(reTrim, '');
12472      var isBinary = reIsBinary.test(value);
12473      return (isBinary || reIsOctal.test(value))
12474        ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
12475        : (reIsBadHex.test(value) ? NAN : +value);
12476    }
12477
12478    /**
12479     * Converts `value` to a plain object flattening inherited enumerable string
12480     * keyed properties of `value` to own properties of the plain object.
12481     *
12482     * @static
12483     * @memberOf _
12484     * @since 3.0.0
12485     * @category Lang
12486     * @param {*} value The value to convert.
12487     * @returns {Object} Returns the converted plain object.
12488     * @example
12489     *
12490     * function Foo() {
12491     *   this.b = 2;
12492     * }
12493     *
12494     * Foo.prototype.c = 3;
12495     *
12496     * _.assign({ 'a': 1 }, new Foo);
12497     * // => { 'a': 1, 'b': 2 }
12498     *
12499     * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12500     * // => { 'a': 1, 'b': 2, 'c': 3 }
12501     */
12502    function toPlainObject(value) {
12503      return copyObject(value, keysIn(value));
12504    }
12505
12506    /**
12507     * Converts `value` to a safe integer. A safe integer can be compared and
12508     * represented correctly.
12509     *
12510     * @static
12511     * @memberOf _
12512     * @since 4.0.0
12513     * @category Lang
12514     * @param {*} value The value to convert.
12515     * @returns {number} Returns the converted integer.
12516     * @example
12517     *
12518     * _.toSafeInteger(3.2);
12519     * // => 3
12520     *
12521     * _.toSafeInteger(Number.MIN_VALUE);
12522     * // => 0
12523     *
12524     * _.toSafeInteger(Infinity);
12525     * // => 9007199254740991
12526     *
12527     * _.toSafeInteger('3.2');
12528     * // => 3
12529     */
12530    function toSafeInteger(value) {
12531      return value
12532        ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
12533        : (value === 0 ? value : 0);
12534    }
12535
12536    /**
12537     * Converts `value` to a string. An empty string is returned for `null`
12538     * and `undefined` values. The sign of `-0` is preserved.
12539     *
12540     * @static
12541     * @memberOf _
12542     * @since 4.0.0
12543     * @category Lang
12544     * @param {*} value The value to convert.
12545     * @returns {string} Returns the converted string.
12546     * @example
12547     *
12548     * _.toString(null);
12549     * // => ''
12550     *
12551     * _.toString(-0);
12552     * // => '-0'
12553     *
12554     * _.toString([1, 2, 3]);
12555     * // => '1,2,3'
12556     */
12557    function toString(value) {
12558      return value == null ? '' : baseToString(value);
12559    }
12560
12561    /*------------------------------------------------------------------------*/
12562
12563    /**
12564     * Assigns own enumerable string keyed properties of source objects to the
12565     * destination object. Source objects are applied from left to right.
12566     * Subsequent sources overwrite property assignments of previous sources.
12567     *
12568     * **Note:** This method mutates `object` and is loosely based on
12569     * [`Object.assign`](https://mdn.io/Object/assign).
12570     *
12571     * @static
12572     * @memberOf _
12573     * @since 0.10.0
12574     * @category Object
12575     * @param {Object} object The destination object.
12576     * @param {...Object} [sources] The source objects.
12577     * @returns {Object} Returns `object`.
12578     * @see _.assignIn
12579     * @example
12580     *
12581     * function Foo() {
12582     *   this.a = 1;
12583     * }
12584     *
12585     * function Bar() {
12586     *   this.c = 3;
12587     * }
12588     *
12589     * Foo.prototype.b = 2;
12590     * Bar.prototype.d = 4;
12591     *
12592     * _.assign({ 'a': 0 }, new Foo, new Bar);
12593     * // => { 'a': 1, 'c': 3 }
12594     */
12595    var assign = createAssigner(function(object, source) {
12596      if (isPrototype(source) || isArrayLike(source)) {
12597        copyObject(source, keys(source), object);
12598        return;
12599      }
12600      for (var key in source) {
12601        if (hasOwnProperty.call(source, key)) {
12602          assignValue(object, key, source[key]);
12603        }
12604      }
12605    });
12606
12607    /**
12608     * This method is like `_.assign` except that it iterates over own and
12609     * inherited source properties.
12610     *
12611     * **Note:** This method mutates `object`.
12612     *
12613     * @static
12614     * @memberOf _
12615     * @since 4.0.0
12616     * @alias extend
12617     * @category Object
12618     * @param {Object} object The destination object.
12619     * @param {...Object} [sources] The source objects.
12620     * @returns {Object} Returns `object`.
12621     * @see _.assign
12622     * @example
12623     *
12624     * function Foo() {
12625     *   this.a = 1;
12626     * }
12627     *
12628     * function Bar() {
12629     *   this.c = 3;
12630     * }
12631     *
12632     * Foo.prototype.b = 2;
12633     * Bar.prototype.d = 4;
12634     *
12635     * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12636     * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12637     */
12638    var assignIn = createAssigner(function(object, source) {
12639      copyObject(source, keysIn(source), object);
12640    });
12641
12642    /**
12643     * This method is like `_.assignIn` except that it accepts `customizer`
12644     * which is invoked to produce the assigned values. If `customizer` returns
12645     * `undefined`, assignment is handled by the method instead. The `customizer`
12646     * is invoked with five arguments: (objValue, srcValue, key, object, source).
12647     *
12648     * **Note:** This method mutates `object`.
12649     *
12650     * @static
12651     * @memberOf _
12652     * @since 4.0.0
12653     * @alias extendWith
12654     * @category Object
12655     * @param {Object} object The destination object.
12656     * @param {...Object} sources The source objects.
12657     * @param {Function} [customizer] The function to customize assigned values.
12658     * @returns {Object} Returns `object`.
12659     * @see _.assignWith
12660     * @example
12661     *
12662     * function customizer(objValue, srcValue) {
12663     *   return _.isUndefined(objValue) ? srcValue : objValue;
12664     * }
12665     *
12666     * var defaults = _.partialRight(_.assignInWith, customizer);
12667     *
12668     * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12669     * // => { 'a': 1, 'b': 2 }
12670     */
12671    var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
12672      copyObject(source, keysIn(source), object, customizer);
12673    });
12674
12675    /**
12676     * This method is like `_.assign` except that it accepts `customizer`
12677     * which is invoked to produce the assigned values. If `customizer` returns
12678     * `undefined`, assignment is handled by the method instead. The `customizer`
12679     * is invoked with five arguments: (objValue, srcValue, key, object, source).
12680     *
12681     * **Note:** This method mutates `object`.
12682     *
12683     * @static
12684     * @memberOf _
12685     * @since 4.0.0
12686     * @category Object
12687     * @param {Object} object The destination object.
12688     * @param {...Object} sources The source objects.
12689     * @param {Function} [customizer] The function to customize assigned values.
12690     * @returns {Object} Returns `object`.
12691     * @see _.assignInWith
12692     * @example
12693     *
12694     * function customizer(objValue, srcValue) {
12695     *   return _.isUndefined(objValue) ? srcValue : objValue;
12696     * }
12697     *
12698     * var defaults = _.partialRight(_.assignWith, customizer);
12699     *
12700     * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12701     * // => { 'a': 1, 'b': 2 }
12702     */
12703    var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
12704      copyObject(source, keys(source), object, customizer);
12705    });
12706
12707    /**
12708     * Creates an array of values corresponding to `paths` of `object`.
12709     *
12710     * @static
12711     * @memberOf _
12712     * @since 1.0.0
12713     * @category Object
12714     * @param {Object} object The object to iterate over.
12715     * @param {...(string|string[])} [paths] The property paths to pick.
12716     * @returns {Array} Returns the picked values.
12717     * @example
12718     *
12719     * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
12720     *
12721     * _.at(object, ['a[0].b.c', 'a[1]']);
12722     * // => [3, 4]
12723     */
12724    var at = flatRest(baseAt);
12725
12726    /**
12727     * Creates an object that inherits from the `prototype` object. If a
12728     * `properties` object is given, its own enumerable string keyed properties
12729     * are assigned to the created object.
12730     *
12731     * @static
12732     * @memberOf _
12733     * @since 2.3.0
12734     * @category Object
12735     * @param {Object} prototype The object to inherit from.
12736     * @param {Object} [properties] The properties to assign to the object.
12737     * @returns {Object} Returns the new object.
12738     * @example
12739     *
12740     * function Shape() {
12741     *   this.x = 0;
12742     *   this.y = 0;
12743     * }
12744     *
12745     * function Circle() {
12746     *   Shape.call(this);
12747     * }
12748     *
12749     * Circle.prototype = _.create(Shape.prototype, {
12750     *   'constructor': Circle
12751     * });
12752     *
12753     * var circle = new Circle;
12754     * circle instanceof Circle;
12755     * // => true
12756     *
12757     * circle instanceof Shape;
12758     * // => true
12759     */
12760    function create(prototype, properties) {
12761      var result = baseCreate(prototype);
12762      return properties == null ? result : baseAssign(result, properties);
12763    }
12764
12765    /**
12766     * Assigns own and inherited enumerable string keyed properties of source
12767     * objects to the destination object for all destination properties that
12768     * resolve to `undefined`. Source objects are applied from left to right.
12769     * Once a property is set, additional values of the same property are ignored.
12770     *
12771     * **Note:** This method mutates `object`.
12772     *
12773     * @static
12774     * @since 0.1.0
12775     * @memberOf _
12776     * @category Object
12777     * @param {Object} object The destination object.
12778     * @param {...Object} [sources] The source objects.
12779     * @returns {Object} Returns `object`.
12780     * @see _.defaultsDeep
12781     * @example
12782     *
12783     * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12784     * // => { 'a': 1, 'b': 2 }
12785     */
12786    var defaults = baseRest(function(object, sources) {
12787      object = Object(object);
12788
12789      var index = -1;
12790      var length = sources.length;
12791      var guard = length > 2 ? sources[2] : undefined;
12792
12793      if (guard && isIterateeCall(sources[0], sources[1], guard)) {
12794        length = 1;
12795      }
12796
12797      while (++index < length) {
12798        var source = sources[index];
12799        var props = keysIn(source);
12800        var propsIndex = -1;
12801        var propsLength = props.length;
12802
12803        while (++propsIndex < propsLength) {
12804          var key = props[propsIndex];
12805          var value = object[key];
12806
12807          if (value === undefined ||
12808              (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
12809            object[key] = source[key];
12810          }
12811        }
12812      }
12813
12814      return object;
12815    });
12816
12817    /**
12818     * This method is like `_.defaults` except that it recursively assigns
12819     * default properties.
12820     *
12821     * **Note:** This method mutates `object`.
12822     *
12823     * @static
12824     * @memberOf _
12825     * @since 3.10.0
12826     * @category Object
12827     * @param {Object} object The destination object.
12828     * @param {...Object} [sources] The source objects.
12829     * @returns {Object} Returns `object`.
12830     * @see _.defaults
12831     * @example
12832     *
12833     * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
12834     * // => { 'a': { 'b': 2, 'c': 3 } }
12835     */
12836    var defaultsDeep = baseRest(function(args) {
12837      args.push(undefined, customDefaultsMerge);
12838      return apply(mergeWith, undefined, args);
12839    });
12840
12841    /**
12842     * This method is like `_.find` except that it returns the key of the first
12843     * element `predicate` returns truthy for instead of the element itself.
12844     *
12845     * @static
12846     * @memberOf _
12847     * @since 1.1.0
12848     * @category Object
12849     * @param {Object} object The object to inspect.
12850     * @param {Function} [predicate=_.identity] The function invoked per iteration.
12851     * @returns {string|undefined} Returns the key of the matched element,
12852     *  else `undefined`.
12853     * @example
12854     *
12855     * var users = {
12856     *   'barney':  { 'age': 36, 'active': true },
12857     *   'fred':    { 'age': 40, 'active': false },
12858     *   'pebbles': { 'age': 1,  'active': true }
12859     * };
12860     *
12861     * _.findKey(users, function(o) { return o.age < 40; });
12862     * // => 'barney' (iteration order is not guaranteed)
12863     *
12864     * // The `_.matches` iteratee shorthand.
12865     * _.findKey(users, { 'age': 1, 'active': true });
12866     * // => 'pebbles'
12867     *
12868     * // The `_.matchesProperty` iteratee shorthand.
12869     * _.findKey(users, ['active', false]);
12870     * // => 'fred'
12871     *
12872     * // The `_.property` iteratee shorthand.
12873     * _.findKey(users, 'active');
12874     * // => 'barney'
12875     */
12876    function findKey(object, predicate) {
12877      return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
12878    }
12879
12880    /**
12881     * This method is like `_.findKey` except that it iterates over elements of
12882     * a collection in the opposite order.
12883     *
12884     * @static
12885     * @memberOf _
12886     * @since 2.0.0
12887     * @category Object
12888     * @param {Object} object The object to inspect.
12889     * @param {Function} [predicate=_.identity] The function invoked per iteration.
12890     * @returns {string|undefined} Returns the key of the matched element,
12891     *  else `undefined`.
12892     * @example
12893     *
12894     * var users = {
12895     *   'barney':  { 'age': 36, 'active': true },
12896     *   'fred':    { 'age': 40, 'active': false },
12897     *   'pebbles': { 'age': 1,  'active': true }
12898     * };
12899     *
12900     * _.findLastKey(users, function(o) { return o.age < 40; });
12901     * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
12902     *
12903     * // The `_.matches` iteratee shorthand.
12904     * _.findLastKey(users, { 'age': 36, 'active': true });
12905     * // => 'barney'
12906     *
12907     * // The `_.matchesProperty` iteratee shorthand.
12908     * _.findLastKey(users, ['active', false]);
12909     * // => 'fred'
12910     *
12911     * // The `_.property` iteratee shorthand.
12912     * _.findLastKey(users, 'active');
12913     * // => 'pebbles'
12914     */
12915    function findLastKey(object, predicate) {
12916      return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
12917    }
12918
12919    /**
12920     * Iterates over own and inherited enumerable string keyed properties of an
12921     * object and invokes `iteratee` for each property. The iteratee is invoked
12922     * with three arguments: (value, key, object). Iteratee functions may exit
12923     * iteration early by explicitly returning `false`.
12924     *
12925     * @static
12926     * @memberOf _
12927     * @since 0.3.0
12928     * @category Object
12929     * @param {Object} object The object to iterate over.
12930     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12931     * @returns {Object} Returns `object`.
12932     * @see _.forInRight
12933     * @example
12934     *
12935     * function Foo() {
12936     *   this.a = 1;
12937     *   this.b = 2;
12938     * }
12939     *
12940     * Foo.prototype.c = 3;
12941     *
12942     * _.forIn(new Foo, function(value, key) {
12943     *   console.log(key);
12944     * });
12945     * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
12946     */
12947    function forIn(object, iteratee) {
12948      return object == null
12949        ? object
12950        : baseFor(object, getIteratee(iteratee, 3), keysIn);
12951    }
12952
12953    /**
12954     * This method is like `_.forIn` except that it iterates over properties of
12955     * `object` in the opposite order.
12956     *
12957     * @static
12958     * @memberOf _
12959     * @since 2.0.0
12960     * @category Object
12961     * @param {Object} object The object to iterate over.
12962     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12963     * @returns {Object} Returns `object`.
12964     * @see _.forIn
12965     * @example
12966     *
12967     * function Foo() {
12968     *   this.a = 1;
12969     *   this.b = 2;
12970     * }
12971     *
12972     * Foo.prototype.c = 3;
12973     *
12974     * _.forInRight(new Foo, function(value, key) {
12975     *   console.log(key);
12976     * });
12977     * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
12978     */
12979    function forInRight(object, iteratee) {
12980      return object == null
12981        ? object
12982        : baseForRight(object, getIteratee(iteratee, 3), keysIn);
12983    }
12984
12985    /**
12986     * Iterates over own enumerable string keyed properties of an object and
12987     * invokes `iteratee` for each property. The iteratee is invoked with three
12988     * arguments: (value, key, object). Iteratee functions may exit iteration
12989     * early by explicitly returning `false`.
12990     *
12991     * @static
12992     * @memberOf _
12993     * @since 0.3.0
12994     * @category Object
12995     * @param {Object} object The object to iterate over.
12996     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12997     * @returns {Object} Returns `object`.
12998     * @see _.forOwnRight
12999     * @example
13000     *
13001     * function Foo() {
13002     *   this.a = 1;
13003     *   this.b = 2;
13004     * }
13005     *
13006     * Foo.prototype.c = 3;
13007     *
13008     * _.forOwn(new Foo, function(value, key) {
13009     *   console.log(key);
13010     * });
13011     * // => Logs 'a' then 'b' (iteration order is not guaranteed).
13012     */
13013    function forOwn(object, iteratee) {
13014      return object && baseForOwn(object, getIteratee(iteratee, 3));
13015    }
13016
13017    /**
13018     * This method is like `_.forOwn` except that it iterates over properties of
13019     * `object` in the opposite order.
13020     *
13021     * @static
13022     * @memberOf _
13023     * @since 2.0.0
13024     * @category Object
13025     * @param {Object} object The object to iterate over.
13026     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13027     * @returns {Object} Returns `object`.
13028     * @see _.forOwn
13029     * @example
13030     *
13031     * function Foo() {
13032     *   this.a = 1;
13033     *   this.b = 2;
13034     * }
13035     *
13036     * Foo.prototype.c = 3;
13037     *
13038     * _.forOwnRight(new Foo, function(value, key) {
13039     *   console.log(key);
13040     * });
13041     * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
13042     */
13043    function forOwnRight(object, iteratee) {
13044      return object && baseForOwnRight(object, getIteratee(iteratee, 3));
13045    }
13046
13047    /**
13048     * Creates an array of function property names from own enumerable properties
13049     * of `object`.
13050     *
13051     * @static
13052     * @since 0.1.0
13053     * @memberOf _
13054     * @category Object
13055     * @param {Object} object The object to inspect.
13056     * @returns {Array} Returns the function names.
13057     * @see _.functionsIn
13058     * @example
13059     *
13060     * function Foo() {
13061     *   this.a = _.constant('a');
13062     *   this.b = _.constant('b');
13063     * }
13064     *
13065     * Foo.prototype.c = _.constant('c');
13066     *
13067     * _.functions(new Foo);
13068     * // => ['a', 'b']
13069     */
13070    function functions(object) {
13071      return object == null ? [] : baseFunctions(object, keys(object));
13072    }
13073
13074    /**
13075     * Creates an array of function property names from own and inherited
13076     * enumerable properties of `object`.
13077     *
13078     * @static
13079     * @memberOf _
13080     * @since 4.0.0
13081     * @category Object
13082     * @param {Object} object The object to inspect.
13083     * @returns {Array} Returns the function names.
13084     * @see _.functions
13085     * @example
13086     *
13087     * function Foo() {
13088     *   this.a = _.constant('a');
13089     *   this.b = _.constant('b');
13090     * }
13091     *
13092     * Foo.prototype.c = _.constant('c');
13093     *
13094     * _.functionsIn(new Foo);
13095     * // => ['a', 'b', 'c']
13096     */
13097    function functionsIn(object) {
13098      return object == null ? [] : baseFunctions(object, keysIn(object));
13099    }
13100
13101    /**
13102     * Gets the value at `path` of `object`. If the resolved value is
13103     * `undefined`, the `defaultValue` is returned in its place.
13104     *
13105     * @static
13106     * @memberOf _
13107     * @since 3.7.0
13108     * @category Object
13109     * @param {Object} object The object to query.
13110     * @param {Array|string} path The path of the property to get.
13111     * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13112     * @returns {*} Returns the resolved value.
13113     * @example
13114     *
13115     * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13116     *
13117     * _.get(object, 'a[0].b.c');
13118     * // => 3
13119     *
13120     * _.get(object, ['a', '0', 'b', 'c']);
13121     * // => 3
13122     *
13123     * _.get(object, 'a.b.c', 'default');
13124     * // => 'default'
13125     */
13126    function get(object, path, defaultValue) {
13127      var result = object == null ? undefined : baseGet(object, path);
13128      return result === undefined ? defaultValue : result;
13129    }
13130
13131    /**
13132     * Checks if `path` is a direct property of `object`.
13133     *
13134     * @static
13135     * @since 0.1.0
13136     * @memberOf _
13137     * @category Object
13138     * @param {Object} object The object to query.
13139     * @param {Array|string} path The path to check.
13140     * @returns {boolean} Returns `true` if `path` exists, else `false`.
13141     * @example
13142     *
13143     * var object = { 'a': { 'b': 2 } };
13144     * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13145     *
13146     * _.has(object, 'a');
13147     * // => true
13148     *
13149     * _.has(object, 'a.b');
13150     * // => true
13151     *
13152     * _.has(object, ['a', 'b']);
13153     * // => true
13154     *
13155     * _.has(other, 'a');
13156     * // => false
13157     */
13158    function has(object, path) {
13159      return object != null && hasPath(object, path, baseHas);
13160    }
13161
13162    /**
13163     * Checks if `path` is a direct or inherited property of `object`.
13164     *
13165     * @static
13166     * @memberOf _
13167     * @since 4.0.0
13168     * @category Object
13169     * @param {Object} object The object to query.
13170     * @param {Array|string} path The path to check.
13171     * @returns {boolean} Returns `true` if `path` exists, else `false`.
13172     * @example
13173     *
13174     * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13175     *
13176     * _.hasIn(object, 'a');
13177     * // => true
13178     *
13179     * _.hasIn(object, 'a.b');
13180     * // => true
13181     *
13182     * _.hasIn(object, ['a', 'b']);
13183     * // => true
13184     *
13185     * _.hasIn(object, 'b');
13186     * // => false
13187     */
13188    function hasIn(object, path) {
13189      return object != null && hasPath(object, path, baseHasIn);
13190    }
13191
13192    /**
13193     * Creates an object composed of the inverted keys and values of `object`.
13194     * If `object` contains duplicate values, subsequent values overwrite
13195     * property assignments of previous values.
13196     *
13197     * @static
13198     * @memberOf _
13199     * @since 0.7.0
13200     * @category Object
13201     * @param {Object} object The object to invert.
13202     * @returns {Object} Returns the new inverted object.
13203     * @example
13204     *
13205     * var object = { 'a': 1, 'b': 2, 'c': 1 };
13206     *
13207     * _.invert(object);
13208     * // => { '1': 'c', '2': 'b' }
13209     */
13210    var invert = createInverter(function(result, value, key) {
13211      if (value != null &&
13212          typeof value.toString != 'function') {
13213        value = nativeObjectToString.call(value);
13214      }
13215
13216      result[value] = key;
13217    }, constant(identity));
13218
13219    /**
13220     * This method is like `_.invert` except that the inverted object is generated
13221     * from the results of running each element of `object` thru `iteratee`. The
13222     * corresponding inverted value of each inverted key is an array of keys
13223     * responsible for generating the inverted value. The iteratee is invoked
13224     * with one argument: (value).
13225     *
13226     * @static
13227     * @memberOf _
13228     * @since 4.1.0
13229     * @category Object
13230     * @param {Object} object The object to invert.
13231     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
13232     * @returns {Object} Returns the new inverted object.
13233     * @example
13234     *
13235     * var object = { 'a': 1, 'b': 2, 'c': 1 };
13236     *
13237     * _.invertBy(object);
13238     * // => { '1': ['a', 'c'], '2': ['b'] }
13239     *
13240     * _.invertBy(object, function(value) {
13241     *   return 'group' + value;
13242     * });
13243     * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13244     */
13245    var invertBy = createInverter(function(result, value, key) {
13246      if (value != null &&
13247          typeof value.toString != 'function') {
13248        value = nativeObjectToString.call(value);
13249      }
13250
13251      if (hasOwnProperty.call(result, value)) {
13252        result[value].push(key);
13253      } else {
13254        result[value] = [key];
13255      }
13256    }, getIteratee);
13257
13258    /**
13259     * Invokes the method at `path` of `object`.
13260     *
13261     * @static
13262     * @memberOf _
13263     * @since 4.0.0
13264     * @category Object
13265     * @param {Object} object The object to query.
13266     * @param {Array|string} path The path of the method to invoke.
13267     * @param {...*} [args] The arguments to invoke the method with.
13268     * @returns {*} Returns the result of the invoked method.
13269     * @example
13270     *
13271     * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13272     *
13273     * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13274     * // => [2, 3]
13275     */
13276    var invoke = baseRest(baseInvoke);
13277
13278    /**
13279     * Creates an array of the own enumerable property names of `object`.
13280     *
13281     * **Note:** Non-object values are coerced to objects. See the
13282     * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
13283     * for more details.
13284     *
13285     * @static
13286     * @since 0.1.0
13287     * @memberOf _
13288     * @category Object
13289     * @param {Object} object The object to query.
13290     * @returns {Array} Returns the array of property names.
13291     * @example
13292     *
13293     * function Foo() {
13294     *   this.a = 1;
13295     *   this.b = 2;
13296     * }
13297     *
13298     * Foo.prototype.c = 3;
13299     *
13300     * _.keys(new Foo);
13301     * // => ['a', 'b'] (iteration order is not guaranteed)
13302     *
13303     * _.keys('hi');
13304     * // => ['0', '1']
13305     */
13306    function keys(object) {
13307      return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13308    }
13309
13310    /**
13311     * Creates an array of the own and inherited enumerable property names of `object`.
13312     *
13313     * **Note:** Non-object values are coerced to objects.
13314     *
13315     * @static
13316     * @memberOf _
13317     * @since 3.0.0
13318     * @category Object
13319     * @param {Object} object The object to query.
13320     * @returns {Array} Returns the array of property names.
13321     * @example
13322     *
13323     * function Foo() {
13324     *   this.a = 1;
13325     *   this.b = 2;
13326     * }
13327     *
13328     * Foo.prototype.c = 3;
13329     *
13330     * _.keysIn(new Foo);
13331     * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13332     */
13333    function keysIn(object) {
13334      return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
13335    }
13336
13337    /**
13338     * The opposite of `_.mapValues`; this method creates an object with the
13339     * same values as `object` and keys generated by running each own enumerable
13340     * string keyed property of `object` thru `iteratee`. The iteratee is invoked
13341     * with three arguments: (value, key, object).
13342     *
13343     * @static
13344     * @memberOf _
13345     * @since 3.8.0
13346     * @category Object
13347     * @param {Object} object The object to iterate over.
13348     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13349     * @returns {Object} Returns the new mapped object.
13350     * @see _.mapValues
13351     * @example
13352     *
13353     * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13354     *   return key + value;
13355     * });
13356     * // => { 'a1': 1, 'b2': 2 }
13357     */
13358    function mapKeys(object, iteratee) {
13359      var result = {};
13360      iteratee = getIteratee(iteratee, 3);
13361
13362      baseForOwn(object, function(value, key, object) {
13363        baseAssignValue(result, iteratee(value, key, object), value);
13364      });
13365      return result;
13366    }
13367
13368    /**
13369     * Creates an object with the same keys as `object` and values generated
13370     * by running each own enumerable string keyed property of `object` thru
13371     * `iteratee`. The iteratee is invoked with three arguments:
13372     * (value, key, object).
13373     *
13374     * @static
13375     * @memberOf _
13376     * @since 2.4.0
13377     * @category Object
13378     * @param {Object} object The object to iterate over.
13379     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13380     * @returns {Object} Returns the new mapped object.
13381     * @see _.mapKeys
13382     * @example
13383     *
13384     * var users = {
13385     *   'fred':    { 'user': 'fred',    'age': 40 },
13386     *   'pebbles': { 'user': 'pebbles', 'age': 1 }
13387     * };
13388     *
13389     * _.mapValues(users, function(o) { return o.age; });
13390     * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13391     *
13392     * // The `_.property` iteratee shorthand.
13393     * _.mapValues(users, 'age');
13394     * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13395     */
13396    function mapValues(object, iteratee) {
13397      var result = {};
13398      iteratee = getIteratee(iteratee, 3);
13399
13400      baseForOwn(object, function(value, key, object) {
13401        baseAssignValue(result, key, iteratee(value, key, object));
13402      });
13403      return result;
13404    }
13405
13406    /**
13407     * This method is like `_.assign` except that it recursively merges own and
13408     * inherited enumerable string keyed properties of source objects into the
13409     * destination object. Source properties that resolve to `undefined` are
13410     * skipped if a destination value exists. Array and plain object properties
13411     * are merged recursively. Other objects and value types are overridden by
13412     * assignment. Source objects are applied from left to right. Subsequent
13413     * sources overwrite property assignments of previous sources.
13414     *
13415     * **Note:** This method mutates `object`.
13416     *
13417     * @static
13418     * @memberOf _
13419     * @since 0.5.0
13420     * @category Object
13421     * @param {Object} object The destination object.
13422     * @param {...Object} [sources] The source objects.
13423     * @returns {Object} Returns `object`.
13424     * @example
13425     *
13426     * var object = {
13427     *   'a': [{ 'b': 2 }, { 'd': 4 }]
13428     * };
13429     *
13430     * var other = {
13431     *   'a': [{ 'c': 3 }, { 'e': 5 }]
13432     * };
13433     *
13434     * _.merge(object, other);
13435     * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13436     */
13437    var merge = createAssigner(function(object, source, srcIndex) {
13438      baseMerge(object, source, srcIndex);
13439    });
13440
13441    /**
13442     * This method is like `_.merge` except that it accepts `customizer` which
13443     * is invoked to produce the merged values of the destination and source
13444     * properties. If `customizer` returns `undefined`, merging is handled by the
13445     * method instead. The `customizer` is invoked with six arguments:
13446     * (objValue, srcValue, key, object, source, stack).
13447     *
13448     * **Note:** This method mutates `object`.
13449     *
13450     * @static
13451     * @memberOf _
13452     * @since 4.0.0
13453     * @category Object
13454     * @param {Object} object The destination object.
13455     * @param {...Object} sources The source objects.
13456     * @param {Function} customizer The function to customize assigned values.
13457     * @returns {Object} Returns `object`.
13458     * @example
13459     *
13460     * function customizer(objValue, srcValue) {
13461     *   if (_.isArray(objValue)) {
13462     *     return objValue.concat(srcValue);
13463     *   }
13464     * }
13465     *
13466     * var object = { 'a': [1], 'b': [2] };
13467     * var other = { 'a': [3], 'b': [4] };
13468     *
13469     * _.mergeWith(object, other, customizer);
13470     * // => { 'a': [1, 3], 'b': [2, 4] }
13471     */
13472    var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13473      baseMerge(object, source, srcIndex, customizer);
13474    });
13475
13476    /**
13477     * The opposite of `_.pick`; this method creates an object composed of the
13478     * own and inherited enumerable property paths of `object` that are not omitted.
13479     *
13480     * **Note:** This method is considerably slower than `_.pick`.
13481     *
13482     * @static
13483     * @since 0.1.0
13484     * @memberOf _
13485     * @category Object
13486     * @param {Object} object The source object.
13487     * @param {...(string|string[])} [paths] The property paths to omit.
13488     * @returns {Object} Returns the new object.
13489     * @example
13490     *
13491     * var object = { 'a': 1, 'b': '2', 'c': 3 };
13492     *
13493     * _.omit(object, ['a', 'c']);
13494     * // => { 'b': '2' }
13495     */
13496    var omit = flatRest(function(object, paths) {
13497      var result = {};
13498      if (object == null) {
13499        return result;
13500      }
13501      var isDeep = false;
13502      paths = arrayMap(paths, function(path) {
13503        path = castPath(path, object);
13504        isDeep || (isDeep = path.length > 1);
13505        return path;
13506      });
13507      copyObject(object, getAllKeysIn(object), result);
13508      if (isDeep) {
13509        result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
13510      }
13511      var length = paths.length;
13512      while (length--) {
13513        baseUnset(result, paths[length]);
13514      }
13515      return result;
13516    });
13517
13518    /**
13519     * The opposite of `_.pickBy`; this method creates an object composed of
13520     * the own and inherited enumerable string keyed properties of `object` that
13521     * `predicate` doesn't return truthy for. The predicate is invoked with two
13522     * arguments: (value, key).
13523     *
13524     * @static
13525     * @memberOf _
13526     * @since 4.0.0
13527     * @category Object
13528     * @param {Object} object The source object.
13529     * @param {Function} [predicate=_.identity] The function invoked per property.
13530     * @returns {Object} Returns the new object.
13531     * @example
13532     *
13533     * var object = { 'a': 1, 'b': '2', 'c': 3 };
13534     *
13535     * _.omitBy(object, _.isNumber);
13536     * // => { 'b': '2' }
13537     */
13538    function omitBy(object, predicate) {
13539      return pickBy(object, negate(getIteratee(predicate)));
13540    }
13541
13542    /**
13543     * Creates an object composed of the picked `object` properties.
13544     *
13545     * @static
13546     * @since 0.1.0
13547     * @memberOf _
13548     * @category Object
13549     * @param {Object} object The source object.
13550     * @param {...(string|string[])} [paths] The property paths to pick.
13551     * @returns {Object} Returns the new object.
13552     * @example
13553     *
13554     * var object = { 'a': 1, 'b': '2', 'c': 3 };
13555     *
13556     * _.pick(object, ['a', 'c']);
13557     * // => { 'a': 1, 'c': 3 }
13558     */
13559    var pick = flatRest(function(object, paths) {
13560      return object == null ? {} : basePick(object, paths);
13561    });
13562
13563    /**
13564     * Creates an object composed of the `object` properties `predicate` returns
13565     * truthy for. The predicate is invoked with two arguments: (value, key).
13566     *
13567     * @static
13568     * @memberOf _
13569     * @since 4.0.0
13570     * @category Object
13571     * @param {Object} object The source object.
13572     * @param {Function} [predicate=_.identity] The function invoked per property.
13573     * @returns {Object} Returns the new object.
13574     * @example
13575     *
13576     * var object = { 'a': 1, 'b': '2', 'c': 3 };
13577     *
13578     * _.pickBy(object, _.isNumber);
13579     * // => { 'a': 1, 'c': 3 }
13580     */
13581    function pickBy(object, predicate) {
13582      if (object == null) {
13583        return {};
13584      }
13585      var props = arrayMap(getAllKeysIn(object), function(prop) {
13586        return [prop];
13587      });
13588      predicate = getIteratee(predicate);
13589      return basePickBy(object, props, function(value, path) {
13590        return predicate(value, path[0]);
13591      });
13592    }
13593
13594    /**
13595     * This method is like `_.get` except that if the resolved value is a
13596     * function it's invoked with the `this` binding of its parent object and
13597     * its result is returned.
13598     *
13599     * @static
13600     * @since 0.1.0
13601     * @memberOf _
13602     * @category Object
13603     * @param {Object} object The object to query.
13604     * @param {Array|string} path The path of the property to resolve.
13605     * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13606     * @returns {*} Returns the resolved value.
13607     * @example
13608     *
13609     * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13610     *
13611     * _.result(object, 'a[0].b.c1');
13612     * // => 3
13613     *
13614     * _.result(object, 'a[0].b.c2');
13615     * // => 4
13616     *
13617     * _.result(object, 'a[0].b.c3', 'default');
13618     * // => 'default'
13619     *
13620     * _.result(object, 'a[0].b.c3', _.constant('default'));
13621     * // => 'default'
13622     */
13623    function result(object, path, defaultValue) {
13624      path = castPath(path, object);
13625
13626      var index = -1,
13627          length = path.length;
13628
13629      // Ensure the loop is entered when path is empty.
13630      if (!length) {
13631        length = 1;
13632        object = undefined;
13633      }
13634      while (++index < length) {
13635        var value = object == null ? undefined : object[toKey(path[index])];
13636        if (value === undefined) {
13637          index = length;
13638          value = defaultValue;
13639        }
13640        object = isFunction(value) ? value.call(object) : value;
13641      }
13642      return object;
13643    }
13644
13645    /**
13646     * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
13647     * it's created. Arrays are created for missing index properties while objects
13648     * are created for all other missing properties. Use `_.setWith` to customize
13649     * `path` creation.
13650     *
13651     * **Note:** This method mutates `object`.
13652     *
13653     * @static
13654     * @memberOf _
13655     * @since 3.7.0
13656     * @category Object
13657     * @param {Object} object The object to modify.
13658     * @param {Array|string} path The path of the property to set.
13659     * @param {*} value The value to set.
13660     * @returns {Object} Returns `object`.
13661     * @example
13662     *
13663     * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13664     *
13665     * _.set(object, 'a[0].b.c', 4);
13666     * console.log(object.a[0].b.c);
13667     * // => 4
13668     *
13669     * _.set(object, ['x', '0', 'y', 'z'], 5);
13670     * console.log(object.x[0].y.z);
13671     * // => 5
13672     */
13673    function set(object, path, value) {
13674      return object == null ? object : baseSet(object, path, value);
13675    }
13676
13677    /**
13678     * This method is like `_.set` except that it accepts `customizer` which is
13679     * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13680     * path creation is handled by the method instead. The `customizer` is invoked
13681     * with three arguments: (nsValue, key, nsObject).
13682     *
13683     * **Note:** This method mutates `object`.
13684     *
13685     * @static
13686     * @memberOf _
13687     * @since 4.0.0
13688     * @category Object
13689     * @param {Object} object The object to modify.
13690     * @param {Array|string} path The path of the property to set.
13691     * @param {*} value The value to set.
13692     * @param {Function} [customizer] The function to customize assigned values.
13693     * @returns {Object} Returns `object`.
13694     * @example
13695     *
13696     * var object = {};
13697     *
13698     * _.setWith(object, '[0][1]', 'a', Object);
13699     * // => { '0': { '1': 'a' } }
13700     */
13701    function setWith(object, path, value, customizer) {
13702      customizer = typeof customizer == 'function' ? customizer : undefined;
13703      return object == null ? object : baseSet(object, path, value, customizer);
13704    }
13705
13706    /**
13707     * Creates an array of own enumerable string keyed-value pairs for `object`
13708     * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
13709     * entries are returned.
13710     *
13711     * @static
13712     * @memberOf _
13713     * @since 4.0.0
13714     * @alias entries
13715     * @category Object
13716     * @param {Object} object The object to query.
13717     * @returns {Array} Returns the key-value pairs.
13718     * @example
13719     *
13720     * function Foo() {
13721     *   this.a = 1;
13722     *   this.b = 2;
13723     * }
13724     *
13725     * Foo.prototype.c = 3;
13726     *
13727     * _.toPairs(new Foo);
13728     * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
13729     */
13730    var toPairs = createToPairs(keys);
13731
13732    /**
13733     * Creates an array of own and inherited enumerable string keyed-value pairs
13734     * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
13735     * or set, its entries are returned.
13736     *
13737     * @static
13738     * @memberOf _
13739     * @since 4.0.0
13740     * @alias entriesIn
13741     * @category Object
13742     * @param {Object} object The object to query.
13743     * @returns {Array} Returns the key-value pairs.
13744     * @example
13745     *
13746     * function Foo() {
13747     *   this.a = 1;
13748     *   this.b = 2;
13749     * }
13750     *
13751     * Foo.prototype.c = 3;
13752     *
13753     * _.toPairsIn(new Foo);
13754     * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
13755     */
13756    var toPairsIn = createToPairs(keysIn);
13757
13758    /**
13759     * An alternative to `_.reduce`; this method transforms `object` to a new
13760     * `accumulator` object which is the result of running each of its own
13761     * enumerable string keyed properties thru `iteratee`, with each invocation
13762     * potentially mutating the `accumulator` object. If `accumulator` is not
13763     * provided, a new object with the same `[[Prototype]]` will be used. The
13764     * iteratee is invoked with four arguments: (accumulator, value, key, object).
13765     * Iteratee functions may exit iteration early by explicitly returning `false`.
13766     *
13767     * @static
13768     * @memberOf _
13769     * @since 1.3.0
13770     * @category Object
13771     * @param {Object} object The object to iterate over.
13772     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13773     * @param {*} [accumulator] The custom accumulator value.
13774     * @returns {*} Returns the accumulated value.
13775     * @example
13776     *
13777     * _.transform([2, 3, 4], function(result, n) {
13778     *   result.push(n *= n);
13779     *   return n % 2 == 0;
13780     * }, []);
13781     * // => [4, 9]
13782     *
13783     * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
13784     *   (result[value] || (result[value] = [])).push(key);
13785     * }, {});
13786     * // => { '1': ['a', 'c'], '2': ['b'] }
13787     */
13788    function transform(object, iteratee, accumulator) {
13789      var isArr = isArray(object),
13790          isArrLike = isArr || isBuffer(object) || isTypedArray(object);
13791
13792      iteratee = getIteratee(iteratee, 4);
13793      if (accumulator == null) {
13794        var Ctor = object && object.constructor;
13795        if (isArrLike) {
13796          accumulator = isArr ? new Ctor : [];
13797        }
13798        else if (isObject(object)) {
13799          accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
13800        }
13801        else {
13802          accumulator = {};
13803        }
13804      }
13805      (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
13806        return iteratee(accumulator, value, index, object);
13807      });
13808      return accumulator;
13809    }
13810
13811    /**
13812     * Removes the property at `path` of `object`.
13813     *
13814     * **Note:** This method mutates `object`.
13815     *
13816     * @static
13817     * @memberOf _
13818     * @since 4.0.0
13819     * @category Object
13820     * @param {Object} object The object to modify.
13821     * @param {Array|string} path The path of the property to unset.
13822     * @returns {boolean} Returns `true` if the property is deleted, else `false`.
13823     * @example
13824     *
13825     * var object = { 'a': [{ 'b': { 'c': 7 } }] };
13826     * _.unset(object, 'a[0].b.c');
13827     * // => true
13828     *
13829     * console.log(object);
13830     * // => { 'a': [{ 'b': {} }] };
13831     *
13832     * _.unset(object, ['a', '0', 'b', 'c']);
13833     * // => true
13834     *
13835     * console.log(object);
13836     * // => { 'a': [{ 'b': {} }] };
13837     */
13838    function unset(object, path) {
13839      return object == null ? true : baseUnset(object, path);
13840    }
13841
13842    /**
13843     * This method is like `_.set` except that accepts `updater` to produce the
13844     * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
13845     * is invoked with one argument: (value).
13846     *
13847     * **Note:** This method mutates `object`.
13848     *
13849     * @static
13850     * @memberOf _
13851     * @since 4.6.0
13852     * @category Object
13853     * @param {Object} object The object to modify.
13854     * @param {Array|string} path The path of the property to set.
13855     * @param {Function} updater The function to produce the updated value.
13856     * @returns {Object} Returns `object`.
13857     * @example
13858     *
13859     * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13860     *
13861     * _.update(object, 'a[0].b.c', function(n) { return n * n; });
13862     * console.log(object.a[0].b.c);
13863     * // => 9
13864     *
13865     * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
13866     * console.log(object.x[0].y.z);
13867     * // => 0
13868     */
13869    function update(object, path, updater) {
13870      return object == null ? object : baseUpdate(object, path, castFunction(updater));
13871    }
13872
13873    /**
13874     * This method is like `_.update` except that it accepts `customizer` which is
13875     * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13876     * path creation is handled by the method instead. The `customizer` is invoked
13877     * with three arguments: (nsValue, key, nsObject).
13878     *
13879     * **Note:** This method mutates `object`.
13880     *
13881     * @static
13882     * @memberOf _
13883     * @since 4.6.0
13884     * @category Object
13885     * @param {Object} object The object to modify.
13886     * @param {Array|string} path The path of the property to set.
13887     * @param {Function} updater The function to produce the updated value.
13888     * @param {Function} [customizer] The function to customize assigned values.
13889     * @returns {Object} Returns `object`.
13890     * @example
13891     *
13892     * var object = {};
13893     *
13894     * _.updateWith(object, '[0][1]', _.constant('a'), Object);
13895     * // => { '0': { '1': 'a' } }
13896     */
13897    function updateWith(object, path, updater, customizer) {
13898      customizer = typeof customizer == 'function' ? customizer : undefined;
13899      return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
13900    }
13901
13902    /**
13903     * Creates an array of the own enumerable string keyed property values of `object`.
13904     *
13905     * **Note:** Non-object values are coerced to objects.
13906     *
13907     * @static
13908     * @since 0.1.0
13909     * @memberOf _
13910     * @category Object
13911     * @param {Object} object The object to query.
13912     * @returns {Array} Returns the array of property values.
13913     * @example
13914     *
13915     * function Foo() {
13916     *   this.a = 1;
13917     *   this.b = 2;
13918     * }
13919     *
13920     * Foo.prototype.c = 3;
13921     *
13922     * _.values(new Foo);
13923     * // => [1, 2] (iteration order is not guaranteed)
13924     *
13925     * _.values('hi');
13926     * // => ['h', 'i']
13927     */
13928    function values(object) {
13929      return object == null ? [] : baseValues(object, keys(object));
13930    }
13931
13932    /**
13933     * Creates an array of the own and inherited enumerable string keyed property
13934     * values of `object`.
13935     *
13936     * **Note:** Non-object values are coerced to objects.
13937     *
13938     * @static
13939     * @memberOf _
13940     * @since 3.0.0
13941     * @category Object
13942     * @param {Object} object The object to query.
13943     * @returns {Array} Returns the array of property values.
13944     * @example
13945     *
13946     * function Foo() {
13947     *   this.a = 1;
13948     *   this.b = 2;
13949     * }
13950     *
13951     * Foo.prototype.c = 3;
13952     *
13953     * _.valuesIn(new Foo);
13954     * // => [1, 2, 3] (iteration order is not guaranteed)
13955     */
13956    function valuesIn(object) {
13957      return object == null ? [] : baseValues(object, keysIn(object));
13958    }
13959
13960    /*------------------------------------------------------------------------*/
13961
13962    /**
13963     * Clamps `number` within the inclusive `lower` and `upper` bounds.
13964     *
13965     * @static
13966     * @memberOf _
13967     * @since 4.0.0
13968     * @category Number
13969     * @param {number} number The number to clamp.
13970     * @param {number} [lower] The lower bound.
13971     * @param {number} upper The upper bound.
13972     * @returns {number} Returns the clamped number.
13973     * @example
13974     *
13975     * _.clamp(-10, -5, 5);
13976     * // => -5
13977     *
13978     * _.clamp(10, -5, 5);
13979     * // => 5
13980     */
13981    function clamp(number, lower, upper) {
13982      if (upper === undefined) {
13983        upper = lower;
13984        lower = undefined;
13985      }
13986      if (upper !== undefined) {
13987        upper = toNumber(upper);
13988        upper = upper === upper ? upper : 0;
13989      }
13990      if (lower !== undefined) {
13991        lower = toNumber(lower);
13992        lower = lower === lower ? lower : 0;
13993      }
13994      return baseClamp(toNumber(number), lower, upper);
13995    }
13996
13997    /**
13998     * Checks if `n` is between `start` and up to, but not including, `end`. If
13999     * `end` is not specified, it's set to `start` with `start` then set to `0`.
14000     * If `start` is greater than `end` the params are swapped to support
14001     * negative ranges.
14002     *
14003     * @static
14004     * @memberOf _
14005     * @since 3.3.0
14006     * @category Number
14007     * @param {number} number The number to check.
14008     * @param {number} [start=0] The start of the range.
14009     * @param {number} end The end of the range.
14010     * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
14011     * @see _.range, _.rangeRight
14012     * @example
14013     *
14014     * _.inRange(3, 2, 4);
14015     * // => true
14016     *
14017     * _.inRange(4, 8);
14018     * // => true
14019     *
14020     * _.inRange(4, 2);
14021     * // => false
14022     *
14023     * _.inRange(2, 2);
14024     * // => false
14025     *
14026     * _.inRange(1.2, 2);
14027     * // => true
14028     *
14029     * _.inRange(5.2, 4);
14030     * // => false
14031     *
14032     * _.inRange(-3, -2, -6);
14033     * // => true
14034     */
14035    function inRange(number, start, end) {
14036      start = toFinite(start);
14037      if (end === undefined) {
14038        end = start;
14039        start = 0;
14040      } else {
14041        end = toFinite(end);
14042      }
14043      number = toNumber(number);
14044      return baseInRange(number, start, end);
14045    }
14046
14047    /**
14048     * Produces a random number between the inclusive `lower` and `upper` bounds.
14049     * If only one argument is provided a number between `0` and the given number
14050     * is returned. If `floating` is `true`, or either `lower` or `upper` are
14051     * floats, a floating-point number is returned instead of an integer.
14052     *
14053     * **Note:** JavaScript follows the IEEE-754 standard for resolving
14054     * floating-point values which can produce unexpected results.
14055     *
14056     * @static
14057     * @memberOf _
14058     * @since 0.7.0
14059     * @category Number
14060     * @param {number} [lower=0] The lower bound.
14061     * @param {number} [upper=1] The upper bound.
14062     * @param {boolean} [floating] Specify returning a floating-point number.
14063     * @returns {number} Returns the random number.
14064     * @example
14065     *
14066     * _.random(0, 5);
14067     * // => an integer between 0 and 5
14068     *
14069     * _.random(5);
14070     * // => also an integer between 0 and 5
14071     *
14072     * _.random(5, true);
14073     * // => a floating-point number between 0 and 5
14074     *
14075     * _.random(1.2, 5.2);
14076     * // => a floating-point number between 1.2 and 5.2
14077     */
14078    function random(lower, upper, floating) {
14079      if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
14080        upper = floating = undefined;
14081      }
14082      if (floating === undefined) {
14083        if (typeof upper == 'boolean') {
14084          floating = upper;
14085          upper = undefined;
14086        }
14087        else if (typeof lower == 'boolean') {
14088          floating = lower;
14089          lower = undefined;
14090        }
14091      }
14092      if (lower === undefined && upper === undefined) {
14093        lower = 0;
14094        upper = 1;
14095      }
14096      else {
14097        lower = toFinite(lower);
14098        if (upper === undefined) {
14099          upper = lower;
14100          lower = 0;
14101        } else {
14102          upper = toFinite(upper);
14103        }
14104      }
14105      if (lower > upper) {
14106        var temp = lower;
14107        lower = upper;
14108        upper = temp;
14109      }
14110      if (floating || lower % 1 || upper % 1) {
14111        var rand = nativeRandom();
14112        return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14113      }
14114      return baseRandom(lower, upper);
14115    }
14116
14117    /*------------------------------------------------------------------------*/
14118
14119    /**
14120     * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14121     *
14122     * @static
14123     * @memberOf _
14124     * @since 3.0.0
14125     * @category String
14126     * @param {string} [string=''] The string to convert.
14127     * @returns {string} Returns the camel cased string.
14128     * @example
14129     *
14130     * _.camelCase('Foo Bar');
14131     * // => 'fooBar'
14132     *
14133     * _.camelCase('--foo-bar--');
14134     * // => 'fooBar'
14135     *
14136     * _.camelCase('__FOO_BAR__');
14137     * // => 'fooBar'
14138     */
14139    var camelCase = createCompounder(function(result, word, index) {
14140      word = word.toLowerCase();
14141      return result + (index ? capitalize(word) : word);
14142    });
14143
14144    /**
14145     * Converts the first character of `string` to upper case and the remaining
14146     * to lower case.
14147     *
14148     * @static
14149     * @memberOf _
14150     * @since 3.0.0
14151     * @category String
14152     * @param {string} [string=''] The string to capitalize.
14153     * @returns {string} Returns the capitalized string.
14154     * @example
14155     *
14156     * _.capitalize('FRED');
14157     * // => 'Fred'
14158     */
14159    function capitalize(string) {
14160      return upperFirst(toString(string).toLowerCase());
14161    }
14162
14163    /**
14164     * Deburrs `string` by converting
14165     * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
14166     * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
14167     * letters to basic Latin letters and removing
14168     * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
14169     *
14170     * @static
14171     * @memberOf _
14172     * @since 3.0.0
14173     * @category String
14174     * @param {string} [string=''] The string to deburr.
14175     * @returns {string} Returns the deburred string.
14176     * @example
14177     *
14178     * _.deburr('déjà vu');
14179     * // => 'deja vu'
14180     */
14181    function deburr(string) {
14182      string = toString(string);
14183      return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14184    }
14185
14186    /**
14187     * Checks if `string` ends with the given target string.
14188     *
14189     * @static
14190     * @memberOf _
14191     * @since 3.0.0
14192     * @category String
14193     * @param {string} [string=''] The string to inspect.
14194     * @param {string} [target] The string to search for.
14195     * @param {number} [position=string.length] The position to search up to.
14196     * @returns {boolean} Returns `true` if `string` ends with `target`,
14197     *  else `false`.
14198     * @example
14199     *
14200     * _.endsWith('abc', 'c');
14201     * // => true
14202     *
14203     * _.endsWith('abc', 'b');
14204     * // => false
14205     *
14206     * _.endsWith('abc', 'b', 2);
14207     * // => true
14208     */
14209    function endsWith(string, target, position) {
14210      string = toString(string);
14211      target = baseToString(target);
14212
14213      var length = string.length;
14214      position = position === undefined
14215        ? length
14216        : baseClamp(toInteger(position), 0, length);
14217
14218      var end = position;
14219      position -= target.length;
14220      return position >= 0 && string.slice(position, end) == target;
14221    }
14222
14223    /**
14224     * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14225     * corresponding HTML entities.
14226     *
14227     * **Note:** No other characters are escaped. To escape additional
14228     * characters use a third-party library like [_he_](https://mths.be/he).
14229     *
14230     * Though the ">" character is escaped for symmetry, characters like
14231     * ">" and "/" don't need escaping in HTML and have no special meaning
14232     * unless they're part of a tag or unquoted attribute value. See
14233     * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
14234     * (under "semi-related fun fact") for more details.
14235     *
14236     * When working with HTML you should always
14237     * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14238     * XSS vectors.
14239     *
14240     * @static
14241     * @since 0.1.0
14242     * @memberOf _
14243     * @category String
14244     * @param {string} [string=''] The string to escape.
14245     * @returns {string} Returns the escaped string.
14246     * @example
14247     *
14248     * _.escape('fred, barney, & pebbles');
14249     * // => 'fred, barney, &amp; pebbles'
14250     */
14251    function escape(string) {
14252      string = toString(string);
14253      return (string && reHasUnescapedHtml.test(string))
14254        ? string.replace(reUnescapedHtml, escapeHtmlChar)
14255        : string;
14256    }
14257
14258    /**
14259     * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14260     * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14261     *
14262     * @static
14263     * @memberOf _
14264     * @since 3.0.0
14265     * @category String
14266     * @param {string} [string=''] The string to escape.
14267     * @returns {string} Returns the escaped string.
14268     * @example
14269     *
14270     * _.escapeRegExp('[lodash](https://lodash.com/)');
14271     * // => '\[lodash\]\(https://lodash\.com/\)'
14272     */
14273    function escapeRegExp(string) {
14274      string = toString(string);
14275      return (string && reHasRegExpChar.test(string))
14276        ? string.replace(reRegExpChar, '\\$&')
14277        : string;
14278    }
14279
14280    /**
14281     * Converts `string` to
14282     * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14283     *
14284     * @static
14285     * @memberOf _
14286     * @since 3.0.0
14287     * @category String
14288     * @param {string} [string=''] The string to convert.
14289     * @returns {string} Returns the kebab cased string.
14290     * @example
14291     *
14292     * _.kebabCase('Foo Bar');
14293     * // => 'foo-bar'
14294     *
14295     * _.kebabCase('fooBar');
14296     * // => 'foo-bar'
14297     *
14298     * _.kebabCase('__FOO_BAR__');
14299     * // => 'foo-bar'
14300     */
14301    var kebabCase = createCompounder(function(result, word, index) {
14302      return result + (index ? '-' : '') + word.toLowerCase();
14303    });
14304
14305    /**
14306     * Converts `string`, as space separated words, to lower case.
14307     *
14308     * @static
14309     * @memberOf _
14310     * @since 4.0.0
14311     * @category String
14312     * @param {string} [string=''] The string to convert.
14313     * @returns {string} Returns the lower cased string.
14314     * @example
14315     *
14316     * _.lowerCase('--Foo-Bar--');
14317     * // => 'foo bar'
14318     *
14319     * _.lowerCase('fooBar');
14320     * // => 'foo bar'
14321     *
14322     * _.lowerCase('__FOO_BAR__');
14323     * // => 'foo bar'
14324     */
14325    var lowerCase = createCompounder(function(result, word, index) {
14326      return result + (index ? ' ' : '') + word.toLowerCase();
14327    });
14328
14329    /**
14330     * Converts the first character of `string` to lower case.
14331     *
14332     * @static
14333     * @memberOf _
14334     * @since 4.0.0
14335     * @category String
14336     * @param {string} [string=''] The string to convert.
14337     * @returns {string} Returns the converted string.
14338     * @example
14339     *
14340     * _.lowerFirst('Fred');
14341     * // => 'fred'
14342     *
14343     * _.lowerFirst('FRED');
14344     * // => 'fRED'
14345     */
14346    var lowerFirst = createCaseFirst('toLowerCase');
14347
14348    /**
14349     * Pads `string` on the left and right sides if it's shorter than `length`.
14350     * Padding characters are truncated if they can't be evenly divided by `length`.
14351     *
14352     * @static
14353     * @memberOf _
14354     * @since 3.0.0
14355     * @category String
14356     * @param {string} [string=''] The string to pad.
14357     * @param {number} [length=0] The padding length.
14358     * @param {string} [chars=' '] The string used as padding.
14359     * @returns {string} Returns the padded string.
14360     * @example
14361     *
14362     * _.pad('abc', 8);
14363     * // => '  abc   '
14364     *
14365     * _.pad('abc', 8, '_-');
14366     * // => '_-abc_-_'
14367     *
14368     * _.pad('abc', 3);
14369     * // => 'abc'
14370     */
14371    function pad(string, length, chars) {
14372      string = toString(string);
14373      length = toInteger(length);
14374
14375      var strLength = length ? stringSize(string) : 0;
14376      if (!length || strLength >= length) {
14377        return string;
14378      }
14379      var mid = (length - strLength) / 2;
14380      return (
14381        createPadding(nativeFloor(mid), chars) +
14382        string +
14383        createPadding(nativeCeil(mid), chars)
14384      );
14385    }
14386
14387    /**
14388     * Pads `string` on the right side if it's shorter than `length`. Padding
14389     * characters are truncated if they exceed `length`.
14390     *
14391     * @static
14392     * @memberOf _
14393     * @since 4.0.0
14394     * @category String
14395     * @param {string} [string=''] The string to pad.
14396     * @param {number} [length=0] The padding length.
14397     * @param {string} [chars=' '] The string used as padding.
14398     * @returns {string} Returns the padded string.
14399     * @example
14400     *
14401     * _.padEnd('abc', 6);
14402     * // => 'abc   '
14403     *
14404     * _.padEnd('abc', 6, '_-');
14405     * // => 'abc_-_'
14406     *
14407     * _.padEnd('abc', 3);
14408     * // => 'abc'
14409     */
14410    function padEnd(string, length, chars) {
14411      string = toString(string);
14412      length = toInteger(length);
14413
14414      var strLength = length ? stringSize(string) : 0;
14415      return (length && strLength < length)
14416        ? (string + createPadding(length - strLength, chars))
14417        : string;
14418    }
14419
14420    /**
14421     * Pads `string` on the left side if it's shorter than `length`. Padding
14422     * characters are truncated if they exceed `length`.
14423     *
14424     * @static
14425     * @memberOf _
14426     * @since 4.0.0
14427     * @category String
14428     * @param {string} [string=''] The string to pad.
14429     * @param {number} [length=0] The padding length.
14430     * @param {string} [chars=' '] The string used as padding.
14431     * @returns {string} Returns the padded string.
14432     * @example
14433     *
14434     * _.padStart('abc', 6);
14435     * // => '   abc'
14436     *
14437     * _.padStart('abc', 6, '_-');
14438     * // => '_-_abc'
14439     *
14440     * _.padStart('abc', 3);
14441     * // => 'abc'
14442     */
14443    function padStart(string, length, chars) {
14444      string = toString(string);
14445      length = toInteger(length);
14446
14447      var strLength = length ? stringSize(string) : 0;
14448      return (length && strLength < length)
14449        ? (createPadding(length - strLength, chars) + string)
14450        : string;
14451    }
14452
14453    /**
14454     * Converts `string` to an integer of the specified radix. If `radix` is
14455     * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
14456     * hexadecimal, in which case a `radix` of `16` is used.
14457     *
14458     * **Note:** This method aligns with the
14459     * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
14460     *
14461     * @static
14462     * @memberOf _
14463     * @since 1.1.0
14464     * @category String
14465     * @param {string} string The string to convert.
14466     * @param {number} [radix=10] The radix to interpret `value` by.
14467     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14468     * @returns {number} Returns the converted integer.
14469     * @example
14470     *
14471     * _.parseInt('08');
14472     * // => 8
14473     *
14474     * _.map(['6', '08', '10'], _.parseInt);
14475     * // => [6, 8, 10]
14476     */
14477    function parseInt(string, radix, guard) {
14478      if (guard || radix == null) {
14479        radix = 0;
14480      } else if (radix) {
14481        radix = +radix;
14482      }
14483      return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14484    }
14485
14486    /**
14487     * Repeats the given string `n` times.
14488     *
14489     * @static
14490     * @memberOf _
14491     * @since 3.0.0
14492     * @category String
14493     * @param {string} [string=''] The string to repeat.
14494     * @param {number} [n=1] The number of times to repeat the string.
14495     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14496     * @returns {string} Returns the repeated string.
14497     * @example
14498     *
14499     * _.repeat('*', 3);
14500     * // => '***'
14501     *
14502     * _.repeat('abc', 2);
14503     * // => 'abcabc'
14504     *
14505     * _.repeat('abc', 0);
14506     * // => ''
14507     */
14508    function repeat(string, n, guard) {
14509      if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
14510        n = 1;
14511      } else {
14512        n = toInteger(n);
14513      }
14514      return baseRepeat(toString(string), n);
14515    }
14516
14517    /**
14518     * Replaces matches for `pattern` in `string` with `replacement`.
14519     *
14520     * **Note:** This method is based on
14521     * [`String#replace`](https://mdn.io/String/replace).
14522     *
14523     * @static
14524     * @memberOf _
14525     * @since 4.0.0
14526     * @category String
14527     * @param {string} [string=''] The string to modify.
14528     * @param {RegExp|string} pattern The pattern to replace.
14529     * @param {Function|string} replacement The match replacement.
14530     * @returns {string} Returns the modified string.
14531     * @example
14532     *
14533     * _.replace('Hi Fred', 'Fred', 'Barney');
14534     * // => 'Hi Barney'
14535     */
14536    function replace() {
14537      var args = arguments,
14538          string = toString(args[0]);
14539
14540      return args.length < 3 ? string : string.replace(args[1], args[2]);
14541    }
14542
14543    /**
14544     * Converts `string` to
14545     * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14546     *
14547     * @static
14548     * @memberOf _
14549     * @since 3.0.0
14550     * @category String
14551     * @param {string} [string=''] The string to convert.
14552     * @returns {string} Returns the snake cased string.
14553     * @example
14554     *
14555     * _.snakeCase('Foo Bar');
14556     * // => 'foo_bar'
14557     *
14558     * _.snakeCase('fooBar');
14559     * // => 'foo_bar'
14560     *
14561     * _.snakeCase('--FOO-BAR--');
14562     * // => 'foo_bar'
14563     */
14564    var snakeCase = createCompounder(function(result, word, index) {
14565      return result + (index ? '_' : '') + word.toLowerCase();
14566    });
14567
14568    /**
14569     * Splits `string` by `separator`.
14570     *
14571     * **Note:** This method is based on
14572     * [`String#split`](https://mdn.io/String/split).
14573     *
14574     * @static
14575     * @memberOf _
14576     * @since 4.0.0
14577     * @category String
14578     * @param {string} [string=''] The string to split.
14579     * @param {RegExp|string} separator The separator pattern to split by.
14580     * @param {number} [limit] The length to truncate results to.
14581     * @returns {Array} Returns the string segments.
14582     * @example
14583     *
14584     * _.split('a-b-c', '-', 2);
14585     * // => ['a', 'b']
14586     */
14587    function split(string, separator, limit) {
14588      if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14589        separator = limit = undefined;
14590      }
14591      limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
14592      if (!limit) {
14593        return [];
14594      }
14595      string = toString(string);
14596      if (string && (
14597            typeof separator == 'string' ||
14598            (separator != null && !isRegExp(separator))
14599          )) {
14600        separator = baseToString(separator);
14601        if (!separator && hasUnicode(string)) {
14602          return castSlice(stringToArray(string), 0, limit);
14603        }
14604      }
14605      return string.split(separator, limit);
14606    }
14607
14608    /**
14609     * Converts `string` to
14610     * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14611     *
14612     * @static
14613     * @memberOf _
14614     * @since 3.1.0
14615     * @category String
14616     * @param {string} [string=''] The string to convert.
14617     * @returns {string} Returns the start cased string.
14618     * @example
14619     *
14620     * _.startCase('--foo-bar--');
14621     * // => 'Foo Bar'
14622     *
14623     * _.startCase('fooBar');
14624     * // => 'Foo Bar'
14625     *
14626     * _.startCase('__FOO_BAR__');
14627     * // => 'FOO BAR'
14628     */
14629    var startCase = createCompounder(function(result, word, index) {
14630      return result + (index ? ' ' : '') + upperFirst(word);
14631    });
14632
14633    /**
14634     * Checks if `string` starts with the given target string.
14635     *
14636     * @static
14637     * @memberOf _
14638     * @since 3.0.0
14639     * @category String
14640     * @param {string} [string=''] The string to inspect.
14641     * @param {string} [target] The string to search for.
14642     * @param {number} [position=0] The position to search from.
14643     * @returns {boolean} Returns `true` if `string` starts with `target`,
14644     *  else `false`.
14645     * @example
14646     *
14647     * _.startsWith('abc', 'a');
14648     * // => true
14649     *
14650     * _.startsWith('abc', 'b');
14651     * // => false
14652     *
14653     * _.startsWith('abc', 'b', 1);
14654     * // => true
14655     */
14656    function startsWith(string, target, position) {
14657      string = toString(string);
14658      position = position == null
14659        ? 0
14660        : baseClamp(toInteger(position), 0, string.length);
14661
14662      target = baseToString(target);
14663      return string.slice(position, position + target.length) == target;
14664    }
14665
14666    /**
14667     * Creates a compiled template function that can interpolate data properties
14668     * in "interpolate" delimiters, HTML-escape interpolated data properties in
14669     * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
14670     * properties may be accessed as free variables in the template. If a setting
14671     * object is given, it takes precedence over `_.templateSettings` values.
14672     *
14673     * **Note:** In the development build `_.template` utilizes
14674     * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
14675     * for easier debugging.
14676     *
14677     * For more information on precompiling templates see
14678     * [lodash's custom builds documentation](https://lodash.com/custom-builds).
14679     *
14680     * For more information on Chrome extension sandboxes see
14681     * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
14682     *
14683     * @static
14684     * @since 0.1.0
14685     * @memberOf _
14686     * @category String
14687     * @param {string} [string=''] The template string.
14688     * @param {Object} [options={}] The options object.
14689     * @param {RegExp} [options.escape=_.templateSettings.escape]
14690     *  The HTML "escape" delimiter.
14691     * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
14692     *  The "evaluate" delimiter.
14693     * @param {Object} [options.imports=_.templateSettings.imports]
14694     *  An object to import into the template as free variables.
14695     * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
14696     *  The "interpolate" delimiter.
14697     * @param {string} [options.sourceURL='lodash.templateSources[n]']
14698     *  The sourceURL of the compiled template.
14699     * @param {string} [options.variable='obj']
14700     *  The data object variable name.
14701     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14702     * @returns {Function} Returns the compiled template function.
14703     * @example
14704     *
14705     * // Use the "interpolate" delimiter to create a compiled template.
14706     * var compiled = _.template('hello <%= user %>!');
14707     * compiled({ 'user': 'fred' });
14708     * // => 'hello fred!'
14709     *
14710     * // Use the HTML "escape" delimiter to escape data property values.
14711     * var compiled = _.template('<b><%- value %></b>');
14712     * compiled({ 'value': '<script>' });
14713     * // => '<b>&lt;script&gt;</b>'
14714     *
14715     * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
14716     * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
14717     * compiled({ 'users': ['fred', 'barney'] });
14718     * // => '<li>fred</li><li>barney</li>'
14719     *
14720     * // Use the internal `print` function in "evaluate" delimiters.
14721     * var compiled = _.template('<% print("hello " + user); %>!');
14722     * compiled({ 'user': 'barney' });
14723     * // => 'hello barney!'
14724     *
14725     * // Use the ES template literal delimiter as an "interpolate" delimiter.
14726     * // Disable support by replacing the "interpolate" delimiter.
14727     * var compiled = _.template('hello ${ user }!');
14728     * compiled({ 'user': 'pebbles' });
14729     * // => 'hello pebbles!'
14730     *
14731     * // Use backslashes to treat delimiters as plain text.
14732     * var compiled = _.template('<%= "\\<%- value %\\>" %>');
14733     * compiled({ 'value': 'ignored' });
14734     * // => '<%- value %>'
14735     *
14736     * // Use the `imports` option to import `jQuery` as `jq`.
14737     * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
14738     * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
14739     * compiled({ 'users': ['fred', 'barney'] });
14740     * // => '<li>fred</li><li>barney</li>'
14741     *
14742     * // Use the `sourceURL` option to specify a custom sourceURL for the template.
14743     * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
14744     * compiled(data);
14745     * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
14746     *
14747     * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
14748     * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
14749     * compiled.source;
14750     * // => function(data) {
14751     * //   var __t, __p = '';
14752     * //   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
14753     * //   return __p;
14754     * // }
14755     *
14756     * // Use custom template delimiters.
14757     * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
14758     * var compiled = _.template('hello {{ user }}!');
14759     * compiled({ 'user': 'mustache' });
14760     * // => 'hello mustache!'
14761     *
14762     * // Use the `source` property to inline compiled templates for meaningful
14763     * // line numbers in error messages and stack traces.
14764     * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
14765     *   var JST = {\
14766     *     "main": ' + _.template(mainText).source + '\
14767     *   };\
14768     * ');
14769     */
14770    function template(string, options, guard) {
14771      // Based on John Resig's `tmpl` implementation
14772      // (http://ejohn.org/blog/javascript-micro-templating/)
14773      // and Laura Doktorova's doT.js (https://github.com/olado/doT).
14774      var settings = lodash.templateSettings;
14775
14776      if (guard && isIterateeCall(string, options, guard)) {
14777        options = undefined;
14778      }
14779      string = toString(string);
14780      options = assignInWith({}, options, settings, customDefaultsAssignIn);
14781
14782      var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
14783          importsKeys = keys(imports),
14784          importsValues = baseValues(imports, importsKeys);
14785
14786      var isEscaping,
14787          isEvaluating,
14788          index = 0,
14789          interpolate = options.interpolate || reNoMatch,
14790          source = "__p += '";
14791
14792      // Compile the regexp to match each delimiter.
14793      var reDelimiters = RegExp(
14794        (options.escape || reNoMatch).source + '|' +
14795        interpolate.source + '|' +
14796        (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
14797        (options.evaluate || reNoMatch).source + '|$'
14798      , 'g');
14799
14800      // Use a sourceURL for easier debugging.
14801      // The sourceURL gets injected into the source that's eval-ed, so be careful
14802      // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
14803      // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
14804      var sourceURL = '//# sourceURL=' +
14805        (hasOwnProperty.call(options, 'sourceURL')
14806          ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
14807          : ('lodash.templateSources[' + (++templateCounter) + ']')
14808        ) + '\n';
14809
14810      string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
14811        interpolateValue || (interpolateValue = esTemplateValue);
14812
14813        // Escape characters that can't be included in string literals.
14814        source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
14815
14816        // Replace delimiters with snippets.
14817        if (escapeValue) {
14818          isEscaping = true;
14819          source += "' +\n__e(" + escapeValue + ") +\n'";
14820        }
14821        if (evaluateValue) {
14822          isEvaluating = true;
14823          source += "';\n" + evaluateValue + ";\n__p += '";
14824        }
14825        if (interpolateValue) {
14826          source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
14827        }
14828        index = offset + match.length;
14829
14830        // The JS engine embedded in Adobe products needs `match` returned in
14831        // order to produce the correct `offset` value.
14832        return match;
14833      });
14834
14835      source += "';\n";
14836
14837      // If `variable` is not specified wrap a with-statement around the generated
14838      // code to add the data object to the top of the scope chain.
14839      // Like with sourceURL, we take care to not check the option's prototype,
14840      // as this configuration is a code injection vector.
14841      var variable = hasOwnProperty.call(options, 'variable') && options.variable;
14842      if (!variable) {
14843        source = 'with (obj) {\n' + source + '\n}\n';
14844      }
14845      // Cleanup code by stripping empty strings.
14846      source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
14847        .replace(reEmptyStringMiddle, '$1')
14848        .replace(reEmptyStringTrailing, '$1;');
14849
14850      // Frame code as the function body.
14851      source = 'function(' + (variable || 'obj') + ') {\n' +
14852        (variable
14853          ? ''
14854          : 'obj || (obj = {});\n'
14855        ) +
14856        "var __t, __p = ''" +
14857        (isEscaping
14858           ? ', __e = _.escape'
14859           : ''
14860        ) +
14861        (isEvaluating
14862          ? ', __j = Array.prototype.join;\n' +
14863            "function print() { __p += __j.call(arguments, '') }\n"
14864          : ';\n'
14865        ) +
14866        source +
14867        'return __p\n}';
14868
14869      var result = attempt(function() {
14870        return Function(importsKeys, sourceURL + 'return ' + source)
14871          .apply(undefined, importsValues);
14872      });
14873
14874      // Provide the compiled function's source by its `toString` method or
14875      // the `source` property as a convenience for inlining compiled templates.
14876      result.source = source;
14877      if (isError(result)) {
14878        throw result;
14879      }
14880      return result;
14881    }
14882
14883    /**
14884     * Converts `string`, as a whole, to lower case just like
14885     * [String#toLowerCase](https://mdn.io/toLowerCase).
14886     *
14887     * @static
14888     * @memberOf _
14889     * @since 4.0.0
14890     * @category String
14891     * @param {string} [string=''] The string to convert.
14892     * @returns {string} Returns the lower cased string.
14893     * @example
14894     *
14895     * _.toLower('--Foo-Bar--');
14896     * // => '--foo-bar--'
14897     *
14898     * _.toLower('fooBar');
14899     * // => 'foobar'
14900     *
14901     * _.toLower('__FOO_BAR__');
14902     * // => '__foo_bar__'
14903     */
14904    function toLower(value) {
14905      return toString(value).toLowerCase();
14906    }
14907
14908    /**
14909     * Converts `string`, as a whole, to upper case just like
14910     * [String#toUpperCase](https://mdn.io/toUpperCase).
14911     *
14912     * @static
14913     * @memberOf _
14914     * @since 4.0.0
14915     * @category String
14916     * @param {string} [string=''] The string to convert.
14917     * @returns {string} Returns the upper cased string.
14918     * @example
14919     *
14920     * _.toUpper('--foo-bar--');
14921     * // => '--FOO-BAR--'
14922     *
14923     * _.toUpper('fooBar');
14924     * // => 'FOOBAR'
14925     *
14926     * _.toUpper('__foo_bar__');
14927     * // => '__FOO_BAR__'
14928     */
14929    function toUpper(value) {
14930      return toString(value).toUpperCase();
14931    }
14932
14933    /**
14934     * Removes leading and trailing whitespace or specified characters from `string`.
14935     *
14936     * @static
14937     * @memberOf _
14938     * @since 3.0.0
14939     * @category String
14940     * @param {string} [string=''] The string to trim.
14941     * @param {string} [chars=whitespace] The characters to trim.
14942     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14943     * @returns {string} Returns the trimmed string.
14944     * @example
14945     *
14946     * _.trim('  abc  ');
14947     * // => 'abc'
14948     *
14949     * _.trim('-_-abc-_-', '_-');
14950     * // => 'abc'
14951     *
14952     * _.map(['  foo  ', '  bar  '], _.trim);
14953     * // => ['foo', 'bar']
14954     */
14955    function trim(string, chars, guard) {
14956      string = toString(string);
14957      if (string && (guard || chars === undefined)) {
14958        return string.replace(reTrim, '');
14959      }
14960      if (!string || !(chars = baseToString(chars))) {
14961        return string;
14962      }
14963      var strSymbols = stringToArray(string),
14964          chrSymbols = stringToArray(chars),
14965          start = charsStartIndex(strSymbols, chrSymbols),
14966          end = charsEndIndex(strSymbols, chrSymbols) + 1;
14967
14968      return castSlice(strSymbols, start, end).join('');
14969    }
14970
14971    /**
14972     * Removes trailing whitespace or specified characters from `string`.
14973     *
14974     * @static
14975     * @memberOf _
14976     * @since 4.0.0
14977     * @category String
14978     * @param {string} [string=''] The string to trim.
14979     * @param {string} [chars=whitespace] The characters to trim.
14980     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14981     * @returns {string} Returns the trimmed string.
14982     * @example
14983     *
14984     * _.trimEnd('  abc  ');
14985     * // => '  abc'
14986     *
14987     * _.trimEnd('-_-abc-_-', '_-');
14988     * // => '-_-abc'
14989     */
14990    function trimEnd(string, chars, guard) {
14991      string = toString(string);
14992      if (string && (guard || chars === undefined)) {
14993        return string.replace(reTrimEnd, '');
14994      }
14995      if (!string || !(chars = baseToString(chars))) {
14996        return string;
14997      }
14998      var strSymbols = stringToArray(string),
14999          end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
15000
15001      return castSlice(strSymbols, 0, end).join('');
15002    }
15003
15004    /**
15005     * Removes leading whitespace or specified characters from `string`.
15006     *
15007     * @static
15008     * @memberOf _
15009     * @since 4.0.0
15010     * @category String
15011     * @param {string} [string=''] The string to trim.
15012     * @param {string} [chars=whitespace] The characters to trim.
15013     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15014     * @returns {string} Returns the trimmed string.
15015     * @example
15016     *
15017     * _.trimStart('  abc  ');
15018     * // => 'abc  '
15019     *
15020     * _.trimStart('-_-abc-_-', '_-');
15021     * // => 'abc-_-'
15022     */
15023    function trimStart(string, chars, guard) {
15024      string = toString(string);
15025      if (string && (guard || chars === undefined)) {
15026        return string.replace(reTrimStart, '');
15027      }
15028      if (!string || !(chars = baseToString(chars))) {
15029        return string;
15030      }
15031      var strSymbols = stringToArray(string),
15032          start = charsStartIndex(strSymbols, stringToArray(chars));
15033
15034      return castSlice(strSymbols, start).join('');
15035    }
15036
15037    /**
15038     * Truncates `string` if it's longer than the given maximum string length.
15039     * The last characters of the truncated string are replaced with the omission
15040     * string which defaults to "...".
15041     *
15042     * @static
15043     * @memberOf _
15044     * @since 4.0.0
15045     * @category String
15046     * @param {string} [string=''] The string to truncate.
15047     * @param {Object} [options={}] The options object.
15048     * @param {number} [options.length=30] The maximum string length.
15049     * @param {string} [options.omission='...'] The string to indicate text is omitted.
15050     * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
15051     * @returns {string} Returns the truncated string.
15052     * @example
15053     *
15054     * _.truncate('hi-diddly-ho there, neighborino');
15055     * // => 'hi-diddly-ho there, neighbo...'
15056     *
15057     * _.truncate('hi-diddly-ho there, neighborino', {
15058     *   'length': 24,
15059     *   'separator': ' '
15060     * });
15061     * // => 'hi-diddly-ho there,...'
15062     *
15063     * _.truncate('hi-diddly-ho there, neighborino', {
15064     *   'length': 24,
15065     *   'separator': /,? +/
15066     * });
15067     * // => 'hi-diddly-ho there...'
15068     *
15069     * _.truncate('hi-diddly-ho there, neighborino', {
15070     *   'omission': ' [...]'
15071     * });
15072     * // => 'hi-diddly-ho there, neig [...]'
15073     */
15074    function truncate(string, options) {
15075      var length = DEFAULT_TRUNC_LENGTH,
15076          omission = DEFAULT_TRUNC_OMISSION;
15077
15078      if (isObject(options)) {
15079        var separator = 'separator' in options ? options.separator : separator;
15080        length = 'length' in options ? toInteger(options.length) : length;
15081        omission = 'omission' in options ? baseToString(options.omission) : omission;
15082      }
15083      string = toString(string);
15084
15085      var strLength = string.length;
15086      if (hasUnicode(string)) {
15087        var strSymbols = stringToArray(string);
15088        strLength = strSymbols.length;
15089      }
15090      if (length >= strLength) {
15091        return string;
15092      }
15093      var end = length - stringSize(omission);
15094      if (end < 1) {
15095        return omission;
15096      }
15097      var result = strSymbols
15098        ? castSlice(strSymbols, 0, end).join('')
15099        : string.slice(0, end);
15100
15101      if (separator === undefined) {
15102        return result + omission;
15103      }
15104      if (strSymbols) {
15105        end += (result.length - end);
15106      }
15107      if (isRegExp(separator)) {
15108        if (string.slice(end).search(separator)) {
15109          var match,
15110              substring = result;
15111
15112          if (!separator.global) {
15113            separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15114          }
15115          separator.lastIndex = 0;
15116          while ((match = separator.exec(substring))) {
15117            var newEnd = match.index;
15118          }
15119          result = result.slice(0, newEnd === undefined ? end : newEnd);
15120        }
15121      } else if (string.indexOf(baseToString(separator), end) != end) {
15122        var index = result.lastIndexOf(separator);
15123        if (index > -1) {
15124          result = result.slice(0, index);
15125        }
15126      }
15127      return result + omission;
15128    }
15129
15130    /**
15131     * The inverse of `_.escape`; this method converts the HTML entities
15132     * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
15133     * their corresponding characters.
15134     *
15135     * **Note:** No other HTML entities are unescaped. To unescape additional
15136     * HTML entities use a third-party library like [_he_](https://mths.be/he).
15137     *
15138     * @static
15139     * @memberOf _
15140     * @since 0.6.0
15141     * @category String
15142     * @param {string} [string=''] The string to unescape.
15143     * @returns {string} Returns the unescaped string.
15144     * @example
15145     *
15146     * _.unescape('fred, barney, &amp; pebbles');
15147     * // => 'fred, barney, & pebbles'
15148     */
15149    function unescape(string) {
15150      string = toString(string);
15151      return (string && reHasEscapedHtml.test(string))
15152        ? string.replace(reEscapedHtml, unescapeHtmlChar)
15153        : string;
15154    }
15155
15156    /**
15157     * Converts `string`, as space separated words, to upper case.
15158     *
15159     * @static
15160     * @memberOf _
15161     * @since 4.0.0
15162     * @category String
15163     * @param {string} [string=''] The string to convert.
15164     * @returns {string} Returns the upper cased string.
15165     * @example
15166     *
15167     * _.upperCase('--foo-bar');
15168     * // => 'FOO BAR'
15169     *
15170     * _.upperCase('fooBar');
15171     * // => 'FOO BAR'
15172     *
15173     * _.upperCase('__foo_bar__');
15174     * // => 'FOO BAR'
15175     */
15176    var upperCase = createCompounder(function(result, word, index) {
15177      return result + (index ? ' ' : '') + word.toUpperCase();
15178    });
15179
15180    /**
15181     * Converts the first character of `string` to upper case.
15182     *
15183     * @static
15184     * @memberOf _
15185     * @since 4.0.0
15186     * @category String
15187     * @param {string} [string=''] The string to convert.
15188     * @returns {string} Returns the converted string.
15189     * @example
15190     *
15191     * _.upperFirst('fred');
15192     * // => 'Fred'
15193     *
15194     * _.upperFirst('FRED');
15195     * // => 'FRED'
15196     */
15197    var upperFirst = createCaseFirst('toUpperCase');
15198
15199    /**
15200     * Splits `string` into an array of its words.
15201     *
15202     * @static
15203     * @memberOf _
15204     * @since 3.0.0
15205     * @category String
15206     * @param {string} [string=''] The string to inspect.
15207     * @param {RegExp|string} [pattern] The pattern to match words.
15208     * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15209     * @returns {Array} Returns the words of `string`.
15210     * @example
15211     *
15212     * _.words('fred, barney, & pebbles');
15213     * // => ['fred', 'barney', 'pebbles']
15214     *
15215     * _.words('fred, barney, & pebbles', /[^, ]+/g);
15216     * // => ['fred', 'barney', '&', 'pebbles']
15217     */
15218    function words(string, pattern, guard) {
15219      string = toString(string);
15220      pattern = guard ? undefined : pattern;
15221
15222      if (pattern === undefined) {
15223        return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15224      }
15225      return string.match(pattern) || [];
15226    }
15227
15228    /*------------------------------------------------------------------------*/
15229
15230    /**
15231     * Attempts to invoke `func`, returning either the result or the caught error
15232     * object. Any additional arguments are provided to `func` when it's invoked.
15233     *
15234     * @static
15235     * @memberOf _
15236     * @since 3.0.0
15237     * @category Util
15238     * @param {Function} func The function to attempt.
15239     * @param {...*} [args] The arguments to invoke `func` with.
15240     * @returns {*} Returns the `func` result or error object.
15241     * @example
15242     *
15243     * // Avoid throwing errors for invalid selectors.
15244     * var elements = _.attempt(function(selector) {
15245     *   return document.querySelectorAll(selector);
15246     * }, '>_>');
15247     *
15248     * if (_.isError(elements)) {
15249     *   elements = [];
15250     * }
15251     */
15252    var attempt = baseRest(function(func, args) {
15253      try {
15254        return apply(func, undefined, args);
15255      } catch (e) {
15256        return isError(e) ? e : new Error(e);
15257      }
15258    });
15259
15260    /**
15261     * Binds methods of an object to the object itself, overwriting the existing
15262     * method.
15263     *
15264     * **Note:** This method doesn't set the "length" property of bound functions.
15265     *
15266     * @static
15267     * @since 0.1.0
15268     * @memberOf _
15269     * @category Util
15270     * @param {Object} object The object to bind and assign the bound methods to.
15271     * @param {...(string|string[])} methodNames The object method names to bind.
15272     * @returns {Object} Returns `object`.
15273     * @example
15274     *
15275     * var view = {
15276     *   'label': 'docs',
15277     *   'click': function() {
15278     *     console.log('clicked ' + this.label);
15279     *   }
15280     * };
15281     *
15282     * _.bindAll(view, ['click']);
15283     * jQuery(element).on('click', view.click);
15284     * // => Logs 'clicked docs' when clicked.
15285     */
15286    var bindAll = flatRest(function(object, methodNames) {
15287      arrayEach(methodNames, function(key) {
15288        key = toKey(key);
15289        baseAssignValue(object, key, bind(object[key], object));
15290      });
15291      return object;
15292    });
15293
15294    /**
15295     * Creates a function that iterates over `pairs` and invokes the corresponding
15296     * function of the first predicate to return truthy. The predicate-function
15297     * pairs are invoked with the `this` binding and arguments of the created
15298     * function.
15299     *
15300     * @static
15301     * @memberOf _
15302     * @since 4.0.0
15303     * @category Util
15304     * @param {Array} pairs The predicate-function pairs.
15305     * @returns {Function} Returns the new composite function.
15306     * @example
15307     *
15308     * var func = _.cond([
15309     *   [_.matches({ 'a': 1 }),           _.constant('matches A')],
15310     *   [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15311     *   [_.stubTrue,                      _.constant('no match')]
15312     * ]);
15313     *
15314     * func({ 'a': 1, 'b': 2 });
15315     * // => 'matches A'
15316     *
15317     * func({ 'a': 0, 'b': 1 });
15318     * // => 'matches B'
15319     *
15320     * func({ 'a': '1', 'b': '2' });
15321     * // => 'no match'
15322     */
15323    function cond(pairs) {
15324      var length = pairs == null ? 0 : pairs.length,
15325          toIteratee = getIteratee();
15326
15327      pairs = !length ? [] : arrayMap(pairs, function(pair) {
15328        if (typeof pair[1] != 'function') {
15329          throw new TypeError(FUNC_ERROR_TEXT);
15330        }
15331        return [toIteratee(pair[0]), pair[1]];
15332      });
15333
15334      return baseRest(function(args) {
15335        var index = -1;
15336        while (++index < length) {
15337          var pair = pairs[index];
15338          if (apply(pair[0], this, args)) {
15339            return apply(pair[1], this, args);
15340          }
15341        }
15342      });
15343    }
15344
15345    /**
15346     * Creates a function that invokes the predicate properties of `source` with
15347     * the corresponding property values of a given object, returning `true` if
15348     * all predicates return truthy, else `false`.
15349     *
15350     * **Note:** The created function is equivalent to `_.conformsTo` with
15351     * `source` partially applied.
15352     *
15353     * @static
15354     * @memberOf _
15355     * @since 4.0.0
15356     * @category Util
15357     * @param {Object} source The object of property predicates to conform to.
15358     * @returns {Function} Returns the new spec function.
15359     * @example
15360     *
15361     * var objects = [
15362     *   { 'a': 2, 'b': 1 },
15363     *   { 'a': 1, 'b': 2 }
15364     * ];
15365     *
15366     * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15367     * // => [{ 'a': 1, 'b': 2 }]
15368     */
15369    function conforms(source) {
15370      return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
15371    }
15372
15373    /**
15374     * Creates a function that returns `value`.
15375     *
15376     * @static
15377     * @memberOf _
15378     * @since 2.4.0
15379     * @category Util
15380     * @param {*} value The value to return from the new function.
15381     * @returns {Function} Returns the new constant function.
15382     * @example
15383     *
15384     * var objects = _.times(2, _.constant({ 'a': 1 }));
15385     *
15386     * console.log(objects);
15387     * // => [{ 'a': 1 }, { 'a': 1 }]
15388     *
15389     * console.log(objects[0] === objects[1]);
15390     * // => true
15391     */
15392    function constant(value) {
15393      return function() {
15394        return value;
15395      };
15396    }
15397
15398    /**
15399     * Checks `value` to determine whether a default value should be returned in
15400     * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
15401     * or `undefined`.
15402     *
15403     * @static
15404     * @memberOf _
15405     * @since 4.14.0
15406     * @category Util
15407     * @param {*} value The value to check.
15408     * @param {*} defaultValue The default value.
15409     * @returns {*} Returns the resolved value.
15410     * @example
15411     *
15412     * _.defaultTo(1, 10);
15413     * // => 1
15414     *
15415     * _.defaultTo(undefined, 10);
15416     * // => 10
15417     */
15418    function defaultTo(value, defaultValue) {
15419      return (value == null || value !== value) ? defaultValue : value;
15420    }
15421
15422    /**
15423     * Creates a function that returns the result of invoking the given functions
15424     * with the `this` binding of the created function, where each successive
15425     * invocation is supplied the return value of the previous.
15426     *
15427     * @static
15428     * @memberOf _
15429     * @since 3.0.0
15430     * @category Util
15431     * @param {...(Function|Function[])} [funcs] The functions to invoke.
15432     * @returns {Function} Returns the new composite function.
15433     * @see _.flowRight
15434     * @example
15435     *
15436     * function square(n) {
15437     *   return n * n;
15438     * }
15439     *
15440     * var addSquare = _.flow([_.add, square]);
15441     * addSquare(1, 2);
15442     * // => 9
15443     */
15444    var flow = createFlow();
15445
15446    /**
15447     * This method is like `_.flow` except that it creates a function that
15448     * invokes the given functions from right to left.
15449     *
15450     * @static
15451     * @since 3.0.0
15452     * @memberOf _
15453     * @category Util
15454     * @param {...(Function|Function[])} [funcs] The functions to invoke.
15455     * @returns {Function} Returns the new composite function.
15456     * @see _.flow
15457     * @example
15458     *
15459     * function square(n) {
15460     *   return n * n;
15461     * }
15462     *
15463     * var addSquare = _.flowRight([square, _.add]);
15464     * addSquare(1, 2);
15465     * // => 9
15466     */
15467    var flowRight = createFlow(true);
15468
15469    /**
15470     * This method returns the first argument it receives.
15471     *
15472     * @static
15473     * @since 0.1.0
15474     * @memberOf _
15475     * @category Util
15476     * @param {*} value Any value.
15477     * @returns {*} Returns `value`.
15478     * @example
15479     *
15480     * var object = { 'a': 1 };
15481     *
15482     * console.log(_.identity(object) === object);
15483     * // => true
15484     */
15485    function identity(value) {
15486      return value;
15487    }
15488
15489    /**
15490     * Creates a function that invokes `func` with the arguments of the created
15491     * function. If `func` is a property name, the created function returns the
15492     * property value for a given element. If `func` is an array or object, the
15493     * created function returns `true` for elements that contain the equivalent
15494     * source properties, otherwise it returns `false`.
15495     *
15496     * @static
15497     * @since 4.0.0
15498     * @memberOf _
15499     * @category Util
15500     * @param {*} [func=_.identity] The value to convert to a callback.
15501     * @returns {Function} Returns the callback.
15502     * @example
15503     *
15504     * var users = [
15505     *   { 'user': 'barney', 'age': 36, 'active': true },
15506     *   { 'user': 'fred',   'age': 40, 'active': false }
15507     * ];
15508     *
15509     * // The `_.matches` iteratee shorthand.
15510     * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15511     * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15512     *
15513     * // The `_.matchesProperty` iteratee shorthand.
15514     * _.filter(users, _.iteratee(['user', 'fred']));
15515     * // => [{ 'user': 'fred', 'age': 40 }]
15516     *
15517     * // The `_.property` iteratee shorthand.
15518     * _.map(users, _.iteratee('user'));
15519     * // => ['barney', 'fred']
15520     *
15521     * // Create custom iteratee shorthands.
15522     * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
15523     *   return !_.isRegExp(func) ? iteratee(func) : function(string) {
15524     *     return func.test(string);
15525     *   };
15526     * });
15527     *
15528     * _.filter(['abc', 'def'], /ef/);
15529     * // => ['def']
15530     */
15531    function iteratee(func) {
15532      return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
15533    }
15534
15535    /**
15536     * Creates a function that performs a partial deep comparison between a given
15537     * object and `source`, returning `true` if the given object has equivalent
15538     * property values, else `false`.
15539     *
15540     * **Note:** The created function is equivalent to `_.isMatch` with `source`
15541     * partially applied.
15542     *
15543     * Partial comparisons will match empty array and empty object `source`
15544     * values against any array or object value, respectively. See `_.isEqual`
15545     * for a list of supported value comparisons.
15546     *
15547     * @static
15548     * @memberOf _
15549     * @since 3.0.0
15550     * @category Util
15551     * @param {Object} source The object of property values to match.
15552     * @returns {Function} Returns the new spec function.
15553     * @example
15554     *
15555     * var objects = [
15556     *   { 'a': 1, 'b': 2, 'c': 3 },
15557     *   { 'a': 4, 'b': 5, 'c': 6 }
15558     * ];
15559     *
15560     * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15561     * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15562     */
15563    function matches(source) {
15564      return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
15565    }
15566
15567    /**
15568     * Creates a function that performs a partial deep comparison between the
15569     * value at `path` of a given object to `srcValue`, returning `true` if the
15570     * object value is equivalent, else `false`.
15571     *
15572     * **Note:** Partial comparisons will match empty array and empty object
15573     * `srcValue` values against any array or object value, respectively. See
15574     * `_.isEqual` for a list of supported value comparisons.
15575     *
15576     * @static
15577     * @memberOf _
15578     * @since 3.2.0
15579     * @category Util
15580     * @param {Array|string} path The path of the property to get.
15581     * @param {*} srcValue The value to match.
15582     * @returns {Function} Returns the new spec function.
15583     * @example
15584     *
15585     * var objects = [
15586     *   { 'a': 1, 'b': 2, 'c': 3 },
15587     *   { 'a': 4, 'b': 5, 'c': 6 }
15588     * ];
15589     *
15590     * _.find(objects, _.matchesProperty('a', 4));
15591     * // => { 'a': 4, 'b': 5, 'c': 6 }
15592     */
15593    function matchesProperty(path, srcValue) {
15594      return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
15595    }
15596
15597    /**
15598     * Creates a function that invokes the method at `path` of a given object.
15599     * Any additional arguments are provided to the invoked method.
15600     *
15601     * @static
15602     * @memberOf _
15603     * @since 3.7.0
15604     * @category Util
15605     * @param {Array|string} path The path of the method to invoke.
15606     * @param {...*} [args] The arguments to invoke the method with.
15607     * @returns {Function} Returns the new invoker function.
15608     * @example
15609     *
15610     * var objects = [
15611     *   { 'a': { 'b': _.constant(2) } },
15612     *   { 'a': { 'b': _.constant(1) } }
15613     * ];
15614     *
15615     * _.map(objects, _.method('a.b'));
15616     * // => [2, 1]
15617     *
15618     * _.map(objects, _.method(['a', 'b']));
15619     * // => [2, 1]
15620     */
15621    var method = baseRest(function(path, args) {
15622      return function(object) {
15623        return baseInvoke(object, path, args);
15624      };
15625    });
15626
15627    /**
15628     * The opposite of `_.method`; this method creates a function that invokes
15629     * the method at a given path of `object`. Any additional arguments are
15630     * provided to the invoked method.
15631     *
15632     * @static
15633     * @memberOf _
15634     * @since 3.7.0
15635     * @category Util
15636     * @param {Object} object The object to query.
15637     * @param {...*} [args] The arguments to invoke the method with.
15638     * @returns {Function} Returns the new invoker function.
15639     * @example
15640     *
15641     * var array = _.times(3, _.constant),
15642     *     object = { 'a': array, 'b': array, 'c': array };
15643     *
15644     * _.map(['a[2]', 'c[0]'], _.methodOf(object));
15645     * // => [2, 0]
15646     *
15647     * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
15648     * // => [2, 0]
15649     */
15650    var methodOf = baseRest(function(object, args) {
15651      return function(path) {
15652        return baseInvoke(object, path, args);
15653      };
15654    });
15655
15656    /**
15657     * Adds all own enumerable string keyed function properties of a source
15658     * object to the destination object. If `object` is a function, then methods
15659     * are added to its prototype as well.
15660     *
15661     * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
15662     * avoid conflicts caused by modifying the original.
15663     *
15664     * @static
15665     * @since 0.1.0
15666     * @memberOf _
15667     * @category Util
15668     * @param {Function|Object} [object=lodash] The destination object.
15669     * @param {Object} source The object of functions to add.
15670     * @param {Object} [options={}] The options object.
15671     * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
15672     * @returns {Function|Object} Returns `object`.
15673     * @example
15674     *
15675     * function vowels(string) {
15676     *   return _.filter(string, function(v) {
15677     *     return /[aeiou]/i.test(v);
15678     *   });
15679     * }
15680     *
15681     * _.mixin({ 'vowels': vowels });
15682     * _.vowels('fred');
15683     * // => ['e']
15684     *
15685     * _('fred').vowels().value();
15686     * // => ['e']
15687     *
15688     * _.mixin({ 'vowels': vowels }, { 'chain': false });
15689     * _('fred').vowels();
15690     * // => ['e']
15691     */
15692    function mixin(object, source, options) {
15693      var props = keys(source),
15694          methodNames = baseFunctions(source, props);
15695
15696      if (options == null &&
15697          !(isObject(source) && (methodNames.length || !props.length))) {
15698        options = source;
15699        source = object;
15700        object = this;
15701        methodNames = baseFunctions(source, keys(source));
15702      }
15703      var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
15704          isFunc = isFunction(object);
15705
15706      arrayEach(methodNames, function(methodName) {
15707        var func = source[methodName];
15708        object[methodName] = func;
15709        if (isFunc) {
15710          object.prototype[methodName] = function() {
15711            var chainAll = this.__chain__;
15712            if (chain || chainAll) {
15713              var result = object(this.__wrapped__),
15714                  actions = result.__actions__ = copyArray(this.__actions__);
15715
15716              actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
15717              result.__chain__ = chainAll;
15718              return result;
15719            }
15720            return func.apply(object, arrayPush([this.value()], arguments));
15721          };
15722        }
15723      });
15724
15725      return object;
15726    }
15727
15728    /**
15729     * Reverts the `_` variable to its previous value and returns a reference to
15730     * the `lodash` function.
15731     *
15732     * @static
15733     * @since 0.1.0
15734     * @memberOf _
15735     * @category Util
15736     * @returns {Function} Returns the `lodash` function.
15737     * @example
15738     *
15739     * var lodash = _.noConflict();
15740     */
15741    function noConflict() {
15742      if (root._ === this) {
15743        root._ = oldDash;
15744      }
15745      return this;
15746    }
15747
15748    /**
15749     * This method returns `undefined`.
15750     *
15751     * @static
15752     * @memberOf _
15753     * @since 2.3.0
15754     * @category Util
15755     * @example
15756     *
15757     * _.times(2, _.noop);
15758     * // => [undefined, undefined]
15759     */
15760    function noop() {
15761      // No operation performed.
15762    }
15763
15764    /**
15765     * Creates a function that gets the argument at index `n`. If `n` is negative,
15766     * the nth argument from the end is returned.
15767     *
15768     * @static
15769     * @memberOf _
15770     * @since 4.0.0
15771     * @category Util
15772     * @param {number} [n=0] The index of the argument to return.
15773     * @returns {Function} Returns the new pass-thru function.
15774     * @example
15775     *
15776     * var func = _.nthArg(1);
15777     * func('a', 'b', 'c', 'd');
15778     * // => 'b'
15779     *
15780     * var func = _.nthArg(-2);
15781     * func('a', 'b', 'c', 'd');
15782     * // => 'c'
15783     */
15784    function nthArg(n) {
15785      n = toInteger(n);
15786      return baseRest(function(args) {
15787        return baseNth(args, n);
15788      });
15789    }
15790
15791    /**
15792     * Creates a function that invokes `iteratees` with the arguments it receives
15793     * and returns their results.
15794     *
15795     * @static
15796     * @memberOf _
15797     * @since 4.0.0
15798     * @category Util
15799     * @param {...(Function|Function[])} [iteratees=[_.identity]]
15800     *  The iteratees to invoke.
15801     * @returns {Function} Returns the new function.
15802     * @example
15803     *
15804     * var func = _.over([Math.max, Math.min]);
15805     *
15806     * func(1, 2, 3, 4);
15807     * // => [4, 1]
15808     */
15809    var over = createOver(arrayMap);
15810
15811    /**
15812     * Creates a function that checks if **all** of the `predicates` return
15813     * truthy when invoked with the arguments it receives.
15814     *
15815     * @static
15816     * @memberOf _
15817     * @since 4.0.0
15818     * @category Util
15819     * @param {...(Function|Function[])} [predicates=[_.identity]]
15820     *  The predicates to check.
15821     * @returns {Function} Returns the new function.
15822     * @example
15823     *
15824     * var func = _.overEvery([Boolean, isFinite]);
15825     *
15826     * func('1');
15827     * // => true
15828     *
15829     * func(null);
15830     * // => false
15831     *
15832     * func(NaN);
15833     * // => false
15834     */
15835    var overEvery = createOver(arrayEvery);
15836
15837    /**
15838     * Creates a function that checks if **any** of the `predicates` return
15839     * truthy when invoked with the arguments it receives.
15840     *
15841     * @static
15842     * @memberOf _
15843     * @since 4.0.0
15844     * @category Util
15845     * @param {...(Function|Function[])} [predicates=[_.identity]]
15846     *  The predicates to check.
15847     * @returns {Function} Returns the new function.
15848     * @example
15849     *
15850     * var func = _.overSome([Boolean, isFinite]);
15851     *
15852     * func('1');
15853     * // => true
15854     *
15855     * func(null);
15856     * // => true
15857     *
15858     * func(NaN);
15859     * // => false
15860     */
15861    var overSome = createOver(arraySome);
15862
15863    /**
15864     * Creates a function that returns the value at `path` of a given object.
15865     *
15866     * @static
15867     * @memberOf _
15868     * @since 2.4.0
15869     * @category Util
15870     * @param {Array|string} path The path of the property to get.
15871     * @returns {Function} Returns the new accessor function.
15872     * @example
15873     *
15874     * var objects = [
15875     *   { 'a': { 'b': 2 } },
15876     *   { 'a': { 'b': 1 } }
15877     * ];
15878     *
15879     * _.map(objects, _.property('a.b'));
15880     * // => [2, 1]
15881     *
15882     * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
15883     * // => [1, 2]
15884     */
15885    function property(path) {
15886      return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
15887    }
15888
15889    /**
15890     * The opposite of `_.property`; this method creates a function that returns
15891     * the value at a given path of `object`.
15892     *
15893     * @static
15894     * @memberOf _
15895     * @since 3.0.0
15896     * @category Util
15897     * @param {Object} object The object to query.
15898     * @returns {Function} Returns the new accessor function.
15899     * @example
15900     *
15901     * var array = [0, 1, 2],
15902     *     object = { 'a': array, 'b': array, 'c': array };
15903     *
15904     * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
15905     * // => [2, 0]
15906     *
15907     * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
15908     * // => [2, 0]
15909     */
15910    function propertyOf(object) {
15911      return function(path) {
15912        return object == null ? undefined : baseGet(object, path);
15913      };
15914    }
15915
15916    /**
15917     * Creates an array of numbers (positive and/or negative) progressing from
15918     * `start` up to, but not including, `end`. A step of `-1` is used if a negative
15919     * `start` is specified without an `end` or `step`. If `end` is not specified,
15920     * it's set to `start` with `start` then set to `0`.
15921     *
15922     * **Note:** JavaScript follows the IEEE-754 standard for resolving
15923     * floating-point values which can produce unexpected results.
15924     *
15925     * @static
15926     * @since 0.1.0
15927     * @memberOf _
15928     * @category Util
15929     * @param {number} [start=0] The start of the range.
15930     * @param {number} end The end of the range.
15931     * @param {number} [step=1] The value to increment or decrement by.
15932     * @returns {Array} Returns the range of numbers.
15933     * @see _.inRange, _.rangeRight
15934     * @example
15935     *
15936     * _.range(4);
15937     * // => [0, 1, 2, 3]
15938     *
15939     * _.range(-4);
15940     * // => [0, -1, -2, -3]
15941     *
15942     * _.range(1, 5);
15943     * // => [1, 2, 3, 4]
15944     *
15945     * _.range(0, 20, 5);
15946     * // => [0, 5, 10, 15]
15947     *
15948     * _.range(0, -4, -1);
15949     * // => [0, -1, -2, -3]
15950     *
15951     * _.range(1, 4, 0);
15952     * // => [1, 1, 1]
15953     *
15954     * _.range(0);
15955     * // => []
15956     */
15957    var range = createRange();
15958
15959    /**
15960     * This method is like `_.range` except that it populates values in
15961     * descending order.
15962     *
15963     * @static
15964     * @memberOf _
15965     * @since 4.0.0
15966     * @category Util
15967     * @param {number} [start=0] The start of the range.
15968     * @param {number} end The end of the range.
15969     * @param {number} [step=1] The value to increment or decrement by.
15970     * @returns {Array} Returns the range of numbers.
15971     * @see _.inRange, _.range
15972     * @example
15973     *
15974     * _.rangeRight(4);
15975     * // => [3, 2, 1, 0]
15976     *
15977     * _.rangeRight(-4);
15978     * // => [-3, -2, -1, 0]
15979     *
15980     * _.rangeRight(1, 5);
15981     * // => [4, 3, 2, 1]
15982     *
15983     * _.rangeRight(0, 20, 5);
15984     * // => [15, 10, 5, 0]
15985     *
15986     * _.rangeRight(0, -4, -1);
15987     * // => [-3, -2, -1, 0]
15988     *
15989     * _.rangeRight(1, 4, 0);
15990     * // => [1, 1, 1]
15991     *
15992     * _.rangeRight(0);
15993     * // => []
15994     */
15995    var rangeRight = createRange(true);
15996
15997    /**
15998     * This method returns a new empty array.
15999     *
16000     * @static
16001     * @memberOf _
16002     * @since 4.13.0
16003     * @category Util
16004     * @returns {Array} Returns the new empty array.
16005     * @example
16006     *
16007     * var arrays = _.times(2, _.stubArray);
16008     *
16009     * console.log(arrays);
16010     * // => [[], []]
16011     *
16012     * console.log(arrays[0] === arrays[1]);
16013     * // => false
16014     */
16015    function stubArray() {
16016      return [];
16017    }
16018
16019    /**
16020     * This method returns `false`.
16021     *
16022     * @static
16023     * @memberOf _
16024     * @since 4.13.0
16025     * @category Util
16026     * @returns {boolean} Returns `false`.
16027     * @example
16028     *
16029     * _.times(2, _.stubFalse);
16030     * // => [false, false]
16031     */
16032    function stubFalse() {
16033      return false;
16034    }
16035
16036    /**
16037     * This method returns a new empty object.
16038     *
16039     * @static
16040     * @memberOf _
16041     * @since 4.13.0
16042     * @category Util
16043     * @returns {Object} Returns the new empty object.
16044     * @example
16045     *
16046     * var objects = _.times(2, _.stubObject);
16047     *
16048     * console.log(objects);
16049     * // => [{}, {}]
16050     *
16051     * console.log(objects[0] === objects[1]);
16052     * // => false
16053     */
16054    function stubObject() {
16055      return {};
16056    }
16057
16058    /**
16059     * This method returns an empty string.
16060     *
16061     * @static
16062     * @memberOf _
16063     * @since 4.13.0
16064     * @category Util
16065     * @returns {string} Returns the empty string.
16066     * @example
16067     *
16068     * _.times(2, _.stubString);
16069     * // => ['', '']
16070     */
16071    function stubString() {
16072      return '';
16073    }
16074
16075    /**
16076     * This method returns `true`.
16077     *
16078     * @static
16079     * @memberOf _
16080     * @since 4.13.0
16081     * @category Util
16082     * @returns {boolean} Returns `true`.
16083     * @example
16084     *
16085     * _.times(2, _.stubTrue);
16086     * // => [true, true]
16087     */
16088    function stubTrue() {
16089      return true;
16090    }
16091
16092    /**
16093     * Invokes the iteratee `n` times, returning an array of the results of
16094     * each invocation. The iteratee is invoked with one argument; (index).
16095     *
16096     * @static
16097     * @since 0.1.0
16098     * @memberOf _
16099     * @category Util
16100     * @param {number} n The number of times to invoke `iteratee`.
16101     * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16102     * @returns {Array} Returns the array of results.
16103     * @example
16104     *
16105     * _.times(3, String);
16106     * // => ['0', '1', '2']
16107     *
16108     *  _.times(4, _.constant(0));
16109     * // => [0, 0, 0, 0]
16110     */
16111    function times(n, iteratee) {
16112      n = toInteger(n);
16113      if (n < 1 || n > MAX_SAFE_INTEGER) {
16114        return [];
16115      }
16116      var index = MAX_ARRAY_LENGTH,
16117          length = nativeMin(n, MAX_ARRAY_LENGTH);
16118
16119      iteratee = getIteratee(iteratee);
16120      n -= MAX_ARRAY_LENGTH;
16121
16122      var result = baseTimes(length, iteratee);
16123      while (++index < n) {
16124        iteratee(index);
16125      }
16126      return result;
16127    }
16128
16129    /**
16130     * Converts `value` to a property path array.
16131     *
16132     * @static
16133     * @memberOf _
16134     * @since 4.0.0
16135     * @category Util
16136     * @param {*} value The value to convert.
16137     * @returns {Array} Returns the new property path array.
16138     * @example
16139     *
16140     * _.toPath('a.b.c');
16141     * // => ['a', 'b', 'c']
16142     *
16143     * _.toPath('a[0].b.c');
16144     * // => ['a', '0', 'b', 'c']
16145     */
16146    function toPath(value) {
16147      if (isArray(value)) {
16148        return arrayMap(value, toKey);
16149      }
16150      return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
16151    }
16152
16153    /**
16154     * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16155     *
16156     * @static
16157     * @since 0.1.0
16158     * @memberOf _
16159     * @category Util
16160     * @param {string} [prefix=''] The value to prefix the ID with.
16161     * @returns {string} Returns the unique ID.
16162     * @example
16163     *
16164     * _.uniqueId('contact_');
16165     * // => 'contact_104'
16166     *
16167     * _.uniqueId();
16168     * // => '105'
16169     */
16170    function uniqueId(prefix) {
16171      var id = ++idCounter;
16172      return toString(prefix) + id;
16173    }
16174
16175    /*------------------------------------------------------------------------*/
16176
16177    /**
16178     * Adds two numbers.
16179     *
16180     * @static
16181     * @memberOf _
16182     * @since 3.4.0
16183     * @category Math
16184     * @param {number} augend The first number in an addition.
16185     * @param {number} addend The second number in an addition.
16186     * @returns {number} Returns the total.
16187     * @example
16188     *
16189     * _.add(6, 4);
16190     * // => 10
16191     */
16192    var add = createMathOperation(function(augend, addend) {
16193      return augend + addend;
16194    }, 0);
16195
16196    /**
16197     * Computes `number` rounded up to `precision`.
16198     *
16199     * @static
16200     * @memberOf _
16201     * @since 3.10.0
16202     * @category Math
16203     * @param {number} number The number to round up.
16204     * @param {number} [precision=0] The precision to round up to.
16205     * @returns {number} Returns the rounded up number.
16206     * @example
16207     *
16208     * _.ceil(4.006);
16209     * // => 5
16210     *
16211     * _.ceil(6.004, 2);
16212     * // => 6.01
16213     *
16214     * _.ceil(6040, -2);
16215     * // => 6100
16216     */
16217    var ceil = createRound('ceil');
16218
16219    /**
16220     * Divide two numbers.
16221     *
16222     * @static
16223     * @memberOf _
16224     * @since 4.7.0
16225     * @category Math
16226     * @param {number} dividend The first number in a division.
16227     * @param {number} divisor The second number in a division.
16228     * @returns {number} Returns the quotient.
16229     * @example
16230     *
16231     * _.divide(6, 4);
16232     * // => 1.5
16233     */
16234    var divide = createMathOperation(function(dividend, divisor) {
16235      return dividend / divisor;
16236    }, 1);
16237
16238    /**
16239     * Computes `number` rounded down to `precision`.
16240     *
16241     * @static
16242     * @memberOf _
16243     * @since 3.10.0
16244     * @category Math
16245     * @param {number} number The number to round down.
16246     * @param {number} [precision=0] The precision to round down to.
16247     * @returns {number} Returns the rounded down number.
16248     * @example
16249     *
16250     * _.floor(4.006);
16251     * // => 4
16252     *
16253     * _.floor(0.046, 2);
16254     * // => 0.04
16255     *
16256     * _.floor(4060, -2);
16257     * // => 4000
16258     */
16259    var floor = createRound('floor');
16260
16261    /**
16262     * Computes the maximum value of `array`. If `array` is empty or falsey,
16263     * `undefined` is returned.
16264     *
16265     * @static
16266     * @since 0.1.0
16267     * @memberOf _
16268     * @category Math
16269     * @param {Array} array The array to iterate over.
16270     * @returns {*} Returns the maximum value.
16271     * @example
16272     *
16273     * _.max([4, 2, 8, 6]);
16274     * // => 8
16275     *
16276     * _.max([]);
16277     * // => undefined
16278     */
16279    function max(array) {
16280      return (array && array.length)
16281        ? baseExtremum(array, identity, baseGt)
16282        : undefined;
16283    }
16284
16285    /**
16286     * This method is like `_.max` except that it accepts `iteratee` which is
16287     * invoked for each element in `array` to generate the criterion by which
16288     * the value is ranked. The iteratee is invoked with one argument: (value).
16289     *
16290     * @static
16291     * @memberOf _
16292     * @since 4.0.0
16293     * @category Math
16294     * @param {Array} array The array to iterate over.
16295     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16296     * @returns {*} Returns the maximum value.
16297     * @example
16298     *
16299     * var objects = [{ 'n': 1 }, { 'n': 2 }];
16300     *
16301     * _.maxBy(objects, function(o) { return o.n; });
16302     * // => { 'n': 2 }
16303     *
16304     * // The `_.property` iteratee shorthand.
16305     * _.maxBy(objects, 'n');
16306     * // => { 'n': 2 }
16307     */
16308    function maxBy(array, iteratee) {
16309      return (array && array.length)
16310        ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
16311        : undefined;
16312    }
16313
16314    /**
16315     * Computes the mean of the values in `array`.
16316     *
16317     * @static
16318     * @memberOf _
16319     * @since 4.0.0
16320     * @category Math
16321     * @param {Array} array The array to iterate over.
16322     * @returns {number} Returns the mean.
16323     * @example
16324     *
16325     * _.mean([4, 2, 8, 6]);
16326     * // => 5
16327     */
16328    function mean(array) {
16329      return baseMean(array, identity);
16330    }
16331
16332    /**
16333     * This method is like `_.mean` except that it accepts `iteratee` which is
16334     * invoked for each element in `array` to generate the value to be averaged.
16335     * The iteratee is invoked with one argument: (value).
16336     *
16337     * @static
16338     * @memberOf _
16339     * @since 4.7.0
16340     * @category Math
16341     * @param {Array} array The array to iterate over.
16342     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16343     * @returns {number} Returns the mean.
16344     * @example
16345     *
16346     * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16347     *
16348     * _.meanBy(objects, function(o) { return o.n; });
16349     * // => 5
16350     *
16351     * // The `_.property` iteratee shorthand.
16352     * _.meanBy(objects, 'n');
16353     * // => 5
16354     */
16355    function meanBy(array, iteratee) {
16356      return baseMean(array, getIteratee(iteratee, 2));
16357    }
16358
16359    /**
16360     * Computes the minimum value of `array`. If `array` is empty or falsey,
16361     * `undefined` is returned.
16362     *
16363     * @static
16364     * @since 0.1.0
16365     * @memberOf _
16366     * @category Math
16367     * @param {Array} array The array to iterate over.
16368     * @returns {*} Returns the minimum value.
16369     * @example
16370     *
16371     * _.min([4, 2, 8, 6]);
16372     * // => 2
16373     *
16374     * _.min([]);
16375     * // => undefined
16376     */
16377    function min(array) {
16378      return (array && array.length)
16379        ? baseExtremum(array, identity, baseLt)
16380        : undefined;
16381    }
16382
16383    /**
16384     * This method is like `_.min` except that it accepts `iteratee` which is
16385     * invoked for each element in `array` to generate the criterion by which
16386     * the value is ranked. The iteratee is invoked with one argument: (value).
16387     *
16388     * @static
16389     * @memberOf _
16390     * @since 4.0.0
16391     * @category Math
16392     * @param {Array} array The array to iterate over.
16393     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16394     * @returns {*} Returns the minimum value.
16395     * @example
16396     *
16397     * var objects = [{ 'n': 1 }, { 'n': 2 }];
16398     *
16399     * _.minBy(objects, function(o) { return o.n; });
16400     * // => { 'n': 1 }
16401     *
16402     * // The `_.property` iteratee shorthand.
16403     * _.minBy(objects, 'n');
16404     * // => { 'n': 1 }
16405     */
16406    function minBy(array, iteratee) {
16407      return (array && array.length)
16408        ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
16409        : undefined;
16410    }
16411
16412    /**
16413     * Multiply two numbers.
16414     *
16415     * @static
16416     * @memberOf _
16417     * @since 4.7.0
16418     * @category Math
16419     * @param {number} multiplier The first number in a multiplication.
16420     * @param {number} multiplicand The second number in a multiplication.
16421     * @returns {number} Returns the product.
16422     * @example
16423     *
16424     * _.multiply(6, 4);
16425     * // => 24
16426     */
16427    var multiply = createMathOperation(function(multiplier, multiplicand) {
16428      return multiplier * multiplicand;
16429    }, 1);
16430
16431    /**
16432     * Computes `number` rounded to `precision`.
16433     *
16434     * @static
16435     * @memberOf _
16436     * @since 3.10.0
16437     * @category Math
16438     * @param {number} number The number to round.
16439     * @param {number} [precision=0] The precision to round to.
16440     * @returns {number} Returns the rounded number.
16441     * @example
16442     *
16443     * _.round(4.006);
16444     * // => 4
16445     *
16446     * _.round(4.006, 2);
16447     * // => 4.01
16448     *
16449     * _.round(4060, -2);
16450     * // => 4100
16451     */
16452    var round = createRound('round');
16453
16454    /**
16455     * Subtract two numbers.
16456     *
16457     * @static
16458     * @memberOf _
16459     * @since 4.0.0
16460     * @category Math
16461     * @param {number} minuend The first number in a subtraction.
16462     * @param {number} subtrahend The second number in a subtraction.
16463     * @returns {number} Returns the difference.
16464     * @example
16465     *
16466     * _.subtract(6, 4);
16467     * // => 2
16468     */
16469    var subtract = createMathOperation(function(minuend, subtrahend) {
16470      return minuend - subtrahend;
16471    }, 0);
16472
16473    /**
16474     * Computes the sum of the values in `array`.
16475     *
16476     * @static
16477     * @memberOf _
16478     * @since 3.4.0
16479     * @category Math
16480     * @param {Array} array The array to iterate over.
16481     * @returns {number} Returns the sum.
16482     * @example
16483     *
16484     * _.sum([4, 2, 8, 6]);
16485     * // => 20
16486     */
16487    function sum(array) {
16488      return (array && array.length)
16489        ? baseSum(array, identity)
16490        : 0;
16491    }
16492
16493    /**
16494     * This method is like `_.sum` except that it accepts `iteratee` which is
16495     * invoked for each element in `array` to generate the value to be summed.
16496     * The iteratee is invoked with one argument: (value).
16497     *
16498     * @static
16499     * @memberOf _
16500     * @since 4.0.0
16501     * @category Math
16502     * @param {Array} array The array to iterate over.
16503     * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16504     * @returns {number} Returns the sum.
16505     * @example
16506     *
16507     * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16508     *
16509     * _.sumBy(objects, function(o) { return o.n; });
16510     * // => 20
16511     *
16512     * // The `_.property` iteratee shorthand.
16513     * _.sumBy(objects, 'n');
16514     * // => 20
16515     */
16516    function sumBy(array, iteratee) {
16517      return (array && array.length)
16518        ? baseSum(array, getIteratee(iteratee, 2))
16519        : 0;
16520    }
16521
16522    /*------------------------------------------------------------------------*/
16523
16524    // Add methods that return wrapped values in chain sequences.
16525    lodash.after = after;
16526    lodash.ary = ary;
16527    lodash.assign = assign;
16528    lodash.assignIn = assignIn;
16529    lodash.assignInWith = assignInWith;
16530    lodash.assignWith = assignWith;
16531    lodash.at = at;
16532    lodash.before = before;
16533    lodash.bind = bind;
16534    lodash.bindAll = bindAll;
16535    lodash.bindKey = bindKey;
16536    lodash.castArray = castArray;
16537    lodash.chain = chain;
16538    lodash.chunk = chunk;
16539    lodash.compact = compact;
16540    lodash.concat = concat;
16541    lodash.cond = cond;
16542    lodash.conforms = conforms;
16543    lodash.constant = constant;
16544    lodash.countBy = countBy;
16545    lodash.create = create;
16546    lodash.curry = curry;
16547    lodash.curryRight = curryRight;
16548    lodash.debounce = debounce;
16549    lodash.defaults = defaults;
16550    lodash.defaultsDeep = defaultsDeep;
16551    lodash.defer = defer;
16552    lodash.delay = delay;
16553    lodash.difference = difference;
16554    lodash.differenceBy = differenceBy;
16555    lodash.differenceWith = differenceWith;
16556    lodash.drop = drop;
16557    lodash.dropRight = dropRight;
16558    lodash.dropRightWhile = dropRightWhile;
16559    lodash.dropWhile = dropWhile;
16560    lodash.fill = fill;
16561    lodash.filter = filter;
16562    lodash.flatMap = flatMap;
16563    lodash.flatMapDeep = flatMapDeep;
16564    lodash.flatMapDepth = flatMapDepth;
16565    lodash.flatten = flatten;
16566    lodash.flattenDeep = flattenDeep;
16567    lodash.flattenDepth = flattenDepth;
16568    lodash.flip = flip;
16569    lodash.flow = flow;
16570    lodash.flowRight = flowRight;
16571    lodash.fromPairs = fromPairs;
16572    lodash.functions = functions;
16573    lodash.functionsIn = functionsIn;
16574    lodash.groupBy = groupBy;
16575    lodash.initial = initial;
16576    lodash.intersection = intersection;
16577    lodash.intersectionBy = intersectionBy;
16578    lodash.intersectionWith = intersectionWith;
16579    lodash.invert = invert;
16580    lodash.invertBy = invertBy;
16581    lodash.invokeMap = invokeMap;
16582    lodash.iteratee = iteratee;
16583    lodash.keyBy = keyBy;
16584    lodash.keys = keys;
16585    lodash.keysIn = keysIn;
16586    lodash.map = map;
16587    lodash.mapKeys = mapKeys;
16588    lodash.mapValues = mapValues;
16589    lodash.matches = matches;
16590    lodash.matchesProperty = matchesProperty;
16591    lodash.memoize = memoize;
16592    lodash.merge = merge;
16593    lodash.mergeWith = mergeWith;
16594    lodash.method = method;
16595    lodash.methodOf = methodOf;
16596    lodash.mixin = mixin;
16597    lodash.negate = negate;
16598    lodash.nthArg = nthArg;
16599    lodash.omit = omit;
16600    lodash.omitBy = omitBy;
16601    lodash.once = once;
16602    lodash.orderBy = orderBy;
16603    lodash.over = over;
16604    lodash.overArgs = overArgs;
16605    lodash.overEvery = overEvery;
16606    lodash.overSome = overSome;
16607    lodash.partial = partial;
16608    lodash.partialRight = partialRight;
16609    lodash.partition = partition;
16610    lodash.pick = pick;
16611    lodash.pickBy = pickBy;
16612    lodash.property = property;
16613    lodash.propertyOf = propertyOf;
16614    lodash.pull = pull;
16615    lodash.pullAll = pullAll;
16616    lodash.pullAllBy = pullAllBy;
16617    lodash.pullAllWith = pullAllWith;
16618    lodash.pullAt = pullAt;
16619    lodash.range = range;
16620    lodash.rangeRight = rangeRight;
16621    lodash.rearg = rearg;
16622    lodash.reject = reject;
16623    lodash.remove = remove;
16624    lodash.rest = rest;
16625    lodash.reverse = reverse;
16626    lodash.sampleSize = sampleSize;
16627    lodash.set = set;
16628    lodash.setWith = setWith;
16629    lodash.shuffle = shuffle;
16630    lodash.slice = slice;
16631    lodash.sortBy = sortBy;
16632    lodash.sortedUniq = sortedUniq;
16633    lodash.sortedUniqBy = sortedUniqBy;
16634    lodash.split = split;
16635    lodash.spread = spread;
16636    lodash.tail = tail;
16637    lodash.take = take;
16638    lodash.takeRight = takeRight;
16639    lodash.takeRightWhile = takeRightWhile;
16640    lodash.takeWhile = takeWhile;
16641    lodash.tap = tap;
16642    lodash.throttle = throttle;
16643    lodash.thru = thru;
16644    lodash.toArray = toArray;
16645    lodash.toPairs = toPairs;
16646    lodash.toPairsIn = toPairsIn;
16647    lodash.toPath = toPath;
16648    lodash.toPlainObject = toPlainObject;
16649    lodash.transform = transform;
16650    lodash.unary = unary;
16651    lodash.union = union;
16652    lodash.unionBy = unionBy;
16653    lodash.unionWith = unionWith;
16654    lodash.uniq = uniq;
16655    lodash.uniqBy = uniqBy;
16656    lodash.uniqWith = uniqWith;
16657    lodash.unset = unset;
16658    lodash.unzip = unzip;
16659    lodash.unzipWith = unzipWith;
16660    lodash.update = update;
16661    lodash.updateWith = updateWith;
16662    lodash.values = values;
16663    lodash.valuesIn = valuesIn;
16664    lodash.without = without;
16665    lodash.words = words;
16666    lodash.wrap = wrap;
16667    lodash.xor = xor;
16668    lodash.xorBy = xorBy;
16669    lodash.xorWith = xorWith;
16670    lodash.zip = zip;
16671    lodash.zipObject = zipObject;
16672    lodash.zipObjectDeep = zipObjectDeep;
16673    lodash.zipWith = zipWith;
16674
16675    // Add aliases.
16676    lodash.entries = toPairs;
16677    lodash.entriesIn = toPairsIn;
16678    lodash.extend = assignIn;
16679    lodash.extendWith = assignInWith;
16680
16681    // Add methods to `lodash.prototype`.
16682    mixin(lodash, lodash);
16683
16684    /*------------------------------------------------------------------------*/
16685
16686    // Add methods that return unwrapped values in chain sequences.
16687    lodash.add = add;
16688    lodash.attempt = attempt;
16689    lodash.camelCase = camelCase;
16690    lodash.capitalize = capitalize;
16691    lodash.ceil = ceil;
16692    lodash.clamp = clamp;
16693    lodash.clone = clone;
16694    lodash.cloneDeep = cloneDeep;
16695    lodash.cloneDeepWith = cloneDeepWith;
16696    lodash.cloneWith = cloneWith;
16697    lodash.conformsTo = conformsTo;
16698    lodash.deburr = deburr;
16699    lodash.defaultTo = defaultTo;
16700    lodash.divide = divide;
16701    lodash.endsWith = endsWith;
16702    lodash.eq = eq;
16703    lodash.escape = escape;
16704    lodash.escapeRegExp = escapeRegExp;
16705    lodash.every = every;
16706    lodash.find = find;
16707    lodash.findIndex = findIndex;
16708    lodash.findKey = findKey;
16709    lodash.findLast = findLast;
16710    lodash.findLastIndex = findLastIndex;
16711    lodash.findLastKey = findLastKey;
16712    lodash.floor = floor;
16713    lodash.forEach = forEach;
16714    lodash.forEachRight = forEachRight;
16715    lodash.forIn = forIn;
16716    lodash.forInRight = forInRight;
16717    lodash.forOwn = forOwn;
16718    lodash.forOwnRight = forOwnRight;
16719    lodash.get = get;
16720    lodash.gt = gt;
16721    lodash.gte = gte;
16722    lodash.has = has;
16723    lodash.hasIn = hasIn;
16724    lodash.head = head;
16725    lodash.identity = identity;
16726    lodash.includes = includes;
16727    lodash.indexOf = indexOf;
16728    lodash.inRange = inRange;
16729    lodash.invoke = invoke;
16730    lodash.isArguments = isArguments;
16731    lodash.isArray = isArray;
16732    lodash.isArrayBuffer = isArrayBuffer;
16733    lodash.isArrayLike = isArrayLike;
16734    lodash.isArrayLikeObject = isArrayLikeObject;
16735    lodash.isBoolean = isBoolean;
16736    lodash.isBuffer = isBuffer;
16737    lodash.isDate = isDate;
16738    lodash.isElement = isElement;
16739    lodash.isEmpty = isEmpty;
16740    lodash.isEqual = isEqual;
16741    lodash.isEqualWith = isEqualWith;
16742    lodash.isError = isError;
16743    lodash.isFinite = isFinite;
16744    lodash.isFunction = isFunction;
16745    lodash.isInteger = isInteger;
16746    lodash.isLength = isLength;
16747    lodash.isMap = isMap;
16748    lodash.isMatch = isMatch;
16749    lodash.isMatchWith = isMatchWith;
16750    lodash.isNaN = isNaN;
16751    lodash.isNative = isNative;
16752    lodash.isNil = isNil;
16753    lodash.isNull = isNull;
16754    lodash.isNumber = isNumber;
16755    lodash.isObject = isObject;
16756    lodash.isObjectLike = isObjectLike;
16757    lodash.isPlainObject = isPlainObject;
16758    lodash.isRegExp = isRegExp;
16759    lodash.isSafeInteger = isSafeInteger;
16760    lodash.isSet = isSet;
16761    lodash.isString = isString;
16762    lodash.isSymbol = isSymbol;
16763    lodash.isTypedArray = isTypedArray;
16764    lodash.isUndefined = isUndefined;
16765    lodash.isWeakMap = isWeakMap;
16766    lodash.isWeakSet = isWeakSet;
16767    lodash.join = join;
16768    lodash.kebabCase = kebabCase;
16769    lodash.last = last;
16770    lodash.lastIndexOf = lastIndexOf;
16771    lodash.lowerCase = lowerCase;
16772    lodash.lowerFirst = lowerFirst;
16773    lodash.lt = lt;
16774    lodash.lte = lte;
16775    lodash.max = max;
16776    lodash.maxBy = maxBy;
16777    lodash.mean = mean;
16778    lodash.meanBy = meanBy;
16779    lodash.min = min;
16780    lodash.minBy = minBy;
16781    lodash.stubArray = stubArray;
16782    lodash.stubFalse = stubFalse;
16783    lodash.stubObject = stubObject;
16784    lodash.stubString = stubString;
16785    lodash.stubTrue = stubTrue;
16786    lodash.multiply = multiply;
16787    lodash.nth = nth;
16788    lodash.noConflict = noConflict;
16789    lodash.noop = noop;
16790    lodash.now = now;
16791    lodash.pad = pad;
16792    lodash.padEnd = padEnd;
16793    lodash.padStart = padStart;
16794    lodash.parseInt = parseInt;
16795    lodash.random = random;
16796    lodash.reduce = reduce;
16797    lodash.reduceRight = reduceRight;
16798    lodash.repeat = repeat;
16799    lodash.replace = replace;
16800    lodash.result = result;
16801    lodash.round = round;
16802    lodash.runInContext = runInContext;
16803    lodash.sample = sample;
16804    lodash.size = size;
16805    lodash.snakeCase = snakeCase;
16806    lodash.some = some;
16807    lodash.sortedIndex = sortedIndex;
16808    lodash.sortedIndexBy = sortedIndexBy;
16809    lodash.sortedIndexOf = sortedIndexOf;
16810    lodash.sortedLastIndex = sortedLastIndex;
16811    lodash.sortedLastIndexBy = sortedLastIndexBy;
16812    lodash.sortedLastIndexOf = sortedLastIndexOf;
16813    lodash.startCase = startCase;
16814    lodash.startsWith = startsWith;
16815    lodash.subtract = subtract;
16816    lodash.sum = sum;
16817    lodash.sumBy = sumBy;
16818    lodash.template = template;
16819    lodash.times = times;
16820    lodash.toFinite = toFinite;
16821    lodash.toInteger = toInteger;
16822    lodash.toLength = toLength;
16823    lodash.toLower = toLower;
16824    lodash.toNumber = toNumber;
16825    lodash.toSafeInteger = toSafeInteger;
16826    lodash.toString = toString;
16827    lodash.toUpper = toUpper;
16828    lodash.trim = trim;
16829    lodash.trimEnd = trimEnd;
16830    lodash.trimStart = trimStart;
16831    lodash.truncate = truncate;
16832    lodash.unescape = unescape;
16833    lodash.uniqueId = uniqueId;
16834    lodash.upperCase = upperCase;
16835    lodash.upperFirst = upperFirst;
16836
16837    // Add aliases.
16838    lodash.each = forEach;
16839    lodash.eachRight = forEachRight;
16840    lodash.first = head;
16841
16842    mixin(lodash, (function() {
16843      var source = {};
16844      baseForOwn(lodash, function(func, methodName) {
16845        if (!hasOwnProperty.call(lodash.prototype, methodName)) {
16846          source[methodName] = func;
16847        }
16848      });
16849      return source;
16850    }()), { 'chain': false });
16851
16852    /*------------------------------------------------------------------------*/
16853
16854    /**
16855     * The semantic version number.
16856     *
16857     * @static
16858     * @memberOf _
16859     * @type {string}
16860     */
16861    lodash.VERSION = VERSION;
16862
16863    // Assign default placeholders.
16864    arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
16865      lodash[methodName].placeholder = lodash;
16866    });
16867
16868    // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
16869    arrayEach(['drop', 'take'], function(methodName, index) {
16870      LazyWrapper.prototype[methodName] = function(n) {
16871        n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
16872
16873        var result = (this.__filtered__ && !index)
16874          ? new LazyWrapper(this)
16875          : this.clone();
16876
16877        if (result.__filtered__) {
16878          result.__takeCount__ = nativeMin(n, result.__takeCount__);
16879        } else {
16880          result.__views__.push({
16881            'size': nativeMin(n, MAX_ARRAY_LENGTH),
16882            'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
16883          });
16884        }
16885        return result;
16886      };
16887
16888      LazyWrapper.prototype[methodName + 'Right'] = function(n) {
16889        return this.reverse()[methodName](n).reverse();
16890      };
16891    });
16892
16893    // Add `LazyWrapper` methods that accept an `iteratee` value.
16894    arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
16895      var type = index + 1,
16896          isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
16897
16898      LazyWrapper.prototype[methodName] = function(iteratee) {
16899        var result = this.clone();
16900        result.__iteratees__.push({
16901          'iteratee': getIteratee(iteratee, 3),
16902          'type': type
16903        });
16904        result.__filtered__ = result.__filtered__ || isFilter;
16905        return result;
16906      };
16907    });
16908
16909    // Add `LazyWrapper` methods for `_.head` and `_.last`.
16910    arrayEach(['head', 'last'], function(methodName, index) {
16911      var takeName = 'take' + (index ? 'Right' : '');
16912
16913      LazyWrapper.prototype[methodName] = function() {
16914        return this[takeName](1).value()[0];
16915      };
16916    });
16917
16918    // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
16919    arrayEach(['initial', 'tail'], function(methodName, index) {
16920      var dropName = 'drop' + (index ? '' : 'Right');
16921
16922      LazyWrapper.prototype[methodName] = function() {
16923        return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
16924      };
16925    });
16926
16927    LazyWrapper.prototype.compact = function() {
16928      return this.filter(identity);
16929    };
16930
16931    LazyWrapper.prototype.find = function(predicate) {
16932      return this.filter(predicate).head();
16933    };
16934
16935    LazyWrapper.prototype.findLast = function(predicate) {
16936      return this.reverse().find(predicate);
16937    };
16938
16939    LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
16940      if (typeof path == 'function') {
16941        return new LazyWrapper(this);
16942      }
16943      return this.map(function(value) {
16944        return baseInvoke(value, path, args);
16945      });
16946    });
16947
16948    LazyWrapper.prototype.reject = function(predicate) {
16949      return this.filter(negate(getIteratee(predicate)));
16950    };
16951
16952    LazyWrapper.prototype.slice = function(start, end) {
16953      start = toInteger(start);
16954
16955      var result = this;
16956      if (result.__filtered__ && (start > 0 || end < 0)) {
16957        return new LazyWrapper(result);
16958      }
16959      if (start < 0) {
16960        result = result.takeRight(-start);
16961      } else if (start) {
16962        result = result.drop(start);
16963      }
16964      if (end !== undefined) {
16965        end = toInteger(end);
16966        result = end < 0 ? result.dropRight(-end) : result.take(end - start);
16967      }
16968      return result;
16969    };
16970
16971    LazyWrapper.prototype.takeRightWhile = function(predicate) {
16972      return this.reverse().takeWhile(predicate).reverse();
16973    };
16974
16975    LazyWrapper.prototype.toArray = function() {
16976      return this.take(MAX_ARRAY_LENGTH);
16977    };
16978
16979    // Add `LazyWrapper` methods to `lodash.prototype`.
16980    baseForOwn(LazyWrapper.prototype, function(func, methodName) {
16981      var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
16982          isTaker = /^(?:head|last)$/.test(methodName),
16983          lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
16984          retUnwrapped = isTaker || /^find/.test(methodName);
16985
16986      if (!lodashFunc) {
16987        return;
16988      }
16989      lodash.prototype[methodName] = function() {
16990        var value = this.__wrapped__,
16991            args = isTaker ? [1] : arguments,
16992            isLazy = value instanceof LazyWrapper,
16993            iteratee = args[0],
16994            useLazy = isLazy || isArray(value);
16995
16996        var interceptor = function(value) {
16997          var result = lodashFunc.apply(lodash, arrayPush([value], args));
16998          return (isTaker && chainAll) ? result[0] : result;
16999        };
17000
17001        if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
17002          // Avoid lazy use if the iteratee has a "length" value other than `1`.
17003          isLazy = useLazy = false;
17004        }
17005        var chainAll = this.__chain__,
17006            isHybrid = !!this.__actions__.length,
17007            isUnwrapped = retUnwrapped && !chainAll,
17008            onlyLazy = isLazy && !isHybrid;
17009
17010        if (!retUnwrapped && useLazy) {
17011          value = onlyLazy ? value : new LazyWrapper(this);
17012          var result = func.apply(value, args);
17013          result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
17014          return new LodashWrapper(result, chainAll);
17015        }
17016        if (isUnwrapped && onlyLazy) {
17017          return func.apply(this, args);
17018        }
17019        result = this.thru(interceptor);
17020        return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
17021      };
17022    });
17023
17024    // Add `Array` methods to `lodash.prototype`.
17025    arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
17026      var func = arrayProto[methodName],
17027          chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
17028          retUnwrapped = /^(?:pop|shift)$/.test(methodName);
17029
17030      lodash.prototype[methodName] = function() {
17031        var args = arguments;
17032        if (retUnwrapped && !this.__chain__) {
17033          var value = this.value();
17034          return func.apply(isArray(value) ? value : [], args);
17035        }
17036        return this[chainName](function(value) {
17037          return func.apply(isArray(value) ? value : [], args);
17038        });
17039      };
17040    });
17041
17042    // Map minified method names to their real names.
17043    baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17044      var lodashFunc = lodash[methodName];
17045      if (lodashFunc) {
17046        var key = lodashFunc.name + '';
17047        if (!hasOwnProperty.call(realNames, key)) {
17048          realNames[key] = [];
17049        }
17050        realNames[key].push({ 'name': methodName, 'func': lodashFunc });
17051      }
17052    });
17053
17054    realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
17055      'name': 'wrapper',
17056      'func': undefined
17057    }];
17058
17059    // Add methods to `LazyWrapper`.
17060    LazyWrapper.prototype.clone = lazyClone;
17061    LazyWrapper.prototype.reverse = lazyReverse;
17062    LazyWrapper.prototype.value = lazyValue;
17063
17064    // Add chain sequence methods to the `lodash` wrapper.
17065    lodash.prototype.at = wrapperAt;
17066    lodash.prototype.chain = wrapperChain;
17067    lodash.prototype.commit = wrapperCommit;
17068    lodash.prototype.next = wrapperNext;
17069    lodash.prototype.plant = wrapperPlant;
17070    lodash.prototype.reverse = wrapperReverse;
17071    lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
17072
17073    // Add lazy aliases.
17074    lodash.prototype.first = lodash.prototype.head;
17075
17076    if (symIterator) {
17077      lodash.prototype[symIterator] = wrapperToIterator;
17078    }
17079    return lodash;
17080  });
17081
17082  /*--------------------------------------------------------------------------*/
17083
17084  // Export lodash.
17085  var _ = runInContext();
17086
17087  // Some AMD build optimizers, like r.js, check for condition patterns like:
17088  if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
17089    // Expose Lodash on the global object to prevent errors when Lodash is
17090    // loaded by a script tag in the presence of an AMD loader.
17091    // See http://requirejs.org/docs/errors.html#mismatch for more details.
17092    // Use `_.noConflict` to remove Lodash from the global object.
17093    root._ = _;
17094
17095    // Define as an anonymous module so, through path mapping, it can be
17096    // referenced as the "underscore" module.
17097    define(function() {
17098      return _;
17099    });
17100  }
17101  // Check for `exports` after `define` in case a build optimizer adds it.
17102  else if (freeModule) {
17103    // Export for Node.js.
17104    (freeModule.exports = _)._ = _;
17105    // Export for CommonJS support.
17106    freeExports._ = _;
17107  }
17108  else {
17109    // Export to the global object.
17110    root._ = _;
17111  }
17112}.call(this));
17113