OSDN Git Service

f087441c7072378b1e6e8c27b2f8c7443def8e28
[bytom/Byone.git] / js / 5.js
1 // [AIV_SHORT]  Build version: 2.2.0 - Thursday, June 4th, 2020, 2:31:20 PM  
2  webpackJsonp([5],{
3
4 /***/ 434:
5 /***/ (function(module, exports, __webpack_require__) {
6
7 /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
8  * @license
9  * Lodash <https://lodash.com/>
10  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
11  * Released under MIT license <https://lodash.com/license>
12  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
13  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
14  */
15 ;(function() {
16
17   /** Used as a safe reference for `undefined` in pre-ES5 environments. */
18   var undefined;
19
20   /** Used as the semantic version number. */
21   var VERSION = '4.17.15';
22
23   /** Used as the size to enable large array optimizations. */
24   var LARGE_ARRAY_SIZE = 200;
25
26   /** Error message constants. */
27   var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
28       FUNC_ERROR_TEXT = 'Expected a function';
29
30   /** Used to stand-in for `undefined` hash values. */
31   var HASH_UNDEFINED = '__lodash_hash_undefined__';
32
33   /** Used as the maximum memoize cache size. */
34   var MAX_MEMOIZE_SIZE = 500;
35
36   /** Used as the internal argument placeholder. */
37   var PLACEHOLDER = '__lodash_placeholder__';
38
39   /** Used to compose bitmasks for cloning. */
40   var CLONE_DEEP_FLAG = 1,
41       CLONE_FLAT_FLAG = 2,
42       CLONE_SYMBOLS_FLAG = 4;
43
44   /** Used to compose bitmasks for value comparisons. */
45   var COMPARE_PARTIAL_FLAG = 1,
46       COMPARE_UNORDERED_FLAG = 2;
47
48   /** Used to compose bitmasks for function metadata. */
49   var WRAP_BIND_FLAG = 1,
50       WRAP_BIND_KEY_FLAG = 2,
51       WRAP_CURRY_BOUND_FLAG = 4,
52       WRAP_CURRY_FLAG = 8,
53       WRAP_CURRY_RIGHT_FLAG = 16,
54       WRAP_PARTIAL_FLAG = 32,
55       WRAP_PARTIAL_RIGHT_FLAG = 64,
56       WRAP_ARY_FLAG = 128,
57       WRAP_REARG_FLAG = 256,
58       WRAP_FLIP_FLAG = 512;
59
60   /** Used as default options for `_.truncate`. */
61   var DEFAULT_TRUNC_LENGTH = 30,
62       DEFAULT_TRUNC_OMISSION = '...';
63
64   /** Used to detect hot functions by number of calls within a span of milliseconds. */
65   var HOT_COUNT = 800,
66       HOT_SPAN = 16;
67
68   /** Used to indicate the type of lazy iteratees. */
69   var LAZY_FILTER_FLAG = 1,
70       LAZY_MAP_FLAG = 2,
71       LAZY_WHILE_FLAG = 3;
72
73   /** Used as references for various `Number` constants. */
74   var INFINITY = 1 / 0,
75       MAX_SAFE_INTEGER = 9007199254740991,
76       MAX_INTEGER = 1.7976931348623157e+308,
77       NAN = 0 / 0;
78
79   /** Used as references for the maximum length and index of an array. */
80   var MAX_ARRAY_LENGTH = 4294967295,
81       MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
82       HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
83
84   /** Used to associate wrap methods with their bit flags. */
85   var wrapFlags = [
86     ['ary', WRAP_ARY_FLAG],
87     ['bind', WRAP_BIND_FLAG],
88     ['bindKey', WRAP_BIND_KEY_FLAG],
89     ['curry', WRAP_CURRY_FLAG],
90     ['curryRight', WRAP_CURRY_RIGHT_FLAG],
91     ['flip', WRAP_FLIP_FLAG],
92     ['partial', WRAP_PARTIAL_FLAG],
93     ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
94     ['rearg', WRAP_REARG_FLAG]
95   ];
96
97   /** `Object#toString` result references. */
98   var argsTag = '[object Arguments]',
99       arrayTag = '[object Array]',
100       asyncTag = '[object AsyncFunction]',
101       boolTag = '[object Boolean]',
102       dateTag = '[object Date]',
103       domExcTag = '[object DOMException]',
104       errorTag = '[object Error]',
105       funcTag = '[object Function]',
106       genTag = '[object GeneratorFunction]',
107       mapTag = '[object Map]',
108       numberTag = '[object Number]',
109       nullTag = '[object Null]',
110       objectTag = '[object Object]',
111       promiseTag = '[object Promise]',
112       proxyTag = '[object Proxy]',
113       regexpTag = '[object RegExp]',
114       setTag = '[object Set]',
115       stringTag = '[object String]',
116       symbolTag = '[object Symbol]',
117       undefinedTag = '[object Undefined]',
118       weakMapTag = '[object WeakMap]',
119       weakSetTag = '[object WeakSet]';
120
121   var arrayBufferTag = '[object ArrayBuffer]',
122       dataViewTag = '[object DataView]',
123       float32Tag = '[object Float32Array]',
124       float64Tag = '[object Float64Array]',
125       int8Tag = '[object Int8Array]',
126       int16Tag = '[object Int16Array]',
127       int32Tag = '[object Int32Array]',
128       uint8Tag = '[object Uint8Array]',
129       uint8ClampedTag = '[object Uint8ClampedArray]',
130       uint16Tag = '[object Uint16Array]',
131       uint32Tag = '[object Uint32Array]';
132
133   /** Used to match empty string literals in compiled template source. */
134   var reEmptyStringLeading = /\b__p \+= '';/g,
135       reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
136       reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
137
138   /** Used to match HTML entities and HTML characters. */
139   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
140       reUnescapedHtml = /[&<>"']/g,
141       reHasEscapedHtml = RegExp(reEscapedHtml.source),
142       reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
143
144   /** Used to match template delimiters. */
145   var reEscape = /<%-([\s\S]+?)%>/g,
146       reEvaluate = /<%([\s\S]+?)%>/g,
147       reInterpolate = /<%=([\s\S]+?)%>/g;
148
149   /** Used to match property names within property paths. */
150   var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
151       reIsPlainProp = /^\w*$/,
152       rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
153
154   /**
155    * Used to match `RegExp`
156    * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
157    */
158   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
159       reHasRegExpChar = RegExp(reRegExpChar.source);
160
161   /** Used to match leading and trailing whitespace. */
162   var reTrim = /^\s+|\s+$/g,
163       reTrimStart = /^\s+/,
164       reTrimEnd = /\s+$/;
165
166   /** Used to match wrap detail comments. */
167   var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
168       reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
169       reSplitDetails = /,? & /;
170
171   /** Used to match words composed of alphanumeric characters. */
172   var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
173
174   /** Used to match backslashes in property paths. */
175   var reEscapeChar = /\\(\\)?/g;
176
177   /**
178    * Used to match
179    * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
180    */
181   var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
182
183   /** Used to match `RegExp` flags from their coerced string values. */
184   var reFlags = /\w*$/;
185
186   /** Used to detect bad signed hexadecimal string values. */
187   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
188
189   /** Used to detect binary string values. */
190   var reIsBinary = /^0b[01]+$/i;
191
192   /** Used to detect host constructors (Safari). */
193   var reIsHostCtor = /^\[object .+?Constructor\]$/;
194
195   /** Used to detect octal string values. */
196   var reIsOctal = /^0o[0-7]+$/i;
197
198   /** Used to detect unsigned integer values. */
199   var reIsUint = /^(?:0|[1-9]\d*)$/;
200
201   /** Used to match Latin Unicode letters (excluding mathematical operators). */
202   var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
203
204   /** Used to ensure capturing order of template delimiters. */
205   var reNoMatch = /($^)/;
206
207   /** Used to match unescaped characters in compiled string literals. */
208   var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
209
210   /** Used to compose unicode character classes. */
211   var rsAstralRange = '\\ud800-\\udfff',
212       rsComboMarksRange = '\\u0300-\\u036f',
213       reComboHalfMarksRange = '\\ufe20-\\ufe2f',
214       rsComboSymbolsRange = '\\u20d0-\\u20ff',
215       rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
216       rsDingbatRange = '\\u2700-\\u27bf',
217       rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
218       rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
219       rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
220       rsPunctuationRange = '\\u2000-\\u206f',
221       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',
222       rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
223       rsVarRange = '\\ufe0e\\ufe0f',
224       rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
225
226   /** Used to compose unicode capture groups. */
227   var rsApos = "['\u2019]",
228       rsAstral = '[' + rsAstralRange + ']',
229       rsBreak = '[' + rsBreakRange + ']',
230       rsCombo = '[' + rsComboRange + ']',
231       rsDigits = '\\d+',
232       rsDingbat = '[' + rsDingbatRange + ']',
233       rsLower = '[' + rsLowerRange + ']',
234       rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
235       rsFitz = '\\ud83c[\\udffb-\\udfff]',
236       rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
237       rsNonAstral = '[^' + rsAstralRange + ']',
238       rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
239       rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
240       rsUpper = '[' + rsUpperRange + ']',
241       rsZWJ = '\\u200d';
242
243   /** Used to compose unicode regexes. */
244   var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
245       rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
246       rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
247       rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
248       reOptMod = rsModifier + '?',
249       rsOptVar = '[' + rsVarRange + ']?',
250       rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
251       rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
252       rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
253       rsSeq = rsOptVar + reOptMod + rsOptJoin,
254       rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
255       rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
256
257   /** Used to match apostrophes. */
258   var reApos = RegExp(rsApos, 'g');
259
260   /**
261    * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
262    * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
263    */
264   var reComboMark = RegExp(rsCombo, 'g');
265
266   /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
267   var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
268
269   /** Used to match complex or compound words. */
270   var reUnicodeWord = RegExp([
271     rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
272     rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
273     rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
274     rsUpper + '+' + rsOptContrUpper,
275     rsOrdUpper,
276     rsOrdLower,
277     rsDigits,
278     rsEmoji
279   ].join('|'), 'g');
280
281   /** 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/). */
282   var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange  + rsComboRange + rsVarRange + ']');
283
284   /** Used to detect strings that need a more robust regexp to match words. */
285   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 ]/;
286
287   /** Used to assign default `context` object properties. */
288   var contextProps = [
289     'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
290     'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
291     'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
292     'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
293     '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
294   ];
295
296   /** Used to make template sourceURLs easier to identify. */
297   var templateCounter = -1;
298
299   /** Used to identify `toStringTag` values of typed arrays. */
300   var typedArrayTags = {};
301   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
302   typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
303   typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
304   typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
305   typedArrayTags[uint32Tag] = true;
306   typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
307   typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
308   typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
309   typedArrayTags[errorTag] = typedArrayTags[funcTag] =
310   typedArrayTags[mapTag] = typedArrayTags[numberTag] =
311   typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
312   typedArrayTags[setTag] = typedArrayTags[stringTag] =
313   typedArrayTags[weakMapTag] = false;
314
315   /** Used to identify `toStringTag` values supported by `_.clone`. */
316   var cloneableTags = {};
317   cloneableTags[argsTag] = cloneableTags[arrayTag] =
318   cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
319   cloneableTags[boolTag] = cloneableTags[dateTag] =
320   cloneableTags[float32Tag] = cloneableTags[float64Tag] =
321   cloneableTags[int8Tag] = cloneableTags[int16Tag] =
322   cloneableTags[int32Tag] = cloneableTags[mapTag] =
323   cloneableTags[numberTag] = cloneableTags[objectTag] =
324   cloneableTags[regexpTag] = cloneableTags[setTag] =
325   cloneableTags[stringTag] = cloneableTags[symbolTag] =
326   cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
327   cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
328   cloneableTags[errorTag] = cloneableTags[funcTag] =
329   cloneableTags[weakMapTag] = false;
330
331   /** Used to map Latin Unicode letters to basic Latin letters. */
332   var deburredLetters = {
333     // Latin-1 Supplement block.
334     '\xc0': 'A',  '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
335     '\xe0': 'a',  '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
336     '\xc7': 'C',  '\xe7': 'c',
337     '\xd0': 'D',  '\xf0': 'd',
338     '\xc8': 'E',  '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
339     '\xe8': 'e',  '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
340     '\xcc': 'I',  '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
341     '\xec': 'i',  '\xed': 'i', '\xee': 'i', '\xef': 'i',
342     '\xd1': 'N',  '\xf1': 'n',
343     '\xd2': 'O',  '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
344     '\xf2': 'o',  '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
345     '\xd9': 'U',  '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
346     '\xf9': 'u',  '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
347     '\xdd': 'Y',  '\xfd': 'y', '\xff': 'y',
348     '\xc6': 'Ae', '\xe6': 'ae',
349     '\xde': 'Th', '\xfe': 'th',
350     '\xdf': 'ss',
351     // Latin Extended-A block.
352     '\u0100': 'A',  '\u0102': 'A', '\u0104': 'A',
353     '\u0101': 'a',  '\u0103': 'a', '\u0105': 'a',
354     '\u0106': 'C',  '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
355     '\u0107': 'c',  '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
356     '\u010e': 'D',  '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
357     '\u0112': 'E',  '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
358     '\u0113': 'e',  '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
359     '\u011c': 'G',  '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
360     '\u011d': 'g',  '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
361     '\u0124': 'H',  '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
362     '\u0128': 'I',  '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
363     '\u0129': 'i',  '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
364     '\u0134': 'J',  '\u0135': 'j',
365     '\u0136': 'K',  '\u0137': 'k', '\u0138': 'k',
366     '\u0139': 'L',  '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
367     '\u013a': 'l',  '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
368     '\u0143': 'N',  '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
369     '\u0144': 'n',  '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
370     '\u014c': 'O',  '\u014e': 'O', '\u0150': 'O',
371     '\u014d': 'o',  '\u014f': 'o', '\u0151': 'o',
372     '\u0154': 'R',  '\u0156': 'R', '\u0158': 'R',
373     '\u0155': 'r',  '\u0157': 'r', '\u0159': 'r',
374     '\u015a': 'S',  '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
375     '\u015b': 's',  '\u015d': 's', '\u015f': 's', '\u0161': 's',
376     '\u0162': 'T',  '\u0164': 'T', '\u0166': 'T',
377     '\u0163': 't',  '\u0165': 't', '\u0167': 't',
378     '\u0168': 'U',  '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
379     '\u0169': 'u',  '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
380     '\u0174': 'W',  '\u0175': 'w',
381     '\u0176': 'Y',  '\u0177': 'y', '\u0178': 'Y',
382     '\u0179': 'Z',  '\u017b': 'Z', '\u017d': 'Z',
383     '\u017a': 'z',  '\u017c': 'z', '\u017e': 'z',
384     '\u0132': 'IJ', '\u0133': 'ij',
385     '\u0152': 'Oe', '\u0153': 'oe',
386     '\u0149': "'n", '\u017f': 's'
387   };
388
389   /** Used to map characters to HTML entities. */
390   var htmlEscapes = {
391     '&': '&amp;',
392     '<': '&lt;',
393     '>': '&gt;',
394     '"': '&quot;',
395     "'": '&#39;'
396   };
397
398   /** Used to map HTML entities to characters. */
399   var htmlUnescapes = {
400     '&amp;': '&',
401     '&lt;': '<',
402     '&gt;': '>',
403     '&quot;': '"',
404     '&#39;': "'"
405   };
406
407   /** Used to escape characters for inclusion in compiled string literals. */
408   var stringEscapes = {
409     '\\': '\\',
410     "'": "'",
411     '\n': 'n',
412     '\r': 'r',
413     '\u2028': 'u2028',
414     '\u2029': 'u2029'
415   };
416
417   /** Built-in method references without a dependency on `root`. */
418   var freeParseFloat = parseFloat,
419       freeParseInt = parseInt;
420
421   /** Detect free variable `global` from Node.js. */
422   var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
423
424   /** Detect free variable `self`. */
425   var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
426
427   /** Used as a reference to the global object. */
428   var root = freeGlobal || freeSelf || Function('return this')();
429
430   /** Detect free variable `exports`. */
431   var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
432
433   /** Detect free variable `module`. */
434   var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
435
436   /** Detect the popular CommonJS extension `module.exports`. */
437   var moduleExports = freeModule && freeModule.exports === freeExports;
438
439   /** Detect free variable `process` from Node.js. */
440   var freeProcess = moduleExports && freeGlobal.process;
441
442   /** Used to access faster Node.js helpers. */
443   var nodeUtil = (function() {
444     try {
445       // Use `util.types` for Node.js 10+.
446       var types = freeModule && freeModule.require && freeModule.require('util').types;
447
448       if (types) {
449         return types;
450       }
451
452       // Legacy `process.binding('util')` for Node.js < 10.
453       return freeProcess && freeProcess.binding && freeProcess.binding('util');
454     } catch (e) {}
455   }());
456
457   /* Node.js helper references. */
458   var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
459       nodeIsDate = nodeUtil && nodeUtil.isDate,
460       nodeIsMap = nodeUtil && nodeUtil.isMap,
461       nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
462       nodeIsSet = nodeUtil && nodeUtil.isSet,
463       nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
464
465   /*--------------------------------------------------------------------------*/
466
467   /**
468    * A faster alternative to `Function#apply`, this function invokes `func`
469    * with the `this` binding of `thisArg` and the arguments of `args`.
470    *
471    * @private
472    * @param {Function} func The function to invoke.
473    * @param {*} thisArg The `this` binding of `func`.
474    * @param {Array} args The arguments to invoke `func` with.
475    * @returns {*} Returns the result of `func`.
476    */
477   function apply(func, thisArg, args) {
478     switch (args.length) {
479       case 0: return func.call(thisArg);
480       case 1: return func.call(thisArg, args[0]);
481       case 2: return func.call(thisArg, args[0], args[1]);
482       case 3: return func.call(thisArg, args[0], args[1], args[2]);
483     }
484     return func.apply(thisArg, args);
485   }
486
487   /**
488    * A specialized version of `baseAggregator` for arrays.
489    *
490    * @private
491    * @param {Array} [array] The array to iterate over.
492    * @param {Function} setter The function to set `accumulator` values.
493    * @param {Function} iteratee The iteratee to transform keys.
494    * @param {Object} accumulator The initial aggregated object.
495    * @returns {Function} Returns `accumulator`.
496    */
497   function arrayAggregator(array, setter, iteratee, accumulator) {
498     var index = -1,
499         length = array == null ? 0 : array.length;
500
501     while (++index < length) {
502       var value = array[index];
503       setter(accumulator, value, iteratee(value), array);
504     }
505     return accumulator;
506   }
507
508   /**
509    * A specialized version of `_.forEach` for arrays without support for
510    * iteratee shorthands.
511    *
512    * @private
513    * @param {Array} [array] The array to iterate over.
514    * @param {Function} iteratee The function invoked per iteration.
515    * @returns {Array} Returns `array`.
516    */
517   function arrayEach(array, iteratee) {
518     var index = -1,
519         length = array == null ? 0 : array.length;
520
521     while (++index < length) {
522       if (iteratee(array[index], index, array) === false) {
523         break;
524       }
525     }
526     return array;
527   }
528
529   /**
530    * A specialized version of `_.forEachRight` for arrays without support for
531    * iteratee shorthands.
532    *
533    * @private
534    * @param {Array} [array] The array to iterate over.
535    * @param {Function} iteratee The function invoked per iteration.
536    * @returns {Array} Returns `array`.
537    */
538   function arrayEachRight(array, iteratee) {
539     var length = array == null ? 0 : array.length;
540
541     while (length--) {
542       if (iteratee(array[length], length, array) === false) {
543         break;
544       }
545     }
546     return array;
547   }
548
549   /**
550    * A specialized version of `_.every` for arrays without support for
551    * iteratee shorthands.
552    *
553    * @private
554    * @param {Array} [array] The array to iterate over.
555    * @param {Function} predicate The function invoked per iteration.
556    * @returns {boolean} Returns `true` if all elements pass the predicate check,
557    *  else `false`.
558    */
559   function arrayEvery(array, predicate) {
560     var index = -1,
561         length = array == null ? 0 : array.length;
562
563     while (++index < length) {
564       if (!predicate(array[index], index, array)) {
565         return false;
566       }
567     }
568     return true;
569   }
570
571   /**
572    * A specialized version of `_.filter` for arrays without support for
573    * iteratee shorthands.
574    *
575    * @private
576    * @param {Array} [array] The array to iterate over.
577    * @param {Function} predicate The function invoked per iteration.
578    * @returns {Array} Returns the new filtered array.
579    */
580   function arrayFilter(array, predicate) {
581     var index = -1,
582         length = array == null ? 0 : array.length,
583         resIndex = 0,
584         result = [];
585
586     while (++index < length) {
587       var value = array[index];
588       if (predicate(value, index, array)) {
589         result[resIndex++] = value;
590       }
591     }
592     return result;
593   }
594
595   /**
596    * A specialized version of `_.includes` for arrays without support for
597    * specifying an index to search from.
598    *
599    * @private
600    * @param {Array} [array] The array to inspect.
601    * @param {*} target The value to search for.
602    * @returns {boolean} Returns `true` if `target` is found, else `false`.
603    */
604   function arrayIncludes(array, value) {
605     var length = array == null ? 0 : array.length;
606     return !!length && baseIndexOf(array, value, 0) > -1;
607   }
608
609   /**
610    * This function is like `arrayIncludes` except that it accepts a comparator.
611    *
612    * @private
613    * @param {Array} [array] The array to inspect.
614    * @param {*} target The value to search for.
615    * @param {Function} comparator The comparator invoked per element.
616    * @returns {boolean} Returns `true` if `target` is found, else `false`.
617    */
618   function arrayIncludesWith(array, value, comparator) {
619     var index = -1,
620         length = array == null ? 0 : array.length;
621
622     while (++index < length) {
623       if (comparator(value, array[index])) {
624         return true;
625       }
626     }
627     return false;
628   }
629
630   /**
631    * A specialized version of `_.map` for arrays without support for iteratee
632    * shorthands.
633    *
634    * @private
635    * @param {Array} [array] The array to iterate over.
636    * @param {Function} iteratee The function invoked per iteration.
637    * @returns {Array} Returns the new mapped array.
638    */
639   function arrayMap(array, iteratee) {
640     var index = -1,
641         length = array == null ? 0 : array.length,
642         result = Array(length);
643
644     while (++index < length) {
645       result[index] = iteratee(array[index], index, array);
646     }
647     return result;
648   }
649
650   /**
651    * Appends the elements of `values` to `array`.
652    *
653    * @private
654    * @param {Array} array The array to modify.
655    * @param {Array} values The values to append.
656    * @returns {Array} Returns `array`.
657    */
658   function arrayPush(array, values) {
659     var index = -1,
660         length = values.length,
661         offset = array.length;
662
663     while (++index < length) {
664       array[offset + index] = values[index];
665     }
666     return array;
667   }
668
669   /**
670    * A specialized version of `_.reduce` for arrays without support for
671    * iteratee shorthands.
672    *
673    * @private
674    * @param {Array} [array] The array to iterate over.
675    * @param {Function} iteratee The function invoked per iteration.
676    * @param {*} [accumulator] The initial value.
677    * @param {boolean} [initAccum] Specify using the first element of `array` as
678    *  the initial value.
679    * @returns {*} Returns the accumulated value.
680    */
681   function arrayReduce(array, iteratee, accumulator, initAccum) {
682     var index = -1,
683         length = array == null ? 0 : array.length;
684
685     if (initAccum && length) {
686       accumulator = array[++index];
687     }
688     while (++index < length) {
689       accumulator = iteratee(accumulator, array[index], index, array);
690     }
691     return accumulator;
692   }
693
694   /**
695    * A specialized version of `_.reduceRight` for arrays without support for
696    * iteratee shorthands.
697    *
698    * @private
699    * @param {Array} [array] The array to iterate over.
700    * @param {Function} iteratee The function invoked per iteration.
701    * @param {*} [accumulator] The initial value.
702    * @param {boolean} [initAccum] Specify using the last element of `array` as
703    *  the initial value.
704    * @returns {*} Returns the accumulated value.
705    */
706   function arrayReduceRight(array, iteratee, accumulator, initAccum) {
707     var length = array == null ? 0 : array.length;
708     if (initAccum && length) {
709       accumulator = array[--length];
710     }
711     while (length--) {
712       accumulator = iteratee(accumulator, array[length], length, array);
713     }
714     return accumulator;
715   }
716
717   /**
718    * A specialized version of `_.some` for arrays without support for iteratee
719    * shorthands.
720    *
721    * @private
722    * @param {Array} [array] The array to iterate over.
723    * @param {Function} predicate The function invoked per iteration.
724    * @returns {boolean} Returns `true` if any element passes the predicate check,
725    *  else `false`.
726    */
727   function arraySome(array, predicate) {
728     var index = -1,
729         length = array == null ? 0 : array.length;
730
731     while (++index < length) {
732       if (predicate(array[index], index, array)) {
733         return true;
734       }
735     }
736     return false;
737   }
738
739   /**
740    * Gets the size of an ASCII `string`.
741    *
742    * @private
743    * @param {string} string The string inspect.
744    * @returns {number} Returns the string size.
745    */
746   var asciiSize = baseProperty('length');
747
748   /**
749    * Converts an ASCII `string` to an array.
750    *
751    * @private
752    * @param {string} string The string to convert.
753    * @returns {Array} Returns the converted array.
754    */
755   function asciiToArray(string) {
756     return string.split('');
757   }
758
759   /**
760    * Splits an ASCII `string` into an array of its words.
761    *
762    * @private
763    * @param {string} The string to inspect.
764    * @returns {Array} Returns the words of `string`.
765    */
766   function asciiWords(string) {
767     return string.match(reAsciiWord) || [];
768   }
769
770   /**
771    * The base implementation of methods like `_.findKey` and `_.findLastKey`,
772    * without support for iteratee shorthands, which iterates over `collection`
773    * using `eachFunc`.
774    *
775    * @private
776    * @param {Array|Object} collection The collection to inspect.
777    * @param {Function} predicate The function invoked per iteration.
778    * @param {Function} eachFunc The function to iterate over `collection`.
779    * @returns {*} Returns the found element or its key, else `undefined`.
780    */
781   function baseFindKey(collection, predicate, eachFunc) {
782     var result;
783     eachFunc(collection, function(value, key, collection) {
784       if (predicate(value, key, collection)) {
785         result = key;
786         return false;
787       }
788     });
789     return result;
790   }
791
792   /**
793    * The base implementation of `_.findIndex` and `_.findLastIndex` without
794    * support for iteratee shorthands.
795    *
796    * @private
797    * @param {Array} array The array to inspect.
798    * @param {Function} predicate The function invoked per iteration.
799    * @param {number} fromIndex The index to search from.
800    * @param {boolean} [fromRight] Specify iterating from right to left.
801    * @returns {number} Returns the index of the matched value, else `-1`.
802    */
803   function baseFindIndex(array, predicate, fromIndex, fromRight) {
804     var length = array.length,
805         index = fromIndex + (fromRight ? 1 : -1);
806
807     while ((fromRight ? index-- : ++index < length)) {
808       if (predicate(array[index], index, array)) {
809         return index;
810       }
811     }
812     return -1;
813   }
814
815   /**
816    * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
817    *
818    * @private
819    * @param {Array} array The array to inspect.
820    * @param {*} value The value to search for.
821    * @param {number} fromIndex The index to search from.
822    * @returns {number} Returns the index of the matched value, else `-1`.
823    */
824   function baseIndexOf(array, value, fromIndex) {
825     return value === value
826       ? strictIndexOf(array, value, fromIndex)
827       : baseFindIndex(array, baseIsNaN, fromIndex);
828   }
829
830   /**
831    * This function is like `baseIndexOf` except that it accepts a comparator.
832    *
833    * @private
834    * @param {Array} array The array to inspect.
835    * @param {*} value The value to search for.
836    * @param {number} fromIndex The index to search from.
837    * @param {Function} comparator The comparator invoked per element.
838    * @returns {number} Returns the index of the matched value, else `-1`.
839    */
840   function baseIndexOfWith(array, value, fromIndex, comparator) {
841     var index = fromIndex - 1,
842         length = array.length;
843
844     while (++index < length) {
845       if (comparator(array[index], value)) {
846         return index;
847       }
848     }
849     return -1;
850   }
851
852   /**
853    * The base implementation of `_.isNaN` without support for number objects.
854    *
855    * @private
856    * @param {*} value The value to check.
857    * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
858    */
859   function baseIsNaN(value) {
860     return value !== value;
861   }
862
863   /**
864    * The base implementation of `_.mean` and `_.meanBy` without support for
865    * iteratee shorthands.
866    *
867    * @private
868    * @param {Array} array The array to iterate over.
869    * @param {Function} iteratee The function invoked per iteration.
870    * @returns {number} Returns the mean.
871    */
872   function baseMean(array, iteratee) {
873     var length = array == null ? 0 : array.length;
874     return length ? (baseSum(array, iteratee) / length) : NAN;
875   }
876
877   /**
878    * The base implementation of `_.property` without support for deep paths.
879    *
880    * @private
881    * @param {string} key The key of the property to get.
882    * @returns {Function} Returns the new accessor function.
883    */
884   function baseProperty(key) {
885     return function(object) {
886       return object == null ? undefined : object[key];
887     };
888   }
889
890   /**
891    * The base implementation of `_.propertyOf` without support for deep paths.
892    *
893    * @private
894    * @param {Object} object The object to query.
895    * @returns {Function} Returns the new accessor function.
896    */
897   function basePropertyOf(object) {
898     return function(key) {
899       return object == null ? undefined : object[key];
900     };
901   }
902
903   /**
904    * The base implementation of `_.reduce` and `_.reduceRight`, without support
905    * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
906    *
907    * @private
908    * @param {Array|Object} collection The collection to iterate over.
909    * @param {Function} iteratee The function invoked per iteration.
910    * @param {*} accumulator The initial value.
911    * @param {boolean} initAccum Specify using the first or last element of
912    *  `collection` as the initial value.
913    * @param {Function} eachFunc The function to iterate over `collection`.
914    * @returns {*} Returns the accumulated value.
915    */
916   function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
917     eachFunc(collection, function(value, index, collection) {
918       accumulator = initAccum
919         ? (initAccum = false, value)
920         : iteratee(accumulator, value, index, collection);
921     });
922     return accumulator;
923   }
924
925   /**
926    * The base implementation of `_.sortBy` which uses `comparer` to define the
927    * sort order of `array` and replaces criteria objects with their corresponding
928    * values.
929    *
930    * @private
931    * @param {Array} array The array to sort.
932    * @param {Function} comparer The function to define sort order.
933    * @returns {Array} Returns `array`.
934    */
935   function baseSortBy(array, comparer) {
936     var length = array.length;
937
938     array.sort(comparer);
939     while (length--) {
940       array[length] = array[length].value;
941     }
942     return array;
943   }
944
945   /**
946    * The base implementation of `_.sum` and `_.sumBy` without support for
947    * iteratee shorthands.
948    *
949    * @private
950    * @param {Array} array The array to iterate over.
951    * @param {Function} iteratee The function invoked per iteration.
952    * @returns {number} Returns the sum.
953    */
954   function baseSum(array, iteratee) {
955     var result,
956         index = -1,
957         length = array.length;
958
959     while (++index < length) {
960       var current = iteratee(array[index]);
961       if (current !== undefined) {
962         result = result === undefined ? current : (result + current);
963       }
964     }
965     return result;
966   }
967
968   /**
969    * The base implementation of `_.times` without support for iteratee shorthands
970    * or max array length checks.
971    *
972    * @private
973    * @param {number} n The number of times to invoke `iteratee`.
974    * @param {Function} iteratee The function invoked per iteration.
975    * @returns {Array} Returns the array of results.
976    */
977   function baseTimes(n, iteratee) {
978     var index = -1,
979         result = Array(n);
980
981     while (++index < n) {
982       result[index] = iteratee(index);
983     }
984     return result;
985   }
986
987   /**
988    * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
989    * of key-value pairs for `object` corresponding to the property names of `props`.
990    *
991    * @private
992    * @param {Object} object The object to query.
993    * @param {Array} props The property names to get values for.
994    * @returns {Object} Returns the key-value pairs.
995    */
996   function baseToPairs(object, props) {
997     return arrayMap(props, function(key) {
998       return [key, object[key]];
999     });
1000   }
1001
1002   /**
1003    * The base implementation of `_.unary` without support for storing metadata.
1004    *
1005    * @private
1006    * @param {Function} func The function to cap arguments for.
1007    * @returns {Function} Returns the new capped function.
1008    */
1009   function baseUnary(func) {
1010     return function(value) {
1011       return func(value);
1012     };
1013   }
1014
1015   /**
1016    * The base implementation of `_.values` and `_.valuesIn` which creates an
1017    * array of `object` property values corresponding to the property names
1018    * of `props`.
1019    *
1020    * @private
1021    * @param {Object} object The object to query.
1022    * @param {Array} props The property names to get values for.
1023    * @returns {Object} Returns the array of property values.
1024    */
1025   function baseValues(object, props) {
1026     return arrayMap(props, function(key) {
1027       return object[key];
1028     });
1029   }
1030
1031   /**
1032    * Checks if a `cache` value for `key` exists.
1033    *
1034    * @private
1035    * @param {Object} cache The cache to query.
1036    * @param {string} key The key of the entry to check.
1037    * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1038    */
1039   function cacheHas(cache, key) {
1040     return cache.has(key);
1041   }
1042
1043   /**
1044    * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1045    * that is not found in the character symbols.
1046    *
1047    * @private
1048    * @param {Array} strSymbols The string symbols to inspect.
1049    * @param {Array} chrSymbols The character symbols to find.
1050    * @returns {number} Returns the index of the first unmatched string symbol.
1051    */
1052   function charsStartIndex(strSymbols, chrSymbols) {
1053     var index = -1,
1054         length = strSymbols.length;
1055
1056     while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1057     return index;
1058   }
1059
1060   /**
1061    * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1062    * that is not found in the character symbols.
1063    *
1064    * @private
1065    * @param {Array} strSymbols The string symbols to inspect.
1066    * @param {Array} chrSymbols The character symbols to find.
1067    * @returns {number} Returns the index of the last unmatched string symbol.
1068    */
1069   function charsEndIndex(strSymbols, chrSymbols) {
1070     var index = strSymbols.length;
1071
1072     while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1073     return index;
1074   }
1075
1076   /**
1077    * Gets the number of `placeholder` occurrences in `array`.
1078    *
1079    * @private
1080    * @param {Array} array The array to inspect.
1081    * @param {*} placeholder The placeholder to search for.
1082    * @returns {number} Returns the placeholder count.
1083    */
1084   function countHolders(array, placeholder) {
1085     var length = array.length,
1086         result = 0;
1087
1088     while (length--) {
1089       if (array[length] === placeholder) {
1090         ++result;
1091       }
1092     }
1093     return result;
1094   }
1095
1096   /**
1097    * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1098    * letters to basic Latin letters.
1099    *
1100    * @private
1101    * @param {string} letter The matched letter to deburr.
1102    * @returns {string} Returns the deburred letter.
1103    */
1104   var deburrLetter = basePropertyOf(deburredLetters);
1105
1106   /**
1107    * Used by `_.escape` to convert characters to HTML entities.
1108    *
1109    * @private
1110    * @param {string} chr The matched character to escape.
1111    * @returns {string} Returns the escaped character.
1112    */
1113   var escapeHtmlChar = basePropertyOf(htmlEscapes);
1114
1115   /**
1116    * Used by `_.template` to escape characters for inclusion in compiled string literals.
1117    *
1118    * @private
1119    * @param {string} chr The matched character to escape.
1120    * @returns {string} Returns the escaped character.
1121    */
1122   function escapeStringChar(chr) {
1123     return '\\' + stringEscapes[chr];
1124   }
1125
1126   /**
1127    * Gets the value at `key` of `object`.
1128    *
1129    * @private
1130    * @param {Object} [object] The object to query.
1131    * @param {string} key The key of the property to get.
1132    * @returns {*} Returns the property value.
1133    */
1134   function getValue(object, key) {
1135     return object == null ? undefined : object[key];
1136   }
1137
1138   /**
1139    * Checks if `string` contains Unicode symbols.
1140    *
1141    * @private
1142    * @param {string} string The string to inspect.
1143    * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1144    */
1145   function hasUnicode(string) {
1146     return reHasUnicode.test(string);
1147   }
1148
1149   /**
1150    * Checks if `string` contains a word composed of Unicode symbols.
1151    *
1152    * @private
1153    * @param {string} string The string to inspect.
1154    * @returns {boolean} Returns `true` if a word is found, else `false`.
1155    */
1156   function hasUnicodeWord(string) {
1157     return reHasUnicodeWord.test(string);
1158   }
1159
1160   /**
1161    * Converts `iterator` to an array.
1162    *
1163    * @private
1164    * @param {Object} iterator The iterator to convert.
1165    * @returns {Array} Returns the converted array.
1166    */
1167   function iteratorToArray(iterator) {
1168     var data,
1169         result = [];
1170
1171     while (!(data = iterator.next()).done) {
1172       result.push(data.value);
1173     }
1174     return result;
1175   }
1176
1177   /**
1178    * Converts `map` to its key-value pairs.
1179    *
1180    * @private
1181    * @param {Object} map The map to convert.
1182    * @returns {Array} Returns the key-value pairs.
1183    */
1184   function mapToArray(map) {
1185     var index = -1,
1186         result = Array(map.size);
1187
1188     map.forEach(function(value, key) {
1189       result[++index] = [key, value];
1190     });
1191     return result;
1192   }
1193
1194   /**
1195    * Creates a unary function that invokes `func` with its argument transformed.
1196    *
1197    * @private
1198    * @param {Function} func The function to wrap.
1199    * @param {Function} transform The argument transform.
1200    * @returns {Function} Returns the new function.
1201    */
1202   function overArg(func, transform) {
1203     return function(arg) {
1204       return func(transform(arg));
1205     };
1206   }
1207
1208   /**
1209    * Replaces all `placeholder` elements in `array` with an internal placeholder
1210    * and returns an array of their indexes.
1211    *
1212    * @private
1213    * @param {Array} array The array to modify.
1214    * @param {*} placeholder The placeholder to replace.
1215    * @returns {Array} Returns the new array of placeholder indexes.
1216    */
1217   function replaceHolders(array, placeholder) {
1218     var index = -1,
1219         length = array.length,
1220         resIndex = 0,
1221         result = [];
1222
1223     while (++index < length) {
1224       var value = array[index];
1225       if (value === placeholder || value === PLACEHOLDER) {
1226         array[index] = PLACEHOLDER;
1227         result[resIndex++] = index;
1228       }
1229     }
1230     return result;
1231   }
1232
1233   /**
1234    * Converts `set` to an array of its values.
1235    *
1236    * @private
1237    * @param {Object} set The set to convert.
1238    * @returns {Array} Returns the values.
1239    */
1240   function setToArray(set) {
1241     var index = -1,
1242         result = Array(set.size);
1243
1244     set.forEach(function(value) {
1245       result[++index] = value;
1246     });
1247     return result;
1248   }
1249
1250   /**
1251    * Converts `set` to its value-value pairs.
1252    *
1253    * @private
1254    * @param {Object} set The set to convert.
1255    * @returns {Array} Returns the value-value pairs.
1256    */
1257   function setToPairs(set) {
1258     var index = -1,
1259         result = Array(set.size);
1260
1261     set.forEach(function(value) {
1262       result[++index] = [value, value];
1263     });
1264     return result;
1265   }
1266
1267   /**
1268    * A specialized version of `_.indexOf` which performs strict equality
1269    * comparisons of values, i.e. `===`.
1270    *
1271    * @private
1272    * @param {Array} array The array to inspect.
1273    * @param {*} value The value to search for.
1274    * @param {number} fromIndex The index to search from.
1275    * @returns {number} Returns the index of the matched value, else `-1`.
1276    */
1277   function strictIndexOf(array, value, fromIndex) {
1278     var index = fromIndex - 1,
1279         length = array.length;
1280
1281     while (++index < length) {
1282       if (array[index] === value) {
1283         return index;
1284       }
1285     }
1286     return -1;
1287   }
1288
1289   /**
1290    * A specialized version of `_.lastIndexOf` which performs strict equality
1291    * comparisons of values, i.e. `===`.
1292    *
1293    * @private
1294    * @param {Array} array The array to inspect.
1295    * @param {*} value The value to search for.
1296    * @param {number} fromIndex The index to search from.
1297    * @returns {number} Returns the index of the matched value, else `-1`.
1298    */
1299   function strictLastIndexOf(array, value, fromIndex) {
1300     var index = fromIndex + 1;
1301     while (index--) {
1302       if (array[index] === value) {
1303         return index;
1304       }
1305     }
1306     return index;
1307   }
1308
1309   /**
1310    * Gets the number of symbols in `string`.
1311    *
1312    * @private
1313    * @param {string} string The string to inspect.
1314    * @returns {number} Returns the string size.
1315    */
1316   function stringSize(string) {
1317     return hasUnicode(string)
1318       ? unicodeSize(string)
1319       : asciiSize(string);
1320   }
1321
1322   /**
1323    * Converts `string` to an array.
1324    *
1325    * @private
1326    * @param {string} string The string to convert.
1327    * @returns {Array} Returns the converted array.
1328    */
1329   function stringToArray(string) {
1330     return hasUnicode(string)
1331       ? unicodeToArray(string)
1332       : asciiToArray(string);
1333   }
1334
1335   /**
1336    * Used by `_.unescape` to convert HTML entities to characters.
1337    *
1338    * @private
1339    * @param {string} chr The matched character to unescape.
1340    * @returns {string} Returns the unescaped character.
1341    */
1342   var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1343
1344   /**
1345    * Gets the size of a Unicode `string`.
1346    *
1347    * @private
1348    * @param {string} string The string inspect.
1349    * @returns {number} Returns the string size.
1350    */
1351   function unicodeSize(string) {
1352     var result = reUnicode.lastIndex = 0;
1353     while (reUnicode.test(string)) {
1354       ++result;
1355     }
1356     return result;
1357   }
1358
1359   /**
1360    * Converts a Unicode `string` to an array.
1361    *
1362    * @private
1363    * @param {string} string The string to convert.
1364    * @returns {Array} Returns the converted array.
1365    */
1366   function unicodeToArray(string) {
1367     return string.match(reUnicode) || [];
1368   }
1369
1370   /**
1371    * Splits a Unicode `string` into an array of its words.
1372    *
1373    * @private
1374    * @param {string} The string to inspect.
1375    * @returns {Array} Returns the words of `string`.
1376    */
1377   function unicodeWords(string) {
1378     return string.match(reUnicodeWord) || [];
1379   }
1380
1381   /*--------------------------------------------------------------------------*/
1382
1383   /**
1384    * Create a new pristine `lodash` function using the `context` object.
1385    *
1386    * @static
1387    * @memberOf _
1388    * @since 1.1.0
1389    * @category Util
1390    * @param {Object} [context=root] The context object.
1391    * @returns {Function} Returns a new `lodash` function.
1392    * @example
1393    *
1394    * _.mixin({ 'foo': _.constant('foo') });
1395    *
1396    * var lodash = _.runInContext();
1397    * lodash.mixin({ 'bar': lodash.constant('bar') });
1398    *
1399    * _.isFunction(_.foo);
1400    * // => true
1401    * _.isFunction(_.bar);
1402    * // => false
1403    *
1404    * lodash.isFunction(lodash.foo);
1405    * // => false
1406    * lodash.isFunction(lodash.bar);
1407    * // => true
1408    *
1409    * // Create a suped-up `defer` in Node.js.
1410    * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1411    */
1412   var runInContext = (function runInContext(context) {
1413     context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1414
1415     /** Built-in constructor references. */
1416     var Array = context.Array,
1417         Date = context.Date,
1418         Error = context.Error,
1419         Function = context.Function,
1420         Math = context.Math,
1421         Object = context.Object,
1422         RegExp = context.RegExp,
1423         String = context.String,
1424         TypeError = context.TypeError;
1425
1426     /** Used for built-in method references. */
1427     var arrayProto = Array.prototype,
1428         funcProto = Function.prototype,
1429         objectProto = Object.prototype;
1430
1431     /** Used to detect overreaching core-js shims. */
1432     var coreJsData = context['__core-js_shared__'];
1433
1434     /** Used to resolve the decompiled source of functions. */
1435     var funcToString = funcProto.toString;
1436
1437     /** Used to check objects for own properties. */
1438     var hasOwnProperty = objectProto.hasOwnProperty;
1439
1440     /** Used to generate unique IDs. */
1441     var idCounter = 0;
1442
1443     /** Used to detect methods masquerading as native. */
1444     var maskSrcKey = (function() {
1445       var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1446       return uid ? ('Symbol(src)_1.' + uid) : '';
1447     }());
1448
1449     /**
1450      * Used to resolve the
1451      * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1452      * of values.
1453      */
1454     var nativeObjectToString = objectProto.toString;
1455
1456     /** Used to infer the `Object` constructor. */
1457     var objectCtorString = funcToString.call(Object);
1458
1459     /** Used to restore the original `_` reference in `_.noConflict`. */
1460     var oldDash = root._;
1461
1462     /** Used to detect if a method is native. */
1463     var reIsNative = RegExp('^' +
1464       funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1465       .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1466     );
1467
1468     /** Built-in value references. */
1469     var Buffer = moduleExports ? context.Buffer : undefined,
1470         Symbol = context.Symbol,
1471         Uint8Array = context.Uint8Array,
1472         allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
1473         getPrototype = overArg(Object.getPrototypeOf, Object),
1474         objectCreate = Object.create,
1475         propertyIsEnumerable = objectProto.propertyIsEnumerable,
1476         splice = arrayProto.splice,
1477         spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
1478         symIterator = Symbol ? Symbol.iterator : undefined,
1479         symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1480
1481     var defineProperty = (function() {
1482       try {
1483         var func = getNative(Object, 'defineProperty');
1484         func({}, '', {});
1485         return func;
1486       } catch (e) {}
1487     }());
1488
1489     /** Mocked built-ins. */
1490     var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
1491         ctxNow = Date && Date.now !== root.Date.now && Date.now,
1492         ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1493
1494     /* Built-in method references for those with the same name as other `lodash` methods. */
1495     var nativeCeil = Math.ceil,
1496         nativeFloor = Math.floor,
1497         nativeGetSymbols = Object.getOwnPropertySymbols,
1498         nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
1499         nativeIsFinite = context.isFinite,
1500         nativeJoin = arrayProto.join,
1501         nativeKeys = overArg(Object.keys, Object),
1502         nativeMax = Math.max,
1503         nativeMin = Math.min,
1504         nativeNow = Date.now,
1505         nativeParseInt = context.parseInt,
1506         nativeRandom = Math.random,
1507         nativeReverse = arrayProto.reverse;
1508
1509     /* Built-in method references that are verified to be native. */
1510     var DataView = getNative(context, 'DataView'),
1511         Map = getNative(context, 'Map'),
1512         Promise = getNative(context, 'Promise'),
1513         Set = getNative(context, 'Set'),
1514         WeakMap = getNative(context, 'WeakMap'),
1515         nativeCreate = getNative(Object, 'create');
1516
1517     /** Used to store function metadata. */
1518     var metaMap = WeakMap && new WeakMap;
1519
1520     /** Used to lookup unminified function names. */
1521     var realNames = {};
1522
1523     /** Used to detect maps, sets, and weakmaps. */
1524     var dataViewCtorString = toSource(DataView),
1525         mapCtorString = toSource(Map),
1526         promiseCtorString = toSource(Promise),
1527         setCtorString = toSource(Set),
1528         weakMapCtorString = toSource(WeakMap);
1529
1530     /** Used to convert symbols to primitives and strings. */
1531     var symbolProto = Symbol ? Symbol.prototype : undefined,
1532         symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
1533         symbolToString = symbolProto ? symbolProto.toString : undefined;
1534
1535     /*------------------------------------------------------------------------*/
1536
1537     /**
1538      * Creates a `lodash` object which wraps `value` to enable implicit method
1539      * chain sequences. Methods that operate on and return arrays, collections,
1540      * and functions can be chained together. Methods that retrieve a single value
1541      * or may return a primitive value will automatically end the chain sequence
1542      * and return the unwrapped value. Otherwise, the value must be unwrapped
1543      * with `_#value`.
1544      *
1545      * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1546      * enabled using `_.chain`.
1547      *
1548      * The execution of chained methods is lazy, that is, it's deferred until
1549      * `_#value` is implicitly or explicitly called.
1550      *
1551      * Lazy evaluation allows several methods to support shortcut fusion.
1552      * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1553      * the creation of intermediate arrays and can greatly reduce the number of
1554      * iteratee executions. Sections of a chain sequence qualify for shortcut
1555      * fusion if the section is applied to an array and iteratees accept only
1556      * one argument. The heuristic for whether a section qualifies for shortcut
1557      * fusion is subject to change.
1558      *
1559      * Chaining is supported in custom builds as long as the `_#value` method is
1560      * directly or indirectly included in the build.
1561      *
1562      * In addition to lodash methods, wrappers have `Array` and `String` methods.
1563      *
1564      * The wrapper `Array` methods are:
1565      * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1566      *
1567      * The wrapper `String` methods are:
1568      * `replace` and `split`
1569      *
1570      * The wrapper methods that support shortcut fusion are:
1571      * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1572      * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1573      * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1574      *
1575      * The chainable wrapper methods are:
1576      * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1577      * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1578      * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1579      * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1580      * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1581      * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1582      * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1583      * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1584      * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1585      * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1586      * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1587      * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1588      * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1589      * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1590      * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1591      * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1592      * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1593      * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1594      * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1595      * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1596      * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1597      * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1598      * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1599      * `zipObject`, `zipObjectDeep`, and `zipWith`
1600      *
1601      * The wrapper methods that are **not** chainable by default are:
1602      * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1603      * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
1604      * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
1605      * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
1606      * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
1607      * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
1608      * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
1609      * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
1610      * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
1611      * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
1612      * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
1613      * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
1614      * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
1615      * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
1616      * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
1617      * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
1618      * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
1619      * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
1620      * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
1621      * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
1622      * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
1623      * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
1624      * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
1625      * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
1626      * `upperFirst`, `value`, and `words`
1627      *
1628      * @name _
1629      * @constructor
1630      * @category Seq
1631      * @param {*} value The value to wrap in a `lodash` instance.
1632      * @returns {Object} Returns the new `lodash` wrapper instance.
1633      * @example
1634      *
1635      * function square(n) {
1636      *   return n * n;
1637      * }
1638      *
1639      * var wrapped = _([1, 2, 3]);
1640      *
1641      * // Returns an unwrapped value.
1642      * wrapped.reduce(_.add);
1643      * // => 6
1644      *
1645      * // Returns a wrapped value.
1646      * var squares = wrapped.map(square);
1647      *
1648      * _.isArray(squares);
1649      * // => false
1650      *
1651      * _.isArray(squares.value());
1652      * // => true
1653      */
1654     function lodash(value) {
1655       if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1656         if (value instanceof LodashWrapper) {
1657           return value;
1658         }
1659         if (hasOwnProperty.call(value, '__wrapped__')) {
1660           return wrapperClone(value);
1661         }
1662       }
1663       return new LodashWrapper(value);
1664     }
1665
1666     /**
1667      * The base implementation of `_.create` without support for assigning
1668      * properties to the created object.
1669      *
1670      * @private
1671      * @param {Object} proto The object to inherit from.
1672      * @returns {Object} Returns the new object.
1673      */
1674     var baseCreate = (function() {
1675       function object() {}
1676       return function(proto) {
1677         if (!isObject(proto)) {
1678           return {};
1679         }
1680         if (objectCreate) {
1681           return objectCreate(proto);
1682         }
1683         object.prototype = proto;
1684         var result = new object;
1685         object.prototype = undefined;
1686         return result;
1687       };
1688     }());
1689
1690     /**
1691      * The function whose prototype chain sequence wrappers inherit from.
1692      *
1693      * @private
1694      */
1695     function baseLodash() {
1696       // No operation performed.
1697     }
1698
1699     /**
1700      * The base constructor for creating `lodash` wrapper objects.
1701      *
1702      * @private
1703      * @param {*} value The value to wrap.
1704      * @param {boolean} [chainAll] Enable explicit method chain sequences.
1705      */
1706     function LodashWrapper(value, chainAll) {
1707       this.__wrapped__ = value;
1708       this.__actions__ = [];
1709       this.__chain__ = !!chainAll;
1710       this.__index__ = 0;
1711       this.__values__ = undefined;
1712     }
1713
1714     /**
1715      * By default, the template delimiters used by lodash are like those in
1716      * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1717      * following template settings to use alternative delimiters.
1718      *
1719      * @static
1720      * @memberOf _
1721      * @type {Object}
1722      */
1723     lodash.templateSettings = {
1724
1725       /**
1726        * Used to detect `data` property values to be HTML-escaped.
1727        *
1728        * @memberOf _.templateSettings
1729        * @type {RegExp}
1730        */
1731       'escape': reEscape,
1732
1733       /**
1734        * Used to detect code to be evaluated.
1735        *
1736        * @memberOf _.templateSettings
1737        * @type {RegExp}
1738        */
1739       'evaluate': reEvaluate,
1740
1741       /**
1742        * Used to detect `data` property values to inject.
1743        *
1744        * @memberOf _.templateSettings
1745        * @type {RegExp}
1746        */
1747       'interpolate': reInterpolate,
1748
1749       /**
1750        * Used to reference the data object in the template text.
1751        *
1752        * @memberOf _.templateSettings
1753        * @type {string}
1754        */
1755       'variable': '',
1756
1757       /**
1758        * Used to import variables into the compiled template.
1759        *
1760        * @memberOf _.templateSettings
1761        * @type {Object}
1762        */
1763       'imports': {
1764
1765         /**
1766          * A reference to the `lodash` function.
1767          *
1768          * @memberOf _.templateSettings.imports
1769          * @type {Function}
1770          */
1771         '_': lodash
1772       }
1773     };
1774
1775     // Ensure wrappers are instances of `baseLodash`.
1776     lodash.prototype = baseLodash.prototype;
1777     lodash.prototype.constructor = lodash;
1778
1779     LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1780     LodashWrapper.prototype.constructor = LodashWrapper;
1781
1782     /*------------------------------------------------------------------------*/
1783
1784     /**
1785      * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1786      *
1787      * @private
1788      * @constructor
1789      * @param {*} value The value to wrap.
1790      */
1791     function LazyWrapper(value) {
1792       this.__wrapped__ = value;
1793       this.__actions__ = [];
1794       this.__dir__ = 1;
1795       this.__filtered__ = false;
1796       this.__iteratees__ = [];
1797       this.__takeCount__ = MAX_ARRAY_LENGTH;
1798       this.__views__ = [];
1799     }
1800
1801     /**
1802      * Creates a clone of the lazy wrapper object.
1803      *
1804      * @private
1805      * @name clone
1806      * @memberOf LazyWrapper
1807      * @returns {Object} Returns the cloned `LazyWrapper` object.
1808      */
1809     function lazyClone() {
1810       var result = new LazyWrapper(this.__wrapped__);
1811       result.__actions__ = copyArray(this.__actions__);
1812       result.__dir__ = this.__dir__;
1813       result.__filtered__ = this.__filtered__;
1814       result.__iteratees__ = copyArray(this.__iteratees__);
1815       result.__takeCount__ = this.__takeCount__;
1816       result.__views__ = copyArray(this.__views__);
1817       return result;
1818     }
1819
1820     /**
1821      * Reverses the direction of lazy iteration.
1822      *
1823      * @private
1824      * @name reverse
1825      * @memberOf LazyWrapper
1826      * @returns {Object} Returns the new reversed `LazyWrapper` object.
1827      */
1828     function lazyReverse() {
1829       if (this.__filtered__) {
1830         var result = new LazyWrapper(this);
1831         result.__dir__ = -1;
1832         result.__filtered__ = true;
1833       } else {
1834         result = this.clone();
1835         result.__dir__ *= -1;
1836       }
1837       return result;
1838     }
1839
1840     /**
1841      * Extracts the unwrapped value from its lazy wrapper.
1842      *
1843      * @private
1844      * @name value
1845      * @memberOf LazyWrapper
1846      * @returns {*} Returns the unwrapped value.
1847      */
1848     function lazyValue() {
1849       var array = this.__wrapped__.value(),
1850           dir = this.__dir__,
1851           isArr = isArray(array),
1852           isRight = dir < 0,
1853           arrLength = isArr ? array.length : 0,
1854           view = getView(0, arrLength, this.__views__),
1855           start = view.start,
1856           end = view.end,
1857           length = end - start,
1858           index = isRight ? end : (start - 1),
1859           iteratees = this.__iteratees__,
1860           iterLength = iteratees.length,
1861           resIndex = 0,
1862           takeCount = nativeMin(length, this.__takeCount__);
1863
1864       if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
1865         return baseWrapperValue(array, this.__actions__);
1866       }
1867       var result = [];
1868
1869       outer:
1870       while (length-- && resIndex < takeCount) {
1871         index += dir;
1872
1873         var iterIndex = -1,
1874             value = array[index];
1875
1876         while (++iterIndex < iterLength) {
1877           var data = iteratees[iterIndex],
1878               iteratee = data.iteratee,
1879               type = data.type,
1880               computed = iteratee(value);
1881
1882           if (type == LAZY_MAP_FLAG) {
1883             value = computed;
1884           } else if (!computed) {
1885             if (type == LAZY_FILTER_FLAG) {
1886               continue outer;
1887             } else {
1888               break outer;
1889             }
1890           }
1891         }
1892         result[resIndex++] = value;
1893       }
1894       return result;
1895     }
1896
1897     // Ensure `LazyWrapper` is an instance of `baseLodash`.
1898     LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1899     LazyWrapper.prototype.constructor = LazyWrapper;
1900
1901     /*------------------------------------------------------------------------*/
1902
1903     /**
1904      * Creates a hash object.
1905      *
1906      * @private
1907      * @constructor
1908      * @param {Array} [entries] The key-value pairs to cache.
1909      */
1910     function Hash(entries) {
1911       var index = -1,
1912           length = entries == null ? 0 : entries.length;
1913
1914       this.clear();
1915       while (++index < length) {
1916         var entry = entries[index];
1917         this.set(entry[0], entry[1]);
1918       }
1919     }
1920
1921     /**
1922      * Removes all key-value entries from the hash.
1923      *
1924      * @private
1925      * @name clear
1926      * @memberOf Hash
1927      */
1928     function hashClear() {
1929       this.__data__ = nativeCreate ? nativeCreate(null) : {};
1930       this.size = 0;
1931     }
1932
1933     /**
1934      * Removes `key` and its value from the hash.
1935      *
1936      * @private
1937      * @name delete
1938      * @memberOf Hash
1939      * @param {Object} hash The hash to modify.
1940      * @param {string} key The key of the value to remove.
1941      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1942      */
1943     function hashDelete(key) {
1944       var result = this.has(key) && delete this.__data__[key];
1945       this.size -= result ? 1 : 0;
1946       return result;
1947     }
1948
1949     /**
1950      * Gets the hash value for `key`.
1951      *
1952      * @private
1953      * @name get
1954      * @memberOf Hash
1955      * @param {string} key The key of the value to get.
1956      * @returns {*} Returns the entry value.
1957      */
1958     function hashGet(key) {
1959       var data = this.__data__;
1960       if (nativeCreate) {
1961         var result = data[key];
1962         return result === HASH_UNDEFINED ? undefined : result;
1963       }
1964       return hasOwnProperty.call(data, key) ? data[key] : undefined;
1965     }
1966
1967     /**
1968      * Checks if a hash value for `key` exists.
1969      *
1970      * @private
1971      * @name has
1972      * @memberOf Hash
1973      * @param {string} key The key of the entry to check.
1974      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1975      */
1976     function hashHas(key) {
1977       var data = this.__data__;
1978       return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
1979     }
1980
1981     /**
1982      * Sets the hash `key` to `value`.
1983      *
1984      * @private
1985      * @name set
1986      * @memberOf Hash
1987      * @param {string} key The key of the value to set.
1988      * @param {*} value The value to set.
1989      * @returns {Object} Returns the hash instance.
1990      */
1991     function hashSet(key, value) {
1992       var data = this.__data__;
1993       this.size += this.has(key) ? 0 : 1;
1994       data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1995       return this;
1996     }
1997
1998     // Add methods to `Hash`.
1999     Hash.prototype.clear = hashClear;
2000     Hash.prototype['delete'] = hashDelete;
2001     Hash.prototype.get = hashGet;
2002     Hash.prototype.has = hashHas;
2003     Hash.prototype.set = hashSet;
2004
2005     /*------------------------------------------------------------------------*/
2006
2007     /**
2008      * Creates an list cache object.
2009      *
2010      * @private
2011      * @constructor
2012      * @param {Array} [entries] The key-value pairs to cache.
2013      */
2014     function ListCache(entries) {
2015       var index = -1,
2016           length = entries == null ? 0 : entries.length;
2017
2018       this.clear();
2019       while (++index < length) {
2020         var entry = entries[index];
2021         this.set(entry[0], entry[1]);
2022       }
2023     }
2024
2025     /**
2026      * Removes all key-value entries from the list cache.
2027      *
2028      * @private
2029      * @name clear
2030      * @memberOf ListCache
2031      */
2032     function listCacheClear() {
2033       this.__data__ = [];
2034       this.size = 0;
2035     }
2036
2037     /**
2038      * Removes `key` and its value from the list cache.
2039      *
2040      * @private
2041      * @name delete
2042      * @memberOf ListCache
2043      * @param {string} key The key of the value to remove.
2044      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2045      */
2046     function listCacheDelete(key) {
2047       var data = this.__data__,
2048           index = assocIndexOf(data, key);
2049
2050       if (index < 0) {
2051         return false;
2052       }
2053       var lastIndex = data.length - 1;
2054       if (index == lastIndex) {
2055         data.pop();
2056       } else {
2057         splice.call(data, index, 1);
2058       }
2059       --this.size;
2060       return true;
2061     }
2062
2063     /**
2064      * Gets the list cache value for `key`.
2065      *
2066      * @private
2067      * @name get
2068      * @memberOf ListCache
2069      * @param {string} key The key of the value to get.
2070      * @returns {*} Returns the entry value.
2071      */
2072     function listCacheGet(key) {
2073       var data = this.__data__,
2074           index = assocIndexOf(data, key);
2075
2076       return index < 0 ? undefined : data[index][1];
2077     }
2078
2079     /**
2080      * Checks if a list cache value for `key` exists.
2081      *
2082      * @private
2083      * @name has
2084      * @memberOf ListCache
2085      * @param {string} key The key of the entry to check.
2086      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2087      */
2088     function listCacheHas(key) {
2089       return assocIndexOf(this.__data__, key) > -1;
2090     }
2091
2092     /**
2093      * Sets the list cache `key` to `value`.
2094      *
2095      * @private
2096      * @name set
2097      * @memberOf ListCache
2098      * @param {string} key The key of the value to set.
2099      * @param {*} value The value to set.
2100      * @returns {Object} Returns the list cache instance.
2101      */
2102     function listCacheSet(key, value) {
2103       var data = this.__data__,
2104           index = assocIndexOf(data, key);
2105
2106       if (index < 0) {
2107         ++this.size;
2108         data.push([key, value]);
2109       } else {
2110         data[index][1] = value;
2111       }
2112       return this;
2113     }
2114
2115     // Add methods to `ListCache`.
2116     ListCache.prototype.clear = listCacheClear;
2117     ListCache.prototype['delete'] = listCacheDelete;
2118     ListCache.prototype.get = listCacheGet;
2119     ListCache.prototype.has = listCacheHas;
2120     ListCache.prototype.set = listCacheSet;
2121
2122     /*------------------------------------------------------------------------*/
2123
2124     /**
2125      * Creates a map cache object to store key-value pairs.
2126      *
2127      * @private
2128      * @constructor
2129      * @param {Array} [entries] The key-value pairs to cache.
2130      */
2131     function MapCache(entries) {
2132       var index = -1,
2133           length = entries == null ? 0 : entries.length;
2134
2135       this.clear();
2136       while (++index < length) {
2137         var entry = entries[index];
2138         this.set(entry[0], entry[1]);
2139       }
2140     }
2141
2142     /**
2143      * Removes all key-value entries from the map.
2144      *
2145      * @private
2146      * @name clear
2147      * @memberOf MapCache
2148      */
2149     function mapCacheClear() {
2150       this.size = 0;
2151       this.__data__ = {
2152         'hash': new Hash,
2153         'map': new (Map || ListCache),
2154         'string': new Hash
2155       };
2156     }
2157
2158     /**
2159      * Removes `key` and its value from the map.
2160      *
2161      * @private
2162      * @name delete
2163      * @memberOf MapCache
2164      * @param {string} key The key of the value to remove.
2165      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2166      */
2167     function mapCacheDelete(key) {
2168       var result = getMapData(this, key)['delete'](key);
2169       this.size -= result ? 1 : 0;
2170       return result;
2171     }
2172
2173     /**
2174      * Gets the map value for `key`.
2175      *
2176      * @private
2177      * @name get
2178      * @memberOf MapCache
2179      * @param {string} key The key of the value to get.
2180      * @returns {*} Returns the entry value.
2181      */
2182     function mapCacheGet(key) {
2183       return getMapData(this, key).get(key);
2184     }
2185
2186     /**
2187      * Checks if a map value for `key` exists.
2188      *
2189      * @private
2190      * @name has
2191      * @memberOf MapCache
2192      * @param {string} key The key of the entry to check.
2193      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2194      */
2195     function mapCacheHas(key) {
2196       return getMapData(this, key).has(key);
2197     }
2198
2199     /**
2200      * Sets the map `key` to `value`.
2201      *
2202      * @private
2203      * @name set
2204      * @memberOf MapCache
2205      * @param {string} key The key of the value to set.
2206      * @param {*} value The value to set.
2207      * @returns {Object} Returns the map cache instance.
2208      */
2209     function mapCacheSet(key, value) {
2210       var data = getMapData(this, key),
2211           size = data.size;
2212
2213       data.set(key, value);
2214       this.size += data.size == size ? 0 : 1;
2215       return this;
2216     }
2217
2218     // Add methods to `MapCache`.
2219     MapCache.prototype.clear = mapCacheClear;
2220     MapCache.prototype['delete'] = mapCacheDelete;
2221     MapCache.prototype.get = mapCacheGet;
2222     MapCache.prototype.has = mapCacheHas;
2223     MapCache.prototype.set = mapCacheSet;
2224
2225     /*------------------------------------------------------------------------*/
2226
2227     /**
2228      *
2229      * Creates an array cache object to store unique values.
2230      *
2231      * @private
2232      * @constructor
2233      * @param {Array} [values] The values to cache.
2234      */
2235     function SetCache(values) {
2236       var index = -1,
2237           length = values == null ? 0 : values.length;
2238
2239       this.__data__ = new MapCache;
2240       while (++index < length) {
2241         this.add(values[index]);
2242       }
2243     }
2244
2245     /**
2246      * Adds `value` to the array cache.
2247      *
2248      * @private
2249      * @name add
2250      * @memberOf SetCache
2251      * @alias push
2252      * @param {*} value The value to cache.
2253      * @returns {Object} Returns the cache instance.
2254      */
2255     function setCacheAdd(value) {
2256       this.__data__.set(value, HASH_UNDEFINED);
2257       return this;
2258     }
2259
2260     /**
2261      * Checks if `value` is in the array cache.
2262      *
2263      * @private
2264      * @name has
2265      * @memberOf SetCache
2266      * @param {*} value The value to search for.
2267      * @returns {number} Returns `true` if `value` is found, else `false`.
2268      */
2269     function setCacheHas(value) {
2270       return this.__data__.has(value);
2271     }
2272
2273     // Add methods to `SetCache`.
2274     SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2275     SetCache.prototype.has = setCacheHas;
2276
2277     /*------------------------------------------------------------------------*/
2278
2279     /**
2280      * Creates a stack cache object to store key-value pairs.
2281      *
2282      * @private
2283      * @constructor
2284      * @param {Array} [entries] The key-value pairs to cache.
2285      */
2286     function Stack(entries) {
2287       var data = this.__data__ = new ListCache(entries);
2288       this.size = data.size;
2289     }
2290
2291     /**
2292      * Removes all key-value entries from the stack.
2293      *
2294      * @private
2295      * @name clear
2296      * @memberOf Stack
2297      */
2298     function stackClear() {
2299       this.__data__ = new ListCache;
2300       this.size = 0;
2301     }
2302
2303     /**
2304      * Removes `key` and its value from the stack.
2305      *
2306      * @private
2307      * @name delete
2308      * @memberOf Stack
2309      * @param {string} key The key of the value to remove.
2310      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2311      */
2312     function stackDelete(key) {
2313       var data = this.__data__,
2314           result = data['delete'](key);
2315
2316       this.size = data.size;
2317       return result;
2318     }
2319
2320     /**
2321      * Gets the stack value for `key`.
2322      *
2323      * @private
2324      * @name get
2325      * @memberOf Stack
2326      * @param {string} key The key of the value to get.
2327      * @returns {*} Returns the entry value.
2328      */
2329     function stackGet(key) {
2330       return this.__data__.get(key);
2331     }
2332
2333     /**
2334      * Checks if a stack value for `key` exists.
2335      *
2336      * @private
2337      * @name has
2338      * @memberOf Stack
2339      * @param {string} key The key of the entry to check.
2340      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2341      */
2342     function stackHas(key) {
2343       return this.__data__.has(key);
2344     }
2345
2346     /**
2347      * Sets the stack `key` to `value`.
2348      *
2349      * @private
2350      * @name set
2351      * @memberOf Stack
2352      * @param {string} key The key of the value to set.
2353      * @param {*} value The value to set.
2354      * @returns {Object} Returns the stack cache instance.
2355      */
2356     function stackSet(key, value) {
2357       var data = this.__data__;
2358       if (data instanceof ListCache) {
2359         var pairs = data.__data__;
2360         if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2361           pairs.push([key, value]);
2362           this.size = ++data.size;
2363           return this;
2364         }
2365         data = this.__data__ = new MapCache(pairs);
2366       }
2367       data.set(key, value);
2368       this.size = data.size;
2369       return this;
2370     }
2371
2372     // Add methods to `Stack`.
2373     Stack.prototype.clear = stackClear;
2374     Stack.prototype['delete'] = stackDelete;
2375     Stack.prototype.get = stackGet;
2376     Stack.prototype.has = stackHas;
2377     Stack.prototype.set = stackSet;
2378
2379     /*------------------------------------------------------------------------*/
2380
2381     /**
2382      * Creates an array of the enumerable property names of the array-like `value`.
2383      *
2384      * @private
2385      * @param {*} value The value to query.
2386      * @param {boolean} inherited Specify returning inherited property names.
2387      * @returns {Array} Returns the array of property names.
2388      */
2389     function arrayLikeKeys(value, inherited) {
2390       var isArr = isArray(value),
2391           isArg = !isArr && isArguments(value),
2392           isBuff = !isArr && !isArg && isBuffer(value),
2393           isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2394           skipIndexes = isArr || isArg || isBuff || isType,
2395           result = skipIndexes ? baseTimes(value.length, String) : [],
2396           length = result.length;
2397
2398       for (var key in value) {
2399         if ((inherited || hasOwnProperty.call(value, key)) &&
2400             !(skipIndexes && (
2401                // Safari 9 has enumerable `arguments.length` in strict mode.
2402                key == 'length' ||
2403                // Node.js 0.10 has enumerable non-index properties on buffers.
2404                (isBuff && (key == 'offset' || key == 'parent')) ||
2405                // PhantomJS 2 has enumerable non-index properties on typed arrays.
2406                (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2407                // Skip index properties.
2408                isIndex(key, length)
2409             ))) {
2410           result.push(key);
2411         }
2412       }
2413       return result;
2414     }
2415
2416     /**
2417      * A specialized version of `_.sample` for arrays.
2418      *
2419      * @private
2420      * @param {Array} array The array to sample.
2421      * @returns {*} Returns the random element.
2422      */
2423     function arraySample(array) {
2424       var length = array.length;
2425       return length ? array[baseRandom(0, length - 1)] : undefined;
2426     }
2427
2428     /**
2429      * A specialized version of `_.sampleSize` for arrays.
2430      *
2431      * @private
2432      * @param {Array} array The array to sample.
2433      * @param {number} n The number of elements to sample.
2434      * @returns {Array} Returns the random elements.
2435      */
2436     function arraySampleSize(array, n) {
2437       return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2438     }
2439
2440     /**
2441      * A specialized version of `_.shuffle` for arrays.
2442      *
2443      * @private
2444      * @param {Array} array The array to shuffle.
2445      * @returns {Array} Returns the new shuffled array.
2446      */
2447     function arrayShuffle(array) {
2448       return shuffleSelf(copyArray(array));
2449     }
2450
2451     /**
2452      * This function is like `assignValue` except that it doesn't assign
2453      * `undefined` values.
2454      *
2455      * @private
2456      * @param {Object} object The object to modify.
2457      * @param {string} key The key of the property to assign.
2458      * @param {*} value The value to assign.
2459      */
2460     function assignMergeValue(object, key, value) {
2461       if ((value !== undefined && !eq(object[key], value)) ||
2462           (value === undefined && !(key in object))) {
2463         baseAssignValue(object, key, value);
2464       }
2465     }
2466
2467     /**
2468      * Assigns `value` to `key` of `object` if the existing value is not equivalent
2469      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2470      * for equality comparisons.
2471      *
2472      * @private
2473      * @param {Object} object The object to modify.
2474      * @param {string} key The key of the property to assign.
2475      * @param {*} value The value to assign.
2476      */
2477     function assignValue(object, key, value) {
2478       var objValue = object[key];
2479       if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2480           (value === undefined && !(key in object))) {
2481         baseAssignValue(object, key, value);
2482       }
2483     }
2484
2485     /**
2486      * Gets the index at which the `key` is found in `array` of key-value pairs.
2487      *
2488      * @private
2489      * @param {Array} array The array to inspect.
2490      * @param {*} key The key to search for.
2491      * @returns {number} Returns the index of the matched value, else `-1`.
2492      */
2493     function assocIndexOf(array, key) {
2494       var length = array.length;
2495       while (length--) {
2496         if (eq(array[length][0], key)) {
2497           return length;
2498         }
2499       }
2500       return -1;
2501     }
2502
2503     /**
2504      * Aggregates elements of `collection` on `accumulator` with keys transformed
2505      * by `iteratee` and values set by `setter`.
2506      *
2507      * @private
2508      * @param {Array|Object} collection The collection to iterate over.
2509      * @param {Function} setter The function to set `accumulator` values.
2510      * @param {Function} iteratee The iteratee to transform keys.
2511      * @param {Object} accumulator The initial aggregated object.
2512      * @returns {Function} Returns `accumulator`.
2513      */
2514     function baseAggregator(collection, setter, iteratee, accumulator) {
2515       baseEach(collection, function(value, key, collection) {
2516         setter(accumulator, value, iteratee(value), collection);
2517       });
2518       return accumulator;
2519     }
2520
2521     /**
2522      * The base implementation of `_.assign` without support for multiple sources
2523      * or `customizer` functions.
2524      *
2525      * @private
2526      * @param {Object} object The destination object.
2527      * @param {Object} source The source object.
2528      * @returns {Object} Returns `object`.
2529      */
2530     function baseAssign(object, source) {
2531       return object && copyObject(source, keys(source), object);
2532     }
2533
2534     /**
2535      * The base implementation of `_.assignIn` without support for multiple sources
2536      * or `customizer` functions.
2537      *
2538      * @private
2539      * @param {Object} object The destination object.
2540      * @param {Object} source The source object.
2541      * @returns {Object} Returns `object`.
2542      */
2543     function baseAssignIn(object, source) {
2544       return object && copyObject(source, keysIn(source), object);
2545     }
2546
2547     /**
2548      * The base implementation of `assignValue` and `assignMergeValue` without
2549      * value checks.
2550      *
2551      * @private
2552      * @param {Object} object The object to modify.
2553      * @param {string} key The key of the property to assign.
2554      * @param {*} value The value to assign.
2555      */
2556     function baseAssignValue(object, key, value) {
2557       if (key == '__proto__' && defineProperty) {
2558         defineProperty(object, key, {
2559           'configurable': true,
2560           'enumerable': true,
2561           'value': value,
2562           'writable': true
2563         });
2564       } else {
2565         object[key] = value;
2566       }
2567     }
2568
2569     /**
2570      * The base implementation of `_.at` without support for individual paths.
2571      *
2572      * @private
2573      * @param {Object} object The object to iterate over.
2574      * @param {string[]} paths The property paths to pick.
2575      * @returns {Array} Returns the picked elements.
2576      */
2577     function baseAt(object, paths) {
2578       var index = -1,
2579           length = paths.length,
2580           result = Array(length),
2581           skip = object == null;
2582
2583       while (++index < length) {
2584         result[index] = skip ? undefined : get(object, paths[index]);
2585       }
2586       return result;
2587     }
2588
2589     /**
2590      * The base implementation of `_.clamp` which doesn't coerce arguments.
2591      *
2592      * @private
2593      * @param {number} number The number to clamp.
2594      * @param {number} [lower] The lower bound.
2595      * @param {number} upper The upper bound.
2596      * @returns {number} Returns the clamped number.
2597      */
2598     function baseClamp(number, lower, upper) {
2599       if (number === number) {
2600         if (upper !== undefined) {
2601           number = number <= upper ? number : upper;
2602         }
2603         if (lower !== undefined) {
2604           number = number >= lower ? number : lower;
2605         }
2606       }
2607       return number;
2608     }
2609
2610     /**
2611      * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2612      * traversed objects.
2613      *
2614      * @private
2615      * @param {*} value The value to clone.
2616      * @param {boolean} bitmask The bitmask flags.
2617      *  1 - Deep clone
2618      *  2 - Flatten inherited properties
2619      *  4 - Clone symbols
2620      * @param {Function} [customizer] The function to customize cloning.
2621      * @param {string} [key] The key of `value`.
2622      * @param {Object} [object] The parent object of `value`.
2623      * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2624      * @returns {*} Returns the cloned value.
2625      */
2626     function baseClone(value, bitmask, customizer, key, object, stack) {
2627       var result,
2628           isDeep = bitmask & CLONE_DEEP_FLAG,
2629           isFlat = bitmask & CLONE_FLAT_FLAG,
2630           isFull = bitmask & CLONE_SYMBOLS_FLAG;
2631
2632       if (customizer) {
2633         result = object ? customizer(value, key, object, stack) : customizer(value);
2634       }
2635       if (result !== undefined) {
2636         return result;
2637       }
2638       if (!isObject(value)) {
2639         return value;
2640       }
2641       var isArr = isArray(value);
2642       if (isArr) {
2643         result = initCloneArray(value);
2644         if (!isDeep) {
2645           return copyArray(value, result);
2646         }
2647       } else {
2648         var tag = getTag(value),
2649             isFunc = tag == funcTag || tag == genTag;
2650
2651         if (isBuffer(value)) {
2652           return cloneBuffer(value, isDeep);
2653         }
2654         if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2655           result = (isFlat || isFunc) ? {} : initCloneObject(value);
2656           if (!isDeep) {
2657             return isFlat
2658               ? copySymbolsIn(value, baseAssignIn(result, value))
2659               : copySymbols(value, baseAssign(result, value));
2660           }
2661         } else {
2662           if (!cloneableTags[tag]) {
2663             return object ? value : {};
2664           }
2665           result = initCloneByTag(value, tag, isDeep);
2666         }
2667       }
2668       // Check for circular references and return its corresponding clone.
2669       stack || (stack = new Stack);
2670       var stacked = stack.get(value);
2671       if (stacked) {
2672         return stacked;
2673       }
2674       stack.set(value, result);
2675
2676       if (isSet(value)) {
2677         value.forEach(function(subValue) {
2678           result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2679         });
2680       } else if (isMap(value)) {
2681         value.forEach(function(subValue, key) {
2682           result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
2683         });
2684       }
2685
2686       var keysFunc = isFull
2687         ? (isFlat ? getAllKeysIn : getAllKeys)
2688         : (isFlat ? keysIn : keys);
2689
2690       var props = isArr ? undefined : keysFunc(value);
2691       arrayEach(props || value, function(subValue, key) {
2692         if (props) {
2693           key = subValue;
2694           subValue = value[key];
2695         }
2696         // Recursively populate clone (susceptible to call stack limits).
2697         assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
2698       });
2699       return result;
2700     }
2701
2702     /**
2703      * The base implementation of `_.conforms` which doesn't clone `source`.
2704      *
2705      * @private
2706      * @param {Object} source The object of property predicates to conform to.
2707      * @returns {Function} Returns the new spec function.
2708      */
2709     function baseConforms(source) {
2710       var props = keys(source);
2711       return function(object) {
2712         return baseConformsTo(object, source, props);
2713       };
2714     }
2715
2716     /**
2717      * The base implementation of `_.conformsTo` which accepts `props` to check.
2718      *
2719      * @private
2720      * @param {Object} object The object to inspect.
2721      * @param {Object} source The object of property predicates to conform to.
2722      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
2723      */
2724     function baseConformsTo(object, source, props) {
2725       var length = props.length;
2726       if (object == null) {
2727         return !length;
2728       }
2729       object = Object(object);
2730       while (length--) {
2731         var key = props[length],
2732             predicate = source[key],
2733             value = object[key];
2734
2735         if ((value === undefined && !(key in object)) || !predicate(value)) {
2736           return false;
2737         }
2738       }
2739       return true;
2740     }
2741
2742     /**
2743      * The base implementation of `_.delay` and `_.defer` which accepts `args`
2744      * to provide to `func`.
2745      *
2746      * @private
2747      * @param {Function} func The function to delay.
2748      * @param {number} wait The number of milliseconds to delay invocation.
2749      * @param {Array} args The arguments to provide to `func`.
2750      * @returns {number|Object} Returns the timer id or timeout object.
2751      */
2752     function baseDelay(func, wait, args) {
2753       if (typeof func != 'function') {
2754         throw new TypeError(FUNC_ERROR_TEXT);
2755       }
2756       return setTimeout(function() { func.apply(undefined, args); }, wait);
2757     }
2758
2759     /**
2760      * The base implementation of methods like `_.difference` without support
2761      * for excluding multiple arrays or iteratee shorthands.
2762      *
2763      * @private
2764      * @param {Array} array The array to inspect.
2765      * @param {Array} values The values to exclude.
2766      * @param {Function} [iteratee] The iteratee invoked per element.
2767      * @param {Function} [comparator] The comparator invoked per element.
2768      * @returns {Array} Returns the new array of filtered values.
2769      */
2770     function baseDifference(array, values, iteratee, comparator) {
2771       var index = -1,
2772           includes = arrayIncludes,
2773           isCommon = true,
2774           length = array.length,
2775           result = [],
2776           valuesLength = values.length;
2777
2778       if (!length) {
2779         return result;
2780       }
2781       if (iteratee) {
2782         values = arrayMap(values, baseUnary(iteratee));
2783       }
2784       if (comparator) {
2785         includes = arrayIncludesWith;
2786         isCommon = false;
2787       }
2788       else if (values.length >= LARGE_ARRAY_SIZE) {
2789         includes = cacheHas;
2790         isCommon = false;
2791         values = new SetCache(values);
2792       }
2793       outer:
2794       while (++index < length) {
2795         var value = array[index],
2796             computed = iteratee == null ? value : iteratee(value);
2797
2798         value = (comparator || value !== 0) ? value : 0;
2799         if (isCommon && computed === computed) {
2800           var valuesIndex = valuesLength;
2801           while (valuesIndex--) {
2802             if (values[valuesIndex] === computed) {
2803               continue outer;
2804             }
2805           }
2806           result.push(value);
2807         }
2808         else if (!includes(values, computed, comparator)) {
2809           result.push(value);
2810         }
2811       }
2812       return result;
2813     }
2814
2815     /**
2816      * The base implementation of `_.forEach` without support for iteratee shorthands.
2817      *
2818      * @private
2819      * @param {Array|Object} collection The collection to iterate over.
2820      * @param {Function} iteratee The function invoked per iteration.
2821      * @returns {Array|Object} Returns `collection`.
2822      */
2823     var baseEach = createBaseEach(baseForOwn);
2824
2825     /**
2826      * The base implementation of `_.forEachRight` without support for iteratee shorthands.
2827      *
2828      * @private
2829      * @param {Array|Object} collection The collection to iterate over.
2830      * @param {Function} iteratee The function invoked per iteration.
2831      * @returns {Array|Object} Returns `collection`.
2832      */
2833     var baseEachRight = createBaseEach(baseForOwnRight, true);
2834
2835     /**
2836      * The base implementation of `_.every` without support for iteratee shorthands.
2837      *
2838      * @private
2839      * @param {Array|Object} collection The collection to iterate over.
2840      * @param {Function} predicate The function invoked per iteration.
2841      * @returns {boolean} Returns `true` if all elements pass the predicate check,
2842      *  else `false`
2843      */
2844     function baseEvery(collection, predicate) {
2845       var result = true;
2846       baseEach(collection, function(value, index, collection) {
2847         result = !!predicate(value, index, collection);
2848         return result;
2849       });
2850       return result;
2851     }
2852
2853     /**
2854      * The base implementation of methods like `_.max` and `_.min` which accepts a
2855      * `comparator` to determine the extremum value.
2856      *
2857      * @private
2858      * @param {Array} array The array to iterate over.
2859      * @param {Function} iteratee The iteratee invoked per iteration.
2860      * @param {Function} comparator The comparator used to compare values.
2861      * @returns {*} Returns the extremum value.
2862      */
2863     function baseExtremum(array, iteratee, comparator) {
2864       var index = -1,
2865           length = array.length;
2866
2867       while (++index < length) {
2868         var value = array[index],
2869             current = iteratee(value);
2870
2871         if (current != null && (computed === undefined
2872               ? (current === current && !isSymbol(current))
2873               : comparator(current, computed)
2874             )) {
2875           var computed = current,
2876               result = value;
2877         }
2878       }
2879       return result;
2880     }
2881
2882     /**
2883      * The base implementation of `_.fill` without an iteratee call guard.
2884      *
2885      * @private
2886      * @param {Array} array The array to fill.
2887      * @param {*} value The value to fill `array` with.
2888      * @param {number} [start=0] The start position.
2889      * @param {number} [end=array.length] The end position.
2890      * @returns {Array} Returns `array`.
2891      */
2892     function baseFill(array, value, start, end) {
2893       var length = array.length;
2894
2895       start = toInteger(start);
2896       if (start < 0) {
2897         start = -start > length ? 0 : (length + start);
2898       }
2899       end = (end === undefined || end > length) ? length : toInteger(end);
2900       if (end < 0) {
2901         end += length;
2902       }
2903       end = start > end ? 0 : toLength(end);
2904       while (start < end) {
2905         array[start++] = value;
2906       }
2907       return array;
2908     }
2909
2910     /**
2911      * The base implementation of `_.filter` without support for iteratee shorthands.
2912      *
2913      * @private
2914      * @param {Array|Object} collection The collection to iterate over.
2915      * @param {Function} predicate The function invoked per iteration.
2916      * @returns {Array} Returns the new filtered array.
2917      */
2918     function baseFilter(collection, predicate) {
2919       var result = [];
2920       baseEach(collection, function(value, index, collection) {
2921         if (predicate(value, index, collection)) {
2922           result.push(value);
2923         }
2924       });
2925       return result;
2926     }
2927
2928     /**
2929      * The base implementation of `_.flatten` with support for restricting flattening.
2930      *
2931      * @private
2932      * @param {Array} array The array to flatten.
2933      * @param {number} depth The maximum recursion depth.
2934      * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
2935      * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
2936      * @param {Array} [result=[]] The initial result value.
2937      * @returns {Array} Returns the new flattened array.
2938      */
2939     function baseFlatten(array, depth, predicate, isStrict, result) {
2940       var index = -1,
2941           length = array.length;
2942
2943       predicate || (predicate = isFlattenable);
2944       result || (result = []);
2945
2946       while (++index < length) {
2947         var value = array[index];
2948         if (depth > 0 && predicate(value)) {
2949           if (depth > 1) {
2950             // Recursively flatten arrays (susceptible to call stack limits).
2951             baseFlatten(value, depth - 1, predicate, isStrict, result);
2952           } else {
2953             arrayPush(result, value);
2954           }
2955         } else if (!isStrict) {
2956           result[result.length] = value;
2957         }
2958       }
2959       return result;
2960     }
2961
2962     /**
2963      * The base implementation of `baseForOwn` which iterates over `object`
2964      * properties returned by `keysFunc` and invokes `iteratee` for each property.
2965      * Iteratee functions may exit iteration early by explicitly returning `false`.
2966      *
2967      * @private
2968      * @param {Object} object The object to iterate over.
2969      * @param {Function} iteratee The function invoked per iteration.
2970      * @param {Function} keysFunc The function to get the keys of `object`.
2971      * @returns {Object} Returns `object`.
2972      */
2973     var baseFor = createBaseFor();
2974
2975     /**
2976      * This function is like `baseFor` except that it iterates over properties
2977      * in the opposite order.
2978      *
2979      * @private
2980      * @param {Object} object The object to iterate over.
2981      * @param {Function} iteratee The function invoked per iteration.
2982      * @param {Function} keysFunc The function to get the keys of `object`.
2983      * @returns {Object} Returns `object`.
2984      */
2985     var baseForRight = createBaseFor(true);
2986
2987     /**
2988      * The base implementation of `_.forOwn` without support for iteratee shorthands.
2989      *
2990      * @private
2991      * @param {Object} object The object to iterate over.
2992      * @param {Function} iteratee The function invoked per iteration.
2993      * @returns {Object} Returns `object`.
2994      */
2995     function baseForOwn(object, iteratee) {
2996       return object && baseFor(object, iteratee, keys);
2997     }
2998
2999     /**
3000      * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
3001      *
3002      * @private
3003      * @param {Object} object The object to iterate over.
3004      * @param {Function} iteratee The function invoked per iteration.
3005      * @returns {Object} Returns `object`.
3006      */
3007     function baseForOwnRight(object, iteratee) {
3008       return object && baseForRight(object, iteratee, keys);
3009     }
3010
3011     /**
3012      * The base implementation of `_.functions` which creates an array of
3013      * `object` function property names filtered from `props`.
3014      *
3015      * @private
3016      * @param {Object} object The object to inspect.
3017      * @param {Array} props The property names to filter.
3018      * @returns {Array} Returns the function names.
3019      */
3020     function baseFunctions(object, props) {
3021       return arrayFilter(props, function(key) {
3022         return isFunction(object[key]);
3023       });
3024     }
3025
3026     /**
3027      * The base implementation of `_.get` without support for default values.
3028      *
3029      * @private
3030      * @param {Object} object The object to query.
3031      * @param {Array|string} path The path of the property to get.
3032      * @returns {*} Returns the resolved value.
3033      */
3034     function baseGet(object, path) {
3035       path = castPath(path, object);
3036
3037       var index = 0,
3038           length = path.length;
3039
3040       while (object != null && index < length) {
3041         object = object[toKey(path[index++])];
3042       }
3043       return (index && index == length) ? object : undefined;
3044     }
3045
3046     /**
3047      * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3048      * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3049      * symbols of `object`.
3050      *
3051      * @private
3052      * @param {Object} object The object to query.
3053      * @param {Function} keysFunc The function to get the keys of `object`.
3054      * @param {Function} symbolsFunc The function to get the symbols of `object`.
3055      * @returns {Array} Returns the array of property names and symbols.
3056      */
3057     function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3058       var result = keysFunc(object);
3059       return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3060     }
3061
3062     /**
3063      * The base implementation of `getTag` without fallbacks for buggy environments.
3064      *
3065      * @private
3066      * @param {*} value The value to query.
3067      * @returns {string} Returns the `toStringTag`.
3068      */
3069     function baseGetTag(value) {
3070       if (value == null) {
3071         return value === undefined ? undefinedTag : nullTag;
3072       }
3073       return (symToStringTag && symToStringTag in Object(value))
3074         ? getRawTag(value)
3075         : objectToString(value);
3076     }
3077
3078     /**
3079      * The base implementation of `_.gt` which doesn't coerce arguments.
3080      *
3081      * @private
3082      * @param {*} value The value to compare.
3083      * @param {*} other The other value to compare.
3084      * @returns {boolean} Returns `true` if `value` is greater than `other`,
3085      *  else `false`.
3086      */
3087     function baseGt(value, other) {
3088       return value > other;
3089     }
3090
3091     /**
3092      * The base implementation of `_.has` without support for deep paths.
3093      *
3094      * @private
3095      * @param {Object} [object] The object to query.
3096      * @param {Array|string} key The key to check.
3097      * @returns {boolean} Returns `true` if `key` exists, else `false`.
3098      */
3099     function baseHas(object, key) {
3100       return object != null && hasOwnProperty.call(object, key);
3101     }
3102
3103     /**
3104      * The base implementation of `_.hasIn` without support for deep paths.
3105      *
3106      * @private
3107      * @param {Object} [object] The object to query.
3108      * @param {Array|string} key The key to check.
3109      * @returns {boolean} Returns `true` if `key` exists, else `false`.
3110      */
3111     function baseHasIn(object, key) {
3112       return object != null && key in Object(object);
3113     }
3114
3115     /**
3116      * The base implementation of `_.inRange` which doesn't coerce arguments.
3117      *
3118      * @private
3119      * @param {number} number The number to check.
3120      * @param {number} start The start of the range.
3121      * @param {number} end The end of the range.
3122      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
3123      */
3124     function baseInRange(number, start, end) {
3125       return number >= nativeMin(start, end) && number < nativeMax(start, end);
3126     }
3127
3128     /**
3129      * The base implementation of methods like `_.intersection`, without support
3130      * for iteratee shorthands, that accepts an array of arrays to inspect.
3131      *
3132      * @private
3133      * @param {Array} arrays The arrays to inspect.
3134      * @param {Function} [iteratee] The iteratee invoked per element.
3135      * @param {Function} [comparator] The comparator invoked per element.
3136      * @returns {Array} Returns the new array of shared values.
3137      */
3138     function baseIntersection(arrays, iteratee, comparator) {
3139       var includes = comparator ? arrayIncludesWith : arrayIncludes,
3140           length = arrays[0].length,
3141           othLength = arrays.length,
3142           othIndex = othLength,
3143           caches = Array(othLength),
3144           maxLength = Infinity,
3145           result = [];
3146
3147       while (othIndex--) {
3148         var array = arrays[othIndex];
3149         if (othIndex && iteratee) {
3150           array = arrayMap(array, baseUnary(iteratee));
3151         }
3152         maxLength = nativeMin(array.length, maxLength);
3153         caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3154           ? new SetCache(othIndex && array)
3155           : undefined;
3156       }
3157       array = arrays[0];
3158
3159       var index = -1,
3160           seen = caches[0];
3161
3162       outer:
3163       while (++index < length && result.length < maxLength) {
3164         var value = array[index],
3165             computed = iteratee ? iteratee(value) : value;
3166
3167         value = (comparator || value !== 0) ? value : 0;
3168         if (!(seen
3169               ? cacheHas(seen, computed)
3170               : includes(result, computed, comparator)
3171             )) {
3172           othIndex = othLength;
3173           while (--othIndex) {
3174             var cache = caches[othIndex];
3175             if (!(cache
3176                   ? cacheHas(cache, computed)
3177                   : includes(arrays[othIndex], computed, comparator))
3178                 ) {
3179               continue outer;
3180             }
3181           }
3182           if (seen) {
3183             seen.push(computed);
3184           }
3185           result.push(value);
3186         }
3187       }
3188       return result;
3189     }
3190
3191     /**
3192      * The base implementation of `_.invert` and `_.invertBy` which inverts
3193      * `object` with values transformed by `iteratee` and set by `setter`.
3194      *
3195      * @private
3196      * @param {Object} object The object to iterate over.
3197      * @param {Function} setter The function to set `accumulator` values.
3198      * @param {Function} iteratee The iteratee to transform values.
3199      * @param {Object} accumulator The initial inverted object.
3200      * @returns {Function} Returns `accumulator`.
3201      */
3202     function baseInverter(object, setter, iteratee, accumulator) {
3203       baseForOwn(object, function(value, key, object) {
3204         setter(accumulator, iteratee(value), key, object);
3205       });
3206       return accumulator;
3207     }
3208
3209     /**
3210      * The base implementation of `_.invoke` without support for individual
3211      * method arguments.
3212      *
3213      * @private
3214      * @param {Object} object The object to query.
3215      * @param {Array|string} path The path of the method to invoke.
3216      * @param {Array} args The arguments to invoke the method with.
3217      * @returns {*} Returns the result of the invoked method.
3218      */
3219     function baseInvoke(object, path, args) {
3220       path = castPath(path, object);
3221       object = parent(object, path);
3222       var func = object == null ? object : object[toKey(last(path))];
3223       return func == null ? undefined : apply(func, object, args);
3224     }
3225
3226     /**
3227      * The base implementation of `_.isArguments`.
3228      *
3229      * @private
3230      * @param {*} value The value to check.
3231      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3232      */
3233     function baseIsArguments(value) {
3234       return isObjectLike(value) && baseGetTag(value) == argsTag;
3235     }
3236
3237     /**
3238      * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3239      *
3240      * @private
3241      * @param {*} value The value to check.
3242      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3243      */
3244     function baseIsArrayBuffer(value) {
3245       return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3246     }
3247
3248     /**
3249      * The base implementation of `_.isDate` without Node.js optimizations.
3250      *
3251      * @private
3252      * @param {*} value The value to check.
3253      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3254      */
3255     function baseIsDate(value) {
3256       return isObjectLike(value) && baseGetTag(value) == dateTag;
3257     }
3258
3259     /**
3260      * The base implementation of `_.isEqual` which supports partial comparisons
3261      * and tracks traversed objects.
3262      *
3263      * @private
3264      * @param {*} value The value to compare.
3265      * @param {*} other The other value to compare.
3266      * @param {boolean} bitmask The bitmask flags.
3267      *  1 - Unordered comparison
3268      *  2 - Partial comparison
3269      * @param {Function} [customizer] The function to customize comparisons.
3270      * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3271      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3272      */
3273     function baseIsEqual(value, other, bitmask, customizer, stack) {
3274       if (value === other) {
3275         return true;
3276       }
3277       if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3278         return value !== value && other !== other;
3279       }
3280       return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3281     }
3282
3283     /**
3284      * A specialized version of `baseIsEqual` for arrays and objects which performs
3285      * deep comparisons and tracks traversed objects enabling objects with circular
3286      * references to be compared.
3287      *
3288      * @private
3289      * @param {Object} object The object to compare.
3290      * @param {Object} other The other object to compare.
3291      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3292      * @param {Function} customizer The function to customize comparisons.
3293      * @param {Function} equalFunc The function to determine equivalents of values.
3294      * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3295      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3296      */
3297     function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3298       var objIsArr = isArray(object),
3299           othIsArr = isArray(other),
3300           objTag = objIsArr ? arrayTag : getTag(object),
3301           othTag = othIsArr ? arrayTag : getTag(other);
3302
3303       objTag = objTag == argsTag ? objectTag : objTag;
3304       othTag = othTag == argsTag ? objectTag : othTag;
3305
3306       var objIsObj = objTag == objectTag,
3307           othIsObj = othTag == objectTag,
3308           isSameTag = objTag == othTag;
3309
3310       if (isSameTag && isBuffer(object)) {
3311         if (!isBuffer(other)) {
3312           return false;
3313         }
3314         objIsArr = true;
3315         objIsObj = false;
3316       }
3317       if (isSameTag && !objIsObj) {
3318         stack || (stack = new Stack);
3319         return (objIsArr || isTypedArray(object))
3320           ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3321           : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3322       }
3323       if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3324         var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3325             othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3326
3327         if (objIsWrapped || othIsWrapped) {
3328           var objUnwrapped = objIsWrapped ? object.value() : object,
3329               othUnwrapped = othIsWrapped ? other.value() : other;
3330
3331           stack || (stack = new Stack);
3332           return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3333         }
3334       }
3335       if (!isSameTag) {
3336         return false;
3337       }
3338       stack || (stack = new Stack);
3339       return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3340     }
3341
3342     /**
3343      * The base implementation of `_.isMap` without Node.js optimizations.
3344      *
3345      * @private
3346      * @param {*} value The value to check.
3347      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3348      */
3349     function baseIsMap(value) {
3350       return isObjectLike(value) && getTag(value) == mapTag;
3351     }
3352
3353     /**
3354      * The base implementation of `_.isMatch` without support for iteratee shorthands.
3355      *
3356      * @private
3357      * @param {Object} object The object to inspect.
3358      * @param {Object} source The object of property values to match.
3359      * @param {Array} matchData The property names, values, and compare flags to match.
3360      * @param {Function} [customizer] The function to customize comparisons.
3361      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3362      */
3363     function baseIsMatch(object, source, matchData, customizer) {
3364       var index = matchData.length,
3365           length = index,
3366           noCustomizer = !customizer;
3367
3368       if (object == null) {
3369         return !length;
3370       }
3371       object = Object(object);
3372       while (index--) {
3373         var data = matchData[index];
3374         if ((noCustomizer && data[2])
3375               ? data[1] !== object[data[0]]
3376               : !(data[0] in object)
3377             ) {
3378           return false;
3379         }
3380       }
3381       while (++index < length) {
3382         data = matchData[index];
3383         var key = data[0],
3384             objValue = object[key],
3385             srcValue = data[1];
3386
3387         if (noCustomizer && data[2]) {
3388           if (objValue === undefined && !(key in object)) {
3389             return false;
3390           }
3391         } else {
3392           var stack = new Stack;
3393           if (customizer) {
3394             var result = customizer(objValue, srcValue, key, object, source, stack);
3395           }
3396           if (!(result === undefined
3397                 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
3398                 : result
3399               )) {
3400             return false;
3401           }
3402         }
3403       }
3404       return true;
3405     }
3406
3407     /**
3408      * The base implementation of `_.isNative` without bad shim checks.
3409      *
3410      * @private
3411      * @param {*} value The value to check.
3412      * @returns {boolean} Returns `true` if `value` is a native function,
3413      *  else `false`.
3414      */
3415     function baseIsNative(value) {
3416       if (!isObject(value) || isMasked(value)) {
3417         return false;
3418       }
3419       var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3420       return pattern.test(toSource(value));
3421     }
3422
3423     /**
3424      * The base implementation of `_.isRegExp` without Node.js optimizations.
3425      *
3426      * @private
3427      * @param {*} value The value to check.
3428      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3429      */
3430     function baseIsRegExp(value) {
3431       return isObjectLike(value) && baseGetTag(value) == regexpTag;
3432     }
3433
3434     /**
3435      * The base implementation of `_.isSet` without Node.js optimizations.
3436      *
3437      * @private
3438      * @param {*} value The value to check.
3439      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3440      */
3441     function baseIsSet(value) {
3442       return isObjectLike(value) && getTag(value) == setTag;
3443     }
3444
3445     /**
3446      * The base implementation of `_.isTypedArray` without Node.js optimizations.
3447      *
3448      * @private
3449      * @param {*} value The value to check.
3450      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3451      */
3452     function baseIsTypedArray(value) {
3453       return isObjectLike(value) &&
3454         isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3455     }
3456
3457     /**
3458      * The base implementation of `_.iteratee`.
3459      *
3460      * @private
3461      * @param {*} [value=_.identity] The value to convert to an iteratee.
3462      * @returns {Function} Returns the iteratee.
3463      */
3464     function baseIteratee(value) {
3465       // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3466       // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3467       if (typeof value == 'function') {
3468         return value;
3469       }
3470       if (value == null) {
3471         return identity;
3472       }
3473       if (typeof value == 'object') {
3474         return isArray(value)
3475           ? baseMatchesProperty(value[0], value[1])
3476           : baseMatches(value);
3477       }
3478       return property(value);
3479     }
3480
3481     /**
3482      * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3483      *
3484      * @private
3485      * @param {Object} object The object to query.
3486      * @returns {Array} Returns the array of property names.
3487      */
3488     function baseKeys(object) {
3489       if (!isPrototype(object)) {
3490         return nativeKeys(object);
3491       }
3492       var result = [];
3493       for (var key in Object(object)) {
3494         if (hasOwnProperty.call(object, key) && key != 'constructor') {
3495           result.push(key);
3496         }
3497       }
3498       return result;
3499     }
3500
3501     /**
3502      * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3503      *
3504      * @private
3505      * @param {Object} object The object to query.
3506      * @returns {Array} Returns the array of property names.
3507      */
3508     function baseKeysIn(object) {
3509       if (!isObject(object)) {
3510         return nativeKeysIn(object);
3511       }
3512       var isProto = isPrototype(object),
3513           result = [];
3514
3515       for (var key in object) {
3516         if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3517           result.push(key);
3518         }
3519       }
3520       return result;
3521     }
3522
3523     /**
3524      * The base implementation of `_.lt` which doesn't coerce arguments.
3525      *
3526      * @private
3527      * @param {*} value The value to compare.
3528      * @param {*} other The other value to compare.
3529      * @returns {boolean} Returns `true` if `value` is less than `other`,
3530      *  else `false`.
3531      */
3532     function baseLt(value, other) {
3533       return value < other;
3534     }
3535
3536     /**
3537      * The base implementation of `_.map` without support for iteratee shorthands.
3538      *
3539      * @private
3540      * @param {Array|Object} collection The collection to iterate over.
3541      * @param {Function} iteratee The function invoked per iteration.
3542      * @returns {Array} Returns the new mapped array.
3543      */
3544     function baseMap(collection, iteratee) {
3545       var index = -1,
3546           result = isArrayLike(collection) ? Array(collection.length) : [];
3547
3548       baseEach(collection, function(value, key, collection) {
3549         result[++index] = iteratee(value, key, collection);
3550       });
3551       return result;
3552     }
3553
3554     /**
3555      * The base implementation of `_.matches` which doesn't clone `source`.
3556      *
3557      * @private
3558      * @param {Object} source The object of property values to match.
3559      * @returns {Function} Returns the new spec function.
3560      */
3561     function baseMatches(source) {
3562       var matchData = getMatchData(source);
3563       if (matchData.length == 1 && matchData[0][2]) {
3564         return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3565       }
3566       return function(object) {
3567         return object === source || baseIsMatch(object, source, matchData);
3568       };
3569     }
3570
3571     /**
3572      * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3573      *
3574      * @private
3575      * @param {string} path The path of the property to get.
3576      * @param {*} srcValue The value to match.
3577      * @returns {Function} Returns the new spec function.
3578      */
3579     function baseMatchesProperty(path, srcValue) {
3580       if (isKey(path) && isStrictComparable(srcValue)) {
3581         return matchesStrictComparable(toKey(path), srcValue);
3582       }
3583       return function(object) {
3584         var objValue = get(object, path);
3585         return (objValue === undefined && objValue === srcValue)
3586           ? hasIn(object, path)
3587           : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3588       };
3589     }
3590
3591     /**
3592      * The base implementation of `_.merge` without support for multiple sources.
3593      *
3594      * @private
3595      * @param {Object} object The destination object.
3596      * @param {Object} source The source object.
3597      * @param {number} srcIndex The index of `source`.
3598      * @param {Function} [customizer] The function to customize merged values.
3599      * @param {Object} [stack] Tracks traversed source values and their merged
3600      *  counterparts.
3601      */
3602     function baseMerge(object, source, srcIndex, customizer, stack) {
3603       if (object === source) {
3604         return;
3605       }
3606       baseFor(source, function(srcValue, key) {
3607         stack || (stack = new Stack);
3608         if (isObject(srcValue)) {
3609           baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3610         }
3611         else {
3612           var newValue = customizer
3613             ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
3614             : undefined;
3615
3616           if (newValue === undefined) {
3617             newValue = srcValue;
3618           }
3619           assignMergeValue(object, key, newValue);
3620         }
3621       }, keysIn);
3622     }
3623
3624     /**
3625      * A specialized version of `baseMerge` for arrays and objects which performs
3626      * deep merges and tracks traversed objects enabling objects with circular
3627      * references to be merged.
3628      *
3629      * @private
3630      * @param {Object} object The destination object.
3631      * @param {Object} source The source object.
3632      * @param {string} key The key of the value to merge.
3633      * @param {number} srcIndex The index of `source`.
3634      * @param {Function} mergeFunc The function to merge values.
3635      * @param {Function} [customizer] The function to customize assigned values.
3636      * @param {Object} [stack] Tracks traversed source values and their merged
3637      *  counterparts.
3638      */
3639     function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3640       var objValue = safeGet(object, key),
3641           srcValue = safeGet(source, key),
3642           stacked = stack.get(srcValue);
3643
3644       if (stacked) {
3645         assignMergeValue(object, key, stacked);
3646         return;
3647       }
3648       var newValue = customizer
3649         ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3650         : undefined;
3651
3652       var isCommon = newValue === undefined;
3653
3654       if (isCommon) {
3655         var isArr = isArray(srcValue),
3656             isBuff = !isArr && isBuffer(srcValue),
3657             isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3658
3659         newValue = srcValue;
3660         if (isArr || isBuff || isTyped) {
3661           if (isArray(objValue)) {
3662             newValue = objValue;
3663           }
3664           else if (isArrayLikeObject(objValue)) {
3665             newValue = copyArray(objValue);
3666           }
3667           else if (isBuff) {
3668             isCommon = false;
3669             newValue = cloneBuffer(srcValue, true);
3670           }
3671           else if (isTyped) {
3672             isCommon = false;
3673             newValue = cloneTypedArray(srcValue, true);
3674           }
3675           else {
3676             newValue = [];
3677           }
3678         }
3679         else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3680           newValue = objValue;
3681           if (isArguments(objValue)) {
3682             newValue = toPlainObject(objValue);
3683           }
3684           else if (!isObject(objValue) || isFunction(objValue)) {
3685             newValue = initCloneObject(srcValue);
3686           }
3687         }
3688         else {
3689           isCommon = false;
3690         }
3691       }
3692       if (isCommon) {
3693         // Recursively merge objects and arrays (susceptible to call stack limits).
3694         stack.set(srcValue, newValue);
3695         mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3696         stack['delete'](srcValue);
3697       }
3698       assignMergeValue(object, key, newValue);
3699     }
3700
3701     /**
3702      * The base implementation of `_.nth` which doesn't coerce arguments.
3703      *
3704      * @private
3705      * @param {Array} array The array to query.
3706      * @param {number} n The index of the element to return.
3707      * @returns {*} Returns the nth element of `array`.
3708      */
3709     function baseNth(array, n) {
3710       var length = array.length;
3711       if (!length) {
3712         return;
3713       }
3714       n += n < 0 ? length : 0;
3715       return isIndex(n, length) ? array[n] : undefined;
3716     }
3717
3718     /**
3719      * The base implementation of `_.orderBy` without param guards.
3720      *
3721      * @private
3722      * @param {Array|Object} collection The collection to iterate over.
3723      * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
3724      * @param {string[]} orders The sort orders of `iteratees`.
3725      * @returns {Array} Returns the new sorted array.
3726      */
3727     function baseOrderBy(collection, iteratees, orders) {
3728       var index = -1;
3729       iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
3730
3731       var result = baseMap(collection, function(value, key, collection) {
3732         var criteria = arrayMap(iteratees, function(iteratee) {
3733           return iteratee(value);
3734         });
3735         return { 'criteria': criteria, 'index': ++index, 'value': value };
3736       });
3737
3738       return baseSortBy(result, function(object, other) {
3739         return compareMultiple(object, other, orders);
3740       });
3741     }
3742
3743     /**
3744      * The base implementation of `_.pick` without support for individual
3745      * property identifiers.
3746      *
3747      * @private
3748      * @param {Object} object The source object.
3749      * @param {string[]} paths The property paths to pick.
3750      * @returns {Object} Returns the new object.
3751      */
3752     function basePick(object, paths) {
3753       return basePickBy(object, paths, function(value, path) {
3754         return hasIn(object, path);
3755       });
3756     }
3757
3758     /**
3759      * The base implementation of  `_.pickBy` without support for iteratee shorthands.
3760      *
3761      * @private
3762      * @param {Object} object The source object.
3763      * @param {string[]} paths The property paths to pick.
3764      * @param {Function} predicate The function invoked per property.
3765      * @returns {Object} Returns the new object.
3766      */
3767     function basePickBy(object, paths, predicate) {
3768       var index = -1,
3769           length = paths.length,
3770           result = {};
3771
3772       while (++index < length) {
3773         var path = paths[index],
3774             value = baseGet(object, path);
3775
3776         if (predicate(value, path)) {
3777           baseSet(result, castPath(path, object), value);
3778         }
3779       }
3780       return result;
3781     }
3782
3783     /**
3784      * A specialized version of `baseProperty` which supports deep paths.
3785      *
3786      * @private
3787      * @param {Array|string} path The path of the property to get.
3788      * @returns {Function} Returns the new accessor function.
3789      */
3790     function basePropertyDeep(path) {
3791       return function(object) {
3792         return baseGet(object, path);
3793       };
3794     }
3795
3796     /**
3797      * The base implementation of `_.pullAllBy` without support for iteratee
3798      * shorthands.
3799      *
3800      * @private
3801      * @param {Array} array The array to modify.
3802      * @param {Array} values The values to remove.
3803      * @param {Function} [iteratee] The iteratee invoked per element.
3804      * @param {Function} [comparator] The comparator invoked per element.
3805      * @returns {Array} Returns `array`.
3806      */
3807     function basePullAll(array, values, iteratee, comparator) {
3808       var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3809           index = -1,
3810           length = values.length,
3811           seen = array;
3812
3813       if (array === values) {
3814         values = copyArray(values);
3815       }
3816       if (iteratee) {
3817         seen = arrayMap(array, baseUnary(iteratee));
3818       }
3819       while (++index < length) {
3820         var fromIndex = 0,
3821             value = values[index],
3822             computed = iteratee ? iteratee(value) : value;
3823
3824         while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3825           if (seen !== array) {
3826             splice.call(seen, fromIndex, 1);
3827           }
3828           splice.call(array, fromIndex, 1);
3829         }
3830       }
3831       return array;
3832     }
3833
3834     /**
3835      * The base implementation of `_.pullAt` without support for individual
3836      * indexes or capturing the removed elements.
3837      *
3838      * @private
3839      * @param {Array} array The array to modify.
3840      * @param {number[]} indexes The indexes of elements to remove.
3841      * @returns {Array} Returns `array`.
3842      */
3843     function basePullAt(array, indexes) {
3844       var length = array ? indexes.length : 0,
3845           lastIndex = length - 1;
3846
3847       while (length--) {
3848         var index = indexes[length];
3849         if (length == lastIndex || index !== previous) {
3850           var previous = index;
3851           if (isIndex(index)) {
3852             splice.call(array, index, 1);
3853           } else {
3854             baseUnset(array, index);
3855           }
3856         }
3857       }
3858       return array;
3859     }
3860
3861     /**
3862      * The base implementation of `_.random` without support for returning
3863      * floating-point numbers.
3864      *
3865      * @private
3866      * @param {number} lower The lower bound.
3867      * @param {number} upper The upper bound.
3868      * @returns {number} Returns the random number.
3869      */
3870     function baseRandom(lower, upper) {
3871       return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
3872     }
3873
3874     /**
3875      * The base implementation of `_.range` and `_.rangeRight` which doesn't
3876      * coerce arguments.
3877      *
3878      * @private
3879      * @param {number} start The start of the range.
3880      * @param {number} end The end of the range.
3881      * @param {number} step The value to increment or decrement by.
3882      * @param {boolean} [fromRight] Specify iterating from right to left.
3883      * @returns {Array} Returns the range of numbers.
3884      */
3885     function baseRange(start, end, step, fromRight) {
3886       var index = -1,
3887           length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
3888           result = Array(length);
3889
3890       while (length--) {
3891         result[fromRight ? length : ++index] = start;
3892         start += step;
3893       }
3894       return result;
3895     }
3896
3897     /**
3898      * The base implementation of `_.repeat` which doesn't coerce arguments.
3899      *
3900      * @private
3901      * @param {string} string The string to repeat.
3902      * @param {number} n The number of times to repeat the string.
3903      * @returns {string} Returns the repeated string.
3904      */
3905     function baseRepeat(string, n) {
3906       var result = '';
3907       if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
3908         return result;
3909       }
3910       // Leverage the exponentiation by squaring algorithm for a faster repeat.
3911       // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
3912       do {
3913         if (n % 2) {
3914           result += string;
3915         }
3916         n = nativeFloor(n / 2);
3917         if (n) {
3918           string += string;
3919         }
3920       } while (n);
3921
3922       return result;
3923     }
3924
3925     /**
3926      * The base implementation of `_.rest` which doesn't validate or coerce arguments.
3927      *
3928      * @private
3929      * @param {Function} func The function to apply a rest parameter to.
3930      * @param {number} [start=func.length-1] The start position of the rest parameter.
3931      * @returns {Function} Returns the new function.
3932      */
3933     function baseRest(func, start) {
3934       return setToString(overRest(func, start, identity), func + '');
3935     }
3936
3937     /**
3938      * The base implementation of `_.sample`.
3939      *
3940      * @private
3941      * @param {Array|Object} collection The collection to sample.
3942      * @returns {*} Returns the random element.
3943      */
3944     function baseSample(collection) {
3945       return arraySample(values(collection));
3946     }
3947
3948     /**
3949      * The base implementation of `_.sampleSize` without param guards.
3950      *
3951      * @private
3952      * @param {Array|Object} collection The collection to sample.
3953      * @param {number} n The number of elements to sample.
3954      * @returns {Array} Returns the random elements.
3955      */
3956     function baseSampleSize(collection, n) {
3957       var array = values(collection);
3958       return shuffleSelf(array, baseClamp(n, 0, array.length));
3959     }
3960
3961     /**
3962      * The base implementation of `_.set`.
3963      *
3964      * @private
3965      * @param {Object} object The object to modify.
3966      * @param {Array|string} path The path of the property to set.
3967      * @param {*} value The value to set.
3968      * @param {Function} [customizer] The function to customize path creation.
3969      * @returns {Object} Returns `object`.
3970      */
3971     function baseSet(object, path, value, customizer) {
3972       if (!isObject(object)) {
3973         return object;
3974       }
3975       path = castPath(path, object);
3976
3977       var index = -1,
3978           length = path.length,
3979           lastIndex = length - 1,
3980           nested = object;
3981
3982       while (nested != null && ++index < length) {
3983         var key = toKey(path[index]),
3984             newValue = value;
3985
3986         if (index != lastIndex) {
3987           var objValue = nested[key];
3988           newValue = customizer ? customizer(objValue, key, nested) : undefined;
3989           if (newValue === undefined) {
3990             newValue = isObject(objValue)
3991               ? objValue
3992               : (isIndex(path[index + 1]) ? [] : {});
3993           }
3994         }
3995         assignValue(nested, key, newValue);
3996         nested = nested[key];
3997       }
3998       return object;
3999     }
4000
4001     /**
4002      * The base implementation of `setData` without support for hot loop shorting.
4003      *
4004      * @private
4005      * @param {Function} func The function to associate metadata with.
4006      * @param {*} data The metadata.
4007      * @returns {Function} Returns `func`.
4008      */
4009     var baseSetData = !metaMap ? identity : function(func, data) {
4010       metaMap.set(func, data);
4011       return func;
4012     };
4013
4014     /**
4015      * The base implementation of `setToString` without support for hot loop shorting.
4016      *
4017      * @private
4018      * @param {Function} func The function to modify.
4019      * @param {Function} string The `toString` result.
4020      * @returns {Function} Returns `func`.
4021      */
4022     var baseSetToString = !defineProperty ? identity : function(func, string) {
4023       return defineProperty(func, 'toString', {
4024         'configurable': true,
4025         'enumerable': false,
4026         'value': constant(string),
4027         'writable': true
4028       });
4029     };
4030
4031     /**
4032      * The base implementation of `_.shuffle`.
4033      *
4034      * @private
4035      * @param {Array|Object} collection The collection to shuffle.
4036      * @returns {Array} Returns the new shuffled array.
4037      */
4038     function baseShuffle(collection) {
4039       return shuffleSelf(values(collection));
4040     }
4041
4042     /**
4043      * The base implementation of `_.slice` without an iteratee call guard.
4044      *
4045      * @private
4046      * @param {Array} array The array to slice.
4047      * @param {number} [start=0] The start position.
4048      * @param {number} [end=array.length] The end position.
4049      * @returns {Array} Returns the slice of `array`.
4050      */
4051     function baseSlice(array, start, end) {
4052       var index = -1,
4053           length = array.length;
4054
4055       if (start < 0) {
4056         start = -start > length ? 0 : (length + start);
4057       }
4058       end = end > length ? length : end;
4059       if (end < 0) {
4060         end += length;
4061       }
4062       length = start > end ? 0 : ((end - start) >>> 0);
4063       start >>>= 0;
4064
4065       var result = Array(length);
4066       while (++index < length) {
4067         result[index] = array[index + start];
4068       }
4069       return result;
4070     }
4071
4072     /**
4073      * The base implementation of `_.some` without support for iteratee shorthands.
4074      *
4075      * @private
4076      * @param {Array|Object} collection The collection to iterate over.
4077      * @param {Function} predicate The function invoked per iteration.
4078      * @returns {boolean} Returns `true` if any element passes the predicate check,
4079      *  else `false`.
4080      */
4081     function baseSome(collection, predicate) {
4082       var result;
4083
4084       baseEach(collection, function(value, index, collection) {
4085         result = predicate(value, index, collection);
4086         return !result;
4087       });
4088       return !!result;
4089     }
4090
4091     /**
4092      * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
4093      * performs a binary search of `array` to determine the index at which `value`
4094      * should be inserted into `array` in order to maintain its sort order.
4095      *
4096      * @private
4097      * @param {Array} array The sorted array to inspect.
4098      * @param {*} value The value to evaluate.
4099      * @param {boolean} [retHighest] Specify returning the highest qualified index.
4100      * @returns {number} Returns the index at which `value` should be inserted
4101      *  into `array`.
4102      */
4103     function baseSortedIndex(array, value, retHighest) {
4104       var low = 0,
4105           high = array == null ? low : array.length;
4106
4107       if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4108         while (low < high) {
4109           var mid = (low + high) >>> 1,
4110               computed = array[mid];
4111
4112           if (computed !== null && !isSymbol(computed) &&
4113               (retHighest ? (computed <= value) : (computed < value))) {
4114             low = mid + 1;
4115           } else {
4116             high = mid;
4117           }
4118         }
4119         return high;
4120       }
4121       return baseSortedIndexBy(array, value, identity, retHighest);
4122     }
4123
4124     /**
4125      * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
4126      * which invokes `iteratee` for `value` and each element of `array` to compute
4127      * their sort ranking. The iteratee is invoked with one argument; (value).
4128      *
4129      * @private
4130      * @param {Array} array The sorted array to inspect.
4131      * @param {*} value The value to evaluate.
4132      * @param {Function} iteratee The iteratee invoked per element.
4133      * @param {boolean} [retHighest] Specify returning the highest qualified index.
4134      * @returns {number} Returns the index at which `value` should be inserted
4135      *  into `array`.
4136      */
4137     function baseSortedIndexBy(array, value, iteratee, retHighest) {
4138       value = iteratee(value);
4139
4140       var low = 0,
4141           high = array == null ? 0 : array.length,
4142           valIsNaN = value !== value,
4143           valIsNull = value === null,
4144           valIsSymbol = isSymbol(value),
4145           valIsUndefined = value === undefined;
4146
4147       while (low < high) {
4148         var mid = nativeFloor((low + high) / 2),
4149             computed = iteratee(array[mid]),
4150             othIsDefined = computed !== undefined,
4151             othIsNull = computed === null,
4152             othIsReflexive = computed === computed,
4153             othIsSymbol = isSymbol(computed);
4154
4155         if (valIsNaN) {
4156           var setLow = retHighest || othIsReflexive;
4157         } else if (valIsUndefined) {
4158           setLow = othIsReflexive && (retHighest || othIsDefined);
4159         } else if (valIsNull) {
4160           setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
4161         } else if (valIsSymbol) {
4162           setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
4163         } else if (othIsNull || othIsSymbol) {
4164           setLow = false;
4165         } else {
4166           setLow = retHighest ? (computed <= value) : (computed < value);
4167         }
4168         if (setLow) {
4169           low = mid + 1;
4170         } else {
4171           high = mid;
4172         }
4173       }
4174       return nativeMin(high, MAX_ARRAY_INDEX);
4175     }
4176
4177     /**
4178      * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4179      * support for iteratee shorthands.
4180      *
4181      * @private
4182      * @param {Array} array The array to inspect.
4183      * @param {Function} [iteratee] The iteratee invoked per element.
4184      * @returns {Array} Returns the new duplicate free array.
4185      */
4186     function baseSortedUniq(array, iteratee) {
4187       var index = -1,
4188           length = array.length,
4189           resIndex = 0,
4190           result = [];
4191
4192       while (++index < length) {
4193         var value = array[index],
4194             computed = iteratee ? iteratee(value) : value;
4195
4196         if (!index || !eq(computed, seen)) {
4197           var seen = computed;
4198           result[resIndex++] = value === 0 ? 0 : value;
4199         }
4200       }
4201       return result;
4202     }
4203
4204     /**
4205      * The base implementation of `_.toNumber` which doesn't ensure correct
4206      * conversions of binary, hexadecimal, or octal string values.
4207      *
4208      * @private
4209      * @param {*} value The value to process.
4210      * @returns {number} Returns the number.
4211      */
4212     function baseToNumber(value) {
4213       if (typeof value == 'number') {
4214         return value;
4215       }
4216       if (isSymbol(value)) {
4217         return NAN;
4218       }
4219       return +value;
4220     }
4221
4222     /**
4223      * The base implementation of `_.toString` which doesn't convert nullish
4224      * values to empty strings.
4225      *
4226      * @private
4227      * @param {*} value The value to process.
4228      * @returns {string} Returns the string.
4229      */
4230     function baseToString(value) {
4231       // Exit early for strings to avoid a performance hit in some environments.
4232       if (typeof value == 'string') {
4233         return value;
4234       }
4235       if (isArray(value)) {
4236         // Recursively convert values (susceptible to call stack limits).
4237         return arrayMap(value, baseToString) + '';
4238       }
4239       if (isSymbol(value)) {
4240         return symbolToString ? symbolToString.call(value) : '';
4241       }
4242       var result = (value + '');
4243       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4244     }
4245
4246     /**
4247      * The base implementation of `_.uniqBy` without support for iteratee shorthands.
4248      *
4249      * @private
4250      * @param {Array} array The array to inspect.
4251      * @param {Function} [iteratee] The iteratee invoked per element.
4252      * @param {Function} [comparator] The comparator invoked per element.
4253      * @returns {Array} Returns the new duplicate free array.
4254      */
4255     function baseUniq(array, iteratee, comparator) {
4256       var index = -1,
4257           includes = arrayIncludes,
4258           length = array.length,
4259           isCommon = true,
4260           result = [],
4261           seen = result;
4262
4263       if (comparator) {
4264         isCommon = false;
4265         includes = arrayIncludesWith;
4266       }
4267       else if (length >= LARGE_ARRAY_SIZE) {
4268         var set = iteratee ? null : createSet(array);
4269         if (set) {
4270           return setToArray(set);
4271         }
4272         isCommon = false;
4273         includes = cacheHas;
4274         seen = new SetCache;
4275       }
4276       else {
4277         seen = iteratee ? [] : result;
4278       }
4279       outer:
4280       while (++index < length) {
4281         var value = array[index],
4282             computed = iteratee ? iteratee(value) : value;
4283
4284         value = (comparator || value !== 0) ? value : 0;
4285         if (isCommon && computed === computed) {
4286           var seenIndex = seen.length;
4287           while (seenIndex--) {
4288             if (seen[seenIndex] === computed) {
4289               continue outer;
4290             }
4291           }
4292           if (iteratee) {
4293             seen.push(computed);
4294           }
4295           result.push(value);
4296         }
4297         else if (!includes(seen, computed, comparator)) {
4298           if (seen !== result) {
4299             seen.push(computed);
4300           }
4301           result.push(value);
4302         }
4303       }
4304       return result;
4305     }
4306
4307     /**
4308      * The base implementation of `_.unset`.
4309      *
4310      * @private
4311      * @param {Object} object The object to modify.
4312      * @param {Array|string} path The property path to unset.
4313      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
4314      */
4315     function baseUnset(object, path) {
4316       path = castPath(path, object);
4317       object = parent(object, path);
4318       return object == null || delete object[toKey(last(path))];
4319     }
4320
4321     /**
4322      * The base implementation of `_.update`.
4323      *
4324      * @private
4325      * @param {Object} object The object to modify.
4326      * @param {Array|string} path The path of the property to update.
4327      * @param {Function} updater The function to produce the updated value.
4328      * @param {Function} [customizer] The function to customize path creation.
4329      * @returns {Object} Returns `object`.
4330      */
4331     function baseUpdate(object, path, updater, customizer) {
4332       return baseSet(object, path, updater(baseGet(object, path)), customizer);
4333     }
4334
4335     /**
4336      * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4337      * without support for iteratee shorthands.
4338      *
4339      * @private
4340      * @param {Array} array The array to query.
4341      * @param {Function} predicate The function invoked per iteration.
4342      * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
4343      * @param {boolean} [fromRight] Specify iterating from right to left.
4344      * @returns {Array} Returns the slice of `array`.
4345      */
4346     function baseWhile(array, predicate, isDrop, fromRight) {
4347       var length = array.length,
4348           index = fromRight ? length : -1;
4349
4350       while ((fromRight ? index-- : ++index < length) &&
4351         predicate(array[index], index, array)) {}
4352
4353       return isDrop
4354         ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
4355         : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
4356     }
4357
4358     /**
4359      * The base implementation of `wrapperValue` which returns the result of
4360      * performing a sequence of actions on the unwrapped `value`, where each
4361      * successive action is supplied the return value of the previous.
4362      *
4363      * @private
4364      * @param {*} value The unwrapped value.
4365      * @param {Array} actions Actions to perform to resolve the unwrapped value.
4366      * @returns {*} Returns the resolved value.
4367      */
4368     function baseWrapperValue(value, actions) {
4369       var result = value;
4370       if (result instanceof LazyWrapper) {
4371         result = result.value();
4372       }
4373       return arrayReduce(actions, function(result, action) {
4374         return action.func.apply(action.thisArg, arrayPush([result], action.args));
4375       }, result);
4376     }
4377
4378     /**
4379      * The base implementation of methods like `_.xor`, without support for
4380      * iteratee shorthands, that accepts an array of arrays to inspect.
4381      *
4382      * @private
4383      * @param {Array} arrays The arrays to inspect.
4384      * @param {Function} [iteratee] The iteratee invoked per element.
4385      * @param {Function} [comparator] The comparator invoked per element.
4386      * @returns {Array} Returns the new array of values.
4387      */
4388     function baseXor(arrays, iteratee, comparator) {
4389       var length = arrays.length;
4390       if (length < 2) {
4391         return length ? baseUniq(arrays[0]) : [];
4392       }
4393       var index = -1,
4394           result = Array(length);
4395
4396       while (++index < length) {
4397         var array = arrays[index],
4398             othIndex = -1;
4399
4400         while (++othIndex < length) {
4401           if (othIndex != index) {
4402             result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4403           }
4404         }
4405       }
4406       return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4407     }
4408
4409     /**
4410      * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
4411      *
4412      * @private
4413      * @param {Array} props The property identifiers.
4414      * @param {Array} values The property values.
4415      * @param {Function} assignFunc The function to assign values.
4416      * @returns {Object} Returns the new object.
4417      */
4418     function baseZipObject(props, values, assignFunc) {
4419       var index = -1,
4420           length = props.length,
4421           valsLength = values.length,
4422           result = {};
4423
4424       while (++index < length) {
4425         var value = index < valsLength ? values[index] : undefined;
4426         assignFunc(result, props[index], value);
4427       }
4428       return result;
4429     }
4430
4431     /**
4432      * Casts `value` to an empty array if it's not an array like object.
4433      *
4434      * @private
4435      * @param {*} value The value to inspect.
4436      * @returns {Array|Object} Returns the cast array-like object.
4437      */
4438     function castArrayLikeObject(value) {
4439       return isArrayLikeObject(value) ? value : [];
4440     }
4441
4442     /**
4443      * Casts `value` to `identity` if it's not a function.
4444      *
4445      * @private
4446      * @param {*} value The value to inspect.
4447      * @returns {Function} Returns cast function.
4448      */
4449     function castFunction(value) {
4450       return typeof value == 'function' ? value : identity;
4451     }
4452
4453     /**
4454      * Casts `value` to a path array if it's not one.
4455      *
4456      * @private
4457      * @param {*} value The value to inspect.
4458      * @param {Object} [object] The object to query keys on.
4459      * @returns {Array} Returns the cast property path array.
4460      */
4461     function castPath(value, object) {
4462       if (isArray(value)) {
4463         return value;
4464       }
4465       return isKey(value, object) ? [value] : stringToPath(toString(value));
4466     }
4467
4468     /**
4469      * A `baseRest` alias which can be replaced with `identity` by module
4470      * replacement plugins.
4471      *
4472      * @private
4473      * @type {Function}
4474      * @param {Function} func The function to apply a rest parameter to.
4475      * @returns {Function} Returns the new function.
4476      */
4477     var castRest = baseRest;
4478
4479     /**
4480      * Casts `array` to a slice if it's needed.
4481      *
4482      * @private
4483      * @param {Array} array The array to inspect.
4484      * @param {number} start The start position.
4485      * @param {number} [end=array.length] The end position.
4486      * @returns {Array} Returns the cast slice.
4487      */
4488     function castSlice(array, start, end) {
4489       var length = array.length;
4490       end = end === undefined ? length : end;
4491       return (!start && end >= length) ? array : baseSlice(array, start, end);
4492     }
4493
4494     /**
4495      * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4496      *
4497      * @private
4498      * @param {number|Object} id The timer id or timeout object of the timer to clear.
4499      */
4500     var clearTimeout = ctxClearTimeout || function(id) {
4501       return root.clearTimeout(id);
4502     };
4503
4504     /**
4505      * Creates a clone of  `buffer`.
4506      *
4507      * @private
4508      * @param {Buffer} buffer The buffer to clone.
4509      * @param {boolean} [isDeep] Specify a deep clone.
4510      * @returns {Buffer} Returns the cloned buffer.
4511      */
4512     function cloneBuffer(buffer, isDeep) {
4513       if (isDeep) {
4514         return buffer.slice();
4515       }
4516       var length = buffer.length,
4517           result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4518
4519       buffer.copy(result);
4520       return result;
4521     }
4522
4523     /**
4524      * Creates a clone of `arrayBuffer`.
4525      *
4526      * @private
4527      * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4528      * @returns {ArrayBuffer} Returns the cloned array buffer.
4529      */
4530     function cloneArrayBuffer(arrayBuffer) {
4531       var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4532       new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4533       return result;
4534     }
4535
4536     /**
4537      * Creates a clone of `dataView`.
4538      *
4539      * @private
4540      * @param {Object} dataView The data view to clone.
4541      * @param {boolean} [isDeep] Specify a deep clone.
4542      * @returns {Object} Returns the cloned data view.
4543      */
4544     function cloneDataView(dataView, isDeep) {
4545       var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4546       return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4547     }
4548
4549     /**
4550      * Creates a clone of `regexp`.
4551      *
4552      * @private
4553      * @param {Object} regexp The regexp to clone.
4554      * @returns {Object} Returns the cloned regexp.
4555      */
4556     function cloneRegExp(regexp) {
4557       var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4558       result.lastIndex = regexp.lastIndex;
4559       return result;
4560     }
4561
4562     /**
4563      * Creates a clone of the `symbol` object.
4564      *
4565      * @private
4566      * @param {Object} symbol The symbol object to clone.
4567      * @returns {Object} Returns the cloned symbol object.
4568      */
4569     function cloneSymbol(symbol) {
4570       return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4571     }
4572
4573     /**
4574      * Creates a clone of `typedArray`.
4575      *
4576      * @private
4577      * @param {Object} typedArray The typed array to clone.
4578      * @param {boolean} [isDeep] Specify a deep clone.
4579      * @returns {Object} Returns the cloned typed array.
4580      */
4581     function cloneTypedArray(typedArray, isDeep) {
4582       var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4583       return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4584     }
4585
4586     /**
4587      * Compares values to sort them in ascending order.
4588      *
4589      * @private
4590      * @param {*} value The value to compare.
4591      * @param {*} other The other value to compare.
4592      * @returns {number} Returns the sort order indicator for `value`.
4593      */
4594     function compareAscending(value, other) {
4595       if (value !== other) {
4596         var valIsDefined = value !== undefined,
4597             valIsNull = value === null,
4598             valIsReflexive = value === value,
4599             valIsSymbol = isSymbol(value);
4600
4601         var othIsDefined = other !== undefined,
4602             othIsNull = other === null,
4603             othIsReflexive = other === other,
4604             othIsSymbol = isSymbol(other);
4605
4606         if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4607             (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4608             (valIsNull && othIsDefined && othIsReflexive) ||
4609             (!valIsDefined && othIsReflexive) ||
4610             !valIsReflexive) {
4611           return 1;
4612         }
4613         if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4614             (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4615             (othIsNull && valIsDefined && valIsReflexive) ||
4616             (!othIsDefined && valIsReflexive) ||
4617             !othIsReflexive) {
4618           return -1;
4619         }
4620       }
4621       return 0;
4622     }
4623
4624     /**
4625      * Used by `_.orderBy` to compare multiple properties of a value to another
4626      * and stable sort them.
4627      *
4628      * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4629      * specify an order of "desc" for descending or "asc" for ascending sort order
4630      * of corresponding values.
4631      *
4632      * @private
4633      * @param {Object} object The object to compare.
4634      * @param {Object} other The other object to compare.
4635      * @param {boolean[]|string[]} orders The order to sort by for each property.
4636      * @returns {number} Returns the sort order indicator for `object`.
4637      */
4638     function compareMultiple(object, other, orders) {
4639       var index = -1,
4640           objCriteria = object.criteria,
4641           othCriteria = other.criteria,
4642           length = objCriteria.length,
4643           ordersLength = orders.length;
4644
4645       while (++index < length) {
4646         var result = compareAscending(objCriteria[index], othCriteria[index]);
4647         if (result) {
4648           if (index >= ordersLength) {
4649             return result;
4650           }
4651           var order = orders[index];
4652           return result * (order == 'desc' ? -1 : 1);
4653         }
4654       }
4655       // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
4656       // that causes it, under certain circumstances, to provide the same value for
4657       // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
4658       // for more details.
4659       //
4660       // This also ensures a stable sort in V8 and other engines.
4661       // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
4662       return object.index - other.index;
4663     }
4664
4665     /**
4666      * Creates an array that is the composition of partially applied arguments,
4667      * placeholders, and provided arguments into a single array of arguments.
4668      *
4669      * @private
4670      * @param {Array} args The provided arguments.
4671      * @param {Array} partials The arguments to prepend to those provided.
4672      * @param {Array} holders The `partials` placeholder indexes.
4673      * @params {boolean} [isCurried] Specify composing for a curried function.
4674      * @returns {Array} Returns the new array of composed arguments.
4675      */
4676     function composeArgs(args, partials, holders, isCurried) {
4677       var argsIndex = -1,
4678           argsLength = args.length,
4679           holdersLength = holders.length,
4680           leftIndex = -1,
4681           leftLength = partials.length,
4682           rangeLength = nativeMax(argsLength - holdersLength, 0),
4683           result = Array(leftLength + rangeLength),
4684           isUncurried = !isCurried;
4685
4686       while (++leftIndex < leftLength) {
4687         result[leftIndex] = partials[leftIndex];
4688       }
4689       while (++argsIndex < holdersLength) {
4690         if (isUncurried || argsIndex < argsLength) {
4691           result[holders[argsIndex]] = args[argsIndex];
4692         }
4693       }
4694       while (rangeLength--) {
4695         result[leftIndex++] = args[argsIndex++];
4696       }
4697       return result;
4698     }
4699
4700     /**
4701      * This function is like `composeArgs` except that the arguments composition
4702      * is tailored for `_.partialRight`.
4703      *
4704      * @private
4705      * @param {Array} args The provided arguments.
4706      * @param {Array} partials The arguments to append to those provided.
4707      * @param {Array} holders The `partials` placeholder indexes.
4708      * @params {boolean} [isCurried] Specify composing for a curried function.
4709      * @returns {Array} Returns the new array of composed arguments.
4710      */
4711     function composeArgsRight(args, partials, holders, isCurried) {
4712       var argsIndex = -1,
4713           argsLength = args.length,
4714           holdersIndex = -1,
4715           holdersLength = holders.length,
4716           rightIndex = -1,
4717           rightLength = partials.length,
4718           rangeLength = nativeMax(argsLength - holdersLength, 0),
4719           result = Array(rangeLength + rightLength),
4720           isUncurried = !isCurried;
4721
4722       while (++argsIndex < rangeLength) {
4723         result[argsIndex] = args[argsIndex];
4724       }
4725       var offset = argsIndex;
4726       while (++rightIndex < rightLength) {
4727         result[offset + rightIndex] = partials[rightIndex];
4728       }
4729       while (++holdersIndex < holdersLength) {
4730         if (isUncurried || argsIndex < argsLength) {
4731           result[offset + holders[holdersIndex]] = args[argsIndex++];
4732         }
4733       }
4734       return result;
4735     }
4736
4737     /**
4738      * Copies the values of `source` to `array`.
4739      *
4740      * @private
4741      * @param {Array} source The array to copy values from.
4742      * @param {Array} [array=[]] The array to copy values to.
4743      * @returns {Array} Returns `array`.
4744      */
4745     function copyArray(source, array) {
4746       var index = -1,
4747           length = source.length;
4748
4749       array || (array = Array(length));
4750       while (++index < length) {
4751         array[index] = source[index];
4752       }
4753       return array;
4754     }
4755
4756     /**
4757      * Copies properties of `source` to `object`.
4758      *
4759      * @private
4760      * @param {Object} source The object to copy properties from.
4761      * @param {Array} props The property identifiers to copy.
4762      * @param {Object} [object={}] The object to copy properties to.
4763      * @param {Function} [customizer] The function to customize copied values.
4764      * @returns {Object} Returns `object`.
4765      */
4766     function copyObject(source, props, object, customizer) {
4767       var isNew = !object;
4768       object || (object = {});
4769
4770       var index = -1,
4771           length = props.length;
4772
4773       while (++index < length) {
4774         var key = props[index];
4775
4776         var newValue = customizer
4777           ? customizer(object[key], source[key], key, object, source)
4778           : undefined;
4779
4780         if (newValue === undefined) {
4781           newValue = source[key];
4782         }
4783         if (isNew) {
4784           baseAssignValue(object, key, newValue);
4785         } else {
4786           assignValue(object, key, newValue);
4787         }
4788       }
4789       return object;
4790     }
4791
4792     /**
4793      * Copies own symbols of `source` to `object`.
4794      *
4795      * @private
4796      * @param {Object} source The object to copy symbols from.
4797      * @param {Object} [object={}] The object to copy symbols to.
4798      * @returns {Object} Returns `object`.
4799      */
4800     function copySymbols(source, object) {
4801       return copyObject(source, getSymbols(source), object);
4802     }
4803
4804     /**
4805      * Copies own and inherited symbols of `source` to `object`.
4806      *
4807      * @private
4808      * @param {Object} source The object to copy symbols from.
4809      * @param {Object} [object={}] The object to copy symbols to.
4810      * @returns {Object} Returns `object`.
4811      */
4812     function copySymbolsIn(source, object) {
4813       return copyObject(source, getSymbolsIn(source), object);
4814     }
4815
4816     /**
4817      * Creates a function like `_.groupBy`.
4818      *
4819      * @private
4820      * @param {Function} setter The function to set accumulator values.
4821      * @param {Function} [initializer] The accumulator object initializer.
4822      * @returns {Function} Returns the new aggregator function.
4823      */
4824     function createAggregator(setter, initializer) {
4825       return function(collection, iteratee) {
4826         var func = isArray(collection) ? arrayAggregator : baseAggregator,
4827             accumulator = initializer ? initializer() : {};
4828
4829         return func(collection, setter, getIteratee(iteratee, 2), accumulator);
4830       };
4831     }
4832
4833     /**
4834      * Creates a function like `_.assign`.
4835      *
4836      * @private
4837      * @param {Function} assigner The function to assign values.
4838      * @returns {Function} Returns the new assigner function.
4839      */
4840     function createAssigner(assigner) {
4841       return baseRest(function(object, sources) {
4842         var index = -1,
4843             length = sources.length,
4844             customizer = length > 1 ? sources[length - 1] : undefined,
4845             guard = length > 2 ? sources[2] : undefined;
4846
4847         customizer = (assigner.length > 3 && typeof customizer == 'function')
4848           ? (length--, customizer)
4849           : undefined;
4850
4851         if (guard && isIterateeCall(sources[0], sources[1], guard)) {
4852           customizer = length < 3 ? undefined : customizer;
4853           length = 1;
4854         }
4855         object = Object(object);
4856         while (++index < length) {
4857           var source = sources[index];
4858           if (source) {
4859             assigner(object, source, index, customizer);
4860           }
4861         }
4862         return object;
4863       });
4864     }
4865
4866     /**
4867      * Creates a `baseEach` or `baseEachRight` function.
4868      *
4869      * @private
4870      * @param {Function} eachFunc The function to iterate over a collection.
4871      * @param {boolean} [fromRight] Specify iterating from right to left.
4872      * @returns {Function} Returns the new base function.
4873      */
4874     function createBaseEach(eachFunc, fromRight) {
4875       return function(collection, iteratee) {
4876         if (collection == null) {
4877           return collection;
4878         }
4879         if (!isArrayLike(collection)) {
4880           return eachFunc(collection, iteratee);
4881         }
4882         var length = collection.length,
4883             index = fromRight ? length : -1,
4884             iterable = Object(collection);
4885
4886         while ((fromRight ? index-- : ++index < length)) {
4887           if (iteratee(iterable[index], index, iterable) === false) {
4888             break;
4889           }
4890         }
4891         return collection;
4892       };
4893     }
4894
4895     /**
4896      * Creates a base function for methods like `_.forIn` and `_.forOwn`.
4897      *
4898      * @private
4899      * @param {boolean} [fromRight] Specify iterating from right to left.
4900      * @returns {Function} Returns the new base function.
4901      */
4902     function createBaseFor(fromRight) {
4903       return function(object, iteratee, keysFunc) {
4904         var index = -1,
4905             iterable = Object(object),
4906             props = keysFunc(object),
4907             length = props.length;
4908
4909         while (length--) {
4910           var key = props[fromRight ? length : ++index];
4911           if (iteratee(iterable[key], key, iterable) === false) {
4912             break;
4913           }
4914         }
4915         return object;
4916       };
4917     }
4918
4919     /**
4920      * Creates a function that wraps `func` to invoke it with the optional `this`
4921      * binding of `thisArg`.
4922      *
4923      * @private
4924      * @param {Function} func The function to wrap.
4925      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
4926      * @param {*} [thisArg] The `this` binding of `func`.
4927      * @returns {Function} Returns the new wrapped function.
4928      */
4929     function createBind(func, bitmask, thisArg) {
4930       var isBind = bitmask & WRAP_BIND_FLAG,
4931           Ctor = createCtor(func);
4932
4933       function wrapper() {
4934         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4935         return fn.apply(isBind ? thisArg : this, arguments);
4936       }
4937       return wrapper;
4938     }
4939
4940     /**
4941      * Creates a function like `_.lowerFirst`.
4942      *
4943      * @private
4944      * @param {string} methodName The name of the `String` case method to use.
4945      * @returns {Function} Returns the new case function.
4946      */
4947     function createCaseFirst(methodName) {
4948       return function(string) {
4949         string = toString(string);
4950
4951         var strSymbols = hasUnicode(string)
4952           ? stringToArray(string)
4953           : undefined;
4954
4955         var chr = strSymbols
4956           ? strSymbols[0]
4957           : string.charAt(0);
4958
4959         var trailing = strSymbols
4960           ? castSlice(strSymbols, 1).join('')
4961           : string.slice(1);
4962
4963         return chr[methodName]() + trailing;
4964       };
4965     }
4966
4967     /**
4968      * Creates a function like `_.camelCase`.
4969      *
4970      * @private
4971      * @param {Function} callback The function to combine each word.
4972      * @returns {Function} Returns the new compounder function.
4973      */
4974     function createCompounder(callback) {
4975       return function(string) {
4976         return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
4977       };
4978     }
4979
4980     /**
4981      * Creates a function that produces an instance of `Ctor` regardless of
4982      * whether it was invoked as part of a `new` expression or by `call` or `apply`.
4983      *
4984      * @private
4985      * @param {Function} Ctor The constructor to wrap.
4986      * @returns {Function} Returns the new wrapped function.
4987      */
4988     function createCtor(Ctor) {
4989       return function() {
4990         // Use a `switch` statement to work with class constructors. See
4991         // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
4992         // for more details.
4993         var args = arguments;
4994         switch (args.length) {
4995           case 0: return new Ctor;
4996           case 1: return new Ctor(args[0]);
4997           case 2: return new Ctor(args[0], args[1]);
4998           case 3: return new Ctor(args[0], args[1], args[2]);
4999           case 4: return new Ctor(args[0], args[1], args[2], args[3]);
5000           case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5001           case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5002           case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5003         }
5004         var thisBinding = baseCreate(Ctor.prototype),
5005             result = Ctor.apply(thisBinding, args);
5006
5007         // Mimic the constructor's `return` behavior.
5008         // See https://es5.github.io/#x13.2.2 for more details.
5009         return isObject(result) ? result : thisBinding;
5010       };
5011     }
5012
5013     /**
5014      * Creates a function that wraps `func` to enable currying.
5015      *
5016      * @private
5017      * @param {Function} func The function to wrap.
5018      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5019      * @param {number} arity The arity of `func`.
5020      * @returns {Function} Returns the new wrapped function.
5021      */
5022     function createCurry(func, bitmask, arity) {
5023       var Ctor = createCtor(func);
5024
5025       function wrapper() {
5026         var length = arguments.length,
5027             args = Array(length),
5028             index = length,
5029             placeholder = getHolder(wrapper);
5030
5031         while (index--) {
5032           args[index] = arguments[index];
5033         }
5034         var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5035           ? []
5036           : replaceHolders(args, placeholder);
5037
5038         length -= holders.length;
5039         if (length < arity) {
5040           return createRecurry(
5041             func, bitmask, createHybrid, wrapper.placeholder, undefined,
5042             args, holders, undefined, undefined, arity - length);
5043         }
5044         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5045         return apply(fn, this, args);
5046       }
5047       return wrapper;
5048     }
5049
5050     /**
5051      * Creates a `_.find` or `_.findLast` function.
5052      *
5053      * @private
5054      * @param {Function} findIndexFunc The function to find the collection index.
5055      * @returns {Function} Returns the new find function.
5056      */
5057     function createFind(findIndexFunc) {
5058       return function(collection, predicate, fromIndex) {
5059         var iterable = Object(collection);
5060         if (!isArrayLike(collection)) {
5061           var iteratee = getIteratee(predicate, 3);
5062           collection = keys(collection);
5063           predicate = function(key) { return iteratee(iterable[key], key, iterable); };
5064         }
5065         var index = findIndexFunc(collection, predicate, fromIndex);
5066         return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
5067       };
5068     }
5069
5070     /**
5071      * Creates a `_.flow` or `_.flowRight` function.
5072      *
5073      * @private
5074      * @param {boolean} [fromRight] Specify iterating from right to left.
5075      * @returns {Function} Returns the new flow function.
5076      */
5077     function createFlow(fromRight) {
5078       return flatRest(function(funcs) {
5079         var length = funcs.length,
5080             index = length,
5081             prereq = LodashWrapper.prototype.thru;
5082
5083         if (fromRight) {
5084           funcs.reverse();
5085         }
5086         while (index--) {
5087           var func = funcs[index];
5088           if (typeof func != 'function') {
5089             throw new TypeError(FUNC_ERROR_TEXT);
5090           }
5091           if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5092             var wrapper = new LodashWrapper([], true);
5093           }
5094         }
5095         index = wrapper ? index : length;
5096         while (++index < length) {
5097           func = funcs[index];
5098
5099           var funcName = getFuncName(func),
5100               data = funcName == 'wrapper' ? getData(func) : undefined;
5101
5102           if (data && isLaziable(data[0]) &&
5103                 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
5104                 !data[4].length && data[9] == 1
5105               ) {
5106             wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5107           } else {
5108             wrapper = (func.length == 1 && isLaziable(func))
5109               ? wrapper[funcName]()
5110               : wrapper.thru(func);
5111           }
5112         }
5113         return function() {
5114           var args = arguments,
5115               value = args[0];
5116
5117           if (wrapper && args.length == 1 && isArray(value)) {
5118             return wrapper.plant(value).value();
5119           }
5120           var index = 0,
5121               result = length ? funcs[index].apply(this, args) : value;
5122
5123           while (++index < length) {
5124             result = funcs[index].call(this, result);
5125           }
5126           return result;
5127         };
5128       });
5129     }
5130
5131     /**
5132      * Creates a function that wraps `func` to invoke it with optional `this`
5133      * binding of `thisArg`, partial application, and currying.
5134      *
5135      * @private
5136      * @param {Function|string} func The function or method name to wrap.
5137      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5138      * @param {*} [thisArg] The `this` binding of `func`.
5139      * @param {Array} [partials] The arguments to prepend to those provided to
5140      *  the new function.
5141      * @param {Array} [holders] The `partials` placeholder indexes.
5142      * @param {Array} [partialsRight] The arguments to append to those provided
5143      *  to the new function.
5144      * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
5145      * @param {Array} [argPos] The argument positions of the new function.
5146      * @param {number} [ary] The arity cap of `func`.
5147      * @param {number} [arity] The arity of `func`.
5148      * @returns {Function} Returns the new wrapped function.
5149      */
5150     function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5151       var isAry = bitmask & WRAP_ARY_FLAG,
5152           isBind = bitmask & WRAP_BIND_FLAG,
5153           isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
5154           isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
5155           isFlip = bitmask & WRAP_FLIP_FLAG,
5156           Ctor = isBindKey ? undefined : createCtor(func);
5157
5158       function wrapper() {
5159         var length = arguments.length,
5160             args = Array(length),
5161             index = length;
5162
5163         while (index--) {
5164           args[index] = arguments[index];
5165         }
5166         if (isCurried) {
5167           var placeholder = getHolder(wrapper),
5168               holdersCount = countHolders(args, placeholder);
5169         }
5170         if (partials) {
5171           args = composeArgs(args, partials, holders, isCurried);
5172         }
5173         if (partialsRight) {
5174           args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
5175         }
5176         length -= holdersCount;
5177         if (isCurried && length < arity) {
5178           var newHolders = replaceHolders(args, placeholder);
5179           return createRecurry(
5180             func, bitmask, createHybrid, wrapper.placeholder, thisArg,
5181             args, newHolders, argPos, ary, arity - length
5182           );
5183         }
5184         var thisBinding = isBind ? thisArg : this,
5185             fn = isBindKey ? thisBinding[func] : func;
5186
5187         length = args.length;
5188         if (argPos) {
5189           args = reorder(args, argPos);
5190         } else if (isFlip && length > 1) {
5191           args.reverse();
5192         }
5193         if (isAry && ary < length) {
5194           args.length = ary;
5195         }
5196         if (this && this !== root && this instanceof wrapper) {
5197           fn = Ctor || createCtor(fn);
5198         }
5199         return fn.apply(thisBinding, args);
5200       }
5201       return wrapper;
5202     }
5203
5204     /**
5205      * Creates a function like `_.invertBy`.
5206      *
5207      * @private
5208      * @param {Function} setter The function to set accumulator values.
5209      * @param {Function} toIteratee The function to resolve iteratees.
5210      * @returns {Function} Returns the new inverter function.
5211      */
5212     function createInverter(setter, toIteratee) {
5213       return function(object, iteratee) {
5214         return baseInverter(object, setter, toIteratee(iteratee), {});
5215       };
5216     }
5217
5218     /**
5219      * Creates a function that performs a mathematical operation on two values.
5220      *
5221      * @private
5222      * @param {Function} operator The function to perform the operation.
5223      * @param {number} [defaultValue] The value used for `undefined` arguments.
5224      * @returns {Function} Returns the new mathematical operation function.
5225      */
5226     function createMathOperation(operator, defaultValue) {
5227       return function(value, other) {
5228         var result;
5229         if (value === undefined && other === undefined) {
5230           return defaultValue;
5231         }
5232         if (value !== undefined) {
5233           result = value;
5234         }
5235         if (other !== undefined) {
5236           if (result === undefined) {
5237             return other;
5238           }
5239           if (typeof value == 'string' || typeof other == 'string') {
5240             value = baseToString(value);
5241             other = baseToString(other);
5242           } else {
5243             value = baseToNumber(value);
5244             other = baseToNumber(other);
5245           }
5246           result = operator(value, other);
5247         }
5248         return result;
5249       };
5250     }
5251
5252     /**
5253      * Creates a function like `_.over`.
5254      *
5255      * @private
5256      * @param {Function} arrayFunc The function to iterate over iteratees.
5257      * @returns {Function} Returns the new over function.
5258      */
5259     function createOver(arrayFunc) {
5260       return flatRest(function(iteratees) {
5261         iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5262         return baseRest(function(args) {
5263           var thisArg = this;
5264           return arrayFunc(iteratees, function(iteratee) {
5265             return apply(iteratee, thisArg, args);
5266           });
5267         });
5268       });
5269     }
5270
5271     /**
5272      * Creates the padding for `string` based on `length`. The `chars` string
5273      * is truncated if the number of characters exceeds `length`.
5274      *
5275      * @private
5276      * @param {number} length The padding length.
5277      * @param {string} [chars=' '] The string used as padding.
5278      * @returns {string} Returns the padding for `string`.
5279      */
5280     function createPadding(length, chars) {
5281       chars = chars === undefined ? ' ' : baseToString(chars);
5282
5283       var charsLength = chars.length;
5284       if (charsLength < 2) {
5285         return charsLength ? baseRepeat(chars, length) : chars;
5286       }
5287       var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
5288       return hasUnicode(chars)
5289         ? castSlice(stringToArray(result), 0, length).join('')
5290         : result.slice(0, length);
5291     }
5292
5293     /**
5294      * Creates a function that wraps `func` to invoke it with the `this` binding
5295      * of `thisArg` and `partials` prepended to the arguments it receives.
5296      *
5297      * @private
5298      * @param {Function} func The function to wrap.
5299      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5300      * @param {*} thisArg The `this` binding of `func`.
5301      * @param {Array} partials The arguments to prepend to those provided to
5302      *  the new function.
5303      * @returns {Function} Returns the new wrapped function.
5304      */
5305     function createPartial(func, bitmask, thisArg, partials) {
5306       var isBind = bitmask & WRAP_BIND_FLAG,
5307           Ctor = createCtor(func);
5308
5309       function wrapper() {
5310         var argsIndex = -1,
5311             argsLength = arguments.length,
5312             leftIndex = -1,
5313             leftLength = partials.length,
5314             args = Array(leftLength + argsLength),
5315             fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5316
5317         while (++leftIndex < leftLength) {
5318           args[leftIndex] = partials[leftIndex];
5319         }
5320         while (argsLength--) {
5321           args[leftIndex++] = arguments[++argsIndex];
5322         }
5323         return apply(fn, isBind ? thisArg : this, args);
5324       }
5325       return wrapper;
5326     }
5327
5328     /**
5329      * Creates a `_.range` or `_.rangeRight` function.
5330      *
5331      * @private
5332      * @param {boolean} [fromRight] Specify iterating from right to left.
5333      * @returns {Function} Returns the new range function.
5334      */
5335     function createRange(fromRight) {
5336       return function(start, end, step) {
5337         if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5338           end = step = undefined;
5339         }
5340         // Ensure the sign of `-0` is preserved.
5341         start = toFinite(start);
5342         if (end === undefined) {
5343           end = start;
5344           start = 0;
5345         } else {
5346           end = toFinite(end);
5347         }
5348         step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
5349         return baseRange(start, end, step, fromRight);
5350       };
5351     }
5352
5353     /**
5354      * Creates a function that performs a relational operation on two values.
5355      *
5356      * @private
5357      * @param {Function} operator The function to perform the operation.
5358      * @returns {Function} Returns the new relational operation function.
5359      */
5360     function createRelationalOperation(operator) {
5361       return function(value, other) {
5362         if (!(typeof value == 'string' && typeof other == 'string')) {
5363           value = toNumber(value);
5364           other = toNumber(other);
5365         }
5366         return operator(value, other);
5367       };
5368     }
5369
5370     /**
5371      * Creates a function that wraps `func` to continue currying.
5372      *
5373      * @private
5374      * @param {Function} func The function to wrap.
5375      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5376      * @param {Function} wrapFunc The function to create the `func` wrapper.
5377      * @param {*} placeholder The placeholder value.
5378      * @param {*} [thisArg] The `this` binding of `func`.
5379      * @param {Array} [partials] The arguments to prepend to those provided to
5380      *  the new function.
5381      * @param {Array} [holders] The `partials` placeholder indexes.
5382      * @param {Array} [argPos] The argument positions of the new function.
5383      * @param {number} [ary] The arity cap of `func`.
5384      * @param {number} [arity] The arity of `func`.
5385      * @returns {Function} Returns the new wrapped function.
5386      */
5387     function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
5388       var isCurry = bitmask & WRAP_CURRY_FLAG,
5389           newHolders = isCurry ? holders : undefined,
5390           newHoldersRight = isCurry ? undefined : holders,
5391           newPartials = isCurry ? partials : undefined,
5392           newPartialsRight = isCurry ? undefined : partials;
5393
5394       bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
5395       bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
5396
5397       if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
5398         bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
5399       }
5400       var newData = [
5401         func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5402         newHoldersRight, argPos, ary, arity
5403       ];
5404
5405       var result = wrapFunc.apply(undefined, newData);
5406       if (isLaziable(func)) {
5407         setData(result, newData);
5408       }
5409       result.placeholder = placeholder;
5410       return setWrapToString(result, func, bitmask);
5411     }
5412
5413     /**
5414      * Creates a function like `_.round`.
5415      *
5416      * @private
5417      * @param {string} methodName The name of the `Math` method to use when rounding.
5418      * @returns {Function} Returns the new round function.
5419      */
5420     function createRound(methodName) {
5421       var func = Math[methodName];
5422       return function(number, precision) {
5423         number = toNumber(number);
5424         precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
5425         if (precision && nativeIsFinite(number)) {
5426           // Shift with exponential notation to avoid floating-point issues.
5427           // See [MDN](https://mdn.io/round#Examples) for more details.
5428           var pair = (toString(number) + 'e').split('e'),
5429               value = func(pair[0] + 'e' + (+pair[1] + precision));
5430
5431           pair = (toString(value) + 'e').split('e');
5432           return +(pair[0] + 'e' + (+pair[1] - precision));
5433         }
5434         return func(number);
5435       };
5436     }
5437
5438     /**
5439      * Creates a set object of `values`.
5440      *
5441      * @private
5442      * @param {Array} values The values to add to the set.
5443      * @returns {Object} Returns the new set.
5444      */
5445     var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
5446       return new Set(values);
5447     };
5448
5449     /**
5450      * Creates a `_.toPairs` or `_.toPairsIn` function.
5451      *
5452      * @private
5453      * @param {Function} keysFunc The function to get the keys of a given object.
5454      * @returns {Function} Returns the new pairs function.
5455      */
5456     function createToPairs(keysFunc) {
5457       return function(object) {
5458         var tag = getTag(object);
5459         if (tag == mapTag) {
5460           return mapToArray(object);
5461         }
5462         if (tag == setTag) {
5463           return setToPairs(object);
5464         }
5465         return baseToPairs(object, keysFunc(object));
5466       };
5467     }
5468
5469     /**
5470      * Creates a function that either curries or invokes `func` with optional
5471      * `this` binding and partially applied arguments.
5472      *
5473      * @private
5474      * @param {Function|string} func The function or method name to wrap.
5475      * @param {number} bitmask The bitmask flags.
5476      *    1 - `_.bind`
5477      *    2 - `_.bindKey`
5478      *    4 - `_.curry` or `_.curryRight` of a bound function
5479      *    8 - `_.curry`
5480      *   16 - `_.curryRight`
5481      *   32 - `_.partial`
5482      *   64 - `_.partialRight`
5483      *  128 - `_.rearg`
5484      *  256 - `_.ary`
5485      *  512 - `_.flip`
5486      * @param {*} [thisArg] The `this` binding of `func`.
5487      * @param {Array} [partials] The arguments to be partially applied.
5488      * @param {Array} [holders] The `partials` placeholder indexes.
5489      * @param {Array} [argPos] The argument positions of the new function.
5490      * @param {number} [ary] The arity cap of `func`.
5491      * @param {number} [arity] The arity of `func`.
5492      * @returns {Function} Returns the new wrapped function.
5493      */
5494     function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5495       var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
5496       if (!isBindKey && typeof func != 'function') {
5497         throw new TypeError(FUNC_ERROR_TEXT);
5498       }
5499       var length = partials ? partials.length : 0;
5500       if (!length) {
5501         bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
5502         partials = holders = undefined;
5503       }
5504       ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
5505       arity = arity === undefined ? arity : toInteger(arity);
5506       length -= holders ? holders.length : 0;
5507
5508       if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
5509         var partialsRight = partials,
5510             holdersRight = holders;
5511
5512         partials = holders = undefined;
5513       }
5514       var data = isBindKey ? undefined : getData(func);
5515
5516       var newData = [
5517         func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5518         argPos, ary, arity
5519       ];
5520
5521       if (data) {
5522         mergeData(newData, data);
5523       }
5524       func = newData[0];
5525       bitmask = newData[1];
5526       thisArg = newData[2];
5527       partials = newData[3];
5528       holders = newData[4];
5529       arity = newData[9] = newData[9] === undefined
5530         ? (isBindKey ? 0 : func.length)
5531         : nativeMax(newData[9] - length, 0);
5532
5533       if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
5534         bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
5535       }
5536       if (!bitmask || bitmask == WRAP_BIND_FLAG) {
5537         var result = createBind(func, bitmask, thisArg);
5538       } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
5539         result = createCurry(func, bitmask, arity);
5540       } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
5541         result = createPartial(func, bitmask, thisArg, partials);
5542       } else {
5543         result = createHybrid.apply(undefined, newData);
5544       }
5545       var setter = data ? baseSetData : setData;
5546       return setWrapToString(setter(result, newData), func, bitmask);
5547     }
5548
5549     /**
5550      * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
5551      * of source objects to the destination object for all destination properties
5552      * that resolve to `undefined`.
5553      *
5554      * @private
5555      * @param {*} objValue The destination value.
5556      * @param {*} srcValue The source value.
5557      * @param {string} key The key of the property to assign.
5558      * @param {Object} object The parent object of `objValue`.
5559      * @returns {*} Returns the value to assign.
5560      */
5561     function customDefaultsAssignIn(objValue, srcValue, key, object) {
5562       if (objValue === undefined ||
5563           (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
5564         return srcValue;
5565       }
5566       return objValue;
5567     }
5568
5569     /**
5570      * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
5571      * objects into destination objects that are passed thru.
5572      *
5573      * @private
5574      * @param {*} objValue The destination value.
5575      * @param {*} srcValue The source value.
5576      * @param {string} key The key of the property to merge.
5577      * @param {Object} object The parent object of `objValue`.
5578      * @param {Object} source The parent object of `srcValue`.
5579      * @param {Object} [stack] Tracks traversed source values and their merged
5580      *  counterparts.
5581      * @returns {*} Returns the value to assign.
5582      */
5583     function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
5584       if (isObject(objValue) && isObject(srcValue)) {
5585         // Recursively merge objects and arrays (susceptible to call stack limits).
5586         stack.set(srcValue, objValue);
5587         baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
5588         stack['delete'](srcValue);
5589       }
5590       return objValue;
5591     }
5592
5593     /**
5594      * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
5595      * objects.
5596      *
5597      * @private
5598      * @param {*} value The value to inspect.
5599      * @param {string} key The key of the property to inspect.
5600      * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
5601      */
5602     function customOmitClone(value) {
5603       return isPlainObject(value) ? undefined : value;
5604     }
5605
5606     /**
5607      * A specialized version of `baseIsEqualDeep` for arrays with support for
5608      * partial deep comparisons.
5609      *
5610      * @private
5611      * @param {Array} array The array to compare.
5612      * @param {Array} other The other array to compare.
5613      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5614      * @param {Function} customizer The function to customize comparisons.
5615      * @param {Function} equalFunc The function to determine equivalents of values.
5616      * @param {Object} stack Tracks traversed `array` and `other` objects.
5617      * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
5618      */
5619     function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
5620       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5621           arrLength = array.length,
5622           othLength = other.length;
5623
5624       if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5625         return false;
5626       }
5627       // Assume cyclic values are equal.
5628       var stacked = stack.get(array);
5629       if (stacked && stack.get(other)) {
5630         return stacked == other;
5631       }
5632       var index = -1,
5633           result = true,
5634           seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
5635
5636       stack.set(array, other);
5637       stack.set(other, array);
5638
5639       // Ignore non-index properties.
5640       while (++index < arrLength) {
5641         var arrValue = array[index],
5642             othValue = other[index];
5643
5644         if (customizer) {
5645           var compared = isPartial
5646             ? customizer(othValue, arrValue, index, other, array, stack)
5647             : customizer(arrValue, othValue, index, array, other, stack);
5648         }
5649         if (compared !== undefined) {
5650           if (compared) {
5651             continue;
5652           }
5653           result = false;
5654           break;
5655         }
5656         // Recursively compare arrays (susceptible to call stack limits).
5657         if (seen) {
5658           if (!arraySome(other, function(othValue, othIndex) {
5659                 if (!cacheHas(seen, othIndex) &&
5660                     (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
5661                   return seen.push(othIndex);
5662                 }
5663               })) {
5664             result = false;
5665             break;
5666           }
5667         } else if (!(
5668               arrValue === othValue ||
5669                 equalFunc(arrValue, othValue, bitmask, customizer, stack)
5670             )) {
5671           result = false;
5672           break;
5673         }
5674       }
5675       stack['delete'](array);
5676       stack['delete'](other);
5677       return result;
5678     }
5679
5680     /**
5681      * A specialized version of `baseIsEqualDeep` for comparing objects of
5682      * the same `toStringTag`.
5683      *
5684      * **Note:** This function only supports comparing values with tags of
5685      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5686      *
5687      * @private
5688      * @param {Object} object The object to compare.
5689      * @param {Object} other The other object to compare.
5690      * @param {string} tag The `toStringTag` of the objects to compare.
5691      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5692      * @param {Function} customizer The function to customize comparisons.
5693      * @param {Function} equalFunc The function to determine equivalents of values.
5694      * @param {Object} stack Tracks traversed `object` and `other` objects.
5695      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5696      */
5697     function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
5698       switch (tag) {
5699         case dataViewTag:
5700           if ((object.byteLength != other.byteLength) ||
5701               (object.byteOffset != other.byteOffset)) {
5702             return false;
5703           }
5704           object = object.buffer;
5705           other = other.buffer;
5706
5707         case arrayBufferTag:
5708           if ((object.byteLength != other.byteLength) ||
5709               !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5710             return false;
5711           }
5712           return true;
5713
5714         case boolTag:
5715         case dateTag:
5716         case numberTag:
5717           // Coerce booleans to `1` or `0` and dates to milliseconds.
5718           // Invalid dates are coerced to `NaN`.
5719           return eq(+object, +other);
5720
5721         case errorTag:
5722           return object.name == other.name && object.message == other.message;
5723
5724         case regexpTag:
5725         case stringTag:
5726           // Coerce regexes to strings and treat strings, primitives and objects,
5727           // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
5728           // for more details.
5729           return object == (other + '');
5730
5731         case mapTag:
5732           var convert = mapToArray;
5733
5734         case setTag:
5735           var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
5736           convert || (convert = setToArray);
5737
5738           if (object.size != other.size && !isPartial) {
5739             return false;
5740           }
5741           // Assume cyclic values are equal.
5742           var stacked = stack.get(object);
5743           if (stacked) {
5744             return stacked == other;
5745           }
5746           bitmask |= COMPARE_UNORDERED_FLAG;
5747
5748           // Recursively compare objects (susceptible to call stack limits).
5749           stack.set(object, other);
5750           var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
5751           stack['delete'](object);
5752           return result;
5753
5754         case symbolTag:
5755           if (symbolValueOf) {
5756             return symbolValueOf.call(object) == symbolValueOf.call(other);
5757           }
5758       }
5759       return false;
5760     }
5761
5762     /**
5763      * A specialized version of `baseIsEqualDeep` for objects with support for
5764      * partial deep comparisons.
5765      *
5766      * @private
5767      * @param {Object} object The object to compare.
5768      * @param {Object} other The other object to compare.
5769      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5770      * @param {Function} customizer The function to customize comparisons.
5771      * @param {Function} equalFunc The function to determine equivalents of values.
5772      * @param {Object} stack Tracks traversed `object` and `other` objects.
5773      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5774      */
5775     function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
5776       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5777           objProps = getAllKeys(object),
5778           objLength = objProps.length,
5779           othProps = getAllKeys(other),
5780           othLength = othProps.length;
5781
5782       if (objLength != othLength && !isPartial) {
5783         return false;
5784       }
5785       var index = objLength;
5786       while (index--) {
5787         var key = objProps[index];
5788         if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
5789           return false;
5790         }
5791       }
5792       // Assume cyclic values are equal.
5793       var stacked = stack.get(object);
5794       if (stacked && stack.get(other)) {
5795         return stacked == other;
5796       }
5797       var result = true;
5798       stack.set(object, other);
5799       stack.set(other, object);
5800
5801       var skipCtor = isPartial;
5802       while (++index < objLength) {
5803         key = objProps[index];
5804         var objValue = object[key],
5805             othValue = other[key];
5806
5807         if (customizer) {
5808           var compared = isPartial
5809             ? customizer(othValue, objValue, key, other, object, stack)
5810             : customizer(objValue, othValue, key, object, other, stack);
5811         }
5812         // Recursively compare objects (susceptible to call stack limits).
5813         if (!(compared === undefined
5814               ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
5815               : compared
5816             )) {
5817           result = false;
5818           break;
5819         }
5820         skipCtor || (skipCtor = key == 'constructor');
5821       }
5822       if (result && !skipCtor) {
5823         var objCtor = object.constructor,
5824             othCtor = other.constructor;
5825
5826         // Non `Object` object instances with different constructors are not equal.
5827         if (objCtor != othCtor &&
5828             ('constructor' in object && 'constructor' in other) &&
5829             !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
5830               typeof othCtor == 'function' && othCtor instanceof othCtor)) {
5831           result = false;
5832         }
5833       }
5834       stack['delete'](object);
5835       stack['delete'](other);
5836       return result;
5837     }
5838
5839     /**
5840      * A specialized version of `baseRest` which flattens the rest array.
5841      *
5842      * @private
5843      * @param {Function} func The function to apply a rest parameter to.
5844      * @returns {Function} Returns the new function.
5845      */
5846     function flatRest(func) {
5847       return setToString(overRest(func, undefined, flatten), func + '');
5848     }
5849
5850     /**
5851      * Creates an array of own enumerable property names and symbols of `object`.
5852      *
5853      * @private
5854      * @param {Object} object The object to query.
5855      * @returns {Array} Returns the array of property names and symbols.
5856      */
5857     function getAllKeys(object) {
5858       return baseGetAllKeys(object, keys, getSymbols);
5859     }
5860
5861     /**
5862      * Creates an array of own and inherited enumerable property names and
5863      * symbols of `object`.
5864      *
5865      * @private
5866      * @param {Object} object The object to query.
5867      * @returns {Array} Returns the array of property names and symbols.
5868      */
5869     function getAllKeysIn(object) {
5870       return baseGetAllKeys(object, keysIn, getSymbolsIn);
5871     }
5872
5873     /**
5874      * Gets metadata for `func`.
5875      *
5876      * @private
5877      * @param {Function} func The function to query.
5878      * @returns {*} Returns the metadata for `func`.
5879      */
5880     var getData = !metaMap ? noop : function(func) {
5881       return metaMap.get(func);
5882     };
5883
5884     /**
5885      * Gets the name of `func`.
5886      *
5887      * @private
5888      * @param {Function} func The function to query.
5889      * @returns {string} Returns the function name.
5890      */
5891     function getFuncName(func) {
5892       var result = (func.name + ''),
5893           array = realNames[result],
5894           length = hasOwnProperty.call(realNames, result) ? array.length : 0;
5895
5896       while (length--) {
5897         var data = array[length],
5898             otherFunc = data.func;
5899         if (otherFunc == null || otherFunc == func) {
5900           return data.name;
5901         }
5902       }
5903       return result;
5904     }
5905
5906     /**
5907      * Gets the argument placeholder value for `func`.
5908      *
5909      * @private
5910      * @param {Function} func The function to inspect.
5911      * @returns {*} Returns the placeholder value.
5912      */
5913     function getHolder(func) {
5914       var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
5915       return object.placeholder;
5916     }
5917
5918     /**
5919      * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
5920      * this function returns the custom method, otherwise it returns `baseIteratee`.
5921      * If arguments are provided, the chosen function is invoked with them and
5922      * its result is returned.
5923      *
5924      * @private
5925      * @param {*} [value] The value to convert to an iteratee.
5926      * @param {number} [arity] The arity of the created iteratee.
5927      * @returns {Function} Returns the chosen function or its result.
5928      */
5929     function getIteratee() {
5930       var result = lodash.iteratee || iteratee;
5931       result = result === iteratee ? baseIteratee : result;
5932       return arguments.length ? result(arguments[0], arguments[1]) : result;
5933     }
5934
5935     /**
5936      * Gets the data for `map`.
5937      *
5938      * @private
5939      * @param {Object} map The map to query.
5940      * @param {string} key The reference key.
5941      * @returns {*} Returns the map data.
5942      */
5943     function getMapData(map, key) {
5944       var data = map.__data__;
5945       return isKeyable(key)
5946         ? data[typeof key == 'string' ? 'string' : 'hash']
5947         : data.map;
5948     }
5949
5950     /**
5951      * Gets the property names, values, and compare flags of `object`.
5952      *
5953      * @private
5954      * @param {Object} object The object to query.
5955      * @returns {Array} Returns the match data of `object`.
5956      */
5957     function getMatchData(object) {
5958       var result = keys(object),
5959           length = result.length;
5960
5961       while (length--) {
5962         var key = result[length],
5963             value = object[key];
5964
5965         result[length] = [key, value, isStrictComparable(value)];
5966       }
5967       return result;
5968     }
5969
5970     /**
5971      * Gets the native function at `key` of `object`.
5972      *
5973      * @private
5974      * @param {Object} object The object to query.
5975      * @param {string} key The key of the method to get.
5976      * @returns {*} Returns the function if it's native, else `undefined`.
5977      */
5978     function getNative(object, key) {
5979       var value = getValue(object, key);
5980       return baseIsNative(value) ? value : undefined;
5981     }
5982
5983     /**
5984      * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
5985      *
5986      * @private
5987      * @param {*} value The value to query.
5988      * @returns {string} Returns the raw `toStringTag`.
5989      */
5990     function getRawTag(value) {
5991       var isOwn = hasOwnProperty.call(value, symToStringTag),
5992           tag = value[symToStringTag];
5993
5994       try {
5995         value[symToStringTag] = undefined;
5996         var unmasked = true;
5997       } catch (e) {}
5998
5999       var result = nativeObjectToString.call(value);
6000       if (unmasked) {
6001         if (isOwn) {
6002           value[symToStringTag] = tag;
6003         } else {
6004           delete value[symToStringTag];
6005         }
6006       }
6007       return result;
6008     }
6009
6010     /**
6011      * Creates an array of the own enumerable symbols of `object`.
6012      *
6013      * @private
6014      * @param {Object} object The object to query.
6015      * @returns {Array} Returns the array of symbols.
6016      */
6017     var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
6018       if (object == null) {
6019         return [];
6020       }
6021       object = Object(object);
6022       return arrayFilter(nativeGetSymbols(object), function(symbol) {
6023         return propertyIsEnumerable.call(object, symbol);
6024       });
6025     };
6026
6027     /**
6028      * Creates an array of the own and inherited enumerable symbols of `object`.
6029      *
6030      * @private
6031      * @param {Object} object The object to query.
6032      * @returns {Array} Returns the array of symbols.
6033      */
6034     var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6035       var result = [];
6036       while (object) {
6037         arrayPush(result, getSymbols(object));
6038         object = getPrototype(object);
6039       }
6040       return result;
6041     };
6042
6043     /**
6044      * Gets the `toStringTag` of `value`.
6045      *
6046      * @private
6047      * @param {*} value The value to query.
6048      * @returns {string} Returns the `toStringTag`.
6049      */
6050     var getTag = baseGetTag;
6051
6052     // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
6053     if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
6054         (Map && getTag(new Map) != mapTag) ||
6055         (Promise && getTag(Promise.resolve()) != promiseTag) ||
6056         (Set && getTag(new Set) != setTag) ||
6057         (WeakMap && getTag(new WeakMap) != weakMapTag)) {
6058       getTag = function(value) {
6059         var result = baseGetTag(value),
6060             Ctor = result == objectTag ? value.constructor : undefined,
6061             ctorString = Ctor ? toSource(Ctor) : '';
6062
6063         if (ctorString) {
6064           switch (ctorString) {
6065             case dataViewCtorString: return dataViewTag;
6066             case mapCtorString: return mapTag;
6067             case promiseCtorString: return promiseTag;
6068             case setCtorString: return setTag;
6069             case weakMapCtorString: return weakMapTag;
6070           }
6071         }
6072         return result;
6073       };
6074     }
6075
6076     /**
6077      * Gets the view, applying any `transforms` to the `start` and `end` positions.
6078      *
6079      * @private
6080      * @param {number} start The start of the view.
6081      * @param {number} end The end of the view.
6082      * @param {Array} transforms The transformations to apply to the view.
6083      * @returns {Object} Returns an object containing the `start` and `end`
6084      *  positions of the view.
6085      */
6086     function getView(start, end, transforms) {
6087       var index = -1,
6088           length = transforms.length;
6089
6090       while (++index < length) {
6091         var data = transforms[index],
6092             size = data.size;
6093
6094         switch (data.type) {
6095           case 'drop':      start += size; break;
6096           case 'dropRight': end -= size; break;
6097           case 'take':      end = nativeMin(end, start + size); break;
6098           case 'takeRight': start = nativeMax(start, end - size); break;
6099         }
6100       }
6101       return { 'start': start, 'end': end };
6102     }
6103
6104     /**
6105      * Extracts wrapper details from the `source` body comment.
6106      *
6107      * @private
6108      * @param {string} source The source to inspect.
6109      * @returns {Array} Returns the wrapper details.
6110      */
6111     function getWrapDetails(source) {
6112       var match = source.match(reWrapDetails);
6113       return match ? match[1].split(reSplitDetails) : [];
6114     }
6115
6116     /**
6117      * Checks if `path` exists on `object`.
6118      *
6119      * @private
6120      * @param {Object} object The object to query.
6121      * @param {Array|string} path The path to check.
6122      * @param {Function} hasFunc The function to check properties.
6123      * @returns {boolean} Returns `true` if `path` exists, else `false`.
6124      */
6125     function hasPath(object, path, hasFunc) {
6126       path = castPath(path, object);
6127
6128       var index = -1,
6129           length = path.length,
6130           result = false;
6131
6132       while (++index < length) {
6133         var key = toKey(path[index]);
6134         if (!(result = object != null && hasFunc(object, key))) {
6135           break;
6136         }
6137         object = object[key];
6138       }
6139       if (result || ++index != length) {
6140         return result;
6141       }
6142       length = object == null ? 0 : object.length;
6143       return !!length && isLength(length) && isIndex(key, length) &&
6144         (isArray(object) || isArguments(object));
6145     }
6146
6147     /**
6148      * Initializes an array clone.
6149      *
6150      * @private
6151      * @param {Array} array The array to clone.
6152      * @returns {Array} Returns the initialized clone.
6153      */
6154     function initCloneArray(array) {
6155       var length = array.length,
6156           result = new array.constructor(length);
6157
6158       // Add properties assigned by `RegExp#exec`.
6159       if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
6160         result.index = array.index;
6161         result.input = array.input;
6162       }
6163       return result;
6164     }
6165
6166     /**
6167      * Initializes an object clone.
6168      *
6169      * @private
6170      * @param {Object} object The object to clone.
6171      * @returns {Object} Returns the initialized clone.
6172      */
6173     function initCloneObject(object) {
6174       return (typeof object.constructor == 'function' && !isPrototype(object))
6175         ? baseCreate(getPrototype(object))
6176         : {};
6177     }
6178
6179     /**
6180      * Initializes an object clone based on its `toStringTag`.
6181      *
6182      * **Note:** This function only supports cloning values with tags of
6183      * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
6184      *
6185      * @private
6186      * @param {Object} object The object to clone.
6187      * @param {string} tag The `toStringTag` of the object to clone.
6188      * @param {boolean} [isDeep] Specify a deep clone.
6189      * @returns {Object} Returns the initialized clone.
6190      */
6191     function initCloneByTag(object, tag, isDeep) {
6192       var Ctor = object.constructor;
6193       switch (tag) {
6194         case arrayBufferTag:
6195           return cloneArrayBuffer(object);
6196
6197         case boolTag:
6198         case dateTag:
6199           return new Ctor(+object);
6200
6201         case dataViewTag:
6202           return cloneDataView(object, isDeep);
6203
6204         case float32Tag: case float64Tag:
6205         case int8Tag: case int16Tag: case int32Tag:
6206         case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
6207           return cloneTypedArray(object, isDeep);
6208
6209         case mapTag:
6210           return new Ctor;
6211
6212         case numberTag:
6213         case stringTag:
6214           return new Ctor(object);
6215
6216         case regexpTag:
6217           return cloneRegExp(object);
6218
6219         case setTag:
6220           return new Ctor;
6221
6222         case symbolTag:
6223           return cloneSymbol(object);
6224       }
6225     }
6226
6227     /**
6228      * Inserts wrapper `details` in a comment at the top of the `source` body.
6229      *
6230      * @private
6231      * @param {string} source The source to modify.
6232      * @returns {Array} details The details to insert.
6233      * @returns {string} Returns the modified source.
6234      */
6235     function insertWrapDetails(source, details) {
6236       var length = details.length;
6237       if (!length) {
6238         return source;
6239       }
6240       var lastIndex = length - 1;
6241       details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
6242       details = details.join(length > 2 ? ', ' : ' ');
6243       return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
6244     }
6245
6246     /**
6247      * Checks if `value` is a flattenable `arguments` object or array.
6248      *
6249      * @private
6250      * @param {*} value The value to check.
6251      * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6252      */
6253     function isFlattenable(value) {
6254       return isArray(value) || isArguments(value) ||
6255         !!(spreadableSymbol && value && value[spreadableSymbol]);
6256     }
6257
6258     /**
6259      * Checks if `value` is a valid array-like index.
6260      *
6261      * @private
6262      * @param {*} value The value to check.
6263      * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
6264      * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
6265      */
6266     function isIndex(value, length) {
6267       var type = typeof value;
6268       length = length == null ? MAX_SAFE_INTEGER : length;
6269
6270       return !!length &&
6271         (type == 'number' ||
6272           (type != 'symbol' && reIsUint.test(value))) &&
6273             (value > -1 && value % 1 == 0 && value < length);
6274     }
6275
6276     /**
6277      * Checks if the given arguments are from an iteratee call.
6278      *
6279      * @private
6280      * @param {*} value The potential iteratee value argument.
6281      * @param {*} index The potential iteratee index or key argument.
6282      * @param {*} object The potential iteratee object argument.
6283      * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
6284      *  else `false`.
6285      */
6286     function isIterateeCall(value, index, object) {
6287       if (!isObject(object)) {
6288         return false;
6289       }
6290       var type = typeof index;
6291       if (type == 'number'
6292             ? (isArrayLike(object) && isIndex(index, object.length))
6293             : (type == 'string' && index in object)
6294           ) {
6295         return eq(object[index], value);
6296       }
6297       return false;
6298     }
6299
6300     /**
6301      * Checks if `value` is a property name and not a property path.
6302      *
6303      * @private
6304      * @param {*} value The value to check.
6305      * @param {Object} [object] The object to query keys on.
6306      * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
6307      */
6308     function isKey(value, object) {
6309       if (isArray(value)) {
6310         return false;
6311       }
6312       var type = typeof value;
6313       if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6314           value == null || isSymbol(value)) {
6315         return true;
6316       }
6317       return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6318         (object != null && value in Object(object));
6319     }
6320
6321     /**
6322      * Checks if `value` is suitable for use as unique object key.
6323      *
6324      * @private
6325      * @param {*} value The value to check.
6326      * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6327      */
6328     function isKeyable(value) {
6329       var type = typeof value;
6330       return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
6331         ? (value !== '__proto__')
6332         : (value === null);
6333     }
6334
6335     /**
6336      * Checks if `func` has a lazy counterpart.
6337      *
6338      * @private
6339      * @param {Function} func The function to check.
6340      * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6341      *  else `false`.
6342      */
6343     function isLaziable(func) {
6344       var funcName = getFuncName(func),
6345           other = lodash[funcName];
6346
6347       if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6348         return false;
6349       }
6350       if (func === other) {
6351         return true;
6352       }
6353       var data = getData(other);
6354       return !!data && func === data[0];
6355     }
6356
6357     /**
6358      * Checks if `func` has its source masked.
6359      *
6360      * @private
6361      * @param {Function} func The function to check.
6362      * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6363      */
6364     function isMasked(func) {
6365       return !!maskSrcKey && (maskSrcKey in func);
6366     }
6367
6368     /**
6369      * Checks if `func` is capable of being masked.
6370      *
6371      * @private
6372      * @param {*} value The value to check.
6373      * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6374      */
6375     var isMaskable = coreJsData ? isFunction : stubFalse;
6376
6377     /**
6378      * Checks if `value` is likely a prototype object.
6379      *
6380      * @private
6381      * @param {*} value The value to check.
6382      * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6383      */
6384     function isPrototype(value) {
6385       var Ctor = value && value.constructor,
6386           proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6387
6388       return value === proto;
6389     }
6390
6391     /**
6392      * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6393      *
6394      * @private
6395      * @param {*} value The value to check.
6396      * @returns {boolean} Returns `true` if `value` if suitable for strict
6397      *  equality comparisons, else `false`.
6398      */
6399     function isStrictComparable(value) {
6400       return value === value && !isObject(value);
6401     }
6402
6403     /**
6404      * A specialized version of `matchesProperty` for source values suitable
6405      * for strict equality comparisons, i.e. `===`.
6406      *
6407      * @private
6408      * @param {string} key The key of the property to get.
6409      * @param {*} srcValue The value to match.
6410      * @returns {Function} Returns the new spec function.
6411      */
6412     function matchesStrictComparable(key, srcValue) {
6413       return function(object) {
6414         if (object == null) {
6415           return false;
6416         }
6417         return object[key] === srcValue &&
6418           (srcValue !== undefined || (key in Object(object)));
6419       };
6420     }
6421
6422     /**
6423      * A specialized version of `_.memoize` which clears the memoized function's
6424      * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6425      *
6426      * @private
6427      * @param {Function} func The function to have its output memoized.
6428      * @returns {Function} Returns the new memoized function.
6429      */
6430     function memoizeCapped(func) {
6431       var result = memoize(func, function(key) {
6432         if (cache.size === MAX_MEMOIZE_SIZE) {
6433           cache.clear();
6434         }
6435         return key;
6436       });
6437
6438       var cache = result.cache;
6439       return result;
6440     }
6441
6442     /**
6443      * Merges the function metadata of `source` into `data`.
6444      *
6445      * Merging metadata reduces the number of wrappers used to invoke a function.
6446      * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
6447      * may be applied regardless of execution order. Methods like `_.ary` and
6448      * `_.rearg` modify function arguments, making the order in which they are
6449      * executed important, preventing the merging of metadata. However, we make
6450      * an exception for a safe combined case where curried functions have `_.ary`
6451      * and or `_.rearg` applied.
6452      *
6453      * @private
6454      * @param {Array} data The destination metadata.
6455      * @param {Array} source The source metadata.
6456      * @returns {Array} Returns `data`.
6457      */
6458     function mergeData(data, source) {
6459       var bitmask = data[1],
6460           srcBitmask = source[1],
6461           newBitmask = bitmask | srcBitmask,
6462           isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6463
6464       var isCombo =
6465         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
6466         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
6467         ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
6468
6469       // Exit early if metadata can't be merged.
6470       if (!(isCommon || isCombo)) {
6471         return data;
6472       }
6473       // Use source `thisArg` if available.
6474       if (srcBitmask & WRAP_BIND_FLAG) {
6475         data[2] = source[2];
6476         // Set when currying a bound function.
6477         newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6478       }
6479       // Compose partial arguments.
6480       var value = source[3];
6481       if (value) {
6482         var partials = data[3];
6483         data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6484         data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6485       }
6486       // Compose partial right arguments.
6487       value = source[5];
6488       if (value) {
6489         partials = data[5];
6490         data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6491         data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6492       }
6493       // Use source `argPos` if available.
6494       value = source[7];
6495       if (value) {
6496         data[7] = value;
6497       }
6498       // Use source `ary` if it's smaller.
6499       if (srcBitmask & WRAP_ARY_FLAG) {
6500         data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
6501       }
6502       // Use source `arity` if one is not provided.
6503       if (data[9] == null) {
6504         data[9] = source[9];
6505       }
6506       // Use source `func` and merge bitmasks.
6507       data[0] = source[0];
6508       data[1] = newBitmask;
6509
6510       return data;
6511     }
6512
6513     /**
6514      * This function is like
6515      * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
6516      * except that it includes inherited enumerable properties.
6517      *
6518      * @private
6519      * @param {Object} object The object to query.
6520      * @returns {Array} Returns the array of property names.
6521      */
6522     function nativeKeysIn(object) {
6523       var result = [];
6524       if (object != null) {
6525         for (var key in Object(object)) {
6526           result.push(key);
6527         }
6528       }
6529       return result;
6530     }
6531
6532     /**
6533      * Converts `value` to a string using `Object.prototype.toString`.
6534      *
6535      * @private
6536      * @param {*} value The value to convert.
6537      * @returns {string} Returns the converted string.
6538      */
6539     function objectToString(value) {
6540       return nativeObjectToString.call(value);
6541     }
6542
6543     /**
6544      * A specialized version of `baseRest` which transforms the rest array.
6545      *
6546      * @private
6547      * @param {Function} func The function to apply a rest parameter to.
6548      * @param {number} [start=func.length-1] The start position of the rest parameter.
6549      * @param {Function} transform The rest array transform.
6550      * @returns {Function} Returns the new function.
6551      */
6552     function overRest(func, start, transform) {
6553       start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
6554       return function() {
6555         var args = arguments,
6556             index = -1,
6557             length = nativeMax(args.length - start, 0),
6558             array = Array(length);
6559
6560         while (++index < length) {
6561           array[index] = args[start + index];
6562         }
6563         index = -1;
6564         var otherArgs = Array(start + 1);
6565         while (++index < start) {
6566           otherArgs[index] = args[index];
6567         }
6568         otherArgs[start] = transform(array);
6569         return apply(func, this, otherArgs);
6570       };
6571     }
6572
6573     /**
6574      * Gets the parent value at `path` of `object`.
6575      *
6576      * @private
6577      * @param {Object} object The object to query.
6578      * @param {Array} path The path to get the parent value of.
6579      * @returns {*} Returns the parent value.
6580      */
6581     function parent(object, path) {
6582       return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6583     }
6584
6585     /**
6586      * Reorder `array` according to the specified indexes where the element at
6587      * the first index is assigned as the first element, the element at
6588      * the second index is assigned as the second element, and so on.
6589      *
6590      * @private
6591      * @param {Array} array The array to reorder.
6592      * @param {Array} indexes The arranged array indexes.
6593      * @returns {Array} Returns `array`.
6594      */
6595     function reorder(array, indexes) {
6596       var arrLength = array.length,
6597           length = nativeMin(indexes.length, arrLength),
6598           oldArray = copyArray(array);
6599
6600       while (length--) {
6601         var index = indexes[length];
6602         array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
6603       }
6604       return array;
6605     }
6606
6607     /**
6608      * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
6609      *
6610      * @private
6611      * @param {Object} object The object to query.
6612      * @param {string} key The key of the property to get.
6613      * @returns {*} Returns the property value.
6614      */
6615     function safeGet(object, key) {
6616       if (key === 'constructor' && typeof object[key] === 'function') {
6617         return;
6618       }
6619
6620       if (key == '__proto__') {
6621         return;
6622       }
6623
6624       return object[key];
6625     }
6626
6627     /**
6628      * Sets metadata for `func`.
6629      *
6630      * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
6631      * period of time, it will trip its breaker and transition to an identity
6632      * function to avoid garbage collection pauses in V8. See
6633      * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
6634      * for more details.
6635      *
6636      * @private
6637      * @param {Function} func The function to associate metadata with.
6638      * @param {*} data The metadata.
6639      * @returns {Function} Returns `func`.
6640      */
6641     var setData = shortOut(baseSetData);
6642
6643     /**
6644      * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
6645      *
6646      * @private
6647      * @param {Function} func The function to delay.
6648      * @param {number} wait The number of milliseconds to delay invocation.
6649      * @returns {number|Object} Returns the timer id or timeout object.
6650      */
6651     var setTimeout = ctxSetTimeout || function(func, wait) {
6652       return root.setTimeout(func, wait);
6653     };
6654
6655     /**
6656      * Sets the `toString` method of `func` to return `string`.
6657      *
6658      * @private
6659      * @param {Function} func The function to modify.
6660      * @param {Function} string The `toString` result.
6661      * @returns {Function} Returns `func`.
6662      */
6663     var setToString = shortOut(baseSetToString);
6664
6665     /**
6666      * Sets the `toString` method of `wrapper` to mimic the source of `reference`
6667      * with wrapper details in a comment at the top of the source body.
6668      *
6669      * @private
6670      * @param {Function} wrapper The function to modify.
6671      * @param {Function} reference The reference function.
6672      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6673      * @returns {Function} Returns `wrapper`.
6674      */
6675     function setWrapToString(wrapper, reference, bitmask) {
6676       var source = (reference + '');
6677       return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6678     }
6679
6680     /**
6681      * Creates a function that'll short out and invoke `identity` instead
6682      * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
6683      * milliseconds.
6684      *
6685      * @private
6686      * @param {Function} func The function to restrict.
6687      * @returns {Function} Returns the new shortable function.
6688      */
6689     function shortOut(func) {
6690       var count = 0,
6691           lastCalled = 0;
6692
6693       return function() {
6694         var stamp = nativeNow(),
6695             remaining = HOT_SPAN - (stamp - lastCalled);
6696
6697         lastCalled = stamp;
6698         if (remaining > 0) {
6699           if (++count >= HOT_COUNT) {
6700             return arguments[0];
6701           }
6702         } else {
6703           count = 0;
6704         }
6705         return func.apply(undefined, arguments);
6706       };
6707     }
6708
6709     /**
6710      * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
6711      *
6712      * @private
6713      * @param {Array} array The array to shuffle.
6714      * @param {number} [size=array.length] The size of `array`.
6715      * @returns {Array} Returns `array`.
6716      */
6717     function shuffleSelf(array, size) {
6718       var index = -1,
6719           length = array.length,
6720           lastIndex = length - 1;
6721
6722       size = size === undefined ? length : size;
6723       while (++index < size) {
6724         var rand = baseRandom(index, lastIndex),
6725             value = array[rand];
6726
6727         array[rand] = array[index];
6728         array[index] = value;
6729       }
6730       array.length = size;
6731       return array;
6732     }
6733
6734     /**
6735      * Converts `string` to a property path array.
6736      *
6737      * @private
6738      * @param {string} string The string to convert.
6739      * @returns {Array} Returns the property path array.
6740      */
6741     var stringToPath = memoizeCapped(function(string) {
6742       var result = [];
6743       if (string.charCodeAt(0) === 46 /* . */) {
6744         result.push('');
6745       }
6746       string.replace(rePropName, function(match, number, quote, subString) {
6747         result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
6748       });
6749       return result;
6750     });
6751
6752     /**
6753      * Converts `value` to a string key if it's not a string or symbol.
6754      *
6755      * @private
6756      * @param {*} value The value to inspect.
6757      * @returns {string|symbol} Returns the key.
6758      */
6759     function toKey(value) {
6760       if (typeof value == 'string' || isSymbol(value)) {
6761         return value;
6762       }
6763       var result = (value + '');
6764       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
6765     }
6766
6767     /**
6768      * Converts `func` to its source code.
6769      *
6770      * @private
6771      * @param {Function} func The function to convert.
6772      * @returns {string} Returns the source code.
6773      */
6774     function toSource(func) {
6775       if (func != null) {
6776         try {
6777           return funcToString.call(func);
6778         } catch (e) {}
6779         try {
6780           return (func + '');
6781         } catch (e) {}
6782       }
6783       return '';
6784     }
6785
6786     /**
6787      * Updates wrapper `details` based on `bitmask` flags.
6788      *
6789      * @private
6790      * @returns {Array} details The details to modify.
6791      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6792      * @returns {Array} Returns `details`.
6793      */
6794     function updateWrapDetails(details, bitmask) {
6795       arrayEach(wrapFlags, function(pair) {
6796         var value = '_.' + pair[0];
6797         if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
6798           details.push(value);
6799         }
6800       });
6801       return details.sort();
6802     }
6803
6804     /**
6805      * Creates a clone of `wrapper`.
6806      *
6807      * @private
6808      * @param {Object} wrapper The wrapper to clone.
6809      * @returns {Object} Returns the cloned wrapper.
6810      */
6811     function wrapperClone(wrapper) {
6812       if (wrapper instanceof LazyWrapper) {
6813         return wrapper.clone();
6814       }
6815       var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6816       result.__actions__ = copyArray(wrapper.__actions__);
6817       result.__index__  = wrapper.__index__;
6818       result.__values__ = wrapper.__values__;
6819       return result;
6820     }
6821
6822     /*------------------------------------------------------------------------*/
6823
6824     /**
6825      * Creates an array of elements split into groups the length of `size`.
6826      * If `array` can't be split evenly, the final chunk will be the remaining
6827      * elements.
6828      *
6829      * @static
6830      * @memberOf _
6831      * @since 3.0.0
6832      * @category Array
6833      * @param {Array} array The array to process.
6834      * @param {number} [size=1] The length of each chunk
6835      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
6836      * @returns {Array} Returns the new array of chunks.
6837      * @example
6838      *
6839      * _.chunk(['a', 'b', 'c', 'd'], 2);
6840      * // => [['a', 'b'], ['c', 'd']]
6841      *
6842      * _.chunk(['a', 'b', 'c', 'd'], 3);
6843      * // => [['a', 'b', 'c'], ['d']]
6844      */
6845     function chunk(array, size, guard) {
6846       if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
6847         size = 1;
6848       } else {
6849         size = nativeMax(toInteger(size), 0);
6850       }
6851       var length = array == null ? 0 : array.length;
6852       if (!length || size < 1) {
6853         return [];
6854       }
6855       var index = 0,
6856           resIndex = 0,
6857           result = Array(nativeCeil(length / size));
6858
6859       while (index < length) {
6860         result[resIndex++] = baseSlice(array, index, (index += size));
6861       }
6862       return result;
6863     }
6864
6865     /**
6866      * Creates an array with all falsey values removed. The values `false`, `null`,
6867      * `0`, `""`, `undefined`, and `NaN` are falsey.
6868      *
6869      * @static
6870      * @memberOf _
6871      * @since 0.1.0
6872      * @category Array
6873      * @param {Array} array The array to compact.
6874      * @returns {Array} Returns the new array of filtered values.
6875      * @example
6876      *
6877      * _.compact([0, 1, false, 2, '', 3]);
6878      * // => [1, 2, 3]
6879      */
6880     function compact(array) {
6881       var index = -1,
6882           length = array == null ? 0 : array.length,
6883           resIndex = 0,
6884           result = [];
6885
6886       while (++index < length) {
6887         var value = array[index];
6888         if (value) {
6889           result[resIndex++] = value;
6890         }
6891       }
6892       return result;
6893     }
6894
6895     /**
6896      * Creates a new array concatenating `array` with any additional arrays
6897      * and/or values.
6898      *
6899      * @static
6900      * @memberOf _
6901      * @since 4.0.0
6902      * @category Array
6903      * @param {Array} array The array to concatenate.
6904      * @param {...*} [values] The values to concatenate.
6905      * @returns {Array} Returns the new concatenated array.
6906      * @example
6907      *
6908      * var array = [1];
6909      * var other = _.concat(array, 2, [3], [[4]]);
6910      *
6911      * console.log(other);
6912      * // => [1, 2, 3, [4]]
6913      *
6914      * console.log(array);
6915      * // => [1]
6916      */
6917     function concat() {
6918       var length = arguments.length;
6919       if (!length) {
6920         return [];
6921       }
6922       var args = Array(length - 1),
6923           array = arguments[0],
6924           index = length;
6925
6926       while (index--) {
6927         args[index - 1] = arguments[index];
6928       }
6929       return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
6930     }
6931
6932     /**
6933      * Creates an array of `array` values not included in the other given arrays
6934      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
6935      * for equality comparisons. The order and references of result values are
6936      * determined by the first array.
6937      *
6938      * **Note:** Unlike `_.pullAll`, this method returns a new array.
6939      *
6940      * @static
6941      * @memberOf _
6942      * @since 0.1.0
6943      * @category Array
6944      * @param {Array} array The array to inspect.
6945      * @param {...Array} [values] The values to exclude.
6946      * @returns {Array} Returns the new array of filtered values.
6947      * @see _.without, _.xor
6948      * @example
6949      *
6950      * _.difference([2, 1], [2, 3]);
6951      * // => [1]
6952      */
6953     var difference = baseRest(function(array, values) {
6954       return isArrayLikeObject(array)
6955         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
6956         : [];
6957     });
6958
6959     /**
6960      * This method is like `_.difference` except that it accepts `iteratee` which
6961      * is invoked for each element of `array` and `values` to generate the criterion
6962      * by which they're compared. The order and references of result values are
6963      * determined by the first array. The iteratee is invoked with one argument:
6964      * (value).
6965      *
6966      * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
6967      *
6968      * @static
6969      * @memberOf _
6970      * @since 4.0.0
6971      * @category Array
6972      * @param {Array} array The array to inspect.
6973      * @param {...Array} [values] The values to exclude.
6974      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
6975      * @returns {Array} Returns the new array of filtered values.
6976      * @example
6977      *
6978      * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
6979      * // => [1.2]
6980      *
6981      * // The `_.property` iteratee shorthand.
6982      * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
6983      * // => [{ 'x': 2 }]
6984      */
6985     var differenceBy = baseRest(function(array, values) {
6986       var iteratee = last(values);
6987       if (isArrayLikeObject(iteratee)) {
6988         iteratee = undefined;
6989       }
6990       return isArrayLikeObject(array)
6991         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
6992         : [];
6993     });
6994
6995     /**
6996      * This method is like `_.difference` except that it accepts `comparator`
6997      * which is invoked to compare elements of `array` to `values`. The order and
6998      * references of result values are determined by the first array. The comparator
6999      * is invoked with two arguments: (arrVal, othVal).
7000      *
7001      * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
7002      *
7003      * @static
7004      * @memberOf _
7005      * @since 4.0.0
7006      * @category Array
7007      * @param {Array} array The array to inspect.
7008      * @param {...Array} [values] The values to exclude.
7009      * @param {Function} [comparator] The comparator invoked per element.
7010      * @returns {Array} Returns the new array of filtered values.
7011      * @example
7012      *
7013      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7014      *
7015      * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
7016      * // => [{ 'x': 2, 'y': 1 }]
7017      */
7018     var differenceWith = baseRest(function(array, values) {
7019       var comparator = last(values);
7020       if (isArrayLikeObject(comparator)) {
7021         comparator = undefined;
7022       }
7023       return isArrayLikeObject(array)
7024         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
7025         : [];
7026     });
7027
7028     /**
7029      * Creates a slice of `array` with `n` elements dropped from the beginning.
7030      *
7031      * @static
7032      * @memberOf _
7033      * @since 0.5.0
7034      * @category Array
7035      * @param {Array} array The array to query.
7036      * @param {number} [n=1] The number of elements to drop.
7037      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7038      * @returns {Array} Returns the slice of `array`.
7039      * @example
7040      *
7041      * _.drop([1, 2, 3]);
7042      * // => [2, 3]
7043      *
7044      * _.drop([1, 2, 3], 2);
7045      * // => [3]
7046      *
7047      * _.drop([1, 2, 3], 5);
7048      * // => []
7049      *
7050      * _.drop([1, 2, 3], 0);
7051      * // => [1, 2, 3]
7052      */
7053     function drop(array, n, guard) {
7054       var length = array == null ? 0 : array.length;
7055       if (!length) {
7056         return [];
7057       }
7058       n = (guard || n === undefined) ? 1 : toInteger(n);
7059       return baseSlice(array, n < 0 ? 0 : n, length);
7060     }
7061
7062     /**
7063      * Creates a slice of `array` with `n` elements dropped from the end.
7064      *
7065      * @static
7066      * @memberOf _
7067      * @since 3.0.0
7068      * @category Array
7069      * @param {Array} array The array to query.
7070      * @param {number} [n=1] The number of elements to drop.
7071      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7072      * @returns {Array} Returns the slice of `array`.
7073      * @example
7074      *
7075      * _.dropRight([1, 2, 3]);
7076      * // => [1, 2]
7077      *
7078      * _.dropRight([1, 2, 3], 2);
7079      * // => [1]
7080      *
7081      * _.dropRight([1, 2, 3], 5);
7082      * // => []
7083      *
7084      * _.dropRight([1, 2, 3], 0);
7085      * // => [1, 2, 3]
7086      */
7087     function dropRight(array, n, guard) {
7088       var length = array == null ? 0 : array.length;
7089       if (!length) {
7090         return [];
7091       }
7092       n = (guard || n === undefined) ? 1 : toInteger(n);
7093       n = length - n;
7094       return baseSlice(array, 0, n < 0 ? 0 : n);
7095     }
7096
7097     /**
7098      * Creates a slice of `array` excluding elements dropped from the end.
7099      * Elements are dropped until `predicate` returns falsey. The predicate is
7100      * invoked with three arguments: (value, index, array).
7101      *
7102      * @static
7103      * @memberOf _
7104      * @since 3.0.0
7105      * @category Array
7106      * @param {Array} array The array to query.
7107      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7108      * @returns {Array} Returns the slice of `array`.
7109      * @example
7110      *
7111      * var users = [
7112      *   { 'user': 'barney',  'active': true },
7113      *   { 'user': 'fred',    'active': false },
7114      *   { 'user': 'pebbles', 'active': false }
7115      * ];
7116      *
7117      * _.dropRightWhile(users, function(o) { return !o.active; });
7118      * // => objects for ['barney']
7119      *
7120      * // The `_.matches` iteratee shorthand.
7121      * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7122      * // => objects for ['barney', 'fred']
7123      *
7124      * // The `_.matchesProperty` iteratee shorthand.
7125      * _.dropRightWhile(users, ['active', false]);
7126      * // => objects for ['barney']
7127      *
7128      * // The `_.property` iteratee shorthand.
7129      * _.dropRightWhile(users, 'active');
7130      * // => objects for ['barney', 'fred', 'pebbles']
7131      */
7132     function dropRightWhile(array, predicate) {
7133       return (array && array.length)
7134         ? baseWhile(array, getIteratee(predicate, 3), true, true)
7135         : [];
7136     }
7137
7138     /**
7139      * Creates a slice of `array` excluding elements dropped from the beginning.
7140      * Elements are dropped until `predicate` returns falsey. The predicate is
7141      * invoked with three arguments: (value, index, array).
7142      *
7143      * @static
7144      * @memberOf _
7145      * @since 3.0.0
7146      * @category Array
7147      * @param {Array} array The array to query.
7148      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7149      * @returns {Array} Returns the slice of `array`.
7150      * @example
7151      *
7152      * var users = [
7153      *   { 'user': 'barney',  'active': false },
7154      *   { 'user': 'fred',    'active': false },
7155      *   { 'user': 'pebbles', 'active': true }
7156      * ];
7157      *
7158      * _.dropWhile(users, function(o) { return !o.active; });
7159      * // => objects for ['pebbles']
7160      *
7161      * // The `_.matches` iteratee shorthand.
7162      * _.dropWhile(users, { 'user': 'barney', 'active': false });
7163      * // => objects for ['fred', 'pebbles']
7164      *
7165      * // The `_.matchesProperty` iteratee shorthand.
7166      * _.dropWhile(users, ['active', false]);
7167      * // => objects for ['pebbles']
7168      *
7169      * // The `_.property` iteratee shorthand.
7170      * _.dropWhile(users, 'active');
7171      * // => objects for ['barney', 'fred', 'pebbles']
7172      */
7173     function dropWhile(array, predicate) {
7174       return (array && array.length)
7175         ? baseWhile(array, getIteratee(predicate, 3), true)
7176         : [];
7177     }
7178
7179     /**
7180      * Fills elements of `array` with `value` from `start` up to, but not
7181      * including, `end`.
7182      *
7183      * **Note:** This method mutates `array`.
7184      *
7185      * @static
7186      * @memberOf _
7187      * @since 3.2.0
7188      * @category Array
7189      * @param {Array} array The array to fill.
7190      * @param {*} value The value to fill `array` with.
7191      * @param {number} [start=0] The start position.
7192      * @param {number} [end=array.length] The end position.
7193      * @returns {Array} Returns `array`.
7194      * @example
7195      *
7196      * var array = [1, 2, 3];
7197      *
7198      * _.fill(array, 'a');
7199      * console.log(array);
7200      * // => ['a', 'a', 'a']
7201      *
7202      * _.fill(Array(3), 2);
7203      * // => [2, 2, 2]
7204      *
7205      * _.fill([4, 6, 8, 10], '*', 1, 3);
7206      * // => [4, '*', '*', 10]
7207      */
7208     function fill(array, value, start, end) {
7209       var length = array == null ? 0 : array.length;
7210       if (!length) {
7211         return [];
7212       }
7213       if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7214         start = 0;
7215         end = length;
7216       }
7217       return baseFill(array, value, start, end);
7218     }
7219
7220     /**
7221      * This method is like `_.find` except that it returns the index of the first
7222      * element `predicate` returns truthy for instead of the element itself.
7223      *
7224      * @static
7225      * @memberOf _
7226      * @since 1.1.0
7227      * @category Array
7228      * @param {Array} array The array to inspect.
7229      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7230      * @param {number} [fromIndex=0] The index to search from.
7231      * @returns {number} Returns the index of the found element, else `-1`.
7232      * @example
7233      *
7234      * var users = [
7235      *   { 'user': 'barney',  'active': false },
7236      *   { 'user': 'fred',    'active': false },
7237      *   { 'user': 'pebbles', 'active': true }
7238      * ];
7239      *
7240      * _.findIndex(users, function(o) { return o.user == 'barney'; });
7241      * // => 0
7242      *
7243      * // The `_.matches` iteratee shorthand.
7244      * _.findIndex(users, { 'user': 'fred', 'active': false });
7245      * // => 1
7246      *
7247      * // The `_.matchesProperty` iteratee shorthand.
7248      * _.findIndex(users, ['active', false]);
7249      * // => 0
7250      *
7251      * // The `_.property` iteratee shorthand.
7252      * _.findIndex(users, 'active');
7253      * // => 2
7254      */
7255     function findIndex(array, predicate, fromIndex) {
7256       var length = array == null ? 0 : array.length;
7257       if (!length) {
7258         return -1;
7259       }
7260       var index = fromIndex == null ? 0 : toInteger(fromIndex);
7261       if (index < 0) {
7262         index = nativeMax(length + index, 0);
7263       }
7264       return baseFindIndex(array, getIteratee(predicate, 3), index);
7265     }
7266
7267     /**
7268      * This method is like `_.findIndex` except that it iterates over elements
7269      * of `collection` from right to left.
7270      *
7271      * @static
7272      * @memberOf _
7273      * @since 2.0.0
7274      * @category Array
7275      * @param {Array} array The array to inspect.
7276      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7277      * @param {number} [fromIndex=array.length-1] The index to search from.
7278      * @returns {number} Returns the index of the found element, else `-1`.
7279      * @example
7280      *
7281      * var users = [
7282      *   { 'user': 'barney',  'active': true },
7283      *   { 'user': 'fred',    'active': false },
7284      *   { 'user': 'pebbles', 'active': false }
7285      * ];
7286      *
7287      * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7288      * // => 2
7289      *
7290      * // The `_.matches` iteratee shorthand.
7291      * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7292      * // => 0
7293      *
7294      * // The `_.matchesProperty` iteratee shorthand.
7295      * _.findLastIndex(users, ['active', false]);
7296      * // => 2
7297      *
7298      * // The `_.property` iteratee shorthand.
7299      * _.findLastIndex(users, 'active');
7300      * // => 0
7301      */
7302     function findLastIndex(array, predicate, fromIndex) {
7303       var length = array == null ? 0 : array.length;
7304       if (!length) {
7305         return -1;
7306       }
7307       var index = length - 1;
7308       if (fromIndex !== undefined) {
7309         index = toInteger(fromIndex);
7310         index = fromIndex < 0
7311           ? nativeMax(length + index, 0)
7312           : nativeMin(index, length - 1);
7313       }
7314       return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7315     }
7316
7317     /**
7318      * Flattens `array` a single level deep.
7319      *
7320      * @static
7321      * @memberOf _
7322      * @since 0.1.0
7323      * @category Array
7324      * @param {Array} array The array to flatten.
7325      * @returns {Array} Returns the new flattened array.
7326      * @example
7327      *
7328      * _.flatten([1, [2, [3, [4]], 5]]);
7329      * // => [1, 2, [3, [4]], 5]
7330      */
7331     function flatten(array) {
7332       var length = array == null ? 0 : array.length;
7333       return length ? baseFlatten(array, 1) : [];
7334     }
7335
7336     /**
7337      * Recursively flattens `array`.
7338      *
7339      * @static
7340      * @memberOf _
7341      * @since 3.0.0
7342      * @category Array
7343      * @param {Array} array The array to flatten.
7344      * @returns {Array} Returns the new flattened array.
7345      * @example
7346      *
7347      * _.flattenDeep([1, [2, [3, [4]], 5]]);
7348      * // => [1, 2, 3, 4, 5]
7349      */
7350     function flattenDeep(array) {
7351       var length = array == null ? 0 : array.length;
7352       return length ? baseFlatten(array, INFINITY) : [];
7353     }
7354
7355     /**
7356      * Recursively flatten `array` up to `depth` times.
7357      *
7358      * @static
7359      * @memberOf _
7360      * @since 4.4.0
7361      * @category Array
7362      * @param {Array} array The array to flatten.
7363      * @param {number} [depth=1] The maximum recursion depth.
7364      * @returns {Array} Returns the new flattened array.
7365      * @example
7366      *
7367      * var array = [1, [2, [3, [4]], 5]];
7368      *
7369      * _.flattenDepth(array, 1);
7370      * // => [1, 2, [3, [4]], 5]
7371      *
7372      * _.flattenDepth(array, 2);
7373      * // => [1, 2, 3, [4], 5]
7374      */
7375     function flattenDepth(array, depth) {
7376       var length = array == null ? 0 : array.length;
7377       if (!length) {
7378         return [];
7379       }
7380       depth = depth === undefined ? 1 : toInteger(depth);
7381       return baseFlatten(array, depth);
7382     }
7383
7384     /**
7385      * The inverse of `_.toPairs`; this method returns an object composed
7386      * from key-value `pairs`.
7387      *
7388      * @static
7389      * @memberOf _
7390      * @since 4.0.0
7391      * @category Array
7392      * @param {Array} pairs The key-value pairs.
7393      * @returns {Object} Returns the new object.
7394      * @example
7395      *
7396      * _.fromPairs([['a', 1], ['b', 2]]);
7397      * // => { 'a': 1, 'b': 2 }
7398      */
7399     function fromPairs(pairs) {
7400       var index = -1,
7401           length = pairs == null ? 0 : pairs.length,
7402           result = {};
7403
7404       while (++index < length) {
7405         var pair = pairs[index];
7406         result[pair[0]] = pair[1];
7407       }
7408       return result;
7409     }
7410
7411     /**
7412      * Gets the first element of `array`.
7413      *
7414      * @static
7415      * @memberOf _
7416      * @since 0.1.0
7417      * @alias first
7418      * @category Array
7419      * @param {Array} array The array to query.
7420      * @returns {*} Returns the first element of `array`.
7421      * @example
7422      *
7423      * _.head([1, 2, 3]);
7424      * // => 1
7425      *
7426      * _.head([]);
7427      * // => undefined
7428      */
7429     function head(array) {
7430       return (array && array.length) ? array[0] : undefined;
7431     }
7432
7433     /**
7434      * Gets the index at which the first occurrence of `value` is found in `array`
7435      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7436      * for equality comparisons. If `fromIndex` is negative, it's used as the
7437      * offset from the end of `array`.
7438      *
7439      * @static
7440      * @memberOf _
7441      * @since 0.1.0
7442      * @category Array
7443      * @param {Array} array The array to inspect.
7444      * @param {*} value The value to search for.
7445      * @param {number} [fromIndex=0] The index to search from.
7446      * @returns {number} Returns the index of the matched value, else `-1`.
7447      * @example
7448      *
7449      * _.indexOf([1, 2, 1, 2], 2);
7450      * // => 1
7451      *
7452      * // Search from the `fromIndex`.
7453      * _.indexOf([1, 2, 1, 2], 2, 2);
7454      * // => 3
7455      */
7456     function indexOf(array, value, fromIndex) {
7457       var length = array == null ? 0 : array.length;
7458       if (!length) {
7459         return -1;
7460       }
7461       var index = fromIndex == null ? 0 : toInteger(fromIndex);
7462       if (index < 0) {
7463         index = nativeMax(length + index, 0);
7464       }
7465       return baseIndexOf(array, value, index);
7466     }
7467
7468     /**
7469      * Gets all but the last element of `array`.
7470      *
7471      * @static
7472      * @memberOf _
7473      * @since 0.1.0
7474      * @category Array
7475      * @param {Array} array The array to query.
7476      * @returns {Array} Returns the slice of `array`.
7477      * @example
7478      *
7479      * _.initial([1, 2, 3]);
7480      * // => [1, 2]
7481      */
7482     function initial(array) {
7483       var length = array == null ? 0 : array.length;
7484       return length ? baseSlice(array, 0, -1) : [];
7485     }
7486
7487     /**
7488      * Creates an array of unique values that are included in all given arrays
7489      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7490      * for equality comparisons. The order and references of result values are
7491      * determined by the first array.
7492      *
7493      * @static
7494      * @memberOf _
7495      * @since 0.1.0
7496      * @category Array
7497      * @param {...Array} [arrays] The arrays to inspect.
7498      * @returns {Array} Returns the new array of intersecting values.
7499      * @example
7500      *
7501      * _.intersection([2, 1], [2, 3]);
7502      * // => [2]
7503      */
7504     var intersection = baseRest(function(arrays) {
7505       var mapped = arrayMap(arrays, castArrayLikeObject);
7506       return (mapped.length && mapped[0] === arrays[0])
7507         ? baseIntersection(mapped)
7508         : [];
7509     });
7510
7511     /**
7512      * This method is like `_.intersection` except that it accepts `iteratee`
7513      * which is invoked for each element of each `arrays` to generate the criterion
7514      * by which they're compared. The order and references of result values are
7515      * determined by the first array. The iteratee is invoked with one argument:
7516      * (value).
7517      *
7518      * @static
7519      * @memberOf _
7520      * @since 4.0.0
7521      * @category Array
7522      * @param {...Array} [arrays] The arrays to inspect.
7523      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7524      * @returns {Array} Returns the new array of intersecting values.
7525      * @example
7526      *
7527      * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7528      * // => [2.1]
7529      *
7530      * // The `_.property` iteratee shorthand.
7531      * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7532      * // => [{ 'x': 1 }]
7533      */
7534     var intersectionBy = baseRest(function(arrays) {
7535       var iteratee = last(arrays),
7536           mapped = arrayMap(arrays, castArrayLikeObject);
7537
7538       if (iteratee === last(mapped)) {
7539         iteratee = undefined;
7540       } else {
7541         mapped.pop();
7542       }
7543       return (mapped.length && mapped[0] === arrays[0])
7544         ? baseIntersection(mapped, getIteratee(iteratee, 2))
7545         : [];
7546     });
7547
7548     /**
7549      * This method is like `_.intersection` except that it accepts `comparator`
7550      * which is invoked to compare elements of `arrays`. The order and references
7551      * of result values are determined by the first array. The comparator is
7552      * invoked with two arguments: (arrVal, othVal).
7553      *
7554      * @static
7555      * @memberOf _
7556      * @since 4.0.0
7557      * @category Array
7558      * @param {...Array} [arrays] The arrays to inspect.
7559      * @param {Function} [comparator] The comparator invoked per element.
7560      * @returns {Array} Returns the new array of intersecting values.
7561      * @example
7562      *
7563      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7564      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7565      *
7566      * _.intersectionWith(objects, others, _.isEqual);
7567      * // => [{ 'x': 1, 'y': 2 }]
7568      */
7569     var intersectionWith = baseRest(function(arrays) {
7570       var comparator = last(arrays),
7571           mapped = arrayMap(arrays, castArrayLikeObject);
7572
7573       comparator = typeof comparator == 'function' ? comparator : undefined;
7574       if (comparator) {
7575         mapped.pop();
7576       }
7577       return (mapped.length && mapped[0] === arrays[0])
7578         ? baseIntersection(mapped, undefined, comparator)
7579         : [];
7580     });
7581
7582     /**
7583      * Converts all elements in `array` into a string separated by `separator`.
7584      *
7585      * @static
7586      * @memberOf _
7587      * @since 4.0.0
7588      * @category Array
7589      * @param {Array} array The array to convert.
7590      * @param {string} [separator=','] The element separator.
7591      * @returns {string} Returns the joined string.
7592      * @example
7593      *
7594      * _.join(['a', 'b', 'c'], '~');
7595      * // => 'a~b~c'
7596      */
7597     function join(array, separator) {
7598       return array == null ? '' : nativeJoin.call(array, separator);
7599     }
7600
7601     /**
7602      * Gets the last element of `array`.
7603      *
7604      * @static
7605      * @memberOf _
7606      * @since 0.1.0
7607      * @category Array
7608      * @param {Array} array The array to query.
7609      * @returns {*} Returns the last element of `array`.
7610      * @example
7611      *
7612      * _.last([1, 2, 3]);
7613      * // => 3
7614      */
7615     function last(array) {
7616       var length = array == null ? 0 : array.length;
7617       return length ? array[length - 1] : undefined;
7618     }
7619
7620     /**
7621      * This method is like `_.indexOf` except that it iterates over elements of
7622      * `array` from right to left.
7623      *
7624      * @static
7625      * @memberOf _
7626      * @since 0.1.0
7627      * @category Array
7628      * @param {Array} array The array to inspect.
7629      * @param {*} value The value to search for.
7630      * @param {number} [fromIndex=array.length-1] The index to search from.
7631      * @returns {number} Returns the index of the matched value, else `-1`.
7632      * @example
7633      *
7634      * _.lastIndexOf([1, 2, 1, 2], 2);
7635      * // => 3
7636      *
7637      * // Search from the `fromIndex`.
7638      * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7639      * // => 1
7640      */
7641     function lastIndexOf(array, value, fromIndex) {
7642       var length = array == null ? 0 : array.length;
7643       if (!length) {
7644         return -1;
7645       }
7646       var index = length;
7647       if (fromIndex !== undefined) {
7648         index = toInteger(fromIndex);
7649         index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7650       }
7651       return value === value
7652         ? strictLastIndexOf(array, value, index)
7653         : baseFindIndex(array, baseIsNaN, index, true);
7654     }
7655
7656     /**
7657      * Gets the element at index `n` of `array`. If `n` is negative, the nth
7658      * element from the end is returned.
7659      *
7660      * @static
7661      * @memberOf _
7662      * @since 4.11.0
7663      * @category Array
7664      * @param {Array} array The array to query.
7665      * @param {number} [n=0] The index of the element to return.
7666      * @returns {*} Returns the nth element of `array`.
7667      * @example
7668      *
7669      * var array = ['a', 'b', 'c', 'd'];
7670      *
7671      * _.nth(array, 1);
7672      * // => 'b'
7673      *
7674      * _.nth(array, -2);
7675      * // => 'c';
7676      */
7677     function nth(array, n) {
7678       return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
7679     }
7680
7681     /**
7682      * Removes all given values from `array` using
7683      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7684      * for equality comparisons.
7685      *
7686      * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
7687      * to remove elements from an array by predicate.
7688      *
7689      * @static
7690      * @memberOf _
7691      * @since 2.0.0
7692      * @category Array
7693      * @param {Array} array The array to modify.
7694      * @param {...*} [values] The values to remove.
7695      * @returns {Array} Returns `array`.
7696      * @example
7697      *
7698      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7699      *
7700      * _.pull(array, 'a', 'c');
7701      * console.log(array);
7702      * // => ['b', 'b']
7703      */
7704     var pull = baseRest(pullAll);
7705
7706     /**
7707      * This method is like `_.pull` except that it accepts an array of values to remove.
7708      *
7709      * **Note:** Unlike `_.difference`, this method mutates `array`.
7710      *
7711      * @static
7712      * @memberOf _
7713      * @since 4.0.0
7714      * @category Array
7715      * @param {Array} array The array to modify.
7716      * @param {Array} values The values to remove.
7717      * @returns {Array} Returns `array`.
7718      * @example
7719      *
7720      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7721      *
7722      * _.pullAll(array, ['a', 'c']);
7723      * console.log(array);
7724      * // => ['b', 'b']
7725      */
7726     function pullAll(array, values) {
7727       return (array && array.length && values && values.length)
7728         ? basePullAll(array, values)
7729         : array;
7730     }
7731
7732     /**
7733      * This method is like `_.pullAll` except that it accepts `iteratee` which is
7734      * invoked for each element of `array` and `values` to generate the criterion
7735      * by which they're compared. The iteratee is invoked with one argument: (value).
7736      *
7737      * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
7738      *
7739      * @static
7740      * @memberOf _
7741      * @since 4.0.0
7742      * @category Array
7743      * @param {Array} array The array to modify.
7744      * @param {Array} values The values to remove.
7745      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7746      * @returns {Array} Returns `array`.
7747      * @example
7748      *
7749      * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
7750      *
7751      * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
7752      * console.log(array);
7753      * // => [{ 'x': 2 }]
7754      */
7755     function pullAllBy(array, values, iteratee) {
7756       return (array && array.length && values && values.length)
7757         ? basePullAll(array, values, getIteratee(iteratee, 2))
7758         : array;
7759     }
7760
7761     /**
7762      * This method is like `_.pullAll` except that it accepts `comparator` which
7763      * is invoked to compare elements of `array` to `values`. The comparator is
7764      * invoked with two arguments: (arrVal, othVal).
7765      *
7766      * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
7767      *
7768      * @static
7769      * @memberOf _
7770      * @since 4.6.0
7771      * @category Array
7772      * @param {Array} array The array to modify.
7773      * @param {Array} values The values to remove.
7774      * @param {Function} [comparator] The comparator invoked per element.
7775      * @returns {Array} Returns `array`.
7776      * @example
7777      *
7778      * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
7779      *
7780      * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
7781      * console.log(array);
7782      * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
7783      */
7784     function pullAllWith(array, values, comparator) {
7785       return (array && array.length && values && values.length)
7786         ? basePullAll(array, values, undefined, comparator)
7787         : array;
7788     }
7789
7790     /**
7791      * Removes elements from `array` corresponding to `indexes` and returns an
7792      * array of removed elements.
7793      *
7794      * **Note:** Unlike `_.at`, this method mutates `array`.
7795      *
7796      * @static
7797      * @memberOf _
7798      * @since 3.0.0
7799      * @category Array
7800      * @param {Array} array The array to modify.
7801      * @param {...(number|number[])} [indexes] The indexes of elements to remove.
7802      * @returns {Array} Returns the new array of removed elements.
7803      * @example
7804      *
7805      * var array = ['a', 'b', 'c', 'd'];
7806      * var pulled = _.pullAt(array, [1, 3]);
7807      *
7808      * console.log(array);
7809      * // => ['a', 'c']
7810      *
7811      * console.log(pulled);
7812      * // => ['b', 'd']
7813      */
7814     var pullAt = flatRest(function(array, indexes) {
7815       var length = array == null ? 0 : array.length,
7816           result = baseAt(array, indexes);
7817
7818       basePullAt(array, arrayMap(indexes, function(index) {
7819         return isIndex(index, length) ? +index : index;
7820       }).sort(compareAscending));
7821
7822       return result;
7823     });
7824
7825     /**
7826      * Removes all elements from `array` that `predicate` returns truthy for
7827      * and returns an array of the removed elements. The predicate is invoked
7828      * with three arguments: (value, index, array).
7829      *
7830      * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
7831      * to pull elements from an array by value.
7832      *
7833      * @static
7834      * @memberOf _
7835      * @since 2.0.0
7836      * @category Array
7837      * @param {Array} array The array to modify.
7838      * @param {Function} [predicate=_.identity] The function invoked per iteration.
7839      * @returns {Array} Returns the new array of removed elements.
7840      * @example
7841      *
7842      * var array = [1, 2, 3, 4];
7843      * var evens = _.remove(array, function(n) {
7844      *   return n % 2 == 0;
7845      * });
7846      *
7847      * console.log(array);
7848      * // => [1, 3]
7849      *
7850      * console.log(evens);
7851      * // => [2, 4]
7852      */
7853     function remove(array, predicate) {
7854       var result = [];
7855       if (!(array && array.length)) {
7856         return result;
7857       }
7858       var index = -1,
7859           indexes = [],
7860           length = array.length;
7861
7862       predicate = getIteratee(predicate, 3);
7863       while (++index < length) {
7864         var value = array[index];
7865         if (predicate(value, index, array)) {
7866           result.push(value);
7867           indexes.push(index);
7868         }
7869       }
7870       basePullAt(array, indexes);
7871       return result;
7872     }
7873
7874     /**
7875      * Reverses `array` so that the first element becomes the last, the second
7876      * element becomes the second to last, and so on.
7877      *
7878      * **Note:** This method mutates `array` and is based on
7879      * [`Array#reverse`](https://mdn.io/Array/reverse).
7880      *
7881      * @static
7882      * @memberOf _
7883      * @since 4.0.0
7884      * @category Array
7885      * @param {Array} array The array to modify.
7886      * @returns {Array} Returns `array`.
7887      * @example
7888      *
7889      * var array = [1, 2, 3];
7890      *
7891      * _.reverse(array);
7892      * // => [3, 2, 1]
7893      *
7894      * console.log(array);
7895      * // => [3, 2, 1]
7896      */
7897     function reverse(array) {
7898       return array == null ? array : nativeReverse.call(array);
7899     }
7900
7901     /**
7902      * Creates a slice of `array` from `start` up to, but not including, `end`.
7903      *
7904      * **Note:** This method is used instead of
7905      * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
7906      * returned.
7907      *
7908      * @static
7909      * @memberOf _
7910      * @since 3.0.0
7911      * @category Array
7912      * @param {Array} array The array to slice.
7913      * @param {number} [start=0] The start position.
7914      * @param {number} [end=array.length] The end position.
7915      * @returns {Array} Returns the slice of `array`.
7916      */
7917     function slice(array, start, end) {
7918       var length = array == null ? 0 : array.length;
7919       if (!length) {
7920         return [];
7921       }
7922       if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
7923         start = 0;
7924         end = length;
7925       }
7926       else {
7927         start = start == null ? 0 : toInteger(start);
7928         end = end === undefined ? length : toInteger(end);
7929       }
7930       return baseSlice(array, start, end);
7931     }
7932
7933     /**
7934      * Uses a binary search to determine the lowest index at which `value`
7935      * should be inserted into `array` in order to maintain its sort order.
7936      *
7937      * @static
7938      * @memberOf _
7939      * @since 0.1.0
7940      * @category Array
7941      * @param {Array} array The sorted array to inspect.
7942      * @param {*} value The value to evaluate.
7943      * @returns {number} Returns the index at which `value` should be inserted
7944      *  into `array`.
7945      * @example
7946      *
7947      * _.sortedIndex([30, 50], 40);
7948      * // => 1
7949      */
7950     function sortedIndex(array, value) {
7951       return baseSortedIndex(array, value);
7952     }
7953
7954     /**
7955      * This method is like `_.sortedIndex` except that it accepts `iteratee`
7956      * which is invoked for `value` and each element of `array` to compute their
7957      * sort ranking. The iteratee is invoked with one argument: (value).
7958      *
7959      * @static
7960      * @memberOf _
7961      * @since 4.0.0
7962      * @category Array
7963      * @param {Array} array The sorted array to inspect.
7964      * @param {*} value The value to evaluate.
7965      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7966      * @returns {number} Returns the index at which `value` should be inserted
7967      *  into `array`.
7968      * @example
7969      *
7970      * var objects = [{ 'x': 4 }, { 'x': 5 }];
7971      *
7972      * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
7973      * // => 0
7974      *
7975      * // The `_.property` iteratee shorthand.
7976      * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
7977      * // => 0
7978      */
7979     function sortedIndexBy(array, value, iteratee) {
7980       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
7981     }
7982
7983     /**
7984      * This method is like `_.indexOf` except that it performs a binary
7985      * search on a sorted `array`.
7986      *
7987      * @static
7988      * @memberOf _
7989      * @since 4.0.0
7990      * @category Array
7991      * @param {Array} array The array to inspect.
7992      * @param {*} value The value to search for.
7993      * @returns {number} Returns the index of the matched value, else `-1`.
7994      * @example
7995      *
7996      * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
7997      * // => 1
7998      */
7999     function sortedIndexOf(array, value) {
8000       var length = array == null ? 0 : array.length;
8001       if (length) {
8002         var index = baseSortedIndex(array, value);
8003         if (index < length && eq(array[index], value)) {
8004           return index;
8005         }
8006       }
8007       return -1;
8008     }
8009
8010     /**
8011      * This method is like `_.sortedIndex` except that it returns the highest
8012      * index at which `value` should be inserted into `array` in order to
8013      * maintain its sort order.
8014      *
8015      * @static
8016      * @memberOf _
8017      * @since 3.0.0
8018      * @category Array
8019      * @param {Array} array The sorted array to inspect.
8020      * @param {*} value The value to evaluate.
8021      * @returns {number} Returns the index at which `value` should be inserted
8022      *  into `array`.
8023      * @example
8024      *
8025      * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
8026      * // => 4
8027      */
8028     function sortedLastIndex(array, value) {
8029       return baseSortedIndex(array, value, true);
8030     }
8031
8032     /**
8033      * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
8034      * which is invoked for `value` and each element of `array` to compute their
8035      * sort ranking. The iteratee is invoked with one argument: (value).
8036      *
8037      * @static
8038      * @memberOf _
8039      * @since 4.0.0
8040      * @category Array
8041      * @param {Array} array The sorted array to inspect.
8042      * @param {*} value The value to evaluate.
8043      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8044      * @returns {number} Returns the index at which `value` should be inserted
8045      *  into `array`.
8046      * @example
8047      *
8048      * var objects = [{ 'x': 4 }, { 'x': 5 }];
8049      *
8050      * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8051      * // => 1
8052      *
8053      * // The `_.property` iteratee shorthand.
8054      * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8055      * // => 1
8056      */
8057     function sortedLastIndexBy(array, value, iteratee) {
8058       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8059     }
8060
8061     /**
8062      * This method is like `_.lastIndexOf` except that it performs a binary
8063      * search on a sorted `array`.
8064      *
8065      * @static
8066      * @memberOf _
8067      * @since 4.0.0
8068      * @category Array
8069      * @param {Array} array The array to inspect.
8070      * @param {*} value The value to search for.
8071      * @returns {number} Returns the index of the matched value, else `-1`.
8072      * @example
8073      *
8074      * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8075      * // => 3
8076      */
8077     function sortedLastIndexOf(array, value) {
8078       var length = array == null ? 0 : array.length;
8079       if (length) {
8080         var index = baseSortedIndex(array, value, true) - 1;
8081         if (eq(array[index], value)) {
8082           return index;
8083         }
8084       }
8085       return -1;
8086     }
8087
8088     /**
8089      * This method is like `_.uniq` except that it's designed and optimized
8090      * for sorted arrays.
8091      *
8092      * @static
8093      * @memberOf _
8094      * @since 4.0.0
8095      * @category Array
8096      * @param {Array} array The array to inspect.
8097      * @returns {Array} Returns the new duplicate free array.
8098      * @example
8099      *
8100      * _.sortedUniq([1, 1, 2]);
8101      * // => [1, 2]
8102      */
8103     function sortedUniq(array) {
8104       return (array && array.length)
8105         ? baseSortedUniq(array)
8106         : [];
8107     }
8108
8109     /**
8110      * This method is like `_.uniqBy` except that it's designed and optimized
8111      * for sorted arrays.
8112      *
8113      * @static
8114      * @memberOf _
8115      * @since 4.0.0
8116      * @category Array
8117      * @param {Array} array The array to inspect.
8118      * @param {Function} [iteratee] The iteratee invoked per element.
8119      * @returns {Array} Returns the new duplicate free array.
8120      * @example
8121      *
8122      * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8123      * // => [1.1, 2.3]
8124      */
8125     function sortedUniqBy(array, iteratee) {
8126       return (array && array.length)
8127         ? baseSortedUniq(array, getIteratee(iteratee, 2))
8128         : [];
8129     }
8130
8131     /**
8132      * Gets all but the first element of `array`.
8133      *
8134      * @static
8135      * @memberOf _
8136      * @since 4.0.0
8137      * @category Array
8138      * @param {Array} array The array to query.
8139      * @returns {Array} Returns the slice of `array`.
8140      * @example
8141      *
8142      * _.tail([1, 2, 3]);
8143      * // => [2, 3]
8144      */
8145     function tail(array) {
8146       var length = array == null ? 0 : array.length;
8147       return length ? baseSlice(array, 1, length) : [];
8148     }
8149
8150     /**
8151      * Creates a slice of `array` with `n` elements taken from the beginning.
8152      *
8153      * @static
8154      * @memberOf _
8155      * @since 0.1.0
8156      * @category Array
8157      * @param {Array} array The array to query.
8158      * @param {number} [n=1] The number of elements to take.
8159      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8160      * @returns {Array} Returns the slice of `array`.
8161      * @example
8162      *
8163      * _.take([1, 2, 3]);
8164      * // => [1]
8165      *
8166      * _.take([1, 2, 3], 2);
8167      * // => [1, 2]
8168      *
8169      * _.take([1, 2, 3], 5);
8170      * // => [1, 2, 3]
8171      *
8172      * _.take([1, 2, 3], 0);
8173      * // => []
8174      */
8175     function take(array, n, guard) {
8176       if (!(array && array.length)) {
8177         return [];
8178       }
8179       n = (guard || n === undefined) ? 1 : toInteger(n);
8180       return baseSlice(array, 0, n < 0 ? 0 : n);
8181     }
8182
8183     /**
8184      * Creates a slice of `array` with `n` elements taken from the end.
8185      *
8186      * @static
8187      * @memberOf _
8188      * @since 3.0.0
8189      * @category Array
8190      * @param {Array} array The array to query.
8191      * @param {number} [n=1] The number of elements to take.
8192      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8193      * @returns {Array} Returns the slice of `array`.
8194      * @example
8195      *
8196      * _.takeRight([1, 2, 3]);
8197      * // => [3]
8198      *
8199      * _.takeRight([1, 2, 3], 2);
8200      * // => [2, 3]
8201      *
8202      * _.takeRight([1, 2, 3], 5);
8203      * // => [1, 2, 3]
8204      *
8205      * _.takeRight([1, 2, 3], 0);
8206      * // => []
8207      */
8208     function takeRight(array, n, guard) {
8209       var length = array == null ? 0 : array.length;
8210       if (!length) {
8211         return [];
8212       }
8213       n = (guard || n === undefined) ? 1 : toInteger(n);
8214       n = length - n;
8215       return baseSlice(array, n < 0 ? 0 : n, length);
8216     }
8217
8218     /**
8219      * Creates a slice of `array` with elements taken from the end. Elements are
8220      * taken until `predicate` returns falsey. The predicate is invoked with
8221      * three arguments: (value, index, array).
8222      *
8223      * @static
8224      * @memberOf _
8225      * @since 3.0.0
8226      * @category Array
8227      * @param {Array} array The array to query.
8228      * @param {Function} [predicate=_.identity] The function invoked per iteration.
8229      * @returns {Array} Returns the slice of `array`.
8230      * @example
8231      *
8232      * var users = [
8233      *   { 'user': 'barney',  'active': true },
8234      *   { 'user': 'fred',    'active': false },
8235      *   { 'user': 'pebbles', 'active': false }
8236      * ];
8237      *
8238      * _.takeRightWhile(users, function(o) { return !o.active; });
8239      * // => objects for ['fred', 'pebbles']
8240      *
8241      * // The `_.matches` iteratee shorthand.
8242      * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8243      * // => objects for ['pebbles']
8244      *
8245      * // The `_.matchesProperty` iteratee shorthand.
8246      * _.takeRightWhile(users, ['active', false]);
8247      * // => objects for ['fred', 'pebbles']
8248      *
8249      * // The `_.property` iteratee shorthand.
8250      * _.takeRightWhile(users, 'active');
8251      * // => []
8252      */
8253     function takeRightWhile(array, predicate) {
8254       return (array && array.length)
8255         ? baseWhile(array, getIteratee(predicate, 3), false, true)
8256         : [];
8257     }
8258
8259     /**
8260      * Creates a slice of `array` with elements taken from the beginning. Elements
8261      * are taken until `predicate` returns falsey. The predicate is invoked with
8262      * three arguments: (value, index, array).
8263      *
8264      * @static
8265      * @memberOf _
8266      * @since 3.0.0
8267      * @category Array
8268      * @param {Array} array The array to query.
8269      * @param {Function} [predicate=_.identity] The function invoked per iteration.
8270      * @returns {Array} Returns the slice of `array`.
8271      * @example
8272      *
8273      * var users = [
8274      *   { 'user': 'barney',  'active': false },
8275      *   { 'user': 'fred',    'active': false },
8276      *   { 'user': 'pebbles', 'active': true }
8277      * ];
8278      *
8279      * _.takeWhile(users, function(o) { return !o.active; });
8280      * // => objects for ['barney', 'fred']
8281      *
8282      * // The `_.matches` iteratee shorthand.
8283      * _.takeWhile(users, { 'user': 'barney', 'active': false });
8284      * // => objects for ['barney']
8285      *
8286      * // The `_.matchesProperty` iteratee shorthand.
8287      * _.takeWhile(users, ['active', false]);
8288      * // => objects for ['barney', 'fred']
8289      *
8290      * // The `_.property` iteratee shorthand.
8291      * _.takeWhile(users, 'active');
8292      * // => []
8293      */
8294     function takeWhile(array, predicate) {
8295       return (array && array.length)
8296         ? baseWhile(array, getIteratee(predicate, 3))
8297         : [];
8298     }
8299
8300     /**
8301      * Creates an array of unique values, in order, from all given arrays using
8302      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8303      * for equality comparisons.
8304      *
8305      * @static
8306      * @memberOf _
8307      * @since 0.1.0
8308      * @category Array
8309      * @param {...Array} [arrays] The arrays to inspect.
8310      * @returns {Array} Returns the new array of combined values.
8311      * @example
8312      *
8313      * _.union([2], [1, 2]);
8314      * // => [2, 1]
8315      */
8316     var union = baseRest(function(arrays) {
8317       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8318     });
8319
8320     /**
8321      * This method is like `_.union` except that it accepts `iteratee` which is
8322      * invoked for each element of each `arrays` to generate the criterion by
8323      * which uniqueness is computed. Result values are chosen from the first
8324      * array in which the value occurs. The iteratee is invoked with one argument:
8325      * (value).
8326      *
8327      * @static
8328      * @memberOf _
8329      * @since 4.0.0
8330      * @category Array
8331      * @param {...Array} [arrays] The arrays to inspect.
8332      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8333      * @returns {Array} Returns the new array of combined values.
8334      * @example
8335      *
8336      * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8337      * // => [2.1, 1.2]
8338      *
8339      * // The `_.property` iteratee shorthand.
8340      * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8341      * // => [{ 'x': 1 }, { 'x': 2 }]
8342      */
8343     var unionBy = baseRest(function(arrays) {
8344       var iteratee = last(arrays);
8345       if (isArrayLikeObject(iteratee)) {
8346         iteratee = undefined;
8347       }
8348       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
8349     });
8350
8351     /**
8352      * This method is like `_.union` except that it accepts `comparator` which
8353      * is invoked to compare elements of `arrays`. Result values are chosen from
8354      * the first array in which the value occurs. The comparator is invoked
8355      * with two arguments: (arrVal, othVal).
8356      *
8357      * @static
8358      * @memberOf _
8359      * @since 4.0.0
8360      * @category Array
8361      * @param {...Array} [arrays] The arrays to inspect.
8362      * @param {Function} [comparator] The comparator invoked per element.
8363      * @returns {Array} Returns the new array of combined values.
8364      * @example
8365      *
8366      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8367      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8368      *
8369      * _.unionWith(objects, others, _.isEqual);
8370      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8371      */
8372     var unionWith = baseRest(function(arrays) {
8373       var comparator = last(arrays);
8374       comparator = typeof comparator == 'function' ? comparator : undefined;
8375       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
8376     });
8377
8378     /**
8379      * Creates a duplicate-free version of an array, using
8380      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8381      * for equality comparisons, in which only the first occurrence of each element
8382      * is kept. The order of result values is determined by the order they occur
8383      * in the array.
8384      *
8385      * @static
8386      * @memberOf _
8387      * @since 0.1.0
8388      * @category Array
8389      * @param {Array} array The array to inspect.
8390      * @returns {Array} Returns the new duplicate free array.
8391      * @example
8392      *
8393      * _.uniq([2, 1, 2]);
8394      * // => [2, 1]
8395      */
8396     function uniq(array) {
8397       return (array && array.length) ? baseUniq(array) : [];
8398     }
8399
8400     /**
8401      * This method is like `_.uniq` except that it accepts `iteratee` which is
8402      * invoked for each element in `array` to generate the criterion by which
8403      * uniqueness is computed. The order of result values is determined by the
8404      * order they occur in the array. The iteratee is invoked with one argument:
8405      * (value).
8406      *
8407      * @static
8408      * @memberOf _
8409      * @since 4.0.0
8410      * @category Array
8411      * @param {Array} array The array to inspect.
8412      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8413      * @returns {Array} Returns the new duplicate free array.
8414      * @example
8415      *
8416      * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8417      * // => [2.1, 1.2]
8418      *
8419      * // The `_.property` iteratee shorthand.
8420      * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8421      * // => [{ 'x': 1 }, { 'x': 2 }]
8422      */
8423     function uniqBy(array, iteratee) {
8424       return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
8425     }
8426
8427     /**
8428      * This method is like `_.uniq` except that it accepts `comparator` which
8429      * is invoked to compare elements of `array`. The order of result values is
8430      * determined by the order they occur in the array.The comparator is invoked
8431      * with two arguments: (arrVal, othVal).
8432      *
8433      * @static
8434      * @memberOf _
8435      * @since 4.0.0
8436      * @category Array
8437      * @param {Array} array The array to inspect.
8438      * @param {Function} [comparator] The comparator invoked per element.
8439      * @returns {Array} Returns the new duplicate free array.
8440      * @example
8441      *
8442      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8443      *
8444      * _.uniqWith(objects, _.isEqual);
8445      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8446      */
8447     function uniqWith(array, comparator) {
8448       comparator = typeof comparator == 'function' ? comparator : undefined;
8449       return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
8450     }
8451
8452     /**
8453      * This method is like `_.zip` except that it accepts an array of grouped
8454      * elements and creates an array regrouping the elements to their pre-zip
8455      * configuration.
8456      *
8457      * @static
8458      * @memberOf _
8459      * @since 1.2.0
8460      * @category Array
8461      * @param {Array} array The array of grouped elements to process.
8462      * @returns {Array} Returns the new array of regrouped elements.
8463      * @example
8464      *
8465      * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8466      * // => [['a', 1, true], ['b', 2, false]]
8467      *
8468      * _.unzip(zipped);
8469      * // => [['a', 'b'], [1, 2], [true, false]]
8470      */
8471     function unzip(array) {
8472       if (!(array && array.length)) {
8473         return [];
8474       }
8475       var length = 0;
8476       array = arrayFilter(array, function(group) {
8477         if (isArrayLikeObject(group)) {
8478           length = nativeMax(group.length, length);
8479           return true;
8480         }
8481       });
8482       return baseTimes(length, function(index) {
8483         return arrayMap(array, baseProperty(index));
8484       });
8485     }
8486
8487     /**
8488      * This method is like `_.unzip` except that it accepts `iteratee` to specify
8489      * how regrouped values should be combined. The iteratee is invoked with the
8490      * elements of each group: (...group).
8491      *
8492      * @static
8493      * @memberOf _
8494      * @since 3.8.0
8495      * @category Array
8496      * @param {Array} array The array of grouped elements to process.
8497      * @param {Function} [iteratee=_.identity] The function to combine
8498      *  regrouped values.
8499      * @returns {Array} Returns the new array of regrouped elements.
8500      * @example
8501      *
8502      * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8503      * // => [[1, 10, 100], [2, 20, 200]]
8504      *
8505      * _.unzipWith(zipped, _.add);
8506      * // => [3, 30, 300]
8507      */
8508     function unzipWith(array, iteratee) {
8509       if (!(array && array.length)) {
8510         return [];
8511       }
8512       var result = unzip(array);
8513       if (iteratee == null) {
8514         return result;
8515       }
8516       return arrayMap(result, function(group) {
8517         return apply(iteratee, undefined, group);
8518       });
8519     }
8520
8521     /**
8522      * Creates an array excluding all given values using
8523      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8524      * for equality comparisons.
8525      *
8526      * **Note:** Unlike `_.pull`, this method returns a new array.
8527      *
8528      * @static
8529      * @memberOf _
8530      * @since 0.1.0
8531      * @category Array
8532      * @param {Array} array The array to inspect.
8533      * @param {...*} [values] The values to exclude.
8534      * @returns {Array} Returns the new array of filtered values.
8535      * @see _.difference, _.xor
8536      * @example
8537      *
8538      * _.without([2, 1, 2, 3], 1, 2);
8539      * // => [3]
8540      */
8541     var without = baseRest(function(array, values) {
8542       return isArrayLikeObject(array)
8543         ? baseDifference(array, values)
8544         : [];
8545     });
8546
8547     /**
8548      * Creates an array of unique values that is the
8549      * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
8550      * of the given arrays. The order of result values is determined by the order
8551      * they occur in the arrays.
8552      *
8553      * @static
8554      * @memberOf _
8555      * @since 2.4.0
8556      * @category Array
8557      * @param {...Array} [arrays] The arrays to inspect.
8558      * @returns {Array} Returns the new array of filtered values.
8559      * @see _.difference, _.without
8560      * @example
8561      *
8562      * _.xor([2, 1], [2, 3]);
8563      * // => [1, 3]
8564      */
8565     var xor = baseRest(function(arrays) {
8566       return baseXor(arrayFilter(arrays, isArrayLikeObject));
8567     });
8568
8569     /**
8570      * This method is like `_.xor` except that it accepts `iteratee` which is
8571      * invoked for each element of each `arrays` to generate the criterion by
8572      * which by which they're compared. The order of result values is determined
8573      * by the order they occur in the arrays. The iteratee is invoked with one
8574      * argument: (value).
8575      *
8576      * @static
8577      * @memberOf _
8578      * @since 4.0.0
8579      * @category Array
8580      * @param {...Array} [arrays] The arrays to inspect.
8581      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8582      * @returns {Array} Returns the new array of filtered values.
8583      * @example
8584      *
8585      * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8586      * // => [1.2, 3.4]
8587      *
8588      * // The `_.property` iteratee shorthand.
8589      * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8590      * // => [{ 'x': 2 }]
8591      */
8592     var xorBy = baseRest(function(arrays) {
8593       var iteratee = last(arrays);
8594       if (isArrayLikeObject(iteratee)) {
8595         iteratee = undefined;
8596       }
8597       return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
8598     });
8599
8600     /**
8601      * This method is like `_.xor` except that it accepts `comparator` which is
8602      * invoked to compare elements of `arrays`. The order of result values is
8603      * determined by the order they occur in the arrays. The comparator is invoked
8604      * with two arguments: (arrVal, othVal).
8605      *
8606      * @static
8607      * @memberOf _
8608      * @since 4.0.0
8609      * @category Array
8610      * @param {...Array} [arrays] The arrays to inspect.
8611      * @param {Function} [comparator] The comparator invoked per element.
8612      * @returns {Array} Returns the new array of filtered values.
8613      * @example
8614      *
8615      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8616      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8617      *
8618      * _.xorWith(objects, others, _.isEqual);
8619      * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8620      */
8621     var xorWith = baseRest(function(arrays) {
8622       var comparator = last(arrays);
8623       comparator = typeof comparator == 'function' ? comparator : undefined;
8624       return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
8625     });
8626
8627     /**
8628      * Creates an array of grouped elements, the first of which contains the
8629      * first elements of the given arrays, the second of which contains the
8630      * second elements of the given arrays, and so on.
8631      *
8632      * @static
8633      * @memberOf _
8634      * @since 0.1.0
8635      * @category Array
8636      * @param {...Array} [arrays] The arrays to process.
8637      * @returns {Array} Returns the new array of grouped elements.
8638      * @example
8639      *
8640      * _.zip(['a', 'b'], [1, 2], [true, false]);
8641      * // => [['a', 1, true], ['b', 2, false]]
8642      */
8643     var zip = baseRest(unzip);
8644
8645     /**
8646      * This method is like `_.fromPairs` except that it accepts two arrays,
8647      * one of property identifiers and one of corresponding values.
8648      *
8649      * @static
8650      * @memberOf _
8651      * @since 0.4.0
8652      * @category Array
8653      * @param {Array} [props=[]] The property identifiers.
8654      * @param {Array} [values=[]] The property values.
8655      * @returns {Object} Returns the new object.
8656      * @example
8657      *
8658      * _.zipObject(['a', 'b'], [1, 2]);
8659      * // => { 'a': 1, 'b': 2 }
8660      */
8661     function zipObject(props, values) {
8662       return baseZipObject(props || [], values || [], assignValue);
8663     }
8664
8665     /**
8666      * This method is like `_.zipObject` except that it supports property paths.
8667      *
8668      * @static
8669      * @memberOf _
8670      * @since 4.1.0
8671      * @category Array
8672      * @param {Array} [props=[]] The property identifiers.
8673      * @param {Array} [values=[]] The property values.
8674      * @returns {Object} Returns the new object.
8675      * @example
8676      *
8677      * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
8678      * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
8679      */
8680     function zipObjectDeep(props, values) {
8681       return baseZipObject(props || [], values || [], baseSet);
8682     }
8683
8684     /**
8685      * This method is like `_.zip` except that it accepts `iteratee` to specify
8686      * how grouped values should be combined. The iteratee is invoked with the
8687      * elements of each group: (...group).
8688      *
8689      * @static
8690      * @memberOf _
8691      * @since 3.8.0
8692      * @category Array
8693      * @param {...Array} [arrays] The arrays to process.
8694      * @param {Function} [iteratee=_.identity] The function to combine
8695      *  grouped values.
8696      * @returns {Array} Returns the new array of grouped elements.
8697      * @example
8698      *
8699      * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
8700      *   return a + b + c;
8701      * });
8702      * // => [111, 222]
8703      */
8704     var zipWith = baseRest(function(arrays) {
8705       var length = arrays.length,
8706           iteratee = length > 1 ? arrays[length - 1] : undefined;
8707
8708       iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
8709       return unzipWith(arrays, iteratee);
8710     });
8711
8712     /*------------------------------------------------------------------------*/
8713
8714     /**
8715      * Creates a `lodash` wrapper instance that wraps `value` with explicit method
8716      * chain sequences enabled. The result of such sequences must be unwrapped
8717      * with `_#value`.
8718      *
8719      * @static
8720      * @memberOf _
8721      * @since 1.3.0
8722      * @category Seq
8723      * @param {*} value The value to wrap.
8724      * @returns {Object} Returns the new `lodash` wrapper instance.
8725      * @example
8726      *
8727      * var users = [
8728      *   { 'user': 'barney',  'age': 36 },
8729      *   { 'user': 'fred',    'age': 40 },
8730      *   { 'user': 'pebbles', 'age': 1 }
8731      * ];
8732      *
8733      * var youngest = _
8734      *   .chain(users)
8735      *   .sortBy('age')
8736      *   .map(function(o) {
8737      *     return o.user + ' is ' + o.age;
8738      *   })
8739      *   .head()
8740      *   .value();
8741      * // => 'pebbles is 1'
8742      */
8743     function chain(value) {
8744       var result = lodash(value);
8745       result.__chain__ = true;
8746       return result;
8747     }
8748
8749     /**
8750      * This method invokes `interceptor` and returns `value`. The interceptor
8751      * is invoked with one argument; (value). The purpose of this method is to
8752      * "tap into" a method chain sequence in order to modify intermediate results.
8753      *
8754      * @static
8755      * @memberOf _
8756      * @since 0.1.0
8757      * @category Seq
8758      * @param {*} value The value to provide to `interceptor`.
8759      * @param {Function} interceptor The function to invoke.
8760      * @returns {*} Returns `value`.
8761      * @example
8762      *
8763      * _([1, 2, 3])
8764      *  .tap(function(array) {
8765      *    // Mutate input array.
8766      *    array.pop();
8767      *  })
8768      *  .reverse()
8769      *  .value();
8770      * // => [2, 1]
8771      */
8772     function tap(value, interceptor) {
8773       interceptor(value);
8774       return value;
8775     }
8776
8777     /**
8778      * This method is like `_.tap` except that it returns the result of `interceptor`.
8779      * The purpose of this method is to "pass thru" values replacing intermediate
8780      * results in a method chain sequence.
8781      *
8782      * @static
8783      * @memberOf _
8784      * @since 3.0.0
8785      * @category Seq
8786      * @param {*} value The value to provide to `interceptor`.
8787      * @param {Function} interceptor The function to invoke.
8788      * @returns {*} Returns the result of `interceptor`.
8789      * @example
8790      *
8791      * _('  abc  ')
8792      *  .chain()
8793      *  .trim()
8794      *  .thru(function(value) {
8795      *    return [value];
8796      *  })
8797      *  .value();
8798      * // => ['abc']
8799      */
8800     function thru(value, interceptor) {
8801       return interceptor(value);
8802     }
8803
8804     /**
8805      * This method is the wrapper version of `_.at`.
8806      *
8807      * @name at
8808      * @memberOf _
8809      * @since 1.0.0
8810      * @category Seq
8811      * @param {...(string|string[])} [paths] The property paths to pick.
8812      * @returns {Object} Returns the new `lodash` wrapper instance.
8813      * @example
8814      *
8815      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
8816      *
8817      * _(object).at(['a[0].b.c', 'a[1]']).value();
8818      * // => [3, 4]
8819      */
8820     var wrapperAt = flatRest(function(paths) {
8821       var length = paths.length,
8822           start = length ? paths[0] : 0,
8823           value = this.__wrapped__,
8824           interceptor = function(object) { return baseAt(object, paths); };
8825
8826       if (length > 1 || this.__actions__.length ||
8827           !(value instanceof LazyWrapper) || !isIndex(start)) {
8828         return this.thru(interceptor);
8829       }
8830       value = value.slice(start, +start + (length ? 1 : 0));
8831       value.__actions__.push({
8832         'func': thru,
8833         'args': [interceptor],
8834         'thisArg': undefined
8835       });
8836       return new LodashWrapper(value, this.__chain__).thru(function(array) {
8837         if (length && !array.length) {
8838           array.push(undefined);
8839         }
8840         return array;
8841       });
8842     });
8843
8844     /**
8845      * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
8846      *
8847      * @name chain
8848      * @memberOf _
8849      * @since 0.1.0
8850      * @category Seq
8851      * @returns {Object} Returns the new `lodash` wrapper instance.
8852      * @example
8853      *
8854      * var users = [
8855      *   { 'user': 'barney', 'age': 36 },
8856      *   { 'user': 'fred',   'age': 40 }
8857      * ];
8858      *
8859      * // A sequence without explicit chaining.
8860      * _(users).head();
8861      * // => { 'user': 'barney', 'age': 36 }
8862      *
8863      * // A sequence with explicit chaining.
8864      * _(users)
8865      *   .chain()
8866      *   .head()
8867      *   .pick('user')
8868      *   .value();
8869      * // => { 'user': 'barney' }
8870      */
8871     function wrapperChain() {
8872       return chain(this);
8873     }
8874
8875     /**
8876      * Executes the chain sequence and returns the wrapped result.
8877      *
8878      * @name commit
8879      * @memberOf _
8880      * @since 3.2.0
8881      * @category Seq
8882      * @returns {Object} Returns the new `lodash` wrapper instance.
8883      * @example
8884      *
8885      * var array = [1, 2];
8886      * var wrapped = _(array).push(3);
8887      *
8888      * console.log(array);
8889      * // => [1, 2]
8890      *
8891      * wrapped = wrapped.commit();
8892      * console.log(array);
8893      * // => [1, 2, 3]
8894      *
8895      * wrapped.last();
8896      * // => 3
8897      *
8898      * console.log(array);
8899      * // => [1, 2, 3]
8900      */
8901     function wrapperCommit() {
8902       return new LodashWrapper(this.value(), this.__chain__);
8903     }
8904
8905     /**
8906      * Gets the next value on a wrapped object following the
8907      * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
8908      *
8909      * @name next
8910      * @memberOf _
8911      * @since 4.0.0
8912      * @category Seq
8913      * @returns {Object} Returns the next iterator value.
8914      * @example
8915      *
8916      * var wrapped = _([1, 2]);
8917      *
8918      * wrapped.next();
8919      * // => { 'done': false, 'value': 1 }
8920      *
8921      * wrapped.next();
8922      * // => { 'done': false, 'value': 2 }
8923      *
8924      * wrapped.next();
8925      * // => { 'done': true, 'value': undefined }
8926      */
8927     function wrapperNext() {
8928       if (this.__values__ === undefined) {
8929         this.__values__ = toArray(this.value());
8930       }
8931       var done = this.__index__ >= this.__values__.length,
8932           value = done ? undefined : this.__values__[this.__index__++];
8933
8934       return { 'done': done, 'value': value };
8935     }
8936
8937     /**
8938      * Enables the wrapper to be iterable.
8939      *
8940      * @name Symbol.iterator
8941      * @memberOf _
8942      * @since 4.0.0
8943      * @category Seq
8944      * @returns {Object} Returns the wrapper object.
8945      * @example
8946      *
8947      * var wrapped = _([1, 2]);
8948      *
8949      * wrapped[Symbol.iterator]() === wrapped;
8950      * // => true
8951      *
8952      * Array.from(wrapped);
8953      * // => [1, 2]
8954      */
8955     function wrapperToIterator() {
8956       return this;
8957     }
8958
8959     /**
8960      * Creates a clone of the chain sequence planting `value` as the wrapped value.
8961      *
8962      * @name plant
8963      * @memberOf _
8964      * @since 3.2.0
8965      * @category Seq
8966      * @param {*} value The value to plant.
8967      * @returns {Object} Returns the new `lodash` wrapper instance.
8968      * @example
8969      *
8970      * function square(n) {
8971      *   return n * n;
8972      * }
8973      *
8974      * var wrapped = _([1, 2]).map(square);
8975      * var other = wrapped.plant([3, 4]);
8976      *
8977      * other.value();
8978      * // => [9, 16]
8979      *
8980      * wrapped.value();
8981      * // => [1, 4]
8982      */
8983     function wrapperPlant(value) {
8984       var result,
8985           parent = this;
8986
8987       while (parent instanceof baseLodash) {
8988         var clone = wrapperClone(parent);
8989         clone.__index__ = 0;
8990         clone.__values__ = undefined;
8991         if (result) {
8992           previous.__wrapped__ = clone;
8993         } else {
8994           result = clone;
8995         }
8996         var previous = clone;
8997         parent = parent.__wrapped__;
8998       }
8999       previous.__wrapped__ = value;
9000       return result;
9001     }
9002
9003     /**
9004      * This method is the wrapper version of `_.reverse`.
9005      *
9006      * **Note:** This method mutates the wrapped array.
9007      *
9008      * @name reverse
9009      * @memberOf _
9010      * @since 0.1.0
9011      * @category Seq
9012      * @returns {Object} Returns the new `lodash` wrapper instance.
9013      * @example
9014      *
9015      * var array = [1, 2, 3];
9016      *
9017      * _(array).reverse().value()
9018      * // => [3, 2, 1]
9019      *
9020      * console.log(array);
9021      * // => [3, 2, 1]
9022      */
9023     function wrapperReverse() {
9024       var value = this.__wrapped__;
9025       if (value instanceof LazyWrapper) {
9026         var wrapped = value;
9027         if (this.__actions__.length) {
9028           wrapped = new LazyWrapper(this);
9029         }
9030         wrapped = wrapped.reverse();
9031         wrapped.__actions__.push({
9032           'func': thru,
9033           'args': [reverse],
9034           'thisArg': undefined
9035         });
9036         return new LodashWrapper(wrapped, this.__chain__);
9037       }
9038       return this.thru(reverse);
9039     }
9040
9041     /**
9042      * Executes the chain sequence to resolve the unwrapped value.
9043      *
9044      * @name value
9045      * @memberOf _
9046      * @since 0.1.0
9047      * @alias toJSON, valueOf
9048      * @category Seq
9049      * @returns {*} Returns the resolved unwrapped value.
9050      * @example
9051      *
9052      * _([1, 2, 3]).value();
9053      * // => [1, 2, 3]
9054      */
9055     function wrapperValue() {
9056       return baseWrapperValue(this.__wrapped__, this.__actions__);
9057     }
9058
9059     /*------------------------------------------------------------------------*/
9060
9061     /**
9062      * Creates an object composed of keys generated from the results of running
9063      * each element of `collection` thru `iteratee`. The corresponding value of
9064      * each key is the number of times the key was returned by `iteratee`. The
9065      * iteratee is invoked with one argument: (value).
9066      *
9067      * @static
9068      * @memberOf _
9069      * @since 0.5.0
9070      * @category Collection
9071      * @param {Array|Object} collection The collection to iterate over.
9072      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9073      * @returns {Object} Returns the composed aggregate object.
9074      * @example
9075      *
9076      * _.countBy([6.1, 4.2, 6.3], Math.floor);
9077      * // => { '4': 1, '6': 2 }
9078      *
9079      * // The `_.property` iteratee shorthand.
9080      * _.countBy(['one', 'two', 'three'], 'length');
9081      * // => { '3': 2, '5': 1 }
9082      */
9083     var countBy = createAggregator(function(result, value, key) {
9084       if (hasOwnProperty.call(result, key)) {
9085         ++result[key];
9086       } else {
9087         baseAssignValue(result, key, 1);
9088       }
9089     });
9090
9091     /**
9092      * Checks if `predicate` returns truthy for **all** elements of `collection`.
9093      * Iteration is stopped once `predicate` returns falsey. The predicate is
9094      * invoked with three arguments: (value, index|key, collection).
9095      *
9096      * **Note:** This method returns `true` for
9097      * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
9098      * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
9099      * elements of empty collections.
9100      *
9101      * @static
9102      * @memberOf _
9103      * @since 0.1.0
9104      * @category Collection
9105      * @param {Array|Object} collection The collection to iterate over.
9106      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9107      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9108      * @returns {boolean} Returns `true` if all elements pass the predicate check,
9109      *  else `false`.
9110      * @example
9111      *
9112      * _.every([true, 1, null, 'yes'], Boolean);
9113      * // => false
9114      *
9115      * var users = [
9116      *   { 'user': 'barney', 'age': 36, 'active': false },
9117      *   { 'user': 'fred',   'age': 40, 'active': false }
9118      * ];
9119      *
9120      * // The `_.matches` iteratee shorthand.
9121      * _.every(users, { 'user': 'barney', 'active': false });
9122      * // => false
9123      *
9124      * // The `_.matchesProperty` iteratee shorthand.
9125      * _.every(users, ['active', false]);
9126      * // => true
9127      *
9128      * // The `_.property` iteratee shorthand.
9129      * _.every(users, 'active');
9130      * // => false
9131      */
9132     function every(collection, predicate, guard) {
9133       var func = isArray(collection) ? arrayEvery : baseEvery;
9134       if (guard && isIterateeCall(collection, predicate, guard)) {
9135         predicate = undefined;
9136       }
9137       return func(collection, getIteratee(predicate, 3));
9138     }
9139
9140     /**
9141      * Iterates over elements of `collection`, returning an array of all elements
9142      * `predicate` returns truthy for. The predicate is invoked with three
9143      * arguments: (value, index|key, collection).
9144      *
9145      * **Note:** Unlike `_.remove`, this method returns a new array.
9146      *
9147      * @static
9148      * @memberOf _
9149      * @since 0.1.0
9150      * @category Collection
9151      * @param {Array|Object} collection The collection to iterate over.
9152      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9153      * @returns {Array} Returns the new filtered array.
9154      * @see _.reject
9155      * @example
9156      *
9157      * var users = [
9158      *   { 'user': 'barney', 'age': 36, 'active': true },
9159      *   { 'user': 'fred',   'age': 40, 'active': false }
9160      * ];
9161      *
9162      * _.filter(users, function(o) { return !o.active; });
9163      * // => objects for ['fred']
9164      *
9165      * // The `_.matches` iteratee shorthand.
9166      * _.filter(users, { 'age': 36, 'active': true });
9167      * // => objects for ['barney']
9168      *
9169      * // The `_.matchesProperty` iteratee shorthand.
9170      * _.filter(users, ['active', false]);
9171      * // => objects for ['fred']
9172      *
9173      * // The `_.property` iteratee shorthand.
9174      * _.filter(users, 'active');
9175      * // => objects for ['barney']
9176      */
9177     function filter(collection, predicate) {
9178       var func = isArray(collection) ? arrayFilter : baseFilter;
9179       return func(collection, getIteratee(predicate, 3));
9180     }
9181
9182     /**
9183      * Iterates over elements of `collection`, returning the first element
9184      * `predicate` returns truthy for. The predicate is invoked with three
9185      * arguments: (value, index|key, collection).
9186      *
9187      * @static
9188      * @memberOf _
9189      * @since 0.1.0
9190      * @category Collection
9191      * @param {Array|Object} collection The collection to inspect.
9192      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9193      * @param {number} [fromIndex=0] The index to search from.
9194      * @returns {*} Returns the matched element, else `undefined`.
9195      * @example
9196      *
9197      * var users = [
9198      *   { 'user': 'barney',  'age': 36, 'active': true },
9199      *   { 'user': 'fred',    'age': 40, 'active': false },
9200      *   { 'user': 'pebbles', 'age': 1,  'active': true }
9201      * ];
9202      *
9203      * _.find(users, function(o) { return o.age < 40; });
9204      * // => object for 'barney'
9205      *
9206      * // The `_.matches` iteratee shorthand.
9207      * _.find(users, { 'age': 1, 'active': true });
9208      * // => object for 'pebbles'
9209      *
9210      * // The `_.matchesProperty` iteratee shorthand.
9211      * _.find(users, ['active', false]);
9212      * // => object for 'fred'
9213      *
9214      * // The `_.property` iteratee shorthand.
9215      * _.find(users, 'active');
9216      * // => object for 'barney'
9217      */
9218     var find = createFind(findIndex);
9219
9220     /**
9221      * This method is like `_.find` except that it iterates over elements of
9222      * `collection` from right to left.
9223      *
9224      * @static
9225      * @memberOf _
9226      * @since 2.0.0
9227      * @category Collection
9228      * @param {Array|Object} collection The collection to inspect.
9229      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9230      * @param {number} [fromIndex=collection.length-1] The index to search from.
9231      * @returns {*} Returns the matched element, else `undefined`.
9232      * @example
9233      *
9234      * _.findLast([1, 2, 3, 4], function(n) {
9235      *   return n % 2 == 1;
9236      * });
9237      * // => 3
9238      */
9239     var findLast = createFind(findLastIndex);
9240
9241     /**
9242      * Creates a flattened array of values by running each element in `collection`
9243      * thru `iteratee` and flattening the mapped results. The iteratee is invoked
9244      * with three arguments: (value, index|key, collection).
9245      *
9246      * @static
9247      * @memberOf _
9248      * @since 4.0.0
9249      * @category Collection
9250      * @param {Array|Object} collection The collection to iterate over.
9251      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9252      * @returns {Array} Returns the new flattened array.
9253      * @example
9254      *
9255      * function duplicate(n) {
9256      *   return [n, n];
9257      * }
9258      *
9259      * _.flatMap([1, 2], duplicate);
9260      * // => [1, 1, 2, 2]
9261      */
9262     function flatMap(collection, iteratee) {
9263       return baseFlatten(map(collection, iteratee), 1);
9264     }
9265
9266     /**
9267      * This method is like `_.flatMap` except that it recursively flattens the
9268      * mapped results.
9269      *
9270      * @static
9271      * @memberOf _
9272      * @since 4.7.0
9273      * @category Collection
9274      * @param {Array|Object} collection The collection to iterate over.
9275      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9276      * @returns {Array} Returns the new flattened array.
9277      * @example
9278      *
9279      * function duplicate(n) {
9280      *   return [[[n, n]]];
9281      * }
9282      *
9283      * _.flatMapDeep([1, 2], duplicate);
9284      * // => [1, 1, 2, 2]
9285      */
9286     function flatMapDeep(collection, iteratee) {
9287       return baseFlatten(map(collection, iteratee), INFINITY);
9288     }
9289
9290     /**
9291      * This method is like `_.flatMap` except that it recursively flattens the
9292      * mapped results up to `depth` times.
9293      *
9294      * @static
9295      * @memberOf _
9296      * @since 4.7.0
9297      * @category Collection
9298      * @param {Array|Object} collection The collection to iterate over.
9299      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9300      * @param {number} [depth=1] The maximum recursion depth.
9301      * @returns {Array} Returns the new flattened array.
9302      * @example
9303      *
9304      * function duplicate(n) {
9305      *   return [[[n, n]]];
9306      * }
9307      *
9308      * _.flatMapDepth([1, 2], duplicate, 2);
9309      * // => [[1, 1], [2, 2]]
9310      */
9311     function flatMapDepth(collection, iteratee, depth) {
9312       depth = depth === undefined ? 1 : toInteger(depth);
9313       return baseFlatten(map(collection, iteratee), depth);
9314     }
9315
9316     /**
9317      * Iterates over elements of `collection` and invokes `iteratee` for each element.
9318      * The iteratee is invoked with three arguments: (value, index|key, collection).
9319      * Iteratee functions may exit iteration early by explicitly returning `false`.
9320      *
9321      * **Note:** As with other "Collections" methods, objects with a "length"
9322      * property are iterated like arrays. To avoid this behavior use `_.forIn`
9323      * or `_.forOwn` for object iteration.
9324      *
9325      * @static
9326      * @memberOf _
9327      * @since 0.1.0
9328      * @alias each
9329      * @category Collection
9330      * @param {Array|Object} collection The collection to iterate over.
9331      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9332      * @returns {Array|Object} Returns `collection`.
9333      * @see _.forEachRight
9334      * @example
9335      *
9336      * _.forEach([1, 2], function(value) {
9337      *   console.log(value);
9338      * });
9339      * // => Logs `1` then `2`.
9340      *
9341      * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9342      *   console.log(key);
9343      * });
9344      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9345      */
9346     function forEach(collection, iteratee) {
9347       var func = isArray(collection) ? arrayEach : baseEach;
9348       return func(collection, getIteratee(iteratee, 3));
9349     }
9350
9351     /**
9352      * This method is like `_.forEach` except that it iterates over elements of
9353      * `collection` from right to left.
9354      *
9355      * @static
9356      * @memberOf _
9357      * @since 2.0.0
9358      * @alias eachRight
9359      * @category Collection
9360      * @param {Array|Object} collection The collection to iterate over.
9361      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9362      * @returns {Array|Object} Returns `collection`.
9363      * @see _.forEach
9364      * @example
9365      *
9366      * _.forEachRight([1, 2], function(value) {
9367      *   console.log(value);
9368      * });
9369      * // => Logs `2` then `1`.
9370      */
9371     function forEachRight(collection, iteratee) {
9372       var func = isArray(collection) ? arrayEachRight : baseEachRight;
9373       return func(collection, getIteratee(iteratee, 3));
9374     }
9375
9376     /**
9377      * Creates an object composed of keys generated from the results of running
9378      * each element of `collection` thru `iteratee`. The order of grouped values
9379      * is determined by the order they occur in `collection`. The corresponding
9380      * value of each key is an array of elements responsible for generating the
9381      * key. The iteratee is invoked with one argument: (value).
9382      *
9383      * @static
9384      * @memberOf _
9385      * @since 0.1.0
9386      * @category Collection
9387      * @param {Array|Object} collection The collection to iterate over.
9388      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9389      * @returns {Object} Returns the composed aggregate object.
9390      * @example
9391      *
9392      * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9393      * // => { '4': [4.2], '6': [6.1, 6.3] }
9394      *
9395      * // The `_.property` iteratee shorthand.
9396      * _.groupBy(['one', 'two', 'three'], 'length');
9397      * // => { '3': ['one', 'two'], '5': ['three'] }
9398      */
9399     var groupBy = createAggregator(function(result, value, key) {
9400       if (hasOwnProperty.call(result, key)) {
9401         result[key].push(value);
9402       } else {
9403         baseAssignValue(result, key, [value]);
9404       }
9405     });
9406
9407     /**
9408      * Checks if `value` is in `collection`. If `collection` is a string, it's
9409      * checked for a substring of `value`, otherwise
9410      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9411      * is used for equality comparisons. If `fromIndex` is negative, it's used as
9412      * the offset from the end of `collection`.
9413      *
9414      * @static
9415      * @memberOf _
9416      * @since 0.1.0
9417      * @category Collection
9418      * @param {Array|Object|string} collection The collection to inspect.
9419      * @param {*} value The value to search for.
9420      * @param {number} [fromIndex=0] The index to search from.
9421      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9422      * @returns {boolean} Returns `true` if `value` is found, else `false`.
9423      * @example
9424      *
9425      * _.includes([1, 2, 3], 1);
9426      * // => true
9427      *
9428      * _.includes([1, 2, 3], 1, 2);
9429      * // => false
9430      *
9431      * _.includes({ 'a': 1, 'b': 2 }, 1);
9432      * // => true
9433      *
9434      * _.includes('abcd', 'bc');
9435      * // => true
9436      */
9437     function includes(collection, value, fromIndex, guard) {
9438       collection = isArrayLike(collection) ? collection : values(collection);
9439       fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9440
9441       var length = collection.length;
9442       if (fromIndex < 0) {
9443         fromIndex = nativeMax(length + fromIndex, 0);
9444       }
9445       return isString(collection)
9446         ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9447         : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9448     }
9449
9450     /**
9451      * Invokes the method at `path` of each element in `collection`, returning
9452      * an array of the results of each invoked method. Any additional arguments
9453      * are provided to each invoked method. If `path` is a function, it's invoked
9454      * for, and `this` bound to, each element in `collection`.
9455      *
9456      * @static
9457      * @memberOf _
9458      * @since 4.0.0
9459      * @category Collection
9460      * @param {Array|Object} collection The collection to iterate over.
9461      * @param {Array|Function|string} path The path of the method to invoke or
9462      *  the function invoked per iteration.
9463      * @param {...*} [args] The arguments to invoke each method with.
9464      * @returns {Array} Returns the array of results.
9465      * @example
9466      *
9467      * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9468      * // => [[1, 5, 7], [1, 2, 3]]
9469      *
9470      * _.invokeMap([123, 456], String.prototype.split, '');
9471      * // => [['1', '2', '3'], ['4', '5', '6']]
9472      */
9473     var invokeMap = baseRest(function(collection, path, args) {
9474       var index = -1,
9475           isFunc = typeof path == 'function',
9476           result = isArrayLike(collection) ? Array(collection.length) : [];
9477
9478       baseEach(collection, function(value) {
9479         result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
9480       });
9481       return result;
9482     });
9483
9484     /**
9485      * Creates an object composed of keys generated from the results of running
9486      * each element of `collection` thru `iteratee`. The corresponding value of
9487      * each key is the last element responsible for generating the key. The
9488      * iteratee is invoked with one argument: (value).
9489      *
9490      * @static
9491      * @memberOf _
9492      * @since 4.0.0
9493      * @category Collection
9494      * @param {Array|Object} collection The collection to iterate over.
9495      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9496      * @returns {Object} Returns the composed aggregate object.
9497      * @example
9498      *
9499      * var array = [
9500      *   { 'dir': 'left', 'code': 97 },
9501      *   { 'dir': 'right', 'code': 100 }
9502      * ];
9503      *
9504      * _.keyBy(array, function(o) {
9505      *   return String.fromCharCode(o.code);
9506      * });
9507      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9508      *
9509      * _.keyBy(array, 'dir');
9510      * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9511      */
9512     var keyBy = createAggregator(function(result, value, key) {
9513       baseAssignValue(result, key, value);
9514     });
9515
9516     /**
9517      * Creates an array of values by running each element in `collection` thru
9518      * `iteratee`. The iteratee is invoked with three arguments:
9519      * (value, index|key, collection).
9520      *
9521      * Many lodash methods are guarded to work as iteratees for methods like
9522      * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9523      *
9524      * The guarded methods are:
9525      * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9526      * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9527      * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9528      * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9529      *
9530      * @static
9531      * @memberOf _
9532      * @since 0.1.0
9533      * @category Collection
9534      * @param {Array|Object} collection The collection to iterate over.
9535      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9536      * @returns {Array} Returns the new mapped array.
9537      * @example
9538      *
9539      * function square(n) {
9540      *   return n * n;
9541      * }
9542      *
9543      * _.map([4, 8], square);
9544      * // => [16, 64]
9545      *
9546      * _.map({ 'a': 4, 'b': 8 }, square);
9547      * // => [16, 64] (iteration order is not guaranteed)
9548      *
9549      * var users = [
9550      *   { 'user': 'barney' },
9551      *   { 'user': 'fred' }
9552      * ];
9553      *
9554      * // The `_.property` iteratee shorthand.
9555      * _.map(users, 'user');
9556      * // => ['barney', 'fred']
9557      */
9558     function map(collection, iteratee) {
9559       var func = isArray(collection) ? arrayMap : baseMap;
9560       return func(collection, getIteratee(iteratee, 3));
9561     }
9562
9563     /**
9564      * This method is like `_.sortBy` except that it allows specifying the sort
9565      * orders of the iteratees to sort by. If `orders` is unspecified, all values
9566      * are sorted in ascending order. Otherwise, specify an order of "desc" for
9567      * descending or "asc" for ascending sort order of corresponding values.
9568      *
9569      * @static
9570      * @memberOf _
9571      * @since 4.0.0
9572      * @category Collection
9573      * @param {Array|Object} collection The collection to iterate over.
9574      * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
9575      *  The iteratees to sort by.
9576      * @param {string[]} [orders] The sort orders of `iteratees`.
9577      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9578      * @returns {Array} Returns the new sorted array.
9579      * @example
9580      *
9581      * var users = [
9582      *   { 'user': 'fred',   'age': 48 },
9583      *   { 'user': 'barney', 'age': 34 },
9584      *   { 'user': 'fred',   'age': 40 },
9585      *   { 'user': 'barney', 'age': 36 }
9586      * ];
9587      *
9588      * // Sort by `user` in ascending order and by `age` in descending order.
9589      * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
9590      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9591      */
9592     function orderBy(collection, iteratees, orders, guard) {
9593       if (collection == null) {
9594         return [];
9595       }
9596       if (!isArray(iteratees)) {
9597         iteratees = iteratees == null ? [] : [iteratees];
9598       }
9599       orders = guard ? undefined : orders;
9600       if (!isArray(orders)) {
9601         orders = orders == null ? [] : [orders];
9602       }
9603       return baseOrderBy(collection, iteratees, orders);
9604     }
9605
9606     /**
9607      * Creates an array of elements split into two groups, the first of which
9608      * contains elements `predicate` returns truthy for, the second of which
9609      * contains elements `predicate` returns falsey for. The predicate is
9610      * invoked with one argument: (value).
9611      *
9612      * @static
9613      * @memberOf _
9614      * @since 3.0.0
9615      * @category Collection
9616      * @param {Array|Object} collection The collection to iterate over.
9617      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9618      * @returns {Array} Returns the array of grouped elements.
9619      * @example
9620      *
9621      * var users = [
9622      *   { 'user': 'barney',  'age': 36, 'active': false },
9623      *   { 'user': 'fred',    'age': 40, 'active': true },
9624      *   { 'user': 'pebbles', 'age': 1,  'active': false }
9625      * ];
9626      *
9627      * _.partition(users, function(o) { return o.active; });
9628      * // => objects for [['fred'], ['barney', 'pebbles']]
9629      *
9630      * // The `_.matches` iteratee shorthand.
9631      * _.partition(users, { 'age': 1, 'active': false });
9632      * // => objects for [['pebbles'], ['barney', 'fred']]
9633      *
9634      * // The `_.matchesProperty` iteratee shorthand.
9635      * _.partition(users, ['active', false]);
9636      * // => objects for [['barney', 'pebbles'], ['fred']]
9637      *
9638      * // The `_.property` iteratee shorthand.
9639      * _.partition(users, 'active');
9640      * // => objects for [['fred'], ['barney', 'pebbles']]
9641      */
9642     var partition = createAggregator(function(result, value, key) {
9643       result[key ? 0 : 1].push(value);
9644     }, function() { return [[], []]; });
9645
9646     /**
9647      * Reduces `collection` to a value which is the accumulated result of running
9648      * each element in `collection` thru `iteratee`, where each successive
9649      * invocation is supplied the return value of the previous. If `accumulator`
9650      * is not given, the first element of `collection` is used as the initial
9651      * value. The iteratee is invoked with four arguments:
9652      * (accumulator, value, index|key, collection).
9653      *
9654      * Many lodash methods are guarded to work as iteratees for methods like
9655      * `_.reduce`, `_.reduceRight`, and `_.transform`.
9656      *
9657      * The guarded methods are:
9658      * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
9659      * and `sortBy`
9660      *
9661      * @static
9662      * @memberOf _
9663      * @since 0.1.0
9664      * @category Collection
9665      * @param {Array|Object} collection The collection to iterate over.
9666      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9667      * @param {*} [accumulator] The initial value.
9668      * @returns {*} Returns the accumulated value.
9669      * @see _.reduceRight
9670      * @example
9671      *
9672      * _.reduce([1, 2], function(sum, n) {
9673      *   return sum + n;
9674      * }, 0);
9675      * // => 3
9676      *
9677      * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
9678      *   (result[value] || (result[value] = [])).push(key);
9679      *   return result;
9680      * }, {});
9681      * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
9682      */
9683     function reduce(collection, iteratee, accumulator) {
9684       var func = isArray(collection) ? arrayReduce : baseReduce,
9685           initAccum = arguments.length < 3;
9686
9687       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
9688     }
9689
9690     /**
9691      * This method is like `_.reduce` except that it iterates over elements of
9692      * `collection` from right to left.
9693      *
9694      * @static
9695      * @memberOf _
9696      * @since 0.1.0
9697      * @category Collection
9698      * @param {Array|Object} collection The collection to iterate over.
9699      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9700      * @param {*} [accumulator] The initial value.
9701      * @returns {*} Returns the accumulated value.
9702      * @see _.reduce
9703      * @example
9704      *
9705      * var array = [[0, 1], [2, 3], [4, 5]];
9706      *
9707      * _.reduceRight(array, function(flattened, other) {
9708      *   return flattened.concat(other);
9709      * }, []);
9710      * // => [4, 5, 2, 3, 0, 1]
9711      */
9712     function reduceRight(collection, iteratee, accumulator) {
9713       var func = isArray(collection) ? arrayReduceRight : baseReduce,
9714           initAccum = arguments.length < 3;
9715
9716       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
9717     }
9718
9719     /**
9720      * The opposite of `_.filter`; this method returns the elements of `collection`
9721      * that `predicate` does **not** return truthy for.
9722      *
9723      * @static
9724      * @memberOf _
9725      * @since 0.1.0
9726      * @category Collection
9727      * @param {Array|Object} collection The collection to iterate over.
9728      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9729      * @returns {Array} Returns the new filtered array.
9730      * @see _.filter
9731      * @example
9732      *
9733      * var users = [
9734      *   { 'user': 'barney', 'age': 36, 'active': false },
9735      *   { 'user': 'fred',   'age': 40, 'active': true }
9736      * ];
9737      *
9738      * _.reject(users, function(o) { return !o.active; });
9739      * // => objects for ['fred']
9740      *
9741      * // The `_.matches` iteratee shorthand.
9742      * _.reject(users, { 'age': 40, 'active': true });
9743      * // => objects for ['barney']
9744      *
9745      * // The `_.matchesProperty` iteratee shorthand.
9746      * _.reject(users, ['active', false]);
9747      * // => objects for ['fred']
9748      *
9749      * // The `_.property` iteratee shorthand.
9750      * _.reject(users, 'active');
9751      * // => objects for ['barney']
9752      */
9753     function reject(collection, predicate) {
9754       var func = isArray(collection) ? arrayFilter : baseFilter;
9755       return func(collection, negate(getIteratee(predicate, 3)));
9756     }
9757
9758     /**
9759      * Gets a random element from `collection`.
9760      *
9761      * @static
9762      * @memberOf _
9763      * @since 2.0.0
9764      * @category Collection
9765      * @param {Array|Object} collection The collection to sample.
9766      * @returns {*} Returns the random element.
9767      * @example
9768      *
9769      * _.sample([1, 2, 3, 4]);
9770      * // => 2
9771      */
9772     function sample(collection) {
9773       var func = isArray(collection) ? arraySample : baseSample;
9774       return func(collection);
9775     }
9776
9777     /**
9778      * Gets `n` random elements at unique keys from `collection` up to the
9779      * size of `collection`.
9780      *
9781      * @static
9782      * @memberOf _
9783      * @since 4.0.0
9784      * @category Collection
9785      * @param {Array|Object} collection The collection to sample.
9786      * @param {number} [n=1] The number of elements to sample.
9787      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9788      * @returns {Array} Returns the random elements.
9789      * @example
9790      *
9791      * _.sampleSize([1, 2, 3], 2);
9792      * // => [3, 1]
9793      *
9794      * _.sampleSize([1, 2, 3], 4);
9795      * // => [2, 3, 1]
9796      */
9797     function sampleSize(collection, n, guard) {
9798       if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
9799         n = 1;
9800       } else {
9801         n = toInteger(n);
9802       }
9803       var func = isArray(collection) ? arraySampleSize : baseSampleSize;
9804       return func(collection, n);
9805     }
9806
9807     /**
9808      * Creates an array of shuffled values, using a version of the
9809      * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9810      *
9811      * @static
9812      * @memberOf _
9813      * @since 0.1.0
9814      * @category Collection
9815      * @param {Array|Object} collection The collection to shuffle.
9816      * @returns {Array} Returns the new shuffled array.
9817      * @example
9818      *
9819      * _.shuffle([1, 2, 3, 4]);
9820      * // => [4, 1, 3, 2]
9821      */
9822     function shuffle(collection) {
9823       var func = isArray(collection) ? arrayShuffle : baseShuffle;
9824       return func(collection);
9825     }
9826
9827     /**
9828      * Gets the size of `collection` by returning its length for array-like
9829      * values or the number of own enumerable string keyed properties for objects.
9830      *
9831      * @static
9832      * @memberOf _
9833      * @since 0.1.0
9834      * @category Collection
9835      * @param {Array|Object|string} collection The collection to inspect.
9836      * @returns {number} Returns the collection size.
9837      * @example
9838      *
9839      * _.size([1, 2, 3]);
9840      * // => 3
9841      *
9842      * _.size({ 'a': 1, 'b': 2 });
9843      * // => 2
9844      *
9845      * _.size('pebbles');
9846      * // => 7
9847      */
9848     function size(collection) {
9849       if (collection == null) {
9850         return 0;
9851       }
9852       if (isArrayLike(collection)) {
9853         return isString(collection) ? stringSize(collection) : collection.length;
9854       }
9855       var tag = getTag(collection);
9856       if (tag == mapTag || tag == setTag) {
9857         return collection.size;
9858       }
9859       return baseKeys(collection).length;
9860     }
9861
9862     /**
9863      * Checks if `predicate` returns truthy for **any** element of `collection`.
9864      * Iteration is stopped once `predicate` returns truthy. The predicate is
9865      * invoked with three arguments: (value, index|key, collection).
9866      *
9867      * @static
9868      * @memberOf _
9869      * @since 0.1.0
9870      * @category Collection
9871      * @param {Array|Object} collection The collection to iterate over.
9872      * @param {Function} [predicate=_.identity] The function invoked per iteration.
9873      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9874      * @returns {boolean} Returns `true` if any element passes the predicate check,
9875      *  else `false`.
9876      * @example
9877      *
9878      * _.some([null, 0, 'yes', false], Boolean);
9879      * // => true
9880      *
9881      * var users = [
9882      *   { 'user': 'barney', 'active': true },
9883      *   { 'user': 'fred',   'active': false }
9884      * ];
9885      *
9886      * // The `_.matches` iteratee shorthand.
9887      * _.some(users, { 'user': 'barney', 'active': false });
9888      * // => false
9889      *
9890      * // The `_.matchesProperty` iteratee shorthand.
9891      * _.some(users, ['active', false]);
9892      * // => true
9893      *
9894      * // The `_.property` iteratee shorthand.
9895      * _.some(users, 'active');
9896      * // => true
9897      */
9898     function some(collection, predicate, guard) {
9899       var func = isArray(collection) ? arraySome : baseSome;
9900       if (guard && isIterateeCall(collection, predicate, guard)) {
9901         predicate = undefined;
9902       }
9903       return func(collection, getIteratee(predicate, 3));
9904     }
9905
9906     /**
9907      * Creates an array of elements, sorted in ascending order by the results of
9908      * running each element in a collection thru each iteratee. This method
9909      * performs a stable sort, that is, it preserves the original sort order of
9910      * equal elements. The iteratees are invoked with one argument: (value).
9911      *
9912      * @static
9913      * @memberOf _
9914      * @since 0.1.0
9915      * @category Collection
9916      * @param {Array|Object} collection The collection to iterate over.
9917      * @param {...(Function|Function[])} [iteratees=[_.identity]]
9918      *  The iteratees to sort by.
9919      * @returns {Array} Returns the new sorted array.
9920      * @example
9921      *
9922      * var users = [
9923      *   { 'user': 'fred',   'age': 48 },
9924      *   { 'user': 'barney', 'age': 36 },
9925      *   { 'user': 'fred',   'age': 40 },
9926      *   { 'user': 'barney', 'age': 34 }
9927      * ];
9928      *
9929      * _.sortBy(users, [function(o) { return o.user; }]);
9930      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9931      *
9932      * _.sortBy(users, ['user', 'age']);
9933      * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
9934      */
9935     var sortBy = baseRest(function(collection, iteratees) {
9936       if (collection == null) {
9937         return [];
9938       }
9939       var length = iteratees.length;
9940       if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
9941         iteratees = [];
9942       } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
9943         iteratees = [iteratees[0]];
9944       }
9945       return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
9946     });
9947
9948     /*------------------------------------------------------------------------*/
9949
9950     /**
9951      * Gets the timestamp of the number of milliseconds that have elapsed since
9952      * the Unix epoch (1 January 1970 00:00:00 UTC).
9953      *
9954      * @static
9955      * @memberOf _
9956      * @since 2.4.0
9957      * @category Date
9958      * @returns {number} Returns the timestamp.
9959      * @example
9960      *
9961      * _.defer(function(stamp) {
9962      *   console.log(_.now() - stamp);
9963      * }, _.now());
9964      * // => Logs the number of milliseconds it took for the deferred invocation.
9965      */
9966     var now = ctxNow || function() {
9967       return root.Date.now();
9968     };
9969
9970     /*------------------------------------------------------------------------*/
9971
9972     /**
9973      * The opposite of `_.before`; this method creates a function that invokes
9974      * `func` once it's called `n` or more times.
9975      *
9976      * @static
9977      * @memberOf _
9978      * @since 0.1.0
9979      * @category Function
9980      * @param {number} n The number of calls before `func` is invoked.
9981      * @param {Function} func The function to restrict.
9982      * @returns {Function} Returns the new restricted function.
9983      * @example
9984      *
9985      * var saves = ['profile', 'settings'];
9986      *
9987      * var done = _.after(saves.length, function() {
9988      *   console.log('done saving!');
9989      * });
9990      *
9991      * _.forEach(saves, function(type) {
9992      *   asyncSave({ 'type': type, 'complete': done });
9993      * });
9994      * // => Logs 'done saving!' after the two async saves have completed.
9995      */
9996     function after(n, func) {
9997       if (typeof func != 'function') {
9998         throw new TypeError(FUNC_ERROR_TEXT);
9999       }
10000       n = toInteger(n);
10001       return function() {
10002         if (--n < 1) {
10003           return func.apply(this, arguments);
10004         }
10005       };
10006     }
10007
10008     /**
10009      * Creates a function that invokes `func`, with up to `n` arguments,
10010      * ignoring any additional arguments.
10011      *
10012      * @static
10013      * @memberOf _
10014      * @since 3.0.0
10015      * @category Function
10016      * @param {Function} func The function to cap arguments for.
10017      * @param {number} [n=func.length] The arity cap.
10018      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10019      * @returns {Function} Returns the new capped function.
10020      * @example
10021      *
10022      * _.map(['6', '8', '10'], _.ary(parseInt, 1));
10023      * // => [6, 8, 10]
10024      */
10025     function ary(func, n, guard) {
10026       n = guard ? undefined : n;
10027       n = (func && n == null) ? func.length : n;
10028       return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
10029     }
10030
10031     /**
10032      * Creates a function that invokes `func`, with the `this` binding and arguments
10033      * of the created function, while it's called less than `n` times. Subsequent
10034      * calls to the created function return the result of the last `func` invocation.
10035      *
10036      * @static
10037      * @memberOf _
10038      * @since 3.0.0
10039      * @category Function
10040      * @param {number} n The number of calls at which `func` is no longer invoked.
10041      * @param {Function} func The function to restrict.
10042      * @returns {Function} Returns the new restricted function.
10043      * @example
10044      *
10045      * jQuery(element).on('click', _.before(5, addContactToList));
10046      * // => Allows adding up to 4 contacts to the list.
10047      */
10048     function before(n, func) {
10049       var result;
10050       if (typeof func != 'function') {
10051         throw new TypeError(FUNC_ERROR_TEXT);
10052       }
10053       n = toInteger(n);
10054       return function() {
10055         if (--n > 0) {
10056           result = func.apply(this, arguments);
10057         }
10058         if (n <= 1) {
10059           func = undefined;
10060         }
10061         return result;
10062       };
10063     }
10064
10065     /**
10066      * Creates a function that invokes `func` with the `this` binding of `thisArg`
10067      * and `partials` prepended to the arguments it receives.
10068      *
10069      * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10070      * may be used as a placeholder for partially applied arguments.
10071      *
10072      * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10073      * property of bound functions.
10074      *
10075      * @static
10076      * @memberOf _
10077      * @since 0.1.0
10078      * @category Function
10079      * @param {Function} func The function to bind.
10080      * @param {*} thisArg The `this` binding of `func`.
10081      * @param {...*} [partials] The arguments to be partially applied.
10082      * @returns {Function} Returns the new bound function.
10083      * @example
10084      *
10085      * function greet(greeting, punctuation) {
10086      *   return greeting + ' ' + this.user + punctuation;
10087      * }
10088      *
10089      * var object = { 'user': 'fred' };
10090      *
10091      * var bound = _.bind(greet, object, 'hi');
10092      * bound('!');
10093      * // => 'hi fred!'
10094      *
10095      * // Bound with placeholders.
10096      * var bound = _.bind(greet, object, _, '!');
10097      * bound('hi');
10098      * // => 'hi fred!'
10099      */
10100     var bind = baseRest(function(func, thisArg, partials) {
10101       var bitmask = WRAP_BIND_FLAG;
10102       if (partials.length) {
10103         var holders = replaceHolders(partials, getHolder(bind));
10104         bitmask |= WRAP_PARTIAL_FLAG;
10105       }
10106       return createWrap(func, bitmask, thisArg, partials, holders);
10107     });
10108
10109     /**
10110      * Creates a function that invokes the method at `object[key]` with `partials`
10111      * prepended to the arguments it receives.
10112      *
10113      * This method differs from `_.bind` by allowing bound functions to reference
10114      * methods that may be redefined or don't yet exist. See
10115      * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
10116      * for more details.
10117      *
10118      * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10119      * builds, may be used as a placeholder for partially applied arguments.
10120      *
10121      * @static
10122      * @memberOf _
10123      * @since 0.10.0
10124      * @category Function
10125      * @param {Object} object The object to invoke the method on.
10126      * @param {string} key The key of the method.
10127      * @param {...*} [partials] The arguments to be partially applied.
10128      * @returns {Function} Returns the new bound function.
10129      * @example
10130      *
10131      * var object = {
10132      *   'user': 'fred',
10133      *   'greet': function(greeting, punctuation) {
10134      *     return greeting + ' ' + this.user + punctuation;
10135      *   }
10136      * };
10137      *
10138      * var bound = _.bindKey(object, 'greet', 'hi');
10139      * bound('!');
10140      * // => 'hi fred!'
10141      *
10142      * object.greet = function(greeting, punctuation) {
10143      *   return greeting + 'ya ' + this.user + punctuation;
10144      * };
10145      *
10146      * bound('!');
10147      * // => 'hiya fred!'
10148      *
10149      * // Bound with placeholders.
10150      * var bound = _.bindKey(object, 'greet', _, '!');
10151      * bound('hi');
10152      * // => 'hiya fred!'
10153      */
10154     var bindKey = baseRest(function(object, key, partials) {
10155       var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
10156       if (partials.length) {
10157         var holders = replaceHolders(partials, getHolder(bindKey));
10158         bitmask |= WRAP_PARTIAL_FLAG;
10159       }
10160       return createWrap(key, bitmask, object, partials, holders);
10161     });
10162
10163     /**
10164      * Creates a function that accepts arguments of `func` and either invokes
10165      * `func` returning its result, if at least `arity` number of arguments have
10166      * been provided, or returns a function that accepts the remaining `func`
10167      * arguments, and so on. The arity of `func` may be specified if `func.length`
10168      * is not sufficient.
10169      *
10170      * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10171      * may be used as a placeholder for provided arguments.
10172      *
10173      * **Note:** This method doesn't set the "length" property of curried functions.
10174      *
10175      * @static
10176      * @memberOf _
10177      * @since 2.0.0
10178      * @category Function
10179      * @param {Function} func The function to curry.
10180      * @param {number} [arity=func.length] The arity of `func`.
10181      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10182      * @returns {Function} Returns the new curried function.
10183      * @example
10184      *
10185      * var abc = function(a, b, c) {
10186      *   return [a, b, c];
10187      * };
10188      *
10189      * var curried = _.curry(abc);
10190      *
10191      * curried(1)(2)(3);
10192      * // => [1, 2, 3]
10193      *
10194      * curried(1, 2)(3);
10195      * // => [1, 2, 3]
10196      *
10197      * curried(1, 2, 3);
10198      * // => [1, 2, 3]
10199      *
10200      * // Curried with placeholders.
10201      * curried(1)(_, 3)(2);
10202      * // => [1, 2, 3]
10203      */
10204     function curry(func, arity, guard) {
10205       arity = guard ? undefined : arity;
10206       var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10207       result.placeholder = curry.placeholder;
10208       return result;
10209     }
10210
10211     /**
10212      * This method is like `_.curry` except that arguments are applied to `func`
10213      * in the manner of `_.partialRight` instead of `_.partial`.
10214      *
10215      * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10216      * builds, may be used as a placeholder for provided arguments.
10217      *
10218      * **Note:** This method doesn't set the "length" property of curried functions.
10219      *
10220      * @static
10221      * @memberOf _
10222      * @since 3.0.0
10223      * @category Function
10224      * @param {Function} func The function to curry.
10225      * @param {number} [arity=func.length] The arity of `func`.
10226      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10227      * @returns {Function} Returns the new curried function.
10228      * @example
10229      *
10230      * var abc = function(a, b, c) {
10231      *   return [a, b, c];
10232      * };
10233      *
10234      * var curried = _.curryRight(abc);
10235      *
10236      * curried(3)(2)(1);
10237      * // => [1, 2, 3]
10238      *
10239      * curried(2, 3)(1);
10240      * // => [1, 2, 3]
10241      *
10242      * curried(1, 2, 3);
10243      * // => [1, 2, 3]
10244      *
10245      * // Curried with placeholders.
10246      * curried(3)(1, _)(2);
10247      * // => [1, 2, 3]
10248      */
10249     function curryRight(func, arity, guard) {
10250       arity = guard ? undefined : arity;
10251       var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10252       result.placeholder = curryRight.placeholder;
10253       return result;
10254     }
10255
10256     /**
10257      * Creates a debounced function that delays invoking `func` until after `wait`
10258      * milliseconds have elapsed since the last time the debounced function was
10259      * invoked. The debounced function comes with a `cancel` method to cancel
10260      * delayed `func` invocations and a `flush` method to immediately invoke them.
10261      * Provide `options` to indicate whether `func` should be invoked on the
10262      * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
10263      * with the last arguments provided to the debounced function. Subsequent
10264      * calls to the debounced function return the result of the last `func`
10265      * invocation.
10266      *
10267      * **Note:** If `leading` and `trailing` options are `true`, `func` is
10268      * invoked on the trailing edge of the timeout only if the debounced function
10269      * is invoked more than once during the `wait` timeout.
10270      *
10271      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10272      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10273      *
10274      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10275      * for details over the differences between `_.debounce` and `_.throttle`.
10276      *
10277      * @static
10278      * @memberOf _
10279      * @since 0.1.0
10280      * @category Function
10281      * @param {Function} func The function to debounce.
10282      * @param {number} [wait=0] The number of milliseconds to delay.
10283      * @param {Object} [options={}] The options object.
10284      * @param {boolean} [options.leading=false]
10285      *  Specify invoking on the leading edge of the timeout.
10286      * @param {number} [options.maxWait]
10287      *  The maximum time `func` is allowed to be delayed before it's invoked.
10288      * @param {boolean} [options.trailing=true]
10289      *  Specify invoking on the trailing edge of the timeout.
10290      * @returns {Function} Returns the new debounced function.
10291      * @example
10292      *
10293      * // Avoid costly calculations while the window size is in flux.
10294      * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10295      *
10296      * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10297      * jQuery(element).on('click', _.debounce(sendMail, 300, {
10298      *   'leading': true,
10299      *   'trailing': false
10300      * }));
10301      *
10302      * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
10303      * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
10304      * var source = new EventSource('/stream');
10305      * jQuery(source).on('message', debounced);
10306      *
10307      * // Cancel the trailing debounced invocation.
10308      * jQuery(window).on('popstate', debounced.cancel);
10309      */
10310     function debounce(func, wait, options) {
10311       var lastArgs,
10312           lastThis,
10313           maxWait,
10314           result,
10315           timerId,
10316           lastCallTime,
10317           lastInvokeTime = 0,
10318           leading = false,
10319           maxing = false,
10320           trailing = true;
10321
10322       if (typeof func != 'function') {
10323         throw new TypeError(FUNC_ERROR_TEXT);
10324       }
10325       wait = toNumber(wait) || 0;
10326       if (isObject(options)) {
10327         leading = !!options.leading;
10328         maxing = 'maxWait' in options;
10329         maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
10330         trailing = 'trailing' in options ? !!options.trailing : trailing;
10331       }
10332
10333       function invokeFunc(time) {
10334         var args = lastArgs,
10335             thisArg = lastThis;
10336
10337         lastArgs = lastThis = undefined;
10338         lastInvokeTime = time;
10339         result = func.apply(thisArg, args);
10340         return result;
10341       }
10342
10343       function leadingEdge(time) {
10344         // Reset any `maxWait` timer.
10345         lastInvokeTime = time;
10346         // Start the timer for the trailing edge.
10347         timerId = setTimeout(timerExpired, wait);
10348         // Invoke the leading edge.
10349         return leading ? invokeFunc(time) : result;
10350       }
10351
10352       function remainingWait(time) {
10353         var timeSinceLastCall = time - lastCallTime,
10354             timeSinceLastInvoke = time - lastInvokeTime,
10355             timeWaiting = wait - timeSinceLastCall;
10356
10357         return maxing
10358           ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
10359           : timeWaiting;
10360       }
10361
10362       function shouldInvoke(time) {
10363         var timeSinceLastCall = time - lastCallTime,
10364             timeSinceLastInvoke = time - lastInvokeTime;
10365
10366         // Either this is the first call, activity has stopped and we're at the
10367         // trailing edge, the system time has gone backwards and we're treating
10368         // it as the trailing edge, or we've hit the `maxWait` limit.
10369         return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
10370           (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
10371       }
10372
10373       function timerExpired() {
10374         var time = now();
10375         if (shouldInvoke(time)) {
10376           return trailingEdge(time);
10377         }
10378         // Restart the timer.
10379         timerId = setTimeout(timerExpired, remainingWait(time));
10380       }
10381
10382       function trailingEdge(time) {
10383         timerId = undefined;
10384
10385         // Only invoke if we have `lastArgs` which means `func` has been
10386         // debounced at least once.
10387         if (trailing && lastArgs) {
10388           return invokeFunc(time);
10389         }
10390         lastArgs = lastThis = undefined;
10391         return result;
10392       }
10393
10394       function cancel() {
10395         if (timerId !== undefined) {
10396           clearTimeout(timerId);
10397         }
10398         lastInvokeTime = 0;
10399         lastArgs = lastCallTime = lastThis = timerId = undefined;
10400       }
10401
10402       function flush() {
10403         return timerId === undefined ? result : trailingEdge(now());
10404       }
10405
10406       function debounced() {
10407         var time = now(),
10408             isInvoking = shouldInvoke(time);
10409
10410         lastArgs = arguments;
10411         lastThis = this;
10412         lastCallTime = time;
10413
10414         if (isInvoking) {
10415           if (timerId === undefined) {
10416             return leadingEdge(lastCallTime);
10417           }
10418           if (maxing) {
10419             // Handle invocations in a tight loop.
10420             clearTimeout(timerId);
10421             timerId = setTimeout(timerExpired, wait);
10422             return invokeFunc(lastCallTime);
10423           }
10424         }
10425         if (timerId === undefined) {
10426           timerId = setTimeout(timerExpired, wait);
10427         }
10428         return result;
10429       }
10430       debounced.cancel = cancel;
10431       debounced.flush = flush;
10432       return debounced;
10433     }
10434
10435     /**
10436      * Defers invoking the `func` until the current call stack has cleared. Any
10437      * additional arguments are provided to `func` when it's invoked.
10438      *
10439      * @static
10440      * @memberOf _
10441      * @since 0.1.0
10442      * @category Function
10443      * @param {Function} func The function to defer.
10444      * @param {...*} [args] The arguments to invoke `func` with.
10445      * @returns {number} Returns the timer id.
10446      * @example
10447      *
10448      * _.defer(function(text) {
10449      *   console.log(text);
10450      * }, 'deferred');
10451      * // => Logs 'deferred' after one millisecond.
10452      */
10453     var defer = baseRest(function(func, args) {
10454       return baseDelay(func, 1, args);
10455     });
10456
10457     /**
10458      * Invokes `func` after `wait` milliseconds. Any additional arguments are
10459      * provided to `func` when it's invoked.
10460      *
10461      * @static
10462      * @memberOf _
10463      * @since 0.1.0
10464      * @category Function
10465      * @param {Function} func The function to delay.
10466      * @param {number} wait The number of milliseconds to delay invocation.
10467      * @param {...*} [args] The arguments to invoke `func` with.
10468      * @returns {number} Returns the timer id.
10469      * @example
10470      *
10471      * _.delay(function(text) {
10472      *   console.log(text);
10473      * }, 1000, 'later');
10474      * // => Logs 'later' after one second.
10475      */
10476     var delay = baseRest(function(func, wait, args) {
10477       return baseDelay(func, toNumber(wait) || 0, args);
10478     });
10479
10480     /**
10481      * Creates a function that invokes `func` with arguments reversed.
10482      *
10483      * @static
10484      * @memberOf _
10485      * @since 4.0.0
10486      * @category Function
10487      * @param {Function} func The function to flip arguments for.
10488      * @returns {Function} Returns the new flipped function.
10489      * @example
10490      *
10491      * var flipped = _.flip(function() {
10492      *   return _.toArray(arguments);
10493      * });
10494      *
10495      * flipped('a', 'b', 'c', 'd');
10496      * // => ['d', 'c', 'b', 'a']
10497      */
10498     function flip(func) {
10499       return createWrap(func, WRAP_FLIP_FLAG);
10500     }
10501
10502     /**
10503      * Creates a function that memoizes the result of `func`. If `resolver` is
10504      * provided, it determines the cache key for storing the result based on the
10505      * arguments provided to the memoized function. By default, the first argument
10506      * provided to the memoized function is used as the map cache key. The `func`
10507      * is invoked with the `this` binding of the memoized function.
10508      *
10509      * **Note:** The cache is exposed as the `cache` property on the memoized
10510      * function. Its creation may be customized by replacing the `_.memoize.Cache`
10511      * constructor with one whose instances implement the
10512      * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
10513      * method interface of `clear`, `delete`, `get`, `has`, and `set`.
10514      *
10515      * @static
10516      * @memberOf _
10517      * @since 0.1.0
10518      * @category Function
10519      * @param {Function} func The function to have its output memoized.
10520      * @param {Function} [resolver] The function to resolve the cache key.
10521      * @returns {Function} Returns the new memoized function.
10522      * @example
10523      *
10524      * var object = { 'a': 1, 'b': 2 };
10525      * var other = { 'c': 3, 'd': 4 };
10526      *
10527      * var values = _.memoize(_.values);
10528      * values(object);
10529      * // => [1, 2]
10530      *
10531      * values(other);
10532      * // => [3, 4]
10533      *
10534      * object.a = 2;
10535      * values(object);
10536      * // => [1, 2]
10537      *
10538      * // Modify the result cache.
10539      * values.cache.set(object, ['a', 'b']);
10540      * values(object);
10541      * // => ['a', 'b']
10542      *
10543      * // Replace `_.memoize.Cache`.
10544      * _.memoize.Cache = WeakMap;
10545      */
10546     function memoize(func, resolver) {
10547       if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10548         throw new TypeError(FUNC_ERROR_TEXT);
10549       }
10550       var memoized = function() {
10551         var args = arguments,
10552             key = resolver ? resolver.apply(this, args) : args[0],
10553             cache = memoized.cache;
10554
10555         if (cache.has(key)) {
10556           return cache.get(key);
10557         }
10558         var result = func.apply(this, args);
10559         memoized.cache = cache.set(key, result) || cache;
10560         return result;
10561       };
10562       memoized.cache = new (memoize.Cache || MapCache);
10563       return memoized;
10564     }
10565
10566     // Expose `MapCache`.
10567     memoize.Cache = MapCache;
10568
10569     /**
10570      * Creates a function that negates the result of the predicate `func`. The
10571      * `func` predicate is invoked with the `this` binding and arguments of the
10572      * created function.
10573      *
10574      * @static
10575      * @memberOf _
10576      * @since 3.0.0
10577      * @category Function
10578      * @param {Function} predicate The predicate to negate.
10579      * @returns {Function} Returns the new negated function.
10580      * @example
10581      *
10582      * function isEven(n) {
10583      *   return n % 2 == 0;
10584      * }
10585      *
10586      * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10587      * // => [1, 3, 5]
10588      */
10589     function negate(predicate) {
10590       if (typeof predicate != 'function') {
10591         throw new TypeError(FUNC_ERROR_TEXT);
10592       }
10593       return function() {
10594         var args = arguments;
10595         switch (args.length) {
10596           case 0: return !predicate.call(this);
10597           case 1: return !predicate.call(this, args[0]);
10598           case 2: return !predicate.call(this, args[0], args[1]);
10599           case 3: return !predicate.call(this, args[0], args[1], args[2]);
10600         }
10601         return !predicate.apply(this, args);
10602       };
10603     }
10604
10605     /**
10606      * Creates a function that is restricted to invoking `func` once. Repeat calls
10607      * to the function return the value of the first invocation. The `func` is
10608      * invoked with the `this` binding and arguments of the created function.
10609      *
10610      * @static
10611      * @memberOf _
10612      * @since 0.1.0
10613      * @category Function
10614      * @param {Function} func The function to restrict.
10615      * @returns {Function} Returns the new restricted function.
10616      * @example
10617      *
10618      * var initialize = _.once(createApplication);
10619      * initialize();
10620      * initialize();
10621      * // => `createApplication` is invoked once
10622      */
10623     function once(func) {
10624       return before(2, func);
10625     }
10626
10627     /**
10628      * Creates a function that invokes `func` with its arguments transformed.
10629      *
10630      * @static
10631      * @since 4.0.0
10632      * @memberOf _
10633      * @category Function
10634      * @param {Function} func The function to wrap.
10635      * @param {...(Function|Function[])} [transforms=[_.identity]]
10636      *  The argument transforms.
10637      * @returns {Function} Returns the new function.
10638      * @example
10639      *
10640      * function doubled(n) {
10641      *   return n * 2;
10642      * }
10643      *
10644      * function square(n) {
10645      *   return n * n;
10646      * }
10647      *
10648      * var func = _.overArgs(function(x, y) {
10649      *   return [x, y];
10650      * }, [square, doubled]);
10651      *
10652      * func(9, 3);
10653      * // => [81, 6]
10654      *
10655      * func(10, 5);
10656      * // => [100, 10]
10657      */
10658     var overArgs = castRest(function(func, transforms) {
10659       transforms = (transforms.length == 1 && isArray(transforms[0]))
10660         ? arrayMap(transforms[0], baseUnary(getIteratee()))
10661         : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
10662
10663       var funcsLength = transforms.length;
10664       return baseRest(function(args) {
10665         var index = -1,
10666             length = nativeMin(args.length, funcsLength);
10667
10668         while (++index < length) {
10669           args[index] = transforms[index].call(this, args[index]);
10670         }
10671         return apply(func, this, args);
10672       });
10673     });
10674
10675     /**
10676      * Creates a function that invokes `func` with `partials` prepended to the
10677      * arguments it receives. This method is like `_.bind` except it does **not**
10678      * alter the `this` binding.
10679      *
10680      * The `_.partial.placeholder` value, which defaults to `_` in monolithic
10681      * builds, may be used as a placeholder for partially applied arguments.
10682      *
10683      * **Note:** This method doesn't set the "length" property of partially
10684      * applied functions.
10685      *
10686      * @static
10687      * @memberOf _
10688      * @since 0.2.0
10689      * @category Function
10690      * @param {Function} func The function to partially apply arguments to.
10691      * @param {...*} [partials] The arguments to be partially applied.
10692      * @returns {Function} Returns the new partially applied function.
10693      * @example
10694      *
10695      * function greet(greeting, name) {
10696      *   return greeting + ' ' + name;
10697      * }
10698      *
10699      * var sayHelloTo = _.partial(greet, 'hello');
10700      * sayHelloTo('fred');
10701      * // => 'hello fred'
10702      *
10703      * // Partially applied with placeholders.
10704      * var greetFred = _.partial(greet, _, 'fred');
10705      * greetFred('hi');
10706      * // => 'hi fred'
10707      */
10708     var partial = baseRest(function(func, partials) {
10709       var holders = replaceHolders(partials, getHolder(partial));
10710       return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
10711     });
10712
10713     /**
10714      * This method is like `_.partial` except that partially applied arguments
10715      * are appended to the arguments it receives.
10716      *
10717      * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
10718      * builds, may be used as a placeholder for partially applied arguments.
10719      *
10720      * **Note:** This method doesn't set the "length" property of partially
10721      * applied functions.
10722      *
10723      * @static
10724      * @memberOf _
10725      * @since 1.0.0
10726      * @category Function
10727      * @param {Function} func The function to partially apply arguments to.
10728      * @param {...*} [partials] The arguments to be partially applied.
10729      * @returns {Function} Returns the new partially applied function.
10730      * @example
10731      *
10732      * function greet(greeting, name) {
10733      *   return greeting + ' ' + name;
10734      * }
10735      *
10736      * var greetFred = _.partialRight(greet, 'fred');
10737      * greetFred('hi');
10738      * // => 'hi fred'
10739      *
10740      * // Partially applied with placeholders.
10741      * var sayHelloTo = _.partialRight(greet, 'hello', _);
10742      * sayHelloTo('fred');
10743      * // => 'hello fred'
10744      */
10745     var partialRight = baseRest(function(func, partials) {
10746       var holders = replaceHolders(partials, getHolder(partialRight));
10747       return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
10748     });
10749
10750     /**
10751      * Creates a function that invokes `func` with arguments arranged according
10752      * to the specified `indexes` where the argument value at the first index is
10753      * provided as the first argument, the argument value at the second index is
10754      * provided as the second argument, and so on.
10755      *
10756      * @static
10757      * @memberOf _
10758      * @since 3.0.0
10759      * @category Function
10760      * @param {Function} func The function to rearrange arguments for.
10761      * @param {...(number|number[])} indexes The arranged argument indexes.
10762      * @returns {Function} Returns the new function.
10763      * @example
10764      *
10765      * var rearged = _.rearg(function(a, b, c) {
10766      *   return [a, b, c];
10767      * }, [2, 0, 1]);
10768      *
10769      * rearged('b', 'c', 'a')
10770      * // => ['a', 'b', 'c']
10771      */
10772     var rearg = flatRest(function(func, indexes) {
10773       return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
10774     });
10775
10776     /**
10777      * Creates a function that invokes `func` with the `this` binding of the
10778      * created function and arguments from `start` and beyond provided as
10779      * an array.
10780      *
10781      * **Note:** This method is based on the
10782      * [rest parameter](https://mdn.io/rest_parameters).
10783      *
10784      * @static
10785      * @memberOf _
10786      * @since 4.0.0
10787      * @category Function
10788      * @param {Function} func The function to apply a rest parameter to.
10789      * @param {number} [start=func.length-1] The start position of the rest parameter.
10790      * @returns {Function} Returns the new function.
10791      * @example
10792      *
10793      * var say = _.rest(function(what, names) {
10794      *   return what + ' ' + _.initial(names).join(', ') +
10795      *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
10796      * });
10797      *
10798      * say('hello', 'fred', 'barney', 'pebbles');
10799      * // => 'hello fred, barney, & pebbles'
10800      */
10801     function rest(func, start) {
10802       if (typeof func != 'function') {
10803         throw new TypeError(FUNC_ERROR_TEXT);
10804       }
10805       start = start === undefined ? start : toInteger(start);
10806       return baseRest(func, start);
10807     }
10808
10809     /**
10810      * Creates a function that invokes `func` with the `this` binding of the
10811      * create function and an array of arguments much like
10812      * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
10813      *
10814      * **Note:** This method is based on the
10815      * [spread operator](https://mdn.io/spread_operator).
10816      *
10817      * @static
10818      * @memberOf _
10819      * @since 3.2.0
10820      * @category Function
10821      * @param {Function} func The function to spread arguments over.
10822      * @param {number} [start=0] The start position of the spread.
10823      * @returns {Function} Returns the new function.
10824      * @example
10825      *
10826      * var say = _.spread(function(who, what) {
10827      *   return who + ' says ' + what;
10828      * });
10829      *
10830      * say(['fred', 'hello']);
10831      * // => 'fred says hello'
10832      *
10833      * var numbers = Promise.all([
10834      *   Promise.resolve(40),
10835      *   Promise.resolve(36)
10836      * ]);
10837      *
10838      * numbers.then(_.spread(function(x, y) {
10839      *   return x + y;
10840      * }));
10841      * // => a Promise of 76
10842      */
10843     function spread(func, start) {
10844       if (typeof func != 'function') {
10845         throw new TypeError(FUNC_ERROR_TEXT);
10846       }
10847       start = start == null ? 0 : nativeMax(toInteger(start), 0);
10848       return baseRest(function(args) {
10849         var array = args[start],
10850             otherArgs = castSlice(args, 0, start);
10851
10852         if (array) {
10853           arrayPush(otherArgs, array);
10854         }
10855         return apply(func, this, otherArgs);
10856       });
10857     }
10858
10859     /**
10860      * Creates a throttled function that only invokes `func` at most once per
10861      * every `wait` milliseconds. The throttled function comes with a `cancel`
10862      * method to cancel delayed `func` invocations and a `flush` method to
10863      * immediately invoke them. Provide `options` to indicate whether `func`
10864      * should be invoked on the leading and/or trailing edge of the `wait`
10865      * timeout. The `func` is invoked with the last arguments provided to the
10866      * throttled function. Subsequent calls to the throttled function return the
10867      * result of the last `func` invocation.
10868      *
10869      * **Note:** If `leading` and `trailing` options are `true`, `func` is
10870      * invoked on the trailing edge of the timeout only if the throttled function
10871      * is invoked more than once during the `wait` timeout.
10872      *
10873      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10874      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10875      *
10876      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10877      * for details over the differences between `_.throttle` and `_.debounce`.
10878      *
10879      * @static
10880      * @memberOf _
10881      * @since 0.1.0
10882      * @category Function
10883      * @param {Function} func The function to throttle.
10884      * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
10885      * @param {Object} [options={}] The options object.
10886      * @param {boolean} [options.leading=true]
10887      *  Specify invoking on the leading edge of the timeout.
10888      * @param {boolean} [options.trailing=true]
10889      *  Specify invoking on the trailing edge of the timeout.
10890      * @returns {Function} Returns the new throttled function.
10891      * @example
10892      *
10893      * // Avoid excessively updating the position while scrolling.
10894      * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
10895      *
10896      * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
10897      * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
10898      * jQuery(element).on('click', throttled);
10899      *
10900      * // Cancel the trailing throttled invocation.
10901      * jQuery(window).on('popstate', throttled.cancel);
10902      */
10903     function throttle(func, wait, options) {
10904       var leading = true,
10905           trailing = true;
10906
10907       if (typeof func != 'function') {
10908         throw new TypeError(FUNC_ERROR_TEXT);
10909       }
10910       if (isObject(options)) {
10911         leading = 'leading' in options ? !!options.leading : leading;
10912         trailing = 'trailing' in options ? !!options.trailing : trailing;
10913       }
10914       return debounce(func, wait, {
10915         'leading': leading,
10916         'maxWait': wait,
10917         'trailing': trailing
10918       });
10919     }
10920
10921     /**
10922      * Creates a function that accepts up to one argument, ignoring any
10923      * additional arguments.
10924      *
10925      * @static
10926      * @memberOf _
10927      * @since 4.0.0
10928      * @category Function
10929      * @param {Function} func The function to cap arguments for.
10930      * @returns {Function} Returns the new capped function.
10931      * @example
10932      *
10933      * _.map(['6', '8', '10'], _.unary(parseInt));
10934      * // => [6, 8, 10]
10935      */
10936     function unary(func) {
10937       return ary(func, 1);
10938     }
10939
10940     /**
10941      * Creates a function that provides `value` to `wrapper` as its first
10942      * argument. Any additional arguments provided to the function are appended
10943      * to those provided to the `wrapper`. The wrapper is invoked with the `this`
10944      * binding of the created function.
10945      *
10946      * @static
10947      * @memberOf _
10948      * @since 0.1.0
10949      * @category Function
10950      * @param {*} value The value to wrap.
10951      * @param {Function} [wrapper=identity] The wrapper function.
10952      * @returns {Function} Returns the new function.
10953      * @example
10954      *
10955      * var p = _.wrap(_.escape, function(func, text) {
10956      *   return '<p>' + func(text) + '</p>';
10957      * });
10958      *
10959      * p('fred, barney, & pebbles');
10960      * // => '<p>fred, barney, &amp; pebbles</p>'
10961      */
10962     function wrap(value, wrapper) {
10963       return partial(castFunction(wrapper), value);
10964     }
10965
10966     /*------------------------------------------------------------------------*/
10967
10968     /**
10969      * Casts `value` as an array if it's not one.
10970      *
10971      * @static
10972      * @memberOf _
10973      * @since 4.4.0
10974      * @category Lang
10975      * @param {*} value The value to inspect.
10976      * @returns {Array} Returns the cast array.
10977      * @example
10978      *
10979      * _.castArray(1);
10980      * // => [1]
10981      *
10982      * _.castArray({ 'a': 1 });
10983      * // => [{ 'a': 1 }]
10984      *
10985      * _.castArray('abc');
10986      * // => ['abc']
10987      *
10988      * _.castArray(null);
10989      * // => [null]
10990      *
10991      * _.castArray(undefined);
10992      * // => [undefined]
10993      *
10994      * _.castArray();
10995      * // => []
10996      *
10997      * var array = [1, 2, 3];
10998      * console.log(_.castArray(array) === array);
10999      * // => true
11000      */
11001     function castArray() {
11002       if (!arguments.length) {
11003         return [];
11004       }
11005       var value = arguments[0];
11006       return isArray(value) ? value : [value];
11007     }
11008
11009     /**
11010      * Creates a shallow clone of `value`.
11011      *
11012      * **Note:** This method is loosely based on the
11013      * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
11014      * and supports cloning arrays, array buffers, booleans, date objects, maps,
11015      * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
11016      * arrays. The own enumerable properties of `arguments` objects are cloned
11017      * as plain objects. An empty object is returned for uncloneable values such
11018      * as error objects, functions, DOM nodes, and WeakMaps.
11019      *
11020      * @static
11021      * @memberOf _
11022      * @since 0.1.0
11023      * @category Lang
11024      * @param {*} value The value to clone.
11025      * @returns {*} Returns the cloned value.
11026      * @see _.cloneDeep
11027      * @example
11028      *
11029      * var objects = [{ 'a': 1 }, { 'b': 2 }];
11030      *
11031      * var shallow = _.clone(objects);
11032      * console.log(shallow[0] === objects[0]);
11033      * // => true
11034      */
11035     function clone(value) {
11036       return baseClone(value, CLONE_SYMBOLS_FLAG);
11037     }
11038
11039     /**
11040      * This method is like `_.clone` except that it accepts `customizer` which
11041      * is invoked to produce the cloned value. If `customizer` returns `undefined`,
11042      * cloning is handled by the method instead. The `customizer` is invoked with
11043      * up to four arguments; (value [, index|key, object, stack]).
11044      *
11045      * @static
11046      * @memberOf _
11047      * @since 4.0.0
11048      * @category Lang
11049      * @param {*} value The value to clone.
11050      * @param {Function} [customizer] The function to customize cloning.
11051      * @returns {*} Returns the cloned value.
11052      * @see _.cloneDeepWith
11053      * @example
11054      *
11055      * function customizer(value) {
11056      *   if (_.isElement(value)) {
11057      *     return value.cloneNode(false);
11058      *   }
11059      * }
11060      *
11061      * var el = _.cloneWith(document.body, customizer);
11062      *
11063      * console.log(el === document.body);
11064      * // => false
11065      * console.log(el.nodeName);
11066      * // => 'BODY'
11067      * console.log(el.childNodes.length);
11068      * // => 0
11069      */
11070     function cloneWith(value, customizer) {
11071       customizer = typeof customizer == 'function' ? customizer : undefined;
11072       return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
11073     }
11074
11075     /**
11076      * This method is like `_.clone` except that it recursively clones `value`.
11077      *
11078      * @static
11079      * @memberOf _
11080      * @since 1.0.0
11081      * @category Lang
11082      * @param {*} value The value to recursively clone.
11083      * @returns {*} Returns the deep cloned value.
11084      * @see _.clone
11085      * @example
11086      *
11087      * var objects = [{ 'a': 1 }, { 'b': 2 }];
11088      *
11089      * var deep = _.cloneDeep(objects);
11090      * console.log(deep[0] === objects[0]);
11091      * // => false
11092      */
11093     function cloneDeep(value) {
11094       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
11095     }
11096
11097     /**
11098      * This method is like `_.cloneWith` except that it recursively clones `value`.
11099      *
11100      * @static
11101      * @memberOf _
11102      * @since 4.0.0
11103      * @category Lang
11104      * @param {*} value The value to recursively clone.
11105      * @param {Function} [customizer] The function to customize cloning.
11106      * @returns {*} Returns the deep cloned value.
11107      * @see _.cloneWith
11108      * @example
11109      *
11110      * function customizer(value) {
11111      *   if (_.isElement(value)) {
11112      *     return value.cloneNode(true);
11113      *   }
11114      * }
11115      *
11116      * var el = _.cloneDeepWith(document.body, customizer);
11117      *
11118      * console.log(el === document.body);
11119      * // => false
11120      * console.log(el.nodeName);
11121      * // => 'BODY'
11122      * console.log(el.childNodes.length);
11123      * // => 20
11124      */
11125     function cloneDeepWith(value, customizer) {
11126       customizer = typeof customizer == 'function' ? customizer : undefined;
11127       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
11128     }
11129
11130     /**
11131      * Checks if `object` conforms to `source` by invoking the predicate
11132      * properties of `source` with the corresponding property values of `object`.
11133      *
11134      * **Note:** This method is equivalent to `_.conforms` when `source` is
11135      * partially applied.
11136      *
11137      * @static
11138      * @memberOf _
11139      * @since 4.14.0
11140      * @category Lang
11141      * @param {Object} object The object to inspect.
11142      * @param {Object} source The object of property predicates to conform to.
11143      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
11144      * @example
11145      *
11146      * var object = { 'a': 1, 'b': 2 };
11147      *
11148      * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11149      * // => true
11150      *
11151      * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11152      * // => false
11153      */
11154     function conformsTo(object, source) {
11155       return source == null || baseConformsTo(object, source, keys(source));
11156     }
11157
11158     /**
11159      * Performs a
11160      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11161      * comparison between two values to determine if they are equivalent.
11162      *
11163      * @static
11164      * @memberOf _
11165      * @since 4.0.0
11166      * @category Lang
11167      * @param {*} value The value to compare.
11168      * @param {*} other The other value to compare.
11169      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11170      * @example
11171      *
11172      * var object = { 'a': 1 };
11173      * var other = { 'a': 1 };
11174      *
11175      * _.eq(object, object);
11176      * // => true
11177      *
11178      * _.eq(object, other);
11179      * // => false
11180      *
11181      * _.eq('a', 'a');
11182      * // => true
11183      *
11184      * _.eq('a', Object('a'));
11185      * // => false
11186      *
11187      * _.eq(NaN, NaN);
11188      * // => true
11189      */
11190     function eq(value, other) {
11191       return value === other || (value !== value && other !== other);
11192     }
11193
11194     /**
11195      * Checks if `value` is greater than `other`.
11196      *
11197      * @static
11198      * @memberOf _
11199      * @since 3.9.0
11200      * @category Lang
11201      * @param {*} value The value to compare.
11202      * @param {*} other The other value to compare.
11203      * @returns {boolean} Returns `true` if `value` is greater than `other`,
11204      *  else `false`.
11205      * @see _.lt
11206      * @example
11207      *
11208      * _.gt(3, 1);
11209      * // => true
11210      *
11211      * _.gt(3, 3);
11212      * // => false
11213      *
11214      * _.gt(1, 3);
11215      * // => false
11216      */
11217     var gt = createRelationalOperation(baseGt);
11218
11219     /**
11220      * Checks if `value` is greater than or equal to `other`.
11221      *
11222      * @static
11223      * @memberOf _
11224      * @since 3.9.0
11225      * @category Lang
11226      * @param {*} value The value to compare.
11227      * @param {*} other The other value to compare.
11228      * @returns {boolean} Returns `true` if `value` is greater than or equal to
11229      *  `other`, else `false`.
11230      * @see _.lte
11231      * @example
11232      *
11233      * _.gte(3, 1);
11234      * // => true
11235      *
11236      * _.gte(3, 3);
11237      * // => true
11238      *
11239      * _.gte(1, 3);
11240      * // => false
11241      */
11242     var gte = createRelationalOperation(function(value, other) {
11243       return value >= other;
11244     });
11245
11246     /**
11247      * Checks if `value` is likely an `arguments` object.
11248      *
11249      * @static
11250      * @memberOf _
11251      * @since 0.1.0
11252      * @category Lang
11253      * @param {*} value The value to check.
11254      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11255      *  else `false`.
11256      * @example
11257      *
11258      * _.isArguments(function() { return arguments; }());
11259      * // => true
11260      *
11261      * _.isArguments([1, 2, 3]);
11262      * // => false
11263      */
11264     var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11265       return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11266         !propertyIsEnumerable.call(value, 'callee');
11267     };
11268
11269     /**
11270      * Checks if `value` is classified as an `Array` object.
11271      *
11272      * @static
11273      * @memberOf _
11274      * @since 0.1.0
11275      * @category Lang
11276      * @param {*} value The value to check.
11277      * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11278      * @example
11279      *
11280      * _.isArray([1, 2, 3]);
11281      * // => true
11282      *
11283      * _.isArray(document.body.children);
11284      * // => false
11285      *
11286      * _.isArray('abc');
11287      * // => false
11288      *
11289      * _.isArray(_.noop);
11290      * // => false
11291      */
11292     var isArray = Array.isArray;
11293
11294     /**
11295      * Checks if `value` is classified as an `ArrayBuffer` object.
11296      *
11297      * @static
11298      * @memberOf _
11299      * @since 4.3.0
11300      * @category Lang
11301      * @param {*} value The value to check.
11302      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11303      * @example
11304      *
11305      * _.isArrayBuffer(new ArrayBuffer(2));
11306      * // => true
11307      *
11308      * _.isArrayBuffer(new Array(2));
11309      * // => false
11310      */
11311     var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
11312
11313     /**
11314      * Checks if `value` is array-like. A value is considered array-like if it's
11315      * not a function and has a `value.length` that's an integer greater than or
11316      * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
11317      *
11318      * @static
11319      * @memberOf _
11320      * @since 4.0.0
11321      * @category Lang
11322      * @param {*} value The value to check.
11323      * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11324      * @example
11325      *
11326      * _.isArrayLike([1, 2, 3]);
11327      * // => true
11328      *
11329      * _.isArrayLike(document.body.children);
11330      * // => true
11331      *
11332      * _.isArrayLike('abc');
11333      * // => true
11334      *
11335      * _.isArrayLike(_.noop);
11336      * // => false
11337      */
11338     function isArrayLike(value) {
11339       return value != null && isLength(value.length) && !isFunction(value);
11340     }
11341
11342     /**
11343      * This method is like `_.isArrayLike` except that it also checks if `value`
11344      * is an object.
11345      *
11346      * @static
11347      * @memberOf _
11348      * @since 4.0.0
11349      * @category Lang
11350      * @param {*} value The value to check.
11351      * @returns {boolean} Returns `true` if `value` is an array-like object,
11352      *  else `false`.
11353      * @example
11354      *
11355      * _.isArrayLikeObject([1, 2, 3]);
11356      * // => true
11357      *
11358      * _.isArrayLikeObject(document.body.children);
11359      * // => true
11360      *
11361      * _.isArrayLikeObject('abc');
11362      * // => false
11363      *
11364      * _.isArrayLikeObject(_.noop);
11365      * // => false
11366      */
11367     function isArrayLikeObject(value) {
11368       return isObjectLike(value) && isArrayLike(value);
11369     }
11370
11371     /**
11372      * Checks if `value` is classified as a boolean primitive or object.
11373      *
11374      * @static
11375      * @memberOf _
11376      * @since 0.1.0
11377      * @category Lang
11378      * @param {*} value The value to check.
11379      * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11380      * @example
11381      *
11382      * _.isBoolean(false);
11383      * // => true
11384      *
11385      * _.isBoolean(null);
11386      * // => false
11387      */
11388     function isBoolean(value) {
11389       return value === true || value === false ||
11390         (isObjectLike(value) && baseGetTag(value) == boolTag);
11391     }
11392
11393     /**
11394      * Checks if `value` is a buffer.
11395      *
11396      * @static
11397      * @memberOf _
11398      * @since 4.3.0
11399      * @category Lang
11400      * @param {*} value The value to check.
11401      * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11402      * @example
11403      *
11404      * _.isBuffer(new Buffer(2));
11405      * // => true
11406      *
11407      * _.isBuffer(new Uint8Array(2));
11408      * // => false
11409      */
11410     var isBuffer = nativeIsBuffer || stubFalse;
11411
11412     /**
11413      * Checks if `value` is classified as a `Date` object.
11414      *
11415      * @static
11416      * @memberOf _
11417      * @since 0.1.0
11418      * @category Lang
11419      * @param {*} value The value to check.
11420      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11421      * @example
11422      *
11423      * _.isDate(new Date);
11424      * // => true
11425      *
11426      * _.isDate('Mon April 23 2012');
11427      * // => false
11428      */
11429     var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11430
11431     /**
11432      * Checks if `value` is likely a DOM element.
11433      *
11434      * @static
11435      * @memberOf _
11436      * @since 0.1.0
11437      * @category Lang
11438      * @param {*} value The value to check.
11439      * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11440      * @example
11441      *
11442      * _.isElement(document.body);
11443      * // => true
11444      *
11445      * _.isElement('<body>');
11446      * // => false
11447      */
11448     function isElement(value) {
11449       return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11450     }
11451
11452     /**
11453      * Checks if `value` is an empty object, collection, map, or set.
11454      *
11455      * Objects are considered empty if they have no own enumerable string keyed
11456      * properties.
11457      *
11458      * Array-like values such as `arguments` objects, arrays, buffers, strings, or
11459      * jQuery-like collections are considered empty if they have a `length` of `0`.
11460      * Similarly, maps and sets are considered empty if they have a `size` of `0`.
11461      *
11462      * @static
11463      * @memberOf _
11464      * @since 0.1.0
11465      * @category Lang
11466      * @param {*} value The value to check.
11467      * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11468      * @example
11469      *
11470      * _.isEmpty(null);
11471      * // => true
11472      *
11473      * _.isEmpty(true);
11474      * // => true
11475      *
11476      * _.isEmpty(1);
11477      * // => true
11478      *
11479      * _.isEmpty([1, 2, 3]);
11480      * // => false
11481      *
11482      * _.isEmpty({ 'a': 1 });
11483      * // => false
11484      */
11485     function isEmpty(value) {
11486       if (value == null) {
11487         return true;
11488       }
11489       if (isArrayLike(value) &&
11490           (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
11491             isBuffer(value) || isTypedArray(value) || isArguments(value))) {
11492         return !value.length;
11493       }
11494       var tag = getTag(value);
11495       if (tag == mapTag || tag == setTag) {
11496         return !value.size;
11497       }
11498       if (isPrototype(value)) {
11499         return !baseKeys(value).length;
11500       }
11501       for (var key in value) {
11502         if (hasOwnProperty.call(value, key)) {
11503           return false;
11504         }
11505       }
11506       return true;
11507     }
11508
11509     /**
11510      * Performs a deep comparison between two values to determine if they are
11511      * equivalent.
11512      *
11513      * **Note:** This method supports comparing arrays, array buffers, booleans,
11514      * date objects, error objects, maps, numbers, `Object` objects, regexes,
11515      * sets, strings, symbols, and typed arrays. `Object` objects are compared
11516      * by their own, not inherited, enumerable properties. Functions and DOM
11517      * nodes are compared by strict equality, i.e. `===`.
11518      *
11519      * @static
11520      * @memberOf _
11521      * @since 0.1.0
11522      * @category Lang
11523      * @param {*} value The value to compare.
11524      * @param {*} other The other value to compare.
11525      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11526      * @example
11527      *
11528      * var object = { 'a': 1 };
11529      * var other = { 'a': 1 };
11530      *
11531      * _.isEqual(object, other);
11532      * // => true
11533      *
11534      * object === other;
11535      * // => false
11536      */
11537     function isEqual(value, other) {
11538       return baseIsEqual(value, other);
11539     }
11540
11541     /**
11542      * This method is like `_.isEqual` except that it accepts `customizer` which
11543      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11544      * are handled by the method instead. The `customizer` is invoked with up to
11545      * six arguments: (objValue, othValue [, index|key, object, other, stack]).
11546      *
11547      * @static
11548      * @memberOf _
11549      * @since 4.0.0
11550      * @category Lang
11551      * @param {*} value The value to compare.
11552      * @param {*} other The other value to compare.
11553      * @param {Function} [customizer] The function to customize comparisons.
11554      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11555      * @example
11556      *
11557      * function isGreeting(value) {
11558      *   return /^h(?:i|ello)$/.test(value);
11559      * }
11560      *
11561      * function customizer(objValue, othValue) {
11562      *   if (isGreeting(objValue) && isGreeting(othValue)) {
11563      *     return true;
11564      *   }
11565      * }
11566      *
11567      * var array = ['hello', 'goodbye'];
11568      * var other = ['hi', 'goodbye'];
11569      *
11570      * _.isEqualWith(array, other, customizer);
11571      * // => true
11572      */
11573     function isEqualWith(value, other, customizer) {
11574       customizer = typeof customizer == 'function' ? customizer : undefined;
11575       var result = customizer ? customizer(value, other) : undefined;
11576       return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
11577     }
11578
11579     /**
11580      * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11581      * `SyntaxError`, `TypeError`, or `URIError` object.
11582      *
11583      * @static
11584      * @memberOf _
11585      * @since 3.0.0
11586      * @category Lang
11587      * @param {*} value The value to check.
11588      * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11589      * @example
11590      *
11591      * _.isError(new Error);
11592      * // => true
11593      *
11594      * _.isError(Error);
11595      * // => false
11596      */
11597     function isError(value) {
11598       if (!isObjectLike(value)) {
11599         return false;
11600       }
11601       var tag = baseGetTag(value);
11602       return tag == errorTag || tag == domExcTag ||
11603         (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11604     }
11605
11606     /**
11607      * Checks if `value` is a finite primitive number.
11608      *
11609      * **Note:** This method is based on
11610      * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11611      *
11612      * @static
11613      * @memberOf _
11614      * @since 0.1.0
11615      * @category Lang
11616      * @param {*} value The value to check.
11617      * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11618      * @example
11619      *
11620      * _.isFinite(3);
11621      * // => true
11622      *
11623      * _.isFinite(Number.MIN_VALUE);
11624      * // => true
11625      *
11626      * _.isFinite(Infinity);
11627      * // => false
11628      *
11629      * _.isFinite('3');
11630      * // => false
11631      */
11632     function isFinite(value) {
11633       return typeof value == 'number' && nativeIsFinite(value);
11634     }
11635
11636     /**
11637      * Checks if `value` is classified as a `Function` object.
11638      *
11639      * @static
11640      * @memberOf _
11641      * @since 0.1.0
11642      * @category Lang
11643      * @param {*} value The value to check.
11644      * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11645      * @example
11646      *
11647      * _.isFunction(_);
11648      * // => true
11649      *
11650      * _.isFunction(/abc/);
11651      * // => false
11652      */
11653     function isFunction(value) {
11654       if (!isObject(value)) {
11655         return false;
11656       }
11657       // The use of `Object#toString` avoids issues with the `typeof` operator
11658       // in Safari 9 which returns 'object' for typed arrays and other constructors.
11659       var tag = baseGetTag(value);
11660       return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11661     }
11662
11663     /**
11664      * Checks if `value` is an integer.
11665      *
11666      * **Note:** This method is based on
11667      * [`Number.isInteger`](https://mdn.io/Number/isInteger).
11668      *
11669      * @static
11670      * @memberOf _
11671      * @since 4.0.0
11672      * @category Lang
11673      * @param {*} value The value to check.
11674      * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
11675      * @example
11676      *
11677      * _.isInteger(3);
11678      * // => true
11679      *
11680      * _.isInteger(Number.MIN_VALUE);
11681      * // => false
11682      *
11683      * _.isInteger(Infinity);
11684      * // => false
11685      *
11686      * _.isInteger('3');
11687      * // => false
11688      */
11689     function isInteger(value) {
11690       return typeof value == 'number' && value == toInteger(value);
11691     }
11692
11693     /**
11694      * Checks if `value` is a valid array-like length.
11695      *
11696      * **Note:** This method is loosely based on
11697      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
11698      *
11699      * @static
11700      * @memberOf _
11701      * @since 4.0.0
11702      * @category Lang
11703      * @param {*} value The value to check.
11704      * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11705      * @example
11706      *
11707      * _.isLength(3);
11708      * // => true
11709      *
11710      * _.isLength(Number.MIN_VALUE);
11711      * // => false
11712      *
11713      * _.isLength(Infinity);
11714      * // => false
11715      *
11716      * _.isLength('3');
11717      * // => false
11718      */
11719     function isLength(value) {
11720       return typeof value == 'number' &&
11721         value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
11722     }
11723
11724     /**
11725      * Checks if `value` is the
11726      * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11727      * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11728      *
11729      * @static
11730      * @memberOf _
11731      * @since 0.1.0
11732      * @category Lang
11733      * @param {*} value The value to check.
11734      * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11735      * @example
11736      *
11737      * _.isObject({});
11738      * // => true
11739      *
11740      * _.isObject([1, 2, 3]);
11741      * // => true
11742      *
11743      * _.isObject(_.noop);
11744      * // => true
11745      *
11746      * _.isObject(null);
11747      * // => false
11748      */
11749     function isObject(value) {
11750       var type = typeof value;
11751       return value != null && (type == 'object' || type == 'function');
11752     }
11753
11754     /**
11755      * Checks if `value` is object-like. A value is object-like if it's not `null`
11756      * and has a `typeof` result of "object".
11757      *
11758      * @static
11759      * @memberOf _
11760      * @since 4.0.0
11761      * @category Lang
11762      * @param {*} value The value to check.
11763      * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11764      * @example
11765      *
11766      * _.isObjectLike({});
11767      * // => true
11768      *
11769      * _.isObjectLike([1, 2, 3]);
11770      * // => true
11771      *
11772      * _.isObjectLike(_.noop);
11773      * // => false
11774      *
11775      * _.isObjectLike(null);
11776      * // => false
11777      */
11778     function isObjectLike(value) {
11779       return value != null && typeof value == 'object';
11780     }
11781
11782     /**
11783      * Checks if `value` is classified as a `Map` object.
11784      *
11785      * @static
11786      * @memberOf _
11787      * @since 4.3.0
11788      * @category Lang
11789      * @param {*} value The value to check.
11790      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
11791      * @example
11792      *
11793      * _.isMap(new Map);
11794      * // => true
11795      *
11796      * _.isMap(new WeakMap);
11797      * // => false
11798      */
11799     var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
11800
11801     /**
11802      * Performs a partial deep comparison between `object` and `source` to
11803      * determine if `object` contains equivalent property values.
11804      *
11805      * **Note:** This method is equivalent to `_.matches` when `source` is
11806      * partially applied.
11807      *
11808      * Partial comparisons will match empty array and empty object `source`
11809      * values against any array or object value, respectively. See `_.isEqual`
11810      * for a list of supported value comparisons.
11811      *
11812      * @static
11813      * @memberOf _
11814      * @since 3.0.0
11815      * @category Lang
11816      * @param {Object} object The object to inspect.
11817      * @param {Object} source The object of property values to match.
11818      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11819      * @example
11820      *
11821      * var object = { 'a': 1, 'b': 2 };
11822      *
11823      * _.isMatch(object, { 'b': 2 });
11824      * // => true
11825      *
11826      * _.isMatch(object, { 'b': 1 });
11827      * // => false
11828      */
11829     function isMatch(object, source) {
11830       return object === source || baseIsMatch(object, source, getMatchData(source));
11831     }
11832
11833     /**
11834      * This method is like `_.isMatch` except that it accepts `customizer` which
11835      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11836      * are handled by the method instead. The `customizer` is invoked with five
11837      * arguments: (objValue, srcValue, index|key, object, source).
11838      *
11839      * @static
11840      * @memberOf _
11841      * @since 4.0.0
11842      * @category Lang
11843      * @param {Object} object The object to inspect.
11844      * @param {Object} source The object of property values to match.
11845      * @param {Function} [customizer] The function to customize comparisons.
11846      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11847      * @example
11848      *
11849      * function isGreeting(value) {
11850      *   return /^h(?:i|ello)$/.test(value);
11851      * }
11852      *
11853      * function customizer(objValue, srcValue) {
11854      *   if (isGreeting(objValue) && isGreeting(srcValue)) {
11855      *     return true;
11856      *   }
11857      * }
11858      *
11859      * var object = { 'greeting': 'hello' };
11860      * var source = { 'greeting': 'hi' };
11861      *
11862      * _.isMatchWith(object, source, customizer);
11863      * // => true
11864      */
11865     function isMatchWith(object, source, customizer) {
11866       customizer = typeof customizer == 'function' ? customizer : undefined;
11867       return baseIsMatch(object, source, getMatchData(source), customizer);
11868     }
11869
11870     /**
11871      * Checks if `value` is `NaN`.
11872      *
11873      * **Note:** This method is based on
11874      * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
11875      * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
11876      * `undefined` and other non-number values.
11877      *
11878      * @static
11879      * @memberOf _
11880      * @since 0.1.0
11881      * @category Lang
11882      * @param {*} value The value to check.
11883      * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
11884      * @example
11885      *
11886      * _.isNaN(NaN);
11887      * // => true
11888      *
11889      * _.isNaN(new Number(NaN));
11890      * // => true
11891      *
11892      * isNaN(undefined);
11893      * // => true
11894      *
11895      * _.isNaN(undefined);
11896      * // => false
11897      */
11898     function isNaN(value) {
11899       // An `NaN` primitive is the only value that is not equal to itself.
11900       // Perform the `toStringTag` check first to avoid errors with some
11901       // ActiveX objects in IE.
11902       return isNumber(value) && value != +value;
11903     }
11904
11905     /**
11906      * Checks if `value` is a pristine native function.
11907      *
11908      * **Note:** This method can't reliably detect native functions in the presence
11909      * of the core-js package because core-js circumvents this kind of detection.
11910      * Despite multiple requests, the core-js maintainer has made it clear: any
11911      * attempt to fix the detection will be obstructed. As a result, we're left
11912      * with little choice but to throw an error. Unfortunately, this also affects
11913      * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
11914      * which rely on core-js.
11915      *
11916      * @static
11917      * @memberOf _
11918      * @since 3.0.0
11919      * @category Lang
11920      * @param {*} value The value to check.
11921      * @returns {boolean} Returns `true` if `value` is a native function,
11922      *  else `false`.
11923      * @example
11924      *
11925      * _.isNative(Array.prototype.push);
11926      * // => true
11927      *
11928      * _.isNative(_);
11929      * // => false
11930      */
11931     function isNative(value) {
11932       if (isMaskable(value)) {
11933         throw new Error(CORE_ERROR_TEXT);
11934       }
11935       return baseIsNative(value);
11936     }
11937
11938     /**
11939      * Checks if `value` is `null`.
11940      *
11941      * @static
11942      * @memberOf _
11943      * @since 0.1.0
11944      * @category Lang
11945      * @param {*} value The value to check.
11946      * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
11947      * @example
11948      *
11949      * _.isNull(null);
11950      * // => true
11951      *
11952      * _.isNull(void 0);
11953      * // => false
11954      */
11955     function isNull(value) {
11956       return value === null;
11957     }
11958
11959     /**
11960      * Checks if `value` is `null` or `undefined`.
11961      *
11962      * @static
11963      * @memberOf _
11964      * @since 4.0.0
11965      * @category Lang
11966      * @param {*} value The value to check.
11967      * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
11968      * @example
11969      *
11970      * _.isNil(null);
11971      * // => true
11972      *
11973      * _.isNil(void 0);
11974      * // => true
11975      *
11976      * _.isNil(NaN);
11977      * // => false
11978      */
11979     function isNil(value) {
11980       return value == null;
11981     }
11982
11983     /**
11984      * Checks if `value` is classified as a `Number` primitive or object.
11985      *
11986      * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
11987      * classified as numbers, use the `_.isFinite` method.
11988      *
11989      * @static
11990      * @memberOf _
11991      * @since 0.1.0
11992      * @category Lang
11993      * @param {*} value The value to check.
11994      * @returns {boolean} Returns `true` if `value` is a number, else `false`.
11995      * @example
11996      *
11997      * _.isNumber(3);
11998      * // => true
11999      *
12000      * _.isNumber(Number.MIN_VALUE);
12001      * // => true
12002      *
12003      * _.isNumber(Infinity);
12004      * // => true
12005      *
12006      * _.isNumber('3');
12007      * // => false
12008      */
12009     function isNumber(value) {
12010       return typeof value == 'number' ||
12011         (isObjectLike(value) && baseGetTag(value) == numberTag);
12012     }
12013
12014     /**
12015      * Checks if `value` is a plain object, that is, an object created by the
12016      * `Object` constructor or one with a `[[Prototype]]` of `null`.
12017      *
12018      * @static
12019      * @memberOf _
12020      * @since 0.8.0
12021      * @category Lang
12022      * @param {*} value The value to check.
12023      * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
12024      * @example
12025      *
12026      * function Foo() {
12027      *   this.a = 1;
12028      * }
12029      *
12030      * _.isPlainObject(new Foo);
12031      * // => false
12032      *
12033      * _.isPlainObject([1, 2, 3]);
12034      * // => false
12035      *
12036      * _.isPlainObject({ 'x': 0, 'y': 0 });
12037      * // => true
12038      *
12039      * _.isPlainObject(Object.create(null));
12040      * // => true
12041      */
12042     function isPlainObject(value) {
12043       if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12044         return false;
12045       }
12046       var proto = getPrototype(value);
12047       if (proto === null) {
12048         return true;
12049       }
12050       var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12051       return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12052         funcToString.call(Ctor) == objectCtorString;
12053     }
12054
12055     /**
12056      * Checks if `value` is classified as a `RegExp` object.
12057      *
12058      * @static
12059      * @memberOf _
12060      * @since 0.1.0
12061      * @category Lang
12062      * @param {*} value The value to check.
12063      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12064      * @example
12065      *
12066      * _.isRegExp(/abc/);
12067      * // => true
12068      *
12069      * _.isRegExp('/abc/');
12070      * // => false
12071      */
12072     var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
12073
12074     /**
12075      * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
12076      * double precision number which isn't the result of a rounded unsafe integer.
12077      *
12078      * **Note:** This method is based on
12079      * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12080      *
12081      * @static
12082      * @memberOf _
12083      * @since 4.0.0
12084      * @category Lang
12085      * @param {*} value The value to check.
12086      * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12087      * @example
12088      *
12089      * _.isSafeInteger(3);
12090      * // => true
12091      *
12092      * _.isSafeInteger(Number.MIN_VALUE);
12093      * // => false
12094      *
12095      * _.isSafeInteger(Infinity);
12096      * // => false
12097      *
12098      * _.isSafeInteger('3');
12099      * // => false
12100      */
12101     function isSafeInteger(value) {
12102       return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12103     }
12104
12105     /**
12106      * Checks if `value` is classified as a `Set` object.
12107      *
12108      * @static
12109      * @memberOf _
12110      * @since 4.3.0
12111      * @category Lang
12112      * @param {*} value The value to check.
12113      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12114      * @example
12115      *
12116      * _.isSet(new Set);
12117      * // => true
12118      *
12119      * _.isSet(new WeakSet);
12120      * // => false
12121      */
12122     var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12123
12124     /**
12125      * Checks if `value` is classified as a `String` primitive or object.
12126      *
12127      * @static
12128      * @since 0.1.0
12129      * @memberOf _
12130      * @category Lang
12131      * @param {*} value The value to check.
12132      * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12133      * @example
12134      *
12135      * _.isString('abc');
12136      * // => true
12137      *
12138      * _.isString(1);
12139      * // => false
12140      */
12141     function isString(value) {
12142       return typeof value == 'string' ||
12143         (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12144     }
12145
12146     /**
12147      * Checks if `value` is classified as a `Symbol` primitive or object.
12148      *
12149      * @static
12150      * @memberOf _
12151      * @since 4.0.0
12152      * @category Lang
12153      * @param {*} value The value to check.
12154      * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12155      * @example
12156      *
12157      * _.isSymbol(Symbol.iterator);
12158      * // => true
12159      *
12160      * _.isSymbol('abc');
12161      * // => false
12162      */
12163     function isSymbol(value) {
12164       return typeof value == 'symbol' ||
12165         (isObjectLike(value) && baseGetTag(value) == symbolTag);
12166     }
12167
12168     /**
12169      * Checks if `value` is classified as a typed array.
12170      *
12171      * @static
12172      * @memberOf _
12173      * @since 3.0.0
12174      * @category Lang
12175      * @param {*} value The value to check.
12176      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12177      * @example
12178      *
12179      * _.isTypedArray(new Uint8Array);
12180      * // => true
12181      *
12182      * _.isTypedArray([]);
12183      * // => false
12184      */
12185     var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12186
12187     /**
12188      * Checks if `value` is `undefined`.
12189      *
12190      * @static
12191      * @since 0.1.0
12192      * @memberOf _
12193      * @category Lang
12194      * @param {*} value The value to check.
12195      * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12196      * @example
12197      *
12198      * _.isUndefined(void 0);
12199      * // => true
12200      *
12201      * _.isUndefined(null);
12202      * // => false
12203      */
12204     function isUndefined(value) {
12205       return value === undefined;
12206     }
12207
12208     /**
12209      * Checks if `value` is classified as a `WeakMap` object.
12210      *
12211      * @static
12212      * @memberOf _
12213      * @since 4.3.0
12214      * @category Lang
12215      * @param {*} value The value to check.
12216      * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12217      * @example
12218      *
12219      * _.isWeakMap(new WeakMap);
12220      * // => true
12221      *
12222      * _.isWeakMap(new Map);
12223      * // => false
12224      */
12225     function isWeakMap(value) {
12226       return isObjectLike(value) && getTag(value) == weakMapTag;
12227     }
12228
12229     /**
12230      * Checks if `value` is classified as a `WeakSet` object.
12231      *
12232      * @static
12233      * @memberOf _
12234      * @since 4.3.0
12235      * @category Lang
12236      * @param {*} value The value to check.
12237      * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12238      * @example
12239      *
12240      * _.isWeakSet(new WeakSet);
12241      * // => true
12242      *
12243      * _.isWeakSet(new Set);
12244      * // => false
12245      */
12246     function isWeakSet(value) {
12247       return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12248     }
12249
12250     /**
12251      * Checks if `value` is less than `other`.
12252      *
12253      * @static
12254      * @memberOf _
12255      * @since 3.9.0
12256      * @category Lang
12257      * @param {*} value The value to compare.
12258      * @param {*} other The other value to compare.
12259      * @returns {boolean} Returns `true` if `value` is less than `other`,
12260      *  else `false`.
12261      * @see _.gt
12262      * @example
12263      *
12264      * _.lt(1, 3);
12265      * // => true
12266      *
12267      * _.lt(3, 3);
12268      * // => false
12269      *
12270      * _.lt(3, 1);
12271      * // => false
12272      */
12273     var lt = createRelationalOperation(baseLt);
12274
12275     /**
12276      * Checks if `value` is less than or equal to `other`.
12277      *
12278      * @static
12279      * @memberOf _
12280      * @since 3.9.0
12281      * @category Lang
12282      * @param {*} value The value to compare.
12283      * @param {*} other The other value to compare.
12284      * @returns {boolean} Returns `true` if `value` is less than or equal to
12285      *  `other`, else `false`.
12286      * @see _.gte
12287      * @example
12288      *
12289      * _.lte(1, 3);
12290      * // => true
12291      *
12292      * _.lte(3, 3);
12293      * // => true
12294      *
12295      * _.lte(3, 1);
12296      * // => false
12297      */
12298     var lte = createRelationalOperation(function(value, other) {
12299       return value <= other;
12300     });
12301
12302     /**
12303      * Converts `value` to an array.
12304      *
12305      * @static
12306      * @since 0.1.0
12307      * @memberOf _
12308      * @category Lang
12309      * @param {*} value The value to convert.
12310      * @returns {Array} Returns the converted array.
12311      * @example
12312      *
12313      * _.toArray({ 'a': 1, 'b': 2 });
12314      * // => [1, 2]
12315      *
12316      * _.toArray('abc');
12317      * // => ['a', 'b', 'c']
12318      *
12319      * _.toArray(1);
12320      * // => []
12321      *
12322      * _.toArray(null);
12323      * // => []
12324      */
12325     function toArray(value) {
12326       if (!value) {
12327         return [];
12328       }
12329       if (isArrayLike(value)) {
12330         return isString(value) ? stringToArray(value) : copyArray(value);
12331       }
12332       if (symIterator && value[symIterator]) {
12333         return iteratorToArray(value[symIterator]());
12334       }
12335       var tag = getTag(value),
12336           func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12337
12338       return func(value);
12339     }
12340
12341     /**
12342      * Converts `value` to a finite number.
12343      *
12344      * @static
12345      * @memberOf _
12346      * @since 4.12.0
12347      * @category Lang
12348      * @param {*} value The value to convert.
12349      * @returns {number} Returns the converted number.
12350      * @example
12351      *
12352      * _.toFinite(3.2);
12353      * // => 3.2
12354      *
12355      * _.toFinite(Number.MIN_VALUE);
12356      * // => 5e-324
12357      *
12358      * _.toFinite(Infinity);
12359      * // => 1.7976931348623157e+308
12360      *
12361      * _.toFinite('3.2');
12362      * // => 3.2
12363      */
12364     function toFinite(value) {
12365       if (!value) {
12366         return value === 0 ? value : 0;
12367       }
12368       value = toNumber(value);
12369       if (value === INFINITY || value === -INFINITY) {
12370         var sign = (value < 0 ? -1 : 1);
12371         return sign * MAX_INTEGER;
12372       }
12373       return value === value ? value : 0;
12374     }
12375
12376     /**
12377      * Converts `value` to an integer.
12378      *
12379      * **Note:** This method is loosely based on
12380      * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12381      *
12382      * @static
12383      * @memberOf _
12384      * @since 4.0.0
12385      * @category Lang
12386      * @param {*} value The value to convert.
12387      * @returns {number} Returns the converted integer.
12388      * @example
12389      *
12390      * _.toInteger(3.2);
12391      * // => 3
12392      *
12393      * _.toInteger(Number.MIN_VALUE);
12394      * // => 0
12395      *
12396      * _.toInteger(Infinity);
12397      * // => 1.7976931348623157e+308
12398      *
12399      * _.toInteger('3.2');
12400      * // => 3
12401      */
12402     function toInteger(value) {
12403       var result = toFinite(value),
12404           remainder = result % 1;
12405
12406       return result === result ? (remainder ? result - remainder : result) : 0;
12407     }
12408
12409     /**
12410      * Converts `value` to an integer suitable for use as the length of an
12411      * array-like object.
12412      *
12413      * **Note:** This method is based on
12414      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12415      *
12416      * @static
12417      * @memberOf _
12418      * @since 4.0.0
12419      * @category Lang
12420      * @param {*} value The value to convert.
12421      * @returns {number} Returns the converted integer.
12422      * @example
12423      *
12424      * _.toLength(3.2);
12425      * // => 3
12426      *
12427      * _.toLength(Number.MIN_VALUE);
12428      * // => 0
12429      *
12430      * _.toLength(Infinity);
12431      * // => 4294967295
12432      *
12433      * _.toLength('3.2');
12434      * // => 3
12435      */
12436     function toLength(value) {
12437       return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12438     }
12439
12440     /**
12441      * Converts `value` to a number.
12442      *
12443      * @static
12444      * @memberOf _
12445      * @since 4.0.0
12446      * @category Lang
12447      * @param {*} value The value to process.
12448      * @returns {number} Returns the number.
12449      * @example
12450      *
12451      * _.toNumber(3.2);
12452      * // => 3.2
12453      *
12454      * _.toNumber(Number.MIN_VALUE);
12455      * // => 5e-324
12456      *
12457      * _.toNumber(Infinity);
12458      * // => Infinity
12459      *
12460      * _.toNumber('3.2');
12461      * // => 3.2
12462      */
12463     function toNumber(value) {
12464       if (typeof value == 'number') {
12465         return value;
12466       }
12467       if (isSymbol(value)) {
12468         return NAN;
12469       }
12470       if (isObject(value)) {
12471         var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12472         value = isObject(other) ? (other + '') : other;
12473       }
12474       if (typeof value != 'string') {
12475         return value === 0 ? value : +value;
12476       }
12477       value = value.replace(reTrim, '');
12478       var isBinary = reIsBinary.test(value);
12479       return (isBinary || reIsOctal.test(value))
12480         ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
12481         : (reIsBadHex.test(value) ? NAN : +value);
12482     }
12483
12484     /**
12485      * Converts `value` to a plain object flattening inherited enumerable string
12486      * keyed properties of `value` to own properties of the plain object.
12487      *
12488      * @static
12489      * @memberOf _
12490      * @since 3.0.0
12491      * @category Lang
12492      * @param {*} value The value to convert.
12493      * @returns {Object} Returns the converted plain object.
12494      * @example
12495      *
12496      * function Foo() {
12497      *   this.b = 2;
12498      * }
12499      *
12500      * Foo.prototype.c = 3;
12501      *
12502      * _.assign({ 'a': 1 }, new Foo);
12503      * // => { 'a': 1, 'b': 2 }
12504      *
12505      * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12506      * // => { 'a': 1, 'b': 2, 'c': 3 }
12507      */
12508     function toPlainObject(value) {
12509       return copyObject(value, keysIn(value));
12510     }
12511
12512     /**
12513      * Converts `value` to a safe integer. A safe integer can be compared and
12514      * represented correctly.
12515      *
12516      * @static
12517      * @memberOf _
12518      * @since 4.0.0
12519      * @category Lang
12520      * @param {*} value The value to convert.
12521      * @returns {number} Returns the converted integer.
12522      * @example
12523      *
12524      * _.toSafeInteger(3.2);
12525      * // => 3
12526      *
12527      * _.toSafeInteger(Number.MIN_VALUE);
12528      * // => 0
12529      *
12530      * _.toSafeInteger(Infinity);
12531      * // => 9007199254740991
12532      *
12533      * _.toSafeInteger('3.2');
12534      * // => 3
12535      */
12536     function toSafeInteger(value) {
12537       return value
12538         ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
12539         : (value === 0 ? value : 0);
12540     }
12541
12542     /**
12543      * Converts `value` to a string. An empty string is returned for `null`
12544      * and `undefined` values. The sign of `-0` is preserved.
12545      *
12546      * @static
12547      * @memberOf _
12548      * @since 4.0.0
12549      * @category Lang
12550      * @param {*} value The value to convert.
12551      * @returns {string} Returns the converted string.
12552      * @example
12553      *
12554      * _.toString(null);
12555      * // => ''
12556      *
12557      * _.toString(-0);
12558      * // => '-0'
12559      *
12560      * _.toString([1, 2, 3]);
12561      * // => '1,2,3'
12562      */
12563     function toString(value) {
12564       return value == null ? '' : baseToString(value);
12565     }
12566
12567     /*------------------------------------------------------------------------*/
12568
12569     /**
12570      * Assigns own enumerable string keyed properties of source objects to the
12571      * destination object. Source objects are applied from left to right.
12572      * Subsequent sources overwrite property assignments of previous sources.
12573      *
12574      * **Note:** This method mutates `object` and is loosely based on
12575      * [`Object.assign`](https://mdn.io/Object/assign).
12576      *
12577      * @static
12578      * @memberOf _
12579      * @since 0.10.0
12580      * @category Object
12581      * @param {Object} object The destination object.
12582      * @param {...Object} [sources] The source objects.
12583      * @returns {Object} Returns `object`.
12584      * @see _.assignIn
12585      * @example
12586      *
12587      * function Foo() {
12588      *   this.a = 1;
12589      * }
12590      *
12591      * function Bar() {
12592      *   this.c = 3;
12593      * }
12594      *
12595      * Foo.prototype.b = 2;
12596      * Bar.prototype.d = 4;
12597      *
12598      * _.assign({ 'a': 0 }, new Foo, new Bar);
12599      * // => { 'a': 1, 'c': 3 }
12600      */
12601     var assign = createAssigner(function(object, source) {
12602       if (isPrototype(source) || isArrayLike(source)) {
12603         copyObject(source, keys(source), object);
12604         return;
12605       }
12606       for (var key in source) {
12607         if (hasOwnProperty.call(source, key)) {
12608           assignValue(object, key, source[key]);
12609         }
12610       }
12611     });
12612
12613     /**
12614      * This method is like `_.assign` except that it iterates over own and
12615      * inherited source properties.
12616      *
12617      * **Note:** This method mutates `object`.
12618      *
12619      * @static
12620      * @memberOf _
12621      * @since 4.0.0
12622      * @alias extend
12623      * @category Object
12624      * @param {Object} object The destination object.
12625      * @param {...Object} [sources] The source objects.
12626      * @returns {Object} Returns `object`.
12627      * @see _.assign
12628      * @example
12629      *
12630      * function Foo() {
12631      *   this.a = 1;
12632      * }
12633      *
12634      * function Bar() {
12635      *   this.c = 3;
12636      * }
12637      *
12638      * Foo.prototype.b = 2;
12639      * Bar.prototype.d = 4;
12640      *
12641      * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12642      * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12643      */
12644     var assignIn = createAssigner(function(object, source) {
12645       copyObject(source, keysIn(source), object);
12646     });
12647
12648     /**
12649      * This method is like `_.assignIn` except that it accepts `customizer`
12650      * which is invoked to produce the assigned values. If `customizer` returns
12651      * `undefined`, assignment is handled by the method instead. The `customizer`
12652      * is invoked with five arguments: (objValue, srcValue, key, object, source).
12653      *
12654      * **Note:** This method mutates `object`.
12655      *
12656      * @static
12657      * @memberOf _
12658      * @since 4.0.0
12659      * @alias extendWith
12660      * @category Object
12661      * @param {Object} object The destination object.
12662      * @param {...Object} sources The source objects.
12663      * @param {Function} [customizer] The function to customize assigned values.
12664      * @returns {Object} Returns `object`.
12665      * @see _.assignWith
12666      * @example
12667      *
12668      * function customizer(objValue, srcValue) {
12669      *   return _.isUndefined(objValue) ? srcValue : objValue;
12670      * }
12671      *
12672      * var defaults = _.partialRight(_.assignInWith, customizer);
12673      *
12674      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12675      * // => { 'a': 1, 'b': 2 }
12676      */
12677     var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
12678       copyObject(source, keysIn(source), object, customizer);
12679     });
12680
12681     /**
12682      * This method is like `_.assign` except that it accepts `customizer`
12683      * which is invoked to produce the assigned values. If `customizer` returns
12684      * `undefined`, assignment is handled by the method instead. The `customizer`
12685      * is invoked with five arguments: (objValue, srcValue, key, object, source).
12686      *
12687      * **Note:** This method mutates `object`.
12688      *
12689      * @static
12690      * @memberOf _
12691      * @since 4.0.0
12692      * @category Object
12693      * @param {Object} object The destination object.
12694      * @param {...Object} sources The source objects.
12695      * @param {Function} [customizer] The function to customize assigned values.
12696      * @returns {Object} Returns `object`.
12697      * @see _.assignInWith
12698      * @example
12699      *
12700      * function customizer(objValue, srcValue) {
12701      *   return _.isUndefined(objValue) ? srcValue : objValue;
12702      * }
12703      *
12704      * var defaults = _.partialRight(_.assignWith, customizer);
12705      *
12706      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12707      * // => { 'a': 1, 'b': 2 }
12708      */
12709     var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
12710       copyObject(source, keys(source), object, customizer);
12711     });
12712
12713     /**
12714      * Creates an array of values corresponding to `paths` of `object`.
12715      *
12716      * @static
12717      * @memberOf _
12718      * @since 1.0.0
12719      * @category Object
12720      * @param {Object} object The object to iterate over.
12721      * @param {...(string|string[])} [paths] The property paths to pick.
12722      * @returns {Array} Returns the picked values.
12723      * @example
12724      *
12725      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
12726      *
12727      * _.at(object, ['a[0].b.c', 'a[1]']);
12728      * // => [3, 4]
12729      */
12730     var at = flatRest(baseAt);
12731
12732     /**
12733      * Creates an object that inherits from the `prototype` object. If a
12734      * `properties` object is given, its own enumerable string keyed properties
12735      * are assigned to the created object.
12736      *
12737      * @static
12738      * @memberOf _
12739      * @since 2.3.0
12740      * @category Object
12741      * @param {Object} prototype The object to inherit from.
12742      * @param {Object} [properties] The properties to assign to the object.
12743      * @returns {Object} Returns the new object.
12744      * @example
12745      *
12746      * function Shape() {
12747      *   this.x = 0;
12748      *   this.y = 0;
12749      * }
12750      *
12751      * function Circle() {
12752      *   Shape.call(this);
12753      * }
12754      *
12755      * Circle.prototype = _.create(Shape.prototype, {
12756      *   'constructor': Circle
12757      * });
12758      *
12759      * var circle = new Circle;
12760      * circle instanceof Circle;
12761      * // => true
12762      *
12763      * circle instanceof Shape;
12764      * // => true
12765      */
12766     function create(prototype, properties) {
12767       var result = baseCreate(prototype);
12768       return properties == null ? result : baseAssign(result, properties);
12769     }
12770
12771     /**
12772      * Assigns own and inherited enumerable string keyed properties of source
12773      * objects to the destination object for all destination properties that
12774      * resolve to `undefined`. Source objects are applied from left to right.
12775      * Once a property is set, additional values of the same property are ignored.
12776      *
12777      * **Note:** This method mutates `object`.
12778      *
12779      * @static
12780      * @since 0.1.0
12781      * @memberOf _
12782      * @category Object
12783      * @param {Object} object The destination object.
12784      * @param {...Object} [sources] The source objects.
12785      * @returns {Object} Returns `object`.
12786      * @see _.defaultsDeep
12787      * @example
12788      *
12789      * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12790      * // => { 'a': 1, 'b': 2 }
12791      */
12792     var defaults = baseRest(function(object, sources) {
12793       object = Object(object);
12794
12795       var index = -1;
12796       var length = sources.length;
12797       var guard = length > 2 ? sources[2] : undefined;
12798
12799       if (guard && isIterateeCall(sources[0], sources[1], guard)) {
12800         length = 1;
12801       }
12802
12803       while (++index < length) {
12804         var source = sources[index];
12805         var props = keysIn(source);
12806         var propsIndex = -1;
12807         var propsLength = props.length;
12808
12809         while (++propsIndex < propsLength) {
12810           var key = props[propsIndex];
12811           var value = object[key];
12812
12813           if (value === undefined ||
12814               (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
12815             object[key] = source[key];
12816           }
12817         }
12818       }
12819
12820       return object;
12821     });
12822
12823     /**
12824      * This method is like `_.defaults` except that it recursively assigns
12825      * default properties.
12826      *
12827      * **Note:** This method mutates `object`.
12828      *
12829      * @static
12830      * @memberOf _
12831      * @since 3.10.0
12832      * @category Object
12833      * @param {Object} object The destination object.
12834      * @param {...Object} [sources] The source objects.
12835      * @returns {Object} Returns `object`.
12836      * @see _.defaults
12837      * @example
12838      *
12839      * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
12840      * // => { 'a': { 'b': 2, 'c': 3 } }
12841      */
12842     var defaultsDeep = baseRest(function(args) {
12843       args.push(undefined, customDefaultsMerge);
12844       return apply(mergeWith, undefined, args);
12845     });
12846
12847     /**
12848      * This method is like `_.find` except that it returns the key of the first
12849      * element `predicate` returns truthy for instead of the element itself.
12850      *
12851      * @static
12852      * @memberOf _
12853      * @since 1.1.0
12854      * @category Object
12855      * @param {Object} object The object to inspect.
12856      * @param {Function} [predicate=_.identity] The function invoked per iteration.
12857      * @returns {string|undefined} Returns the key of the matched element,
12858      *  else `undefined`.
12859      * @example
12860      *
12861      * var users = {
12862      *   'barney':  { 'age': 36, 'active': true },
12863      *   'fred':    { 'age': 40, 'active': false },
12864      *   'pebbles': { 'age': 1,  'active': true }
12865      * };
12866      *
12867      * _.findKey(users, function(o) { return o.age < 40; });
12868      * // => 'barney' (iteration order is not guaranteed)
12869      *
12870      * // The `_.matches` iteratee shorthand.
12871      * _.findKey(users, { 'age': 1, 'active': true });
12872      * // => 'pebbles'
12873      *
12874      * // The `_.matchesProperty` iteratee shorthand.
12875      * _.findKey(users, ['active', false]);
12876      * // => 'fred'
12877      *
12878      * // The `_.property` iteratee shorthand.
12879      * _.findKey(users, 'active');
12880      * // => 'barney'
12881      */
12882     function findKey(object, predicate) {
12883       return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
12884     }
12885
12886     /**
12887      * This method is like `_.findKey` except that it iterates over elements of
12888      * a collection in the opposite order.
12889      *
12890      * @static
12891      * @memberOf _
12892      * @since 2.0.0
12893      * @category Object
12894      * @param {Object} object The object to inspect.
12895      * @param {Function} [predicate=_.identity] The function invoked per iteration.
12896      * @returns {string|undefined} Returns the key of the matched element,
12897      *  else `undefined`.
12898      * @example
12899      *
12900      * var users = {
12901      *   'barney':  { 'age': 36, 'active': true },
12902      *   'fred':    { 'age': 40, 'active': false },
12903      *   'pebbles': { 'age': 1,  'active': true }
12904      * };
12905      *
12906      * _.findLastKey(users, function(o) { return o.age < 40; });
12907      * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
12908      *
12909      * // The `_.matches` iteratee shorthand.
12910      * _.findLastKey(users, { 'age': 36, 'active': true });
12911      * // => 'barney'
12912      *
12913      * // The `_.matchesProperty` iteratee shorthand.
12914      * _.findLastKey(users, ['active', false]);
12915      * // => 'fred'
12916      *
12917      * // The `_.property` iteratee shorthand.
12918      * _.findLastKey(users, 'active');
12919      * // => 'pebbles'
12920      */
12921     function findLastKey(object, predicate) {
12922       return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
12923     }
12924
12925     /**
12926      * Iterates over own and inherited enumerable string keyed properties of an
12927      * object and invokes `iteratee` for each property. The iteratee is invoked
12928      * with three arguments: (value, key, object). Iteratee functions may exit
12929      * iteration early by explicitly returning `false`.
12930      *
12931      * @static
12932      * @memberOf _
12933      * @since 0.3.0
12934      * @category Object
12935      * @param {Object} object The object to iterate over.
12936      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12937      * @returns {Object} Returns `object`.
12938      * @see _.forInRight
12939      * @example
12940      *
12941      * function Foo() {
12942      *   this.a = 1;
12943      *   this.b = 2;
12944      * }
12945      *
12946      * Foo.prototype.c = 3;
12947      *
12948      * _.forIn(new Foo, function(value, key) {
12949      *   console.log(key);
12950      * });
12951      * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
12952      */
12953     function forIn(object, iteratee) {
12954       return object == null
12955         ? object
12956         : baseFor(object, getIteratee(iteratee, 3), keysIn);
12957     }
12958
12959     /**
12960      * This method is like `_.forIn` except that it iterates over properties of
12961      * `object` in the opposite order.
12962      *
12963      * @static
12964      * @memberOf _
12965      * @since 2.0.0
12966      * @category Object
12967      * @param {Object} object The object to iterate over.
12968      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12969      * @returns {Object} Returns `object`.
12970      * @see _.forIn
12971      * @example
12972      *
12973      * function Foo() {
12974      *   this.a = 1;
12975      *   this.b = 2;
12976      * }
12977      *
12978      * Foo.prototype.c = 3;
12979      *
12980      * _.forInRight(new Foo, function(value, key) {
12981      *   console.log(key);
12982      * });
12983      * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
12984      */
12985     function forInRight(object, iteratee) {
12986       return object == null
12987         ? object
12988         : baseForRight(object, getIteratee(iteratee, 3), keysIn);
12989     }
12990
12991     /**
12992      * Iterates over own enumerable string keyed properties of an object and
12993      * invokes `iteratee` for each property. The iteratee is invoked with three
12994      * arguments: (value, key, object). Iteratee functions may exit iteration
12995      * early by explicitly returning `false`.
12996      *
12997      * @static
12998      * @memberOf _
12999      * @since 0.3.0
13000      * @category Object
13001      * @param {Object} object The object to iterate over.
13002      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13003      * @returns {Object} Returns `object`.
13004      * @see _.forOwnRight
13005      * @example
13006      *
13007      * function Foo() {
13008      *   this.a = 1;
13009      *   this.b = 2;
13010      * }
13011      *
13012      * Foo.prototype.c = 3;
13013      *
13014      * _.forOwn(new Foo, function(value, key) {
13015      *   console.log(key);
13016      * });
13017      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
13018      */
13019     function forOwn(object, iteratee) {
13020       return object && baseForOwn(object, getIteratee(iteratee, 3));
13021     }
13022
13023     /**
13024      * This method is like `_.forOwn` except that it iterates over properties of
13025      * `object` in the opposite order.
13026      *
13027      * @static
13028      * @memberOf _
13029      * @since 2.0.0
13030      * @category Object
13031      * @param {Object} object The object to iterate over.
13032      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13033      * @returns {Object} Returns `object`.
13034      * @see _.forOwn
13035      * @example
13036      *
13037      * function Foo() {
13038      *   this.a = 1;
13039      *   this.b = 2;
13040      * }
13041      *
13042      * Foo.prototype.c = 3;
13043      *
13044      * _.forOwnRight(new Foo, function(value, key) {
13045      *   console.log(key);
13046      * });
13047      * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
13048      */
13049     function forOwnRight(object, iteratee) {
13050       return object && baseForOwnRight(object, getIteratee(iteratee, 3));
13051     }
13052
13053     /**
13054      * Creates an array of function property names from own enumerable properties
13055      * of `object`.
13056      *
13057      * @static
13058      * @since 0.1.0
13059      * @memberOf _
13060      * @category Object
13061      * @param {Object} object The object to inspect.
13062      * @returns {Array} Returns the function names.
13063      * @see _.functionsIn
13064      * @example
13065      *
13066      * function Foo() {
13067      *   this.a = _.constant('a');
13068      *   this.b = _.constant('b');
13069      * }
13070      *
13071      * Foo.prototype.c = _.constant('c');
13072      *
13073      * _.functions(new Foo);
13074      * // => ['a', 'b']
13075      */
13076     function functions(object) {
13077       return object == null ? [] : baseFunctions(object, keys(object));
13078     }
13079
13080     /**
13081      * Creates an array of function property names from own and inherited
13082      * enumerable properties of `object`.
13083      *
13084      * @static
13085      * @memberOf _
13086      * @since 4.0.0
13087      * @category Object
13088      * @param {Object} object The object to inspect.
13089      * @returns {Array} Returns the function names.
13090      * @see _.functions
13091      * @example
13092      *
13093      * function Foo() {
13094      *   this.a = _.constant('a');
13095      *   this.b = _.constant('b');
13096      * }
13097      *
13098      * Foo.prototype.c = _.constant('c');
13099      *
13100      * _.functionsIn(new Foo);
13101      * // => ['a', 'b', 'c']
13102      */
13103     function functionsIn(object) {
13104       return object == null ? [] : baseFunctions(object, keysIn(object));
13105     }
13106
13107     /**
13108      * Gets the value at `path` of `object`. If the resolved value is
13109      * `undefined`, the `defaultValue` is returned in its place.
13110      *
13111      * @static
13112      * @memberOf _
13113      * @since 3.7.0
13114      * @category Object
13115      * @param {Object} object The object to query.
13116      * @param {Array|string} path The path of the property to get.
13117      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13118      * @returns {*} Returns the resolved value.
13119      * @example
13120      *
13121      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13122      *
13123      * _.get(object, 'a[0].b.c');
13124      * // => 3
13125      *
13126      * _.get(object, ['a', '0', 'b', 'c']);
13127      * // => 3
13128      *
13129      * _.get(object, 'a.b.c', 'default');
13130      * // => 'default'
13131      */
13132     function get(object, path, defaultValue) {
13133       var result = object == null ? undefined : baseGet(object, path);
13134       return result === undefined ? defaultValue : result;
13135     }
13136
13137     /**
13138      * Checks if `path` is a direct property of `object`.
13139      *
13140      * @static
13141      * @since 0.1.0
13142      * @memberOf _
13143      * @category Object
13144      * @param {Object} object The object to query.
13145      * @param {Array|string} path The path to check.
13146      * @returns {boolean} Returns `true` if `path` exists, else `false`.
13147      * @example
13148      *
13149      * var object = { 'a': { 'b': 2 } };
13150      * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13151      *
13152      * _.has(object, 'a');
13153      * // => true
13154      *
13155      * _.has(object, 'a.b');
13156      * // => true
13157      *
13158      * _.has(object, ['a', 'b']);
13159      * // => true
13160      *
13161      * _.has(other, 'a');
13162      * // => false
13163      */
13164     function has(object, path) {
13165       return object != null && hasPath(object, path, baseHas);
13166     }
13167
13168     /**
13169      * Checks if `path` is a direct or inherited property of `object`.
13170      *
13171      * @static
13172      * @memberOf _
13173      * @since 4.0.0
13174      * @category Object
13175      * @param {Object} object The object to query.
13176      * @param {Array|string} path The path to check.
13177      * @returns {boolean} Returns `true` if `path` exists, else `false`.
13178      * @example
13179      *
13180      * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13181      *
13182      * _.hasIn(object, 'a');
13183      * // => true
13184      *
13185      * _.hasIn(object, 'a.b');
13186      * // => true
13187      *
13188      * _.hasIn(object, ['a', 'b']);
13189      * // => true
13190      *
13191      * _.hasIn(object, 'b');
13192      * // => false
13193      */
13194     function hasIn(object, path) {
13195       return object != null && hasPath(object, path, baseHasIn);
13196     }
13197
13198     /**
13199      * Creates an object composed of the inverted keys and values of `object`.
13200      * If `object` contains duplicate values, subsequent values overwrite
13201      * property assignments of previous values.
13202      *
13203      * @static
13204      * @memberOf _
13205      * @since 0.7.0
13206      * @category Object
13207      * @param {Object} object The object to invert.
13208      * @returns {Object} Returns the new inverted object.
13209      * @example
13210      *
13211      * var object = { 'a': 1, 'b': 2, 'c': 1 };
13212      *
13213      * _.invert(object);
13214      * // => { '1': 'c', '2': 'b' }
13215      */
13216     var invert = createInverter(function(result, value, key) {
13217       if (value != null &&
13218           typeof value.toString != 'function') {
13219         value = nativeObjectToString.call(value);
13220       }
13221
13222       result[value] = key;
13223     }, constant(identity));
13224
13225     /**
13226      * This method is like `_.invert` except that the inverted object is generated
13227      * from the results of running each element of `object` thru `iteratee`. The
13228      * corresponding inverted value of each inverted key is an array of keys
13229      * responsible for generating the inverted value. The iteratee is invoked
13230      * with one argument: (value).
13231      *
13232      * @static
13233      * @memberOf _
13234      * @since 4.1.0
13235      * @category Object
13236      * @param {Object} object The object to invert.
13237      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
13238      * @returns {Object} Returns the new inverted object.
13239      * @example
13240      *
13241      * var object = { 'a': 1, 'b': 2, 'c': 1 };
13242      *
13243      * _.invertBy(object);
13244      * // => { '1': ['a', 'c'], '2': ['b'] }
13245      *
13246      * _.invertBy(object, function(value) {
13247      *   return 'group' + value;
13248      * });
13249      * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13250      */
13251     var invertBy = createInverter(function(result, value, key) {
13252       if (value != null &&
13253           typeof value.toString != 'function') {
13254         value = nativeObjectToString.call(value);
13255       }
13256
13257       if (hasOwnProperty.call(result, value)) {
13258         result[value].push(key);
13259       } else {
13260         result[value] = [key];
13261       }
13262     }, getIteratee);
13263
13264     /**
13265      * Invokes the method at `path` of `object`.
13266      *
13267      * @static
13268      * @memberOf _
13269      * @since 4.0.0
13270      * @category Object
13271      * @param {Object} object The object to query.
13272      * @param {Array|string} path The path of the method to invoke.
13273      * @param {...*} [args] The arguments to invoke the method with.
13274      * @returns {*} Returns the result of the invoked method.
13275      * @example
13276      *
13277      * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13278      *
13279      * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13280      * // => [2, 3]
13281      */
13282     var invoke = baseRest(baseInvoke);
13283
13284     /**
13285      * Creates an array of the own enumerable property names of `object`.
13286      *
13287      * **Note:** Non-object values are coerced to objects. See the
13288      * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
13289      * for more details.
13290      *
13291      * @static
13292      * @since 0.1.0
13293      * @memberOf _
13294      * @category Object
13295      * @param {Object} object The object to query.
13296      * @returns {Array} Returns the array of property names.
13297      * @example
13298      *
13299      * function Foo() {
13300      *   this.a = 1;
13301      *   this.b = 2;
13302      * }
13303      *
13304      * Foo.prototype.c = 3;
13305      *
13306      * _.keys(new Foo);
13307      * // => ['a', 'b'] (iteration order is not guaranteed)
13308      *
13309      * _.keys('hi');
13310      * // => ['0', '1']
13311      */
13312     function keys(object) {
13313       return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13314     }
13315
13316     /**
13317      * Creates an array of the own and inherited enumerable property names of `object`.
13318      *
13319      * **Note:** Non-object values are coerced to objects.
13320      *
13321      * @static
13322      * @memberOf _
13323      * @since 3.0.0
13324      * @category Object
13325      * @param {Object} object The object to query.
13326      * @returns {Array} Returns the array of property names.
13327      * @example
13328      *
13329      * function Foo() {
13330      *   this.a = 1;
13331      *   this.b = 2;
13332      * }
13333      *
13334      * Foo.prototype.c = 3;
13335      *
13336      * _.keysIn(new Foo);
13337      * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13338      */
13339     function keysIn(object) {
13340       return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
13341     }
13342
13343     /**
13344      * The opposite of `_.mapValues`; this method creates an object with the
13345      * same values as `object` and keys generated by running each own enumerable
13346      * string keyed property of `object` thru `iteratee`. The iteratee is invoked
13347      * with three arguments: (value, key, object).
13348      *
13349      * @static
13350      * @memberOf _
13351      * @since 3.8.0
13352      * @category Object
13353      * @param {Object} object The object to iterate over.
13354      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13355      * @returns {Object} Returns the new mapped object.
13356      * @see _.mapValues
13357      * @example
13358      *
13359      * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13360      *   return key + value;
13361      * });
13362      * // => { 'a1': 1, 'b2': 2 }
13363      */
13364     function mapKeys(object, iteratee) {
13365       var result = {};
13366       iteratee = getIteratee(iteratee, 3);
13367
13368       baseForOwn(object, function(value, key, object) {
13369         baseAssignValue(result, iteratee(value, key, object), value);
13370       });
13371       return result;
13372     }
13373
13374     /**
13375      * Creates an object with the same keys as `object` and values generated
13376      * by running each own enumerable string keyed property of `object` thru
13377      * `iteratee`. The iteratee is invoked with three arguments:
13378      * (value, key, object).
13379      *
13380      * @static
13381      * @memberOf _
13382      * @since 2.4.0
13383      * @category Object
13384      * @param {Object} object The object to iterate over.
13385      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13386      * @returns {Object} Returns the new mapped object.
13387      * @see _.mapKeys
13388      * @example
13389      *
13390      * var users = {
13391      *   'fred':    { 'user': 'fred',    'age': 40 },
13392      *   'pebbles': { 'user': 'pebbles', 'age': 1 }
13393      * };
13394      *
13395      * _.mapValues(users, function(o) { return o.age; });
13396      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13397      *
13398      * // The `_.property` iteratee shorthand.
13399      * _.mapValues(users, 'age');
13400      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13401      */
13402     function mapValues(object, iteratee) {
13403       var result = {};
13404       iteratee = getIteratee(iteratee, 3);
13405
13406       baseForOwn(object, function(value, key, object) {
13407         baseAssignValue(result, key, iteratee(value, key, object));
13408       });
13409       return result;
13410     }
13411
13412     /**
13413      * This method is like `_.assign` except that it recursively merges own and
13414      * inherited enumerable string keyed properties of source objects into the
13415      * destination object. Source properties that resolve to `undefined` are
13416      * skipped if a destination value exists. Array and plain object properties
13417      * are merged recursively. Other objects and value types are overridden by
13418      * assignment. Source objects are applied from left to right. Subsequent
13419      * sources overwrite property assignments of previous sources.
13420      *
13421      * **Note:** This method mutates `object`.
13422      *
13423      * @static
13424      * @memberOf _
13425      * @since 0.5.0
13426      * @category Object
13427      * @param {Object} object The destination object.
13428      * @param {...Object} [sources] The source objects.
13429      * @returns {Object} Returns `object`.
13430      * @example
13431      *
13432      * var object = {
13433      *   'a': [{ 'b': 2 }, { 'd': 4 }]
13434      * };
13435      *
13436      * var other = {
13437      *   'a': [{ 'c': 3 }, { 'e': 5 }]
13438      * };
13439      *
13440      * _.merge(object, other);
13441      * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13442      */
13443     var merge = createAssigner(function(object, source, srcIndex) {
13444       baseMerge(object, source, srcIndex);
13445     });
13446
13447     /**
13448      * This method is like `_.merge` except that it accepts `customizer` which
13449      * is invoked to produce the merged values of the destination and source
13450      * properties. If `customizer` returns `undefined`, merging is handled by the
13451      * method instead. The `customizer` is invoked with six arguments:
13452      * (objValue, srcValue, key, object, source, stack).
13453      *
13454      * **Note:** This method mutates `object`.
13455      *
13456      * @static
13457      * @memberOf _
13458      * @since 4.0.0
13459      * @category Object
13460      * @param {Object} object The destination object.
13461      * @param {...Object} sources The source objects.
13462      * @param {Function} customizer The function to customize assigned values.
13463      * @returns {Object} Returns `object`.
13464      * @example
13465      *
13466      * function customizer(objValue, srcValue) {
13467      *   if (_.isArray(objValue)) {
13468      *     return objValue.concat(srcValue);
13469      *   }
13470      * }
13471      *
13472      * var object = { 'a': [1], 'b': [2] };
13473      * var other = { 'a': [3], 'b': [4] };
13474      *
13475      * _.mergeWith(object, other, customizer);
13476      * // => { 'a': [1, 3], 'b': [2, 4] }
13477      */
13478     var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13479       baseMerge(object, source, srcIndex, customizer);
13480     });
13481
13482     /**
13483      * The opposite of `_.pick`; this method creates an object composed of the
13484      * own and inherited enumerable property paths of `object` that are not omitted.
13485      *
13486      * **Note:** This method is considerably slower than `_.pick`.
13487      *
13488      * @static
13489      * @since 0.1.0
13490      * @memberOf _
13491      * @category Object
13492      * @param {Object} object The source object.
13493      * @param {...(string|string[])} [paths] The property paths to omit.
13494      * @returns {Object} Returns the new object.
13495      * @example
13496      *
13497      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13498      *
13499      * _.omit(object, ['a', 'c']);
13500      * // => { 'b': '2' }
13501      */
13502     var omit = flatRest(function(object, paths) {
13503       var result = {};
13504       if (object == null) {
13505         return result;
13506       }
13507       var isDeep = false;
13508       paths = arrayMap(paths, function(path) {
13509         path = castPath(path, object);
13510         isDeep || (isDeep = path.length > 1);
13511         return path;
13512       });
13513       copyObject(object, getAllKeysIn(object), result);
13514       if (isDeep) {
13515         result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
13516       }
13517       var length = paths.length;
13518       while (length--) {
13519         baseUnset(result, paths[length]);
13520       }
13521       return result;
13522     });
13523
13524     /**
13525      * The opposite of `_.pickBy`; this method creates an object composed of
13526      * the own and inherited enumerable string keyed properties of `object` that
13527      * `predicate` doesn't return truthy for. The predicate is invoked with two
13528      * arguments: (value, key).
13529      *
13530      * @static
13531      * @memberOf _
13532      * @since 4.0.0
13533      * @category Object
13534      * @param {Object} object The source object.
13535      * @param {Function} [predicate=_.identity] The function invoked per property.
13536      * @returns {Object} Returns the new object.
13537      * @example
13538      *
13539      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13540      *
13541      * _.omitBy(object, _.isNumber);
13542      * // => { 'b': '2' }
13543      */
13544     function omitBy(object, predicate) {
13545       return pickBy(object, negate(getIteratee(predicate)));
13546     }
13547
13548     /**
13549      * Creates an object composed of the picked `object` properties.
13550      *
13551      * @static
13552      * @since 0.1.0
13553      * @memberOf _
13554      * @category Object
13555      * @param {Object} object The source object.
13556      * @param {...(string|string[])} [paths] The property paths to pick.
13557      * @returns {Object} Returns the new object.
13558      * @example
13559      *
13560      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13561      *
13562      * _.pick(object, ['a', 'c']);
13563      * // => { 'a': 1, 'c': 3 }
13564      */
13565     var pick = flatRest(function(object, paths) {
13566       return object == null ? {} : basePick(object, paths);
13567     });
13568
13569     /**
13570      * Creates an object composed of the `object` properties `predicate` returns
13571      * truthy for. The predicate is invoked with two arguments: (value, key).
13572      *
13573      * @static
13574      * @memberOf _
13575      * @since 4.0.0
13576      * @category Object
13577      * @param {Object} object The source object.
13578      * @param {Function} [predicate=_.identity] The function invoked per property.
13579      * @returns {Object} Returns the new object.
13580      * @example
13581      *
13582      * var object = { 'a': 1, 'b': '2', 'c': 3 };
13583      *
13584      * _.pickBy(object, _.isNumber);
13585      * // => { 'a': 1, 'c': 3 }
13586      */
13587     function pickBy(object, predicate) {
13588       if (object == null) {
13589         return {};
13590       }
13591       var props = arrayMap(getAllKeysIn(object), function(prop) {
13592         return [prop];
13593       });
13594       predicate = getIteratee(predicate);
13595       return basePickBy(object, props, function(value, path) {
13596         return predicate(value, path[0]);
13597       });
13598     }
13599
13600     /**
13601      * This method is like `_.get` except that if the resolved value is a
13602      * function it's invoked with the `this` binding of its parent object and
13603      * its result is returned.
13604      *
13605      * @static
13606      * @since 0.1.0
13607      * @memberOf _
13608      * @category Object
13609      * @param {Object} object The object to query.
13610      * @param {Array|string} path The path of the property to resolve.
13611      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13612      * @returns {*} Returns the resolved value.
13613      * @example
13614      *
13615      * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13616      *
13617      * _.result(object, 'a[0].b.c1');
13618      * // => 3
13619      *
13620      * _.result(object, 'a[0].b.c2');
13621      * // => 4
13622      *
13623      * _.result(object, 'a[0].b.c3', 'default');
13624      * // => 'default'
13625      *
13626      * _.result(object, 'a[0].b.c3', _.constant('default'));
13627      * // => 'default'
13628      */
13629     function result(object, path, defaultValue) {
13630       path = castPath(path, object);
13631
13632       var index = -1,
13633           length = path.length;
13634
13635       // Ensure the loop is entered when path is empty.
13636       if (!length) {
13637         length = 1;
13638         object = undefined;
13639       }
13640       while (++index < length) {
13641         var value = object == null ? undefined : object[toKey(path[index])];
13642         if (value === undefined) {
13643           index = length;
13644           value = defaultValue;
13645         }
13646         object = isFunction(value) ? value.call(object) : value;
13647       }
13648       return object;
13649     }
13650
13651     /**
13652      * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
13653      * it's created. Arrays are created for missing index properties while objects
13654      * are created for all other missing properties. Use `_.setWith` to customize
13655      * `path` creation.
13656      *
13657      * **Note:** This method mutates `object`.
13658      *
13659      * @static
13660      * @memberOf _
13661      * @since 3.7.0
13662      * @category Object
13663      * @param {Object} object The object to modify.
13664      * @param {Array|string} path The path of the property to set.
13665      * @param {*} value The value to set.
13666      * @returns {Object} Returns `object`.
13667      * @example
13668      *
13669      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13670      *
13671      * _.set(object, 'a[0].b.c', 4);
13672      * console.log(object.a[0].b.c);
13673      * // => 4
13674      *
13675      * _.set(object, ['x', '0', 'y', 'z'], 5);
13676      * console.log(object.x[0].y.z);
13677      * // => 5
13678      */
13679     function set(object, path, value) {
13680       return object == null ? object : baseSet(object, path, value);
13681     }
13682
13683     /**
13684      * This method is like `_.set` except that it accepts `customizer` which is
13685      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13686      * path creation is handled by the method instead. The `customizer` is invoked
13687      * with three arguments: (nsValue, key, nsObject).
13688      *
13689      * **Note:** This method mutates `object`.
13690      *
13691      * @static
13692      * @memberOf _
13693      * @since 4.0.0
13694      * @category Object
13695      * @param {Object} object The object to modify.
13696      * @param {Array|string} path The path of the property to set.
13697      * @param {*} value The value to set.
13698      * @param {Function} [customizer] The function to customize assigned values.
13699      * @returns {Object} Returns `object`.
13700      * @example
13701      *
13702      * var object = {};
13703      *
13704      * _.setWith(object, '[0][1]', 'a', Object);
13705      * // => { '0': { '1': 'a' } }
13706      */
13707     function setWith(object, path, value, customizer) {
13708       customizer = typeof customizer == 'function' ? customizer : undefined;
13709       return object == null ? object : baseSet(object, path, value, customizer);
13710     }
13711
13712     /**
13713      * Creates an array of own enumerable string keyed-value pairs for `object`
13714      * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
13715      * entries are returned.
13716      *
13717      * @static
13718      * @memberOf _
13719      * @since 4.0.0
13720      * @alias entries
13721      * @category Object
13722      * @param {Object} object The object to query.
13723      * @returns {Array} Returns the key-value pairs.
13724      * @example
13725      *
13726      * function Foo() {
13727      *   this.a = 1;
13728      *   this.b = 2;
13729      * }
13730      *
13731      * Foo.prototype.c = 3;
13732      *
13733      * _.toPairs(new Foo);
13734      * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
13735      */
13736     var toPairs = createToPairs(keys);
13737
13738     /**
13739      * Creates an array of own and inherited enumerable string keyed-value pairs
13740      * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
13741      * or set, its entries are returned.
13742      *
13743      * @static
13744      * @memberOf _
13745      * @since 4.0.0
13746      * @alias entriesIn
13747      * @category Object
13748      * @param {Object} object The object to query.
13749      * @returns {Array} Returns the key-value pairs.
13750      * @example
13751      *
13752      * function Foo() {
13753      *   this.a = 1;
13754      *   this.b = 2;
13755      * }
13756      *
13757      * Foo.prototype.c = 3;
13758      *
13759      * _.toPairsIn(new Foo);
13760      * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
13761      */
13762     var toPairsIn = createToPairs(keysIn);
13763
13764     /**
13765      * An alternative to `_.reduce`; this method transforms `object` to a new
13766      * `accumulator` object which is the result of running each of its own
13767      * enumerable string keyed properties thru `iteratee`, with each invocation
13768      * potentially mutating the `accumulator` object. If `accumulator` is not
13769      * provided, a new object with the same `[[Prototype]]` will be used. The
13770      * iteratee is invoked with four arguments: (accumulator, value, key, object).
13771      * Iteratee functions may exit iteration early by explicitly returning `false`.
13772      *
13773      * @static
13774      * @memberOf _
13775      * @since 1.3.0
13776      * @category Object
13777      * @param {Object} object The object to iterate over.
13778      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13779      * @param {*} [accumulator] The custom accumulator value.
13780      * @returns {*} Returns the accumulated value.
13781      * @example
13782      *
13783      * _.transform([2, 3, 4], function(result, n) {
13784      *   result.push(n *= n);
13785      *   return n % 2 == 0;
13786      * }, []);
13787      * // => [4, 9]
13788      *
13789      * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
13790      *   (result[value] || (result[value] = [])).push(key);
13791      * }, {});
13792      * // => { '1': ['a', 'c'], '2': ['b'] }
13793      */
13794     function transform(object, iteratee, accumulator) {
13795       var isArr = isArray(object),
13796           isArrLike = isArr || isBuffer(object) || isTypedArray(object);
13797
13798       iteratee = getIteratee(iteratee, 4);
13799       if (accumulator == null) {
13800         var Ctor = object && object.constructor;
13801         if (isArrLike) {
13802           accumulator = isArr ? new Ctor : [];
13803         }
13804         else if (isObject(object)) {
13805           accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
13806         }
13807         else {
13808           accumulator = {};
13809         }
13810       }
13811       (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
13812         return iteratee(accumulator, value, index, object);
13813       });
13814       return accumulator;
13815     }
13816
13817     /**
13818      * Removes the property at `path` of `object`.
13819      *
13820      * **Note:** This method mutates `object`.
13821      *
13822      * @static
13823      * @memberOf _
13824      * @since 4.0.0
13825      * @category Object
13826      * @param {Object} object The object to modify.
13827      * @param {Array|string} path The path of the property to unset.
13828      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
13829      * @example
13830      *
13831      * var object = { 'a': [{ 'b': { 'c': 7 } }] };
13832      * _.unset(object, 'a[0].b.c');
13833      * // => true
13834      *
13835      * console.log(object);
13836      * // => { 'a': [{ 'b': {} }] };
13837      *
13838      * _.unset(object, ['a', '0', 'b', 'c']);
13839      * // => true
13840      *
13841      * console.log(object);
13842      * // => { 'a': [{ 'b': {} }] };
13843      */
13844     function unset(object, path) {
13845       return object == null ? true : baseUnset(object, path);
13846     }
13847
13848     /**
13849      * This method is like `_.set` except that accepts `updater` to produce the
13850      * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
13851      * is invoked with one argument: (value).
13852      *
13853      * **Note:** This method mutates `object`.
13854      *
13855      * @static
13856      * @memberOf _
13857      * @since 4.6.0
13858      * @category Object
13859      * @param {Object} object The object to modify.
13860      * @param {Array|string} path The path of the property to set.
13861      * @param {Function} updater The function to produce the updated value.
13862      * @returns {Object} Returns `object`.
13863      * @example
13864      *
13865      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13866      *
13867      * _.update(object, 'a[0].b.c', function(n) { return n * n; });
13868      * console.log(object.a[0].b.c);
13869      * // => 9
13870      *
13871      * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
13872      * console.log(object.x[0].y.z);
13873      * // => 0
13874      */
13875     function update(object, path, updater) {
13876       return object == null ? object : baseUpdate(object, path, castFunction(updater));
13877     }
13878
13879     /**
13880      * This method is like `_.update` except that it accepts `customizer` which is
13881      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
13882      * path creation is handled by the method instead. The `customizer` is invoked
13883      * with three arguments: (nsValue, key, nsObject).
13884      *
13885      * **Note:** This method mutates `object`.
13886      *
13887      * @static
13888      * @memberOf _
13889      * @since 4.6.0
13890      * @category Object
13891      * @param {Object} object The object to modify.
13892      * @param {Array|string} path The path of the property to set.
13893      * @param {Function} updater The function to produce the updated value.
13894      * @param {Function} [customizer] The function to customize assigned values.
13895      * @returns {Object} Returns `object`.
13896      * @example
13897      *
13898      * var object = {};
13899      *
13900      * _.updateWith(object, '[0][1]', _.constant('a'), Object);
13901      * // => { '0': { '1': 'a' } }
13902      */
13903     function updateWith(object, path, updater, customizer) {
13904       customizer = typeof customizer == 'function' ? customizer : undefined;
13905       return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
13906     }
13907
13908     /**
13909      * Creates an array of the own enumerable string keyed property values of `object`.
13910      *
13911      * **Note:** Non-object values are coerced to objects.
13912      *
13913      * @static
13914      * @since 0.1.0
13915      * @memberOf _
13916      * @category Object
13917      * @param {Object} object The object to query.
13918      * @returns {Array} Returns the array of property values.
13919      * @example
13920      *
13921      * function Foo() {
13922      *   this.a = 1;
13923      *   this.b = 2;
13924      * }
13925      *
13926      * Foo.prototype.c = 3;
13927      *
13928      * _.values(new Foo);
13929      * // => [1, 2] (iteration order is not guaranteed)
13930      *
13931      * _.values('hi');
13932      * // => ['h', 'i']
13933      */
13934     function values(object) {
13935       return object == null ? [] : baseValues(object, keys(object));
13936     }
13937
13938     /**
13939      * Creates an array of the own and inherited enumerable string keyed property
13940      * values of `object`.
13941      *
13942      * **Note:** Non-object values are coerced to objects.
13943      *
13944      * @static
13945      * @memberOf _
13946      * @since 3.0.0
13947      * @category Object
13948      * @param {Object} object The object to query.
13949      * @returns {Array} Returns the array of property values.
13950      * @example
13951      *
13952      * function Foo() {
13953      *   this.a = 1;
13954      *   this.b = 2;
13955      * }
13956      *
13957      * Foo.prototype.c = 3;
13958      *
13959      * _.valuesIn(new Foo);
13960      * // => [1, 2, 3] (iteration order is not guaranteed)
13961      */
13962     function valuesIn(object) {
13963       return object == null ? [] : baseValues(object, keysIn(object));
13964     }
13965
13966     /*------------------------------------------------------------------------*/
13967
13968     /**
13969      * Clamps `number` within the inclusive `lower` and `upper` bounds.
13970      *
13971      * @static
13972      * @memberOf _
13973      * @since 4.0.0
13974      * @category Number
13975      * @param {number} number The number to clamp.
13976      * @param {number} [lower] The lower bound.
13977      * @param {number} upper The upper bound.
13978      * @returns {number} Returns the clamped number.
13979      * @example
13980      *
13981      * _.clamp(-10, -5, 5);
13982      * // => -5
13983      *
13984      * _.clamp(10, -5, 5);
13985      * // => 5
13986      */
13987     function clamp(number, lower, upper) {
13988       if (upper === undefined) {
13989         upper = lower;
13990         lower = undefined;
13991       }
13992       if (upper !== undefined) {
13993         upper = toNumber(upper);
13994         upper = upper === upper ? upper : 0;
13995       }
13996       if (lower !== undefined) {
13997         lower = toNumber(lower);
13998         lower = lower === lower ? lower : 0;
13999       }
14000       return baseClamp(toNumber(number), lower, upper);
14001     }
14002
14003     /**
14004      * Checks if `n` is between `start` and up to, but not including, `end`. If
14005      * `end` is not specified, it's set to `start` with `start` then set to `0`.
14006      * If `start` is greater than `end` the params are swapped to support
14007      * negative ranges.
14008      *
14009      * @static
14010      * @memberOf _
14011      * @since 3.3.0
14012      * @category Number
14013      * @param {number} number The number to check.
14014      * @param {number} [start=0] The start of the range.
14015      * @param {number} end The end of the range.
14016      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
14017      * @see _.range, _.rangeRight
14018      * @example
14019      *
14020      * _.inRange(3, 2, 4);
14021      * // => true
14022      *
14023      * _.inRange(4, 8);
14024      * // => true
14025      *
14026      * _.inRange(4, 2);
14027      * // => false
14028      *
14029      * _.inRange(2, 2);
14030      * // => false
14031      *
14032      * _.inRange(1.2, 2);
14033      * // => true
14034      *
14035      * _.inRange(5.2, 4);
14036      * // => false
14037      *
14038      * _.inRange(-3, -2, -6);
14039      * // => true
14040      */
14041     function inRange(number, start, end) {
14042       start = toFinite(start);
14043       if (end === undefined) {
14044         end = start;
14045         start = 0;
14046       } else {
14047         end = toFinite(end);
14048       }
14049       number = toNumber(number);
14050       return baseInRange(number, start, end);
14051     }
14052
14053     /**
14054      * Produces a random number between the inclusive `lower` and `upper` bounds.
14055      * If only one argument is provided a number between `0` and the given number
14056      * is returned. If `floating` is `true`, or either `lower` or `upper` are
14057      * floats, a floating-point number is returned instead of an integer.
14058      *
14059      * **Note:** JavaScript follows the IEEE-754 standard for resolving
14060      * floating-point values which can produce unexpected results.
14061      *
14062      * @static
14063      * @memberOf _
14064      * @since 0.7.0
14065      * @category Number
14066      * @param {number} [lower=0] The lower bound.
14067      * @param {number} [upper=1] The upper bound.
14068      * @param {boolean} [floating] Specify returning a floating-point number.
14069      * @returns {number} Returns the random number.
14070      * @example
14071      *
14072      * _.random(0, 5);
14073      * // => an integer between 0 and 5
14074      *
14075      * _.random(5);
14076      * // => also an integer between 0 and 5
14077      *
14078      * _.random(5, true);
14079      * // => a floating-point number between 0 and 5
14080      *
14081      * _.random(1.2, 5.2);
14082      * // => a floating-point number between 1.2 and 5.2
14083      */
14084     function random(lower, upper, floating) {
14085       if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
14086         upper = floating = undefined;
14087       }
14088       if (floating === undefined) {
14089         if (typeof upper == 'boolean') {
14090           floating = upper;
14091           upper = undefined;
14092         }
14093         else if (typeof lower == 'boolean') {
14094           floating = lower;
14095           lower = undefined;
14096         }
14097       }
14098       if (lower === undefined && upper === undefined) {
14099         lower = 0;
14100         upper = 1;
14101       }
14102       else {
14103         lower = toFinite(lower);
14104         if (upper === undefined) {
14105           upper = lower;
14106           lower = 0;
14107         } else {
14108           upper = toFinite(upper);
14109         }
14110       }
14111       if (lower > upper) {
14112         var temp = lower;
14113         lower = upper;
14114         upper = temp;
14115       }
14116       if (floating || lower % 1 || upper % 1) {
14117         var rand = nativeRandom();
14118         return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14119       }
14120       return baseRandom(lower, upper);
14121     }
14122
14123     /*------------------------------------------------------------------------*/
14124
14125     /**
14126      * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14127      *
14128      * @static
14129      * @memberOf _
14130      * @since 3.0.0
14131      * @category String
14132      * @param {string} [string=''] The string to convert.
14133      * @returns {string} Returns the camel cased string.
14134      * @example
14135      *
14136      * _.camelCase('Foo Bar');
14137      * // => 'fooBar'
14138      *
14139      * _.camelCase('--foo-bar--');
14140      * // => 'fooBar'
14141      *
14142      * _.camelCase('__FOO_BAR__');
14143      * // => 'fooBar'
14144      */
14145     var camelCase = createCompounder(function(result, word, index) {
14146       word = word.toLowerCase();
14147       return result + (index ? capitalize(word) : word);
14148     });
14149
14150     /**
14151      * Converts the first character of `string` to upper case and the remaining
14152      * to lower case.
14153      *
14154      * @static
14155      * @memberOf _
14156      * @since 3.0.0
14157      * @category String
14158      * @param {string} [string=''] The string to capitalize.
14159      * @returns {string} Returns the capitalized string.
14160      * @example
14161      *
14162      * _.capitalize('FRED');
14163      * // => 'Fred'
14164      */
14165     function capitalize(string) {
14166       return upperFirst(toString(string).toLowerCase());
14167     }
14168
14169     /**
14170      * Deburrs `string` by converting
14171      * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
14172      * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
14173      * letters to basic Latin letters and removing
14174      * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
14175      *
14176      * @static
14177      * @memberOf _
14178      * @since 3.0.0
14179      * @category String
14180      * @param {string} [string=''] The string to deburr.
14181      * @returns {string} Returns the deburred string.
14182      * @example
14183      *
14184      * _.deburr('déjà vu');
14185      * // => 'deja vu'
14186      */
14187     function deburr(string) {
14188       string = toString(string);
14189       return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14190     }
14191
14192     /**
14193      * Checks if `string` ends with the given target string.
14194      *
14195      * @static
14196      * @memberOf _
14197      * @since 3.0.0
14198      * @category String
14199      * @param {string} [string=''] The string to inspect.
14200      * @param {string} [target] The string to search for.
14201      * @param {number} [position=string.length] The position to search up to.
14202      * @returns {boolean} Returns `true` if `string` ends with `target`,
14203      *  else `false`.
14204      * @example
14205      *
14206      * _.endsWith('abc', 'c');
14207      * // => true
14208      *
14209      * _.endsWith('abc', 'b');
14210      * // => false
14211      *
14212      * _.endsWith('abc', 'b', 2);
14213      * // => true
14214      */
14215     function endsWith(string, target, position) {
14216       string = toString(string);
14217       target = baseToString(target);
14218
14219       var length = string.length;
14220       position = position === undefined
14221         ? length
14222         : baseClamp(toInteger(position), 0, length);
14223
14224       var end = position;
14225       position -= target.length;
14226       return position >= 0 && string.slice(position, end) == target;
14227     }
14228
14229     /**
14230      * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14231      * corresponding HTML entities.
14232      *
14233      * **Note:** No other characters are escaped. To escape additional
14234      * characters use a third-party library like [_he_](https://mths.be/he).
14235      *
14236      * Though the ">" character is escaped for symmetry, characters like
14237      * ">" and "/" don't need escaping in HTML and have no special meaning
14238      * unless they're part of a tag or unquoted attribute value. See
14239      * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
14240      * (under "semi-related fun fact") for more details.
14241      *
14242      * When working with HTML you should always
14243      * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14244      * XSS vectors.
14245      *
14246      * @static
14247      * @since 0.1.0
14248      * @memberOf _
14249      * @category String
14250      * @param {string} [string=''] The string to escape.
14251      * @returns {string} Returns the escaped string.
14252      * @example
14253      *
14254      * _.escape('fred, barney, & pebbles');
14255      * // => 'fred, barney, &amp; pebbles'
14256      */
14257     function escape(string) {
14258       string = toString(string);
14259       return (string && reHasUnescapedHtml.test(string))
14260         ? string.replace(reUnescapedHtml, escapeHtmlChar)
14261         : string;
14262     }
14263
14264     /**
14265      * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14266      * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14267      *
14268      * @static
14269      * @memberOf _
14270      * @since 3.0.0
14271      * @category String
14272      * @param {string} [string=''] The string to escape.
14273      * @returns {string} Returns the escaped string.
14274      * @example
14275      *
14276      * _.escapeRegExp('[lodash](https://lodash.com/)');
14277      * // => '\[lodash\]\(https://lodash\.com/\)'
14278      */
14279     function escapeRegExp(string) {
14280       string = toString(string);
14281       return (string && reHasRegExpChar.test(string))
14282         ? string.replace(reRegExpChar, '\\$&')
14283         : string;
14284     }
14285
14286     /**
14287      * Converts `string` to
14288      * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14289      *
14290      * @static
14291      * @memberOf _
14292      * @since 3.0.0
14293      * @category String
14294      * @param {string} [string=''] The string to convert.
14295      * @returns {string} Returns the kebab cased string.
14296      * @example
14297      *
14298      * _.kebabCase('Foo Bar');
14299      * // => 'foo-bar'
14300      *
14301      * _.kebabCase('fooBar');
14302      * // => 'foo-bar'
14303      *
14304      * _.kebabCase('__FOO_BAR__');
14305      * // => 'foo-bar'
14306      */
14307     var kebabCase = createCompounder(function(result, word, index) {
14308       return result + (index ? '-' : '') + word.toLowerCase();
14309     });
14310
14311     /**
14312      * Converts `string`, as space separated words, to lower case.
14313      *
14314      * @static
14315      * @memberOf _
14316      * @since 4.0.0
14317      * @category String
14318      * @param {string} [string=''] The string to convert.
14319      * @returns {string} Returns the lower cased string.
14320      * @example
14321      *
14322      * _.lowerCase('--Foo-Bar--');
14323      * // => 'foo bar'
14324      *
14325      * _.lowerCase('fooBar');
14326      * // => 'foo bar'
14327      *
14328      * _.lowerCase('__FOO_BAR__');
14329      * // => 'foo bar'
14330      */
14331     var lowerCase = createCompounder(function(result, word, index) {
14332       return result + (index ? ' ' : '') + word.toLowerCase();
14333     });
14334
14335     /**
14336      * Converts the first character of `string` to lower case.
14337      *
14338      * @static
14339      * @memberOf _
14340      * @since 4.0.0
14341      * @category String
14342      * @param {string} [string=''] The string to convert.
14343      * @returns {string} Returns the converted string.
14344      * @example
14345      *
14346      * _.lowerFirst('Fred');
14347      * // => 'fred'
14348      *
14349      * _.lowerFirst('FRED');
14350      * // => 'fRED'
14351      */
14352     var lowerFirst = createCaseFirst('toLowerCase');
14353
14354     /**
14355      * Pads `string` on the left and right sides if it's shorter than `length`.
14356      * Padding characters are truncated if they can't be evenly divided by `length`.
14357      *
14358      * @static
14359      * @memberOf _
14360      * @since 3.0.0
14361      * @category String
14362      * @param {string} [string=''] The string to pad.
14363      * @param {number} [length=0] The padding length.
14364      * @param {string} [chars=' '] The string used as padding.
14365      * @returns {string} Returns the padded string.
14366      * @example
14367      *
14368      * _.pad('abc', 8);
14369      * // => '  abc   '
14370      *
14371      * _.pad('abc', 8, '_-');
14372      * // => '_-abc_-_'
14373      *
14374      * _.pad('abc', 3);
14375      * // => 'abc'
14376      */
14377     function pad(string, length, chars) {
14378       string = toString(string);
14379       length = toInteger(length);
14380
14381       var strLength = length ? stringSize(string) : 0;
14382       if (!length || strLength >= length) {
14383         return string;
14384       }
14385       var mid = (length - strLength) / 2;
14386       return (
14387         createPadding(nativeFloor(mid), chars) +
14388         string +
14389         createPadding(nativeCeil(mid), chars)
14390       );
14391     }
14392
14393     /**
14394      * Pads `string` on the right side if it's shorter than `length`. Padding
14395      * characters are truncated if they exceed `length`.
14396      *
14397      * @static
14398      * @memberOf _
14399      * @since 4.0.0
14400      * @category String
14401      * @param {string} [string=''] The string to pad.
14402      * @param {number} [length=0] The padding length.
14403      * @param {string} [chars=' '] The string used as padding.
14404      * @returns {string} Returns the padded string.
14405      * @example
14406      *
14407      * _.padEnd('abc', 6);
14408      * // => 'abc   '
14409      *
14410      * _.padEnd('abc', 6, '_-');
14411      * // => 'abc_-_'
14412      *
14413      * _.padEnd('abc', 3);
14414      * // => 'abc'
14415      */
14416     function padEnd(string, length, chars) {
14417       string = toString(string);
14418       length = toInteger(length);
14419
14420       var strLength = length ? stringSize(string) : 0;
14421       return (length && strLength < length)
14422         ? (string + createPadding(length - strLength, chars))
14423         : string;
14424     }
14425
14426     /**
14427      * Pads `string` on the left side if it's shorter than `length`. Padding
14428      * characters are truncated if they exceed `length`.
14429      *
14430      * @static
14431      * @memberOf _
14432      * @since 4.0.0
14433      * @category String
14434      * @param {string} [string=''] The string to pad.
14435      * @param {number} [length=0] The padding length.
14436      * @param {string} [chars=' '] The string used as padding.
14437      * @returns {string} Returns the padded string.
14438      * @example
14439      *
14440      * _.padStart('abc', 6);
14441      * // => '   abc'
14442      *
14443      * _.padStart('abc', 6, '_-');
14444      * // => '_-_abc'
14445      *
14446      * _.padStart('abc', 3);
14447      * // => 'abc'
14448      */
14449     function padStart(string, length, chars) {
14450       string = toString(string);
14451       length = toInteger(length);
14452
14453       var strLength = length ? stringSize(string) : 0;
14454       return (length && strLength < length)
14455         ? (createPadding(length - strLength, chars) + string)
14456         : string;
14457     }
14458
14459     /**
14460      * Converts `string` to an integer of the specified radix. If `radix` is
14461      * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
14462      * hexadecimal, in which case a `radix` of `16` is used.
14463      *
14464      * **Note:** This method aligns with the
14465      * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
14466      *
14467      * @static
14468      * @memberOf _
14469      * @since 1.1.0
14470      * @category String
14471      * @param {string} string The string to convert.
14472      * @param {number} [radix=10] The radix to interpret `value` by.
14473      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14474      * @returns {number} Returns the converted integer.
14475      * @example
14476      *
14477      * _.parseInt('08');
14478      * // => 8
14479      *
14480      * _.map(['6', '08', '10'], _.parseInt);
14481      * // => [6, 8, 10]
14482      */
14483     function parseInt(string, radix, guard) {
14484       if (guard || radix == null) {
14485         radix = 0;
14486       } else if (radix) {
14487         radix = +radix;
14488       }
14489       return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14490     }
14491
14492     /**
14493      * Repeats the given string `n` times.
14494      *
14495      * @static
14496      * @memberOf _
14497      * @since 3.0.0
14498      * @category String
14499      * @param {string} [string=''] The string to repeat.
14500      * @param {number} [n=1] The number of times to repeat the string.
14501      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14502      * @returns {string} Returns the repeated string.
14503      * @example
14504      *
14505      * _.repeat('*', 3);
14506      * // => '***'
14507      *
14508      * _.repeat('abc', 2);
14509      * // => 'abcabc'
14510      *
14511      * _.repeat('abc', 0);
14512      * // => ''
14513      */
14514     function repeat(string, n, guard) {
14515       if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
14516         n = 1;
14517       } else {
14518         n = toInteger(n);
14519       }
14520       return baseRepeat(toString(string), n);
14521     }
14522
14523     /**
14524      * Replaces matches for `pattern` in `string` with `replacement`.
14525      *
14526      * **Note:** This method is based on
14527      * [`String#replace`](https://mdn.io/String/replace).
14528      *
14529      * @static
14530      * @memberOf _
14531      * @since 4.0.0
14532      * @category String
14533      * @param {string} [string=''] The string to modify.
14534      * @param {RegExp|string} pattern The pattern to replace.
14535      * @param {Function|string} replacement The match replacement.
14536      * @returns {string} Returns the modified string.
14537      * @example
14538      *
14539      * _.replace('Hi Fred', 'Fred', 'Barney');
14540      * // => 'Hi Barney'
14541      */
14542     function replace() {
14543       var args = arguments,
14544           string = toString(args[0]);
14545
14546       return args.length < 3 ? string : string.replace(args[1], args[2]);
14547     }
14548
14549     /**
14550      * Converts `string` to
14551      * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14552      *
14553      * @static
14554      * @memberOf _
14555      * @since 3.0.0
14556      * @category String
14557      * @param {string} [string=''] The string to convert.
14558      * @returns {string} Returns the snake cased string.
14559      * @example
14560      *
14561      * _.snakeCase('Foo Bar');
14562      * // => 'foo_bar'
14563      *
14564      * _.snakeCase('fooBar');
14565      * // => 'foo_bar'
14566      *
14567      * _.snakeCase('--FOO-BAR--');
14568      * // => 'foo_bar'
14569      */
14570     var snakeCase = createCompounder(function(result, word, index) {
14571       return result + (index ? '_' : '') + word.toLowerCase();
14572     });
14573
14574     /**
14575      * Splits `string` by `separator`.
14576      *
14577      * **Note:** This method is based on
14578      * [`String#split`](https://mdn.io/String/split).
14579      *
14580      * @static
14581      * @memberOf _
14582      * @since 4.0.0
14583      * @category String
14584      * @param {string} [string=''] The string to split.
14585      * @param {RegExp|string} separator The separator pattern to split by.
14586      * @param {number} [limit] The length to truncate results to.
14587      * @returns {Array} Returns the string segments.
14588      * @example
14589      *
14590      * _.split('a-b-c', '-', 2);
14591      * // => ['a', 'b']
14592      */
14593     function split(string, separator, limit) {
14594       if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14595         separator = limit = undefined;
14596       }
14597       limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
14598       if (!limit) {
14599         return [];
14600       }
14601       string = toString(string);
14602       if (string && (
14603             typeof separator == 'string' ||
14604             (separator != null && !isRegExp(separator))
14605           )) {
14606         separator = baseToString(separator);
14607         if (!separator && hasUnicode(string)) {
14608           return castSlice(stringToArray(string), 0, limit);
14609         }
14610       }
14611       return string.split(separator, limit);
14612     }
14613
14614     /**
14615      * Converts `string` to
14616      * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14617      *
14618      * @static
14619      * @memberOf _
14620      * @since 3.1.0
14621      * @category String
14622      * @param {string} [string=''] The string to convert.
14623      * @returns {string} Returns the start cased string.
14624      * @example
14625      *
14626      * _.startCase('--foo-bar--');
14627      * // => 'Foo Bar'
14628      *
14629      * _.startCase('fooBar');
14630      * // => 'Foo Bar'
14631      *
14632      * _.startCase('__FOO_BAR__');
14633      * // => 'FOO BAR'
14634      */
14635     var startCase = createCompounder(function(result, word, index) {
14636       return result + (index ? ' ' : '') + upperFirst(word);
14637     });
14638
14639     /**
14640      * Checks if `string` starts with the given target string.
14641      *
14642      * @static
14643      * @memberOf _
14644      * @since 3.0.0
14645      * @category String
14646      * @param {string} [string=''] The string to inspect.
14647      * @param {string} [target] The string to search for.
14648      * @param {number} [position=0] The position to search from.
14649      * @returns {boolean} Returns `true` if `string` starts with `target`,
14650      *  else `false`.
14651      * @example
14652      *
14653      * _.startsWith('abc', 'a');
14654      * // => true
14655      *
14656      * _.startsWith('abc', 'b');
14657      * // => false
14658      *
14659      * _.startsWith('abc', 'b', 1);
14660      * // => true
14661      */
14662     function startsWith(string, target, position) {
14663       string = toString(string);
14664       position = position == null
14665         ? 0
14666         : baseClamp(toInteger(position), 0, string.length);
14667
14668       target = baseToString(target);
14669       return string.slice(position, position + target.length) == target;
14670     }
14671
14672     /**
14673      * Creates a compiled template function that can interpolate data properties
14674      * in "interpolate" delimiters, HTML-escape interpolated data properties in
14675      * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
14676      * properties may be accessed as free variables in the template. If a setting
14677      * object is given, it takes precedence over `_.templateSettings` values.
14678      *
14679      * **Note:** In the development build `_.template` utilizes
14680      * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
14681      * for easier debugging.
14682      *
14683      * For more information on precompiling templates see
14684      * [lodash's custom builds documentation](https://lodash.com/custom-builds).
14685      *
14686      * For more information on Chrome extension sandboxes see
14687      * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
14688      *
14689      * @static
14690      * @since 0.1.0
14691      * @memberOf _
14692      * @category String
14693      * @param {string} [string=''] The template string.
14694      * @param {Object} [options={}] The options object.
14695      * @param {RegExp} [options.escape=_.templateSettings.escape]
14696      *  The HTML "escape" delimiter.
14697      * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
14698      *  The "evaluate" delimiter.
14699      * @param {Object} [options.imports=_.templateSettings.imports]
14700      *  An object to import into the template as free variables.
14701      * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
14702      *  The "interpolate" delimiter.
14703      * @param {string} [options.sourceURL='lodash.templateSources[n]']
14704      *  The sourceURL of the compiled template.
14705      * @param {string} [options.variable='obj']
14706      *  The data object variable name.
14707      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14708      * @returns {Function} Returns the compiled template function.
14709      * @example
14710      *
14711      * // Use the "interpolate" delimiter to create a compiled template.
14712      * var compiled = _.template('hello <%= user %>!');
14713      * compiled({ 'user': 'fred' });
14714      * // => 'hello fred!'
14715      *
14716      * // Use the HTML "escape" delimiter to escape data property values.
14717      * var compiled = _.template('<b><%- value %></b>');
14718      * compiled({ 'value': '<script>' });
14719      * // => '<b>&lt;script&gt;</b>'
14720      *
14721      * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
14722      * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
14723      * compiled({ 'users': ['fred', 'barney'] });
14724      * // => '<li>fred</li><li>barney</li>'
14725      *
14726      * // Use the internal `print` function in "evaluate" delimiters.
14727      * var compiled = _.template('<% print("hello " + user); %>!');
14728      * compiled({ 'user': 'barney' });
14729      * // => 'hello barney!'
14730      *
14731      * // Use the ES template literal delimiter as an "interpolate" delimiter.
14732      * // Disable support by replacing the "interpolate" delimiter.
14733      * var compiled = _.template('hello ${ user }!');
14734      * compiled({ 'user': 'pebbles' });
14735      * // => 'hello pebbles!'
14736      *
14737      * // Use backslashes to treat delimiters as plain text.
14738      * var compiled = _.template('<%= "\\<%- value %\\>" %>');
14739      * compiled({ 'value': 'ignored' });
14740      * // => '<%- value %>'
14741      *
14742      * // Use the `imports` option to import `jQuery` as `jq`.
14743      * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
14744      * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
14745      * compiled({ 'users': ['fred', 'barney'] });
14746      * // => '<li>fred</li><li>barney</li>'
14747      *
14748      * // Use the `sourceURL` option to specify a custom sourceURL for the template.
14749      * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
14750      * compiled(data);
14751      * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
14752      *
14753      * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
14754      * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
14755      * compiled.source;
14756      * // => function(data) {
14757      * //   var __t, __p = '';
14758      * //   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
14759      * //   return __p;
14760      * // }
14761      *
14762      * // Use custom template delimiters.
14763      * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
14764      * var compiled = _.template('hello {{ user }}!');
14765      * compiled({ 'user': 'mustache' });
14766      * // => 'hello mustache!'
14767      *
14768      * // Use the `source` property to inline compiled templates for meaningful
14769      * // line numbers in error messages and stack traces.
14770      * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
14771      *   var JST = {\
14772      *     "main": ' + _.template(mainText).source + '\
14773      *   };\
14774      * ');
14775      */
14776     function template(string, options, guard) {
14777       // Based on John Resig's `tmpl` implementation
14778       // (http://ejohn.org/blog/javascript-micro-templating/)
14779       // and Laura Doktorova's doT.js (https://github.com/olado/doT).
14780       var settings = lodash.templateSettings;
14781
14782       if (guard && isIterateeCall(string, options, guard)) {
14783         options = undefined;
14784       }
14785       string = toString(string);
14786       options = assignInWith({}, options, settings, customDefaultsAssignIn);
14787
14788       var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
14789           importsKeys = keys(imports),
14790           importsValues = baseValues(imports, importsKeys);
14791
14792       var isEscaping,
14793           isEvaluating,
14794           index = 0,
14795           interpolate = options.interpolate || reNoMatch,
14796           source = "__p += '";
14797
14798       // Compile the regexp to match each delimiter.
14799       var reDelimiters = RegExp(
14800         (options.escape || reNoMatch).source + '|' +
14801         interpolate.source + '|' +
14802         (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
14803         (options.evaluate || reNoMatch).source + '|$'
14804       , 'g');
14805
14806       // Use a sourceURL for easier debugging.
14807       // The sourceURL gets injected into the source that's eval-ed, so be careful
14808       // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
14809       // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
14810       var sourceURL = '//# sourceURL=' +
14811         (hasOwnProperty.call(options, 'sourceURL')
14812           ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
14813           : ('lodash.templateSources[' + (++templateCounter) + ']')
14814         ) + '\n';
14815
14816       string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
14817         interpolateValue || (interpolateValue = esTemplateValue);
14818
14819         // Escape characters that can't be included in string literals.
14820         source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
14821
14822         // Replace delimiters with snippets.
14823         if (escapeValue) {
14824           isEscaping = true;
14825           source += "' +\n__e(" + escapeValue + ") +\n'";
14826         }
14827         if (evaluateValue) {
14828           isEvaluating = true;
14829           source += "';\n" + evaluateValue + ";\n__p += '";
14830         }
14831         if (interpolateValue) {
14832           source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
14833         }
14834         index = offset + match.length;
14835
14836         // The JS engine embedded in Adobe products needs `match` returned in
14837         // order to produce the correct `offset` value.
14838         return match;
14839       });
14840
14841       source += "';\n";
14842
14843       // If `variable` is not specified wrap a with-statement around the generated
14844       // code to add the data object to the top of the scope chain.
14845       // Like with sourceURL, we take care to not check the option's prototype,
14846       // as this configuration is a code injection vector.
14847       var variable = hasOwnProperty.call(options, 'variable') && options.variable;
14848       if (!variable) {
14849         source = 'with (obj) {\n' + source + '\n}\n';
14850       }
14851       // Cleanup code by stripping empty strings.
14852       source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
14853         .replace(reEmptyStringMiddle, '$1')
14854         .replace(reEmptyStringTrailing, '$1;');
14855
14856       // Frame code as the function body.
14857       source = 'function(' + (variable || 'obj') + ') {\n' +
14858         (variable
14859           ? ''
14860           : 'obj || (obj = {});\n'
14861         ) +
14862         "var __t, __p = ''" +
14863         (isEscaping
14864            ? ', __e = _.escape'
14865            : ''
14866         ) +
14867         (isEvaluating
14868           ? ', __j = Array.prototype.join;\n' +
14869             "function print() { __p += __j.call(arguments, '') }\n"
14870           : ';\n'
14871         ) +
14872         source +
14873         'return __p\n}';
14874
14875       var result = attempt(function() {
14876         return Function(importsKeys, sourceURL + 'return ' + source)
14877           .apply(undefined, importsValues);
14878       });
14879
14880       // Provide the compiled function's source by its `toString` method or
14881       // the `source` property as a convenience for inlining compiled templates.
14882       result.source = source;
14883       if (isError(result)) {
14884         throw result;
14885       }
14886       return result;
14887     }
14888
14889     /**
14890      * Converts `string`, as a whole, to lower case just like
14891      * [String#toLowerCase](https://mdn.io/toLowerCase).
14892      *
14893      * @static
14894      * @memberOf _
14895      * @since 4.0.0
14896      * @category String
14897      * @param {string} [string=''] The string to convert.
14898      * @returns {string} Returns the lower cased string.
14899      * @example
14900      *
14901      * _.toLower('--Foo-Bar--');
14902      * // => '--foo-bar--'
14903      *
14904      * _.toLower('fooBar');
14905      * // => 'foobar'
14906      *
14907      * _.toLower('__FOO_BAR__');
14908      * // => '__foo_bar__'
14909      */
14910     function toLower(value) {
14911       return toString(value).toLowerCase();
14912     }
14913
14914     /**
14915      * Converts `string`, as a whole, to upper case just like
14916      * [String#toUpperCase](https://mdn.io/toUpperCase).
14917      *
14918      * @static
14919      * @memberOf _
14920      * @since 4.0.0
14921      * @category String
14922      * @param {string} [string=''] The string to convert.
14923      * @returns {string} Returns the upper cased string.
14924      * @example
14925      *
14926      * _.toUpper('--foo-bar--');
14927      * // => '--FOO-BAR--'
14928      *
14929      * _.toUpper('fooBar');
14930      * // => 'FOOBAR'
14931      *
14932      * _.toUpper('__foo_bar__');
14933      * // => '__FOO_BAR__'
14934      */
14935     function toUpper(value) {
14936       return toString(value).toUpperCase();
14937     }
14938
14939     /**
14940      * Removes leading and trailing whitespace or specified characters from `string`.
14941      *
14942      * @static
14943      * @memberOf _
14944      * @since 3.0.0
14945      * @category String
14946      * @param {string} [string=''] The string to trim.
14947      * @param {string} [chars=whitespace] The characters to trim.
14948      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14949      * @returns {string} Returns the trimmed string.
14950      * @example
14951      *
14952      * _.trim('  abc  ');
14953      * // => 'abc'
14954      *
14955      * _.trim('-_-abc-_-', '_-');
14956      * // => 'abc'
14957      *
14958      * _.map(['  foo  ', '  bar  '], _.trim);
14959      * // => ['foo', 'bar']
14960      */
14961     function trim(string, chars, guard) {
14962       string = toString(string);
14963       if (string && (guard || chars === undefined)) {
14964         return string.replace(reTrim, '');
14965       }
14966       if (!string || !(chars = baseToString(chars))) {
14967         return string;
14968       }
14969       var strSymbols = stringToArray(string),
14970           chrSymbols = stringToArray(chars),
14971           start = charsStartIndex(strSymbols, chrSymbols),
14972           end = charsEndIndex(strSymbols, chrSymbols) + 1;
14973
14974       return castSlice(strSymbols, start, end).join('');
14975     }
14976
14977     /**
14978      * Removes trailing whitespace or specified characters from `string`.
14979      *
14980      * @static
14981      * @memberOf _
14982      * @since 4.0.0
14983      * @category String
14984      * @param {string} [string=''] The string to trim.
14985      * @param {string} [chars=whitespace] The characters to trim.
14986      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14987      * @returns {string} Returns the trimmed string.
14988      * @example
14989      *
14990      * _.trimEnd('  abc  ');
14991      * // => '  abc'
14992      *
14993      * _.trimEnd('-_-abc-_-', '_-');
14994      * // => '-_-abc'
14995      */
14996     function trimEnd(string, chars, guard) {
14997       string = toString(string);
14998       if (string && (guard || chars === undefined)) {
14999         return string.replace(reTrimEnd, '');
15000       }
15001       if (!string || !(chars = baseToString(chars))) {
15002         return string;
15003       }
15004       var strSymbols = stringToArray(string),
15005           end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
15006
15007       return castSlice(strSymbols, 0, end).join('');
15008     }
15009
15010     /**
15011      * Removes leading whitespace or specified characters from `string`.
15012      *
15013      * @static
15014      * @memberOf _
15015      * @since 4.0.0
15016      * @category String
15017      * @param {string} [string=''] The string to trim.
15018      * @param {string} [chars=whitespace] The characters to trim.
15019      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15020      * @returns {string} Returns the trimmed string.
15021      * @example
15022      *
15023      * _.trimStart('  abc  ');
15024      * // => 'abc  '
15025      *
15026      * _.trimStart('-_-abc-_-', '_-');
15027      * // => 'abc-_-'
15028      */
15029     function trimStart(string, chars, guard) {
15030       string = toString(string);
15031       if (string && (guard || chars === undefined)) {
15032         return string.replace(reTrimStart, '');
15033       }
15034       if (!string || !(chars = baseToString(chars))) {
15035         return string;
15036       }
15037       var strSymbols = stringToArray(string),
15038           start = charsStartIndex(strSymbols, stringToArray(chars));
15039
15040       return castSlice(strSymbols, start).join('');
15041     }
15042
15043     /**
15044      * Truncates `string` if it's longer than the given maximum string length.
15045      * The last characters of the truncated string are replaced with the omission
15046      * string which defaults to "...".
15047      *
15048      * @static
15049      * @memberOf _
15050      * @since 4.0.0
15051      * @category String
15052      * @param {string} [string=''] The string to truncate.
15053      * @param {Object} [options={}] The options object.
15054      * @param {number} [options.length=30] The maximum string length.
15055      * @param {string} [options.omission='...'] The string to indicate text is omitted.
15056      * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
15057      * @returns {string} Returns the truncated string.
15058      * @example
15059      *
15060      * _.truncate('hi-diddly-ho there, neighborino');
15061      * // => 'hi-diddly-ho there, neighbo...'
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      *   'length': 24,
15071      *   'separator': /,? +/
15072      * });
15073      * // => 'hi-diddly-ho there...'
15074      *
15075      * _.truncate('hi-diddly-ho there, neighborino', {
15076      *   'omission': ' [...]'
15077      * });
15078      * // => 'hi-diddly-ho there, neig [...]'
15079      */
15080     function truncate(string, options) {
15081       var length = DEFAULT_TRUNC_LENGTH,
15082           omission = DEFAULT_TRUNC_OMISSION;
15083
15084       if (isObject(options)) {
15085         var separator = 'separator' in options ? options.separator : separator;
15086         length = 'length' in options ? toInteger(options.length) : length;
15087         omission = 'omission' in options ? baseToString(options.omission) : omission;
15088       }
15089       string = toString(string);
15090
15091       var strLength = string.length;
15092       if (hasUnicode(string)) {
15093         var strSymbols = stringToArray(string);
15094         strLength = strSymbols.length;
15095       }
15096       if (length >= strLength) {
15097         return string;
15098       }
15099       var end = length - stringSize(omission);
15100       if (end < 1) {
15101         return omission;
15102       }
15103       var result = strSymbols
15104         ? castSlice(strSymbols, 0, end).join('')
15105         : string.slice(0, end);
15106
15107       if (separator === undefined) {
15108         return result + omission;
15109       }
15110       if (strSymbols) {
15111         end += (result.length - end);
15112       }
15113       if (isRegExp(separator)) {
15114         if (string.slice(end).search(separator)) {
15115           var match,
15116               substring = result;
15117
15118           if (!separator.global) {
15119             separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15120           }
15121           separator.lastIndex = 0;
15122           while ((match = separator.exec(substring))) {
15123             var newEnd = match.index;
15124           }
15125           result = result.slice(0, newEnd === undefined ? end : newEnd);
15126         }
15127       } else if (string.indexOf(baseToString(separator), end) != end) {
15128         var index = result.lastIndexOf(separator);
15129         if (index > -1) {
15130           result = result.slice(0, index);
15131         }
15132       }
15133       return result + omission;
15134     }
15135
15136     /**
15137      * The inverse of `_.escape`; this method converts the HTML entities
15138      * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
15139      * their corresponding characters.
15140      *
15141      * **Note:** No other HTML entities are unescaped. To unescape additional
15142      * HTML entities use a third-party library like [_he_](https://mths.be/he).
15143      *
15144      * @static
15145      * @memberOf _
15146      * @since 0.6.0
15147      * @category String
15148      * @param {string} [string=''] The string to unescape.
15149      * @returns {string} Returns the unescaped string.
15150      * @example
15151      *
15152      * _.unescape('fred, barney, &amp; pebbles');
15153      * // => 'fred, barney, & pebbles'
15154      */
15155     function unescape(string) {
15156       string = toString(string);
15157       return (string && reHasEscapedHtml.test(string))
15158         ? string.replace(reEscapedHtml, unescapeHtmlChar)
15159         : string;
15160     }
15161
15162     /**
15163      * Converts `string`, as space separated words, to upper case.
15164      *
15165      * @static
15166      * @memberOf _
15167      * @since 4.0.0
15168      * @category String
15169      * @param {string} [string=''] The string to convert.
15170      * @returns {string} Returns the upper cased string.
15171      * @example
15172      *
15173      * _.upperCase('--foo-bar');
15174      * // => 'FOO BAR'
15175      *
15176      * _.upperCase('fooBar');
15177      * // => 'FOO BAR'
15178      *
15179      * _.upperCase('__foo_bar__');
15180      * // => 'FOO BAR'
15181      */
15182     var upperCase = createCompounder(function(result, word, index) {
15183       return result + (index ? ' ' : '') + word.toUpperCase();
15184     });
15185
15186     /**
15187      * Converts the first character of `string` to upper case.
15188      *
15189      * @static
15190      * @memberOf _
15191      * @since 4.0.0
15192      * @category String
15193      * @param {string} [string=''] The string to convert.
15194      * @returns {string} Returns the converted string.
15195      * @example
15196      *
15197      * _.upperFirst('fred');
15198      * // => 'Fred'
15199      *
15200      * _.upperFirst('FRED');
15201      * // => 'FRED'
15202      */
15203     var upperFirst = createCaseFirst('toUpperCase');
15204
15205     /**
15206      * Splits `string` into an array of its words.
15207      *
15208      * @static
15209      * @memberOf _
15210      * @since 3.0.0
15211      * @category String
15212      * @param {string} [string=''] The string to inspect.
15213      * @param {RegExp|string} [pattern] The pattern to match words.
15214      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15215      * @returns {Array} Returns the words of `string`.
15216      * @example
15217      *
15218      * _.words('fred, barney, & pebbles');
15219      * // => ['fred', 'barney', 'pebbles']
15220      *
15221      * _.words('fred, barney, & pebbles', /[^, ]+/g);
15222      * // => ['fred', 'barney', '&', 'pebbles']
15223      */
15224     function words(string, pattern, guard) {
15225       string = toString(string);
15226       pattern = guard ? undefined : pattern;
15227
15228       if (pattern === undefined) {
15229         return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15230       }
15231       return string.match(pattern) || [];
15232     }
15233
15234     /*------------------------------------------------------------------------*/
15235
15236     /**
15237      * Attempts to invoke `func`, returning either the result or the caught error
15238      * object. Any additional arguments are provided to `func` when it's invoked.
15239      *
15240      * @static
15241      * @memberOf _
15242      * @since 3.0.0
15243      * @category Util
15244      * @param {Function} func The function to attempt.
15245      * @param {...*} [args] The arguments to invoke `func` with.
15246      * @returns {*} Returns the `func` result or error object.
15247      * @example
15248      *
15249      * // Avoid throwing errors for invalid selectors.
15250      * var elements = _.attempt(function(selector) {
15251      *   return document.querySelectorAll(selector);
15252      * }, '>_>');
15253      *
15254      * if (_.isError(elements)) {
15255      *   elements = [];
15256      * }
15257      */
15258     var attempt = baseRest(function(func, args) {
15259       try {
15260         return apply(func, undefined, args);
15261       } catch (e) {
15262         return isError(e) ? e : new Error(e);
15263       }
15264     });
15265
15266     /**
15267      * Binds methods of an object to the object itself, overwriting the existing
15268      * method.
15269      *
15270      * **Note:** This method doesn't set the "length" property of bound functions.
15271      *
15272      * @static
15273      * @since 0.1.0
15274      * @memberOf _
15275      * @category Util
15276      * @param {Object} object The object to bind and assign the bound methods to.
15277      * @param {...(string|string[])} methodNames The object method names to bind.
15278      * @returns {Object} Returns `object`.
15279      * @example
15280      *
15281      * var view = {
15282      *   'label': 'docs',
15283      *   'click': function() {
15284      *     console.log('clicked ' + this.label);
15285      *   }
15286      * };
15287      *
15288      * _.bindAll(view, ['click']);
15289      * jQuery(element).on('click', view.click);
15290      * // => Logs 'clicked docs' when clicked.
15291      */
15292     var bindAll = flatRest(function(object, methodNames) {
15293       arrayEach(methodNames, function(key) {
15294         key = toKey(key);
15295         baseAssignValue(object, key, bind(object[key], object));
15296       });
15297       return object;
15298     });
15299
15300     /**
15301      * Creates a function that iterates over `pairs` and invokes the corresponding
15302      * function of the first predicate to return truthy. The predicate-function
15303      * pairs are invoked with the `this` binding and arguments of the created
15304      * function.
15305      *
15306      * @static
15307      * @memberOf _
15308      * @since 4.0.0
15309      * @category Util
15310      * @param {Array} pairs The predicate-function pairs.
15311      * @returns {Function} Returns the new composite function.
15312      * @example
15313      *
15314      * var func = _.cond([
15315      *   [_.matches({ 'a': 1 }),           _.constant('matches A')],
15316      *   [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15317      *   [_.stubTrue,                      _.constant('no match')]
15318      * ]);
15319      *
15320      * func({ 'a': 1, 'b': 2 });
15321      * // => 'matches A'
15322      *
15323      * func({ 'a': 0, 'b': 1 });
15324      * // => 'matches B'
15325      *
15326      * func({ 'a': '1', 'b': '2' });
15327      * // => 'no match'
15328      */
15329     function cond(pairs) {
15330       var length = pairs == null ? 0 : pairs.length,
15331           toIteratee = getIteratee();
15332
15333       pairs = !length ? [] : arrayMap(pairs, function(pair) {
15334         if (typeof pair[1] != 'function') {
15335           throw new TypeError(FUNC_ERROR_TEXT);
15336         }
15337         return [toIteratee(pair[0]), pair[1]];
15338       });
15339
15340       return baseRest(function(args) {
15341         var index = -1;
15342         while (++index < length) {
15343           var pair = pairs[index];
15344           if (apply(pair[0], this, args)) {
15345             return apply(pair[1], this, args);
15346           }
15347         }
15348       });
15349     }
15350
15351     /**
15352      * Creates a function that invokes the predicate properties of `source` with
15353      * the corresponding property values of a given object, returning `true` if
15354      * all predicates return truthy, else `false`.
15355      *
15356      * **Note:** The created function is equivalent to `_.conformsTo` with
15357      * `source` partially applied.
15358      *
15359      * @static
15360      * @memberOf _
15361      * @since 4.0.0
15362      * @category Util
15363      * @param {Object} source The object of property predicates to conform to.
15364      * @returns {Function} Returns the new spec function.
15365      * @example
15366      *
15367      * var objects = [
15368      *   { 'a': 2, 'b': 1 },
15369      *   { 'a': 1, 'b': 2 }
15370      * ];
15371      *
15372      * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15373      * // => [{ 'a': 1, 'b': 2 }]
15374      */
15375     function conforms(source) {
15376       return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
15377     }
15378
15379     /**
15380      * Creates a function that returns `value`.
15381      *
15382      * @static
15383      * @memberOf _
15384      * @since 2.4.0
15385      * @category Util
15386      * @param {*} value The value to return from the new function.
15387      * @returns {Function} Returns the new constant function.
15388      * @example
15389      *
15390      * var objects = _.times(2, _.constant({ 'a': 1 }));
15391      *
15392      * console.log(objects);
15393      * // => [{ 'a': 1 }, { 'a': 1 }]
15394      *
15395      * console.log(objects[0] === objects[1]);
15396      * // => true
15397      */
15398     function constant(value) {
15399       return function() {
15400         return value;
15401       };
15402     }
15403
15404     /**
15405      * Checks `value` to determine whether a default value should be returned in
15406      * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
15407      * or `undefined`.
15408      *
15409      * @static
15410      * @memberOf _
15411      * @since 4.14.0
15412      * @category Util
15413      * @param {*} value The value to check.
15414      * @param {*} defaultValue The default value.
15415      * @returns {*} Returns the resolved value.
15416      * @example
15417      *
15418      * _.defaultTo(1, 10);
15419      * // => 1
15420      *
15421      * _.defaultTo(undefined, 10);
15422      * // => 10
15423      */
15424     function defaultTo(value, defaultValue) {
15425       return (value == null || value !== value) ? defaultValue : value;
15426     }
15427
15428     /**
15429      * Creates a function that returns the result of invoking the given functions
15430      * with the `this` binding of the created function, where each successive
15431      * invocation is supplied the return value of the previous.
15432      *
15433      * @static
15434      * @memberOf _
15435      * @since 3.0.0
15436      * @category Util
15437      * @param {...(Function|Function[])} [funcs] The functions to invoke.
15438      * @returns {Function} Returns the new composite function.
15439      * @see _.flowRight
15440      * @example
15441      *
15442      * function square(n) {
15443      *   return n * n;
15444      * }
15445      *
15446      * var addSquare = _.flow([_.add, square]);
15447      * addSquare(1, 2);
15448      * // => 9
15449      */
15450     var flow = createFlow();
15451
15452     /**
15453      * This method is like `_.flow` except that it creates a function that
15454      * invokes the given functions from right to left.
15455      *
15456      * @static
15457      * @since 3.0.0
15458      * @memberOf _
15459      * @category Util
15460      * @param {...(Function|Function[])} [funcs] The functions to invoke.
15461      * @returns {Function} Returns the new composite function.
15462      * @see _.flow
15463      * @example
15464      *
15465      * function square(n) {
15466      *   return n * n;
15467      * }
15468      *
15469      * var addSquare = _.flowRight([square, _.add]);
15470      * addSquare(1, 2);
15471      * // => 9
15472      */
15473     var flowRight = createFlow(true);
15474
15475     /**
15476      * This method returns the first argument it receives.
15477      *
15478      * @static
15479      * @since 0.1.0
15480      * @memberOf _
15481      * @category Util
15482      * @param {*} value Any value.
15483      * @returns {*} Returns `value`.
15484      * @example
15485      *
15486      * var object = { 'a': 1 };
15487      *
15488      * console.log(_.identity(object) === object);
15489      * // => true
15490      */
15491     function identity(value) {
15492       return value;
15493     }
15494
15495     /**
15496      * Creates a function that invokes `func` with the arguments of the created
15497      * function. If `func` is a property name, the created function returns the
15498      * property value for a given element. If `func` is an array or object, the
15499      * created function returns `true` for elements that contain the equivalent
15500      * source properties, otherwise it returns `false`.
15501      *
15502      * @static
15503      * @since 4.0.0
15504      * @memberOf _
15505      * @category Util
15506      * @param {*} [func=_.identity] The value to convert to a callback.
15507      * @returns {Function} Returns the callback.
15508      * @example
15509      *
15510      * var users = [
15511      *   { 'user': 'barney', 'age': 36, 'active': true },
15512      *   { 'user': 'fred',   'age': 40, 'active': false }
15513      * ];
15514      *
15515      * // The `_.matches` iteratee shorthand.
15516      * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15517      * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15518      *
15519      * // The `_.matchesProperty` iteratee shorthand.
15520      * _.filter(users, _.iteratee(['user', 'fred']));
15521      * // => [{ 'user': 'fred', 'age': 40 }]
15522      *
15523      * // The `_.property` iteratee shorthand.
15524      * _.map(users, _.iteratee('user'));
15525      * // => ['barney', 'fred']
15526      *
15527      * // Create custom iteratee shorthands.
15528      * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
15529      *   return !_.isRegExp(func) ? iteratee(func) : function(string) {
15530      *     return func.test(string);
15531      *   };
15532      * });
15533      *
15534      * _.filter(['abc', 'def'], /ef/);
15535      * // => ['def']
15536      */
15537     function iteratee(func) {
15538       return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
15539     }
15540
15541     /**
15542      * Creates a function that performs a partial deep comparison between a given
15543      * object and `source`, returning `true` if the given object has equivalent
15544      * property values, else `false`.
15545      *
15546      * **Note:** The created function is equivalent to `_.isMatch` with `source`
15547      * partially applied.
15548      *
15549      * Partial comparisons will match empty array and empty object `source`
15550      * values against any array or object value, respectively. See `_.isEqual`
15551      * for a list of supported value comparisons.
15552      *
15553      * @static
15554      * @memberOf _
15555      * @since 3.0.0
15556      * @category Util
15557      * @param {Object} source The object of property values to match.
15558      * @returns {Function} Returns the new spec function.
15559      * @example
15560      *
15561      * var objects = [
15562      *   { 'a': 1, 'b': 2, 'c': 3 },
15563      *   { 'a': 4, 'b': 5, 'c': 6 }
15564      * ];
15565      *
15566      * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15567      * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15568      */
15569     function matches(source) {
15570       return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
15571     }
15572
15573     /**
15574      * Creates a function that performs a partial deep comparison between the
15575      * value at `path` of a given object to `srcValue`, returning `true` if the
15576      * object value is equivalent, else `false`.
15577      *
15578      * **Note:** Partial comparisons will match empty array and empty object
15579      * `srcValue` values against any array or object value, respectively. See
15580      * `_.isEqual` for a list of supported value comparisons.
15581      *
15582      * @static
15583      * @memberOf _
15584      * @since 3.2.0
15585      * @category Util
15586      * @param {Array|string} path The path of the property to get.
15587      * @param {*} srcValue The value to match.
15588      * @returns {Function} Returns the new spec function.
15589      * @example
15590      *
15591      * var objects = [
15592      *   { 'a': 1, 'b': 2, 'c': 3 },
15593      *   { 'a': 4, 'b': 5, 'c': 6 }
15594      * ];
15595      *
15596      * _.find(objects, _.matchesProperty('a', 4));
15597      * // => { 'a': 4, 'b': 5, 'c': 6 }
15598      */
15599     function matchesProperty(path, srcValue) {
15600       return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
15601     }
15602
15603     /**
15604      * Creates a function that invokes the method at `path` of a given object.
15605      * Any additional arguments are provided to the invoked method.
15606      *
15607      * @static
15608      * @memberOf _
15609      * @since 3.7.0
15610      * @category Util
15611      * @param {Array|string} path The path of the method to invoke.
15612      * @param {...*} [args] The arguments to invoke the method with.
15613      * @returns {Function} Returns the new invoker function.
15614      * @example
15615      *
15616      * var objects = [
15617      *   { 'a': { 'b': _.constant(2) } },
15618      *   { 'a': { 'b': _.constant(1) } }
15619      * ];
15620      *
15621      * _.map(objects, _.method('a.b'));
15622      * // => [2, 1]
15623      *
15624      * _.map(objects, _.method(['a', 'b']));
15625      * // => [2, 1]
15626      */
15627     var method = baseRest(function(path, args) {
15628       return function(object) {
15629         return baseInvoke(object, path, args);
15630       };
15631     });
15632
15633     /**
15634      * The opposite of `_.method`; this method creates a function that invokes
15635      * the method at a given path of `object`. Any additional arguments are
15636      * provided to the invoked method.
15637      *
15638      * @static
15639      * @memberOf _
15640      * @since 3.7.0
15641      * @category Util
15642      * @param {Object} object The object to query.
15643      * @param {...*} [args] The arguments to invoke the method with.
15644      * @returns {Function} Returns the new invoker function.
15645      * @example
15646      *
15647      * var array = _.times(3, _.constant),
15648      *     object = { 'a': array, 'b': array, 'c': array };
15649      *
15650      * _.map(['a[2]', 'c[0]'], _.methodOf(object));
15651      * // => [2, 0]
15652      *
15653      * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
15654      * // => [2, 0]
15655      */
15656     var methodOf = baseRest(function(object, args) {
15657       return function(path) {
15658         return baseInvoke(object, path, args);
15659       };
15660     });
15661
15662     /**
15663      * Adds all own enumerable string keyed function properties of a source
15664      * object to the destination object. If `object` is a function, then methods
15665      * are added to its prototype as well.
15666      *
15667      * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
15668      * avoid conflicts caused by modifying the original.
15669      *
15670      * @static
15671      * @since 0.1.0
15672      * @memberOf _
15673      * @category Util
15674      * @param {Function|Object} [object=lodash] The destination object.
15675      * @param {Object} source The object of functions to add.
15676      * @param {Object} [options={}] The options object.
15677      * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
15678      * @returns {Function|Object} Returns `object`.
15679      * @example
15680      *
15681      * function vowels(string) {
15682      *   return _.filter(string, function(v) {
15683      *     return /[aeiou]/i.test(v);
15684      *   });
15685      * }
15686      *
15687      * _.mixin({ 'vowels': vowels });
15688      * _.vowels('fred');
15689      * // => ['e']
15690      *
15691      * _('fred').vowels().value();
15692      * // => ['e']
15693      *
15694      * _.mixin({ 'vowels': vowels }, { 'chain': false });
15695      * _('fred').vowels();
15696      * // => ['e']
15697      */
15698     function mixin(object, source, options) {
15699       var props = keys(source),
15700           methodNames = baseFunctions(source, props);
15701
15702       if (options == null &&
15703           !(isObject(source) && (methodNames.length || !props.length))) {
15704         options = source;
15705         source = object;
15706         object = this;
15707         methodNames = baseFunctions(source, keys(source));
15708       }
15709       var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
15710           isFunc = isFunction(object);
15711
15712       arrayEach(methodNames, function(methodName) {
15713         var func = source[methodName];
15714         object[methodName] = func;
15715         if (isFunc) {
15716           object.prototype[methodName] = function() {
15717             var chainAll = this.__chain__;
15718             if (chain || chainAll) {
15719               var result = object(this.__wrapped__),
15720                   actions = result.__actions__ = copyArray(this.__actions__);
15721
15722               actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
15723               result.__chain__ = chainAll;
15724               return result;
15725             }
15726             return func.apply(object, arrayPush([this.value()], arguments));
15727           };
15728         }
15729       });
15730
15731       return object;
15732     }
15733
15734     /**
15735      * Reverts the `_` variable to its previous value and returns a reference to
15736      * the `lodash` function.
15737      *
15738      * @static
15739      * @since 0.1.0
15740      * @memberOf _
15741      * @category Util
15742      * @returns {Function} Returns the `lodash` function.
15743      * @example
15744      *
15745      * var lodash = _.noConflict();
15746      */
15747     function noConflict() {
15748       if (root._ === this) {
15749         root._ = oldDash;
15750       }
15751       return this;
15752     }
15753
15754     /**
15755      * This method returns `undefined`.
15756      *
15757      * @static
15758      * @memberOf _
15759      * @since 2.3.0
15760      * @category Util
15761      * @example
15762      *
15763      * _.times(2, _.noop);
15764      * // => [undefined, undefined]
15765      */
15766     function noop() {
15767       // No operation performed.
15768     }
15769
15770     /**
15771      * Creates a function that gets the argument at index `n`. If `n` is negative,
15772      * the nth argument from the end is returned.
15773      *
15774      * @static
15775      * @memberOf _
15776      * @since 4.0.0
15777      * @category Util
15778      * @param {number} [n=0] The index of the argument to return.
15779      * @returns {Function} Returns the new pass-thru function.
15780      * @example
15781      *
15782      * var func = _.nthArg(1);
15783      * func('a', 'b', 'c', 'd');
15784      * // => 'b'
15785      *
15786      * var func = _.nthArg(-2);
15787      * func('a', 'b', 'c', 'd');
15788      * // => 'c'
15789      */
15790     function nthArg(n) {
15791       n = toInteger(n);
15792       return baseRest(function(args) {
15793         return baseNth(args, n);
15794       });
15795     }
15796
15797     /**
15798      * Creates a function that invokes `iteratees` with the arguments it receives
15799      * and returns their results.
15800      *
15801      * @static
15802      * @memberOf _
15803      * @since 4.0.0
15804      * @category Util
15805      * @param {...(Function|Function[])} [iteratees=[_.identity]]
15806      *  The iteratees to invoke.
15807      * @returns {Function} Returns the new function.
15808      * @example
15809      *
15810      * var func = _.over([Math.max, Math.min]);
15811      *
15812      * func(1, 2, 3, 4);
15813      * // => [4, 1]
15814      */
15815     var over = createOver(arrayMap);
15816
15817     /**
15818      * Creates a function that checks if **all** of the `predicates` return
15819      * truthy when invoked with the arguments it receives.
15820      *
15821      * @static
15822      * @memberOf _
15823      * @since 4.0.0
15824      * @category Util
15825      * @param {...(Function|Function[])} [predicates=[_.identity]]
15826      *  The predicates to check.
15827      * @returns {Function} Returns the new function.
15828      * @example
15829      *
15830      * var func = _.overEvery([Boolean, isFinite]);
15831      *
15832      * func('1');
15833      * // => true
15834      *
15835      * func(null);
15836      * // => false
15837      *
15838      * func(NaN);
15839      * // => false
15840      */
15841     var overEvery = createOver(arrayEvery);
15842
15843     /**
15844      * Creates a function that checks if **any** of the `predicates` return
15845      * truthy when invoked with the arguments it receives.
15846      *
15847      * @static
15848      * @memberOf _
15849      * @since 4.0.0
15850      * @category Util
15851      * @param {...(Function|Function[])} [predicates=[_.identity]]
15852      *  The predicates to check.
15853      * @returns {Function} Returns the new function.
15854      * @example
15855      *
15856      * var func = _.overSome([Boolean, isFinite]);
15857      *
15858      * func('1');
15859      * // => true
15860      *
15861      * func(null);
15862      * // => true
15863      *
15864      * func(NaN);
15865      * // => false
15866      */
15867     var overSome = createOver(arraySome);
15868
15869     /**
15870      * Creates a function that returns the value at `path` of a given object.
15871      *
15872      * @static
15873      * @memberOf _
15874      * @since 2.4.0
15875      * @category Util
15876      * @param {Array|string} path The path of the property to get.
15877      * @returns {Function} Returns the new accessor function.
15878      * @example
15879      *
15880      * var objects = [
15881      *   { 'a': { 'b': 2 } },
15882      *   { 'a': { 'b': 1 } }
15883      * ];
15884      *
15885      * _.map(objects, _.property('a.b'));
15886      * // => [2, 1]
15887      *
15888      * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
15889      * // => [1, 2]
15890      */
15891     function property(path) {
15892       return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
15893     }
15894
15895     /**
15896      * The opposite of `_.property`; this method creates a function that returns
15897      * the value at a given path of `object`.
15898      *
15899      * @static
15900      * @memberOf _
15901      * @since 3.0.0
15902      * @category Util
15903      * @param {Object} object The object to query.
15904      * @returns {Function} Returns the new accessor function.
15905      * @example
15906      *
15907      * var array = [0, 1, 2],
15908      *     object = { 'a': array, 'b': array, 'c': array };
15909      *
15910      * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
15911      * // => [2, 0]
15912      *
15913      * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
15914      * // => [2, 0]
15915      */
15916     function propertyOf(object) {
15917       return function(path) {
15918         return object == null ? undefined : baseGet(object, path);
15919       };
15920     }
15921
15922     /**
15923      * Creates an array of numbers (positive and/or negative) progressing from
15924      * `start` up to, but not including, `end`. A step of `-1` is used if a negative
15925      * `start` is specified without an `end` or `step`. If `end` is not specified,
15926      * it's set to `start` with `start` then set to `0`.
15927      *
15928      * **Note:** JavaScript follows the IEEE-754 standard for resolving
15929      * floating-point values which can produce unexpected results.
15930      *
15931      * @static
15932      * @since 0.1.0
15933      * @memberOf _
15934      * @category Util
15935      * @param {number} [start=0] The start of the range.
15936      * @param {number} end The end of the range.
15937      * @param {number} [step=1] The value to increment or decrement by.
15938      * @returns {Array} Returns the range of numbers.
15939      * @see _.inRange, _.rangeRight
15940      * @example
15941      *
15942      * _.range(4);
15943      * // => [0, 1, 2, 3]
15944      *
15945      * _.range(-4);
15946      * // => [0, -1, -2, -3]
15947      *
15948      * _.range(1, 5);
15949      * // => [1, 2, 3, 4]
15950      *
15951      * _.range(0, 20, 5);
15952      * // => [0, 5, 10, 15]
15953      *
15954      * _.range(0, -4, -1);
15955      * // => [0, -1, -2, -3]
15956      *
15957      * _.range(1, 4, 0);
15958      * // => [1, 1, 1]
15959      *
15960      * _.range(0);
15961      * // => []
15962      */
15963     var range = createRange();
15964
15965     /**
15966      * This method is like `_.range` except that it populates values in
15967      * descending order.
15968      *
15969      * @static
15970      * @memberOf _
15971      * @since 4.0.0
15972      * @category Util
15973      * @param {number} [start=0] The start of the range.
15974      * @param {number} end The end of the range.
15975      * @param {number} [step=1] The value to increment or decrement by.
15976      * @returns {Array} Returns the range of numbers.
15977      * @see _.inRange, _.range
15978      * @example
15979      *
15980      * _.rangeRight(4);
15981      * // => [3, 2, 1, 0]
15982      *
15983      * _.rangeRight(-4);
15984      * // => [-3, -2, -1, 0]
15985      *
15986      * _.rangeRight(1, 5);
15987      * // => [4, 3, 2, 1]
15988      *
15989      * _.rangeRight(0, 20, 5);
15990      * // => [15, 10, 5, 0]
15991      *
15992      * _.rangeRight(0, -4, -1);
15993      * // => [-3, -2, -1, 0]
15994      *
15995      * _.rangeRight(1, 4, 0);
15996      * // => [1, 1, 1]
15997      *
15998      * _.rangeRight(0);
15999      * // => []
16000      */
16001     var rangeRight = createRange(true);
16002
16003     /**
16004      * This method returns a new empty array.
16005      *
16006      * @static
16007      * @memberOf _
16008      * @since 4.13.0
16009      * @category Util
16010      * @returns {Array} Returns the new empty array.
16011      * @example
16012      *
16013      * var arrays = _.times(2, _.stubArray);
16014      *
16015      * console.log(arrays);
16016      * // => [[], []]
16017      *
16018      * console.log(arrays[0] === arrays[1]);
16019      * // => false
16020      */
16021     function stubArray() {
16022       return [];
16023     }
16024
16025     /**
16026      * This method returns `false`.
16027      *
16028      * @static
16029      * @memberOf _
16030      * @since 4.13.0
16031      * @category Util
16032      * @returns {boolean} Returns `false`.
16033      * @example
16034      *
16035      * _.times(2, _.stubFalse);
16036      * // => [false, false]
16037      */
16038     function stubFalse() {
16039       return false;
16040     }
16041
16042     /**
16043      * This method returns a new empty object.
16044      *
16045      * @static
16046      * @memberOf _
16047      * @since 4.13.0
16048      * @category Util
16049      * @returns {Object} Returns the new empty object.
16050      * @example
16051      *
16052      * var objects = _.times(2, _.stubObject);
16053      *
16054      * console.log(objects);
16055      * // => [{}, {}]
16056      *
16057      * console.log(objects[0] === objects[1]);
16058      * // => false
16059      */
16060     function stubObject() {
16061       return {};
16062     }
16063
16064     /**
16065      * This method returns an empty string.
16066      *
16067      * @static
16068      * @memberOf _
16069      * @since 4.13.0
16070      * @category Util
16071      * @returns {string} Returns the empty string.
16072      * @example
16073      *
16074      * _.times(2, _.stubString);
16075      * // => ['', '']
16076      */
16077     function stubString() {
16078       return '';
16079     }
16080
16081     /**
16082      * This method returns `true`.
16083      *
16084      * @static
16085      * @memberOf _
16086      * @since 4.13.0
16087      * @category Util
16088      * @returns {boolean} Returns `true`.
16089      * @example
16090      *
16091      * _.times(2, _.stubTrue);
16092      * // => [true, true]
16093      */
16094     function stubTrue() {
16095       return true;
16096     }
16097
16098     /**
16099      * Invokes the iteratee `n` times, returning an array of the results of
16100      * each invocation. The iteratee is invoked with one argument; (index).
16101      *
16102      * @static
16103      * @since 0.1.0
16104      * @memberOf _
16105      * @category Util
16106      * @param {number} n The number of times to invoke `iteratee`.
16107      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16108      * @returns {Array} Returns the array of results.
16109      * @example
16110      *
16111      * _.times(3, String);
16112      * // => ['0', '1', '2']
16113      *
16114      *  _.times(4, _.constant(0));
16115      * // => [0, 0, 0, 0]
16116      */
16117     function times(n, iteratee) {
16118       n = toInteger(n);
16119       if (n < 1 || n > MAX_SAFE_INTEGER) {
16120         return [];
16121       }
16122       var index = MAX_ARRAY_LENGTH,
16123           length = nativeMin(n, MAX_ARRAY_LENGTH);
16124
16125       iteratee = getIteratee(iteratee);
16126       n -= MAX_ARRAY_LENGTH;
16127
16128       var result = baseTimes(length, iteratee);
16129       while (++index < n) {
16130         iteratee(index);
16131       }
16132       return result;
16133     }
16134
16135     /**
16136      * Converts `value` to a property path array.
16137      *
16138      * @static
16139      * @memberOf _
16140      * @since 4.0.0
16141      * @category Util
16142      * @param {*} value The value to convert.
16143      * @returns {Array} Returns the new property path array.
16144      * @example
16145      *
16146      * _.toPath('a.b.c');
16147      * // => ['a', 'b', 'c']
16148      *
16149      * _.toPath('a[0].b.c');
16150      * // => ['a', '0', 'b', 'c']
16151      */
16152     function toPath(value) {
16153       if (isArray(value)) {
16154         return arrayMap(value, toKey);
16155       }
16156       return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
16157     }
16158
16159     /**
16160      * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16161      *
16162      * @static
16163      * @since 0.1.0
16164      * @memberOf _
16165      * @category Util
16166      * @param {string} [prefix=''] The value to prefix the ID with.
16167      * @returns {string} Returns the unique ID.
16168      * @example
16169      *
16170      * _.uniqueId('contact_');
16171      * // => 'contact_104'
16172      *
16173      * _.uniqueId();
16174      * // => '105'
16175      */
16176     function uniqueId(prefix) {
16177       var id = ++idCounter;
16178       return toString(prefix) + id;
16179     }
16180
16181     /*------------------------------------------------------------------------*/
16182
16183     /**
16184      * Adds two numbers.
16185      *
16186      * @static
16187      * @memberOf _
16188      * @since 3.4.0
16189      * @category Math
16190      * @param {number} augend The first number in an addition.
16191      * @param {number} addend The second number in an addition.
16192      * @returns {number} Returns the total.
16193      * @example
16194      *
16195      * _.add(6, 4);
16196      * // => 10
16197      */
16198     var add = createMathOperation(function(augend, addend) {
16199       return augend + addend;
16200     }, 0);
16201
16202     /**
16203      * Computes `number` rounded up to `precision`.
16204      *
16205      * @static
16206      * @memberOf _
16207      * @since 3.10.0
16208      * @category Math
16209      * @param {number} number The number to round up.
16210      * @param {number} [precision=0] The precision to round up to.
16211      * @returns {number} Returns the rounded up number.
16212      * @example
16213      *
16214      * _.ceil(4.006);
16215      * // => 5
16216      *
16217      * _.ceil(6.004, 2);
16218      * // => 6.01
16219      *
16220      * _.ceil(6040, -2);
16221      * // => 6100
16222      */
16223     var ceil = createRound('ceil');
16224
16225     /**
16226      * Divide two numbers.
16227      *
16228      * @static
16229      * @memberOf _
16230      * @since 4.7.0
16231      * @category Math
16232      * @param {number} dividend The first number in a division.
16233      * @param {number} divisor The second number in a division.
16234      * @returns {number} Returns the quotient.
16235      * @example
16236      *
16237      * _.divide(6, 4);
16238      * // => 1.5
16239      */
16240     var divide = createMathOperation(function(dividend, divisor) {
16241       return dividend / divisor;
16242     }, 1);
16243
16244     /**
16245      * Computes `number` rounded down to `precision`.
16246      *
16247      * @static
16248      * @memberOf _
16249      * @since 3.10.0
16250      * @category Math
16251      * @param {number} number The number to round down.
16252      * @param {number} [precision=0] The precision to round down to.
16253      * @returns {number} Returns the rounded down number.
16254      * @example
16255      *
16256      * _.floor(4.006);
16257      * // => 4
16258      *
16259      * _.floor(0.046, 2);
16260      * // => 0.04
16261      *
16262      * _.floor(4060, -2);
16263      * // => 4000
16264      */
16265     var floor = createRound('floor');
16266
16267     /**
16268      * Computes the maximum value of `array`. If `array` is empty or falsey,
16269      * `undefined` is returned.
16270      *
16271      * @static
16272      * @since 0.1.0
16273      * @memberOf _
16274      * @category Math
16275      * @param {Array} array The array to iterate over.
16276      * @returns {*} Returns the maximum value.
16277      * @example
16278      *
16279      * _.max([4, 2, 8, 6]);
16280      * // => 8
16281      *
16282      * _.max([]);
16283      * // => undefined
16284      */
16285     function max(array) {
16286       return (array && array.length)
16287         ? baseExtremum(array, identity, baseGt)
16288         : undefined;
16289     }
16290
16291     /**
16292      * This method is like `_.max` except that it accepts `iteratee` which is
16293      * invoked for each element in `array` to generate the criterion by which
16294      * the value is ranked. The iteratee is invoked with one argument: (value).
16295      *
16296      * @static
16297      * @memberOf _
16298      * @since 4.0.0
16299      * @category Math
16300      * @param {Array} array The array to iterate over.
16301      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16302      * @returns {*} Returns the maximum value.
16303      * @example
16304      *
16305      * var objects = [{ 'n': 1 }, { 'n': 2 }];
16306      *
16307      * _.maxBy(objects, function(o) { return o.n; });
16308      * // => { 'n': 2 }
16309      *
16310      * // The `_.property` iteratee shorthand.
16311      * _.maxBy(objects, 'n');
16312      * // => { 'n': 2 }
16313      */
16314     function maxBy(array, iteratee) {
16315       return (array && array.length)
16316         ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
16317         : undefined;
16318     }
16319
16320     /**
16321      * Computes the mean of the values in `array`.
16322      *
16323      * @static
16324      * @memberOf _
16325      * @since 4.0.0
16326      * @category Math
16327      * @param {Array} array The array to iterate over.
16328      * @returns {number} Returns the mean.
16329      * @example
16330      *
16331      * _.mean([4, 2, 8, 6]);
16332      * // => 5
16333      */
16334     function mean(array) {
16335       return baseMean(array, identity);
16336     }
16337
16338     /**
16339      * This method is like `_.mean` except that it accepts `iteratee` which is
16340      * invoked for each element in `array` to generate the value to be averaged.
16341      * The iteratee is invoked with one argument: (value).
16342      *
16343      * @static
16344      * @memberOf _
16345      * @since 4.7.0
16346      * @category Math
16347      * @param {Array} array The array to iterate over.
16348      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16349      * @returns {number} Returns the mean.
16350      * @example
16351      *
16352      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16353      *
16354      * _.meanBy(objects, function(o) { return o.n; });
16355      * // => 5
16356      *
16357      * // The `_.property` iteratee shorthand.
16358      * _.meanBy(objects, 'n');
16359      * // => 5
16360      */
16361     function meanBy(array, iteratee) {
16362       return baseMean(array, getIteratee(iteratee, 2));
16363     }
16364
16365     /**
16366      * Computes the minimum value of `array`. If `array` is empty or falsey,
16367      * `undefined` is returned.
16368      *
16369      * @static
16370      * @since 0.1.0
16371      * @memberOf _
16372      * @category Math
16373      * @param {Array} array The array to iterate over.
16374      * @returns {*} Returns the minimum value.
16375      * @example
16376      *
16377      * _.min([4, 2, 8, 6]);
16378      * // => 2
16379      *
16380      * _.min([]);
16381      * // => undefined
16382      */
16383     function min(array) {
16384       return (array && array.length)
16385         ? baseExtremum(array, identity, baseLt)
16386         : undefined;
16387     }
16388
16389     /**
16390      * This method is like `_.min` except that it accepts `iteratee` which is
16391      * invoked for each element in `array` to generate the criterion by which
16392      * the value is ranked. The iteratee is invoked with one argument: (value).
16393      *
16394      * @static
16395      * @memberOf _
16396      * @since 4.0.0
16397      * @category Math
16398      * @param {Array} array The array to iterate over.
16399      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16400      * @returns {*} Returns the minimum value.
16401      * @example
16402      *
16403      * var objects = [{ 'n': 1 }, { 'n': 2 }];
16404      *
16405      * _.minBy(objects, function(o) { return o.n; });
16406      * // => { 'n': 1 }
16407      *
16408      * // The `_.property` iteratee shorthand.
16409      * _.minBy(objects, 'n');
16410      * // => { 'n': 1 }
16411      */
16412     function minBy(array, iteratee) {
16413       return (array && array.length)
16414         ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
16415         : undefined;
16416     }
16417
16418     /**
16419      * Multiply two numbers.
16420      *
16421      * @static
16422      * @memberOf _
16423      * @since 4.7.0
16424      * @category Math
16425      * @param {number} multiplier The first number in a multiplication.
16426      * @param {number} multiplicand The second number in a multiplication.
16427      * @returns {number} Returns the product.
16428      * @example
16429      *
16430      * _.multiply(6, 4);
16431      * // => 24
16432      */
16433     var multiply = createMathOperation(function(multiplier, multiplicand) {
16434       return multiplier * multiplicand;
16435     }, 1);
16436
16437     /**
16438      * Computes `number` rounded to `precision`.
16439      *
16440      * @static
16441      * @memberOf _
16442      * @since 3.10.0
16443      * @category Math
16444      * @param {number} number The number to round.
16445      * @param {number} [precision=0] The precision to round to.
16446      * @returns {number} Returns the rounded number.
16447      * @example
16448      *
16449      * _.round(4.006);
16450      * // => 4
16451      *
16452      * _.round(4.006, 2);
16453      * // => 4.01
16454      *
16455      * _.round(4060, -2);
16456      * // => 4100
16457      */
16458     var round = createRound('round');
16459
16460     /**
16461      * Subtract two numbers.
16462      *
16463      * @static
16464      * @memberOf _
16465      * @since 4.0.0
16466      * @category Math
16467      * @param {number} minuend The first number in a subtraction.
16468      * @param {number} subtrahend The second number in a subtraction.
16469      * @returns {number} Returns the difference.
16470      * @example
16471      *
16472      * _.subtract(6, 4);
16473      * // => 2
16474      */
16475     var subtract = createMathOperation(function(minuend, subtrahend) {
16476       return minuend - subtrahend;
16477     }, 0);
16478
16479     /**
16480      * Computes the sum of the values in `array`.
16481      *
16482      * @static
16483      * @memberOf _
16484      * @since 3.4.0
16485      * @category Math
16486      * @param {Array} array The array to iterate over.
16487      * @returns {number} Returns the sum.
16488      * @example
16489      *
16490      * _.sum([4, 2, 8, 6]);
16491      * // => 20
16492      */
16493     function sum(array) {
16494       return (array && array.length)
16495         ? baseSum(array, identity)
16496         : 0;
16497     }
16498
16499     /**
16500      * This method is like `_.sum` except that it accepts `iteratee` which is
16501      * invoked for each element in `array` to generate the value to be summed.
16502      * The iteratee is invoked with one argument: (value).
16503      *
16504      * @static
16505      * @memberOf _
16506      * @since 4.0.0
16507      * @category Math
16508      * @param {Array} array The array to iterate over.
16509      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16510      * @returns {number} Returns the sum.
16511      * @example
16512      *
16513      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16514      *
16515      * _.sumBy(objects, function(o) { return o.n; });
16516      * // => 20
16517      *
16518      * // The `_.property` iteratee shorthand.
16519      * _.sumBy(objects, 'n');
16520      * // => 20
16521      */
16522     function sumBy(array, iteratee) {
16523       return (array && array.length)
16524         ? baseSum(array, getIteratee(iteratee, 2))
16525         : 0;
16526     }
16527
16528     /*------------------------------------------------------------------------*/
16529
16530     // Add methods that return wrapped values in chain sequences.
16531     lodash.after = after;
16532     lodash.ary = ary;
16533     lodash.assign = assign;
16534     lodash.assignIn = assignIn;
16535     lodash.assignInWith = assignInWith;
16536     lodash.assignWith = assignWith;
16537     lodash.at = at;
16538     lodash.before = before;
16539     lodash.bind = bind;
16540     lodash.bindAll = bindAll;
16541     lodash.bindKey = bindKey;
16542     lodash.castArray = castArray;
16543     lodash.chain = chain;
16544     lodash.chunk = chunk;
16545     lodash.compact = compact;
16546     lodash.concat = concat;
16547     lodash.cond = cond;
16548     lodash.conforms = conforms;
16549     lodash.constant = constant;
16550     lodash.countBy = countBy;
16551     lodash.create = create;
16552     lodash.curry = curry;
16553     lodash.curryRight = curryRight;
16554     lodash.debounce = debounce;
16555     lodash.defaults = defaults;
16556     lodash.defaultsDeep = defaultsDeep;
16557     lodash.defer = defer;
16558     lodash.delay = delay;
16559     lodash.difference = difference;
16560     lodash.differenceBy = differenceBy;
16561     lodash.differenceWith = differenceWith;
16562     lodash.drop = drop;
16563     lodash.dropRight = dropRight;
16564     lodash.dropRightWhile = dropRightWhile;
16565     lodash.dropWhile = dropWhile;
16566     lodash.fill = fill;
16567     lodash.filter = filter;
16568     lodash.flatMap = flatMap;
16569     lodash.flatMapDeep = flatMapDeep;
16570     lodash.flatMapDepth = flatMapDepth;
16571     lodash.flatten = flatten;
16572     lodash.flattenDeep = flattenDeep;
16573     lodash.flattenDepth = flattenDepth;
16574     lodash.flip = flip;
16575     lodash.flow = flow;
16576     lodash.flowRight = flowRight;
16577     lodash.fromPairs = fromPairs;
16578     lodash.functions = functions;
16579     lodash.functionsIn = functionsIn;
16580     lodash.groupBy = groupBy;
16581     lodash.initial = initial;
16582     lodash.intersection = intersection;
16583     lodash.intersectionBy = intersectionBy;
16584     lodash.intersectionWith = intersectionWith;
16585     lodash.invert = invert;
16586     lodash.invertBy = invertBy;
16587     lodash.invokeMap = invokeMap;
16588     lodash.iteratee = iteratee;
16589     lodash.keyBy = keyBy;
16590     lodash.keys = keys;
16591     lodash.keysIn = keysIn;
16592     lodash.map = map;
16593     lodash.mapKeys = mapKeys;
16594     lodash.mapValues = mapValues;
16595     lodash.matches = matches;
16596     lodash.matchesProperty = matchesProperty;
16597     lodash.memoize = memoize;
16598     lodash.merge = merge;
16599     lodash.mergeWith = mergeWith;
16600     lodash.method = method;
16601     lodash.methodOf = methodOf;
16602     lodash.mixin = mixin;
16603     lodash.negate = negate;
16604     lodash.nthArg = nthArg;
16605     lodash.omit = omit;
16606     lodash.omitBy = omitBy;
16607     lodash.once = once;
16608     lodash.orderBy = orderBy;
16609     lodash.over = over;
16610     lodash.overArgs = overArgs;
16611     lodash.overEvery = overEvery;
16612     lodash.overSome = overSome;
16613     lodash.partial = partial;
16614     lodash.partialRight = partialRight;
16615     lodash.partition = partition;
16616     lodash.pick = pick;
16617     lodash.pickBy = pickBy;
16618     lodash.property = property;
16619     lodash.propertyOf = propertyOf;
16620     lodash.pull = pull;
16621     lodash.pullAll = pullAll;
16622     lodash.pullAllBy = pullAllBy;
16623     lodash.pullAllWith = pullAllWith;
16624     lodash.pullAt = pullAt;
16625     lodash.range = range;
16626     lodash.rangeRight = rangeRight;
16627     lodash.rearg = rearg;
16628     lodash.reject = reject;
16629     lodash.remove = remove;
16630     lodash.rest = rest;
16631     lodash.reverse = reverse;
16632     lodash.sampleSize = sampleSize;
16633     lodash.set = set;
16634     lodash.setWith = setWith;
16635     lodash.shuffle = shuffle;
16636     lodash.slice = slice;
16637     lodash.sortBy = sortBy;
16638     lodash.sortedUniq = sortedUniq;
16639     lodash.sortedUniqBy = sortedUniqBy;
16640     lodash.split = split;
16641     lodash.spread = spread;
16642     lodash.tail = tail;
16643     lodash.take = take;
16644     lodash.takeRight = takeRight;
16645     lodash.takeRightWhile = takeRightWhile;
16646     lodash.takeWhile = takeWhile;
16647     lodash.tap = tap;
16648     lodash.throttle = throttle;
16649     lodash.thru = thru;
16650     lodash.toArray = toArray;
16651     lodash.toPairs = toPairs;
16652     lodash.toPairsIn = toPairsIn;
16653     lodash.toPath = toPath;
16654     lodash.toPlainObject = toPlainObject;
16655     lodash.transform = transform;
16656     lodash.unary = unary;
16657     lodash.union = union;
16658     lodash.unionBy = unionBy;
16659     lodash.unionWith = unionWith;
16660     lodash.uniq = uniq;
16661     lodash.uniqBy = uniqBy;
16662     lodash.uniqWith = uniqWith;
16663     lodash.unset = unset;
16664     lodash.unzip = unzip;
16665     lodash.unzipWith = unzipWith;
16666     lodash.update = update;
16667     lodash.updateWith = updateWith;
16668     lodash.values = values;
16669     lodash.valuesIn = valuesIn;
16670     lodash.without = without;
16671     lodash.words = words;
16672     lodash.wrap = wrap;
16673     lodash.xor = xor;
16674     lodash.xorBy = xorBy;
16675     lodash.xorWith = xorWith;
16676     lodash.zip = zip;
16677     lodash.zipObject = zipObject;
16678     lodash.zipObjectDeep = zipObjectDeep;
16679     lodash.zipWith = zipWith;
16680
16681     // Add aliases.
16682     lodash.entries = toPairs;
16683     lodash.entriesIn = toPairsIn;
16684     lodash.extend = assignIn;
16685     lodash.extendWith = assignInWith;
16686
16687     // Add methods to `lodash.prototype`.
16688     mixin(lodash, lodash);
16689
16690     /*------------------------------------------------------------------------*/
16691
16692     // Add methods that return unwrapped values in chain sequences.
16693     lodash.add = add;
16694     lodash.attempt = attempt;
16695     lodash.camelCase = camelCase;
16696     lodash.capitalize = capitalize;
16697     lodash.ceil = ceil;
16698     lodash.clamp = clamp;
16699     lodash.clone = clone;
16700     lodash.cloneDeep = cloneDeep;
16701     lodash.cloneDeepWith = cloneDeepWith;
16702     lodash.cloneWith = cloneWith;
16703     lodash.conformsTo = conformsTo;
16704     lodash.deburr = deburr;
16705     lodash.defaultTo = defaultTo;
16706     lodash.divide = divide;
16707     lodash.endsWith = endsWith;
16708     lodash.eq = eq;
16709     lodash.escape = escape;
16710     lodash.escapeRegExp = escapeRegExp;
16711     lodash.every = every;
16712     lodash.find = find;
16713     lodash.findIndex = findIndex;
16714     lodash.findKey = findKey;
16715     lodash.findLast = findLast;
16716     lodash.findLastIndex = findLastIndex;
16717     lodash.findLastKey = findLastKey;
16718     lodash.floor = floor;
16719     lodash.forEach = forEach;
16720     lodash.forEachRight = forEachRight;
16721     lodash.forIn = forIn;
16722     lodash.forInRight = forInRight;
16723     lodash.forOwn = forOwn;
16724     lodash.forOwnRight = forOwnRight;
16725     lodash.get = get;
16726     lodash.gt = gt;
16727     lodash.gte = gte;
16728     lodash.has = has;
16729     lodash.hasIn = hasIn;
16730     lodash.head = head;
16731     lodash.identity = identity;
16732     lodash.includes = includes;
16733     lodash.indexOf = indexOf;
16734     lodash.inRange = inRange;
16735     lodash.invoke = invoke;
16736     lodash.isArguments = isArguments;
16737     lodash.isArray = isArray;
16738     lodash.isArrayBuffer = isArrayBuffer;
16739     lodash.isArrayLike = isArrayLike;
16740     lodash.isArrayLikeObject = isArrayLikeObject;
16741     lodash.isBoolean = isBoolean;
16742     lodash.isBuffer = isBuffer;
16743     lodash.isDate = isDate;
16744     lodash.isElement = isElement;
16745     lodash.isEmpty = isEmpty;
16746     lodash.isEqual = isEqual;
16747     lodash.isEqualWith = isEqualWith;
16748     lodash.isError = isError;
16749     lodash.isFinite = isFinite;
16750     lodash.isFunction = isFunction;
16751     lodash.isInteger = isInteger;
16752     lodash.isLength = isLength;
16753     lodash.isMap = isMap;
16754     lodash.isMatch = isMatch;
16755     lodash.isMatchWith = isMatchWith;
16756     lodash.isNaN = isNaN;
16757     lodash.isNative = isNative;
16758     lodash.isNil = isNil;
16759     lodash.isNull = isNull;
16760     lodash.isNumber = isNumber;
16761     lodash.isObject = isObject;
16762     lodash.isObjectLike = isObjectLike;
16763     lodash.isPlainObject = isPlainObject;
16764     lodash.isRegExp = isRegExp;
16765     lodash.isSafeInteger = isSafeInteger;
16766     lodash.isSet = isSet;
16767     lodash.isString = isString;
16768     lodash.isSymbol = isSymbol;
16769     lodash.isTypedArray = isTypedArray;
16770     lodash.isUndefined = isUndefined;
16771     lodash.isWeakMap = isWeakMap;
16772     lodash.isWeakSet = isWeakSet;
16773     lodash.join = join;
16774     lodash.kebabCase = kebabCase;
16775     lodash.last = last;
16776     lodash.lastIndexOf = lastIndexOf;
16777     lodash.lowerCase = lowerCase;
16778     lodash.lowerFirst = lowerFirst;
16779     lodash.lt = lt;
16780     lodash.lte = lte;
16781     lodash.max = max;
16782     lodash.maxBy = maxBy;
16783     lodash.mean = mean;
16784     lodash.meanBy = meanBy;
16785     lodash.min = min;
16786     lodash.minBy = minBy;
16787     lodash.stubArray = stubArray;
16788     lodash.stubFalse = stubFalse;
16789     lodash.stubObject = stubObject;
16790     lodash.stubString = stubString;
16791     lodash.stubTrue = stubTrue;
16792     lodash.multiply = multiply;
16793     lodash.nth = nth;
16794     lodash.noConflict = noConflict;
16795     lodash.noop = noop;
16796     lodash.now = now;
16797     lodash.pad = pad;
16798     lodash.padEnd = padEnd;
16799     lodash.padStart = padStart;
16800     lodash.parseInt = parseInt;
16801     lodash.random = random;
16802     lodash.reduce = reduce;
16803     lodash.reduceRight = reduceRight;
16804     lodash.repeat = repeat;
16805     lodash.replace = replace;
16806     lodash.result = result;
16807     lodash.round = round;
16808     lodash.runInContext = runInContext;
16809     lodash.sample = sample;
16810     lodash.size = size;
16811     lodash.snakeCase = snakeCase;
16812     lodash.some = some;
16813     lodash.sortedIndex = sortedIndex;
16814     lodash.sortedIndexBy = sortedIndexBy;
16815     lodash.sortedIndexOf = sortedIndexOf;
16816     lodash.sortedLastIndex = sortedLastIndex;
16817     lodash.sortedLastIndexBy = sortedLastIndexBy;
16818     lodash.sortedLastIndexOf = sortedLastIndexOf;
16819     lodash.startCase = startCase;
16820     lodash.startsWith = startsWith;
16821     lodash.subtract = subtract;
16822     lodash.sum = sum;
16823     lodash.sumBy = sumBy;
16824     lodash.template = template;
16825     lodash.times = times;
16826     lodash.toFinite = toFinite;
16827     lodash.toInteger = toInteger;
16828     lodash.toLength = toLength;
16829     lodash.toLower = toLower;
16830     lodash.toNumber = toNumber;
16831     lodash.toSafeInteger = toSafeInteger;
16832     lodash.toString = toString;
16833     lodash.toUpper = toUpper;
16834     lodash.trim = trim;
16835     lodash.trimEnd = trimEnd;
16836     lodash.trimStart = trimStart;
16837     lodash.truncate = truncate;
16838     lodash.unescape = unescape;
16839     lodash.uniqueId = uniqueId;
16840     lodash.upperCase = upperCase;
16841     lodash.upperFirst = upperFirst;
16842
16843     // Add aliases.
16844     lodash.each = forEach;
16845     lodash.eachRight = forEachRight;
16846     lodash.first = head;
16847
16848     mixin(lodash, (function() {
16849       var source = {};
16850       baseForOwn(lodash, function(func, methodName) {
16851         if (!hasOwnProperty.call(lodash.prototype, methodName)) {
16852           source[methodName] = func;
16853         }
16854       });
16855       return source;
16856     }()), { 'chain': false });
16857
16858     /*------------------------------------------------------------------------*/
16859
16860     /**
16861      * The semantic version number.
16862      *
16863      * @static
16864      * @memberOf _
16865      * @type {string}
16866      */
16867     lodash.VERSION = VERSION;
16868
16869     // Assign default placeholders.
16870     arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
16871       lodash[methodName].placeholder = lodash;
16872     });
16873
16874     // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
16875     arrayEach(['drop', 'take'], function(methodName, index) {
16876       LazyWrapper.prototype[methodName] = function(n) {
16877         n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
16878
16879         var result = (this.__filtered__ && !index)
16880           ? new LazyWrapper(this)
16881           : this.clone();
16882
16883         if (result.__filtered__) {
16884           result.__takeCount__ = nativeMin(n, result.__takeCount__);
16885         } else {
16886           result.__views__.push({
16887             'size': nativeMin(n, MAX_ARRAY_LENGTH),
16888             'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
16889           });
16890         }
16891         return result;
16892       };
16893
16894       LazyWrapper.prototype[methodName + 'Right'] = function(n) {
16895         return this.reverse()[methodName](n).reverse();
16896       };
16897     });
16898
16899     // Add `LazyWrapper` methods that accept an `iteratee` value.
16900     arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
16901       var type = index + 1,
16902           isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
16903
16904       LazyWrapper.prototype[methodName] = function(iteratee) {
16905         var result = this.clone();
16906         result.__iteratees__.push({
16907           'iteratee': getIteratee(iteratee, 3),
16908           'type': type
16909         });
16910         result.__filtered__ = result.__filtered__ || isFilter;
16911         return result;
16912       };
16913     });
16914
16915     // Add `LazyWrapper` methods for `_.head` and `_.last`.
16916     arrayEach(['head', 'last'], function(methodName, index) {
16917       var takeName = 'take' + (index ? 'Right' : '');
16918
16919       LazyWrapper.prototype[methodName] = function() {
16920         return this[takeName](1).value()[0];
16921       };
16922     });
16923
16924     // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
16925     arrayEach(['initial', 'tail'], function(methodName, index) {
16926       var dropName = 'drop' + (index ? '' : 'Right');
16927
16928       LazyWrapper.prototype[methodName] = function() {
16929         return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
16930       };
16931     });
16932
16933     LazyWrapper.prototype.compact = function() {
16934       return this.filter(identity);
16935     };
16936
16937     LazyWrapper.prototype.find = function(predicate) {
16938       return this.filter(predicate).head();
16939     };
16940
16941     LazyWrapper.prototype.findLast = function(predicate) {
16942       return this.reverse().find(predicate);
16943     };
16944
16945     LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
16946       if (typeof path == 'function') {
16947         return new LazyWrapper(this);
16948       }
16949       return this.map(function(value) {
16950         return baseInvoke(value, path, args);
16951       });
16952     });
16953
16954     LazyWrapper.prototype.reject = function(predicate) {
16955       return this.filter(negate(getIteratee(predicate)));
16956     };
16957
16958     LazyWrapper.prototype.slice = function(start, end) {
16959       start = toInteger(start);
16960
16961       var result = this;
16962       if (result.__filtered__ && (start > 0 || end < 0)) {
16963         return new LazyWrapper(result);
16964       }
16965       if (start < 0) {
16966         result = result.takeRight(-start);
16967       } else if (start) {
16968         result = result.drop(start);
16969       }
16970       if (end !== undefined) {
16971         end = toInteger(end);
16972         result = end < 0 ? result.dropRight(-end) : result.take(end - start);
16973       }
16974       return result;
16975     };
16976
16977     LazyWrapper.prototype.takeRightWhile = function(predicate) {
16978       return this.reverse().takeWhile(predicate).reverse();
16979     };
16980
16981     LazyWrapper.prototype.toArray = function() {
16982       return this.take(MAX_ARRAY_LENGTH);
16983     };
16984
16985     // Add `LazyWrapper` methods to `lodash.prototype`.
16986     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
16987       var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
16988           isTaker = /^(?:head|last)$/.test(methodName),
16989           lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
16990           retUnwrapped = isTaker || /^find/.test(methodName);
16991
16992       if (!lodashFunc) {
16993         return;
16994       }
16995       lodash.prototype[methodName] = function() {
16996         var value = this.__wrapped__,
16997             args = isTaker ? [1] : arguments,
16998             isLazy = value instanceof LazyWrapper,
16999             iteratee = args[0],
17000             useLazy = isLazy || isArray(value);
17001
17002         var interceptor = function(value) {
17003           var result = lodashFunc.apply(lodash, arrayPush([value], args));
17004           return (isTaker && chainAll) ? result[0] : result;
17005         };
17006
17007         if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
17008           // Avoid lazy use if the iteratee has a "length" value other than `1`.
17009           isLazy = useLazy = false;
17010         }
17011         var chainAll = this.__chain__,
17012             isHybrid = !!this.__actions__.length,
17013             isUnwrapped = retUnwrapped && !chainAll,
17014             onlyLazy = isLazy && !isHybrid;
17015
17016         if (!retUnwrapped && useLazy) {
17017           value = onlyLazy ? value : new LazyWrapper(this);
17018           var result = func.apply(value, args);
17019           result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
17020           return new LodashWrapper(result, chainAll);
17021         }
17022         if (isUnwrapped && onlyLazy) {
17023           return func.apply(this, args);
17024         }
17025         result = this.thru(interceptor);
17026         return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
17027       };
17028     });
17029
17030     // Add `Array` methods to `lodash.prototype`.
17031     arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
17032       var func = arrayProto[methodName],
17033           chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
17034           retUnwrapped = /^(?:pop|shift)$/.test(methodName);
17035
17036       lodash.prototype[methodName] = function() {
17037         var args = arguments;
17038         if (retUnwrapped && !this.__chain__) {
17039           var value = this.value();
17040           return func.apply(isArray(value) ? value : [], args);
17041         }
17042         return this[chainName](function(value) {
17043           return func.apply(isArray(value) ? value : [], args);
17044         });
17045       };
17046     });
17047
17048     // Map minified method names to their real names.
17049     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17050       var lodashFunc = lodash[methodName];
17051       if (lodashFunc) {
17052         var key = lodashFunc.name + '';
17053         if (!hasOwnProperty.call(realNames, key)) {
17054           realNames[key] = [];
17055         }
17056         realNames[key].push({ 'name': methodName, 'func': lodashFunc });
17057       }
17058     });
17059
17060     realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
17061       'name': 'wrapper',
17062       'func': undefined
17063     }];
17064
17065     // Add methods to `LazyWrapper`.
17066     LazyWrapper.prototype.clone = lazyClone;
17067     LazyWrapper.prototype.reverse = lazyReverse;
17068     LazyWrapper.prototype.value = lazyValue;
17069
17070     // Add chain sequence methods to the `lodash` wrapper.
17071     lodash.prototype.at = wrapperAt;
17072     lodash.prototype.chain = wrapperChain;
17073     lodash.prototype.commit = wrapperCommit;
17074     lodash.prototype.next = wrapperNext;
17075     lodash.prototype.plant = wrapperPlant;
17076     lodash.prototype.reverse = wrapperReverse;
17077     lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
17078
17079     // Add lazy aliases.
17080     lodash.prototype.first = lodash.prototype.head;
17081
17082     if (symIterator) {
17083       lodash.prototype[symIterator] = wrapperToIterator;
17084     }
17085     return lodash;
17086   });
17087
17088   /*--------------------------------------------------------------------------*/
17089
17090   // Export lodash.
17091   var _ = runInContext();
17092
17093   // Some AMD build optimizers, like r.js, check for condition patterns like:
17094   if (true) {
17095     // Expose Lodash on the global object to prevent errors when Lodash is
17096     // loaded by a script tag in the presence of an AMD loader.
17097     // See http://requirejs.org/docs/errors.html#mismatch for more details.
17098     // Use `_.noConflict` to remove Lodash from the global object.
17099     root._ = _;
17100
17101     // Define as an anonymous module so, through path mapping, it can be
17102     // referenced as the "underscore" module.
17103     !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
17104       return _;
17105     }).call(exports, __webpack_require__, exports, module),
17106                                 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
17107   }
17108   // Check for `exports` after `define` in case a build optimizer adds it.
17109   else if (freeModule) {
17110     // Export for Node.js.
17111     (freeModule.exports = _)._ = _;
17112     // Export for CommonJS support.
17113     freeExports._ = _;
17114   }
17115   else {
17116     // Export to the global object.
17117     root._ = _;
17118   }
17119 }.call(this));
17120
17121 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(128)(module)))
17122
17123 /***/ }),
17124
17125 /***/ 529:
17126 /***/ (function(module, __webpack_exports__, __webpack_require__) {
17127
17128 "use strict";
17129 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return apis; });
17130 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
17131 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
17132
17133
17134 var swallow = function swallow(fn) {
17135     try {
17136         fn();
17137     } catch (e) {}
17138 };
17139
17140 var ApiGenerator = function ApiGenerator() {
17141     var _this = this;
17142
17143     __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, ApiGenerator);
17144
17145     ['app', 'storage', 'extension', 'runtime', 'windows'].map(function (api) {
17146         if (typeof chrome !== 'undefined') swallow(function () {
17147             if (chrome[api]) _this[api] = chrome[api];
17148         });
17149         if (typeof browser !== 'undefined') swallow(function () {
17150             if (browser[api]) _this[api] = browser[api];
17151         });
17152     });
17153
17154     if (typeof browser !== 'undefined') swallow(function () {
17155         if (browser && browser.runtime) _this.runtime = browser.runtime;
17156     });
17157 };
17158
17159 var apis = new ApiGenerator();
17160
17161 /***/ }),
17162
17163 /***/ 530:
17164 /***/ (function(module, __webpack_exports__, __webpack_require__) {
17165
17166 "use strict";
17167 /* unused harmony export ErrorCodes */
17168 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
17169 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
17170 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(36);
17171 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
17172 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ErrorTypes__ = __webpack_require__(535);
17173
17174
17175
17176
17177 var ErrorCodes = {
17178   NO_SIGNATURE: 402,
17179   FORBIDDEN: 403,
17180   TIMED_OUT: 408,
17181   LOCKED: 423,
17182   TOO_MANY_REQUESTS: 429,
17183   TYPE_MISSED: 411,
17184   TYPE_DUPLICATE: 405
17185 };
17186
17187 var Error = function () {
17188   function Error(_type, _message) {
17189     var _code = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ErrorCodes.LOCKED;
17190
17191     __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, Error);
17192
17193     this.type = _type;
17194     this.message = _message;
17195     this.code = _code;
17196     this.isError = true;
17197   }
17198
17199   __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(Error, null, [{
17200     key: "locked",
17201     value: function locked() {
17202       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["a" /* LOCKED */], "The user's Bytom is locked. They have been notified and should unlock before continuing.");
17203     }
17204   }, {
17205     key: "duplicate",
17206     value: function duplicate(_type) {
17207       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["d" /* TYPE_DUPLICATED */], "The current value has been set to '" + _type + "', please select another parameter.", ErrorCodes.TYPE_DUPLICATE);
17208     }
17209   }, {
17210     key: "promptClosedWithoutAction",
17211     value: function promptClosedWithoutAction() {
17212       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["c" /* PROMPT_CLOSED */], "The user closed the prompt without any action.", ErrorCodes.TIMED_OUT);
17213     }
17214   }, {
17215     key: "signatureError",
17216     value: function signatureError(_type, _message) {
17217       return new Error(_type, _message, ErrorCodes.NO_SIGNATURE);
17218     }
17219   }, {
17220     key: "typeMissed",
17221     value: function typeMissed(_type) {
17222       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["e" /* TYPE_MISSED */], "Parameter '" + _type + "' is missing, please add the Parameter '" + _type + "'.");
17223     }
17224   }, {
17225     key: "identityMissing",
17226     value: function identityMissing() {
17227       return this.signatureError("identity_missing", "Identity no longer exists on the user's keychain");
17228     }
17229   }, {
17230     key: "signatureAccountMissing",
17231     value: function signatureAccountMissing() {
17232       return this.signatureError("account_missing", "Missing required accounts, repull the identity");
17233     }
17234   }, {
17235     key: "malformedRequiredFields",
17236     value: function malformedRequiredFields() {
17237       return this.signatureError("malformed_requirements", "The requiredFields you passed in were malformed");
17238     }
17239   }, {
17240     key: "usedKeyProvider",
17241     value: function usedKeyProvider() {
17242       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["b" /* MALICIOUS */], "Do not use a `keyProvider` with a Bytom. Use a `signProvider` and return only signatures to this object. A malicious person could retrieve your keys otherwise.", ErrorCodes.NO_SIGNATURE);
17243     }
17244   }]);
17245
17246   return Error;
17247 }();
17248
17249 /* harmony default export */ __webpack_exports__["a"] = (Error);
17250
17251 /***/ }),
17252
17253 /***/ 532:
17254 /***/ (function(module, exports, __webpack_require__) {
17255
17256 "use strict";
17257
17258
17259 exports.__esModule = true;
17260
17261 var _assign = __webpack_require__(69);
17262
17263 var _assign2 = _interopRequireDefault(_assign);
17264
17265 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17266
17267 exports.default = _assign2.default || function (target) {
17268   for (var i = 1; i < arguments.length; i++) {
17269     var source = arguments[i];
17270
17271     for (var key in source) {
17272       if (Object.prototype.hasOwnProperty.call(source, key)) {
17273         target[key] = source[key];
17274       }
17275     }
17276   }
17277
17278   return target;
17279 };
17280
17281 /***/ }),
17282
17283 /***/ 534:
17284 /***/ (function(module, __webpack_exports__, __webpack_require__) {
17285
17286 "use strict";
17287 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__ = __webpack_require__(144);
17288 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__);
17289 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__ = __webpack_require__(138);
17290 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__);
17291 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(139);
17292 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__);
17293 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
17294 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck__);
17295 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass__ = __webpack_require__(36);
17296 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass__);
17297 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_errors_Error__ = __webpack_require__(530);
17298 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__ = __webpack_require__(529);
17299 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__messages_internal__ = __webpack_require__(267);
17300 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__messages_types__ = __webpack_require__(129);
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311 var openWindow = null;
17312
17313 var NotificationService = function () {
17314     function NotificationService() {
17315         __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck___default()(this, NotificationService);
17316     }
17317
17318     __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass___default()(NotificationService, null, [{
17319         key: 'open',
17320
17321
17322         /***
17323          * Opens a prompt window outside of the extension
17324          * @param notification
17325          */
17326         value: function () {
17327             var _ref = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee2(notification) {
17328                 var _this = this;
17329
17330                 var height, width, middleX, middleY, getPopup, popup;
17331                 return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee2$(_context2) {
17332                     while (1) {
17333                         switch (_context2.prev = _context2.next) {
17334                             case 0:
17335                                 if (openWindow) {
17336                                     // For now we're just going to close the window to get rid of the error
17337                                     // that is caused by already open windows swallowing all further requests
17338                                     openWindow.close();
17339                                     openWindow = null;
17340
17341                                     // Alternatively we could focus the old window, but this would cause
17342                                     // urgent 1-time messages to be lost, such as after dying in a game and
17343                                     // uploading a high-score. That message will be lost.
17344                                     // openWindow.focus();
17345                                     // return false;
17346
17347                                     // A third option would be to add a queue, but this could cause
17348                                     // virus-like behavior as apps overflow the queue causing the user
17349                                     // to have to quit the browser to regain control.
17350                                 }
17351
17352                                 height = 623;
17353                                 width = 360;
17354                                 middleX = window.screen.availWidth / 2 - width / 2;
17355                                 middleY = window.screen.availHeight / 2 - height / 2;
17356
17357                                 getPopup = function () {
17358                                     var _ref2 = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee() {
17359                                         var url, win;
17360                                         return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
17361                                             while (1) {
17362                                                 switch (_context.prev = _context.next) {
17363                                                     case 0:
17364                                                         _context.prev = 0;
17365                                                         url = __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].runtime.getURL('pages/prompt.html') + '#' + notification.routeName();
17366
17367                                                         // Notifications get bound differently depending on browser
17368                                                         // as Firefox does not support opening windows from background.
17369
17370                                                         if (!(typeof chrome !== 'undefined')) {
17371                                                             _context.next = 7;
17372                                                             break;
17373                                                         }
17374
17375                                                         window.notification = notification;
17376                                                         __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.create({
17377                                                             url: url,
17378                                                             height: height,
17379                                                             width: width,
17380                                                             type: 'popup'
17381                                                         }, function (_window) {
17382                                                             __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.onRemoved.addListener(function (windowId) {
17383                                                                 if (windowId === _window.id) {
17384                                                                     notification.responder(__WEBPACK_IMPORTED_MODULE_5__utils_errors_Error__["a" /* default */].promptClosedWithoutAction());
17385                                                                     return false;
17386                                                                 }
17387                                                             });
17388                                                             return _window;
17389                                                         });
17390                                                         _context.next = 11;
17391                                                         break;
17392
17393                                                     case 7:
17394                                                         win = window.open(url, 'BytomPrompt', 'width=' + width + ',height=' + height + ',resizable=0,top=' + middleY + ',left=' + middleX + ',titlebar=0');
17395
17396                                                         win.data = notification;
17397                                                         openWindow = win;
17398                                                         return _context.abrupt('return', win);
17399
17400                                                     case 11:
17401                                                         _context.next = 17;
17402                                                         break;
17403
17404                                                     case 13:
17405                                                         _context.prev = 13;
17406                                                         _context.t0 = _context['catch'](0);
17407
17408                                                         console.log('notification error', _context.t0);
17409                                                         return _context.abrupt('return', null);
17410
17411                                                     case 17:
17412                                                     case 'end':
17413                                                         return _context.stop();
17414                                                 }
17415                                             }
17416                                         }, _callee, _this, [[0, 13]]);
17417                                     }));
17418
17419                                     return function getPopup() {
17420                                         return _ref2.apply(this, arguments);
17421                                     };
17422                                 }();
17423
17424                                 _context2.next = 8;
17425                                 return __WEBPACK_IMPORTED_MODULE_7__messages_internal__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_8__messages_types__["l" /* SET_PROMPT */], __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(notification)).send();
17426
17427                             case 8:
17428                                 _context2.next = 10;
17429                                 return getPopup();
17430
17431                             case 10:
17432                                 popup = _context2.sent;
17433
17434
17435                                 if (popup) {
17436                                     popup.onbeforeunload = function () {
17437                                         notification.responder(__WEBPACK_IMPORTED_MODULE_5__utils_errors_Error__["a" /* default */].promptClosedWithoutAction());
17438
17439                                         // https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
17440                                         // Must return undefined to bypass form protection
17441                                         openWindow = null;
17442                                         return undefined;
17443                                     };
17444                                 }
17445
17446                             case 12:
17447                             case 'end':
17448                                 return _context2.stop();
17449                         }
17450                     }
17451                 }, _callee2, this);
17452             }));
17453
17454             function open(_x) {
17455                 return _ref.apply(this, arguments);
17456             }
17457
17458             return open;
17459         }()
17460
17461         /***
17462          * Always use this method for closing notification popups.
17463          * Otherwise you will double send responses and one will always be null.
17464          */
17465
17466     }, {
17467         key: 'close',
17468         value: function () {
17469             var _ref3 = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee3() {
17470                 var _ref4, windowId;
17471
17472                 return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee3$(_context3) {
17473                     while (1) {
17474                         switch (_context3.prev = _context3.next) {
17475                             case 0:
17476                                 if (!(typeof browser !== 'undefined')) {
17477                                     _context3.next = 8;
17478                                     break;
17479                                 }
17480
17481                                 _context3.next = 3;
17482                                 return __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.getCurrent();
17483
17484                             case 3:
17485                                 _ref4 = _context3.sent;
17486                                 windowId = _ref4.id;
17487
17488                                 __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.remove(windowId);
17489                                 _context3.next = 10;
17490                                 break;
17491
17492                             case 8:
17493                                 window.onbeforeunload = function () {};
17494                                 window.close();
17495
17496                             case 10:
17497                             case 'end':
17498                                 return _context3.stop();
17499                         }
17500                     }
17501                 }, _callee3, this);
17502             }));
17503
17504             function close() {
17505                 return _ref3.apply(this, arguments);
17506             }
17507
17508             return close;
17509         }()
17510     }]);
17511
17512     return NotificationService;
17513 }();
17514
17515 /* harmony default export */ __webpack_exports__["a"] = (NotificationService);
17516
17517 /***/ }),
17518
17519 /***/ 535:
17520 /***/ (function(module, __webpack_exports__, __webpack_require__) {
17521
17522 "use strict";
17523 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return MALICIOUS; });
17524 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LOCKED; });
17525 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return PROMPT_CLOSED; });
17526 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return TYPE_MISSED; });
17527 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return TYPE_DUPLICATED; });
17528 var MALICIOUS = 'malicious';
17529 var LOCKED = 'locked';
17530 var PROMPT_CLOSED = 'prompt_closed';
17531 var TYPE_MISSED = 'type_missed';
17532 var TYPE_DUPLICATED = 'type_duplicated';
17533
17534 /***/ }),
17535
17536 /***/ 549:
17537 /***/ (function(module, __webpack_exports__, __webpack_require__) {
17538
17539 "use strict";
17540 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
17541 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_advancedTransfer_vue__ = __webpack_require__(606);
17542 /* empty harmony namespace reexport */
17543 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_b2586742_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_advancedTransfer_vue__ = __webpack_require__(669);
17544 function injectStyle (ssrContext) {
17545   __webpack_require__(667)
17546 }
17547 var normalizeComponent = __webpack_require__(266)
17548 /* script */
17549
17550
17551 /* template */
17552
17553 /* template functional */
17554 var __vue_template_functional__ = false
17555 /* styles */
17556 var __vue_styles__ = injectStyle
17557 /* scopeId */
17558 var __vue_scopeId__ = "data-v-b2586742"
17559 /* moduleIdentifier (server only) */
17560 var __vue_module_identifier__ = null
17561 var Component = normalizeComponent(
17562   __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_advancedTransfer_vue__["a" /* default */],
17563   __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_b2586742_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_advancedTransfer_vue__["a" /* default */],
17564   __vue_template_functional__,
17565   __vue_styles__,
17566   __vue_scopeId__,
17567   __vue_module_identifier__
17568 )
17569
17570 /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
17571
17572
17573 /***/ }),
17574
17575 /***/ 576:
17576 /***/ (function(module, exports, __webpack_require__) {
17577
17578 var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalObject) {\r
17579   'use strict';\r
17580 \r
17581 /*\r
17582  *      bignumber.js v9.0.0\r
17583  *      A JavaScript library for arbitrary-precision arithmetic.\r
17584  *      https://github.com/MikeMcl/bignumber.js\r
17585  *      Copyright (c) 2019 Michael Mclaughlin <M8ch88l@gmail.com>\r
17586  *      MIT Licensed.\r
17587  *\r
17588  *      BigNumber.prototype methods     |  BigNumber methods\r
17589  *                                      |\r
17590  *      absoluteValue            abs    |  clone\r
17591  *      comparedTo                      |  config               set\r
17592  *      decimalPlaces            dp     |      DECIMAL_PLACES\r
17593  *      dividedBy                div    |      ROUNDING_MODE\r
17594  *      dividedToIntegerBy       idiv   |      EXPONENTIAL_AT\r
17595  *      exponentiatedBy          pow    |      RANGE\r
17596  *      integerValue                    |      CRYPTO\r
17597  *      isEqualTo                eq     |      MODULO_MODE\r
17598  *      isFinite                        |      POW_PRECISION\r
17599  *      isGreaterThan            gt     |      FORMAT\r
17600  *      isGreaterThanOrEqualTo   gte    |      ALPHABET\r
17601  *      isInteger                       |  isBigNumber\r
17602  *      isLessThan               lt     |  maximum              max\r
17603  *      isLessThanOrEqualTo      lte    |  minimum              min\r
17604  *      isNaN                           |  random\r
17605  *      isNegative                      |  sum\r
17606  *      isPositive                      |\r
17607  *      isZero                          |\r
17608  *      minus                           |\r
17609  *      modulo                   mod    |\r
17610  *      multipliedBy             times  |\r
17611  *      negated                         |\r
17612  *      plus                            |\r
17613  *      precision                sd     |\r
17614  *      shiftedBy                       |\r
17615  *      squareRoot               sqrt   |\r
17616  *      toExponential                   |\r
17617  *      toFixed                         |\r
17618  *      toFormat                        |\r
17619  *      toFraction                      |\r
17620  *      toJSON                          |\r
17621  *      toNumber                        |\r
17622  *      toPrecision                     |\r
17623  *      toString                        |\r
17624  *      valueOf                         |\r
17625  *\r
17626  */\r
17627 \r
17628 \r
17629   var BigNumber,\r
17630     isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,\r
17631     mathceil = Math.ceil,\r
17632     mathfloor = Math.floor,\r
17633 \r
17634     bignumberError = '[BigNumber Error] ',\r
17635     tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',\r
17636 \r
17637     BASE = 1e14,\r
17638     LOG_BASE = 14,\r
17639     MAX_SAFE_INTEGER = 0x1fffffffffffff,         // 2^53 - 1\r
17640     // MAX_INT32 = 0x7fffffff,                   // 2^31 - 1\r
17641     POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],\r
17642     SQRT_BASE = 1e7,\r
17643 \r
17644     // EDITABLE\r
17645     // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and\r
17646     // the arguments to toExponential, toFixed, toFormat, and toPrecision.\r
17647     MAX = 1E9;                                   // 0 to MAX_INT32\r
17648 \r
17649 \r
17650   /*\r
17651    * Create and return a BigNumber constructor.\r
17652    */\r
17653   function clone(configObject) {\r
17654     var div, convertBase, parseNumeric,\r
17655       P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },\r
17656       ONE = new BigNumber(1),\r
17657 \r
17658 \r
17659       //----------------------------- EDITABLE CONFIG DEFAULTS -------------------------------\r
17660 \r
17661 \r
17662       // The default values below must be integers within the inclusive ranges stated.\r
17663       // The values can also be changed at run-time using BigNumber.set.\r
17664 \r
17665       // The maximum number of decimal places for operations involving division.\r
17666       DECIMAL_PLACES = 20,                     // 0 to MAX\r
17667 \r
17668       // The rounding mode used when rounding to the above decimal places, and when using\r
17669       // toExponential, toFixed, toFormat and toPrecision, and round (default value).\r
17670       // UP         0 Away from zero.\r
17671       // DOWN       1 Towards zero.\r
17672       // CEIL       2 Towards +Infinity.\r
17673       // FLOOR      3 Towards -Infinity.\r
17674       // HALF_UP    4 Towards nearest neighbour. If equidistant, up.\r
17675       // HALF_DOWN  5 Towards nearest neighbour. If equidistant, down.\r
17676       // HALF_EVEN  6 Towards nearest neighbour. If equidistant, towards even neighbour.\r
17677       // HALF_CEIL  7 Towards nearest neighbour. If equidistant, towards +Infinity.\r
17678       // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.\r
17679       ROUNDING_MODE = 4,                       // 0 to 8\r
17680 \r
17681       // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]\r
17682 \r
17683       // The exponent value at and beneath which toString returns exponential notation.\r
17684       // Number type: -7\r
17685       TO_EXP_NEG = -7,                         // 0 to -MAX\r
17686 \r
17687       // The exponent value at and above which toString returns exponential notation.\r
17688       // Number type: 21\r
17689       TO_EXP_POS = 21,                         // 0 to MAX\r
17690 \r
17691       // RANGE : [MIN_EXP, MAX_EXP]\r
17692 \r
17693       // The minimum exponent value, beneath which underflow to zero occurs.\r
17694       // Number type: -324  (5e-324)\r
17695       MIN_EXP = -1e7,                          // -1 to -MAX\r
17696 \r
17697       // The maximum exponent value, above which overflow to Infinity occurs.\r
17698       // Number type:  308  (1.7976931348623157e+308)\r
17699       // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.\r
17700       MAX_EXP = 1e7,                           // 1 to MAX\r
17701 \r
17702       // Whether to use cryptographically-secure random number generation, if available.\r
17703       CRYPTO = false,                          // true or false\r
17704 \r
17705       // The modulo mode used when calculating the modulus: a mod n.\r
17706       // The quotient (q = a / n) is calculated according to the corresponding rounding mode.\r
17707       // The remainder (r) is calculated as: r = a - n * q.\r
17708       //\r
17709       // UP        0 The remainder is positive if the dividend is negative, else is negative.\r
17710       // DOWN      1 The remainder has the same sign as the dividend.\r
17711       //             This modulo mode is commonly known as 'truncated division' and is\r
17712       //             equivalent to (a % n) in JavaScript.\r
17713       // FLOOR     3 The remainder has the same sign as the divisor (Python %).\r
17714       // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.\r
17715       // EUCLID    9 Euclidian division. q = sign(n) * floor(a / abs(n)).\r
17716       //             The remainder is always positive.\r
17717       //\r
17718       // The truncated division, floored division, Euclidian division and IEEE 754 remainder\r
17719       // modes are commonly used for the modulus operation.\r
17720       // Although the other rounding modes can also be used, they may not give useful results.\r
17721       MODULO_MODE = 1,                         // 0 to 9\r
17722 \r
17723       // The maximum number of significant digits of the result of the exponentiatedBy operation.\r
17724       // If POW_PRECISION is 0, there will be unlimited significant digits.\r
17725       POW_PRECISION = 0,                    // 0 to MAX\r
17726 \r
17727       // The format specification used by the BigNumber.prototype.toFormat method.\r
17728       FORMAT = {\r
17729         prefix: '',\r
17730         groupSize: 3,\r
17731         secondaryGroupSize: 0,\r
17732         groupSeparator: ',',\r
17733         decimalSeparator: '.',\r
17734         fractionGroupSize: 0,\r
17735         fractionGroupSeparator: '\xA0',      // non-breaking space\r
17736         suffix: ''\r
17737       },\r
17738 \r
17739       // The alphabet used for base conversion. It must be at least 2 characters long, with no '+',\r
17740       // '-', '.', whitespace, or repeated character.\r
17741       // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'\r
17742       ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';\r
17743 \r
17744 \r
17745     //------------------------------------------------------------------------------------------\r
17746 \r
17747 \r
17748     // CONSTRUCTOR\r
17749 \r
17750 \r
17751     /*\r
17752      * The BigNumber constructor and exported function.\r
17753      * Create and return a new instance of a BigNumber object.\r
17754      *\r
17755      * v {number|string|BigNumber} A numeric value.\r
17756      * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.\r
17757      */\r
17758     function BigNumber(v, b) {\r
17759       var alphabet, c, caseChanged, e, i, isNum, len, str,\r
17760         x = this;\r
17761 \r
17762       // Enable constructor call without `new`.\r
17763       if (!(x instanceof BigNumber)) return new BigNumber(v, b);\r
17764 \r
17765       if (b == null) {\r
17766 \r
17767         if (v && v._isBigNumber === true) {\r
17768           x.s = v.s;\r
17769 \r
17770           if (!v.c || v.e > MAX_EXP) {\r
17771             x.c = x.e = null;\r
17772           } else if (v.e < MIN_EXP) {\r
17773             x.c = [x.e = 0];\r
17774           } else {\r
17775             x.e = v.e;\r
17776             x.c = v.c.slice();\r
17777           }\r
17778 \r
17779           return;\r
17780         }\r
17781 \r
17782         if ((isNum = typeof v == 'number') && v * 0 == 0) {\r
17783 \r
17784           // Use `1 / n` to handle minus zero also.\r
17785           x.s = 1 / v < 0 ? (v = -v, -1) : 1;\r
17786 \r
17787           // Fast path for integers, where n < 2147483648 (2**31).\r
17788           if (v === ~~v) {\r
17789             for (e = 0, i = v; i >= 10; i /= 10, e++);\r
17790 \r
17791             if (e > MAX_EXP) {\r
17792               x.c = x.e = null;\r
17793             } else {\r
17794               x.e = e;\r
17795               x.c = [v];\r
17796             }\r
17797 \r
17798             return;\r
17799           }\r
17800 \r
17801           str = String(v);\r
17802         } else {\r
17803 \r
17804           if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);\r
17805 \r
17806           x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;\r
17807         }\r
17808 \r
17809         // Decimal point?\r
17810         if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');\r
17811 \r
17812         // Exponential form?\r
17813         if ((i = str.search(/e/i)) > 0) {\r
17814 \r
17815           // Determine exponent.\r
17816           if (e < 0) e = i;\r
17817           e += +str.slice(i + 1);\r
17818           str = str.substring(0, i);\r
17819         } else if (e < 0) {\r
17820 \r
17821           // Integer.\r
17822           e = str.length;\r
17823         }\r
17824 \r
17825       } else {\r
17826 \r
17827         // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'\r
17828         intCheck(b, 2, ALPHABET.length, 'Base');\r
17829 \r
17830         // Allow exponential notation to be used with base 10 argument, while\r
17831         // also rounding to DECIMAL_PLACES as with other bases.\r
17832         if (b == 10) {\r
17833           x = new BigNumber(v);\r
17834           return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);\r
17835         }\r
17836 \r
17837         str = String(v);\r
17838 \r
17839         if (isNum = typeof v == 'number') {\r
17840 \r
17841           // Avoid potential interpretation of Infinity and NaN as base 44+ values.\r
17842           if (v * 0 != 0) return parseNumeric(x, str, isNum, b);\r
17843 \r
17844           x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;\r
17845 \r
17846           // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'\r
17847           if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {\r
17848             throw Error\r
17849              (tooManyDigits + v);\r
17850           }\r
17851         } else {\r
17852           x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;\r
17853         }\r
17854 \r
17855         alphabet = ALPHABET.slice(0, b);\r
17856         e = i = 0;\r
17857 \r
17858         // Check that str is a valid base b number.\r
17859         // Don't use RegExp, so alphabet can contain special characters.\r
17860         for (len = str.length; i < len; i++) {\r
17861           if (alphabet.indexOf(c = str.charAt(i)) < 0) {\r
17862             if (c == '.') {\r
17863 \r
17864               // If '.' is not the first character and it has not be found before.\r
17865               if (i > e) {\r
17866                 e = len;\r
17867                 continue;\r
17868               }\r
17869             } else if (!caseChanged) {\r
17870 \r
17871               // Allow e.g. hexadecimal 'FF' as well as 'ff'.\r
17872               if (str == str.toUpperCase() && (str = str.toLowerCase()) ||\r
17873                   str == str.toLowerCase() && (str = str.toUpperCase())) {\r
17874                 caseChanged = true;\r
17875                 i = -1;\r
17876                 e = 0;\r
17877                 continue;\r
17878               }\r
17879             }\r
17880 \r
17881             return parseNumeric(x, String(v), isNum, b);\r
17882           }\r
17883         }\r
17884 \r
17885         // Prevent later check for length on converted number.\r
17886         isNum = false;\r
17887         str = convertBase(str, b, 10, x.s);\r
17888 \r
17889         // Decimal point?\r
17890         if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');\r
17891         else e = str.length;\r
17892       }\r
17893 \r
17894       // Determine leading zeros.\r
17895       for (i = 0; str.charCodeAt(i) === 48; i++);\r
17896 \r
17897       // Determine trailing zeros.\r
17898       for (len = str.length; str.charCodeAt(--len) === 48;);\r
17899 \r
17900       if (str = str.slice(i, ++len)) {\r
17901         len -= i;\r
17902 \r
17903         // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'\r
17904         if (isNum && BigNumber.DEBUG &&\r
17905           len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {\r
17906             throw Error\r
17907              (tooManyDigits + (x.s * v));\r
17908         }\r
17909 \r
17910          // Overflow?\r
17911         if ((e = e - i - 1) > MAX_EXP) {\r
17912 \r
17913           // Infinity.\r
17914           x.c = x.e = null;\r
17915 \r
17916         // Underflow?\r
17917         } else if (e < MIN_EXP) {\r
17918 \r
17919           // Zero.\r
17920           x.c = [x.e = 0];\r
17921         } else {\r
17922           x.e = e;\r
17923           x.c = [];\r
17924 \r
17925           // Transform base\r
17926 \r
17927           // e is the base 10 exponent.\r
17928           // i is where to slice str to get the first element of the coefficient array.\r
17929           i = (e + 1) % LOG_BASE;\r
17930           if (e < 0) i += LOG_BASE;  // i < 1\r
17931 \r
17932           if (i < len) {\r
17933             if (i) x.c.push(+str.slice(0, i));\r
17934 \r
17935             for (len -= LOG_BASE; i < len;) {\r
17936               x.c.push(+str.slice(i, i += LOG_BASE));\r
17937             }\r
17938 \r
17939             i = LOG_BASE - (str = str.slice(i)).length;\r
17940           } else {\r
17941             i -= len;\r
17942           }\r
17943 \r
17944           for (; i--; str += '0');\r
17945           x.c.push(+str);\r
17946         }\r
17947       } else {\r
17948 \r
17949         // Zero.\r
17950         x.c = [x.e = 0];\r
17951       }\r
17952     }\r
17953 \r
17954 \r
17955     // CONSTRUCTOR PROPERTIES\r
17956 \r
17957 \r
17958     BigNumber.clone = clone;\r
17959 \r
17960     BigNumber.ROUND_UP = 0;\r
17961     BigNumber.ROUND_DOWN = 1;\r
17962     BigNumber.ROUND_CEIL = 2;\r
17963     BigNumber.ROUND_FLOOR = 3;\r
17964     BigNumber.ROUND_HALF_UP = 4;\r
17965     BigNumber.ROUND_HALF_DOWN = 5;\r
17966     BigNumber.ROUND_HALF_EVEN = 6;\r
17967     BigNumber.ROUND_HALF_CEIL = 7;\r
17968     BigNumber.ROUND_HALF_FLOOR = 8;\r
17969     BigNumber.EUCLID = 9;\r
17970 \r
17971 \r
17972     /*\r
17973      * Configure infrequently-changing library-wide settings.\r
17974      *\r
17975      * Accept an object with the following optional properties (if the value of a property is\r
17976      * a number, it must be an integer within the inclusive range stated):\r
17977      *\r
17978      *   DECIMAL_PLACES   {number}           0 to MAX\r
17979      *   ROUNDING_MODE    {number}           0 to 8\r
17980      *   EXPONENTIAL_AT   {number|number[]}  -MAX to MAX  or  [-MAX to 0, 0 to MAX]\r
17981      *   RANGE            {number|number[]}  -MAX to MAX (not zero)  or  [-MAX to -1, 1 to MAX]\r
17982      *   CRYPTO           {boolean}          true or false\r
17983      *   MODULO_MODE      {number}           0 to 9\r
17984      *   POW_PRECISION       {number}           0 to MAX\r
17985      *   ALPHABET         {string}           A string of two or more unique characters which does\r
17986      *                                       not contain '.'.\r
17987      *   FORMAT           {object}           An object with some of the following properties:\r
17988      *     prefix                 {string}\r
17989      *     groupSize              {number}\r
17990      *     secondaryGroupSize     {number}\r
17991      *     groupSeparator         {string}\r
17992      *     decimalSeparator       {string}\r
17993      *     fractionGroupSize      {number}\r
17994      *     fractionGroupSeparator {string}\r
17995      *     suffix                 {string}\r
17996      *\r
17997      * (The values assigned to the above FORMAT object properties are not checked for validity.)\r
17998      *\r
17999      * E.g.\r
18000      * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })\r
18001      *\r
18002      * Ignore properties/parameters set to null or undefined, except for ALPHABET.\r
18003      *\r
18004      * Return an object with the properties current values.\r
18005      */\r
18006     BigNumber.config = BigNumber.set = function (obj) {\r
18007       var p, v;\r
18008 \r
18009       if (obj != null) {\r
18010 \r
18011         if (typeof obj == 'object') {\r
18012 \r
18013           // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.\r
18014           // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}'\r
18015           if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) {\r
18016             v = obj[p];\r
18017             intCheck(v, 0, MAX, p);\r
18018             DECIMAL_PLACES = v;\r
18019           }\r
18020 \r
18021           // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.\r
18022           // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}'\r
18023           if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) {\r
18024             v = obj[p];\r
18025             intCheck(v, 0, 8, p);\r
18026             ROUNDING_MODE = v;\r
18027           }\r
18028 \r
18029           // EXPONENTIAL_AT {number|number[]}\r
18030           // Integer, -MAX to MAX inclusive or\r
18031           // [integer -MAX to 0 inclusive, 0 to MAX inclusive].\r
18032           // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}'\r
18033           if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) {\r
18034             v = obj[p];\r
18035             if (v && v.pop) {\r
18036               intCheck(v[0], -MAX, 0, p);\r
18037               intCheck(v[1], 0, MAX, p);\r
18038               TO_EXP_NEG = v[0];\r
18039               TO_EXP_POS = v[1];\r
18040             } else {\r
18041               intCheck(v, -MAX, MAX, p);\r
18042               TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);\r
18043             }\r
18044           }\r
18045 \r
18046           // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or\r
18047           // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].\r
18048           // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}'\r
18049           if (obj.hasOwnProperty(p = 'RANGE')) {\r
18050             v = obj[p];\r
18051             if (v && v.pop) {\r
18052               intCheck(v[0], -MAX, -1, p);\r
18053               intCheck(v[1], 1, MAX, p);\r
18054               MIN_EXP = v[0];\r
18055               MAX_EXP = v[1];\r
18056             } else {\r
18057               intCheck(v, -MAX, MAX, p);\r
18058               if (v) {\r
18059                 MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);\r
18060               } else {\r
18061                 throw Error\r
18062                  (bignumberError + p + ' cannot be zero: ' + v);\r
18063               }\r
18064             }\r
18065           }\r
18066 \r
18067           // CRYPTO {boolean} true or false.\r
18068           // '[BigNumber Error] CRYPTO not true or false: {v}'\r
18069           // '[BigNumber Error] crypto unavailable'\r
18070           if (obj.hasOwnProperty(p = 'CRYPTO')) {\r
18071             v = obj[p];\r
18072             if (v === !!v) {\r
18073               if (v) {\r
18074                 if (typeof crypto != 'undefined' && crypto &&\r
18075                  (crypto.getRandomValues || crypto.randomBytes)) {\r
18076                   CRYPTO = v;\r
18077                 } else {\r
18078                   CRYPTO = !v;\r
18079                   throw Error\r
18080                    (bignumberError + 'crypto unavailable');\r
18081                 }\r
18082               } else {\r
18083                 CRYPTO = v;\r
18084               }\r
18085             } else {\r
18086               throw Error\r
18087                (bignumberError + p + ' not true or false: ' + v);\r
18088             }\r
18089           }\r
18090 \r
18091           // MODULO_MODE {number} Integer, 0 to 9 inclusive.\r
18092           // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}'\r
18093           if (obj.hasOwnProperty(p = 'MODULO_MODE')) {\r
18094             v = obj[p];\r
18095             intCheck(v, 0, 9, p);\r
18096             MODULO_MODE = v;\r
18097           }\r
18098 \r
18099           // POW_PRECISION {number} Integer, 0 to MAX inclusive.\r
18100           // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}'\r
18101           if (obj.hasOwnProperty(p = 'POW_PRECISION')) {\r
18102             v = obj[p];\r
18103             intCheck(v, 0, MAX, p);\r
18104             POW_PRECISION = v;\r
18105           }\r
18106 \r
18107           // FORMAT {object}\r
18108           // '[BigNumber Error] FORMAT not an object: {v}'\r
18109           if (obj.hasOwnProperty(p = 'FORMAT')) {\r
18110             v = obj[p];\r
18111             if (typeof v == 'object') FORMAT = v;\r
18112             else throw Error\r
18113              (bignumberError + p + ' not an object: ' + v);\r
18114           }\r
18115 \r
18116           // ALPHABET {string}\r
18117           // '[BigNumber Error] ALPHABET invalid: {v}'\r
18118           if (obj.hasOwnProperty(p = 'ALPHABET')) {\r
18119             v = obj[p];\r
18120 \r
18121             // Disallow if only one character,\r
18122             // or if it contains '+', '-', '.', whitespace, or a repeated character.\r
18123             if (typeof v == 'string' && !/^.$|[+-.\s]|(.).*\1/.test(v)) {\r
18124               ALPHABET = v;\r
18125             } else {\r
18126               throw Error\r
18127                (bignumberError + p + ' invalid: ' + v);\r
18128             }\r
18129           }\r
18130 \r
18131         } else {\r
18132 \r
18133           // '[BigNumber Error] Object expected: {v}'\r
18134           throw Error\r
18135            (bignumberError + 'Object expected: ' + obj);\r
18136         }\r
18137       }\r
18138 \r
18139       return {\r
18140         DECIMAL_PLACES: DECIMAL_PLACES,\r
18141         ROUNDING_MODE: ROUNDING_MODE,\r
18142         EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],\r
18143         RANGE: [MIN_EXP, MAX_EXP],\r
18144         CRYPTO: CRYPTO,\r
18145         MODULO_MODE: MODULO_MODE,\r
18146         POW_PRECISION: POW_PRECISION,\r
18147         FORMAT: FORMAT,\r
18148         ALPHABET: ALPHABET\r
18149       };\r
18150     };\r
18151 \r
18152 \r
18153     /*\r
18154      * Return true if v is a BigNumber instance, otherwise return false.\r
18155      *\r
18156      * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.\r
18157      *\r
18158      * v {any}\r
18159      *\r
18160      * '[BigNumber Error] Invalid BigNumber: {v}'\r
18161      */\r
18162     BigNumber.isBigNumber = function (v) {\r
18163       if (!v || v._isBigNumber !== true) return false;\r
18164       if (!BigNumber.DEBUG) return true;\r
18165 \r
18166       var i, n,\r
18167         c = v.c,\r
18168         e = v.e,\r
18169         s = v.s;\r
18170 \r
18171       out: if ({}.toString.call(c) == '[object Array]') {\r
18172 \r
18173         if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {\r
18174 \r
18175           // If the first element is zero, the BigNumber value must be zero.\r
18176           if (c[0] === 0) {\r
18177             if (e === 0 && c.length === 1) return true;\r
18178             break out;\r
18179           }\r
18180 \r
18181           // Calculate number of digits that c[0] should have, based on the exponent.\r
18182           i = (e + 1) % LOG_BASE;\r
18183           if (i < 1) i += LOG_BASE;\r
18184 \r
18185           // Calculate number of digits of c[0].\r
18186           //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {\r
18187           if (String(c[0]).length == i) {\r
18188 \r
18189             for (i = 0; i < c.length; i++) {\r
18190               n = c[i];\r
18191               if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;\r
18192             }\r
18193 \r
18194             // Last element cannot be zero, unless it is the only element.\r
18195             if (n !== 0) return true;\r
18196           }\r
18197         }\r
18198 \r
18199       // Infinity/NaN\r
18200       } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {\r
18201         return true;\r
18202       }\r
18203 \r
18204       throw Error\r
18205         (bignumberError + 'Invalid BigNumber: ' + v);\r
18206     };\r
18207 \r
18208 \r
18209     /*\r
18210      * Return a new BigNumber whose value is the maximum of the arguments.\r
18211      *\r
18212      * arguments {number|string|BigNumber}\r
18213      */\r
18214     BigNumber.maximum = BigNumber.max = function () {\r
18215       return maxOrMin(arguments, P.lt);\r
18216     };\r
18217 \r
18218 \r
18219     /*\r
18220      * Return a new BigNumber whose value is the minimum of the arguments.\r
18221      *\r
18222      * arguments {number|string|BigNumber}\r
18223      */\r
18224     BigNumber.minimum = BigNumber.min = function () {\r
18225       return maxOrMin(arguments, P.gt);\r
18226     };\r
18227 \r
18228 \r
18229     /*\r
18230      * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,\r
18231      * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing\r
18232      * zeros are produced).\r
18233      *\r
18234      * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.\r
18235      *\r
18236      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}'\r
18237      * '[BigNumber Error] crypto unavailable'\r
18238      */\r
18239     BigNumber.random = (function () {\r
18240       var pow2_53 = 0x20000000000000;\r
18241 \r
18242       // Return a 53 bit integer n, where 0 <= n < 9007199254740992.\r
18243       // Check if Math.random() produces more than 32 bits of randomness.\r
18244       // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.\r
18245       // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.\r
18246       var random53bitInt = (Math.random() * pow2_53) & 0x1fffff\r
18247        ? function () { return mathfloor(Math.random() * pow2_53); }\r
18248        : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +\r
18249          (Math.random() * 0x800000 | 0); };\r
18250 \r
18251       return function (dp) {\r
18252         var a, b, e, k, v,\r
18253           i = 0,\r
18254           c = [],\r
18255           rand = new BigNumber(ONE);\r
18256 \r
18257         if (dp == null) dp = DECIMAL_PLACES;\r
18258         else intCheck(dp, 0, MAX);\r
18259 \r
18260         k = mathceil(dp / LOG_BASE);\r
18261 \r
18262         if (CRYPTO) {\r
18263 \r
18264           // Browsers supporting crypto.getRandomValues.\r
18265           if (crypto.getRandomValues) {\r
18266 \r
18267             a = crypto.getRandomValues(new Uint32Array(k *= 2));\r
18268 \r
18269             for (; i < k;) {\r
18270 \r
18271               // 53 bits:\r
18272               // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)\r
18273               // 11111 11111111 11111111 11111111 11100000 00000000 00000000\r
18274               // ((Math.pow(2, 32) - 1) >>> 11).toString(2)\r
18275               //                                     11111 11111111 11111111\r
18276               // 0x20000 is 2^21.\r
18277               v = a[i] * 0x20000 + (a[i + 1] >>> 11);\r
18278 \r
18279               // Rejection sampling:\r
18280               // 0 <= v < 9007199254740992\r
18281               // Probability that v >= 9e15, is\r
18282               // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251\r
18283               if (v >= 9e15) {\r
18284                 b = crypto.getRandomValues(new Uint32Array(2));\r
18285                 a[i] = b[0];\r
18286                 a[i + 1] = b[1];\r
18287               } else {\r
18288 \r
18289                 // 0 <= v <= 8999999999999999\r
18290                 // 0 <= (v % 1e14) <= 99999999999999\r
18291                 c.push(v % 1e14);\r
18292                 i += 2;\r
18293               }\r
18294             }\r
18295             i = k / 2;\r
18296 \r
18297           // Node.js supporting crypto.randomBytes.\r
18298           } else if (crypto.randomBytes) {\r
18299 \r
18300             // buffer\r
18301             a = crypto.randomBytes(k *= 7);\r
18302 \r
18303             for (; i < k;) {\r
18304 \r
18305               // 0x1000000000000 is 2^48, 0x10000000000 is 2^40\r
18306               // 0x100000000 is 2^32, 0x1000000 is 2^24\r
18307               // 11111 11111111 11111111 11111111 11111111 11111111 11111111\r
18308               // 0 <= v < 9007199254740992\r
18309               v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) +\r
18310                  (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) +\r
18311                  (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];\r
18312 \r
18313               if (v >= 9e15) {\r
18314                 crypto.randomBytes(7).copy(a, i);\r
18315               } else {\r
18316 \r
18317                 // 0 <= (v % 1e14) <= 99999999999999\r
18318                 c.push(v % 1e14);\r
18319                 i += 7;\r
18320               }\r
18321             }\r
18322             i = k / 7;\r
18323           } else {\r
18324             CRYPTO = false;\r
18325             throw Error\r
18326              (bignumberError + 'crypto unavailable');\r
18327           }\r
18328         }\r
18329 \r
18330         // Use Math.random.\r
18331         if (!CRYPTO) {\r
18332 \r
18333           for (; i < k;) {\r
18334             v = random53bitInt();\r
18335             if (v < 9e15) c[i++] = v % 1e14;\r
18336           }\r
18337         }\r
18338 \r
18339         k = c[--i];\r
18340         dp %= LOG_BASE;\r
18341 \r
18342         // Convert trailing digits to zeros according to dp.\r
18343         if (k && dp) {\r
18344           v = POWS_TEN[LOG_BASE - dp];\r
18345           c[i] = mathfloor(k / v) * v;\r
18346         }\r
18347 \r
18348         // Remove trailing elements which are zero.\r
18349         for (; c[i] === 0; c.pop(), i--);\r
18350 \r
18351         // Zero?\r
18352         if (i < 0) {\r
18353           c = [e = 0];\r
18354         } else {\r
18355 \r
18356           // Remove leading elements which are zero and adjust exponent accordingly.\r
18357           for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);\r
18358 \r
18359           // Count the digits of the first element of c to determine leading zeros, and...\r
18360           for (i = 1, v = c[0]; v >= 10; v /= 10, i++);\r
18361 \r
18362           // adjust the exponent accordingly.\r
18363           if (i < LOG_BASE) e -= LOG_BASE - i;\r
18364         }\r
18365 \r
18366         rand.e = e;\r
18367         rand.c = c;\r
18368         return rand;\r
18369       };\r
18370     })();\r
18371 \r
18372 \r
18373     /*\r
18374      * Return a BigNumber whose value is the sum of the arguments.\r
18375      *\r
18376      * arguments {number|string|BigNumber}\r
18377      */\r
18378     BigNumber.sum = function () {\r
18379       var i = 1,\r
18380         args = arguments,\r
18381         sum = new BigNumber(args[0]);\r
18382       for (; i < args.length;) sum = sum.plus(args[i++]);\r
18383       return sum;\r
18384     };\r
18385 \r
18386 \r
18387     // PRIVATE FUNCTIONS\r
18388 \r
18389 \r
18390     // Called by BigNumber and BigNumber.prototype.toString.\r
18391     convertBase = (function () {\r
18392       var decimal = '0123456789';\r
18393 \r
18394       /*\r
18395        * Convert string of baseIn to an array of numbers of baseOut.\r
18396        * Eg. toBaseOut('255', 10, 16) returns [15, 15].\r
18397        * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5].\r
18398        */\r
18399       function toBaseOut(str, baseIn, baseOut, alphabet) {\r
18400         var j,\r
18401           arr = [0],\r
18402           arrL,\r
18403           i = 0,\r
18404           len = str.length;\r
18405 \r
18406         for (; i < len;) {\r
18407           for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);\r
18408 \r
18409           arr[0] += alphabet.indexOf(str.charAt(i++));\r
18410 \r
18411           for (j = 0; j < arr.length; j++) {\r
18412 \r
18413             if (arr[j] > baseOut - 1) {\r
18414               if (arr[j + 1] == null) arr[j + 1] = 0;\r
18415               arr[j + 1] += arr[j] / baseOut | 0;\r
18416               arr[j] %= baseOut;\r
18417             }\r
18418           }\r
18419         }\r
18420 \r
18421         return arr.reverse();\r
18422       }\r
18423 \r
18424       // Convert a numeric string of baseIn to a numeric string of baseOut.\r
18425       // If the caller is toString, we are converting from base 10 to baseOut.\r
18426       // If the caller is BigNumber, we are converting from baseIn to base 10.\r
18427       return function (str, baseIn, baseOut, sign, callerIsToString) {\r
18428         var alphabet, d, e, k, r, x, xc, y,\r
18429           i = str.indexOf('.'),\r
18430           dp = DECIMAL_PLACES,\r
18431           rm = ROUNDING_MODE;\r
18432 \r
18433         // Non-integer.\r
18434         if (i >= 0) {\r
18435           k = POW_PRECISION;\r
18436 \r
18437           // Unlimited precision.\r
18438           POW_PRECISION = 0;\r
18439           str = str.replace('.', '');\r
18440           y = new BigNumber(baseIn);\r
18441           x = y.pow(str.length - i);\r
18442           POW_PRECISION = k;\r
18443 \r
18444           // Convert str as if an integer, then restore the fraction part by dividing the\r
18445           // result by its base raised to a power.\r
18446 \r
18447           y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'),\r
18448            10, baseOut, decimal);\r
18449           y.e = y.c.length;\r
18450         }\r
18451 \r
18452         // Convert the number as integer.\r
18453 \r
18454         xc = toBaseOut(str, baseIn, baseOut, callerIsToString\r
18455          ? (alphabet = ALPHABET, decimal)\r
18456          : (alphabet = decimal, ALPHABET));\r
18457 \r
18458         // xc now represents str as an integer and converted to baseOut. e is the exponent.\r
18459         e = k = xc.length;\r
18460 \r
18461         // Remove trailing zeros.\r
18462         for (; xc[--k] == 0; xc.pop());\r
18463 \r
18464         // Zero?\r
18465         if (!xc[0]) return alphabet.charAt(0);\r
18466 \r
18467         // Does str represent an integer? If so, no need for the division.\r
18468         if (i < 0) {\r
18469           --e;\r
18470         } else {\r
18471           x.c = xc;\r
18472           x.e = e;\r
18473 \r
18474           // The sign is needed for correct rounding.\r
18475           x.s = sign;\r
18476           x = div(x, y, dp, rm, baseOut);\r
18477           xc = x.c;\r
18478           r = x.r;\r
18479           e = x.e;\r
18480         }\r
18481 \r
18482         // xc now represents str converted to baseOut.\r
18483 \r
18484         // THe index of the rounding digit.\r
18485         d = e + dp + 1;\r
18486 \r
18487         // The rounding digit: the digit to the right of the digit that may be rounded up.\r
18488         i = xc[d];\r
18489 \r
18490         // Look at the rounding digits and mode to determine whether to round up.\r
18491 \r
18492         k = baseOut / 2;\r
18493         r = r || d < 0 || xc[d + 1] != null;\r
18494 \r
18495         r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))\r
18496               : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||\r
18497                rm == (x.s < 0 ? 8 : 7));\r
18498 \r
18499         // If the index of the rounding digit is not greater than zero, or xc represents\r
18500         // zero, then the result of the base conversion is zero or, if rounding up, a value\r
18501         // such as 0.00001.\r
18502         if (d < 1 || !xc[0]) {\r
18503 \r
18504           // 1^-dp or 0\r
18505           str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);\r
18506         } else {\r
18507 \r
18508           // Truncate xc to the required number of decimal places.\r
18509           xc.length = d;\r
18510 \r
18511           // Round up?\r
18512           if (r) {\r
18513 \r
18514             // Rounding up may mean the previous digit has to be rounded up and so on.\r
18515             for (--baseOut; ++xc[--d] > baseOut;) {\r
18516               xc[d] = 0;\r
18517 \r
18518               if (!d) {\r
18519                 ++e;\r
18520                 xc = [1].concat(xc);\r
18521               }\r
18522             }\r
18523           }\r
18524 \r
18525           // Determine trailing zeros.\r
18526           for (k = xc.length; !xc[--k];);\r
18527 \r
18528           // E.g. [4, 11, 15] becomes 4bf.\r
18529           for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++]));\r
18530 \r
18531           // Add leading zeros, decimal point and trailing zeros as required.\r
18532           str = toFixedPoint(str, e, alphabet.charAt(0));\r
18533         }\r
18534 \r
18535         // The caller will add the sign.\r
18536         return str;\r
18537       };\r
18538     })();\r
18539 \r
18540 \r
18541     // Perform division in the specified base. Called by div and convertBase.\r
18542     div = (function () {\r
18543 \r
18544       // Assume non-zero x and k.\r
18545       function multiply(x, k, base) {\r
18546         var m, temp, xlo, xhi,\r
18547           carry = 0,\r
18548           i = x.length,\r
18549           klo = k % SQRT_BASE,\r
18550           khi = k / SQRT_BASE | 0;\r
18551 \r
18552         for (x = x.slice(); i--;) {\r
18553           xlo = x[i] % SQRT_BASE;\r
18554           xhi = x[i] / SQRT_BASE | 0;\r
18555           m = khi * xlo + xhi * klo;\r
18556           temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;\r
18557           carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;\r
18558           x[i] = temp % base;\r
18559         }\r
18560 \r
18561         if (carry) x = [carry].concat(x);\r
18562 \r
18563         return x;\r
18564       }\r
18565 \r
18566       function compare(a, b, aL, bL) {\r
18567         var i, cmp;\r
18568 \r
18569         if (aL != bL) {\r
18570           cmp = aL > bL ? 1 : -1;\r
18571         } else {\r
18572 \r
18573           for (i = cmp = 0; i < aL; i++) {\r
18574 \r
18575             if (a[i] != b[i]) {\r
18576               cmp = a[i] > b[i] ? 1 : -1;\r
18577               break;\r
18578             }\r
18579           }\r
18580         }\r
18581 \r
18582         return cmp;\r
18583       }\r
18584 \r
18585       function subtract(a, b, aL, base) {\r
18586         var i = 0;\r
18587 \r
18588         // Subtract b from a.\r
18589         for (; aL--;) {\r
18590           a[aL] -= i;\r
18591           i = a[aL] < b[aL] ? 1 : 0;\r
18592           a[aL] = i * base + a[aL] - b[aL];\r
18593         }\r
18594 \r
18595         // Remove leading zeros.\r
18596         for (; !a[0] && a.length > 1; a.splice(0, 1));\r
18597       }\r
18598 \r
18599       // x: dividend, y: divisor.\r
18600       return function (x, y, dp, rm, base) {\r
18601         var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,\r
18602           yL, yz,\r
18603           s = x.s == y.s ? 1 : -1,\r
18604           xc = x.c,\r
18605           yc = y.c;\r
18606 \r
18607         // Either NaN, Infinity or 0?\r
18608         if (!xc || !xc[0] || !yc || !yc[0]) {\r
18609 \r
18610           return new BigNumber(\r
18611 \r
18612            // Return NaN if either NaN, or both Infinity or 0.\r
18613            !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN :\r
18614 \r
18615             // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.\r
18616             xc && xc[0] == 0 || !yc ? s * 0 : s / 0\r
18617          );\r
18618         }\r
18619 \r
18620         q = new BigNumber(s);\r
18621         qc = q.c = [];\r
18622         e = x.e - y.e;\r
18623         s = dp + e + 1;\r
18624 \r
18625         if (!base) {\r
18626           base = BASE;\r
18627           e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);\r
18628           s = s / LOG_BASE | 0;\r
18629         }\r
18630 \r
18631         // Result exponent may be one less then the current value of e.\r
18632         // The coefficients of the BigNumbers from convertBase may have trailing zeros.\r
18633         for (i = 0; yc[i] == (xc[i] || 0); i++);\r
18634 \r
18635         if (yc[i] > (xc[i] || 0)) e--;\r
18636 \r
18637         if (s < 0) {\r
18638           qc.push(1);\r
18639           more = true;\r
18640         } else {\r
18641           xL = xc.length;\r
18642           yL = yc.length;\r
18643           i = 0;\r
18644           s += 2;\r
18645 \r
18646           // Normalise xc and yc so highest order digit of yc is >= base / 2.\r
18647 \r
18648           n = mathfloor(base / (yc[0] + 1));\r
18649 \r
18650           // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1.\r
18651           // if (n > 1 || n++ == 1 && yc[0] < base / 2) {\r
18652           if (n > 1) {\r
18653             yc = multiply(yc, n, base);\r
18654             xc = multiply(xc, n, base);\r
18655             yL = yc.length;\r
18656             xL = xc.length;\r
18657           }\r
18658 \r
18659           xi = yL;\r
18660           rem = xc.slice(0, yL);\r
18661           remL = rem.length;\r
18662 \r
18663           // Add zeros to make remainder as long as divisor.\r
18664           for (; remL < yL; rem[remL++] = 0);\r
18665           yz = yc.slice();\r
18666           yz = [0].concat(yz);\r
18667           yc0 = yc[0];\r
18668           if (yc[1] >= base / 2) yc0++;\r
18669           // Not necessary, but to prevent trial digit n > base, when using base 3.\r
18670           // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15;\r
18671 \r
18672           do {\r
18673             n = 0;\r
18674 \r
18675             // Compare divisor and remainder.\r
18676             cmp = compare(yc, rem, yL, remL);\r
18677 \r
18678             // If divisor < remainder.\r
18679             if (cmp < 0) {\r
18680 \r
18681               // Calculate trial digit, n.\r
18682 \r
18683               rem0 = rem[0];\r
18684               if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);\r
18685 \r
18686               // n is how many times the divisor goes into the current remainder.\r
18687               n = mathfloor(rem0 / yc0);\r
18688 \r
18689               //  Algorithm:\r
18690               //  product = divisor multiplied by trial digit (n).\r
18691               //  Compare product and remainder.\r
18692               //  If product is greater than remainder:\r
18693               //    Subtract divisor from product, decrement trial digit.\r
18694               //  Subtract product from remainder.\r
18695               //  If product was less than remainder at the last compare:\r
18696               //    Compare new remainder and divisor.\r
18697               //    If remainder is greater than divisor:\r
18698               //      Subtract divisor from remainder, increment trial digit.\r
18699 \r
18700               if (n > 1) {\r
18701 \r
18702                 // n may be > base only when base is 3.\r
18703                 if (n >= base) n = base - 1;\r
18704 \r
18705                 // product = divisor * trial digit.\r
18706                 prod = multiply(yc, n, base);\r
18707                 prodL = prod.length;\r
18708                 remL = rem.length;\r
18709 \r
18710                 // Compare product and remainder.\r
18711                 // If product > remainder then trial digit n too high.\r
18712                 // n is 1 too high about 5% of the time, and is not known to have\r
18713                 // ever been more than 1 too high.\r
18714                 while (compare(prod, rem, prodL, remL) == 1) {\r
18715                   n--;\r
18716 \r
18717                   // Subtract divisor from product.\r
18718                   subtract(prod, yL < prodL ? yz : yc, prodL, base);\r
18719                   prodL = prod.length;\r
18720                   cmp = 1;\r
18721                 }\r
18722               } else {\r
18723 \r
18724                 // n is 0 or 1, cmp is -1.\r
18725                 // If n is 0, there is no need to compare yc and rem again below,\r
18726                 // so change cmp to 1 to avoid it.\r
18727                 // If n is 1, leave cmp as -1, so yc and rem are compared again.\r
18728                 if (n == 0) {\r
18729 \r
18730                   // divisor < remainder, so n must be at least 1.\r
18731                   cmp = n = 1;\r
18732                 }\r
18733 \r
18734                 // product = divisor\r
18735                 prod = yc.slice();\r
18736                 prodL = prod.length;\r
18737               }\r
18738 \r
18739               if (prodL < remL) prod = [0].concat(prod);\r
18740 \r
18741               // Subtract product from remainder.\r
18742               subtract(rem, prod, remL, base);\r
18743               remL = rem.length;\r
18744 \r
18745                // If product was < remainder.\r
18746               if (cmp == -1) {\r
18747 \r
18748                 // Compare divisor and new remainder.\r
18749                 // If divisor < new remainder, subtract divisor from remainder.\r
18750                 // Trial digit n too low.\r
18751                 // n is 1 too low about 5% of the time, and very rarely 2 too low.\r
18752                 while (compare(yc, rem, yL, remL) < 1) {\r
18753                   n++;\r
18754 \r
18755                   // Subtract divisor from remainder.\r
18756                   subtract(rem, yL < remL ? yz : yc, remL, base);\r
18757                   remL = rem.length;\r
18758                 }\r
18759               }\r
18760             } else if (cmp === 0) {\r
18761               n++;\r
18762               rem = [0];\r
18763             } // else cmp === 1 and n will be 0\r
18764 \r
18765             // Add the next digit, n, to the result array.\r
18766             qc[i++] = n;\r
18767 \r
18768             // Update the remainder.\r
18769             if (rem[0]) {\r
18770               rem[remL++] = xc[xi] || 0;\r
18771             } else {\r
18772               rem = [xc[xi]];\r
18773               remL = 1;\r
18774             }\r
18775           } while ((xi++ < xL || rem[0] != null) && s--);\r
18776 \r
18777           more = rem[0] != null;\r
18778 \r
18779           // Leading zero?\r
18780           if (!qc[0]) qc.splice(0, 1);\r
18781         }\r
18782 \r
18783         if (base == BASE) {\r
18784 \r
18785           // To calculate q.e, first get the number of digits of qc[0].\r
18786           for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);\r
18787 \r
18788           round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);\r
18789 \r
18790         // Caller is convertBase.\r
18791         } else {\r
18792           q.e = e;\r
18793           q.r = +more;\r
18794         }\r
18795 \r
18796         return q;\r
18797       };\r
18798     })();\r
18799 \r
18800 \r
18801     /*\r
18802      * Return a string representing the value of BigNumber n in fixed-point or exponential\r
18803      * notation rounded to the specified decimal places or significant digits.\r
18804      *\r
18805      * n: a BigNumber.\r
18806      * i: the index of the last digit required (i.e. the digit that may be rounded up).\r
18807      * rm: the rounding mode.\r
18808      * id: 1 (toExponential) or 2 (toPrecision).\r
18809      */\r
18810     function format(n, i, rm, id) {\r
18811       var c0, e, ne, len, str;\r
18812 \r
18813       if (rm == null) rm = ROUNDING_MODE;\r
18814       else intCheck(rm, 0, 8);\r
18815 \r
18816       if (!n.c) return n.toString();\r
18817 \r
18818       c0 = n.c[0];\r
18819       ne = n.e;\r
18820 \r
18821       if (i == null) {\r
18822         str = coeffToString(n.c);\r
18823         str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS)\r
18824          ? toExponential(str, ne)\r
18825          : toFixedPoint(str, ne, '0');\r
18826       } else {\r
18827         n = round(new BigNumber(n), i, rm);\r
18828 \r
18829         // n.e may have changed if the value was rounded up.\r
18830         e = n.e;\r
18831 \r
18832         str = coeffToString(n.c);\r
18833         len = str.length;\r
18834 \r
18835         // toPrecision returns exponential notation if the number of significant digits\r
18836         // specified is less than the number of digits necessary to represent the integer\r
18837         // part of the value in fixed-point notation.\r
18838 \r
18839         // Exponential notation.\r
18840         if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {\r
18841 \r
18842           // Append zeros?\r
18843           for (; len < i; str += '0', len++);\r
18844           str = toExponential(str, e);\r
18845 \r
18846         // Fixed-point notation.\r
18847         } else {\r
18848           i -= ne;\r
18849           str = toFixedPoint(str, e, '0');\r
18850 \r
18851           // Append zeros?\r
18852           if (e + 1 > len) {\r
18853             if (--i > 0) for (str += '.'; i--; str += '0');\r
18854           } else {\r
18855             i += e - len;\r
18856             if (i > 0) {\r
18857               if (e + 1 == len) str += '.';\r
18858               for (; i--; str += '0');\r
18859             }\r
18860           }\r
18861         }\r
18862       }\r
18863 \r
18864       return n.s < 0 && c0 ? '-' + str : str;\r
18865     }\r
18866 \r
18867 \r
18868     // Handle BigNumber.max and BigNumber.min.\r
18869     function maxOrMin(args, method) {\r
18870       var n,\r
18871         i = 1,\r
18872         m = new BigNumber(args[0]);\r
18873 \r
18874       for (; i < args.length; i++) {\r
18875         n = new BigNumber(args[i]);\r
18876 \r
18877         // If any number is NaN, return NaN.\r
18878         if (!n.s) {\r
18879           m = n;\r
18880           break;\r
18881         } else if (method.call(m, n)) {\r
18882           m = n;\r
18883         }\r
18884       }\r
18885 \r
18886       return m;\r
18887     }\r
18888 \r
18889 \r
18890     /*\r
18891      * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.\r
18892      * Called by minus, plus and times.\r
18893      */\r
18894     function normalise(n, c, e) {\r
18895       var i = 1,\r
18896         j = c.length;\r
18897 \r
18898        // Remove trailing zeros.\r
18899       for (; !c[--j]; c.pop());\r
18900 \r
18901       // Calculate the base 10 exponent. First get the number of digits of c[0].\r
18902       for (j = c[0]; j >= 10; j /= 10, i++);\r
18903 \r
18904       // Overflow?\r
18905       if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {\r
18906 \r
18907         // Infinity.\r
18908         n.c = n.e = null;\r
18909 \r
18910       // Underflow?\r
18911       } else if (e < MIN_EXP) {\r
18912 \r
18913         // Zero.\r
18914         n.c = [n.e = 0];\r
18915       } else {\r
18916         n.e = e;\r
18917         n.c = c;\r
18918       }\r
18919 \r
18920       return n;\r
18921     }\r
18922 \r
18923 \r
18924     // Handle values that fail the validity test in BigNumber.\r
18925     parseNumeric = (function () {\r
18926       var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,\r
18927         dotAfter = /^([^.]+)\.$/,\r
18928         dotBefore = /^\.([^.]+)$/,\r
18929         isInfinityOrNaN = /^-?(Infinity|NaN)$/,\r
18930         whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;\r
18931 \r
18932       return function (x, str, isNum, b) {\r
18933         var base,\r
18934           s = isNum ? str : str.replace(whitespaceOrPlus, '');\r
18935 \r
18936         // No exception on ±Infinity or NaN.\r
18937         if (isInfinityOrNaN.test(s)) {\r
18938           x.s = isNaN(s) ? null : s < 0 ? -1 : 1;\r
18939         } else {\r
18940           if (!isNum) {\r
18941 \r
18942             // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i\r
18943             s = s.replace(basePrefix, function (m, p1, p2) {\r
18944               base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;\r
18945               return !b || b == base ? p1 : m;\r
18946             });\r
18947 \r
18948             if (b) {\r
18949               base = b;\r
18950 \r
18951               // E.g. '1.' to '1', '.1' to '0.1'\r
18952               s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');\r
18953             }\r
18954 \r
18955             if (str != s) return new BigNumber(s, base);\r
18956           }\r
18957 \r
18958           // '[BigNumber Error] Not a number: {n}'\r
18959           // '[BigNumber Error] Not a base {b} number: {n}'\r
18960           if (BigNumber.DEBUG) {\r
18961             throw Error\r
18962               (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);\r
18963           }\r
18964 \r
18965           // NaN\r
18966           x.s = null;\r
18967         }\r
18968 \r
18969         x.c = x.e = null;\r
18970       }\r
18971     })();\r
18972 \r
18973 \r
18974     /*\r
18975      * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.\r
18976      * If r is truthy, it is known that there are more digits after the rounding digit.\r
18977      */\r
18978     function round(x, sd, rm, r) {\r
18979       var d, i, j, k, n, ni, rd,\r
18980         xc = x.c,\r
18981         pows10 = POWS_TEN;\r
18982 \r
18983       // if x is not Infinity or NaN...\r
18984       if (xc) {\r
18985 \r
18986         // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.\r
18987         // n is a base 1e14 number, the value of the element of array x.c containing rd.\r
18988         // ni is the index of n within x.c.\r
18989         // d is the number of digits of n.\r
18990         // i is the index of rd within n including leading zeros.\r
18991         // j is the actual index of rd within n (if < 0, rd is a leading zero).\r
18992         out: {\r
18993 \r
18994           // Get the number of digits of the first element of xc.\r
18995           for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);\r
18996           i = sd - d;\r
18997 \r
18998           // If the rounding digit is in the first element of xc...\r
18999           if (i < 0) {\r
19000             i += LOG_BASE;\r
19001             j = sd;\r
19002             n = xc[ni = 0];\r
19003 \r
19004             // Get the rounding digit at index j of n.\r
19005             rd = n / pows10[d - j - 1] % 10 | 0;\r
19006           } else {\r
19007             ni = mathceil((i + 1) / LOG_BASE);\r
19008 \r
19009             if (ni >= xc.length) {\r
19010 \r
19011               if (r) {\r
19012 \r
19013                 // Needed by sqrt.\r
19014                 for (; xc.length <= ni; xc.push(0));\r
19015                 n = rd = 0;\r
19016                 d = 1;\r
19017                 i %= LOG_BASE;\r
19018                 j = i - LOG_BASE + 1;\r
19019               } else {\r
19020                 break out;\r
19021               }\r
19022             } else {\r
19023               n = k = xc[ni];\r
19024 \r
19025               // Get the number of digits of n.\r
19026               for (d = 1; k >= 10; k /= 10, d++);\r
19027 \r
19028               // Get the index of rd within n.\r
19029               i %= LOG_BASE;\r
19030 \r
19031               // Get the index of rd within n, adjusted for leading zeros.\r
19032               // The number of leading zeros of n is given by LOG_BASE - d.\r
19033               j = i - LOG_BASE + d;\r
19034 \r
19035               // Get the rounding digit at index j of n.\r
19036               rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0;\r
19037             }\r
19038           }\r
19039 \r
19040           r = r || sd < 0 ||\r
19041 \r
19042           // Are there any non-zero digits after the rounding digit?\r
19043           // The expression  n % pows10[d - j - 1]  returns all digits of n to the right\r
19044           // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.\r
19045            xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);\r
19046 \r
19047           r = rm < 4\r
19048            ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))\r
19049            : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 &&\r
19050 \r
19051             // Check whether the digit to the left of the rounding digit is odd.\r
19052             ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 ||\r
19053              rm == (x.s < 0 ? 8 : 7));\r
19054 \r
19055           if (sd < 1 || !xc[0]) {\r
19056             xc.length = 0;\r
19057 \r
19058             if (r) {\r
19059 \r
19060               // Convert sd to decimal places.\r
19061               sd -= x.e + 1;\r
19062 \r
19063               // 1, 0.1, 0.01, 0.001, 0.0001 etc.\r
19064               xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];\r
19065               x.e = -sd || 0;\r
19066             } else {\r
19067 \r
19068               // Zero.\r
19069               xc[0] = x.e = 0;\r
19070             }\r
19071 \r
19072             return x;\r
19073           }\r
19074 \r
19075           // Remove excess digits.\r
19076           if (i == 0) {\r
19077             xc.length = ni;\r
19078             k = 1;\r
19079             ni--;\r
19080           } else {\r
19081             xc.length = ni + 1;\r
19082             k = pows10[LOG_BASE - i];\r
19083 \r
19084             // E.g. 56700 becomes 56000 if 7 is the rounding digit.\r
19085             // j > 0 means i > number of leading zeros of n.\r
19086             xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;\r
19087           }\r
19088 \r
19089           // Round up?\r
19090           if (r) {\r
19091 \r
19092             for (; ;) {\r
19093 \r
19094               // If the digit to be rounded up is in the first element of xc...\r
19095               if (ni == 0) {\r
19096 \r
19097                 // i will be the length of xc[0] before k is added.\r
19098                 for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);\r
19099                 j = xc[0] += k;\r
19100                 for (k = 1; j >= 10; j /= 10, k++);\r
19101 \r
19102                 // if i != k the length has increased.\r
19103                 if (i != k) {\r
19104                   x.e++;\r
19105                   if (xc[0] == BASE) xc[0] = 1;\r
19106                 }\r
19107 \r
19108                 break;\r
19109               } else {\r
19110                 xc[ni] += k;\r
19111                 if (xc[ni] != BASE) break;\r
19112                 xc[ni--] = 0;\r
19113                 k = 1;\r
19114               }\r
19115             }\r
19116           }\r
19117 \r
19118           // Remove trailing zeros.\r
19119           for (i = xc.length; xc[--i] === 0; xc.pop());\r
19120         }\r
19121 \r
19122         // Overflow? Infinity.\r
19123         if (x.e > MAX_EXP) {\r
19124           x.c = x.e = null;\r
19125 \r
19126         // Underflow? Zero.\r
19127         } else if (x.e < MIN_EXP) {\r
19128           x.c = [x.e = 0];\r
19129         }\r
19130       }\r
19131 \r
19132       return x;\r
19133     }\r
19134 \r
19135 \r
19136     function valueOf(n) {\r
19137       var str,\r
19138         e = n.e;\r
19139 \r
19140       if (e === null) return n.toString();\r
19141 \r
19142       str = coeffToString(n.c);\r
19143 \r
19144       str = e <= TO_EXP_NEG || e >= TO_EXP_POS\r
19145         ? toExponential(str, e)\r
19146         : toFixedPoint(str, e, '0');\r
19147 \r
19148       return n.s < 0 ? '-' + str : str;\r
19149     }\r
19150 \r
19151 \r
19152     // PROTOTYPE/INSTANCE METHODS\r
19153 \r
19154 \r
19155     /*\r
19156      * Return a new BigNumber whose value is the absolute value of this BigNumber.\r
19157      */\r
19158     P.absoluteValue = P.abs = function () {\r
19159       var x = new BigNumber(this);\r
19160       if (x.s < 0) x.s = 1;\r
19161       return x;\r
19162     };\r
19163 \r
19164 \r
19165     /*\r
19166      * Return\r
19167      *   1 if the value of this BigNumber is greater than the value of BigNumber(y, b),\r
19168      *   -1 if the value of this BigNumber is less than the value of BigNumber(y, b),\r
19169      *   0 if they have the same value,\r
19170      *   or null if the value of either is NaN.\r
19171      */\r
19172     P.comparedTo = function (y, b) {\r
19173       return compare(this, new BigNumber(y, b));\r
19174     };\r
19175 \r
19176 \r
19177     /*\r
19178      * If dp is undefined or null or true or false, return the number of decimal places of the\r
19179      * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.\r
19180      *\r
19181      * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this\r
19182      * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or\r
19183      * ROUNDING_MODE if rm is omitted.\r
19184      *\r
19185      * [dp] {number} Decimal places: integer, 0 to MAX inclusive.\r
19186      * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.\r
19187      *\r
19188      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'\r
19189      */\r
19190     P.decimalPlaces = P.dp = function (dp, rm) {\r
19191       var c, n, v,\r
19192         x = this;\r
19193 \r
19194       if (dp != null) {\r
19195         intCheck(dp, 0, MAX);\r
19196         if (rm == null) rm = ROUNDING_MODE;\r
19197         else intCheck(rm, 0, 8);\r
19198 \r
19199         return round(new BigNumber(x), dp + x.e + 1, rm);\r
19200       }\r
19201 \r
19202       if (!(c = x.c)) return null;\r
19203       n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;\r
19204 \r
19205       // Subtract the number of trailing zeros of the last number.\r
19206       if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);\r
19207       if (n < 0) n = 0;\r
19208 \r
19209       return n;\r
19210     };\r
19211 \r
19212 \r
19213     /*\r
19214      *  n / 0 = I\r
19215      *  n / N = N\r
19216      *  n / I = 0\r
19217      *  0 / n = 0\r
19218      *  0 / 0 = N\r
19219      *  0 / N = N\r
19220      *  0 / I = 0\r
19221      *  N / n = N\r
19222      *  N / 0 = N\r
19223      *  N / N = N\r
19224      *  N / I = N\r
19225      *  I / n = I\r
19226      *  I / 0 = I\r
19227      *  I / N = N\r
19228      *  I / I = N\r
19229      *\r
19230      * Return a new BigNumber whose value is the value of this BigNumber divided by the value of\r
19231      * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.\r
19232      */\r
19233     P.dividedBy = P.div = function (y, b) {\r
19234       return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE);\r
19235     };\r
19236 \r
19237 \r
19238     /*\r
19239      * Return a new BigNumber whose value is the integer part of dividing the value of this\r
19240      * BigNumber by the value of BigNumber(y, b).\r
19241      */\r
19242     P.dividedToIntegerBy = P.idiv = function (y, b) {\r
19243       return div(this, new BigNumber(y, b), 0, 1);\r
19244     };\r
19245 \r
19246 \r
19247     /*\r
19248      * Return a BigNumber whose value is the value of this BigNumber exponentiated by n.\r
19249      *\r
19250      * If m is present, return the result modulo m.\r
19251      * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.\r
19252      * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE.\r
19253      *\r
19254      * The modular power operation works efficiently when x, n, and m are integers, otherwise it\r
19255      * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0.\r
19256      *\r
19257      * n {number|string|BigNumber} The exponent. An integer.\r
19258      * [m] {number|string|BigNumber} The modulus.\r
19259      *\r
19260      * '[BigNumber Error] Exponent not an integer: {n}'\r
19261      */\r
19262     P.exponentiatedBy = P.pow = function (n, m) {\r
19263       var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y,\r
19264         x = this;\r
19265 \r
19266       n = new BigNumber(n);\r
19267 \r
19268       // Allow NaN and ±Infinity, but not other non-integers.\r
19269       if (n.c && !n.isInteger()) {\r
19270         throw Error\r
19271           (bignumberError + 'Exponent not an integer: ' + valueOf(n));\r
19272       }\r
19273 \r
19274       if (m != null) m = new BigNumber(m);\r
19275 \r
19276       // Exponent of MAX_SAFE_INTEGER is 15.\r
19277       nIsBig = n.e > 14;\r
19278 \r
19279       // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0.\r
19280       if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {\r
19281 \r
19282         // The sign of the result of pow when x is negative depends on the evenness of n.\r
19283         // If +n overflows to ±Infinity, the evenness of n would be not be known.\r
19284         y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? 2 - isOdd(n) : +valueOf(n)));\r
19285         return m ? y.mod(m) : y;\r
19286       }\r
19287 \r
19288       nIsNeg = n.s < 0;\r
19289 \r
19290       if (m) {\r
19291 \r
19292         // x % m returns NaN if abs(m) is zero, or m is NaN.\r
19293         if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN);\r
19294 \r
19295         isModExp = !nIsNeg && x.isInteger() && m.isInteger();\r
19296 \r
19297         if (isModExp) x = x.mod(m);\r
19298 \r
19299       // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15.\r
19300       // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15.\r
19301       } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0\r
19302         // [1, 240000000]\r
19303         ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7\r
19304         // [80000000000000]  [99999750000000]\r
19305         : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {\r
19306 \r
19307         // If x is negative and n is odd, k = -0, else k = 0.\r
19308         k = x.s < 0 && isOdd(n) ? -0 : 0;\r
19309 \r
19310         // If x >= 1, k = ±Infinity.\r
19311         if (x.e > -1) k = 1 / k;\r
19312 \r
19313         // If n is negative return ±0, else return ±Infinity.\r
19314         return new BigNumber(nIsNeg ? 1 / k : k);\r
19315 \r
19316       } else if (POW_PRECISION) {\r
19317 \r
19318         // Truncating each coefficient array to a length of k after each multiplication\r
19319         // equates to truncating significant digits to POW_PRECISION + [28, 41],\r
19320         // i.e. there will be a minimum of 28 guard digits retained.\r
19321         k = mathceil(POW_PRECISION / LOG_BASE + 2);\r
19322       }\r
19323 \r
19324       if (nIsBig) {\r
19325         half = new BigNumber(0.5);\r
19326         if (nIsNeg) n.s = 1;\r
19327         nIsOdd = isOdd(n);\r
19328       } else {\r
19329         i = Math.abs(+valueOf(n));\r
19330         nIsOdd = i % 2;\r
19331       }\r
19332 \r
19333       y = new BigNumber(ONE);\r
19334 \r
19335       // Performs 54 loop iterations for n of 9007199254740991.\r
19336       for (; ;) {\r
19337 \r
19338         if (nIsOdd) {\r
19339           y = y.times(x);\r
19340           if (!y.c) break;\r
19341 \r
19342           if (k) {\r
19343             if (y.c.length > k) y.c.length = k;\r
19344           } else if (isModExp) {\r
19345             y = y.mod(m);    //y = y.minus(div(y, m, 0, MODULO_MODE).times(m));\r
19346           }\r
19347         }\r
19348 \r
19349         if (i) {\r
19350           i = mathfloor(i / 2);\r
19351           if (i === 0) break;\r
19352           nIsOdd = i % 2;\r
19353         } else {\r
19354           n = n.times(half);\r
19355           round(n, n.e + 1, 1);\r
19356 \r
19357           if (n.e > 14) {\r
19358             nIsOdd = isOdd(n);\r
19359           } else {\r
19360             i = +valueOf(n);\r
19361             if (i === 0) break;\r
19362             nIsOdd = i % 2;\r
19363           }\r
19364         }\r
19365 \r
19366         x = x.times(x);\r
19367 \r
19368         if (k) {\r
19369           if (x.c && x.c.length > k) x.c.length = k;\r
19370         } else if (isModExp) {\r
19371           x = x.mod(m);    //x = x.minus(div(x, m, 0, MODULO_MODE).times(m));\r
19372         }\r
19373       }\r
19374 \r
19375       if (isModExp) return y;\r
19376       if (nIsNeg) y = ONE.div(y);\r
19377 \r
19378       return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;\r
19379     };\r
19380 \r
19381 \r
19382     /*\r
19383      * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer\r
19384      * using rounding mode rm, or ROUNDING_MODE if rm is omitted.\r
19385      *\r
19386      * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.\r
19387      *\r
19388      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}'\r
19389      */\r
19390     P.integerValue = function (rm) {\r
19391       var n = new BigNumber(this);\r
19392       if (rm == null) rm = ROUNDING_MODE;\r
19393       else intCheck(rm, 0, 8);\r
19394       return round(n, n.e + 1, rm);\r
19395     };\r
19396 \r
19397 \r
19398     /*\r
19399      * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),\r
19400      * otherwise return false.\r
19401      */\r
19402     P.isEqualTo = P.eq = function (y, b) {\r
19403       return compare(this, new BigNumber(y, b)) === 0;\r
19404     };\r
19405 \r
19406 \r
19407     /*\r
19408      * Return true if the value of this BigNumber is a finite number, otherwise return false.\r
19409      */\r
19410     P.isFinite = function () {\r
19411       return !!this.c;\r
19412     };\r
19413 \r
19414 \r
19415     /*\r
19416      * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),\r
19417      * otherwise return false.\r
19418      */\r
19419     P.isGreaterThan = P.gt = function (y, b) {\r
19420       return compare(this, new BigNumber(y, b)) > 0;\r
19421     };\r
19422 \r
19423 \r
19424     /*\r
19425      * Return true if the value of this BigNumber is greater than or equal to the value of\r
19426      * BigNumber(y, b), otherwise return false.\r
19427      */\r
19428     P.isGreaterThanOrEqualTo = P.gte = function (y, b) {\r
19429       return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0;\r
19430 \r
19431     };\r
19432 \r
19433 \r
19434     /*\r
19435      * Return true if the value of this BigNumber is an integer, otherwise return false.\r
19436      */\r
19437     P.isInteger = function () {\r
19438       return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;\r
19439     };\r
19440 \r
19441 \r
19442     /*\r
19443      * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),\r
19444      * otherwise return false.\r
19445      */\r
19446     P.isLessThan = P.lt = function (y, b) {\r
19447       return compare(this, new BigNumber(y, b)) < 0;\r
19448     };\r
19449 \r
19450 \r
19451     /*\r
19452      * Return true if the value of this BigNumber is less than or equal to the value of\r
19453      * BigNumber(y, b), otherwise return false.\r
19454      */\r
19455     P.isLessThanOrEqualTo = P.lte = function (y, b) {\r
19456       return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0;\r
19457     };\r
19458 \r
19459 \r
19460     /*\r
19461      * Return true if the value of this BigNumber is NaN, otherwise return false.\r
19462      */\r
19463     P.isNaN = function () {\r
19464       return !this.s;\r
19465     };\r
19466 \r
19467 \r
19468     /*\r
19469      * Return true if the value of this BigNumber is negative, otherwise return false.\r
19470      */\r
19471     P.isNegative = function () {\r
19472       return this.s < 0;\r
19473     };\r
19474 \r
19475 \r
19476     /*\r
19477      * Return true if the value of this BigNumber is positive, otherwise return false.\r
19478      */\r
19479     P.isPositive = function () {\r
19480       return this.s > 0;\r
19481     };\r
19482 \r
19483 \r
19484     /*\r
19485      * Return true if the value of this BigNumber is 0 or -0, otherwise return false.\r
19486      */\r
19487     P.isZero = function () {\r
19488       return !!this.c && this.c[0] == 0;\r
19489     };\r
19490 \r
19491 \r
19492     /*\r
19493      *  n - 0 = n\r
19494      *  n - N = N\r
19495      *  n - I = -I\r
19496      *  0 - n = -n\r
19497      *  0 - 0 = 0\r
19498      *  0 - N = N\r
19499      *  0 - I = -I\r
19500      *  N - n = N\r
19501      *  N - 0 = N\r
19502      *  N - N = N\r
19503      *  N - I = N\r
19504      *  I - n = I\r
19505      *  I - 0 = I\r
19506      *  I - N = N\r
19507      *  I - I = N\r
19508      *\r
19509      * Return a new BigNumber whose value is the value of this BigNumber minus the value of\r
19510      * BigNumber(y, b).\r
19511      */\r
19512     P.minus = function (y, b) {\r
19513       var i, j, t, xLTy,\r
19514         x = this,\r
19515         a = x.s;\r
19516 \r
19517       y = new BigNumber(y, b);\r
19518       b = y.s;\r
19519 \r
19520       // Either NaN?\r
19521       if (!a || !b) return new BigNumber(NaN);\r
19522 \r
19523       // Signs differ?\r
19524       if (a != b) {\r
19525         y.s = -b;\r
19526         return x.plus(y);\r
19527       }\r
19528 \r
19529       var xe = x.e / LOG_BASE,\r
19530         ye = y.e / LOG_BASE,\r
19531         xc = x.c,\r
19532         yc = y.c;\r
19533 \r
19534       if (!xe || !ye) {\r
19535 \r
19536         // Either Infinity?\r
19537         if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN);\r
19538 \r
19539         // Either zero?\r
19540         if (!xc[0] || !yc[0]) {\r
19541 \r
19542           // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.\r
19543           return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x :\r
19544 \r
19545            // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity\r
19546            ROUNDING_MODE == 3 ? -0 : 0);\r
19547         }\r
19548       }\r
19549 \r
19550       xe = bitFloor(xe);\r
19551       ye = bitFloor(ye);\r
19552       xc = xc.slice();\r
19553 \r
19554       // Determine which is the bigger number.\r
19555       if (a = xe - ye) {\r
19556 \r
19557         if (xLTy = a < 0) {\r
19558           a = -a;\r
19559           t = xc;\r
19560         } else {\r
19561           ye = xe;\r
19562           t = yc;\r
19563         }\r
19564 \r
19565         t.reverse();\r
19566 \r
19567         // Prepend zeros to equalise exponents.\r
19568         for (b = a; b--; t.push(0));\r
19569         t.reverse();\r
19570       } else {\r
19571 \r
19572         // Exponents equal. Check digit by digit.\r
19573         j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;\r
19574 \r
19575         for (a = b = 0; b < j; b++) {\r
19576 \r
19577           if (xc[b] != yc[b]) {\r
19578             xLTy = xc[b] < yc[b];\r
19579             break;\r
19580           }\r
19581         }\r
19582       }\r
19583 \r
19584       // x < y? Point xc to the array of the bigger number.\r
19585       if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;\r
19586 \r
19587       b = (j = yc.length) - (i = xc.length);\r
19588 \r
19589       // Append zeros to xc if shorter.\r
19590       // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.\r
19591       if (b > 0) for (; b--; xc[i++] = 0);\r
19592       b = BASE - 1;\r
19593 \r
19594       // Subtract yc from xc.\r
19595       for (; j > a;) {\r
19596 \r
19597         if (xc[--j] < yc[j]) {\r
19598           for (i = j; i && !xc[--i]; xc[i] = b);\r
19599           --xc[i];\r
19600           xc[j] += BASE;\r
19601         }\r
19602 \r
19603         xc[j] -= yc[j];\r
19604       }\r
19605 \r
19606       // Remove leading zeros and adjust exponent accordingly.\r
19607       for (; xc[0] == 0; xc.splice(0, 1), --ye);\r
19608 \r
19609       // Zero?\r
19610       if (!xc[0]) {\r
19611 \r
19612         // Following IEEE 754 (2008) 6.3,\r
19613         // n - n = +0  but  n - n = -0  when rounding towards -Infinity.\r
19614         y.s = ROUNDING_MODE == 3 ? -1 : 1;\r
19615         y.c = [y.e = 0];\r
19616         return y;\r
19617       }\r
19618 \r
19619       // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity\r
19620       // for finite x and y.\r
19621       return normalise(y, xc, ye);\r
19622     };\r
19623 \r
19624 \r
19625     /*\r
19626      *   n % 0 =  N\r
19627      *   n % N =  N\r
19628      *   n % I =  n\r
19629      *   0 % n =  0\r
19630      *  -0 % n = -0\r
19631      *   0 % 0 =  N\r
19632      *   0 % N =  N\r
19633      *   0 % I =  0\r
19634      *   N % n =  N\r
19635      *   N % 0 =  N\r
19636      *   N % N =  N\r
19637      *   N % I =  N\r
19638      *   I % n =  N\r
19639      *   I % 0 =  N\r
19640      *   I % N =  N\r
19641      *   I % I =  N\r
19642      *\r
19643      * Return a new BigNumber whose value is the value of this BigNumber modulo the value of\r
19644      * BigNumber(y, b). The result depends on the value of MODULO_MODE.\r
19645      */\r
19646     P.modulo = P.mod = function (y, b) {\r
19647       var q, s,\r
19648         x = this;\r
19649 \r
19650       y = new BigNumber(y, b);\r
19651 \r
19652       // Return NaN if x is Infinity or NaN, or y is NaN or zero.\r
19653       if (!x.c || !y.s || y.c && !y.c[0]) {\r
19654         return new BigNumber(NaN);\r
19655 \r
19656       // Return x if y is Infinity or x is zero.\r
19657       } else if (!y.c || x.c && !x.c[0]) {\r
19658         return new BigNumber(x);\r
19659       }\r
19660 \r
19661       if (MODULO_MODE == 9) {\r
19662 \r
19663         // Euclidian division: q = sign(y) * floor(x / abs(y))\r
19664         // r = x - qy    where  0 <= r < abs(y)\r
19665         s = y.s;\r
19666         y.s = 1;\r
19667         q = div(x, y, 0, 3);\r
19668         y.s = s;\r
19669         q.s *= s;\r
19670       } else {\r
19671         q = div(x, y, 0, MODULO_MODE);\r
19672       }\r
19673 \r
19674       y = x.minus(q.times(y));\r
19675 \r
19676       // To match JavaScript %, ensure sign of zero is sign of dividend.\r
19677       if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;\r
19678 \r
19679       return y;\r
19680     };\r
19681 \r
19682 \r
19683     /*\r
19684      *  n * 0 = 0\r
19685      *  n * N = N\r
19686      *  n * I = I\r
19687      *  0 * n = 0\r
19688      *  0 * 0 = 0\r
19689      *  0 * N = N\r
19690      *  0 * I = N\r
19691      *  N * n = N\r
19692      *  N * 0 = N\r
19693      *  N * N = N\r
19694      *  N * I = N\r
19695      *  I * n = I\r
19696      *  I * 0 = N\r
19697      *  I * N = N\r
19698      *  I * I = I\r
19699      *\r
19700      * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value\r
19701      * of BigNumber(y, b).\r
19702      */\r
19703     P.multipliedBy = P.times = function (y, b) {\r
19704       var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,\r
19705         base, sqrtBase,\r
19706         x = this,\r
19707         xc = x.c,\r
19708         yc = (y = new BigNumber(y, b)).c;\r
19709 \r
19710       // Either NaN, ±Infinity or ±0?\r
19711       if (!xc || !yc || !xc[0] || !yc[0]) {\r
19712 \r
19713         // Return NaN if either is NaN, or one is 0 and the other is Infinity.\r
19714         if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {\r
19715           y.c = y.e = y.s = null;\r
19716         } else {\r
19717           y.s *= x.s;\r
19718 \r
19719           // Return ±Infinity if either is ±Infinity.\r
19720           if (!xc || !yc) {\r
19721             y.c = y.e = null;\r
19722 \r
19723           // Return ±0 if either is ±0.\r
19724           } else {\r
19725             y.c = [0];\r
19726             y.e = 0;\r
19727           }\r
19728         }\r
19729 \r
19730         return y;\r
19731       }\r
19732 \r
19733       e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);\r
19734       y.s *= x.s;\r
19735       xcL = xc.length;\r
19736       ycL = yc.length;\r
19737 \r
19738       // Ensure xc points to longer array and xcL to its length.\r
19739       if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;\r
19740 \r
19741       // Initialise the result array with zeros.\r
19742       for (i = xcL + ycL, zc = []; i--; zc.push(0));\r
19743 \r
19744       base = BASE;\r
19745       sqrtBase = SQRT_BASE;\r
19746 \r
19747       for (i = ycL; --i >= 0;) {\r
19748         c = 0;\r
19749         ylo = yc[i] % sqrtBase;\r
19750         yhi = yc[i] / sqrtBase | 0;\r
19751 \r
19752         for (k = xcL, j = i + k; j > i;) {\r
19753           xlo = xc[--k] % sqrtBase;\r
19754           xhi = xc[k] / sqrtBase | 0;\r
19755           m = yhi * xlo + xhi * ylo;\r
19756           xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c;\r
19757           c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;\r
19758           zc[j--] = xlo % base;\r
19759         }\r
19760 \r
19761         zc[j] = c;\r
19762       }\r
19763 \r
19764       if (c) {\r
19765         ++e;\r
19766       } else {\r
19767         zc.splice(0, 1);\r
19768       }\r
19769 \r
19770       return normalise(y, zc, e);\r
19771     };\r
19772 \r
19773 \r
19774     /*\r
19775      * Return a new BigNumber whose value is the value of this BigNumber negated,\r
19776      * i.e. multiplied by -1.\r
19777      */\r
19778     P.negated = function () {\r
19779       var x = new BigNumber(this);\r
19780       x.s = -x.s || null;\r
19781       return x;\r
19782     };\r
19783 \r
19784 \r
19785     /*\r
19786      *  n + 0 = n\r
19787      *  n + N = N\r
19788      *  n + I = I\r
19789      *  0 + n = n\r
19790      *  0 + 0 = 0\r
19791      *  0 + N = N\r
19792      *  0 + I = I\r
19793      *  N + n = N\r
19794      *  N + 0 = N\r
19795      *  N + N = N\r
19796      *  N + I = N\r
19797      *  I + n = I\r
19798      *  I + 0 = I\r
19799      *  I + N = N\r
19800      *  I + I = I\r
19801      *\r
19802      * Return a new BigNumber whose value is the value of this BigNumber plus the value of\r
19803      * BigNumber(y, b).\r
19804      */\r
19805     P.plus = function (y, b) {\r
19806       var t,\r
19807         x = this,\r
19808         a = x.s;\r
19809 \r
19810       y = new BigNumber(y, b);\r
19811       b = y.s;\r
19812 \r
19813       // Either NaN?\r
19814       if (!a || !b) return new BigNumber(NaN);\r
19815 \r
19816       // Signs differ?\r
19817        if (a != b) {\r
19818         y.s = -b;\r
19819         return x.minus(y);\r
19820       }\r
19821 \r
19822       var xe = x.e / LOG_BASE,\r
19823         ye = y.e / LOG_BASE,\r
19824         xc = x.c,\r
19825         yc = y.c;\r
19826 \r
19827       if (!xe || !ye) {\r
19828 \r
19829         // Return ±Infinity if either ±Infinity.\r
19830         if (!xc || !yc) return new BigNumber(a / 0);\r
19831 \r
19832         // Either zero?\r
19833         // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.\r
19834         if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0);\r
19835       }\r
19836 \r
19837       xe = bitFloor(xe);\r
19838       ye = bitFloor(ye);\r
19839       xc = xc.slice();\r
19840 \r
19841       // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.\r
19842       if (a = xe - ye) {\r
19843         if (a > 0) {\r
19844           ye = xe;\r
19845           t = yc;\r
19846         } else {\r
19847           a = -a;\r
19848           t = xc;\r
19849         }\r
19850 \r
19851         t.reverse();\r
19852         for (; a--; t.push(0));\r
19853         t.reverse();\r
19854       }\r
19855 \r
19856       a = xc.length;\r
19857       b = yc.length;\r
19858 \r
19859       // Point xc to the longer array, and b to the shorter length.\r
19860       if (a - b < 0) t = yc, yc = xc, xc = t, b = a;\r
19861 \r
19862       // Only start adding at yc.length - 1 as the further digits of xc can be ignored.\r
19863       for (a = 0; b;) {\r
19864         a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;\r
19865         xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;\r
19866       }\r
19867 \r
19868       if (a) {\r
19869         xc = [a].concat(xc);\r
19870         ++ye;\r
19871       }\r
19872 \r
19873       // No need to check for zero, as +x + +y != 0 && -x + -y != 0\r
19874       // ye = MAX_EXP + 1 possible\r
19875       return normalise(y, xc, ye);\r
19876     };\r
19877 \r
19878 \r
19879     /*\r
19880      * If sd is undefined or null or true or false, return the number of significant digits of\r
19881      * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.\r
19882      * If sd is true include integer-part trailing zeros in the count.\r
19883      *\r
19884      * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this\r
19885      * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or\r
19886      * ROUNDING_MODE if rm is omitted.\r
19887      *\r
19888      * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive.\r
19889      *                     boolean: whether to count integer-part trailing zeros: true or false.\r
19890      * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.\r
19891      *\r
19892      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'\r
19893      */\r
19894     P.precision = P.sd = function (sd, rm) {\r
19895       var c, n, v,\r
19896         x = this;\r
19897 \r
19898       if (sd != null && sd !== !!sd) {\r
19899         intCheck(sd, 1, MAX);\r
19900         if (rm == null) rm = ROUNDING_MODE;\r
19901         else intCheck(rm, 0, 8);\r
19902 \r
19903         return round(new BigNumber(x), sd, rm);\r
19904       }\r
19905 \r
19906       if (!(c = x.c)) return null;\r
19907       v = c.length - 1;\r
19908       n = v * LOG_BASE + 1;\r
19909 \r
19910       if (v = c[v]) {\r
19911 \r
19912         // Subtract the number of trailing zeros of the last element.\r
19913         for (; v % 10 == 0; v /= 10, n--);\r
19914 \r
19915         // Add the number of digits of the first element.\r
19916         for (v = c[0]; v >= 10; v /= 10, n++);\r
19917       }\r
19918 \r
19919       if (sd && x.e + 1 > n) n = x.e + 1;\r
19920 \r
19921       return n;\r
19922     };\r
19923 \r
19924 \r
19925     /*\r
19926      * Return a new BigNumber whose value is the value of this BigNumber shifted by k places\r
19927      * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.\r
19928      *\r
19929      * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.\r
19930      *\r
19931      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}'\r
19932      */\r
19933     P.shiftedBy = function (k) {\r
19934       intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);\r
19935       return this.times('1e' + k);\r
19936     };\r
19937 \r
19938 \r
19939     /*\r
19940      *  sqrt(-n) =  N\r
19941      *  sqrt(N) =  N\r
19942      *  sqrt(-I) =  N\r
19943      *  sqrt(I) =  I\r
19944      *  sqrt(0) =  0\r
19945      *  sqrt(-0) = -0\r
19946      *\r
19947      * Return a new BigNumber whose value is the square root of the value of this BigNumber,\r
19948      * rounded according to DECIMAL_PLACES and ROUNDING_MODE.\r
19949      */\r
19950     P.squareRoot = P.sqrt = function () {\r
19951       var m, n, r, rep, t,\r
19952         x = this,\r
19953         c = x.c,\r
19954         s = x.s,\r
19955         e = x.e,\r
19956         dp = DECIMAL_PLACES + 4,\r
19957         half = new BigNumber('0.5');\r
19958 \r
19959       // Negative/NaN/Infinity/zero?\r
19960       if (s !== 1 || !c || !c[0]) {\r
19961         return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);\r
19962       }\r
19963 \r
19964       // Initial estimate.\r
19965       s = Math.sqrt(+valueOf(x));\r
19966 \r
19967       // Math.sqrt underflow/overflow?\r
19968       // Pass x to Math.sqrt as integer, then adjust the exponent of the result.\r
19969       if (s == 0 || s == 1 / 0) {\r
19970         n = coeffToString(c);\r
19971         if ((n.length + e) % 2 == 0) n += '0';\r
19972         s = Math.sqrt(+n);\r
19973         e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);\r
19974 \r
19975         if (s == 1 / 0) {\r
19976           n = '1e' + e;\r
19977         } else {\r
19978           n = s.toExponential();\r
19979           n = n.slice(0, n.indexOf('e') + 1) + e;\r
19980         }\r
19981 \r
19982         r = new BigNumber(n);\r
19983       } else {\r
19984         r = new BigNumber(s + '');\r
19985       }\r
19986 \r
19987       // Check for zero.\r
19988       // r could be zero if MIN_EXP is changed after the this value was created.\r
19989       // This would cause a division by zero (x/t) and hence Infinity below, which would cause\r
19990       // coeffToString to throw.\r
19991       if (r.c[0]) {\r
19992         e = r.e;\r
19993         s = e + dp;\r
19994         if (s < 3) s = 0;\r
19995 \r
19996         // Newton-Raphson iteration.\r
19997         for (; ;) {\r
19998           t = r;\r
19999           r = half.times(t.plus(div(x, t, dp, 1)));\r
20000 \r
20001           if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {\r
20002 \r
20003             // The exponent of r may here be one less than the final result exponent,\r
20004             // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits\r
20005             // are indexed correctly.\r
20006             if (r.e < e) --s;\r
20007             n = n.slice(s - 3, s + 1);\r
20008 \r
20009             // The 4th rounding digit may be in error by -1 so if the 4 rounding digits\r
20010             // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the\r
20011             // iteration.\r
20012             if (n == '9999' || !rep && n == '4999') {\r
20013 \r
20014               // On the first iteration only, check to see if rounding up gives the\r
20015               // exact result as the nines may infinitely repeat.\r
20016               if (!rep) {\r
20017                 round(t, t.e + DECIMAL_PLACES + 2, 0);\r
20018 \r
20019                 if (t.times(t).eq(x)) {\r
20020                   r = t;\r
20021                   break;\r
20022                 }\r
20023               }\r
20024 \r
20025               dp += 4;\r
20026               s += 4;\r
20027               rep = 1;\r
20028             } else {\r
20029 \r
20030               // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact\r
20031               // result. If not, then there are further digits and m will be truthy.\r
20032               if (!+n || !+n.slice(1) && n.charAt(0) == '5') {\r
20033 \r
20034                 // Truncate to the first rounding digit.\r
20035                 round(r, r.e + DECIMAL_PLACES + 2, 1);\r
20036                 m = !r.times(r).eq(x);\r
20037               }\r
20038 \r
20039               break;\r
20040             }\r
20041           }\r
20042         }\r
20043       }\r
20044 \r
20045       return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);\r
20046     };\r
20047 \r
20048 \r
20049     /*\r
20050      * Return a string representing the value of this BigNumber in exponential notation and\r
20051      * rounded using ROUNDING_MODE to dp fixed decimal places.\r
20052      *\r
20053      * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.\r
20054      * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.\r
20055      *\r
20056      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'\r
20057      */\r
20058     P.toExponential = function (dp, rm) {\r
20059       if (dp != null) {\r
20060         intCheck(dp, 0, MAX);\r
20061         dp++;\r
20062       }\r
20063       return format(this, dp, rm, 1);\r
20064     };\r
20065 \r
20066 \r
20067     /*\r
20068      * Return a string representing the value of this BigNumber in fixed-point notation rounding\r
20069      * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.\r
20070      *\r
20071      * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',\r
20072      * but e.g. (-0.00001).toFixed(0) is '-0'.\r
20073      *\r
20074      * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.\r
20075      * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.\r
20076      *\r
20077      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'\r
20078      */\r
20079     P.toFixed = function (dp, rm) {\r
20080       if (dp != null) {\r
20081         intCheck(dp, 0, MAX);\r
20082         dp = dp + this.e + 1;\r
20083       }\r
20084       return format(this, dp, rm);\r
20085     };\r
20086 \r
20087 \r
20088     /*\r
20089      * Return a string representing the value of this BigNumber in fixed-point notation rounded\r
20090      * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties\r
20091      * of the format or FORMAT object (see BigNumber.set).\r
20092      *\r
20093      * The formatting object may contain some or all of the properties shown below.\r
20094      *\r
20095      * FORMAT = {\r
20096      *   prefix: '',\r
20097      *   groupSize: 3,\r
20098      *   secondaryGroupSize: 0,\r
20099      *   groupSeparator: ',',\r
20100      *   decimalSeparator: '.',\r
20101      *   fractionGroupSize: 0,\r
20102      *   fractionGroupSeparator: '\xA0',      // non-breaking space\r
20103      *   suffix: ''\r
20104      * };\r
20105      *\r
20106      * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.\r
20107      * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.\r
20108      * [format] {object} Formatting options. See FORMAT pbject above.\r
20109      *\r
20110      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'\r
20111      * '[BigNumber Error] Argument not an object: {format}'\r
20112      */\r
20113     P.toFormat = function (dp, rm, format) {\r
20114       var str,\r
20115         x = this;\r
20116 \r
20117       if (format == null) {\r
20118         if (dp != null && rm && typeof rm == 'object') {\r
20119           format = rm;\r
20120           rm = null;\r
20121         } else if (dp && typeof dp == 'object') {\r
20122           format = dp;\r
20123           dp = rm = null;\r
20124         } else {\r
20125           format = FORMAT;\r
20126         }\r
20127       } else if (typeof format != 'object') {\r
20128         throw Error\r
20129           (bignumberError + 'Argument not an object: ' + format);\r
20130       }\r
20131 \r
20132       str = x.toFixed(dp, rm);\r
20133 \r
20134       if (x.c) {\r
20135         var i,\r
20136           arr = str.split('.'),\r
20137           g1 = +format.groupSize,\r
20138           g2 = +format.secondaryGroupSize,\r
20139           groupSeparator = format.groupSeparator || '',\r
20140           intPart = arr[0],\r
20141           fractionPart = arr[1],\r
20142           isNeg = x.s < 0,\r
20143           intDigits = isNeg ? intPart.slice(1) : intPart,\r
20144           len = intDigits.length;\r
20145 \r
20146         if (g2) i = g1, g1 = g2, g2 = i, len -= i;\r
20147 \r
20148         if (g1 > 0 && len > 0) {\r
20149           i = len % g1 || g1;\r
20150           intPart = intDigits.substr(0, i);\r
20151           for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);\r
20152           if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);\r
20153           if (isNeg) intPart = '-' + intPart;\r
20154         }\r
20155 \r
20156         str = fractionPart\r
20157          ? intPart + (format.decimalSeparator || '') + ((g2 = +format.fractionGroupSize)\r
20158           ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'),\r
20159            '$&' + (format.fractionGroupSeparator || ''))\r
20160           : fractionPart)\r
20161          : intPart;\r
20162       }\r
20163 \r
20164       return (format.prefix || '') + str + (format.suffix || '');\r
20165     };\r
20166 \r
20167 \r
20168     /*\r
20169      * Return an array of two BigNumbers representing the value of this BigNumber as a simple\r
20170      * fraction with an integer numerator and an integer denominator.\r
20171      * The denominator will be a positive non-zero value less than or equal to the specified\r
20172      * maximum denominator. If a maximum denominator is not specified, the denominator will be\r
20173      * the lowest value necessary to represent the number exactly.\r
20174      *\r
20175      * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator.\r
20176      *\r
20177      * '[BigNumber Error] Argument {not an integer|out of range} : {md}'\r
20178      */\r
20179     P.toFraction = function (md) {\r
20180       var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s,\r
20181         x = this,\r
20182         xc = x.c;\r
20183 \r
20184       if (md != null) {\r
20185         n = new BigNumber(md);\r
20186 \r
20187         // Throw if md is less than one or is not an integer, unless it is Infinity.\r
20188         if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {\r
20189           throw Error\r
20190             (bignumberError + 'Argument ' +\r
20191               (n.isInteger() ? 'out of range: ' : 'not an integer: ') + valueOf(n));\r
20192         }\r
20193       }\r
20194 \r
20195       if (!xc) return new BigNumber(x);\r
20196 \r
20197       d = new BigNumber(ONE);\r
20198       n1 = d0 = new BigNumber(ONE);\r
20199       d1 = n0 = new BigNumber(ONE);\r
20200       s = coeffToString(xc);\r
20201 \r
20202       // Determine initial denominator.\r
20203       // d is a power of 10 and the minimum max denominator that specifies the value exactly.\r
20204       e = d.e = s.length - x.e - 1;\r
20205       d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];\r
20206       md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n;\r
20207 \r
20208       exp = MAX_EXP;\r
20209       MAX_EXP = 1 / 0;\r
20210       n = new BigNumber(s);\r
20211 \r
20212       // n0 = d1 = 0\r
20213       n0.c[0] = 0;\r
20214 \r
20215       for (; ;)  {\r
20216         q = div(n, d, 0, 1);\r
20217         d2 = d0.plus(q.times(d1));\r
20218         if (d2.comparedTo(md) == 1) break;\r
20219         d0 = d1;\r
20220         d1 = d2;\r
20221         n1 = n0.plus(q.times(d2 = n1));\r
20222         n0 = d2;\r
20223         d = n.minus(q.times(d2 = d));\r
20224         n = d2;\r
20225       }\r
20226 \r
20227       d2 = div(md.minus(d0), d1, 0, 1);\r
20228       n0 = n0.plus(d2.times(n1));\r
20229       d0 = d0.plus(d2.times(d1));\r
20230       n0.s = n1.s = x.s;\r
20231       e = e * 2;\r
20232 \r
20233       // Determine which fraction is closer to x, n0/d0 or n1/d1\r
20234       r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(\r
20235           div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];\r
20236 \r
20237       MAX_EXP = exp;\r
20238 \r
20239       return r;\r
20240     };\r
20241 \r
20242 \r
20243     /*\r
20244      * Return the value of this BigNumber converted to a number primitive.\r
20245      */\r
20246     P.toNumber = function () {\r
20247       return +valueOf(this);\r
20248     };\r
20249 \r
20250 \r
20251     /*\r
20252      * Return a string representing the value of this BigNumber rounded to sd significant digits\r
20253      * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits\r
20254      * necessary to represent the integer part of the value in fixed-point notation, then use\r
20255      * exponential notation.\r
20256      *\r
20257      * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.\r
20258      * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.\r
20259      *\r
20260      * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'\r
20261      */\r
20262     P.toPrecision = function (sd, rm) {\r
20263       if (sd != null) intCheck(sd, 1, MAX);\r
20264       return format(this, sd, rm, 2);\r
20265     };\r
20266 \r
20267 \r
20268     /*\r
20269      * Return a string representing the value of this BigNumber in base b, or base 10 if b is\r
20270      * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and\r
20271      * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent\r
20272      * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than\r
20273      * TO_EXP_NEG, return exponential notation.\r
20274      *\r
20275      * [b] {number} Integer, 2 to ALPHABET.length inclusive.\r
20276      *\r
20277      * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'\r
20278      */\r
20279     P.toString = function (b) {\r
20280       var str,\r
20281         n = this,\r
20282         s = n.s,\r
20283         e = n.e;\r
20284 \r
20285       // Infinity or NaN?\r
20286       if (e === null) {\r
20287         if (s) {\r
20288           str = 'Infinity';\r
20289           if (s < 0) str = '-' + str;\r
20290         } else {\r
20291           str = 'NaN';\r
20292         }\r
20293       } else {\r
20294         if (b == null) {\r
20295           str = e <= TO_EXP_NEG || e >= TO_EXP_POS\r
20296            ? toExponential(coeffToString(n.c), e)\r
20297            : toFixedPoint(coeffToString(n.c), e, '0');\r
20298         } else if (b === 10) {\r
20299           n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);\r
20300           str = toFixedPoint(coeffToString(n.c), n.e, '0');\r
20301         } else {\r
20302           intCheck(b, 2, ALPHABET.length, 'Base');\r
20303           str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);\r
20304         }\r
20305 \r
20306         if (s < 0 && n.c[0]) str = '-' + str;\r
20307       }\r
20308 \r
20309       return str;\r
20310     };\r
20311 \r
20312 \r
20313     /*\r
20314      * Return as toString, but do not accept a base argument, and include the minus sign for\r
20315      * negative zero.\r
20316      */\r
20317     P.valueOf = P.toJSON = function () {\r
20318       return valueOf(this);\r
20319     };\r
20320 \r
20321 \r
20322     P._isBigNumber = true;\r
20323 \r
20324     if (configObject != null) BigNumber.set(configObject);\r
20325 \r
20326     return BigNumber;\r
20327   }\r
20328 \r
20329 \r
20330   // PRIVATE HELPER FUNCTIONS\r
20331 \r
20332   // These functions don't need access to variables,\r
20333   // e.g. DECIMAL_PLACES, in the scope of the `clone` function above.\r
20334 \r
20335 \r
20336   function bitFloor(n) {\r
20337     var i = n | 0;\r
20338     return n > 0 || n === i ? i : i - 1;\r
20339   }\r
20340 \r
20341 \r
20342   // Return a coefficient array as a string of base 10 digits.\r
20343   function coeffToString(a) {\r
20344     var s, z,\r
20345       i = 1,\r
20346       j = a.length,\r
20347       r = a[0] + '';\r
20348 \r
20349     for (; i < j;) {\r
20350       s = a[i++] + '';\r
20351       z = LOG_BASE - s.length;\r
20352       for (; z--; s = '0' + s);\r
20353       r += s;\r
20354     }\r
20355 \r
20356     // Determine trailing zeros.\r
20357     for (j = r.length; r.charCodeAt(--j) === 48;);\r
20358 \r
20359     return r.slice(0, j + 1 || 1);\r
20360   }\r
20361 \r
20362 \r
20363   // Compare the value of BigNumbers x and y.\r
20364   function compare(x, y) {\r
20365     var a, b,\r
20366       xc = x.c,\r
20367       yc = y.c,\r
20368       i = x.s,\r
20369       j = y.s,\r
20370       k = x.e,\r
20371       l = y.e;\r
20372 \r
20373     // Either NaN?\r
20374     if (!i || !j) return null;\r
20375 \r
20376     a = xc && !xc[0];\r
20377     b = yc && !yc[0];\r
20378 \r
20379     // Either zero?\r
20380     if (a || b) return a ? b ? 0 : -j : i;\r
20381 \r
20382     // Signs differ?\r
20383     if (i != j) return i;\r
20384 \r
20385     a = i < 0;\r
20386     b = k == l;\r
20387 \r
20388     // Either Infinity?\r
20389     if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;\r
20390 \r
20391     // Compare exponents.\r
20392     if (!b) return k > l ^ a ? 1 : -1;\r
20393 \r
20394     j = (k = xc.length) < (l = yc.length) ? k : l;\r
20395 \r
20396     // Compare digit by digit.\r
20397     for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;\r
20398 \r
20399     // Compare lengths.\r
20400     return k == l ? 0 : k > l ^ a ? 1 : -1;\r
20401   }\r
20402 \r
20403 \r
20404   /*\r
20405    * Check that n is a primitive number, an integer, and in range, otherwise throw.\r
20406    */\r
20407   function intCheck(n, min, max, name) {\r
20408     if (n < min || n > max || n !== mathfloor(n)) {\r
20409       throw Error\r
20410        (bignumberError + (name || 'Argument') + (typeof n == 'number'\r
20411          ? n < min || n > max ? ' out of range: ' : ' not an integer: '\r
20412          : ' not a primitive number: ') + String(n));\r
20413     }\r
20414   }\r
20415 \r
20416 \r
20417   // Assumes finite n.\r
20418   function isOdd(n) {\r
20419     var k = n.c.length - 1;\r
20420     return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;\r
20421   }\r
20422 \r
20423 \r
20424   function toExponential(str, e) {\r
20425     return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) +\r
20426      (e < 0 ? 'e' : 'e+') + e;\r
20427   }\r
20428 \r
20429 \r
20430   function toFixedPoint(str, e, z) {\r
20431     var len, zs;\r
20432 \r
20433     // Negative exponent?\r
20434     if (e < 0) {\r
20435 \r
20436       // Prepend zeros.\r
20437       for (zs = z + '.'; ++e; zs += z);\r
20438       str = zs + str;\r
20439 \r
20440     // Positive exponent\r
20441     } else {\r
20442       len = str.length;\r
20443 \r
20444       // Append zeros.\r
20445       if (++e > len) {\r
20446         for (zs = z, e -= len; --e; zs += z);\r
20447         str += zs;\r
20448       } else if (e < len) {\r
20449         str = str.slice(0, e) + '.' + str.slice(e);\r
20450       }\r
20451     }\r
20452 \r
20453     return str;\r
20454   }\r
20455 \r
20456 \r
20457   // EXPORT\r
20458 \r
20459 \r
20460   BigNumber = clone();\r
20461   BigNumber['default'] = BigNumber.BigNumber = BigNumber;\r
20462 \r
20463   // AMD.\r
20464   if (true) {\r
20465     !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return BigNumber; }).call(exports, __webpack_require__, exports, module),
20466                                 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\r
20467 \r
20468   // Node.js and other environments that support module.exports.\r
20469   } else if (typeof module != 'undefined' && module.exports) {\r
20470     module.exports = BigNumber;\r
20471 \r
20472   // Browser.\r
20473   } else {\r
20474     if (!globalObject) {\r
20475       globalObject = typeof self != 'undefined' && self ? self : window;\r
20476     }\r
20477 \r
20478     globalObject.BigNumber = BigNumber;\r
20479   }\r
20480 })(this);\r
20481
20482
20483 /***/ }),
20484
20485 /***/ 577:
20486 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20487
20488 "use strict";
20489 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__ = __webpack_require__(144);
20490 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__);
20491 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise__ = __webpack_require__(76);
20492 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise__);
20493 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__bytom__ = __webpack_require__(436);
20494 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_utils__ = __webpack_require__(578);
20495
20496
20497
20498
20499
20500 var transaction = {};
20501
20502 transaction.list = function (guid, asset_id, start, limit, tx_types) {
20503   var filter = { asset_id: asset_id };
20504   if (tx_types) {
20505     filter.tx_types = tx_types;
20506   }
20507   return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.list(guid, filter, null, start, limit);
20508 };
20509
20510 transaction.convertArgument = function (argArray) {
20511   var fn = function asyncConvert(object) {
20512     var type = object.type;
20513     var value = object.value;
20514     return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.convertArgument(type, value).then(function (resp) {
20515       return resp.value;
20516     });
20517   };
20518
20519   var actionFunction = argArray.map(fn);
20520   return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a.all(actionFunction);
20521 };
20522
20523 transaction.chainStatus = function () {
20524   return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].query.getblockcount();
20525 };
20526
20527 transaction.asset = function (asset_id) {
20528   return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].query.asset(asset_id);
20529 };
20530
20531 transaction.build = function (address, to, asset, amount, fee, confirmations) {
20532   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20533     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildPayment(address, to, asset, amount.toString(), fee, confirmations).then(function (res) {
20534       resolve(res);
20535     }).catch(function (error) {
20536       reject(error);
20537     });
20538   });
20539   return retPromise;
20540 };
20541
20542 transaction.buildCrossChain = function (address, to, asset, amount, confirmations) {
20543   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20544     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildCrossChain(address, to, asset, amount.toString(), confirmations).then(function (res) {
20545       resolve(res);
20546     }).catch(function (error) {
20547       reject(error);
20548     });
20549   });
20550   return retPromise;
20551 };
20552
20553 transaction.buildVote = function (address, vote, amount, confirmations, memo) {
20554   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20555     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildVote(address, vote, amount.toString(), confirmations, memo).then(function (res) {
20556       resolve(res);
20557     }).catch(function (error) {
20558       reject(error);
20559     });
20560   });
20561   return retPromise;
20562 };
20563
20564 transaction.buildVeto = function (address, vote, amount, confirmations, memo) {
20565   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20566     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildVeto(address, vote, amount.toString(), confirmations, memo).then(function (res) {
20567       resolve(res);
20568     }).catch(function (error) {
20569       reject(error);
20570     });
20571   });
20572   return retPromise;
20573 };
20574
20575 transaction.buildTransaction = function (address, inputs, outputs, gas, confirmations) {
20576   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20577     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildTransaction(address, inputs, outputs, gas, confirmations).then(function (res) {
20578       resolve(res);
20579     }).catch(function (error) {
20580       reject(error);
20581     });
20582   });
20583   return retPromise;
20584 };
20585
20586 transaction.signTransaction = function (guid, transaction, password) {
20587   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20588     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.signTransaction(guid, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(Object(__WEBPACK_IMPORTED_MODULE_3__utils_utils__["b" /* snakeize */])(transaction)), password).then(function (res) {
20589       resolve(res);
20590     }).catch(function (error) {
20591       reject(error);
20592     });
20593   });
20594   return retPromise;
20595 };
20596
20597 transaction.transfer = function (guid, transaction, password, address) {
20598   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20599     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.signTransaction(guid, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(Object(__WEBPACK_IMPORTED_MODULE_3__utils_utils__["b" /* snakeize */])(transaction)), password).then(function (ret) {
20600       __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.submitPayment(address, ret.raw_transaction, ret.signatures).then(function (res3) {
20601         var object = {
20602           transactionHash: res3.txHash
20603         };
20604         resolve(object);
20605       }).catch(function (error) {
20606         reject(error);
20607       });
20608     }).catch(function (error) {
20609       reject(error);
20610     });
20611   });
20612
20613   return retPromise;
20614 };
20615
20616 transaction.signMessage = function (message, password, address) {
20617   return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].keys.signMessage(message, password, address);
20618 };
20619
20620 transaction.advancedTransfer = function (guid, transaction, password, arrayData, address) {
20621   var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20622     __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.signTransaction(guid, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(Object(__WEBPACK_IMPORTED_MODULE_3__utils_utils__["b" /* snakeize */])(transaction)), password).then(function (ret) {
20623       var signatures = ret.signatures;
20624       if (arrayData) {
20625         signatures[0] = arrayData;
20626       }
20627       __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.submitPayment(address, ret.raw_transaction, signatures).then(function (res3) {
20628         var object = {
20629           transactionHash: res3.txHash
20630         };
20631         resolve(object);
20632       }).catch(function (error) {
20633         reject(error);
20634       });
20635     }).catch(function (error) {
20636       reject(error);
20637     });
20638   });
20639
20640   return retPromise;
20641 };
20642
20643 /* harmony default export */ __webpack_exports__["a"] = (transaction);
20644
20645 /***/ }),
20646
20647 /***/ 578:
20648 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20649
20650 "use strict";
20651 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return camelize; });
20652 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return snakeize; });
20653 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__ = __webpack_require__(145);
20654 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__);
20655
20656 var camelize = function camelize(object) {
20657   if ((typeof object === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(object)) == 'object') {
20658     for (var key in object) {
20659       var value = object[key];
20660       var newKey = key;
20661
20662       if (/_/.test(key)) {
20663         newKey = key.replace(/([_][a-z])/g, function (v) {
20664           return v[1].toUpperCase();
20665         });
20666         delete object[key];
20667       }
20668
20669       if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(value)) == 'object') {
20670         value = camelize(value);
20671       }
20672
20673       object[newKey] = value;
20674     }
20675
20676     return object;
20677   } else {
20678     return object.replace(/([_][a-z])/g, function (v) {
20679       return v[1].toUpperCase();
20680     });
20681   }
20682 };
20683
20684 var snakeize = function snakeize(object) {
20685   for (var key in object) {
20686     var value = object[key];
20687     var newKey = key;
20688
20689     // Skip all-caps keys
20690     if (/^[A-Z]+$/.test(key)) {
20691       continue;
20692     }
20693
20694     if (/[A-Z]/.test(key)) {
20695       newKey = key.replace(/([A-Z])/g, function (v) {
20696         return '_' + v.toLowerCase();
20697       });
20698       delete object[key];
20699     }
20700
20701     if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(value)) == 'object') {
20702       value = snakeize(value);
20703     }
20704
20705     object[newKey] = value;
20706   }
20707
20708   return object;
20709 };
20710
20711 /***/ }),
20712
20713 /***/ 579:
20714 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20715
20716 "use strict";
20717 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cn__ = __webpack_require__(581);
20718
20719
20720 var sdkLang = {
20721     cn: __WEBPACK_IMPORTED_MODULE_0__cn__["a" /* default */]
20722 };
20723
20724 function getLang(str, lang) {
20725     if (sdkLang[lang] && sdkLang[lang][str]) {
20726         return sdkLang[lang][str];
20727     }
20728     return str;
20729 }
20730
20731 /* harmony default export */ __webpack_exports__["a"] = (getLang);
20732
20733 /***/ }),
20734
20735 /***/ 580:
20736 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20737
20738 "use strict";
20739 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Number; });
20740 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
20741 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
20742 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(36);
20743 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
20744 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_bignumber_js__ = __webpack_require__(576);
20745 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_bignumber_js__);
20746
20747
20748
20749
20750 var Number = function () {
20751   function Number() {
20752     __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, Number);
20753   }
20754
20755   __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(Number, null, [{
20756     key: "formatNue",
20757
20758     /***
20759      * format num to BTM
20760      * @returns number
20761      */
20762     value: function formatNue(num, dec, exp) {
20763       var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(num);
20764       if (!exp) {
20765         exp = dec;
20766       }
20767
20768       var result = n;
20769
20770       return result.toFormat(dec);
20771     }
20772
20773     /***
20774      * convert num to Nue
20775      * @returns number
20776      */
20777
20778   }, {
20779     key: "convertToNue",
20780     value: function convertToNue(num, dec) {
20781       var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(num);
20782       var base = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(10).exponentiatedBy(dec);
20783
20784       var result = n.multipliedBy(base);
20785
20786       return result.toNumber().toFixed(0);
20787     }
20788
20789     /***
20790      * format num to percent
20791      * @returns percentage
20792      */
20793
20794   }, {
20795     key: "fractionalNum",
20796     value: function fractionalNum(upper, lower) {
20797       var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(upper).div(lower);
20798
20799       var result = n.shiftedBy(2).decimalPlaces(2);
20800       return result + '%';
20801     }
20802
20803     /***
20804      * format num to currency value
20805      * @returns percentage
20806      */
20807
20808   }, {
20809     key: "formatCurrency",
20810     value: function formatCurrency(num, type) {
20811       var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(num);
20812       switch (type) {
20813         case "inCny":
20814         case "in_cny":
20815           return "\xA5 " + n.toFormat(2);
20816         case "inUsd":
20817         case "in_usd":
20818           return "$ " + n.toFormat();
20819         case "inBtc":
20820         case "in_btc":
20821           return "\u20BF " + n.toFormat();
20822         default:
20823           return "\xA5 " + n.toFormat(2);
20824       }
20825     }
20826   }]);
20827
20828   return Number;
20829 }();
20830
20831 /* harmony default export */ __webpack_exports__["b"] = (Number);
20832
20833 /***/ }),
20834
20835 /***/ 581:
20836 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20837
20838 "use strict";
20839 var cn = {
20840     "key alias already exists": "秘钥别名已经存在",
20841     "db insert error": "数据库写入异常",
20842     "db get error": "数据库查询异常",
20843     "not found by XPub": "未找到私钥数据",
20844     "db update error": "数据库更新失败",
20845     "db update error: not found by rootXPub": "数据库更新失败:未找到相应的私钥数据",
20846     "duplicate account alias": "账户别名已存在",
20847     "The wallet already has account data. Can't restore.": "当前钱包存在数据,无法从备份覆盖恢复",
20848     "could not decrypt key with given passphrase": "无法解密私钥,请检查密码是否正确",
20849     "unknown address type": "未知的地址类型"
20850 };
20851
20852 /* harmony default export */ __webpack_exports__["a"] = (cn);
20853
20854 /***/ }),
20855
20856 /***/ 606:
20857 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20858
20859 "use strict";
20860 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise__ = __webpack_require__(76);
20861 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise__);
20862 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__ = __webpack_require__(138);
20863 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__);
20864 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(139);
20865 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__);
20866 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_extends__ = __webpack_require__(532);
20867 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_extends__);
20868 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__models_transaction__ = __webpack_require__(577);
20869 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__assets_language_sdk__ = __webpack_require__(579);
20870 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_extension_streams__ = __webpack_require__(137);
20871 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_extension_streams___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_extension_streams__);
20872 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__ = __webpack_require__(529);
20873 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__services_NotificationService__ = __webpack_require__(534);
20874 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_vuex__ = __webpack_require__(433);
20875 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_lodash__ = __webpack_require__(434);
20876 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10_lodash__);
20877 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__models_account__ = __webpack_require__(435);
20878 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_Number__ = __webpack_require__(580);
20879
20880
20881
20882
20883 //
20884 //
20885 //
20886 //
20887 //
20888 //
20889 //
20890 //
20891 //
20892 //
20893 //
20894 //
20895 //
20896 //
20897 //
20898 //
20899 //
20900 //
20901 //
20902 //
20903 //
20904 //
20905 //
20906 //
20907 //
20908 //
20909 //
20910 //
20911 //
20912 //
20913 //
20914 //
20915 //
20916 //
20917 //
20918 //
20919 //
20920 //
20921 //
20922 //
20923 //
20924 //
20925 //
20926 //
20927 //
20928 //
20929 //
20930 //
20931 //
20932 //
20933 //
20934 //
20935 //
20936 //
20937 //
20938 //
20939 //
20940 //
20941 //
20942 //
20943 //
20944 //
20945 //
20946 //
20947 //
20948 //
20949 //
20950 //
20951 //
20952 //
20953 //
20954 //
20955 //
20956 //
20957 //
20958 //
20959 //
20960 //
20961 //
20962 //
20963 //
20964 //
20965 //
20966 //
20967 //
20968 //
20969 //
20970 //
20971 //
20972 //
20973 //
20974 //
20975 //
20976 //
20977 //
20978 //
20979 //
20980 //
20981 //
20982 //
20983 //
20984 //
20985 //
20986 //
20987 //
20988 //
20989 //
20990 //
20991 //
20992 //
20993 //
20994 //
20995 //
20996 //
20997 //
20998 //
20999 //
21000 //
21001 //
21002 //
21003 //
21004 //
21005 //
21006 //
21007 //
21008 //
21009 //
21010 //
21011 //
21012 //
21013 //
21014 //
21015 //
21016 //
21017 //
21018 //
21019 //
21020 //
21021 //
21022 //
21023 //
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035 /* harmony default export */ __webpack_exports__["a"] = ({
21036   data: function data() {
21037     return {
21038       full: false,
21039       transaction: {
21040         input: "",
21041         output: "",
21042         args: "",
21043         fee: "",
21044         confirmations: 1,
21045         amounts: []
21046       },
21047       password: '',
21048       prompt: ''
21049     };
21050   },
21051
21052   computed: __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_extends___default()({
21053     address: function address() {
21054       if (this.netType === 'vapor') {
21055         return this.currentAccount.vpAddress;
21056       } else {
21057         return this.currentAccount.address;
21058       }
21059     }
21060   }, Object(__WEBPACK_IMPORTED_MODULE_9_vuex__["c" /* mapGetters */])(['currentAccount', 'net', 'netType'])),
21061   watch: {},
21062   methods: {
21063     close: function close() {
21064       __WEBPACK_IMPORTED_MODULE_8__services_NotificationService__["a" /* default */].close();
21065     },
21066     transfer: function transfer() {
21067       var _this = this;
21068
21069       var loader = this.$loading.show({
21070         // Optional parameters
21071         container: null,
21072         canCancel: true,
21073         onCancel: this.onCancel
21074       });
21075
21076       __WEBPACK_IMPORTED_MODULE_4__models_transaction__["a" /* default */].buildTransaction(this.address, this.transaction.input, this.transaction.output, this.transaction.fee, this.transaction.confirmations).then(function () {
21077         var _ref = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee(result) {
21078           var arrayData;
21079           return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
21080             while (1) {
21081               switch (_context.prev = _context.next) {
21082                 case 0:
21083                   arrayData = void 0;
21084
21085                   if (!_this.transaction.args) {
21086                     _context.next = 5;
21087                     break;
21088                   }
21089
21090                   _context.next = 4;
21091                   return __WEBPACK_IMPORTED_MODULE_4__models_transaction__["a" /* default */].convertArgument(_this.transaction.args);
21092
21093                 case 4:
21094                   arrayData = _context.sent;
21095
21096                 case 5:
21097                   return _context.abrupt("return", __WEBPACK_IMPORTED_MODULE_4__models_transaction__["a" /* default */].advancedTransfer(_this.currentAccount.guid, result[0], _this.password, arrayData, _this.address).then(function (resp) {
21098                     loader.hide();
21099                     _this.prompt.responder(resp);
21100                     _this.$dialog.show({
21101                       type: 'success',
21102                       body: _this.$t("transfer.success")
21103                     });
21104                     __WEBPACK_IMPORTED_MODULE_8__services_NotificationService__["a" /* default */].close();
21105                   }).catch(function (error) {
21106                     throw error;
21107                   }));
21108
21109                 case 6:
21110                 case "end":
21111                   return _context.stop();
21112               }
21113             }
21114           }, _callee, _this);
21115         }));
21116
21117         return function (_x) {
21118           return _ref.apply(this, arguments);
21119         };
21120       }()).catch(function (error) {
21121         loader.hide();
21122
21123         _this.$dialog.show({
21124           body: Object(__WEBPACK_IMPORTED_MODULE_5__assets_language_sdk__["a" /* default */])(error.message)
21125         });
21126       });
21127     },
21128     queryAsset: function queryAsset(assetID) {
21129       return __WEBPACK_IMPORTED_MODULE_4__models_transaction__["a" /* default */].asset(assetID);
21130     }
21131   }, mounted: function mounted() {
21132     var _this2 = this;
21133
21134     this.prompt = window.data || __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].extension.getBackgroundPage().notification || null;
21135
21136     if (this.prompt.data !== undefined) {
21137       var inout = this.prompt.data;
21138       if (inout.input !== undefined) {
21139         this.transaction.input = inout.input;
21140       }
21141       if (inout.output !== undefined) {
21142         this.transaction.output = inout.output;
21143       }
21144       if (inout.args !== undefined) {
21145         this.transaction.args = inout.args;
21146       }
21147       if (inout.gas !== undefined) {
21148         this.transaction.fee = inout.gas;
21149       }
21150       if (inout.confirmations !== undefined) {
21151         this.transaction.confirmations = inout.confirmations;
21152       }
21153
21154       var array = inout.input.filter(function (action) {
21155         return action.type === 'spend_wallet';
21156       });
21157
21158       if (array.length > 0) {
21159         __WEBPACK_IMPORTED_MODULE_11__models_account__["a" /* default */].setupNet("" + this.net + this.netType);
21160         var promise = __WEBPACK_IMPORTED_MODULE_10_lodash___default()(array).groupBy('asset').map(function (objs, key) {
21161           return _this2.queryAsset(key).then(function (resp) {
21162             return {
21163               'asset': key,
21164               'alias': resp.symbol,
21165               'amount': __WEBPACK_IMPORTED_MODULE_10_lodash___default.a.sumBy(objs, 'amount')
21166             };
21167           });
21168         });
21169
21170         var that = this;
21171         __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise___default.a.all(promise).then(function (output) {
21172           that.transaction.amounts = output;
21173         });
21174       }
21175     }
21176   }
21177 });
21178
21179 /***/ }),
21180
21181 /***/ 667:
21182 /***/ (function(module, exports, __webpack_require__) {
21183
21184 // style-loader: Adds some css to the DOM by adding a <style> tag
21185
21186 // load the styles
21187 var content = __webpack_require__(668);
21188 if(typeof content === 'string') content = [[module.i, content, '']];
21189 if(content.locals) module.exports = content.locals;
21190 // add the styles to the DOM
21191 var update = __webpack_require__(84)("f4608966", content, true, {});
21192
21193 /***/ }),
21194
21195 /***/ 668:
21196 /***/ (function(module, exports, __webpack_require__) {
21197
21198 exports = module.exports = __webpack_require__(83)(false);
21199 // imports
21200
21201
21202 // module
21203 exports.push([module.i, ".warp[data-v-b2586742]{position:absolute;top:0;left:0;right:0;height:600px;z-index:2;overflow:scroll}.header[data-v-b2586742]{display:flex}.header p[data-v-b2586742]{text-align:center;width:280px;padding-top:17px}.content[data-v-b2586742]{margin:20px;padding:20px;overflow:hidden;border-radius:4px;width:280px}.divider[data-v-b2586742]{margin:12px 0}.value .uint[data-v-b2586742]{font-size:12px;margin-left:3px}.btn-inline .btn[data-v-b2586742]{margin:10px 15px}.row[data-v-b2586742]{word-break:break-all}.col[data-v-b2586742]{font-size:14px;width:35%}.label[data-v-b2586742]{color:#7b7b7b}.value[data-v-b2586742]{color:#282828;width:60%}table[data-v-b2586742]{width:100%}.form-item[data-v-b2586742]{padding:0;margin:0;margin-bottom:10px}.hide[data-v-b2586742]{width:175px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.view-link[data-v-b2586742]{font-size:14px;color:#035bd4;width:275px;display:block}", ""]);
21204
21205 // exports
21206
21207
21208 /***/ }),
21209
21210 /***/ 669:
21211 /***/ (function(module, __webpack_exports__, __webpack_require__) {
21212
21213 "use strict";
21214 var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"warp bg-gray"},[_c('section',{staticClass:"header bg-header"},[_c('i',{staticClass:"iconfont icon-back",on:{"click":_vm.close}}),_vm._v(" "),_c('p',[_vm._v(_vm._s(_vm.$t('transfer.confirmTransaction')))])]),_vm._v(" "),_c('section',{staticClass:"content bg-white"},[_c('table',[_c('tbody',[_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(_vm.$t('transfer.from')))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(_vm.currentAccount.alias))])]),_vm._v(" "),_c('div',{staticClass:"divider"}),_vm._v(" "),_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v("Input")]),_vm._v(" "),_c('td',{staticClass:"col value",class:{ hide: !_vm.full }},[_vm._v(_vm._s(_vm.transaction.input))])]),_vm._v(" "),_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v("Output")]),_vm._v(" "),_c('td',{staticClass:"col value",class:{ hide: !_vm.full }},[_vm._v(_vm._s(_vm.transaction.output))])]),_vm._v(" "),(_vm.transaction.args)?_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v("Args")]),_vm._v(" "),_c('td',{staticClass:"col value",class:{ hide: !_vm.full }},[_vm._v(_vm._s(_vm.transaction.args))])]):_vm._e(),_vm._v(" "),_c('tr',{staticClass:"row"},[_c('td',{staticClass:"center-text",attrs:{"colspan":"2"}},[_c('a',{staticClass:"view-link",on:{"click":function($event){_vm.full = !_vm.full}}},[_vm._v("\n              "+_vm._s(_vm.full? _vm.$t('transfer.hideAll'): _vm.$t('transfer.viewAll'))+" >>\n            ")])])]),_vm._v(" "),_c('div',{staticClass:"divider"}),_vm._v(" "),_vm._l((_vm.transaction.amounts),function(amountInput,index){return _c('tr',{key:index,staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(index ==0 && _vm.$t('transfer.transferAmount')))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(amountInput.amount)),_c('span',{staticClass:"uint uppercase"},[_vm._v(_vm._s(amountInput.alias || amountInput.asset))])])])}),_vm._v(" "),_c('tr',{staticClass:"row"},[_c('td',{staticClass:"col label"},[_vm._v(_vm._s(_vm.$t('transfer.fee')))]),_vm._v(" "),_c('td',{staticClass:"col value"},[_vm._v(_vm._s(_vm.transaction.fee)),_c('span',{staticClass:"uint"},[_vm._v("BTM")])])])],2)])]),_vm._v(" "),_c('section',{staticClass:"content bg-white"},[_c('div',{staticClass:"form"},[_c('div',{staticClass:"form-item"},[_c('label',{staticClass:"form-item-label"},[_vm._v(_vm._s(_vm.$t('transfer.confirmPassword')))]),_vm._v(" "),_c('div',{staticClass:"form-item-content"},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.password),expression:"password"}],attrs:{"type":"password","autofocus":""},domProps:{"value":(_vm.password)},on:{"input":function($event){if($event.target.composing){ return; }_vm.password=$event.target.value}}})])])])]),_vm._v(" "),_c('div',{staticClass:"row",staticStyle:{"margin":"20px"}},[_c('div',{staticClass:"btn bg-green",on:{"click":_vm.transfer}},[_vm._v(_vm._s(_vm.$t('transfer.confirm')))])])])}
21215 var staticRenderFns = []
21216 var esExports = { render: render, staticRenderFns: staticRenderFns }
21217 /* harmony default export */ __webpack_exports__["a"] = (esExports);
21218
21219 /***/ })
21220
21221 });
21222 //# sourceMappingURL=5.js.map