1 // [AIV_SHORT] Build version: 2.2.0 - Thursday, June 4th, 2020, 2:31:20 PM
5 /***/ (function(module, exports, __webpack_require__) {
7 /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
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
17 /** Used as a safe reference for `undefined` in pre-ES5 environments. */
20 /** Used as the semantic version number. */
21 var VERSION = '4.17.15';
23 /** Used as the size to enable large array optimizations. */
24 var LARGE_ARRAY_SIZE = 200;
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';
30 /** Used to stand-in for `undefined` hash values. */
31 var HASH_UNDEFINED = '__lodash_hash_undefined__';
33 /** Used as the maximum memoize cache size. */
34 var MAX_MEMOIZE_SIZE = 500;
36 /** Used as the internal argument placeholder. */
37 var PLACEHOLDER = '__lodash_placeholder__';
39 /** Used to compose bitmasks for cloning. */
40 var CLONE_DEEP_FLAG = 1,
42 CLONE_SYMBOLS_FLAG = 4;
44 /** Used to compose bitmasks for value comparisons. */
45 var COMPARE_PARTIAL_FLAG = 1,
46 COMPARE_UNORDERED_FLAG = 2;
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,
53 WRAP_CURRY_RIGHT_FLAG = 16,
54 WRAP_PARTIAL_FLAG = 32,
55 WRAP_PARTIAL_RIGHT_FLAG = 64,
57 WRAP_REARG_FLAG = 256,
60 /** Used as default options for `_.truncate`. */
61 var DEFAULT_TRUNC_LENGTH = 30,
62 DEFAULT_TRUNC_OMISSION = '...';
64 /** Used to detect hot functions by number of calls within a span of milliseconds. */
68 /** Used to indicate the type of lazy iteratees. */
69 var LAZY_FILTER_FLAG = 1,
73 /** Used as references for various `Number` constants. */
75 MAX_SAFE_INTEGER = 9007199254740991,
76 MAX_INTEGER = 1.7976931348623157e+308,
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;
84 /** Used to associate wrap methods with their bit flags. */
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]
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]';
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]';
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;
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);
144 /** Used to match template delimiters. */
145 var reEscape = /<%-([\s\S]+?)%>/g,
146 reEvaluate = /<%([\s\S]+?)%>/g,
147 reInterpolate = /<%=([\s\S]+?)%>/g;
149 /** Used to match property names within property paths. */
150 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
151 reIsPlainProp = /^\w*$/,
152 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
155 * Used to match `RegExp`
156 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
158 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
159 reHasRegExpChar = RegExp(reRegExpChar.source);
161 /** Used to match leading and trailing whitespace. */
162 var reTrim = /^\s+|\s+$/g,
163 reTrimStart = /^\s+/,
166 /** Used to match wrap detail comments. */
167 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
168 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
169 reSplitDetails = /,? & /;
171 /** Used to match words composed of alphanumeric characters. */
172 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
174 /** Used to match backslashes in property paths. */
175 var reEscapeChar = /\\(\\)?/g;
179 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
181 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
183 /** Used to match `RegExp` flags from their coerced string values. */
184 var reFlags = /\w*$/;
186 /** Used to detect bad signed hexadecimal string values. */
187 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
189 /** Used to detect binary string values. */
190 var reIsBinary = /^0b[01]+$/i;
192 /** Used to detect host constructors (Safari). */
193 var reIsHostCtor = /^\[object .+?Constructor\]$/;
195 /** Used to detect octal string values. */
196 var reIsOctal = /^0o[0-7]+$/i;
198 /** Used to detect unsigned integer values. */
199 var reIsUint = /^(?:0|[1-9]\d*)$/;
201 /** Used to match Latin Unicode letters (excluding mathematical operators). */
202 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
204 /** Used to ensure capturing order of template delimiters. */
205 var reNoMatch = /($^)/;
207 /** Used to match unescaped characters in compiled string literals. */
208 var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
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;
226 /** Used to compose unicode capture groups. */
227 var rsApos = "['\u2019]",
228 rsAstral = '[' + rsAstralRange + ']',
229 rsBreak = '[' + rsBreakRange + ']',
230 rsCombo = '[' + rsComboRange + ']',
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 + ']',
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('|') + ')';
257 /** Used to match apostrophes. */
258 var reApos = RegExp(rsApos, 'g');
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).
264 var reComboMark = RegExp(rsCombo, 'g');
266 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
267 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
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,
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 + ']');
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 ]/;
287 /** Used to assign default `context` object properties. */
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'
296 /** Used to make template sourceURLs easier to identify. */
297 var templateCounter = -1;
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;
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;
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',
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'
389 /** Used to map characters to HTML entities. */
398 /** Used to map HTML entities to characters. */
399 var htmlUnescapes = {
407 /** Used to escape characters for inclusion in compiled string literals. */
408 var stringEscapes = {
417 /** Built-in method references without a dependency on `root`. */
418 var freeParseFloat = parseFloat,
419 freeParseInt = parseInt;
421 /** Detect free variable `global` from Node.js. */
422 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
424 /** Detect free variable `self`. */
425 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
427 /** Used as a reference to the global object. */
428 var root = freeGlobal || freeSelf || Function('return this')();
430 /** Detect free variable `exports`. */
431 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
433 /** Detect free variable `module`. */
434 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
436 /** Detect the popular CommonJS extension `module.exports`. */
437 var moduleExports = freeModule && freeModule.exports === freeExports;
439 /** Detect free variable `process` from Node.js. */
440 var freeProcess = moduleExports && freeGlobal.process;
442 /** Used to access faster Node.js helpers. */
443 var nodeUtil = (function() {
445 // Use `util.types` for Node.js 10+.
446 var types = freeModule && freeModule.require && freeModule.require('util').types;
452 // Legacy `process.binding('util')` for Node.js < 10.
453 return freeProcess && freeProcess.binding && freeProcess.binding('util');
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;
465 /*--------------------------------------------------------------------------*/
468 * A faster alternative to `Function#apply`, this function invokes `func`
469 * with the `this` binding of `thisArg` and the arguments of `args`.
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`.
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]);
484 return func.apply(thisArg, args);
488 * A specialized version of `baseAggregator` for arrays.
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`.
497 function arrayAggregator(array, setter, iteratee, accumulator) {
499 length = array == null ? 0 : array.length;
501 while (++index < length) {
502 var value = array[index];
503 setter(accumulator, value, iteratee(value), array);
509 * A specialized version of `_.forEach` for arrays without support for
510 * iteratee shorthands.
513 * @param {Array} [array] The array to iterate over.
514 * @param {Function} iteratee The function invoked per iteration.
515 * @returns {Array} Returns `array`.
517 function arrayEach(array, iteratee) {
519 length = array == null ? 0 : array.length;
521 while (++index < length) {
522 if (iteratee(array[index], index, array) === false) {
530 * A specialized version of `_.forEachRight` for arrays without support for
531 * iteratee shorthands.
534 * @param {Array} [array] The array to iterate over.
535 * @param {Function} iteratee The function invoked per iteration.
536 * @returns {Array} Returns `array`.
538 function arrayEachRight(array, iteratee) {
539 var length = array == null ? 0 : array.length;
542 if (iteratee(array[length], length, array) === false) {
550 * A specialized version of `_.every` for arrays without support for
551 * iteratee shorthands.
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,
559 function arrayEvery(array, predicate) {
561 length = array == null ? 0 : array.length;
563 while (++index < length) {
564 if (!predicate(array[index], index, array)) {
572 * A specialized version of `_.filter` for arrays without support for
573 * iteratee shorthands.
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.
580 function arrayFilter(array, predicate) {
582 length = array == null ? 0 : array.length,
586 while (++index < length) {
587 var value = array[index];
588 if (predicate(value, index, array)) {
589 result[resIndex++] = value;
596 * A specialized version of `_.includes` for arrays without support for
597 * specifying an index to search from.
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`.
604 function arrayIncludes(array, value) {
605 var length = array == null ? 0 : array.length;
606 return !!length && baseIndexOf(array, value, 0) > -1;
610 * This function is like `arrayIncludes` except that it accepts a comparator.
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`.
618 function arrayIncludesWith(array, value, comparator) {
620 length = array == null ? 0 : array.length;
622 while (++index < length) {
623 if (comparator(value, array[index])) {
631 * A specialized version of `_.map` for arrays without support for iteratee
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.
639 function arrayMap(array, iteratee) {
641 length = array == null ? 0 : array.length,
642 result = Array(length);
644 while (++index < length) {
645 result[index] = iteratee(array[index], index, array);
651 * Appends the elements of `values` to `array`.
654 * @param {Array} array The array to modify.
655 * @param {Array} values The values to append.
656 * @returns {Array} Returns `array`.
658 function arrayPush(array, values) {
660 length = values.length,
661 offset = array.length;
663 while (++index < length) {
664 array[offset + index] = values[index];
670 * A specialized version of `_.reduce` for arrays without support for
671 * iteratee shorthands.
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
679 * @returns {*} Returns the accumulated value.
681 function arrayReduce(array, iteratee, accumulator, initAccum) {
683 length = array == null ? 0 : array.length;
685 if (initAccum && length) {
686 accumulator = array[++index];
688 while (++index < length) {
689 accumulator = iteratee(accumulator, array[index], index, array);
695 * A specialized version of `_.reduceRight` for arrays without support for
696 * iteratee shorthands.
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
704 * @returns {*} Returns the accumulated value.
706 function arrayReduceRight(array, iteratee, accumulator, initAccum) {
707 var length = array == null ? 0 : array.length;
708 if (initAccum && length) {
709 accumulator = array[--length];
712 accumulator = iteratee(accumulator, array[length], length, array);
718 * A specialized version of `_.some` for arrays without support for iteratee
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,
727 function arraySome(array, predicate) {
729 length = array == null ? 0 : array.length;
731 while (++index < length) {
732 if (predicate(array[index], index, array)) {
740 * Gets the size of an ASCII `string`.
743 * @param {string} string The string inspect.
744 * @returns {number} Returns the string size.
746 var asciiSize = baseProperty('length');
749 * Converts an ASCII `string` to an array.
752 * @param {string} string The string to convert.
753 * @returns {Array} Returns the converted array.
755 function asciiToArray(string) {
756 return string.split('');
760 * Splits an ASCII `string` into an array of its words.
763 * @param {string} The string to inspect.
764 * @returns {Array} Returns the words of `string`.
766 function asciiWords(string) {
767 return string.match(reAsciiWord) || [];
771 * The base implementation of methods like `_.findKey` and `_.findLastKey`,
772 * without support for iteratee shorthands, which iterates over `collection`
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`.
781 function baseFindKey(collection, predicate, eachFunc) {
783 eachFunc(collection, function(value, key, collection) {
784 if (predicate(value, key, collection)) {
793 * The base implementation of `_.findIndex` and `_.findLastIndex` without
794 * support for iteratee shorthands.
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`.
803 function baseFindIndex(array, predicate, fromIndex, fromRight) {
804 var length = array.length,
805 index = fromIndex + (fromRight ? 1 : -1);
807 while ((fromRight ? index-- : ++index < length)) {
808 if (predicate(array[index], index, array)) {
816 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
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`.
824 function baseIndexOf(array, value, fromIndex) {
825 return value === value
826 ? strictIndexOf(array, value, fromIndex)
827 : baseFindIndex(array, baseIsNaN, fromIndex);
831 * This function is like `baseIndexOf` except that it accepts a comparator.
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`.
840 function baseIndexOfWith(array, value, fromIndex, comparator) {
841 var index = fromIndex - 1,
842 length = array.length;
844 while (++index < length) {
845 if (comparator(array[index], value)) {
853 * The base implementation of `_.isNaN` without support for number objects.
856 * @param {*} value The value to check.
857 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
859 function baseIsNaN(value) {
860 return value !== value;
864 * The base implementation of `_.mean` and `_.meanBy` without support for
865 * iteratee shorthands.
868 * @param {Array} array The array to iterate over.
869 * @param {Function} iteratee The function invoked per iteration.
870 * @returns {number} Returns the mean.
872 function baseMean(array, iteratee) {
873 var length = array == null ? 0 : array.length;
874 return length ? (baseSum(array, iteratee) / length) : NAN;
878 * The base implementation of `_.property` without support for deep paths.
881 * @param {string} key The key of the property to get.
882 * @returns {Function} Returns the new accessor function.
884 function baseProperty(key) {
885 return function(object) {
886 return object == null ? undefined : object[key];
891 * The base implementation of `_.propertyOf` without support for deep paths.
894 * @param {Object} object The object to query.
895 * @returns {Function} Returns the new accessor function.
897 function basePropertyOf(object) {
898 return function(key) {
899 return object == null ? undefined : object[key];
904 * The base implementation of `_.reduce` and `_.reduceRight`, without support
905 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
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.
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);
926 * The base implementation of `_.sortBy` which uses `comparer` to define the
927 * sort order of `array` and replaces criteria objects with their corresponding
931 * @param {Array} array The array to sort.
932 * @param {Function} comparer The function to define sort order.
933 * @returns {Array} Returns `array`.
935 function baseSortBy(array, comparer) {
936 var length = array.length;
938 array.sort(comparer);
940 array[length] = array[length].value;
946 * The base implementation of `_.sum` and `_.sumBy` without support for
947 * iteratee shorthands.
950 * @param {Array} array The array to iterate over.
951 * @param {Function} iteratee The function invoked per iteration.
952 * @returns {number} Returns the sum.
954 function baseSum(array, iteratee) {
957 length = array.length;
959 while (++index < length) {
960 var current = iteratee(array[index]);
961 if (current !== undefined) {
962 result = result === undefined ? current : (result + current);
969 * The base implementation of `_.times` without support for iteratee shorthands
970 * or max array length checks.
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.
977 function baseTimes(n, iteratee) {
981 while (++index < n) {
982 result[index] = iteratee(index);
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`.
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.
996 function baseToPairs(object, props) {
997 return arrayMap(props, function(key) {
998 return [key, object[key]];
1003 * The base implementation of `_.unary` without support for storing metadata.
1006 * @param {Function} func The function to cap arguments for.
1007 * @returns {Function} Returns the new capped function.
1009 function baseUnary(func) {
1010 return function(value) {
1016 * The base implementation of `_.values` and `_.valuesIn` which creates an
1017 * array of `object` property values corresponding to the property names
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.
1025 function baseValues(object, props) {
1026 return arrayMap(props, function(key) {
1032 * Checks if a `cache` value for `key` exists.
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`.
1039 function cacheHas(cache, key) {
1040 return cache.has(key);
1044 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1045 * that is not found in the character symbols.
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.
1052 function charsStartIndex(strSymbols, chrSymbols) {
1054 length = strSymbols.length;
1056 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1061 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1062 * that is not found in the character symbols.
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.
1069 function charsEndIndex(strSymbols, chrSymbols) {
1070 var index = strSymbols.length;
1072 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1077 * Gets the number of `placeholder` occurrences in `array`.
1080 * @param {Array} array The array to inspect.
1081 * @param {*} placeholder The placeholder to search for.
1082 * @returns {number} Returns the placeholder count.
1084 function countHolders(array, placeholder) {
1085 var length = array.length,
1089 if (array[length] === placeholder) {
1097 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1098 * letters to basic Latin letters.
1101 * @param {string} letter The matched letter to deburr.
1102 * @returns {string} Returns the deburred letter.
1104 var deburrLetter = basePropertyOf(deburredLetters);
1107 * Used by `_.escape` to convert characters to HTML entities.
1110 * @param {string} chr The matched character to escape.
1111 * @returns {string} Returns the escaped character.
1113 var escapeHtmlChar = basePropertyOf(htmlEscapes);
1116 * Used by `_.template` to escape characters for inclusion in compiled string literals.
1119 * @param {string} chr The matched character to escape.
1120 * @returns {string} Returns the escaped character.
1122 function escapeStringChar(chr) {
1123 return '\\' + stringEscapes[chr];
1127 * Gets the value at `key` of `object`.
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.
1134 function getValue(object, key) {
1135 return object == null ? undefined : object[key];
1139 * Checks if `string` contains Unicode symbols.
1142 * @param {string} string The string to inspect.
1143 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1145 function hasUnicode(string) {
1146 return reHasUnicode.test(string);
1150 * Checks if `string` contains a word composed of Unicode symbols.
1153 * @param {string} string The string to inspect.
1154 * @returns {boolean} Returns `true` if a word is found, else `false`.
1156 function hasUnicodeWord(string) {
1157 return reHasUnicodeWord.test(string);
1161 * Converts `iterator` to an array.
1164 * @param {Object} iterator The iterator to convert.
1165 * @returns {Array} Returns the converted array.
1167 function iteratorToArray(iterator) {
1171 while (!(data = iterator.next()).done) {
1172 result.push(data.value);
1178 * Converts `map` to its key-value pairs.
1181 * @param {Object} map The map to convert.
1182 * @returns {Array} Returns the key-value pairs.
1184 function mapToArray(map) {
1186 result = Array(map.size);
1188 map.forEach(function(value, key) {
1189 result[++index] = [key, value];
1195 * Creates a unary function that invokes `func` with its argument transformed.
1198 * @param {Function} func The function to wrap.
1199 * @param {Function} transform The argument transform.
1200 * @returns {Function} Returns the new function.
1202 function overArg(func, transform) {
1203 return function(arg) {
1204 return func(transform(arg));
1209 * Replaces all `placeholder` elements in `array` with an internal placeholder
1210 * and returns an array of their indexes.
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.
1217 function replaceHolders(array, placeholder) {
1219 length = array.length,
1223 while (++index < length) {
1224 var value = array[index];
1225 if (value === placeholder || value === PLACEHOLDER) {
1226 array[index] = PLACEHOLDER;
1227 result[resIndex++] = index;
1234 * Converts `set` to an array of its values.
1237 * @param {Object} set The set to convert.
1238 * @returns {Array} Returns the values.
1240 function setToArray(set) {
1242 result = Array(set.size);
1244 set.forEach(function(value) {
1245 result[++index] = value;
1251 * Converts `set` to its value-value pairs.
1254 * @param {Object} set The set to convert.
1255 * @returns {Array} Returns the value-value pairs.
1257 function setToPairs(set) {
1259 result = Array(set.size);
1261 set.forEach(function(value) {
1262 result[++index] = [value, value];
1268 * A specialized version of `_.indexOf` which performs strict equality
1269 * comparisons of values, i.e. `===`.
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`.
1277 function strictIndexOf(array, value, fromIndex) {
1278 var index = fromIndex - 1,
1279 length = array.length;
1281 while (++index < length) {
1282 if (array[index] === value) {
1290 * A specialized version of `_.lastIndexOf` which performs strict equality
1291 * comparisons of values, i.e. `===`.
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`.
1299 function strictLastIndexOf(array, value, fromIndex) {
1300 var index = fromIndex + 1;
1302 if (array[index] === value) {
1310 * Gets the number of symbols in `string`.
1313 * @param {string} string The string to inspect.
1314 * @returns {number} Returns the string size.
1316 function stringSize(string) {
1317 return hasUnicode(string)
1318 ? unicodeSize(string)
1319 : asciiSize(string);
1323 * Converts `string` to an array.
1326 * @param {string} string The string to convert.
1327 * @returns {Array} Returns the converted array.
1329 function stringToArray(string) {
1330 return hasUnicode(string)
1331 ? unicodeToArray(string)
1332 : asciiToArray(string);
1336 * Used by `_.unescape` to convert HTML entities to characters.
1339 * @param {string} chr The matched character to unescape.
1340 * @returns {string} Returns the unescaped character.
1342 var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1345 * Gets the size of a Unicode `string`.
1348 * @param {string} string The string inspect.
1349 * @returns {number} Returns the string size.
1351 function unicodeSize(string) {
1352 var result = reUnicode.lastIndex = 0;
1353 while (reUnicode.test(string)) {
1360 * Converts a Unicode `string` to an array.
1363 * @param {string} string The string to convert.
1364 * @returns {Array} Returns the converted array.
1366 function unicodeToArray(string) {
1367 return string.match(reUnicode) || [];
1371 * Splits a Unicode `string` into an array of its words.
1374 * @param {string} The string to inspect.
1375 * @returns {Array} Returns the words of `string`.
1377 function unicodeWords(string) {
1378 return string.match(reUnicodeWord) || [];
1381 /*--------------------------------------------------------------------------*/
1384 * Create a new pristine `lodash` function using the `context` object.
1390 * @param {Object} [context=root] The context object.
1391 * @returns {Function} Returns a new `lodash` function.
1394 * _.mixin({ 'foo': _.constant('foo') });
1396 * var lodash = _.runInContext();
1397 * lodash.mixin({ 'bar': lodash.constant('bar') });
1399 * _.isFunction(_.foo);
1401 * _.isFunction(_.bar);
1404 * lodash.isFunction(lodash.foo);
1406 * lodash.isFunction(lodash.bar);
1409 * // Create a suped-up `defer` in Node.js.
1410 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1412 var runInContext = (function runInContext(context) {
1413 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
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;
1426 /** Used for built-in method references. */
1427 var arrayProto = Array.prototype,
1428 funcProto = Function.prototype,
1429 objectProto = Object.prototype;
1431 /** Used to detect overreaching core-js shims. */
1432 var coreJsData = context['__core-js_shared__'];
1434 /** Used to resolve the decompiled source of functions. */
1435 var funcToString = funcProto.toString;
1437 /** Used to check objects for own properties. */
1438 var hasOwnProperty = objectProto.hasOwnProperty;
1440 /** Used to generate unique IDs. */
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) : '';
1450 * Used to resolve the
1451 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1454 var nativeObjectToString = objectProto.toString;
1456 /** Used to infer the `Object` constructor. */
1457 var objectCtorString = funcToString.call(Object);
1459 /** Used to restore the original `_` reference in `_.noConflict`. */
1460 var oldDash = root._;
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.*?') + '$'
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;
1481 var defineProperty = (function() {
1483 var func = getNative(Object, 'defineProperty');
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;
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;
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');
1517 /** Used to store function metadata. */
1518 var metaMap = WeakMap && new WeakMap;
1520 /** Used to lookup unminified function names. */
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);
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;
1535 /*------------------------------------------------------------------------*/
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
1545 * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1546 * enabled using `_.chain`.
1548 * The execution of chained methods is lazy, that is, it's deferred until
1549 * `_#value` is implicitly or explicitly called.
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.
1559 * Chaining is supported in custom builds as long as the `_#value` method is
1560 * directly or indirectly included in the build.
1562 * In addition to lodash methods, wrappers have `Array` and `String` methods.
1564 * The wrapper `Array` methods are:
1565 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1567 * The wrapper `String` methods are:
1568 * `replace` and `split`
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`
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`
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`
1631 * @param {*} value The value to wrap in a `lodash` instance.
1632 * @returns {Object} Returns the new `lodash` wrapper instance.
1635 * function square(n) {
1639 * var wrapped = _([1, 2, 3]);
1641 * // Returns an unwrapped value.
1642 * wrapped.reduce(_.add);
1645 * // Returns a wrapped value.
1646 * var squares = wrapped.map(square);
1648 * _.isArray(squares);
1651 * _.isArray(squares.value());
1654 function lodash(value) {
1655 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1656 if (value instanceof LodashWrapper) {
1659 if (hasOwnProperty.call(value, '__wrapped__')) {
1660 return wrapperClone(value);
1663 return new LodashWrapper(value);
1667 * The base implementation of `_.create` without support for assigning
1668 * properties to the created object.
1671 * @param {Object} proto The object to inherit from.
1672 * @returns {Object} Returns the new object.
1674 var baseCreate = (function() {
1675 function object() {}
1676 return function(proto) {
1677 if (!isObject(proto)) {
1681 return objectCreate(proto);
1683 object.prototype = proto;
1684 var result = new object;
1685 object.prototype = undefined;
1691 * The function whose prototype chain sequence wrappers inherit from.
1695 function baseLodash() {
1696 // No operation performed.
1700 * The base constructor for creating `lodash` wrapper objects.
1703 * @param {*} value The value to wrap.
1704 * @param {boolean} [chainAll] Enable explicit method chain sequences.
1706 function LodashWrapper(value, chainAll) {
1707 this.__wrapped__ = value;
1708 this.__actions__ = [];
1709 this.__chain__ = !!chainAll;
1711 this.__values__ = undefined;
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.
1723 lodash.templateSettings = {
1726 * Used to detect `data` property values to be HTML-escaped.
1728 * @memberOf _.templateSettings
1734 * Used to detect code to be evaluated.
1736 * @memberOf _.templateSettings
1739 'evaluate': reEvaluate,
1742 * Used to detect `data` property values to inject.
1744 * @memberOf _.templateSettings
1747 'interpolate': reInterpolate,
1750 * Used to reference the data object in the template text.
1752 * @memberOf _.templateSettings
1758 * Used to import variables into the compiled template.
1760 * @memberOf _.templateSettings
1766 * A reference to the `lodash` function.
1768 * @memberOf _.templateSettings.imports
1775 // Ensure wrappers are instances of `baseLodash`.
1776 lodash.prototype = baseLodash.prototype;
1777 lodash.prototype.constructor = lodash;
1779 LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1780 LodashWrapper.prototype.constructor = LodashWrapper;
1782 /*------------------------------------------------------------------------*/
1785 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1789 * @param {*} value The value to wrap.
1791 function LazyWrapper(value) {
1792 this.__wrapped__ = value;
1793 this.__actions__ = [];
1795 this.__filtered__ = false;
1796 this.__iteratees__ = [];
1797 this.__takeCount__ = MAX_ARRAY_LENGTH;
1798 this.__views__ = [];
1802 * Creates a clone of the lazy wrapper object.
1806 * @memberOf LazyWrapper
1807 * @returns {Object} Returns the cloned `LazyWrapper` object.
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__);
1821 * Reverses the direction of lazy iteration.
1825 * @memberOf LazyWrapper
1826 * @returns {Object} Returns the new reversed `LazyWrapper` object.
1828 function lazyReverse() {
1829 if (this.__filtered__) {
1830 var result = new LazyWrapper(this);
1831 result.__dir__ = -1;
1832 result.__filtered__ = true;
1834 result = this.clone();
1835 result.__dir__ *= -1;
1841 * Extracts the unwrapped value from its lazy wrapper.
1845 * @memberOf LazyWrapper
1846 * @returns {*} Returns the unwrapped value.
1848 function lazyValue() {
1849 var array = this.__wrapped__.value(),
1851 isArr = isArray(array),
1853 arrLength = isArr ? array.length : 0,
1854 view = getView(0, arrLength, this.__views__),
1857 length = end - start,
1858 index = isRight ? end : (start - 1),
1859 iteratees = this.__iteratees__,
1860 iterLength = iteratees.length,
1862 takeCount = nativeMin(length, this.__takeCount__);
1864 if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
1865 return baseWrapperValue(array, this.__actions__);
1870 while (length-- && resIndex < takeCount) {
1874 value = array[index];
1876 while (++iterIndex < iterLength) {
1877 var data = iteratees[iterIndex],
1878 iteratee = data.iteratee,
1880 computed = iteratee(value);
1882 if (type == LAZY_MAP_FLAG) {
1884 } else if (!computed) {
1885 if (type == LAZY_FILTER_FLAG) {
1892 result[resIndex++] = value;
1897 // Ensure `LazyWrapper` is an instance of `baseLodash`.
1898 LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1899 LazyWrapper.prototype.constructor = LazyWrapper;
1901 /*------------------------------------------------------------------------*/
1904 * Creates a hash object.
1908 * @param {Array} [entries] The key-value pairs to cache.
1910 function Hash(entries) {
1912 length = entries == null ? 0 : entries.length;
1915 while (++index < length) {
1916 var entry = entries[index];
1917 this.set(entry[0], entry[1]);
1922 * Removes all key-value entries from the hash.
1928 function hashClear() {
1929 this.__data__ = nativeCreate ? nativeCreate(null) : {};
1934 * Removes `key` and its value from the 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`.
1943 function hashDelete(key) {
1944 var result = this.has(key) && delete this.__data__[key];
1945 this.size -= result ? 1 : 0;
1950 * Gets the hash value for `key`.
1955 * @param {string} key The key of the value to get.
1956 * @returns {*} Returns the entry value.
1958 function hashGet(key) {
1959 var data = this.__data__;
1961 var result = data[key];
1962 return result === HASH_UNDEFINED ? undefined : result;
1964 return hasOwnProperty.call(data, key) ? data[key] : undefined;
1968 * Checks if a hash value for `key` exists.
1973 * @param {string} key The key of the entry to check.
1974 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1976 function hashHas(key) {
1977 var data = this.__data__;
1978 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
1982 * Sets the hash `key` to `value`.
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.
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;
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;
2005 /*------------------------------------------------------------------------*/
2008 * Creates an list cache object.
2012 * @param {Array} [entries] The key-value pairs to cache.
2014 function ListCache(entries) {
2016 length = entries == null ? 0 : entries.length;
2019 while (++index < length) {
2020 var entry = entries[index];
2021 this.set(entry[0], entry[1]);
2026 * Removes all key-value entries from the list cache.
2030 * @memberOf ListCache
2032 function listCacheClear() {
2038 * Removes `key` and its value from the list cache.
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`.
2046 function listCacheDelete(key) {
2047 var data = this.__data__,
2048 index = assocIndexOf(data, key);
2053 var lastIndex = data.length - 1;
2054 if (index == lastIndex) {
2057 splice.call(data, index, 1);
2064 * Gets the list cache value for `key`.
2068 * @memberOf ListCache
2069 * @param {string} key The key of the value to get.
2070 * @returns {*} Returns the entry value.
2072 function listCacheGet(key) {
2073 var data = this.__data__,
2074 index = assocIndexOf(data, key);
2076 return index < 0 ? undefined : data[index][1];
2080 * Checks if a list cache value for `key` exists.
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`.
2088 function listCacheHas(key) {
2089 return assocIndexOf(this.__data__, key) > -1;
2093 * Sets the list cache `key` to `value`.
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.
2102 function listCacheSet(key, value) {
2103 var data = this.__data__,
2104 index = assocIndexOf(data, key);
2108 data.push([key, value]);
2110 data[index][1] = value;
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;
2122 /*------------------------------------------------------------------------*/
2125 * Creates a map cache object to store key-value pairs.
2129 * @param {Array} [entries] The key-value pairs to cache.
2131 function MapCache(entries) {
2133 length = entries == null ? 0 : entries.length;
2136 while (++index < length) {
2137 var entry = entries[index];
2138 this.set(entry[0], entry[1]);
2143 * Removes all key-value entries from the map.
2147 * @memberOf MapCache
2149 function mapCacheClear() {
2153 'map': new (Map || ListCache),
2159 * Removes `key` and its value from the map.
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`.
2167 function mapCacheDelete(key) {
2168 var result = getMapData(this, key)['delete'](key);
2169 this.size -= result ? 1 : 0;
2174 * Gets the map value for `key`.
2178 * @memberOf MapCache
2179 * @param {string} key The key of the value to get.
2180 * @returns {*} Returns the entry value.
2182 function mapCacheGet(key) {
2183 return getMapData(this, key).get(key);
2187 * Checks if a map value for `key` exists.
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`.
2195 function mapCacheHas(key) {
2196 return getMapData(this, key).has(key);
2200 * Sets the map `key` to `value`.
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.
2209 function mapCacheSet(key, value) {
2210 var data = getMapData(this, key),
2213 data.set(key, value);
2214 this.size += data.size == size ? 0 : 1;
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;
2225 /*------------------------------------------------------------------------*/
2229 * Creates an array cache object to store unique values.
2233 * @param {Array} [values] The values to cache.
2235 function SetCache(values) {
2237 length = values == null ? 0 : values.length;
2239 this.__data__ = new MapCache;
2240 while (++index < length) {
2241 this.add(values[index]);
2246 * Adds `value` to the array cache.
2250 * @memberOf SetCache
2252 * @param {*} value The value to cache.
2253 * @returns {Object} Returns the cache instance.
2255 function setCacheAdd(value) {
2256 this.__data__.set(value, HASH_UNDEFINED);
2261 * Checks if `value` is in the array cache.
2265 * @memberOf SetCache
2266 * @param {*} value The value to search for.
2267 * @returns {number} Returns `true` if `value` is found, else `false`.
2269 function setCacheHas(value) {
2270 return this.__data__.has(value);
2273 // Add methods to `SetCache`.
2274 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2275 SetCache.prototype.has = setCacheHas;
2277 /*------------------------------------------------------------------------*/
2280 * Creates a stack cache object to store key-value pairs.
2284 * @param {Array} [entries] The key-value pairs to cache.
2286 function Stack(entries) {
2287 var data = this.__data__ = new ListCache(entries);
2288 this.size = data.size;
2292 * Removes all key-value entries from the stack.
2298 function stackClear() {
2299 this.__data__ = new ListCache;
2304 * Removes `key` and its value from the stack.
2309 * @param {string} key The key of the value to remove.
2310 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2312 function stackDelete(key) {
2313 var data = this.__data__,
2314 result = data['delete'](key);
2316 this.size = data.size;
2321 * Gets the stack value for `key`.
2326 * @param {string} key The key of the value to get.
2327 * @returns {*} Returns the entry value.
2329 function stackGet(key) {
2330 return this.__data__.get(key);
2334 * Checks if a stack value for `key` exists.
2339 * @param {string} key The key of the entry to check.
2340 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2342 function stackHas(key) {
2343 return this.__data__.has(key);
2347 * Sets the stack `key` to `value`.
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.
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;
2365 data = this.__data__ = new MapCache(pairs);
2367 data.set(key, value);
2368 this.size = data.size;
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;
2379 /*------------------------------------------------------------------------*/
2382 * Creates an array of the enumerable property names of the array-like `value`.
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.
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;
2398 for (var key in value) {
2399 if ((inherited || hasOwnProperty.call(value, key)) &&
2401 // Safari 9 has enumerable `arguments.length` in strict mode.
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)
2417 * A specialized version of `_.sample` for arrays.
2420 * @param {Array} array The array to sample.
2421 * @returns {*} Returns the random element.
2423 function arraySample(array) {
2424 var length = array.length;
2425 return length ? array[baseRandom(0, length - 1)] : undefined;
2429 * A specialized version of `_.sampleSize` for arrays.
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.
2436 function arraySampleSize(array, n) {
2437 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2441 * A specialized version of `_.shuffle` for arrays.
2444 * @param {Array} array The array to shuffle.
2445 * @returns {Array} Returns the new shuffled array.
2447 function arrayShuffle(array) {
2448 return shuffleSelf(copyArray(array));
2452 * This function is like `assignValue` except that it doesn't assign
2453 * `undefined` values.
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.
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);
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.
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.
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);
2486 * Gets the index at which the `key` is found in `array` of key-value pairs.
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`.
2493 function assocIndexOf(array, key) {
2494 var length = array.length;
2496 if (eq(array[length][0], key)) {
2504 * Aggregates elements of `collection` on `accumulator` with keys transformed
2505 * by `iteratee` and values set by `setter`.
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`.
2514 function baseAggregator(collection, setter, iteratee, accumulator) {
2515 baseEach(collection, function(value, key, collection) {
2516 setter(accumulator, value, iteratee(value), collection);
2522 * The base implementation of `_.assign` without support for multiple sources
2523 * or `customizer` functions.
2526 * @param {Object} object The destination object.
2527 * @param {Object} source The source object.
2528 * @returns {Object} Returns `object`.
2530 function baseAssign(object, source) {
2531 return object && copyObject(source, keys(source), object);
2535 * The base implementation of `_.assignIn` without support for multiple sources
2536 * or `customizer` functions.
2539 * @param {Object} object The destination object.
2540 * @param {Object} source The source object.
2541 * @returns {Object} Returns `object`.
2543 function baseAssignIn(object, source) {
2544 return object && copyObject(source, keysIn(source), object);
2548 * The base implementation of `assignValue` and `assignMergeValue` without
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.
2556 function baseAssignValue(object, key, value) {
2557 if (key == '__proto__' && defineProperty) {
2558 defineProperty(object, key, {
2559 'configurable': true,
2565 object[key] = value;
2570 * The base implementation of `_.at` without support for individual paths.
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.
2577 function baseAt(object, paths) {
2579 length = paths.length,
2580 result = Array(length),
2581 skip = object == null;
2583 while (++index < length) {
2584 result[index] = skip ? undefined : get(object, paths[index]);
2590 * The base implementation of `_.clamp` which doesn't coerce arguments.
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.
2598 function baseClamp(number, lower, upper) {
2599 if (number === number) {
2600 if (upper !== undefined) {
2601 number = number <= upper ? number : upper;
2603 if (lower !== undefined) {
2604 number = number >= lower ? number : lower;
2611 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2612 * traversed objects.
2615 * @param {*} value The value to clone.
2616 * @param {boolean} bitmask The bitmask flags.
2618 * 2 - Flatten inherited properties
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.
2626 function baseClone(value, bitmask, customizer, key, object, stack) {
2628 isDeep = bitmask & CLONE_DEEP_FLAG,
2629 isFlat = bitmask & CLONE_FLAT_FLAG,
2630 isFull = bitmask & CLONE_SYMBOLS_FLAG;
2633 result = object ? customizer(value, key, object, stack) : customizer(value);
2635 if (result !== undefined) {
2638 if (!isObject(value)) {
2641 var isArr = isArray(value);
2643 result = initCloneArray(value);
2645 return copyArray(value, result);
2648 var tag = getTag(value),
2649 isFunc = tag == funcTag || tag == genTag;
2651 if (isBuffer(value)) {
2652 return cloneBuffer(value, isDeep);
2654 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2655 result = (isFlat || isFunc) ? {} : initCloneObject(value);
2658 ? copySymbolsIn(value, baseAssignIn(result, value))
2659 : copySymbols(value, baseAssign(result, value));
2662 if (!cloneableTags[tag]) {
2663 return object ? value : {};
2665 result = initCloneByTag(value, tag, isDeep);
2668 // Check for circular references and return its corresponding clone.
2669 stack || (stack = new Stack);
2670 var stacked = stack.get(value);
2674 stack.set(value, result);
2677 value.forEach(function(subValue) {
2678 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2680 } else if (isMap(value)) {
2681 value.forEach(function(subValue, key) {
2682 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
2686 var keysFunc = isFull
2687 ? (isFlat ? getAllKeysIn : getAllKeys)
2688 : (isFlat ? keysIn : keys);
2690 var props = isArr ? undefined : keysFunc(value);
2691 arrayEach(props || value, function(subValue, key) {
2694 subValue = value[key];
2696 // Recursively populate clone (susceptible to call stack limits).
2697 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
2703 * The base implementation of `_.conforms` which doesn't clone `source`.
2706 * @param {Object} source The object of property predicates to conform to.
2707 * @returns {Function} Returns the new spec function.
2709 function baseConforms(source) {
2710 var props = keys(source);
2711 return function(object) {
2712 return baseConformsTo(object, source, props);
2717 * The base implementation of `_.conformsTo` which accepts `props` to check.
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`.
2724 function baseConformsTo(object, source, props) {
2725 var length = props.length;
2726 if (object == null) {
2729 object = Object(object);
2731 var key = props[length],
2732 predicate = source[key],
2733 value = object[key];
2735 if ((value === undefined && !(key in object)) || !predicate(value)) {
2743 * The base implementation of `_.delay` and `_.defer` which accepts `args`
2744 * to provide to `func`.
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.
2752 function baseDelay(func, wait, args) {
2753 if (typeof func != 'function') {
2754 throw new TypeError(FUNC_ERROR_TEXT);
2756 return setTimeout(function() { func.apply(undefined, args); }, wait);
2760 * The base implementation of methods like `_.difference` without support
2761 * for excluding multiple arrays or iteratee shorthands.
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.
2770 function baseDifference(array, values, iteratee, comparator) {
2772 includes = arrayIncludes,
2774 length = array.length,
2776 valuesLength = values.length;
2782 values = arrayMap(values, baseUnary(iteratee));
2785 includes = arrayIncludesWith;
2788 else if (values.length >= LARGE_ARRAY_SIZE) {
2789 includes = cacheHas;
2791 values = new SetCache(values);
2794 while (++index < length) {
2795 var value = array[index],
2796 computed = iteratee == null ? value : iteratee(value);
2798 value = (comparator || value !== 0) ? value : 0;
2799 if (isCommon && computed === computed) {
2800 var valuesIndex = valuesLength;
2801 while (valuesIndex--) {
2802 if (values[valuesIndex] === computed) {
2808 else if (!includes(values, computed, comparator)) {
2816 * The base implementation of `_.forEach` without support for iteratee shorthands.
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`.
2823 var baseEach = createBaseEach(baseForOwn);
2826 * The base implementation of `_.forEachRight` without support for iteratee shorthands.
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`.
2833 var baseEachRight = createBaseEach(baseForOwnRight, true);
2836 * The base implementation of `_.every` without support for iteratee shorthands.
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,
2844 function baseEvery(collection, predicate) {
2846 baseEach(collection, function(value, index, collection) {
2847 result = !!predicate(value, index, collection);
2854 * The base implementation of methods like `_.max` and `_.min` which accepts a
2855 * `comparator` to determine the extremum value.
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.
2863 function baseExtremum(array, iteratee, comparator) {
2865 length = array.length;
2867 while (++index < length) {
2868 var value = array[index],
2869 current = iteratee(value);
2871 if (current != null && (computed === undefined
2872 ? (current === current && !isSymbol(current))
2873 : comparator(current, computed)
2875 var computed = current,
2883 * The base implementation of `_.fill` without an iteratee call guard.
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`.
2892 function baseFill(array, value, start, end) {
2893 var length = array.length;
2895 start = toInteger(start);
2897 start = -start > length ? 0 : (length + start);
2899 end = (end === undefined || end > length) ? length : toInteger(end);
2903 end = start > end ? 0 : toLength(end);
2904 while (start < end) {
2905 array[start++] = value;
2911 * The base implementation of `_.filter` without support for iteratee shorthands.
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.
2918 function baseFilter(collection, predicate) {
2920 baseEach(collection, function(value, index, collection) {
2921 if (predicate(value, index, collection)) {
2929 * The base implementation of `_.flatten` with support for restricting flattening.
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.
2939 function baseFlatten(array, depth, predicate, isStrict, result) {
2941 length = array.length;
2943 predicate || (predicate = isFlattenable);
2944 result || (result = []);
2946 while (++index < length) {
2947 var value = array[index];
2948 if (depth > 0 && predicate(value)) {
2950 // Recursively flatten arrays (susceptible to call stack limits).
2951 baseFlatten(value, depth - 1, predicate, isStrict, result);
2953 arrayPush(result, value);
2955 } else if (!isStrict) {
2956 result[result.length] = value;
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`.
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`.
2973 var baseFor = createBaseFor();
2976 * This function is like `baseFor` except that it iterates over properties
2977 * in the opposite order.
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`.
2985 var baseForRight = createBaseFor(true);
2988 * The base implementation of `_.forOwn` without support for iteratee shorthands.
2991 * @param {Object} object The object to iterate over.
2992 * @param {Function} iteratee The function invoked per iteration.
2993 * @returns {Object} Returns `object`.
2995 function baseForOwn(object, iteratee) {
2996 return object && baseFor(object, iteratee, keys);
3000 * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
3003 * @param {Object} object The object to iterate over.
3004 * @param {Function} iteratee The function invoked per iteration.
3005 * @returns {Object} Returns `object`.
3007 function baseForOwnRight(object, iteratee) {
3008 return object && baseForRight(object, iteratee, keys);
3012 * The base implementation of `_.functions` which creates an array of
3013 * `object` function property names filtered from `props`.
3016 * @param {Object} object The object to inspect.
3017 * @param {Array} props The property names to filter.
3018 * @returns {Array} Returns the function names.
3020 function baseFunctions(object, props) {
3021 return arrayFilter(props, function(key) {
3022 return isFunction(object[key]);
3027 * The base implementation of `_.get` without support for default values.
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.
3034 function baseGet(object, path) {
3035 path = castPath(path, object);
3038 length = path.length;
3040 while (object != null && index < length) {
3041 object = object[toKey(path[index++])];
3043 return (index && index == length) ? object : undefined;
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`.
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.
3057 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3058 var result = keysFunc(object);
3059 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3063 * The base implementation of `getTag` without fallbacks for buggy environments.
3066 * @param {*} value The value to query.
3067 * @returns {string} Returns the `toStringTag`.
3069 function baseGetTag(value) {
3070 if (value == null) {
3071 return value === undefined ? undefinedTag : nullTag;
3073 return (symToStringTag && symToStringTag in Object(value))
3075 : objectToString(value);
3079 * The base implementation of `_.gt` which doesn't coerce arguments.
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`,
3087 function baseGt(value, other) {
3088 return value > other;
3092 * The base implementation of `_.has` without support for deep paths.
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`.
3099 function baseHas(object, key) {
3100 return object != null && hasOwnProperty.call(object, key);
3104 * The base implementation of `_.hasIn` without support for deep paths.
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`.
3111 function baseHasIn(object, key) {
3112 return object != null && key in Object(object);
3116 * The base implementation of `_.inRange` which doesn't coerce arguments.
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`.
3124 function baseInRange(number, start, end) {
3125 return number >= nativeMin(start, end) && number < nativeMax(start, end);
3129 * The base implementation of methods like `_.intersection`, without support
3130 * for iteratee shorthands, that accepts an array of arrays to inspect.
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.
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,
3147 while (othIndex--) {
3148 var array = arrays[othIndex];
3149 if (othIndex && iteratee) {
3150 array = arrayMap(array, baseUnary(iteratee));
3152 maxLength = nativeMin(array.length, maxLength);
3153 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3154 ? new SetCache(othIndex && array)
3163 while (++index < length && result.length < maxLength) {
3164 var value = array[index],
3165 computed = iteratee ? iteratee(value) : value;
3167 value = (comparator || value !== 0) ? value : 0;
3169 ? cacheHas(seen, computed)
3170 : includes(result, computed, comparator)
3172 othIndex = othLength;
3173 while (--othIndex) {
3174 var cache = caches[othIndex];
3176 ? cacheHas(cache, computed)
3177 : includes(arrays[othIndex], computed, comparator))
3183 seen.push(computed);
3192 * The base implementation of `_.invert` and `_.invertBy` which inverts
3193 * `object` with values transformed by `iteratee` and set by `setter`.
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`.
3202 function baseInverter(object, setter, iteratee, accumulator) {
3203 baseForOwn(object, function(value, key, object) {
3204 setter(accumulator, iteratee(value), key, object);
3210 * The base implementation of `_.invoke` without support for individual
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.
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);
3227 * The base implementation of `_.isArguments`.
3230 * @param {*} value The value to check.
3231 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3233 function baseIsArguments(value) {
3234 return isObjectLike(value) && baseGetTag(value) == argsTag;
3238 * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3241 * @param {*} value The value to check.
3242 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3244 function baseIsArrayBuffer(value) {
3245 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3249 * The base implementation of `_.isDate` without Node.js optimizations.
3252 * @param {*} value The value to check.
3253 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3255 function baseIsDate(value) {
3256 return isObjectLike(value) && baseGetTag(value) == dateTag;
3260 * The base implementation of `_.isEqual` which supports partial comparisons
3261 * and tracks traversed objects.
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`.
3273 function baseIsEqual(value, other, bitmask, customizer, stack) {
3274 if (value === other) {
3277 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3278 return value !== value && other !== other;
3280 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
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.
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`.
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);
3303 objTag = objTag == argsTag ? objectTag : objTag;
3304 othTag = othTag == argsTag ? objectTag : othTag;
3306 var objIsObj = objTag == objectTag,
3307 othIsObj = othTag == objectTag,
3308 isSameTag = objTag == othTag;
3310 if (isSameTag && isBuffer(object)) {
3311 if (!isBuffer(other)) {
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);
3323 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3324 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3325 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3327 if (objIsWrapped || othIsWrapped) {
3328 var objUnwrapped = objIsWrapped ? object.value() : object,
3329 othUnwrapped = othIsWrapped ? other.value() : other;
3331 stack || (stack = new Stack);
3332 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3338 stack || (stack = new Stack);
3339 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3343 * The base implementation of `_.isMap` without Node.js optimizations.
3346 * @param {*} value The value to check.
3347 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3349 function baseIsMap(value) {
3350 return isObjectLike(value) && getTag(value) == mapTag;
3354 * The base implementation of `_.isMatch` without support for iteratee shorthands.
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`.
3363 function baseIsMatch(object, source, matchData, customizer) {
3364 var index = matchData.length,
3366 noCustomizer = !customizer;
3368 if (object == null) {
3371 object = Object(object);
3373 var data = matchData[index];
3374 if ((noCustomizer && data[2])
3375 ? data[1] !== object[data[0]]
3376 : !(data[0] in object)
3381 while (++index < length) {
3382 data = matchData[index];
3384 objValue = object[key],
3387 if (noCustomizer && data[2]) {
3388 if (objValue === undefined && !(key in object)) {
3392 var stack = new Stack;
3394 var result = customizer(objValue, srcValue, key, object, source, stack);
3396 if (!(result === undefined
3397 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
3408 * The base implementation of `_.isNative` without bad shim checks.
3411 * @param {*} value The value to check.
3412 * @returns {boolean} Returns `true` if `value` is a native function,
3415 function baseIsNative(value) {
3416 if (!isObject(value) || isMasked(value)) {
3419 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3420 return pattern.test(toSource(value));
3424 * The base implementation of `_.isRegExp` without Node.js optimizations.
3427 * @param {*} value The value to check.
3428 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3430 function baseIsRegExp(value) {
3431 return isObjectLike(value) && baseGetTag(value) == regexpTag;
3435 * The base implementation of `_.isSet` without Node.js optimizations.
3438 * @param {*} value The value to check.
3439 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3441 function baseIsSet(value) {
3442 return isObjectLike(value) && getTag(value) == setTag;
3446 * The base implementation of `_.isTypedArray` without Node.js optimizations.
3449 * @param {*} value The value to check.
3450 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3452 function baseIsTypedArray(value) {
3453 return isObjectLike(value) &&
3454 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3458 * The base implementation of `_.iteratee`.
3461 * @param {*} [value=_.identity] The value to convert to an iteratee.
3462 * @returns {Function} Returns the iteratee.
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') {
3470 if (value == null) {
3473 if (typeof value == 'object') {
3474 return isArray(value)
3475 ? baseMatchesProperty(value[0], value[1])
3476 : baseMatches(value);
3478 return property(value);
3482 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3485 * @param {Object} object The object to query.
3486 * @returns {Array} Returns the array of property names.
3488 function baseKeys(object) {
3489 if (!isPrototype(object)) {
3490 return nativeKeys(object);
3493 for (var key in Object(object)) {
3494 if (hasOwnProperty.call(object, key) && key != 'constructor') {
3502 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3505 * @param {Object} object The object to query.
3506 * @returns {Array} Returns the array of property names.
3508 function baseKeysIn(object) {
3509 if (!isObject(object)) {
3510 return nativeKeysIn(object);
3512 var isProto = isPrototype(object),
3515 for (var key in object) {
3516 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3524 * The base implementation of `_.lt` which doesn't coerce arguments.
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`,
3532 function baseLt(value, other) {
3533 return value < other;
3537 * The base implementation of `_.map` without support for iteratee shorthands.
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.
3544 function baseMap(collection, iteratee) {
3546 result = isArrayLike(collection) ? Array(collection.length) : [];
3548 baseEach(collection, function(value, key, collection) {
3549 result[++index] = iteratee(value, key, collection);
3555 * The base implementation of `_.matches` which doesn't clone `source`.
3558 * @param {Object} source The object of property values to match.
3559 * @returns {Function} Returns the new spec function.
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]);
3566 return function(object) {
3567 return object === source || baseIsMatch(object, source, matchData);
3572 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
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.
3579 function baseMatchesProperty(path, srcValue) {
3580 if (isKey(path) && isStrictComparable(srcValue)) {
3581 return matchesStrictComparable(toKey(path), srcValue);
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);
3592 * The base implementation of `_.merge` without support for multiple sources.
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
3602 function baseMerge(object, source, srcIndex, customizer, stack) {
3603 if (object === source) {
3606 baseFor(source, function(srcValue, key) {
3607 stack || (stack = new Stack);
3608 if (isObject(srcValue)) {
3609 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3612 var newValue = customizer
3613 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
3616 if (newValue === undefined) {
3617 newValue = srcValue;
3619 assignMergeValue(object, key, newValue);
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.
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
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);
3645 assignMergeValue(object, key, stacked);
3648 var newValue = customizer
3649 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3652 var isCommon = newValue === undefined;
3655 var isArr = isArray(srcValue),
3656 isBuff = !isArr && isBuffer(srcValue),
3657 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3659 newValue = srcValue;
3660 if (isArr || isBuff || isTyped) {
3661 if (isArray(objValue)) {
3662 newValue = objValue;
3664 else if (isArrayLikeObject(objValue)) {
3665 newValue = copyArray(objValue);
3669 newValue = cloneBuffer(srcValue, true);
3673 newValue = cloneTypedArray(srcValue, true);
3679 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3680 newValue = objValue;
3681 if (isArguments(objValue)) {
3682 newValue = toPlainObject(objValue);
3684 else if (!isObject(objValue) || isFunction(objValue)) {
3685 newValue = initCloneObject(srcValue);
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);
3698 assignMergeValue(object, key, newValue);
3702 * The base implementation of `_.nth` which doesn't coerce arguments.
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`.
3709 function baseNth(array, n) {
3710 var length = array.length;
3714 n += n < 0 ? length : 0;
3715 return isIndex(n, length) ? array[n] : undefined;
3719 * The base implementation of `_.orderBy` without param guards.
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.
3727 function baseOrderBy(collection, iteratees, orders) {
3729 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
3731 var result = baseMap(collection, function(value, key, collection) {
3732 var criteria = arrayMap(iteratees, function(iteratee) {
3733 return iteratee(value);
3735 return { 'criteria': criteria, 'index': ++index, 'value': value };
3738 return baseSortBy(result, function(object, other) {
3739 return compareMultiple(object, other, orders);
3744 * The base implementation of `_.pick` without support for individual
3745 * property identifiers.
3748 * @param {Object} object The source object.
3749 * @param {string[]} paths The property paths to pick.
3750 * @returns {Object} Returns the new object.
3752 function basePick(object, paths) {
3753 return basePickBy(object, paths, function(value, path) {
3754 return hasIn(object, path);
3759 * The base implementation of `_.pickBy` without support for iteratee shorthands.
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.
3767 function basePickBy(object, paths, predicate) {
3769 length = paths.length,
3772 while (++index < length) {
3773 var path = paths[index],
3774 value = baseGet(object, path);
3776 if (predicate(value, path)) {
3777 baseSet(result, castPath(path, object), value);
3784 * A specialized version of `baseProperty` which supports deep paths.
3787 * @param {Array|string} path The path of the property to get.
3788 * @returns {Function} Returns the new accessor function.
3790 function basePropertyDeep(path) {
3791 return function(object) {
3792 return baseGet(object, path);
3797 * The base implementation of `_.pullAllBy` without support for iteratee
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`.
3807 function basePullAll(array, values, iteratee, comparator) {
3808 var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3810 length = values.length,
3813 if (array === values) {
3814 values = copyArray(values);
3817 seen = arrayMap(array, baseUnary(iteratee));
3819 while (++index < length) {
3821 value = values[index],
3822 computed = iteratee ? iteratee(value) : value;
3824 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3825 if (seen !== array) {
3826 splice.call(seen, fromIndex, 1);
3828 splice.call(array, fromIndex, 1);
3835 * The base implementation of `_.pullAt` without support for individual
3836 * indexes or capturing the removed elements.
3839 * @param {Array} array The array to modify.
3840 * @param {number[]} indexes The indexes of elements to remove.
3841 * @returns {Array} Returns `array`.
3843 function basePullAt(array, indexes) {
3844 var length = array ? indexes.length : 0,
3845 lastIndex = length - 1;
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);
3854 baseUnset(array, index);
3862 * The base implementation of `_.random` without support for returning
3863 * floating-point numbers.
3866 * @param {number} lower The lower bound.
3867 * @param {number} upper The upper bound.
3868 * @returns {number} Returns the random number.
3870 function baseRandom(lower, upper) {
3871 return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
3875 * The base implementation of `_.range` and `_.rangeRight` which doesn't
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.
3885 function baseRange(start, end, step, fromRight) {
3887 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
3888 result = Array(length);
3891 result[fromRight ? length : ++index] = start;
3898 * The base implementation of `_.repeat` which doesn't coerce arguments.
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.
3905 function baseRepeat(string, n) {
3907 if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
3910 // Leverage the exponentiation by squaring algorithm for a faster repeat.
3911 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
3916 n = nativeFloor(n / 2);
3926 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
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.
3933 function baseRest(func, start) {
3934 return setToString(overRest(func, start, identity), func + '');
3938 * The base implementation of `_.sample`.
3941 * @param {Array|Object} collection The collection to sample.
3942 * @returns {*} Returns the random element.
3944 function baseSample(collection) {
3945 return arraySample(values(collection));
3949 * The base implementation of `_.sampleSize` without param guards.
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.
3956 function baseSampleSize(collection, n) {
3957 var array = values(collection);
3958 return shuffleSelf(array, baseClamp(n, 0, array.length));
3962 * The base implementation of `_.set`.
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`.
3971 function baseSet(object, path, value, customizer) {
3972 if (!isObject(object)) {
3975 path = castPath(path, object);
3978 length = path.length,
3979 lastIndex = length - 1,
3982 while (nested != null && ++index < length) {
3983 var key = toKey(path[index]),
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)
3992 : (isIndex(path[index + 1]) ? [] : {});
3995 assignValue(nested, key, newValue);
3996 nested = nested[key];
4002 * The base implementation of `setData` without support for hot loop shorting.
4005 * @param {Function} func The function to associate metadata with.
4006 * @param {*} data The metadata.
4007 * @returns {Function} Returns `func`.
4009 var baseSetData = !metaMap ? identity : function(func, data) {
4010 metaMap.set(func, data);
4015 * The base implementation of `setToString` without support for hot loop shorting.
4018 * @param {Function} func The function to modify.
4019 * @param {Function} string The `toString` result.
4020 * @returns {Function} Returns `func`.
4022 var baseSetToString = !defineProperty ? identity : function(func, string) {
4023 return defineProperty(func, 'toString', {
4024 'configurable': true,
4025 'enumerable': false,
4026 'value': constant(string),
4032 * The base implementation of `_.shuffle`.
4035 * @param {Array|Object} collection The collection to shuffle.
4036 * @returns {Array} Returns the new shuffled array.
4038 function baseShuffle(collection) {
4039 return shuffleSelf(values(collection));
4043 * The base implementation of `_.slice` without an iteratee call guard.
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`.
4051 function baseSlice(array, start, end) {
4053 length = array.length;
4056 start = -start > length ? 0 : (length + start);
4058 end = end > length ? length : end;
4062 length = start > end ? 0 : ((end - start) >>> 0);
4065 var result = Array(length);
4066 while (++index < length) {
4067 result[index] = array[index + start];
4073 * The base implementation of `_.some` without support for iteratee shorthands.
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,
4081 function baseSome(collection, predicate) {
4084 baseEach(collection, function(value, index, collection) {
4085 result = predicate(value, index, collection);
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.
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
4103 function baseSortedIndex(array, value, retHighest) {
4105 high = array == null ? low : array.length;
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];
4112 if (computed !== null && !isSymbol(computed) &&
4113 (retHighest ? (computed <= value) : (computed < value))) {
4121 return baseSortedIndexBy(array, value, identity, retHighest);
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).
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
4137 function baseSortedIndexBy(array, value, iteratee, retHighest) {
4138 value = iteratee(value);
4141 high = array == null ? 0 : array.length,
4142 valIsNaN = value !== value,
4143 valIsNull = value === null,
4144 valIsSymbol = isSymbol(value),
4145 valIsUndefined = value === undefined;
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);
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) {
4166 setLow = retHighest ? (computed <= value) : (computed < value);
4174 return nativeMin(high, MAX_ARRAY_INDEX);
4178 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4179 * support for iteratee shorthands.
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.
4186 function baseSortedUniq(array, iteratee) {
4188 length = array.length,
4192 while (++index < length) {
4193 var value = array[index],
4194 computed = iteratee ? iteratee(value) : value;
4196 if (!index || !eq(computed, seen)) {
4197 var seen = computed;
4198 result[resIndex++] = value === 0 ? 0 : value;
4205 * The base implementation of `_.toNumber` which doesn't ensure correct
4206 * conversions of binary, hexadecimal, or octal string values.
4209 * @param {*} value The value to process.
4210 * @returns {number} Returns the number.
4212 function baseToNumber(value) {
4213 if (typeof value == 'number') {
4216 if (isSymbol(value)) {
4223 * The base implementation of `_.toString` which doesn't convert nullish
4224 * values to empty strings.
4227 * @param {*} value The value to process.
4228 * @returns {string} Returns the string.
4230 function baseToString(value) {
4231 // Exit early for strings to avoid a performance hit in some environments.
4232 if (typeof value == 'string') {
4235 if (isArray(value)) {
4236 // Recursively convert values (susceptible to call stack limits).
4237 return arrayMap(value, baseToString) + '';
4239 if (isSymbol(value)) {
4240 return symbolToString ? symbolToString.call(value) : '';
4242 var result = (value + '');
4243 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4247 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
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.
4255 function baseUniq(array, iteratee, comparator) {
4257 includes = arrayIncludes,
4258 length = array.length,
4265 includes = arrayIncludesWith;
4267 else if (length >= LARGE_ARRAY_SIZE) {
4268 var set = iteratee ? null : createSet(array);
4270 return setToArray(set);
4273 includes = cacheHas;
4274 seen = new SetCache;
4277 seen = iteratee ? [] : result;
4280 while (++index < length) {
4281 var value = array[index],
4282 computed = iteratee ? iteratee(value) : value;
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) {
4293 seen.push(computed);
4297 else if (!includes(seen, computed, comparator)) {
4298 if (seen !== result) {
4299 seen.push(computed);
4308 * The base implementation of `_.unset`.
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`.
4315 function baseUnset(object, path) {
4316 path = castPath(path, object);
4317 object = parent(object, path);
4318 return object == null || delete object[toKey(last(path))];
4322 * The base implementation of `_.update`.
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`.
4331 function baseUpdate(object, path, updater, customizer) {
4332 return baseSet(object, path, updater(baseGet(object, path)), customizer);
4336 * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4337 * without support for iteratee shorthands.
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`.
4346 function baseWhile(array, predicate, isDrop, fromRight) {
4347 var length = array.length,
4348 index = fromRight ? length : -1;
4350 while ((fromRight ? index-- : ++index < length) &&
4351 predicate(array[index], index, array)) {}
4354 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
4355 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
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.
4364 * @param {*} value The unwrapped value.
4365 * @param {Array} actions Actions to perform to resolve the unwrapped value.
4366 * @returns {*} Returns the resolved value.
4368 function baseWrapperValue(value, actions) {
4370 if (result instanceof LazyWrapper) {
4371 result = result.value();
4373 return arrayReduce(actions, function(result, action) {
4374 return action.func.apply(action.thisArg, arrayPush([result], action.args));
4379 * The base implementation of methods like `_.xor`, without support for
4380 * iteratee shorthands, that accepts an array of arrays to inspect.
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.
4388 function baseXor(arrays, iteratee, comparator) {
4389 var length = arrays.length;
4391 return length ? baseUniq(arrays[0]) : [];
4394 result = Array(length);
4396 while (++index < length) {
4397 var array = arrays[index],
4400 while (++othIndex < length) {
4401 if (othIndex != index) {
4402 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4406 return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4410 * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
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.
4418 function baseZipObject(props, values, assignFunc) {
4420 length = props.length,
4421 valsLength = values.length,
4424 while (++index < length) {
4425 var value = index < valsLength ? values[index] : undefined;
4426 assignFunc(result, props[index], value);
4432 * Casts `value` to an empty array if it's not an array like object.
4435 * @param {*} value The value to inspect.
4436 * @returns {Array|Object} Returns the cast array-like object.
4438 function castArrayLikeObject(value) {
4439 return isArrayLikeObject(value) ? value : [];
4443 * Casts `value` to `identity` if it's not a function.
4446 * @param {*} value The value to inspect.
4447 * @returns {Function} Returns cast function.
4449 function castFunction(value) {
4450 return typeof value == 'function' ? value : identity;
4454 * Casts `value` to a path array if it's not one.
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.
4461 function castPath(value, object) {
4462 if (isArray(value)) {
4465 return isKey(value, object) ? [value] : stringToPath(toString(value));
4469 * A `baseRest` alias which can be replaced with `identity` by module
4470 * replacement plugins.
4474 * @param {Function} func The function to apply a rest parameter to.
4475 * @returns {Function} Returns the new function.
4477 var castRest = baseRest;
4480 * Casts `array` to a slice if it's needed.
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.
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);
4495 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4498 * @param {number|Object} id The timer id or timeout object of the timer to clear.
4500 var clearTimeout = ctxClearTimeout || function(id) {
4501 return root.clearTimeout(id);
4505 * Creates a clone of `buffer`.
4508 * @param {Buffer} buffer The buffer to clone.
4509 * @param {boolean} [isDeep] Specify a deep clone.
4510 * @returns {Buffer} Returns the cloned buffer.
4512 function cloneBuffer(buffer, isDeep) {
4514 return buffer.slice();
4516 var length = buffer.length,
4517 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4519 buffer.copy(result);
4524 * Creates a clone of `arrayBuffer`.
4527 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4528 * @returns {ArrayBuffer} Returns the cloned array buffer.
4530 function cloneArrayBuffer(arrayBuffer) {
4531 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4532 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4537 * Creates a clone of `dataView`.
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.
4544 function cloneDataView(dataView, isDeep) {
4545 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4546 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4550 * Creates a clone of `regexp`.
4553 * @param {Object} regexp The regexp to clone.
4554 * @returns {Object} Returns the cloned regexp.
4556 function cloneRegExp(regexp) {
4557 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4558 result.lastIndex = regexp.lastIndex;
4563 * Creates a clone of the `symbol` object.
4566 * @param {Object} symbol The symbol object to clone.
4567 * @returns {Object} Returns the cloned symbol object.
4569 function cloneSymbol(symbol) {
4570 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4574 * Creates a clone of `typedArray`.
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.
4581 function cloneTypedArray(typedArray, isDeep) {
4582 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4583 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4587 * Compares values to sort them in ascending order.
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`.
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);
4601 var othIsDefined = other !== undefined,
4602 othIsNull = other === null,
4603 othIsReflexive = other === other,
4604 othIsSymbol = isSymbol(other);
4606 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4607 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4608 (valIsNull && othIsDefined && othIsReflexive) ||
4609 (!valIsDefined && othIsReflexive) ||
4613 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4614 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4615 (othIsNull && valIsDefined && valIsReflexive) ||
4616 (!othIsDefined && valIsReflexive) ||
4625 * Used by `_.orderBy` to compare multiple properties of a value to another
4626 * and stable sort them.
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.
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`.
4638 function compareMultiple(object, other, orders) {
4640 objCriteria = object.criteria,
4641 othCriteria = other.criteria,
4642 length = objCriteria.length,
4643 ordersLength = orders.length;
4645 while (++index < length) {
4646 var result = compareAscending(objCriteria[index], othCriteria[index]);
4648 if (index >= ordersLength) {
4651 var order = orders[index];
4652 return result * (order == 'desc' ? -1 : 1);
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.
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;
4666 * Creates an array that is the composition of partially applied arguments,
4667 * placeholders, and provided arguments into a single array of arguments.
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.
4676 function composeArgs(args, partials, holders, isCurried) {
4678 argsLength = args.length,
4679 holdersLength = holders.length,
4681 leftLength = partials.length,
4682 rangeLength = nativeMax(argsLength - holdersLength, 0),
4683 result = Array(leftLength + rangeLength),
4684 isUncurried = !isCurried;
4686 while (++leftIndex < leftLength) {
4687 result[leftIndex] = partials[leftIndex];
4689 while (++argsIndex < holdersLength) {
4690 if (isUncurried || argsIndex < argsLength) {
4691 result[holders[argsIndex]] = args[argsIndex];
4694 while (rangeLength--) {
4695 result[leftIndex++] = args[argsIndex++];
4701 * This function is like `composeArgs` except that the arguments composition
4702 * is tailored for `_.partialRight`.
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.
4711 function composeArgsRight(args, partials, holders, isCurried) {
4713 argsLength = args.length,
4715 holdersLength = holders.length,
4717 rightLength = partials.length,
4718 rangeLength = nativeMax(argsLength - holdersLength, 0),
4719 result = Array(rangeLength + rightLength),
4720 isUncurried = !isCurried;
4722 while (++argsIndex < rangeLength) {
4723 result[argsIndex] = args[argsIndex];
4725 var offset = argsIndex;
4726 while (++rightIndex < rightLength) {
4727 result[offset + rightIndex] = partials[rightIndex];
4729 while (++holdersIndex < holdersLength) {
4730 if (isUncurried || argsIndex < argsLength) {
4731 result[offset + holders[holdersIndex]] = args[argsIndex++];
4738 * Copies the values of `source` to `array`.
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`.
4745 function copyArray(source, array) {
4747 length = source.length;
4749 array || (array = Array(length));
4750 while (++index < length) {
4751 array[index] = source[index];
4757 * Copies properties of `source` to `object`.
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`.
4766 function copyObject(source, props, object, customizer) {
4767 var isNew = !object;
4768 object || (object = {});
4771 length = props.length;
4773 while (++index < length) {
4774 var key = props[index];
4776 var newValue = customizer
4777 ? customizer(object[key], source[key], key, object, source)
4780 if (newValue === undefined) {
4781 newValue = source[key];
4784 baseAssignValue(object, key, newValue);
4786 assignValue(object, key, newValue);
4793 * Copies own symbols of `source` to `object`.
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`.
4800 function copySymbols(source, object) {
4801 return copyObject(source, getSymbols(source), object);
4805 * Copies own and inherited symbols of `source` to `object`.
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`.
4812 function copySymbolsIn(source, object) {
4813 return copyObject(source, getSymbolsIn(source), object);
4817 * Creates a function like `_.groupBy`.
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.
4824 function createAggregator(setter, initializer) {
4825 return function(collection, iteratee) {
4826 var func = isArray(collection) ? arrayAggregator : baseAggregator,
4827 accumulator = initializer ? initializer() : {};
4829 return func(collection, setter, getIteratee(iteratee, 2), accumulator);
4834 * Creates a function like `_.assign`.
4837 * @param {Function} assigner The function to assign values.
4838 * @returns {Function} Returns the new assigner function.
4840 function createAssigner(assigner) {
4841 return baseRest(function(object, sources) {
4843 length = sources.length,
4844 customizer = length > 1 ? sources[length - 1] : undefined,
4845 guard = length > 2 ? sources[2] : undefined;
4847 customizer = (assigner.length > 3 && typeof customizer == 'function')
4848 ? (length--, customizer)
4851 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
4852 customizer = length < 3 ? undefined : customizer;
4855 object = Object(object);
4856 while (++index < length) {
4857 var source = sources[index];
4859 assigner(object, source, index, customizer);
4867 * Creates a `baseEach` or `baseEachRight` function.
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.
4874 function createBaseEach(eachFunc, fromRight) {
4875 return function(collection, iteratee) {
4876 if (collection == null) {
4879 if (!isArrayLike(collection)) {
4880 return eachFunc(collection, iteratee);
4882 var length = collection.length,
4883 index = fromRight ? length : -1,
4884 iterable = Object(collection);
4886 while ((fromRight ? index-- : ++index < length)) {
4887 if (iteratee(iterable[index], index, iterable) === false) {
4896 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
4899 * @param {boolean} [fromRight] Specify iterating from right to left.
4900 * @returns {Function} Returns the new base function.
4902 function createBaseFor(fromRight) {
4903 return function(object, iteratee, keysFunc) {
4905 iterable = Object(object),
4906 props = keysFunc(object),
4907 length = props.length;
4910 var key = props[fromRight ? length : ++index];
4911 if (iteratee(iterable[key], key, iterable) === false) {
4920 * Creates a function that wraps `func` to invoke it with the optional `this`
4921 * binding of `thisArg`.
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.
4929 function createBind(func, bitmask, thisArg) {
4930 var isBind = bitmask & WRAP_BIND_FLAG,
4931 Ctor = createCtor(func);
4933 function wrapper() {
4934 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4935 return fn.apply(isBind ? thisArg : this, arguments);
4941 * Creates a function like `_.lowerFirst`.
4944 * @param {string} methodName The name of the `String` case method to use.
4945 * @returns {Function} Returns the new case function.
4947 function createCaseFirst(methodName) {
4948 return function(string) {
4949 string = toString(string);
4951 var strSymbols = hasUnicode(string)
4952 ? stringToArray(string)
4955 var chr = strSymbols
4959 var trailing = strSymbols
4960 ? castSlice(strSymbols, 1).join('')
4963 return chr[methodName]() + trailing;
4968 * Creates a function like `_.camelCase`.
4971 * @param {Function} callback The function to combine each word.
4972 * @returns {Function} Returns the new compounder function.
4974 function createCompounder(callback) {
4975 return function(string) {
4976 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
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`.
4985 * @param {Function} Ctor The constructor to wrap.
4986 * @returns {Function} Returns the new wrapped function.
4988 function createCtor(Ctor) {
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]);
5004 var thisBinding = baseCreate(Ctor.prototype),
5005 result = Ctor.apply(thisBinding, args);
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;
5014 * Creates a function that wraps `func` to enable currying.
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.
5022 function createCurry(func, bitmask, arity) {
5023 var Ctor = createCtor(func);
5025 function wrapper() {
5026 var length = arguments.length,
5027 args = Array(length),
5029 placeholder = getHolder(wrapper);
5032 args[index] = arguments[index];
5034 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5036 : replaceHolders(args, placeholder);
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);
5044 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5045 return apply(fn, this, args);
5051 * Creates a `_.find` or `_.findLast` function.
5054 * @param {Function} findIndexFunc The function to find the collection index.
5055 * @returns {Function} Returns the new find function.
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); };
5065 var index = findIndexFunc(collection, predicate, fromIndex);
5066 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
5071 * Creates a `_.flow` or `_.flowRight` function.
5074 * @param {boolean} [fromRight] Specify iterating from right to left.
5075 * @returns {Function} Returns the new flow function.
5077 function createFlow(fromRight) {
5078 return flatRest(function(funcs) {
5079 var length = funcs.length,
5081 prereq = LodashWrapper.prototype.thru;
5087 var func = funcs[index];
5088 if (typeof func != 'function') {
5089 throw new TypeError(FUNC_ERROR_TEXT);
5091 if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5092 var wrapper = new LodashWrapper([], true);
5095 index = wrapper ? index : length;
5096 while (++index < length) {
5097 func = funcs[index];
5099 var funcName = getFuncName(func),
5100 data = funcName == 'wrapper' ? getData(func) : undefined;
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
5106 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5108 wrapper = (func.length == 1 && isLaziable(func))
5109 ? wrapper[funcName]()
5110 : wrapper.thru(func);
5114 var args = arguments,
5117 if (wrapper && args.length == 1 && isArray(value)) {
5118 return wrapper.plant(value).value();
5121 result = length ? funcs[index].apply(this, args) : value;
5123 while (++index < length) {
5124 result = funcs[index].call(this, result);
5132 * Creates a function that wraps `func` to invoke it with optional `this`
5133 * binding of `thisArg`, partial application, and currying.
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
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.
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);
5158 function wrapper() {
5159 var length = arguments.length,
5160 args = Array(length),
5164 args[index] = arguments[index];
5167 var placeholder = getHolder(wrapper),
5168 holdersCount = countHolders(args, placeholder);
5171 args = composeArgs(args, partials, holders, isCurried);
5173 if (partialsRight) {
5174 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
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
5184 var thisBinding = isBind ? thisArg : this,
5185 fn = isBindKey ? thisBinding[func] : func;
5187 length = args.length;
5189 args = reorder(args, argPos);
5190 } else if (isFlip && length > 1) {
5193 if (isAry && ary < length) {
5196 if (this && this !== root && this instanceof wrapper) {
5197 fn = Ctor || createCtor(fn);
5199 return fn.apply(thisBinding, args);
5205 * Creates a function like `_.invertBy`.
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.
5212 function createInverter(setter, toIteratee) {
5213 return function(object, iteratee) {
5214 return baseInverter(object, setter, toIteratee(iteratee), {});
5219 * Creates a function that performs a mathematical operation on two values.
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.
5226 function createMathOperation(operator, defaultValue) {
5227 return function(value, other) {
5229 if (value === undefined && other === undefined) {
5230 return defaultValue;
5232 if (value !== undefined) {
5235 if (other !== undefined) {
5236 if (result === undefined) {
5239 if (typeof value == 'string' || typeof other == 'string') {
5240 value = baseToString(value);
5241 other = baseToString(other);
5243 value = baseToNumber(value);
5244 other = baseToNumber(other);
5246 result = operator(value, other);
5253 * Creates a function like `_.over`.
5256 * @param {Function} arrayFunc The function to iterate over iteratees.
5257 * @returns {Function} Returns the new over function.
5259 function createOver(arrayFunc) {
5260 return flatRest(function(iteratees) {
5261 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5262 return baseRest(function(args) {
5264 return arrayFunc(iteratees, function(iteratee) {
5265 return apply(iteratee, thisArg, args);
5272 * Creates the padding for `string` based on `length`. The `chars` string
5273 * is truncated if the number of characters exceeds `length`.
5276 * @param {number} length The padding length.
5277 * @param {string} [chars=' '] The string used as padding.
5278 * @returns {string} Returns the padding for `string`.
5280 function createPadding(length, chars) {
5281 chars = chars === undefined ? ' ' : baseToString(chars);
5283 var charsLength = chars.length;
5284 if (charsLength < 2) {
5285 return charsLength ? baseRepeat(chars, length) : chars;
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);
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.
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
5303 * @returns {Function} Returns the new wrapped function.
5305 function createPartial(func, bitmask, thisArg, partials) {
5306 var isBind = bitmask & WRAP_BIND_FLAG,
5307 Ctor = createCtor(func);
5309 function wrapper() {
5311 argsLength = arguments.length,
5313 leftLength = partials.length,
5314 args = Array(leftLength + argsLength),
5315 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5317 while (++leftIndex < leftLength) {
5318 args[leftIndex] = partials[leftIndex];
5320 while (argsLength--) {
5321 args[leftIndex++] = arguments[++argsIndex];
5323 return apply(fn, isBind ? thisArg : this, args);
5329 * Creates a `_.range` or `_.rangeRight` function.
5332 * @param {boolean} [fromRight] Specify iterating from right to left.
5333 * @returns {Function} Returns the new range function.
5335 function createRange(fromRight) {
5336 return function(start, end, step) {
5337 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5338 end = step = undefined;
5340 // Ensure the sign of `-0` is preserved.
5341 start = toFinite(start);
5342 if (end === undefined) {
5346 end = toFinite(end);
5348 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
5349 return baseRange(start, end, step, fromRight);
5354 * Creates a function that performs a relational operation on two values.
5357 * @param {Function} operator The function to perform the operation.
5358 * @returns {Function} Returns the new relational operation function.
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);
5366 return operator(value, other);
5371 * Creates a function that wraps `func` to continue currying.
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
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.
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;
5394 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
5395 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
5397 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
5398 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
5401 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5402 newHoldersRight, argPos, ary, arity
5405 var result = wrapFunc.apply(undefined, newData);
5406 if (isLaziable(func)) {
5407 setData(result, newData);
5409 result.placeholder = placeholder;
5410 return setWrapToString(result, func, bitmask);
5414 * Creates a function like `_.round`.
5417 * @param {string} methodName The name of the `Math` method to use when rounding.
5418 * @returns {Function} Returns the new round function.
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));
5431 pair = (toString(value) + 'e').split('e');
5432 return +(pair[0] + 'e' + (+pair[1] - precision));
5434 return func(number);
5439 * Creates a set object of `values`.
5442 * @param {Array} values The values to add to the set.
5443 * @returns {Object} Returns the new set.
5445 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
5446 return new Set(values);
5450 * Creates a `_.toPairs` or `_.toPairsIn` function.
5453 * @param {Function} keysFunc The function to get the keys of a given object.
5454 * @returns {Function} Returns the new pairs function.
5456 function createToPairs(keysFunc) {
5457 return function(object) {
5458 var tag = getTag(object);
5459 if (tag == mapTag) {
5460 return mapToArray(object);
5462 if (tag == setTag) {
5463 return setToPairs(object);
5465 return baseToPairs(object, keysFunc(object));
5470 * Creates a function that either curries or invokes `func` with optional
5471 * `this` binding and partially applied arguments.
5474 * @param {Function|string} func The function or method name to wrap.
5475 * @param {number} bitmask The bitmask flags.
5478 * 4 - `_.curry` or `_.curryRight` of a bound function
5480 * 16 - `_.curryRight`
5482 * 64 - `_.partialRight`
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.
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);
5499 var length = partials ? partials.length : 0;
5501 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
5502 partials = holders = undefined;
5504 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
5505 arity = arity === undefined ? arity : toInteger(arity);
5506 length -= holders ? holders.length : 0;
5508 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
5509 var partialsRight = partials,
5510 holdersRight = holders;
5512 partials = holders = undefined;
5514 var data = isBindKey ? undefined : getData(func);
5517 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5522 mergeData(newData, data);
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);
5533 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
5534 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
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);
5543 result = createHybrid.apply(undefined, newData);
5545 var setter = data ? baseSetData : setData;
5546 return setWrapToString(setter(result, newData), func, bitmask);
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`.
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.
5561 function customDefaultsAssignIn(objValue, srcValue, key, object) {
5562 if (objValue === undefined ||
5563 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
5570 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
5571 * objects into destination objects that are passed thru.
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
5581 * @returns {*} Returns the value to assign.
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);
5594 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
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`.
5602 function customOmitClone(value) {
5603 return isPlainObject(value) ? undefined : value;
5607 * A specialized version of `baseIsEqualDeep` for arrays with support for
5608 * partial deep comparisons.
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`.
5619 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
5620 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5621 arrLength = array.length,
5622 othLength = other.length;
5624 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5627 // Assume cyclic values are equal.
5628 var stacked = stack.get(array);
5629 if (stacked && stack.get(other)) {
5630 return stacked == other;
5634 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
5636 stack.set(array, other);
5637 stack.set(other, array);
5639 // Ignore non-index properties.
5640 while (++index < arrLength) {
5641 var arrValue = array[index],
5642 othValue = other[index];
5645 var compared = isPartial
5646 ? customizer(othValue, arrValue, index, other, array, stack)
5647 : customizer(arrValue, othValue, index, array, other, stack);
5649 if (compared !== undefined) {
5656 // Recursively compare arrays (susceptible to call stack limits).
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);
5668 arrValue === othValue ||
5669 equalFunc(arrValue, othValue, bitmask, customizer, stack)
5675 stack['delete'](array);
5676 stack['delete'](other);
5681 * A specialized version of `baseIsEqualDeep` for comparing objects of
5682 * the same `toStringTag`.
5684 * **Note:** This function only supports comparing values with tags of
5685 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
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`.
5697 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
5700 if ((object.byteLength != other.byteLength) ||
5701 (object.byteOffset != other.byteOffset)) {
5704 object = object.buffer;
5705 other = other.buffer;
5707 case arrayBufferTag:
5708 if ((object.byteLength != other.byteLength) ||
5709 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5717 // Coerce booleans to `1` or `0` and dates to milliseconds.
5718 // Invalid dates are coerced to `NaN`.
5719 return eq(+object, +other);
5722 return object.name == other.name && object.message == other.message;
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 + '');
5732 var convert = mapToArray;
5735 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
5736 convert || (convert = setToArray);
5738 if (object.size != other.size && !isPartial) {
5741 // Assume cyclic values are equal.
5742 var stacked = stack.get(object);
5744 return stacked == other;
5746 bitmask |= COMPARE_UNORDERED_FLAG;
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);
5755 if (symbolValueOf) {
5756 return symbolValueOf.call(object) == symbolValueOf.call(other);
5763 * A specialized version of `baseIsEqualDeep` for objects with support for
5764 * partial deep comparisons.
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`.
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;
5782 if (objLength != othLength && !isPartial) {
5785 var index = objLength;
5787 var key = objProps[index];
5788 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
5792 // Assume cyclic values are equal.
5793 var stacked = stack.get(object);
5794 if (stacked && stack.get(other)) {
5795 return stacked == other;
5798 stack.set(object, other);
5799 stack.set(other, object);
5801 var skipCtor = isPartial;
5802 while (++index < objLength) {
5803 key = objProps[index];
5804 var objValue = object[key],
5805 othValue = other[key];
5808 var compared = isPartial
5809 ? customizer(othValue, objValue, key, other, object, stack)
5810 : customizer(objValue, othValue, key, object, other, stack);
5812 // Recursively compare objects (susceptible to call stack limits).
5813 if (!(compared === undefined
5814 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
5820 skipCtor || (skipCtor = key == 'constructor');
5822 if (result && !skipCtor) {
5823 var objCtor = object.constructor,
5824 othCtor = other.constructor;
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)) {
5834 stack['delete'](object);
5835 stack['delete'](other);
5840 * A specialized version of `baseRest` which flattens the rest array.
5843 * @param {Function} func The function to apply a rest parameter to.
5844 * @returns {Function} Returns the new function.
5846 function flatRest(func) {
5847 return setToString(overRest(func, undefined, flatten), func + '');
5851 * Creates an array of own enumerable property names and symbols of `object`.
5854 * @param {Object} object The object to query.
5855 * @returns {Array} Returns the array of property names and symbols.
5857 function getAllKeys(object) {
5858 return baseGetAllKeys(object, keys, getSymbols);
5862 * Creates an array of own and inherited enumerable property names and
5863 * symbols of `object`.
5866 * @param {Object} object The object to query.
5867 * @returns {Array} Returns the array of property names and symbols.
5869 function getAllKeysIn(object) {
5870 return baseGetAllKeys(object, keysIn, getSymbolsIn);
5874 * Gets metadata for `func`.
5877 * @param {Function} func The function to query.
5878 * @returns {*} Returns the metadata for `func`.
5880 var getData = !metaMap ? noop : function(func) {
5881 return metaMap.get(func);
5885 * Gets the name of `func`.
5888 * @param {Function} func The function to query.
5889 * @returns {string} Returns the function name.
5891 function getFuncName(func) {
5892 var result = (func.name + ''),
5893 array = realNames[result],
5894 length = hasOwnProperty.call(realNames, result) ? array.length : 0;
5897 var data = array[length],
5898 otherFunc = data.func;
5899 if (otherFunc == null || otherFunc == func) {
5907 * Gets the argument placeholder value for `func`.
5910 * @param {Function} func The function to inspect.
5911 * @returns {*} Returns the placeholder value.
5913 function getHolder(func) {
5914 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
5915 return object.placeholder;
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.
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.
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;
5936 * Gets the data for `map`.
5939 * @param {Object} map The map to query.
5940 * @param {string} key The reference key.
5941 * @returns {*} Returns the map data.
5943 function getMapData(map, key) {
5944 var data = map.__data__;
5945 return isKeyable(key)
5946 ? data[typeof key == 'string' ? 'string' : 'hash']
5951 * Gets the property names, values, and compare flags of `object`.
5954 * @param {Object} object The object to query.
5955 * @returns {Array} Returns the match data of `object`.
5957 function getMatchData(object) {
5958 var result = keys(object),
5959 length = result.length;
5962 var key = result[length],
5963 value = object[key];
5965 result[length] = [key, value, isStrictComparable(value)];
5971 * Gets the native function at `key` of `object`.
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`.
5978 function getNative(object, key) {
5979 var value = getValue(object, key);
5980 return baseIsNative(value) ? value : undefined;
5984 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
5987 * @param {*} value The value to query.
5988 * @returns {string} Returns the raw `toStringTag`.
5990 function getRawTag(value) {
5991 var isOwn = hasOwnProperty.call(value, symToStringTag),
5992 tag = value[symToStringTag];
5995 value[symToStringTag] = undefined;
5996 var unmasked = true;
5999 var result = nativeObjectToString.call(value);
6002 value[symToStringTag] = tag;
6004 delete value[symToStringTag];
6011 * Creates an array of the own enumerable symbols of `object`.
6014 * @param {Object} object The object to query.
6015 * @returns {Array} Returns the array of symbols.
6017 var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
6018 if (object == null) {
6021 object = Object(object);
6022 return arrayFilter(nativeGetSymbols(object), function(symbol) {
6023 return propertyIsEnumerable.call(object, symbol);
6028 * Creates an array of the own and inherited enumerable symbols of `object`.
6031 * @param {Object} object The object to query.
6032 * @returns {Array} Returns the array of symbols.
6034 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6037 arrayPush(result, getSymbols(object));
6038 object = getPrototype(object);
6044 * Gets the `toStringTag` of `value`.
6047 * @param {*} value The value to query.
6048 * @returns {string} Returns the `toStringTag`.
6050 var getTag = baseGetTag;
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) : '';
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;
6077 * Gets the view, applying any `transforms` to the `start` and `end` positions.
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.
6086 function getView(start, end, transforms) {
6088 length = transforms.length;
6090 while (++index < length) {
6091 var data = transforms[index],
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;
6101 return { 'start': start, 'end': end };
6105 * Extracts wrapper details from the `source` body comment.
6108 * @param {string} source The source to inspect.
6109 * @returns {Array} Returns the wrapper details.
6111 function getWrapDetails(source) {
6112 var match = source.match(reWrapDetails);
6113 return match ? match[1].split(reSplitDetails) : [];
6117 * Checks if `path` exists on `object`.
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`.
6125 function hasPath(object, path, hasFunc) {
6126 path = castPath(path, object);
6129 length = path.length,
6132 while (++index < length) {
6133 var key = toKey(path[index]);
6134 if (!(result = object != null && hasFunc(object, key))) {
6137 object = object[key];
6139 if (result || ++index != length) {
6142 length = object == null ? 0 : object.length;
6143 return !!length && isLength(length) && isIndex(key, length) &&
6144 (isArray(object) || isArguments(object));
6148 * Initializes an array clone.
6151 * @param {Array} array The array to clone.
6152 * @returns {Array} Returns the initialized clone.
6154 function initCloneArray(array) {
6155 var length = array.length,
6156 result = new array.constructor(length);
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;
6167 * Initializes an object clone.
6170 * @param {Object} object The object to clone.
6171 * @returns {Object} Returns the initialized clone.
6173 function initCloneObject(object) {
6174 return (typeof object.constructor == 'function' && !isPrototype(object))
6175 ? baseCreate(getPrototype(object))
6180 * Initializes an object clone based on its `toStringTag`.
6182 * **Note:** This function only supports cloning values with tags of
6183 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
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.
6191 function initCloneByTag(object, tag, isDeep) {
6192 var Ctor = object.constructor;
6194 case arrayBufferTag:
6195 return cloneArrayBuffer(object);
6199 return new Ctor(+object);
6202 return cloneDataView(object, isDeep);
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);
6214 return new Ctor(object);
6217 return cloneRegExp(object);
6223 return cloneSymbol(object);
6228 * Inserts wrapper `details` in a comment at the top of the `source` body.
6231 * @param {string} source The source to modify.
6232 * @returns {Array} details The details to insert.
6233 * @returns {string} Returns the modified source.
6235 function insertWrapDetails(source, details) {
6236 var length = details.length;
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');
6247 * Checks if `value` is a flattenable `arguments` object or array.
6250 * @param {*} value The value to check.
6251 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6253 function isFlattenable(value) {
6254 return isArray(value) || isArguments(value) ||
6255 !!(spreadableSymbol && value && value[spreadableSymbol]);
6259 * Checks if `value` is a valid array-like index.
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`.
6266 function isIndex(value, length) {
6267 var type = typeof value;
6268 length = length == null ? MAX_SAFE_INTEGER : length;
6271 (type == 'number' ||
6272 (type != 'symbol' && reIsUint.test(value))) &&
6273 (value > -1 && value % 1 == 0 && value < length);
6277 * Checks if the given arguments are from an iteratee call.
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,
6286 function isIterateeCall(value, index, object) {
6287 if (!isObject(object)) {
6290 var type = typeof index;
6291 if (type == 'number'
6292 ? (isArrayLike(object) && isIndex(index, object.length))
6293 : (type == 'string' && index in object)
6295 return eq(object[index], value);
6301 * Checks if `value` is a property name and not a property path.
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`.
6308 function isKey(value, object) {
6309 if (isArray(value)) {
6312 var type = typeof value;
6313 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6314 value == null || isSymbol(value)) {
6317 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6318 (object != null && value in Object(object));
6322 * Checks if `value` is suitable for use as unique object key.
6325 * @param {*} value The value to check.
6326 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6328 function isKeyable(value) {
6329 var type = typeof value;
6330 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
6331 ? (value !== '__proto__')
6336 * Checks if `func` has a lazy counterpart.
6339 * @param {Function} func The function to check.
6340 * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6343 function isLaziable(func) {
6344 var funcName = getFuncName(func),
6345 other = lodash[funcName];
6347 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6350 if (func === other) {
6353 var data = getData(other);
6354 return !!data && func === data[0];
6358 * Checks if `func` has its source masked.
6361 * @param {Function} func The function to check.
6362 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6364 function isMasked(func) {
6365 return !!maskSrcKey && (maskSrcKey in func);
6369 * Checks if `func` is capable of being masked.
6372 * @param {*} value The value to check.
6373 * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6375 var isMaskable = coreJsData ? isFunction : stubFalse;
6378 * Checks if `value` is likely a prototype object.
6381 * @param {*} value The value to check.
6382 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6384 function isPrototype(value) {
6385 var Ctor = value && value.constructor,
6386 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6388 return value === proto;
6392 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6395 * @param {*} value The value to check.
6396 * @returns {boolean} Returns `true` if `value` if suitable for strict
6397 * equality comparisons, else `false`.
6399 function isStrictComparable(value) {
6400 return value === value && !isObject(value);
6404 * A specialized version of `matchesProperty` for source values suitable
6405 * for strict equality comparisons, i.e. `===`.
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.
6412 function matchesStrictComparable(key, srcValue) {
6413 return function(object) {
6414 if (object == null) {
6417 return object[key] === srcValue &&
6418 (srcValue !== undefined || (key in Object(object)));
6423 * A specialized version of `_.memoize` which clears the memoized function's
6424 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6427 * @param {Function} func The function to have its output memoized.
6428 * @returns {Function} Returns the new memoized function.
6430 function memoizeCapped(func) {
6431 var result = memoize(func, function(key) {
6432 if (cache.size === MAX_MEMOIZE_SIZE) {
6438 var cache = result.cache;
6443 * Merges the function metadata of `source` into `data`.
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.
6454 * @param {Array} data The destination metadata.
6455 * @param {Array} source The source metadata.
6456 * @returns {Array} Returns `data`.
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);
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));
6469 // Exit early if metadata can't be merged.
6470 if (!(isCommon || isCombo)) {
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;
6479 // Compose partial arguments.
6480 var value = source[3];
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];
6486 // Compose partial right arguments.
6490 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6491 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6493 // Use source `argPos` if available.
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]);
6502 // Use source `arity` if one is not provided.
6503 if (data[9] == null) {
6504 data[9] = source[9];
6506 // Use source `func` and merge bitmasks.
6507 data[0] = source[0];
6508 data[1] = newBitmask;
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.
6519 * @param {Object} object The object to query.
6520 * @returns {Array} Returns the array of property names.
6522 function nativeKeysIn(object) {
6524 if (object != null) {
6525 for (var key in Object(object)) {
6533 * Converts `value` to a string using `Object.prototype.toString`.
6536 * @param {*} value The value to convert.
6537 * @returns {string} Returns the converted string.
6539 function objectToString(value) {
6540 return nativeObjectToString.call(value);
6544 * A specialized version of `baseRest` which transforms the rest array.
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.
6552 function overRest(func, start, transform) {
6553 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
6555 var args = arguments,
6557 length = nativeMax(args.length - start, 0),
6558 array = Array(length);
6560 while (++index < length) {
6561 array[index] = args[start + index];
6564 var otherArgs = Array(start + 1);
6565 while (++index < start) {
6566 otherArgs[index] = args[index];
6568 otherArgs[start] = transform(array);
6569 return apply(func, this, otherArgs);
6574 * Gets the parent value at `path` of `object`.
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.
6581 function parent(object, path) {
6582 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
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.
6591 * @param {Array} array The array to reorder.
6592 * @param {Array} indexes The arranged array indexes.
6593 * @returns {Array} Returns `array`.
6595 function reorder(array, indexes) {
6596 var arrLength = array.length,
6597 length = nativeMin(indexes.length, arrLength),
6598 oldArray = copyArray(array);
6601 var index = indexes[length];
6602 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
6608 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
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.
6615 function safeGet(object, key) {
6616 if (key === 'constructor' && typeof object[key] === 'function') {
6620 if (key == '__proto__') {
6628 * Sets metadata for `func`.
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)
6637 * @param {Function} func The function to associate metadata with.
6638 * @param {*} data The metadata.
6639 * @returns {Function} Returns `func`.
6641 var setData = shortOut(baseSetData);
6644 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
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.
6651 var setTimeout = ctxSetTimeout || function(func, wait) {
6652 return root.setTimeout(func, wait);
6656 * Sets the `toString` method of `func` to return `string`.
6659 * @param {Function} func The function to modify.
6660 * @param {Function} string The `toString` result.
6661 * @returns {Function} Returns `func`.
6663 var setToString = shortOut(baseSetToString);
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.
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`.
6675 function setWrapToString(wrapper, reference, bitmask) {
6676 var source = (reference + '');
6677 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
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`
6686 * @param {Function} func The function to restrict.
6687 * @returns {Function} Returns the new shortable function.
6689 function shortOut(func) {
6694 var stamp = nativeNow(),
6695 remaining = HOT_SPAN - (stamp - lastCalled);
6698 if (remaining > 0) {
6699 if (++count >= HOT_COUNT) {
6700 return arguments[0];
6705 return func.apply(undefined, arguments);
6710 * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
6713 * @param {Array} array The array to shuffle.
6714 * @param {number} [size=array.length] The size of `array`.
6715 * @returns {Array} Returns `array`.
6717 function shuffleSelf(array, size) {
6719 length = array.length,
6720 lastIndex = length - 1;
6722 size = size === undefined ? length : size;
6723 while (++index < size) {
6724 var rand = baseRandom(index, lastIndex),
6725 value = array[rand];
6727 array[rand] = array[index];
6728 array[index] = value;
6730 array.length = size;
6735 * Converts `string` to a property path array.
6738 * @param {string} string The string to convert.
6739 * @returns {Array} Returns the property path array.
6741 var stringToPath = memoizeCapped(function(string) {
6743 if (string.charCodeAt(0) === 46 /* . */) {
6746 string.replace(rePropName, function(match, number, quote, subString) {
6747 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
6753 * Converts `value` to a string key if it's not a string or symbol.
6756 * @param {*} value The value to inspect.
6757 * @returns {string|symbol} Returns the key.
6759 function toKey(value) {
6760 if (typeof value == 'string' || isSymbol(value)) {
6763 var result = (value + '');
6764 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
6768 * Converts `func` to its source code.
6771 * @param {Function} func The function to convert.
6772 * @returns {string} Returns the source code.
6774 function toSource(func) {
6777 return funcToString.call(func);
6787 * Updates wrapper `details` based on `bitmask` flags.
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`.
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);
6801 return details.sort();
6805 * Creates a clone of `wrapper`.
6808 * @param {Object} wrapper The wrapper to clone.
6809 * @returns {Object} Returns the cloned wrapper.
6811 function wrapperClone(wrapper) {
6812 if (wrapper instanceof LazyWrapper) {
6813 return wrapper.clone();
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__;
6822 /*------------------------------------------------------------------------*/
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
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.
6839 * _.chunk(['a', 'b', 'c', 'd'], 2);
6840 * // => [['a', 'b'], ['c', 'd']]
6842 * _.chunk(['a', 'b', 'c', 'd'], 3);
6843 * // => [['a', 'b', 'c'], ['d']]
6845 function chunk(array, size, guard) {
6846 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
6849 size = nativeMax(toInteger(size), 0);
6851 var length = array == null ? 0 : array.length;
6852 if (!length || size < 1) {
6857 result = Array(nativeCeil(length / size));
6859 while (index < length) {
6860 result[resIndex++] = baseSlice(array, index, (index += size));
6866 * Creates an array with all falsey values removed. The values `false`, `null`,
6867 * `0`, `""`, `undefined`, and `NaN` are falsey.
6873 * @param {Array} array The array to compact.
6874 * @returns {Array} Returns the new array of filtered values.
6877 * _.compact([0, 1, false, 2, '', 3]);
6880 function compact(array) {
6882 length = array == null ? 0 : array.length,
6886 while (++index < length) {
6887 var value = array[index];
6889 result[resIndex++] = value;
6896 * Creates a new array concatenating `array` with any additional arrays
6903 * @param {Array} array The array to concatenate.
6904 * @param {...*} [values] The values to concatenate.
6905 * @returns {Array} Returns the new concatenated array.
6909 * var other = _.concat(array, 2, [3], [[4]]);
6911 * console.log(other);
6912 * // => [1, 2, 3, [4]]
6914 * console.log(array);
6918 var length = arguments.length;
6922 var args = Array(length - 1),
6923 array = arguments[0],
6927 args[index - 1] = arguments[index];
6929 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
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.
6938 * **Note:** Unlike `_.pullAll`, this method returns a new 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
6950 * _.difference([2, 1], [2, 3]);
6953 var difference = baseRest(function(array, values) {
6954 return isArrayLikeObject(array)
6955 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
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:
6966 * **Note:** Unlike `_.pullAllBy`, this method returns a new 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.
6978 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
6981 * // The `_.property` iteratee shorthand.
6982 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
6983 * // => [{ 'x': 2 }]
6985 var differenceBy = baseRest(function(array, values) {
6986 var iteratee = last(values);
6987 if (isArrayLikeObject(iteratee)) {
6988 iteratee = undefined;
6990 return isArrayLikeObject(array)
6991 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
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).
7001 * **Note:** Unlike `_.pullAllWith`, this method returns a new 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.
7013 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7015 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
7016 * // => [{ 'x': 2, 'y': 1 }]
7018 var differenceWith = baseRest(function(array, values) {
7019 var comparator = last(values);
7020 if (isArrayLikeObject(comparator)) {
7021 comparator = undefined;
7023 return isArrayLikeObject(array)
7024 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
7029 * Creates a slice of `array` with `n` elements dropped from the beginning.
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`.
7041 * _.drop([1, 2, 3]);
7044 * _.drop([1, 2, 3], 2);
7047 * _.drop([1, 2, 3], 5);
7050 * _.drop([1, 2, 3], 0);
7053 function drop(array, n, guard) {
7054 var length = array == null ? 0 : array.length;
7058 n = (guard || n === undefined) ? 1 : toInteger(n);
7059 return baseSlice(array, n < 0 ? 0 : n, length);
7063 * Creates a slice of `array` with `n` elements dropped from the end.
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`.
7075 * _.dropRight([1, 2, 3]);
7078 * _.dropRight([1, 2, 3], 2);
7081 * _.dropRight([1, 2, 3], 5);
7084 * _.dropRight([1, 2, 3], 0);
7087 function dropRight(array, n, guard) {
7088 var length = array == null ? 0 : array.length;
7092 n = (guard || n === undefined) ? 1 : toInteger(n);
7094 return baseSlice(array, 0, n < 0 ? 0 : n);
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).
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`.
7112 * { 'user': 'barney', 'active': true },
7113 * { 'user': 'fred', 'active': false },
7114 * { 'user': 'pebbles', 'active': false }
7117 * _.dropRightWhile(users, function(o) { return !o.active; });
7118 * // => objects for ['barney']
7120 * // The `_.matches` iteratee shorthand.
7121 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7122 * // => objects for ['barney', 'fred']
7124 * // The `_.matchesProperty` iteratee shorthand.
7125 * _.dropRightWhile(users, ['active', false]);
7126 * // => objects for ['barney']
7128 * // The `_.property` iteratee shorthand.
7129 * _.dropRightWhile(users, 'active');
7130 * // => objects for ['barney', 'fred', 'pebbles']
7132 function dropRightWhile(array, predicate) {
7133 return (array && array.length)
7134 ? baseWhile(array, getIteratee(predicate, 3), true, true)
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).
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`.
7153 * { 'user': 'barney', 'active': false },
7154 * { 'user': 'fred', 'active': false },
7155 * { 'user': 'pebbles', 'active': true }
7158 * _.dropWhile(users, function(o) { return !o.active; });
7159 * // => objects for ['pebbles']
7161 * // The `_.matches` iteratee shorthand.
7162 * _.dropWhile(users, { 'user': 'barney', 'active': false });
7163 * // => objects for ['fred', 'pebbles']
7165 * // The `_.matchesProperty` iteratee shorthand.
7166 * _.dropWhile(users, ['active', false]);
7167 * // => objects for ['pebbles']
7169 * // The `_.property` iteratee shorthand.
7170 * _.dropWhile(users, 'active');
7171 * // => objects for ['barney', 'fred', 'pebbles']
7173 function dropWhile(array, predicate) {
7174 return (array && array.length)
7175 ? baseWhile(array, getIteratee(predicate, 3), true)
7180 * Fills elements of `array` with `value` from `start` up to, but not
7183 * **Note:** This method mutates `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`.
7196 * var array = [1, 2, 3];
7198 * _.fill(array, 'a');
7199 * console.log(array);
7200 * // => ['a', 'a', 'a']
7202 * _.fill(Array(3), 2);
7205 * _.fill([4, 6, 8, 10], '*', 1, 3);
7206 * // => [4, '*', '*', 10]
7208 function fill(array, value, start, end) {
7209 var length = array == null ? 0 : array.length;
7213 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7217 return baseFill(array, value, start, end);
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.
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`.
7235 * { 'user': 'barney', 'active': false },
7236 * { 'user': 'fred', 'active': false },
7237 * { 'user': 'pebbles', 'active': true }
7240 * _.findIndex(users, function(o) { return o.user == 'barney'; });
7243 * // The `_.matches` iteratee shorthand.
7244 * _.findIndex(users, { 'user': 'fred', 'active': false });
7247 * // The `_.matchesProperty` iteratee shorthand.
7248 * _.findIndex(users, ['active', false]);
7251 * // The `_.property` iteratee shorthand.
7252 * _.findIndex(users, 'active');
7255 function findIndex(array, predicate, fromIndex) {
7256 var length = array == null ? 0 : array.length;
7260 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7262 index = nativeMax(length + index, 0);
7264 return baseFindIndex(array, getIteratee(predicate, 3), index);
7268 * This method is like `_.findIndex` except that it iterates over elements
7269 * of `collection` from right to left.
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`.
7282 * { 'user': 'barney', 'active': true },
7283 * { 'user': 'fred', 'active': false },
7284 * { 'user': 'pebbles', 'active': false }
7287 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7290 * // The `_.matches` iteratee shorthand.
7291 * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7294 * // The `_.matchesProperty` iteratee shorthand.
7295 * _.findLastIndex(users, ['active', false]);
7298 * // The `_.property` iteratee shorthand.
7299 * _.findLastIndex(users, 'active');
7302 function findLastIndex(array, predicate, fromIndex) {
7303 var length = array == null ? 0 : array.length;
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);
7314 return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7318 * Flattens `array` a single level deep.
7324 * @param {Array} array The array to flatten.
7325 * @returns {Array} Returns the new flattened array.
7328 * _.flatten([1, [2, [3, [4]], 5]]);
7329 * // => [1, 2, [3, [4]], 5]
7331 function flatten(array) {
7332 var length = array == null ? 0 : array.length;
7333 return length ? baseFlatten(array, 1) : [];
7337 * Recursively flattens `array`.
7343 * @param {Array} array The array to flatten.
7344 * @returns {Array} Returns the new flattened array.
7347 * _.flattenDeep([1, [2, [3, [4]], 5]]);
7348 * // => [1, 2, 3, 4, 5]
7350 function flattenDeep(array) {
7351 var length = array == null ? 0 : array.length;
7352 return length ? baseFlatten(array, INFINITY) : [];
7356 * Recursively flatten `array` up to `depth` times.
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.
7367 * var array = [1, [2, [3, [4]], 5]];
7369 * _.flattenDepth(array, 1);
7370 * // => [1, 2, [3, [4]], 5]
7372 * _.flattenDepth(array, 2);
7373 * // => [1, 2, 3, [4], 5]
7375 function flattenDepth(array, depth) {
7376 var length = array == null ? 0 : array.length;
7380 depth = depth === undefined ? 1 : toInteger(depth);
7381 return baseFlatten(array, depth);
7385 * The inverse of `_.toPairs`; this method returns an object composed
7386 * from key-value `pairs`.
7392 * @param {Array} pairs The key-value pairs.
7393 * @returns {Object} Returns the new object.
7396 * _.fromPairs([['a', 1], ['b', 2]]);
7397 * // => { 'a': 1, 'b': 2 }
7399 function fromPairs(pairs) {
7401 length = pairs == null ? 0 : pairs.length,
7404 while (++index < length) {
7405 var pair = pairs[index];
7406 result[pair[0]] = pair[1];
7412 * Gets the first element of `array`.
7419 * @param {Array} array The array to query.
7420 * @returns {*} Returns the first element of `array`.
7423 * _.head([1, 2, 3]);
7429 function head(array) {
7430 return (array && array.length) ? array[0] : undefined;
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`.
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`.
7449 * _.indexOf([1, 2, 1, 2], 2);
7452 * // Search from the `fromIndex`.
7453 * _.indexOf([1, 2, 1, 2], 2, 2);
7456 function indexOf(array, value, fromIndex) {
7457 var length = array == null ? 0 : array.length;
7461 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7463 index = nativeMax(length + index, 0);
7465 return baseIndexOf(array, value, index);
7469 * Gets all but the last element of `array`.
7475 * @param {Array} array The array to query.
7476 * @returns {Array} Returns the slice of `array`.
7479 * _.initial([1, 2, 3]);
7482 function initial(array) {
7483 var length = array == null ? 0 : array.length;
7484 return length ? baseSlice(array, 0, -1) : [];
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.
7497 * @param {...Array} [arrays] The arrays to inspect.
7498 * @returns {Array} Returns the new array of intersecting values.
7501 * _.intersection([2, 1], [2, 3]);
7504 var intersection = baseRest(function(arrays) {
7505 var mapped = arrayMap(arrays, castArrayLikeObject);
7506 return (mapped.length && mapped[0] === arrays[0])
7507 ? baseIntersection(mapped)
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:
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.
7527 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7530 * // The `_.property` iteratee shorthand.
7531 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7532 * // => [{ 'x': 1 }]
7534 var intersectionBy = baseRest(function(arrays) {
7535 var iteratee = last(arrays),
7536 mapped = arrayMap(arrays, castArrayLikeObject);
7538 if (iteratee === last(mapped)) {
7539 iteratee = undefined;
7543 return (mapped.length && mapped[0] === arrays[0])
7544 ? baseIntersection(mapped, getIteratee(iteratee, 2))
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).
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.
7563 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7564 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7566 * _.intersectionWith(objects, others, _.isEqual);
7567 * // => [{ 'x': 1, 'y': 2 }]
7569 var intersectionWith = baseRest(function(arrays) {
7570 var comparator = last(arrays),
7571 mapped = arrayMap(arrays, castArrayLikeObject);
7573 comparator = typeof comparator == 'function' ? comparator : undefined;
7577 return (mapped.length && mapped[0] === arrays[0])
7578 ? baseIntersection(mapped, undefined, comparator)
7583 * Converts all elements in `array` into a string separated by `separator`.
7589 * @param {Array} array The array to convert.
7590 * @param {string} [separator=','] The element separator.
7591 * @returns {string} Returns the joined string.
7594 * _.join(['a', 'b', 'c'], '~');
7597 function join(array, separator) {
7598 return array == null ? '' : nativeJoin.call(array, separator);
7602 * Gets the last element of `array`.
7608 * @param {Array} array The array to query.
7609 * @returns {*} Returns the last element of `array`.
7612 * _.last([1, 2, 3]);
7615 function last(array) {
7616 var length = array == null ? 0 : array.length;
7617 return length ? array[length - 1] : undefined;
7621 * This method is like `_.indexOf` except that it iterates over elements of
7622 * `array` from right to left.
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`.
7634 * _.lastIndexOf([1, 2, 1, 2], 2);
7637 * // Search from the `fromIndex`.
7638 * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7641 function lastIndexOf(array, value, fromIndex) {
7642 var length = array == null ? 0 : array.length;
7647 if (fromIndex !== undefined) {
7648 index = toInteger(fromIndex);
7649 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7651 return value === value
7652 ? strictLastIndexOf(array, value, index)
7653 : baseFindIndex(array, baseIsNaN, index, true);
7657 * Gets the element at index `n` of `array`. If `n` is negative, the nth
7658 * element from the end is returned.
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`.
7669 * var array = ['a', 'b', 'c', 'd'];
7677 function nth(array, n) {
7678 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
7682 * Removes all given values from `array` using
7683 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7684 * for equality comparisons.
7686 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
7687 * to remove elements from an array by predicate.
7693 * @param {Array} array The array to modify.
7694 * @param {...*} [values] The values to remove.
7695 * @returns {Array} Returns `array`.
7698 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7700 * _.pull(array, 'a', 'c');
7701 * console.log(array);
7704 var pull = baseRest(pullAll);
7707 * This method is like `_.pull` except that it accepts an array of values to remove.
7709 * **Note:** Unlike `_.difference`, this method mutates `array`.
7715 * @param {Array} array The array to modify.
7716 * @param {Array} values The values to remove.
7717 * @returns {Array} Returns `array`.
7720 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7722 * _.pullAll(array, ['a', 'c']);
7723 * console.log(array);
7726 function pullAll(array, values) {
7727 return (array && array.length && values && values.length)
7728 ? basePullAll(array, values)
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).
7737 * **Note:** Unlike `_.differenceBy`, this method mutates `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`.
7749 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
7751 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
7752 * console.log(array);
7753 * // => [{ 'x': 2 }]
7755 function pullAllBy(array, values, iteratee) {
7756 return (array && array.length && values && values.length)
7757 ? basePullAll(array, values, getIteratee(iteratee, 2))
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).
7766 * **Note:** Unlike `_.differenceWith`, this method mutates `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`.
7778 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
7780 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
7781 * console.log(array);
7782 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
7784 function pullAllWith(array, values, comparator) {
7785 return (array && array.length && values && values.length)
7786 ? basePullAll(array, values, undefined, comparator)
7791 * Removes elements from `array` corresponding to `indexes` and returns an
7792 * array of removed elements.
7794 * **Note:** Unlike `_.at`, this method mutates `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.
7805 * var array = ['a', 'b', 'c', 'd'];
7806 * var pulled = _.pullAt(array, [1, 3]);
7808 * console.log(array);
7811 * console.log(pulled);
7814 var pullAt = flatRest(function(array, indexes) {
7815 var length = array == null ? 0 : array.length,
7816 result = baseAt(array, indexes);
7818 basePullAt(array, arrayMap(indexes, function(index) {
7819 return isIndex(index, length) ? +index : index;
7820 }).sort(compareAscending));
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).
7830 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
7831 * to pull elements from an array by value.
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.
7842 * var array = [1, 2, 3, 4];
7843 * var evens = _.remove(array, function(n) {
7844 * return n % 2 == 0;
7847 * console.log(array);
7850 * console.log(evens);
7853 function remove(array, predicate) {
7855 if (!(array && array.length)) {
7860 length = array.length;
7862 predicate = getIteratee(predicate, 3);
7863 while (++index < length) {
7864 var value = array[index];
7865 if (predicate(value, index, array)) {
7867 indexes.push(index);
7870 basePullAt(array, indexes);
7875 * Reverses `array` so that the first element becomes the last, the second
7876 * element becomes the second to last, and so on.
7878 * **Note:** This method mutates `array` and is based on
7879 * [`Array#reverse`](https://mdn.io/Array/reverse).
7885 * @param {Array} array The array to modify.
7886 * @returns {Array} Returns `array`.
7889 * var array = [1, 2, 3];
7894 * console.log(array);
7897 function reverse(array) {
7898 return array == null ? array : nativeReverse.call(array);
7902 * Creates a slice of `array` from `start` up to, but not including, `end`.
7904 * **Note:** This method is used instead of
7905 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
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`.
7917 function slice(array, start, end) {
7918 var length = array == null ? 0 : array.length;
7922 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
7927 start = start == null ? 0 : toInteger(start);
7928 end = end === undefined ? length : toInteger(end);
7930 return baseSlice(array, start, end);
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.
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
7947 * _.sortedIndex([30, 50], 40);
7950 function sortedIndex(array, value) {
7951 return baseSortedIndex(array, value);
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).
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
7970 * var objects = [{ 'x': 4 }, { 'x': 5 }];
7972 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
7975 * // The `_.property` iteratee shorthand.
7976 * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
7979 function sortedIndexBy(array, value, iteratee) {
7980 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
7984 * This method is like `_.indexOf` except that it performs a binary
7985 * search on a sorted `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`.
7996 * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
7999 function sortedIndexOf(array, value) {
8000 var length = array == null ? 0 : array.length;
8002 var index = baseSortedIndex(array, value);
8003 if (index < length && eq(array[index], value)) {
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.
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
8025 * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
8028 function sortedLastIndex(array, value) {
8029 return baseSortedIndex(array, value, true);
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).
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
8048 * var objects = [{ 'x': 4 }, { 'x': 5 }];
8050 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8053 * // The `_.property` iteratee shorthand.
8054 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8057 function sortedLastIndexBy(array, value, iteratee) {
8058 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8062 * This method is like `_.lastIndexOf` except that it performs a binary
8063 * search on a sorted `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`.
8074 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8077 function sortedLastIndexOf(array, value) {
8078 var length = array == null ? 0 : array.length;
8080 var index = baseSortedIndex(array, value, true) - 1;
8081 if (eq(array[index], value)) {
8089 * This method is like `_.uniq` except that it's designed and optimized
8090 * for sorted arrays.
8096 * @param {Array} array The array to inspect.
8097 * @returns {Array} Returns the new duplicate free array.
8100 * _.sortedUniq([1, 1, 2]);
8103 function sortedUniq(array) {
8104 return (array && array.length)
8105 ? baseSortedUniq(array)
8110 * This method is like `_.uniqBy` except that it's designed and optimized
8111 * for sorted arrays.
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.
8122 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8125 function sortedUniqBy(array, iteratee) {
8126 return (array && array.length)
8127 ? baseSortedUniq(array, getIteratee(iteratee, 2))
8132 * Gets all but the first element of `array`.
8138 * @param {Array} array The array to query.
8139 * @returns {Array} Returns the slice of `array`.
8142 * _.tail([1, 2, 3]);
8145 function tail(array) {
8146 var length = array == null ? 0 : array.length;
8147 return length ? baseSlice(array, 1, length) : [];
8151 * Creates a slice of `array` with `n` elements taken from the beginning.
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`.
8163 * _.take([1, 2, 3]);
8166 * _.take([1, 2, 3], 2);
8169 * _.take([1, 2, 3], 5);
8172 * _.take([1, 2, 3], 0);
8175 function take(array, n, guard) {
8176 if (!(array && array.length)) {
8179 n = (guard || n === undefined) ? 1 : toInteger(n);
8180 return baseSlice(array, 0, n < 0 ? 0 : n);
8184 * Creates a slice of `array` with `n` elements taken from the end.
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`.
8196 * _.takeRight([1, 2, 3]);
8199 * _.takeRight([1, 2, 3], 2);
8202 * _.takeRight([1, 2, 3], 5);
8205 * _.takeRight([1, 2, 3], 0);
8208 function takeRight(array, n, guard) {
8209 var length = array == null ? 0 : array.length;
8213 n = (guard || n === undefined) ? 1 : toInteger(n);
8215 return baseSlice(array, n < 0 ? 0 : n, length);
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).
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`.
8233 * { 'user': 'barney', 'active': true },
8234 * { 'user': 'fred', 'active': false },
8235 * { 'user': 'pebbles', 'active': false }
8238 * _.takeRightWhile(users, function(o) { return !o.active; });
8239 * // => objects for ['fred', 'pebbles']
8241 * // The `_.matches` iteratee shorthand.
8242 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8243 * // => objects for ['pebbles']
8245 * // The `_.matchesProperty` iteratee shorthand.
8246 * _.takeRightWhile(users, ['active', false]);
8247 * // => objects for ['fred', 'pebbles']
8249 * // The `_.property` iteratee shorthand.
8250 * _.takeRightWhile(users, 'active');
8253 function takeRightWhile(array, predicate) {
8254 return (array && array.length)
8255 ? baseWhile(array, getIteratee(predicate, 3), false, true)
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).
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`.
8274 * { 'user': 'barney', 'active': false },
8275 * { 'user': 'fred', 'active': false },
8276 * { 'user': 'pebbles', 'active': true }
8279 * _.takeWhile(users, function(o) { return !o.active; });
8280 * // => objects for ['barney', 'fred']
8282 * // The `_.matches` iteratee shorthand.
8283 * _.takeWhile(users, { 'user': 'barney', 'active': false });
8284 * // => objects for ['barney']
8286 * // The `_.matchesProperty` iteratee shorthand.
8287 * _.takeWhile(users, ['active', false]);
8288 * // => objects for ['barney', 'fred']
8290 * // The `_.property` iteratee shorthand.
8291 * _.takeWhile(users, 'active');
8294 function takeWhile(array, predicate) {
8295 return (array && array.length)
8296 ? baseWhile(array, getIteratee(predicate, 3))
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.
8309 * @param {...Array} [arrays] The arrays to inspect.
8310 * @returns {Array} Returns the new array of combined values.
8313 * _.union([2], [1, 2]);
8316 var union = baseRest(function(arrays) {
8317 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
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:
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.
8336 * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8339 * // The `_.property` iteratee shorthand.
8340 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8341 * // => [{ 'x': 1 }, { 'x': 2 }]
8343 var unionBy = baseRest(function(arrays) {
8344 var iteratee = last(arrays);
8345 if (isArrayLikeObject(iteratee)) {
8346 iteratee = undefined;
8348 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
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).
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.
8366 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8367 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8369 * _.unionWith(objects, others, _.isEqual);
8370 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
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);
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
8389 * @param {Array} array The array to inspect.
8390 * @returns {Array} Returns the new duplicate free array.
8393 * _.uniq([2, 1, 2]);
8396 function uniq(array) {
8397 return (array && array.length) ? baseUniq(array) : [];
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:
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.
8416 * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8419 * // The `_.property` iteratee shorthand.
8420 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8421 * // => [{ 'x': 1 }, { 'x': 2 }]
8423 function uniqBy(array, iteratee) {
8424 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
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).
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.
8442 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8444 * _.uniqWith(objects, _.isEqual);
8445 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8447 function uniqWith(array, comparator) {
8448 comparator = typeof comparator == 'function' ? comparator : undefined;
8449 return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
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
8461 * @param {Array} array The array of grouped elements to process.
8462 * @returns {Array} Returns the new array of regrouped elements.
8465 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8466 * // => [['a', 1, true], ['b', 2, false]]
8469 * // => [['a', 'b'], [1, 2], [true, false]]
8471 function unzip(array) {
8472 if (!(array && array.length)) {
8476 array = arrayFilter(array, function(group) {
8477 if (isArrayLikeObject(group)) {
8478 length = nativeMax(group.length, length);
8482 return baseTimes(length, function(index) {
8483 return arrayMap(array, baseProperty(index));
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).
8496 * @param {Array} array The array of grouped elements to process.
8497 * @param {Function} [iteratee=_.identity] The function to combine
8499 * @returns {Array} Returns the new array of regrouped elements.
8502 * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8503 * // => [[1, 10, 100], [2, 20, 200]]
8505 * _.unzipWith(zipped, _.add);
8506 * // => [3, 30, 300]
8508 function unzipWith(array, iteratee) {
8509 if (!(array && array.length)) {
8512 var result = unzip(array);
8513 if (iteratee == null) {
8516 return arrayMap(result, function(group) {
8517 return apply(iteratee, undefined, group);
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.
8526 * **Note:** Unlike `_.pull`, this method returns a new 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
8538 * _.without([2, 1, 2, 3], 1, 2);
8541 var without = baseRest(function(array, values) {
8542 return isArrayLikeObject(array)
8543 ? baseDifference(array, values)
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.
8557 * @param {...Array} [arrays] The arrays to inspect.
8558 * @returns {Array} Returns the new array of filtered values.
8559 * @see _.difference, _.without
8562 * _.xor([2, 1], [2, 3]);
8565 var xor = baseRest(function(arrays) {
8566 return baseXor(arrayFilter(arrays, isArrayLikeObject));
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).
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.
8585 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8588 * // The `_.property` iteratee shorthand.
8589 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8590 * // => [{ 'x': 2 }]
8592 var xorBy = baseRest(function(arrays) {
8593 var iteratee = last(arrays);
8594 if (isArrayLikeObject(iteratee)) {
8595 iteratee = undefined;
8597 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
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).
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.
8615 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8616 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8618 * _.xorWith(objects, others, _.isEqual);
8619 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
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);
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.
8636 * @param {...Array} [arrays] The arrays to process.
8637 * @returns {Array} Returns the new array of grouped elements.
8640 * _.zip(['a', 'b'], [1, 2], [true, false]);
8641 * // => [['a', 1, true], ['b', 2, false]]
8643 var zip = baseRest(unzip);
8646 * This method is like `_.fromPairs` except that it accepts two arrays,
8647 * one of property identifiers and one of corresponding values.
8653 * @param {Array} [props=[]] The property identifiers.
8654 * @param {Array} [values=[]] The property values.
8655 * @returns {Object} Returns the new object.
8658 * _.zipObject(['a', 'b'], [1, 2]);
8659 * // => { 'a': 1, 'b': 2 }
8661 function zipObject(props, values) {
8662 return baseZipObject(props || [], values || [], assignValue);
8666 * This method is like `_.zipObject` except that it supports property paths.
8672 * @param {Array} [props=[]] The property identifiers.
8673 * @param {Array} [values=[]] The property values.
8674 * @returns {Object} Returns the new object.
8677 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
8678 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
8680 function zipObjectDeep(props, values) {
8681 return baseZipObject(props || [], values || [], baseSet);
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).
8693 * @param {...Array} [arrays] The arrays to process.
8694 * @param {Function} [iteratee=_.identity] The function to combine
8696 * @returns {Array} Returns the new array of grouped elements.
8699 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
8704 var zipWith = baseRest(function(arrays) {
8705 var length = arrays.length,
8706 iteratee = length > 1 ? arrays[length - 1] : undefined;
8708 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
8709 return unzipWith(arrays, iteratee);
8712 /*------------------------------------------------------------------------*/
8715 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
8716 * chain sequences enabled. The result of such sequences must be unwrapped
8723 * @param {*} value The value to wrap.
8724 * @returns {Object} Returns the new `lodash` wrapper instance.
8728 * { 'user': 'barney', 'age': 36 },
8729 * { 'user': 'fred', 'age': 40 },
8730 * { 'user': 'pebbles', 'age': 1 }
8736 * .map(function(o) {
8737 * return o.user + ' is ' + o.age;
8741 * // => 'pebbles is 1'
8743 function chain(value) {
8744 var result = lodash(value);
8745 result.__chain__ = true;
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.
8758 * @param {*} value The value to provide to `interceptor`.
8759 * @param {Function} interceptor The function to invoke.
8760 * @returns {*} Returns `value`.
8764 * .tap(function(array) {
8765 * // Mutate input array.
8772 function tap(value, interceptor) {
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.
8786 * @param {*} value The value to provide to `interceptor`.
8787 * @param {Function} interceptor The function to invoke.
8788 * @returns {*} Returns the result of `interceptor`.
8794 * .thru(function(value) {
8800 function thru(value, interceptor) {
8801 return interceptor(value);
8805 * This method is the wrapper version of `_.at`.
8811 * @param {...(string|string[])} [paths] The property paths to pick.
8812 * @returns {Object} Returns the new `lodash` wrapper instance.
8815 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
8817 * _(object).at(['a[0].b.c', 'a[1]']).value();
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); };
8826 if (length > 1 || this.__actions__.length ||
8827 !(value instanceof LazyWrapper) || !isIndex(start)) {
8828 return this.thru(interceptor);
8830 value = value.slice(start, +start + (length ? 1 : 0));
8831 value.__actions__.push({
8833 'args': [interceptor],
8834 'thisArg': undefined
8836 return new LodashWrapper(value, this.__chain__).thru(function(array) {
8837 if (length && !array.length) {
8838 array.push(undefined);
8845 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
8851 * @returns {Object} Returns the new `lodash` wrapper instance.
8855 * { 'user': 'barney', 'age': 36 },
8856 * { 'user': 'fred', 'age': 40 }
8859 * // A sequence without explicit chaining.
8861 * // => { 'user': 'barney', 'age': 36 }
8863 * // A sequence with explicit chaining.
8869 * // => { 'user': 'barney' }
8871 function wrapperChain() {
8876 * Executes the chain sequence and returns the wrapped result.
8882 * @returns {Object} Returns the new `lodash` wrapper instance.
8885 * var array = [1, 2];
8886 * var wrapped = _(array).push(3);
8888 * console.log(array);
8891 * wrapped = wrapped.commit();
8892 * console.log(array);
8898 * console.log(array);
8901 function wrapperCommit() {
8902 return new LodashWrapper(this.value(), this.__chain__);
8906 * Gets the next value on a wrapped object following the
8907 * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
8913 * @returns {Object} Returns the next iterator value.
8916 * var wrapped = _([1, 2]);
8919 * // => { 'done': false, 'value': 1 }
8922 * // => { 'done': false, 'value': 2 }
8925 * // => { 'done': true, 'value': undefined }
8927 function wrapperNext() {
8928 if (this.__values__ === undefined) {
8929 this.__values__ = toArray(this.value());
8931 var done = this.__index__ >= this.__values__.length,
8932 value = done ? undefined : this.__values__[this.__index__++];
8934 return { 'done': done, 'value': value };
8938 * Enables the wrapper to be iterable.
8940 * @name Symbol.iterator
8944 * @returns {Object} Returns the wrapper object.
8947 * var wrapped = _([1, 2]);
8949 * wrapped[Symbol.iterator]() === wrapped;
8952 * Array.from(wrapped);
8955 function wrapperToIterator() {
8960 * Creates a clone of the chain sequence planting `value` as the wrapped value.
8966 * @param {*} value The value to plant.
8967 * @returns {Object} Returns the new `lodash` wrapper instance.
8970 * function square(n) {
8974 * var wrapped = _([1, 2]).map(square);
8975 * var other = wrapped.plant([3, 4]);
8983 function wrapperPlant(value) {
8987 while (parent instanceof baseLodash) {
8988 var clone = wrapperClone(parent);
8989 clone.__index__ = 0;
8990 clone.__values__ = undefined;
8992 previous.__wrapped__ = clone;
8996 var previous = clone;
8997 parent = parent.__wrapped__;
8999 previous.__wrapped__ = value;
9004 * This method is the wrapper version of `_.reverse`.
9006 * **Note:** This method mutates the wrapped array.
9012 * @returns {Object} Returns the new `lodash` wrapper instance.
9015 * var array = [1, 2, 3];
9017 * _(array).reverse().value()
9020 * console.log(array);
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);
9030 wrapped = wrapped.reverse();
9031 wrapped.__actions__.push({
9034 'thisArg': undefined
9036 return new LodashWrapper(wrapped, this.__chain__);
9038 return this.thru(reverse);
9042 * Executes the chain sequence to resolve the unwrapped value.
9047 * @alias toJSON, valueOf
9049 * @returns {*} Returns the resolved unwrapped value.
9052 * _([1, 2, 3]).value();
9055 function wrapperValue() {
9056 return baseWrapperValue(this.__wrapped__, this.__actions__);
9059 /*------------------------------------------------------------------------*/
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).
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.
9076 * _.countBy([6.1, 4.2, 6.3], Math.floor);
9077 * // => { '4': 1, '6': 2 }
9079 * // The `_.property` iteratee shorthand.
9080 * _.countBy(['one', 'two', 'three'], 'length');
9081 * // => { '3': 2, '5': 1 }
9083 var countBy = createAggregator(function(result, value, key) {
9084 if (hasOwnProperty.call(result, key)) {
9087 baseAssignValue(result, key, 1);
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).
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.
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,
9112 * _.every([true, 1, null, 'yes'], Boolean);
9116 * { 'user': 'barney', 'age': 36, 'active': false },
9117 * { 'user': 'fred', 'age': 40, 'active': false }
9120 * // The `_.matches` iteratee shorthand.
9121 * _.every(users, { 'user': 'barney', 'active': false });
9124 * // The `_.matchesProperty` iteratee shorthand.
9125 * _.every(users, ['active', false]);
9128 * // The `_.property` iteratee shorthand.
9129 * _.every(users, 'active');
9132 function every(collection, predicate, guard) {
9133 var func = isArray(collection) ? arrayEvery : baseEvery;
9134 if (guard && isIterateeCall(collection, predicate, guard)) {
9135 predicate = undefined;
9137 return func(collection, getIteratee(predicate, 3));
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).
9145 * **Note:** Unlike `_.remove`, this method returns a new array.
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.
9158 * { 'user': 'barney', 'age': 36, 'active': true },
9159 * { 'user': 'fred', 'age': 40, 'active': false }
9162 * _.filter(users, function(o) { return !o.active; });
9163 * // => objects for ['fred']
9165 * // The `_.matches` iteratee shorthand.
9166 * _.filter(users, { 'age': 36, 'active': true });
9167 * // => objects for ['barney']
9169 * // The `_.matchesProperty` iteratee shorthand.
9170 * _.filter(users, ['active', false]);
9171 * // => objects for ['fred']
9173 * // The `_.property` iteratee shorthand.
9174 * _.filter(users, 'active');
9175 * // => objects for ['barney']
9177 function filter(collection, predicate) {
9178 var func = isArray(collection) ? arrayFilter : baseFilter;
9179 return func(collection, getIteratee(predicate, 3));
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).
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`.
9198 * { 'user': 'barney', 'age': 36, 'active': true },
9199 * { 'user': 'fred', 'age': 40, 'active': false },
9200 * { 'user': 'pebbles', 'age': 1, 'active': true }
9203 * _.find(users, function(o) { return o.age < 40; });
9204 * // => object for 'barney'
9206 * // The `_.matches` iteratee shorthand.
9207 * _.find(users, { 'age': 1, 'active': true });
9208 * // => object for 'pebbles'
9210 * // The `_.matchesProperty` iteratee shorthand.
9211 * _.find(users, ['active', false]);
9212 * // => object for 'fred'
9214 * // The `_.property` iteratee shorthand.
9215 * _.find(users, 'active');
9216 * // => object for 'barney'
9218 var find = createFind(findIndex);
9221 * This method is like `_.find` except that it iterates over elements of
9222 * `collection` from right to left.
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`.
9234 * _.findLast([1, 2, 3, 4], function(n) {
9235 * return n % 2 == 1;
9239 var findLast = createFind(findLastIndex);
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).
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.
9255 * function duplicate(n) {
9259 * _.flatMap([1, 2], duplicate);
9260 * // => [1, 1, 2, 2]
9262 function flatMap(collection, iteratee) {
9263 return baseFlatten(map(collection, iteratee), 1);
9267 * This method is like `_.flatMap` except that it recursively flattens the
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.
9279 * function duplicate(n) {
9280 * return [[[n, n]]];
9283 * _.flatMapDeep([1, 2], duplicate);
9284 * // => [1, 1, 2, 2]
9286 function flatMapDeep(collection, iteratee) {
9287 return baseFlatten(map(collection, iteratee), INFINITY);
9291 * This method is like `_.flatMap` except that it recursively flattens the
9292 * mapped results up to `depth` times.
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.
9304 * function duplicate(n) {
9305 * return [[[n, n]]];
9308 * _.flatMapDepth([1, 2], duplicate, 2);
9309 * // => [[1, 1], [2, 2]]
9311 function flatMapDepth(collection, iteratee, depth) {
9312 depth = depth === undefined ? 1 : toInteger(depth);
9313 return baseFlatten(map(collection, iteratee), depth);
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`.
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.
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
9336 * _.forEach([1, 2], function(value) {
9337 * console.log(value);
9339 * // => Logs `1` then `2`.
9341 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9344 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9346 function forEach(collection, iteratee) {
9347 var func = isArray(collection) ? arrayEach : baseEach;
9348 return func(collection, getIteratee(iteratee, 3));
9352 * This method is like `_.forEach` except that it iterates over elements of
9353 * `collection` from right to left.
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`.
9366 * _.forEachRight([1, 2], function(value) {
9367 * console.log(value);
9369 * // => Logs `2` then `1`.
9371 function forEachRight(collection, iteratee) {
9372 var func = isArray(collection) ? arrayEachRight : baseEachRight;
9373 return func(collection, getIteratee(iteratee, 3));
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).
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.
9392 * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9393 * // => { '4': [4.2], '6': [6.1, 6.3] }
9395 * // The `_.property` iteratee shorthand.
9396 * _.groupBy(['one', 'two', 'three'], 'length');
9397 * // => { '3': ['one', 'two'], '5': ['three'] }
9399 var groupBy = createAggregator(function(result, value, key) {
9400 if (hasOwnProperty.call(result, key)) {
9401 result[key].push(value);
9403 baseAssignValue(result, key, [value]);
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`.
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`.
9425 * _.includes([1, 2, 3], 1);
9428 * _.includes([1, 2, 3], 1, 2);
9431 * _.includes({ 'a': 1, 'b': 2 }, 1);
9434 * _.includes('abcd', 'bc');
9437 function includes(collection, value, fromIndex, guard) {
9438 collection = isArrayLike(collection) ? collection : values(collection);
9439 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9441 var length = collection.length;
9442 if (fromIndex < 0) {
9443 fromIndex = nativeMax(length + fromIndex, 0);
9445 return isString(collection)
9446 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9447 : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
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`.
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.
9467 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9468 * // => [[1, 5, 7], [1, 2, 3]]
9470 * _.invokeMap([123, 456], String.prototype.split, '');
9471 * // => [['1', '2', '3'], ['4', '5', '6']]
9473 var invokeMap = baseRest(function(collection, path, args) {
9475 isFunc = typeof path == 'function',
9476 result = isArrayLike(collection) ? Array(collection.length) : [];
9478 baseEach(collection, function(value) {
9479 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
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).
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.
9500 * { 'dir': 'left', 'code': 97 },
9501 * { 'dir': 'right', 'code': 100 }
9504 * _.keyBy(array, function(o) {
9505 * return String.fromCharCode(o.code);
9507 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9509 * _.keyBy(array, 'dir');
9510 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9512 var keyBy = createAggregator(function(result, value, key) {
9513 baseAssignValue(result, key, value);
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).
9521 * Many lodash methods are guarded to work as iteratees for methods like
9522 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
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`
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.
9539 * function square(n) {
9543 * _.map([4, 8], square);
9546 * _.map({ 'a': 4, 'b': 8 }, square);
9547 * // => [16, 64] (iteration order is not guaranteed)
9550 * { 'user': 'barney' },
9551 * { 'user': 'fred' }
9554 * // The `_.property` iteratee shorthand.
9555 * _.map(users, 'user');
9556 * // => ['barney', 'fred']
9558 function map(collection, iteratee) {
9559 var func = isArray(collection) ? arrayMap : baseMap;
9560 return func(collection, getIteratee(iteratee, 3));
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.
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.
9582 * { 'user': 'fred', 'age': 48 },
9583 * { 'user': 'barney', 'age': 34 },
9584 * { 'user': 'fred', 'age': 40 },
9585 * { 'user': 'barney', 'age': 36 }
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]]
9592 function orderBy(collection, iteratees, orders, guard) {
9593 if (collection == null) {
9596 if (!isArray(iteratees)) {
9597 iteratees = iteratees == null ? [] : [iteratees];
9599 orders = guard ? undefined : orders;
9600 if (!isArray(orders)) {
9601 orders = orders == null ? [] : [orders];
9603 return baseOrderBy(collection, iteratees, orders);
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).
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.
9622 * { 'user': 'barney', 'age': 36, 'active': false },
9623 * { 'user': 'fred', 'age': 40, 'active': true },
9624 * { 'user': 'pebbles', 'age': 1, 'active': false }
9627 * _.partition(users, function(o) { return o.active; });
9628 * // => objects for [['fred'], ['barney', 'pebbles']]
9630 * // The `_.matches` iteratee shorthand.
9631 * _.partition(users, { 'age': 1, 'active': false });
9632 * // => objects for [['pebbles'], ['barney', 'fred']]
9634 * // The `_.matchesProperty` iteratee shorthand.
9635 * _.partition(users, ['active', false]);
9636 * // => objects for [['barney', 'pebbles'], ['fred']]
9638 * // The `_.property` iteratee shorthand.
9639 * _.partition(users, 'active');
9640 * // => objects for [['fred'], ['barney', 'pebbles']]
9642 var partition = createAggregator(function(result, value, key) {
9643 result[key ? 0 : 1].push(value);
9644 }, function() { return [[], []]; });
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).
9654 * Many lodash methods are guarded to work as iteratees for methods like
9655 * `_.reduce`, `_.reduceRight`, and `_.transform`.
9657 * The guarded methods are:
9658 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
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
9672 * _.reduce([1, 2], function(sum, n) {
9677 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
9678 * (result[value] || (result[value] = [])).push(key);
9681 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
9683 function reduce(collection, iteratee, accumulator) {
9684 var func = isArray(collection) ? arrayReduce : baseReduce,
9685 initAccum = arguments.length < 3;
9687 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
9691 * This method is like `_.reduce` except that it iterates over elements of
9692 * `collection` from right to left.
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.
9705 * var array = [[0, 1], [2, 3], [4, 5]];
9707 * _.reduceRight(array, function(flattened, other) {
9708 * return flattened.concat(other);
9710 * // => [4, 5, 2, 3, 0, 1]
9712 function reduceRight(collection, iteratee, accumulator) {
9713 var func = isArray(collection) ? arrayReduceRight : baseReduce,
9714 initAccum = arguments.length < 3;
9716 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
9720 * The opposite of `_.filter`; this method returns the elements of `collection`
9721 * that `predicate` does **not** return truthy for.
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.
9734 * { 'user': 'barney', 'age': 36, 'active': false },
9735 * { 'user': 'fred', 'age': 40, 'active': true }
9738 * _.reject(users, function(o) { return !o.active; });
9739 * // => objects for ['fred']
9741 * // The `_.matches` iteratee shorthand.
9742 * _.reject(users, { 'age': 40, 'active': true });
9743 * // => objects for ['barney']
9745 * // The `_.matchesProperty` iteratee shorthand.
9746 * _.reject(users, ['active', false]);
9747 * // => objects for ['fred']
9749 * // The `_.property` iteratee shorthand.
9750 * _.reject(users, 'active');
9751 * // => objects for ['barney']
9753 function reject(collection, predicate) {
9754 var func = isArray(collection) ? arrayFilter : baseFilter;
9755 return func(collection, negate(getIteratee(predicate, 3)));
9759 * Gets a random element from `collection`.
9764 * @category Collection
9765 * @param {Array|Object} collection The collection to sample.
9766 * @returns {*} Returns the random element.
9769 * _.sample([1, 2, 3, 4]);
9772 function sample(collection) {
9773 var func = isArray(collection) ? arraySample : baseSample;
9774 return func(collection);
9778 * Gets `n` random elements at unique keys from `collection` up to the
9779 * size of `collection`.
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.
9791 * _.sampleSize([1, 2, 3], 2);
9794 * _.sampleSize([1, 2, 3], 4);
9797 function sampleSize(collection, n, guard) {
9798 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
9803 var func = isArray(collection) ? arraySampleSize : baseSampleSize;
9804 return func(collection, n);
9808 * Creates an array of shuffled values, using a version of the
9809 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9814 * @category Collection
9815 * @param {Array|Object} collection The collection to shuffle.
9816 * @returns {Array} Returns the new shuffled array.
9819 * _.shuffle([1, 2, 3, 4]);
9820 * // => [4, 1, 3, 2]
9822 function shuffle(collection) {
9823 var func = isArray(collection) ? arrayShuffle : baseShuffle;
9824 return func(collection);
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.
9834 * @category Collection
9835 * @param {Array|Object|string} collection The collection to inspect.
9836 * @returns {number} Returns the collection size.
9839 * _.size([1, 2, 3]);
9842 * _.size({ 'a': 1, 'b': 2 });
9845 * _.size('pebbles');
9848 function size(collection) {
9849 if (collection == null) {
9852 if (isArrayLike(collection)) {
9853 return isString(collection) ? stringSize(collection) : collection.length;
9855 var tag = getTag(collection);
9856 if (tag == mapTag || tag == setTag) {
9857 return collection.size;
9859 return baseKeys(collection).length;
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).
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,
9878 * _.some([null, 0, 'yes', false], Boolean);
9882 * { 'user': 'barney', 'active': true },
9883 * { 'user': 'fred', 'active': false }
9886 * // The `_.matches` iteratee shorthand.
9887 * _.some(users, { 'user': 'barney', 'active': false });
9890 * // The `_.matchesProperty` iteratee shorthand.
9891 * _.some(users, ['active', false]);
9894 * // The `_.property` iteratee shorthand.
9895 * _.some(users, 'active');
9898 function some(collection, predicate, guard) {
9899 var func = isArray(collection) ? arraySome : baseSome;
9900 if (guard && isIterateeCall(collection, predicate, guard)) {
9901 predicate = undefined;
9903 return func(collection, getIteratee(predicate, 3));
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).
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.
9923 * { 'user': 'fred', 'age': 48 },
9924 * { 'user': 'barney', 'age': 36 },
9925 * { 'user': 'fred', 'age': 40 },
9926 * { 'user': 'barney', 'age': 34 }
9929 * _.sortBy(users, [function(o) { return o.user; }]);
9930 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9932 * _.sortBy(users, ['user', 'age']);
9933 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
9935 var sortBy = baseRest(function(collection, iteratees) {
9936 if (collection == null) {
9939 var length = iteratees.length;
9940 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
9942 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
9943 iteratees = [iteratees[0]];
9945 return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
9948 /*------------------------------------------------------------------------*/
9951 * Gets the timestamp of the number of milliseconds that have elapsed since
9952 * the Unix epoch (1 January 1970 00:00:00 UTC).
9958 * @returns {number} Returns the timestamp.
9961 * _.defer(function(stamp) {
9962 * console.log(_.now() - stamp);
9964 * // => Logs the number of milliseconds it took for the deferred invocation.
9966 var now = ctxNow || function() {
9967 return root.Date.now();
9970 /*------------------------------------------------------------------------*/
9973 * The opposite of `_.before`; this method creates a function that invokes
9974 * `func` once it's called `n` or more times.
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.
9985 * var saves = ['profile', 'settings'];
9987 * var done = _.after(saves.length, function() {
9988 * console.log('done saving!');
9991 * _.forEach(saves, function(type) {
9992 * asyncSave({ 'type': type, 'complete': done });
9994 * // => Logs 'done saving!' after the two async saves have completed.
9996 function after(n, func) {
9997 if (typeof func != 'function') {
9998 throw new TypeError(FUNC_ERROR_TEXT);
10001 return function() {
10003 return func.apply(this, arguments);
10009 * Creates a function that invokes `func`, with up to `n` arguments,
10010 * ignoring any additional arguments.
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.
10022 * _.map(['6', '8', '10'], _.ary(parseInt, 1));
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);
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.
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.
10045 * jQuery(element).on('click', _.before(5, addContactToList));
10046 * // => Allows adding up to 4 contacts to the list.
10048 function before(n, func) {
10050 if (typeof func != 'function') {
10051 throw new TypeError(FUNC_ERROR_TEXT);
10054 return function() {
10056 result = func.apply(this, arguments);
10066 * Creates a function that invokes `func` with the `this` binding of `thisArg`
10067 * and `partials` prepended to the arguments it receives.
10069 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10070 * may be used as a placeholder for partially applied arguments.
10072 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10073 * property of bound functions.
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.
10085 * function greet(greeting, punctuation) {
10086 * return greeting + ' ' + this.user + punctuation;
10089 * var object = { 'user': 'fred' };
10091 * var bound = _.bind(greet, object, 'hi');
10095 * // Bound with placeholders.
10096 * var bound = _.bind(greet, object, _, '!');
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;
10106 return createWrap(func, bitmask, thisArg, partials, holders);
10110 * Creates a function that invokes the method at `object[key]` with `partials`
10111 * prepended to the arguments it receives.
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.
10118 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10119 * builds, may be used as a placeholder for partially applied arguments.
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.
10133 * 'greet': function(greeting, punctuation) {
10134 * return greeting + ' ' + this.user + punctuation;
10138 * var bound = _.bindKey(object, 'greet', 'hi');
10142 * object.greet = function(greeting, punctuation) {
10143 * return greeting + 'ya ' + this.user + punctuation;
10147 * // => 'hiya fred!'
10149 * // Bound with placeholders.
10150 * var bound = _.bindKey(object, 'greet', _, '!');
10152 * // => 'hiya fred!'
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;
10160 return createWrap(key, bitmask, object, partials, holders);
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.
10170 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10171 * may be used as a placeholder for provided arguments.
10173 * **Note:** This method doesn't set the "length" property of curried functions.
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.
10185 * var abc = function(a, b, c) {
10186 * return [a, b, c];
10189 * var curried = _.curry(abc);
10191 * curried(1)(2)(3);
10194 * curried(1, 2)(3);
10197 * curried(1, 2, 3);
10200 * // Curried with placeholders.
10201 * curried(1)(_, 3)(2);
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;
10212 * This method is like `_.curry` except that arguments are applied to `func`
10213 * in the manner of `_.partialRight` instead of `_.partial`.
10215 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10216 * builds, may be used as a placeholder for provided arguments.
10218 * **Note:** This method doesn't set the "length" property of curried functions.
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.
10230 * var abc = function(a, b, c) {
10231 * return [a, b, c];
10234 * var curried = _.curryRight(abc);
10236 * curried(3)(2)(1);
10239 * curried(2, 3)(1);
10242 * curried(1, 2, 3);
10245 * // Curried with placeholders.
10246 * curried(3)(1, _)(2);
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;
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`
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.
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`.
10274 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10275 * for details over the differences between `_.debounce` and `_.throttle`.
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.
10293 * // Avoid costly calculations while the window size is in flux.
10294 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10296 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10297 * jQuery(element).on('click', _.debounce(sendMail, 300, {
10299 * 'trailing': false
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);
10307 * // Cancel the trailing debounced invocation.
10308 * jQuery(window).on('popstate', debounced.cancel);
10310 function debounce(func, wait, options) {
10317 lastInvokeTime = 0,
10322 if (typeof func != 'function') {
10323 throw new TypeError(FUNC_ERROR_TEXT);
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;
10333 function invokeFunc(time) {
10334 var args = lastArgs,
10335 thisArg = lastThis;
10337 lastArgs = lastThis = undefined;
10338 lastInvokeTime = time;
10339 result = func.apply(thisArg, args);
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;
10352 function remainingWait(time) {
10353 var timeSinceLastCall = time - lastCallTime,
10354 timeSinceLastInvoke = time - lastInvokeTime,
10355 timeWaiting = wait - timeSinceLastCall;
10358 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
10362 function shouldInvoke(time) {
10363 var timeSinceLastCall = time - lastCallTime,
10364 timeSinceLastInvoke = time - lastInvokeTime;
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));
10373 function timerExpired() {
10375 if (shouldInvoke(time)) {
10376 return trailingEdge(time);
10378 // Restart the timer.
10379 timerId = setTimeout(timerExpired, remainingWait(time));
10382 function trailingEdge(time) {
10383 timerId = undefined;
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);
10390 lastArgs = lastThis = undefined;
10394 function cancel() {
10395 if (timerId !== undefined) {
10396 clearTimeout(timerId);
10398 lastInvokeTime = 0;
10399 lastArgs = lastCallTime = lastThis = timerId = undefined;
10403 return timerId === undefined ? result : trailingEdge(now());
10406 function debounced() {
10408 isInvoking = shouldInvoke(time);
10410 lastArgs = arguments;
10412 lastCallTime = time;
10415 if (timerId === undefined) {
10416 return leadingEdge(lastCallTime);
10419 // Handle invocations in a tight loop.
10420 clearTimeout(timerId);
10421 timerId = setTimeout(timerExpired, wait);
10422 return invokeFunc(lastCallTime);
10425 if (timerId === undefined) {
10426 timerId = setTimeout(timerExpired, wait);
10430 debounced.cancel = cancel;
10431 debounced.flush = flush;
10436 * Defers invoking the `func` until the current call stack has cleared. Any
10437 * additional arguments are provided to `func` when it's invoked.
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.
10448 * _.defer(function(text) {
10449 * console.log(text);
10451 * // => Logs 'deferred' after one millisecond.
10453 var defer = baseRest(function(func, args) {
10454 return baseDelay(func, 1, args);
10458 * Invokes `func` after `wait` milliseconds. Any additional arguments are
10459 * provided to `func` when it's invoked.
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.
10471 * _.delay(function(text) {
10472 * console.log(text);
10473 * }, 1000, 'later');
10474 * // => Logs 'later' after one second.
10476 var delay = baseRest(function(func, wait, args) {
10477 return baseDelay(func, toNumber(wait) || 0, args);
10481 * Creates a function that invokes `func` with arguments reversed.
10486 * @category Function
10487 * @param {Function} func The function to flip arguments for.
10488 * @returns {Function} Returns the new flipped function.
10491 * var flipped = _.flip(function() {
10492 * return _.toArray(arguments);
10495 * flipped('a', 'b', 'c', 'd');
10496 * // => ['d', 'c', 'b', 'a']
10498 function flip(func) {
10499 return createWrap(func, WRAP_FLIP_FLAG);
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.
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`.
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.
10524 * var object = { 'a': 1, 'b': 2 };
10525 * var other = { 'c': 3, 'd': 4 };
10527 * var values = _.memoize(_.values);
10538 * // Modify the result cache.
10539 * values.cache.set(object, ['a', 'b']);
10543 * // Replace `_.memoize.Cache`.
10544 * _.memoize.Cache = WeakMap;
10546 function memoize(func, resolver) {
10547 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10548 throw new TypeError(FUNC_ERROR_TEXT);
10550 var memoized = function() {
10551 var args = arguments,
10552 key = resolver ? resolver.apply(this, args) : args[0],
10553 cache = memoized.cache;
10555 if (cache.has(key)) {
10556 return cache.get(key);
10558 var result = func.apply(this, args);
10559 memoized.cache = cache.set(key, result) || cache;
10562 memoized.cache = new (memoize.Cache || MapCache);
10566 // Expose `MapCache`.
10567 memoize.Cache = MapCache;
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.
10577 * @category Function
10578 * @param {Function} predicate The predicate to negate.
10579 * @returns {Function} Returns the new negated function.
10582 * function isEven(n) {
10583 * return n % 2 == 0;
10586 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10589 function negate(predicate) {
10590 if (typeof predicate != 'function') {
10591 throw new TypeError(FUNC_ERROR_TEXT);
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]);
10601 return !predicate.apply(this, args);
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.
10613 * @category Function
10614 * @param {Function} func The function to restrict.
10615 * @returns {Function} Returns the new restricted function.
10618 * var initialize = _.once(createApplication);
10621 * // => `createApplication` is invoked once
10623 function once(func) {
10624 return before(2, func);
10628 * Creates a function that invokes `func` with its arguments transformed.
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.
10640 * function doubled(n) {
10644 * function square(n) {
10648 * var func = _.overArgs(function(x, y) {
10650 * }, [square, doubled]);
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()));
10663 var funcsLength = transforms.length;
10664 return baseRest(function(args) {
10666 length = nativeMin(args.length, funcsLength);
10668 while (++index < length) {
10669 args[index] = transforms[index].call(this, args[index]);
10671 return apply(func, this, args);
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.
10680 * The `_.partial.placeholder` value, which defaults to `_` in monolithic
10681 * builds, may be used as a placeholder for partially applied arguments.
10683 * **Note:** This method doesn't set the "length" property of partially
10684 * applied functions.
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.
10695 * function greet(greeting, name) {
10696 * return greeting + ' ' + name;
10699 * var sayHelloTo = _.partial(greet, 'hello');
10700 * sayHelloTo('fred');
10701 * // => 'hello fred'
10703 * // Partially applied with placeholders.
10704 * var greetFred = _.partial(greet, _, 'fred');
10708 var partial = baseRest(function(func, partials) {
10709 var holders = replaceHolders(partials, getHolder(partial));
10710 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
10714 * This method is like `_.partial` except that partially applied arguments
10715 * are appended to the arguments it receives.
10717 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
10718 * builds, may be used as a placeholder for partially applied arguments.
10720 * **Note:** This method doesn't set the "length" property of partially
10721 * applied functions.
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.
10732 * function greet(greeting, name) {
10733 * return greeting + ' ' + name;
10736 * var greetFred = _.partialRight(greet, 'fred');
10740 * // Partially applied with placeholders.
10741 * var sayHelloTo = _.partialRight(greet, 'hello', _);
10742 * sayHelloTo('fred');
10743 * // => 'hello fred'
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);
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.
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.
10765 * var rearged = _.rearg(function(a, b, c) {
10766 * return [a, b, c];
10769 * rearged('b', 'c', 'a')
10770 * // => ['a', 'b', 'c']
10772 var rearg = flatRest(function(func, indexes) {
10773 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
10777 * Creates a function that invokes `func` with the `this` binding of the
10778 * created function and arguments from `start` and beyond provided as
10781 * **Note:** This method is based on the
10782 * [rest parameter](https://mdn.io/rest_parameters).
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.
10793 * var say = _.rest(function(what, names) {
10794 * return what + ' ' + _.initial(names).join(', ') +
10795 * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
10798 * say('hello', 'fred', 'barney', 'pebbles');
10799 * // => 'hello fred, barney, & pebbles'
10801 function rest(func, start) {
10802 if (typeof func != 'function') {
10803 throw new TypeError(FUNC_ERROR_TEXT);
10805 start = start === undefined ? start : toInteger(start);
10806 return baseRest(func, start);
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).
10814 * **Note:** This method is based on the
10815 * [spread operator](https://mdn.io/spread_operator).
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.
10826 * var say = _.spread(function(who, what) {
10827 * return who + ' says ' + what;
10830 * say(['fred', 'hello']);
10831 * // => 'fred says hello'
10833 * var numbers = Promise.all([
10834 * Promise.resolve(40),
10835 * Promise.resolve(36)
10838 * numbers.then(_.spread(function(x, y) {
10841 * // => a Promise of 76
10843 function spread(func, start) {
10844 if (typeof func != 'function') {
10845 throw new TypeError(FUNC_ERROR_TEXT);
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);
10853 arrayPush(otherArgs, array);
10855 return apply(func, this, otherArgs);
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.
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.
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`.
10876 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10877 * for details over the differences between `_.throttle` and `_.debounce`.
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.
10893 * // Avoid excessively updating the position while scrolling.
10894 * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
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);
10900 * // Cancel the trailing throttled invocation.
10901 * jQuery(window).on('popstate', throttled.cancel);
10903 function throttle(func, wait, options) {
10904 var leading = true,
10907 if (typeof func != 'function') {
10908 throw new TypeError(FUNC_ERROR_TEXT);
10910 if (isObject(options)) {
10911 leading = 'leading' in options ? !!options.leading : leading;
10912 trailing = 'trailing' in options ? !!options.trailing : trailing;
10914 return debounce(func, wait, {
10915 'leading': leading,
10917 'trailing': trailing
10922 * Creates a function that accepts up to one argument, ignoring any
10923 * additional arguments.
10928 * @category Function
10929 * @param {Function} func The function to cap arguments for.
10930 * @returns {Function} Returns the new capped function.
10933 * _.map(['6', '8', '10'], _.unary(parseInt));
10936 function unary(func) {
10937 return ary(func, 1);
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.
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.
10955 * var p = _.wrap(_.escape, function(func, text) {
10956 * return '<p>' + func(text) + '</p>';
10959 * p('fred, barney, & pebbles');
10960 * // => '<p>fred, barney, & pebbles</p>'
10962 function wrap(value, wrapper) {
10963 return partial(castFunction(wrapper), value);
10966 /*------------------------------------------------------------------------*/
10969 * Casts `value` as an array if it's not one.
10975 * @param {*} value The value to inspect.
10976 * @returns {Array} Returns the cast array.
10982 * _.castArray({ 'a': 1 });
10983 * // => [{ 'a': 1 }]
10985 * _.castArray('abc');
10988 * _.castArray(null);
10991 * _.castArray(undefined);
10992 * // => [undefined]
10997 * var array = [1, 2, 3];
10998 * console.log(_.castArray(array) === array);
11001 function castArray() {
11002 if (!arguments.length) {
11005 var value = arguments[0];
11006 return isArray(value) ? value : [value];
11010 * Creates a shallow clone of `value`.
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.
11024 * @param {*} value The value to clone.
11025 * @returns {*} Returns the cloned value.
11029 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11031 * var shallow = _.clone(objects);
11032 * console.log(shallow[0] === objects[0]);
11035 function clone(value) {
11036 return baseClone(value, CLONE_SYMBOLS_FLAG);
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]).
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
11055 * function customizer(value) {
11056 * if (_.isElement(value)) {
11057 * return value.cloneNode(false);
11061 * var el = _.cloneWith(document.body, customizer);
11063 * console.log(el === document.body);
11065 * console.log(el.nodeName);
11067 * console.log(el.childNodes.length);
11070 function cloneWith(value, customizer) {
11071 customizer = typeof customizer == 'function' ? customizer : undefined;
11072 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
11076 * This method is like `_.clone` except that it recursively clones `value`.
11082 * @param {*} value The value to recursively clone.
11083 * @returns {*} Returns the deep cloned value.
11087 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11089 * var deep = _.cloneDeep(objects);
11090 * console.log(deep[0] === objects[0]);
11093 function cloneDeep(value) {
11094 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
11098 * This method is like `_.cloneWith` except that it recursively clones `value`.
11104 * @param {*} value The value to recursively clone.
11105 * @param {Function} [customizer] The function to customize cloning.
11106 * @returns {*} Returns the deep cloned value.
11110 * function customizer(value) {
11111 * if (_.isElement(value)) {
11112 * return value.cloneNode(true);
11116 * var el = _.cloneDeepWith(document.body, customizer);
11118 * console.log(el === document.body);
11120 * console.log(el.nodeName);
11122 * console.log(el.childNodes.length);
11125 function cloneDeepWith(value, customizer) {
11126 customizer = typeof customizer == 'function' ? customizer : undefined;
11127 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
11131 * Checks if `object` conforms to `source` by invoking the predicate
11132 * properties of `source` with the corresponding property values of `object`.
11134 * **Note:** This method is equivalent to `_.conforms` when `source` is
11135 * partially applied.
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`.
11146 * var object = { 'a': 1, 'b': 2 };
11148 * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11151 * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11154 function conformsTo(object, source) {
11155 return source == null || baseConformsTo(object, source, keys(source));
11160 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11161 * comparison between two values to determine if they are equivalent.
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`.
11172 * var object = { 'a': 1 };
11173 * var other = { 'a': 1 };
11175 * _.eq(object, object);
11178 * _.eq(object, other);
11184 * _.eq('a', Object('a'));
11190 function eq(value, other) {
11191 return value === other || (value !== value && other !== other);
11195 * Checks if `value` is greater than `other`.
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`,
11217 var gt = createRelationalOperation(baseGt);
11220 * Checks if `value` is greater than or equal to `other`.
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`.
11242 var gte = createRelationalOperation(function(value, other) {
11243 return value >= other;
11247 * Checks if `value` is likely an `arguments` object.
11253 * @param {*} value The value to check.
11254 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11258 * _.isArguments(function() { return arguments; }());
11261 * _.isArguments([1, 2, 3]);
11264 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11265 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11266 !propertyIsEnumerable.call(value, 'callee');
11270 * Checks if `value` is classified as an `Array` object.
11276 * @param {*} value The value to check.
11277 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11280 * _.isArray([1, 2, 3]);
11283 * _.isArray(document.body.children);
11286 * _.isArray('abc');
11289 * _.isArray(_.noop);
11292 var isArray = Array.isArray;
11295 * Checks if `value` is classified as an `ArrayBuffer` object.
11301 * @param {*} value The value to check.
11302 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11305 * _.isArrayBuffer(new ArrayBuffer(2));
11308 * _.isArrayBuffer(new Array(2));
11311 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
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`.
11322 * @param {*} value The value to check.
11323 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11326 * _.isArrayLike([1, 2, 3]);
11329 * _.isArrayLike(document.body.children);
11332 * _.isArrayLike('abc');
11335 * _.isArrayLike(_.noop);
11338 function isArrayLike(value) {
11339 return value != null && isLength(value.length) && !isFunction(value);
11343 * This method is like `_.isArrayLike` except that it also checks if `value`
11350 * @param {*} value The value to check.
11351 * @returns {boolean} Returns `true` if `value` is an array-like object,
11355 * _.isArrayLikeObject([1, 2, 3]);
11358 * _.isArrayLikeObject(document.body.children);
11361 * _.isArrayLikeObject('abc');
11364 * _.isArrayLikeObject(_.noop);
11367 function isArrayLikeObject(value) {
11368 return isObjectLike(value) && isArrayLike(value);
11372 * Checks if `value` is classified as a boolean primitive or object.
11378 * @param {*} value The value to check.
11379 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11382 * _.isBoolean(false);
11385 * _.isBoolean(null);
11388 function isBoolean(value) {
11389 return value === true || value === false ||
11390 (isObjectLike(value) && baseGetTag(value) == boolTag);
11394 * Checks if `value` is a buffer.
11400 * @param {*} value The value to check.
11401 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11404 * _.isBuffer(new Buffer(2));
11407 * _.isBuffer(new Uint8Array(2));
11410 var isBuffer = nativeIsBuffer || stubFalse;
11413 * Checks if `value` is classified as a `Date` object.
11419 * @param {*} value The value to check.
11420 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11423 * _.isDate(new Date);
11426 * _.isDate('Mon April 23 2012');
11429 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11432 * Checks if `value` is likely a DOM element.
11438 * @param {*} value The value to check.
11439 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11442 * _.isElement(document.body);
11445 * _.isElement('<body>');
11448 function isElement(value) {
11449 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11453 * Checks if `value` is an empty object, collection, map, or set.
11455 * Objects are considered empty if they have no own enumerable string keyed
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`.
11466 * @param {*} value The value to check.
11467 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11479 * _.isEmpty([1, 2, 3]);
11482 * _.isEmpty({ 'a': 1 });
11485 function isEmpty(value) {
11486 if (value == null) {
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;
11494 var tag = getTag(value);
11495 if (tag == mapTag || tag == setTag) {
11496 return !value.size;
11498 if (isPrototype(value)) {
11499 return !baseKeys(value).length;
11501 for (var key in value) {
11502 if (hasOwnProperty.call(value, key)) {
11510 * Performs a deep comparison between two values to determine if they are
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. `===`.
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`.
11528 * var object = { 'a': 1 };
11529 * var other = { 'a': 1 };
11531 * _.isEqual(object, other);
11534 * object === other;
11537 function isEqual(value, other) {
11538 return baseIsEqual(value, other);
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]).
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`.
11557 * function isGreeting(value) {
11558 * return /^h(?:i|ello)$/.test(value);
11561 * function customizer(objValue, othValue) {
11562 * if (isGreeting(objValue) && isGreeting(othValue)) {
11567 * var array = ['hello', 'goodbye'];
11568 * var other = ['hi', 'goodbye'];
11570 * _.isEqualWith(array, other, customizer);
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;
11580 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11581 * `SyntaxError`, `TypeError`, or `URIError` object.
11587 * @param {*} value The value to check.
11588 * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11591 * _.isError(new Error);
11594 * _.isError(Error);
11597 function isError(value) {
11598 if (!isObjectLike(value)) {
11601 var tag = baseGetTag(value);
11602 return tag == errorTag || tag == domExcTag ||
11603 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11607 * Checks if `value` is a finite primitive number.
11609 * **Note:** This method is based on
11610 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11616 * @param {*} value The value to check.
11617 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11623 * _.isFinite(Number.MIN_VALUE);
11626 * _.isFinite(Infinity);
11632 function isFinite(value) {
11633 return typeof value == 'number' && nativeIsFinite(value);
11637 * Checks if `value` is classified as a `Function` object.
11643 * @param {*} value The value to check.
11644 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11650 * _.isFunction(/abc/);
11653 function isFunction(value) {
11654 if (!isObject(value)) {
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;
11664 * Checks if `value` is an integer.
11666 * **Note:** This method is based on
11667 * [`Number.isInteger`](https://mdn.io/Number/isInteger).
11673 * @param {*} value The value to check.
11674 * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
11680 * _.isInteger(Number.MIN_VALUE);
11683 * _.isInteger(Infinity);
11686 * _.isInteger('3');
11689 function isInteger(value) {
11690 return typeof value == 'number' && value == toInteger(value);
11694 * Checks if `value` is a valid array-like length.
11696 * **Note:** This method is loosely based on
11697 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
11703 * @param {*} value The value to check.
11704 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11710 * _.isLength(Number.MIN_VALUE);
11713 * _.isLength(Infinity);
11719 function isLength(value) {
11720 return typeof value == 'number' &&
11721 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
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('')`)
11733 * @param {*} value The value to check.
11734 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11740 * _.isObject([1, 2, 3]);
11743 * _.isObject(_.noop);
11746 * _.isObject(null);
11749 function isObject(value) {
11750 var type = typeof value;
11751 return value != null && (type == 'object' || type == 'function');
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".
11762 * @param {*} value The value to check.
11763 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11766 * _.isObjectLike({});
11769 * _.isObjectLike([1, 2, 3]);
11772 * _.isObjectLike(_.noop);
11775 * _.isObjectLike(null);
11778 function isObjectLike(value) {
11779 return value != null && typeof value == 'object';
11783 * Checks if `value` is classified as a `Map` object.
11789 * @param {*} value The value to check.
11790 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
11793 * _.isMap(new Map);
11796 * _.isMap(new WeakMap);
11799 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
11802 * Performs a partial deep comparison between `object` and `source` to
11803 * determine if `object` contains equivalent property values.
11805 * **Note:** This method is equivalent to `_.matches` when `source` is
11806 * partially applied.
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.
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`.
11821 * var object = { 'a': 1, 'b': 2 };
11823 * _.isMatch(object, { 'b': 2 });
11826 * _.isMatch(object, { 'b': 1 });
11829 function isMatch(object, source) {
11830 return object === source || baseIsMatch(object, source, getMatchData(source));
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).
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`.
11849 * function isGreeting(value) {
11850 * return /^h(?:i|ello)$/.test(value);
11853 * function customizer(objValue, srcValue) {
11854 * if (isGreeting(objValue) && isGreeting(srcValue)) {
11859 * var object = { 'greeting': 'hello' };
11860 * var source = { 'greeting': 'hi' };
11862 * _.isMatchWith(object, source, customizer);
11865 function isMatchWith(object, source, customizer) {
11866 customizer = typeof customizer == 'function' ? customizer : undefined;
11867 return baseIsMatch(object, source, getMatchData(source), customizer);
11871 * Checks if `value` is `NaN`.
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.
11882 * @param {*} value The value to check.
11883 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
11889 * _.isNaN(new Number(NaN));
11892 * isNaN(undefined);
11895 * _.isNaN(undefined);
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;
11906 * Checks if `value` is a pristine native function.
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.
11920 * @param {*} value The value to check.
11921 * @returns {boolean} Returns `true` if `value` is a native function,
11925 * _.isNative(Array.prototype.push);
11931 function isNative(value) {
11932 if (isMaskable(value)) {
11933 throw new Error(CORE_ERROR_TEXT);
11935 return baseIsNative(value);
11939 * Checks if `value` is `null`.
11945 * @param {*} value The value to check.
11946 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
11952 * _.isNull(void 0);
11955 function isNull(value) {
11956 return value === null;
11960 * Checks if `value` is `null` or `undefined`.
11966 * @param {*} value The value to check.
11967 * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
11979 function isNil(value) {
11980 return value == null;
11984 * Checks if `value` is classified as a `Number` primitive or object.
11986 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
11987 * classified as numbers, use the `_.isFinite` method.
11993 * @param {*} value The value to check.
11994 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
12000 * _.isNumber(Number.MIN_VALUE);
12003 * _.isNumber(Infinity);
12009 function isNumber(value) {
12010 return typeof value == 'number' ||
12011 (isObjectLike(value) && baseGetTag(value) == numberTag);
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`.
12022 * @param {*} value The value to check.
12023 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
12030 * _.isPlainObject(new Foo);
12033 * _.isPlainObject([1, 2, 3]);
12036 * _.isPlainObject({ 'x': 0, 'y': 0 });
12039 * _.isPlainObject(Object.create(null));
12042 function isPlainObject(value) {
12043 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12046 var proto = getPrototype(value);
12047 if (proto === null) {
12050 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12051 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12052 funcToString.call(Ctor) == objectCtorString;
12056 * Checks if `value` is classified as a `RegExp` object.
12062 * @param {*} value The value to check.
12063 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12066 * _.isRegExp(/abc/);
12069 * _.isRegExp('/abc/');
12072 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
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.
12078 * **Note:** This method is based on
12079 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12085 * @param {*} value The value to check.
12086 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12089 * _.isSafeInteger(3);
12092 * _.isSafeInteger(Number.MIN_VALUE);
12095 * _.isSafeInteger(Infinity);
12098 * _.isSafeInteger('3');
12101 function isSafeInteger(value) {
12102 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12106 * Checks if `value` is classified as a `Set` object.
12112 * @param {*} value The value to check.
12113 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12116 * _.isSet(new Set);
12119 * _.isSet(new WeakSet);
12122 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12125 * Checks if `value` is classified as a `String` primitive or object.
12131 * @param {*} value The value to check.
12132 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12135 * _.isString('abc');
12141 function isString(value) {
12142 return typeof value == 'string' ||
12143 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12147 * Checks if `value` is classified as a `Symbol` primitive or object.
12153 * @param {*} value The value to check.
12154 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12157 * _.isSymbol(Symbol.iterator);
12160 * _.isSymbol('abc');
12163 function isSymbol(value) {
12164 return typeof value == 'symbol' ||
12165 (isObjectLike(value) && baseGetTag(value) == symbolTag);
12169 * Checks if `value` is classified as a typed array.
12175 * @param {*} value The value to check.
12176 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12179 * _.isTypedArray(new Uint8Array);
12182 * _.isTypedArray([]);
12185 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12188 * Checks if `value` is `undefined`.
12194 * @param {*} value The value to check.
12195 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12198 * _.isUndefined(void 0);
12201 * _.isUndefined(null);
12204 function isUndefined(value) {
12205 return value === undefined;
12209 * Checks if `value` is classified as a `WeakMap` object.
12215 * @param {*} value The value to check.
12216 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12219 * _.isWeakMap(new WeakMap);
12222 * _.isWeakMap(new Map);
12225 function isWeakMap(value) {
12226 return isObjectLike(value) && getTag(value) == weakMapTag;
12230 * Checks if `value` is classified as a `WeakSet` object.
12236 * @param {*} value The value to check.
12237 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12240 * _.isWeakSet(new WeakSet);
12243 * _.isWeakSet(new Set);
12246 function isWeakSet(value) {
12247 return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12251 * Checks if `value` is less than `other`.
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`,
12273 var lt = createRelationalOperation(baseLt);
12276 * Checks if `value` is less than or equal to `other`.
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`.
12298 var lte = createRelationalOperation(function(value, other) {
12299 return value <= other;
12303 * Converts `value` to an array.
12309 * @param {*} value The value to convert.
12310 * @returns {Array} Returns the converted array.
12313 * _.toArray({ 'a': 1, 'b': 2 });
12316 * _.toArray('abc');
12317 * // => ['a', 'b', 'c']
12325 function toArray(value) {
12329 if (isArrayLike(value)) {
12330 return isString(value) ? stringToArray(value) : copyArray(value);
12332 if (symIterator && value[symIterator]) {
12333 return iteratorToArray(value[symIterator]());
12335 var tag = getTag(value),
12336 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12338 return func(value);
12342 * Converts `value` to a finite number.
12348 * @param {*} value The value to convert.
12349 * @returns {number} Returns the converted number.
12355 * _.toFinite(Number.MIN_VALUE);
12358 * _.toFinite(Infinity);
12359 * // => 1.7976931348623157e+308
12361 * _.toFinite('3.2');
12364 function toFinite(value) {
12366 return value === 0 ? value : 0;
12368 value = toNumber(value);
12369 if (value === INFINITY || value === -INFINITY) {
12370 var sign = (value < 0 ? -1 : 1);
12371 return sign * MAX_INTEGER;
12373 return value === value ? value : 0;
12377 * Converts `value` to an integer.
12379 * **Note:** This method is loosely based on
12380 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12386 * @param {*} value The value to convert.
12387 * @returns {number} Returns the converted integer.
12390 * _.toInteger(3.2);
12393 * _.toInteger(Number.MIN_VALUE);
12396 * _.toInteger(Infinity);
12397 * // => 1.7976931348623157e+308
12399 * _.toInteger('3.2');
12402 function toInteger(value) {
12403 var result = toFinite(value),
12404 remainder = result % 1;
12406 return result === result ? (remainder ? result - remainder : result) : 0;
12410 * Converts `value` to an integer suitable for use as the length of an
12411 * array-like object.
12413 * **Note:** This method is based on
12414 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12420 * @param {*} value The value to convert.
12421 * @returns {number} Returns the converted integer.
12427 * _.toLength(Number.MIN_VALUE);
12430 * _.toLength(Infinity);
12433 * _.toLength('3.2');
12436 function toLength(value) {
12437 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12441 * Converts `value` to a number.
12447 * @param {*} value The value to process.
12448 * @returns {number} Returns the number.
12454 * _.toNumber(Number.MIN_VALUE);
12457 * _.toNumber(Infinity);
12460 * _.toNumber('3.2');
12463 function toNumber(value) {
12464 if (typeof value == 'number') {
12467 if (isSymbol(value)) {
12470 if (isObject(value)) {
12471 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12472 value = isObject(other) ? (other + '') : other;
12474 if (typeof value != 'string') {
12475 return value === 0 ? value : +value;
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);
12485 * Converts `value` to a plain object flattening inherited enumerable string
12486 * keyed properties of `value` to own properties of the plain object.
12492 * @param {*} value The value to convert.
12493 * @returns {Object} Returns the converted plain object.
12500 * Foo.prototype.c = 3;
12502 * _.assign({ 'a': 1 }, new Foo);
12503 * // => { 'a': 1, 'b': 2 }
12505 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12506 * // => { 'a': 1, 'b': 2, 'c': 3 }
12508 function toPlainObject(value) {
12509 return copyObject(value, keysIn(value));
12513 * Converts `value` to a safe integer. A safe integer can be compared and
12514 * represented correctly.
12520 * @param {*} value The value to convert.
12521 * @returns {number} Returns the converted integer.
12524 * _.toSafeInteger(3.2);
12527 * _.toSafeInteger(Number.MIN_VALUE);
12530 * _.toSafeInteger(Infinity);
12531 * // => 9007199254740991
12533 * _.toSafeInteger('3.2');
12536 function toSafeInteger(value) {
12538 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
12539 : (value === 0 ? value : 0);
12543 * Converts `value` to a string. An empty string is returned for `null`
12544 * and `undefined` values. The sign of `-0` is preserved.
12550 * @param {*} value The value to convert.
12551 * @returns {string} Returns the converted string.
12554 * _.toString(null);
12560 * _.toString([1, 2, 3]);
12563 function toString(value) {
12564 return value == null ? '' : baseToString(value);
12567 /*------------------------------------------------------------------------*/
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.
12574 * **Note:** This method mutates `object` and is loosely based on
12575 * [`Object.assign`](https://mdn.io/Object/assign).
12581 * @param {Object} object The destination object.
12582 * @param {...Object} [sources] The source objects.
12583 * @returns {Object} Returns `object`.
12595 * Foo.prototype.b = 2;
12596 * Bar.prototype.d = 4;
12598 * _.assign({ 'a': 0 }, new Foo, new Bar);
12599 * // => { 'a': 1, 'c': 3 }
12601 var assign = createAssigner(function(object, source) {
12602 if (isPrototype(source) || isArrayLike(source)) {
12603 copyObject(source, keys(source), object);
12606 for (var key in source) {
12607 if (hasOwnProperty.call(source, key)) {
12608 assignValue(object, key, source[key]);
12614 * This method is like `_.assign` except that it iterates over own and
12615 * inherited source properties.
12617 * **Note:** This method mutates `object`.
12624 * @param {Object} object The destination object.
12625 * @param {...Object} [sources] The source objects.
12626 * @returns {Object} Returns `object`.
12638 * Foo.prototype.b = 2;
12639 * Bar.prototype.d = 4;
12641 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12642 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12644 var assignIn = createAssigner(function(object, source) {
12645 copyObject(source, keysIn(source), object);
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).
12654 * **Note:** This method mutates `object`.
12659 * @alias extendWith
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
12668 * function customizer(objValue, srcValue) {
12669 * return _.isUndefined(objValue) ? srcValue : objValue;
12672 * var defaults = _.partialRight(_.assignInWith, customizer);
12674 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12675 * // => { 'a': 1, 'b': 2 }
12677 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
12678 copyObject(source, keysIn(source), object, customizer);
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).
12687 * **Note:** This method mutates `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
12700 * function customizer(objValue, srcValue) {
12701 * return _.isUndefined(objValue) ? srcValue : objValue;
12704 * var defaults = _.partialRight(_.assignWith, customizer);
12706 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12707 * // => { 'a': 1, 'b': 2 }
12709 var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
12710 copyObject(source, keys(source), object, customizer);
12714 * Creates an array of values corresponding to `paths` of `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.
12725 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
12727 * _.at(object, ['a[0].b.c', 'a[1]']);
12730 var at = flatRest(baseAt);
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.
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.
12746 * function Shape() {
12751 * function Circle() {
12752 * Shape.call(this);
12755 * Circle.prototype = _.create(Shape.prototype, {
12756 * 'constructor': Circle
12759 * var circle = new Circle;
12760 * circle instanceof Circle;
12763 * circle instanceof Shape;
12766 function create(prototype, properties) {
12767 var result = baseCreate(prototype);
12768 return properties == null ? result : baseAssign(result, properties);
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.
12777 * **Note:** This method mutates `object`.
12783 * @param {Object} object The destination object.
12784 * @param {...Object} [sources] The source objects.
12785 * @returns {Object} Returns `object`.
12786 * @see _.defaultsDeep
12789 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12790 * // => { 'a': 1, 'b': 2 }
12792 var defaults = baseRest(function(object, sources) {
12793 object = Object(object);
12796 var length = sources.length;
12797 var guard = length > 2 ? sources[2] : undefined;
12799 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
12803 while (++index < length) {
12804 var source = sources[index];
12805 var props = keysIn(source);
12806 var propsIndex = -1;
12807 var propsLength = props.length;
12809 while (++propsIndex < propsLength) {
12810 var key = props[propsIndex];
12811 var value = object[key];
12813 if (value === undefined ||
12814 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
12815 object[key] = source[key];
12824 * This method is like `_.defaults` except that it recursively assigns
12825 * default properties.
12827 * **Note:** This method mutates `object`.
12833 * @param {Object} object The destination object.
12834 * @param {...Object} [sources] The source objects.
12835 * @returns {Object} Returns `object`.
12839 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
12840 * // => { 'a': { 'b': 2, 'c': 3 } }
12842 var defaultsDeep = baseRest(function(args) {
12843 args.push(undefined, customDefaultsMerge);
12844 return apply(mergeWith, undefined, args);
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.
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`.
12862 * 'barney': { 'age': 36, 'active': true },
12863 * 'fred': { 'age': 40, 'active': false },
12864 * 'pebbles': { 'age': 1, 'active': true }
12867 * _.findKey(users, function(o) { return o.age < 40; });
12868 * // => 'barney' (iteration order is not guaranteed)
12870 * // The `_.matches` iteratee shorthand.
12871 * _.findKey(users, { 'age': 1, 'active': true });
12874 * // The `_.matchesProperty` iteratee shorthand.
12875 * _.findKey(users, ['active', false]);
12878 * // The `_.property` iteratee shorthand.
12879 * _.findKey(users, 'active');
12882 function findKey(object, predicate) {
12883 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
12887 * This method is like `_.findKey` except that it iterates over elements of
12888 * a collection in the opposite order.
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`.
12901 * 'barney': { 'age': 36, 'active': true },
12902 * 'fred': { 'age': 40, 'active': false },
12903 * 'pebbles': { 'age': 1, 'active': true }
12906 * _.findLastKey(users, function(o) { return o.age < 40; });
12907 * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
12909 * // The `_.matches` iteratee shorthand.
12910 * _.findLastKey(users, { 'age': 36, 'active': true });
12913 * // The `_.matchesProperty` iteratee shorthand.
12914 * _.findLastKey(users, ['active', false]);
12917 * // The `_.property` iteratee shorthand.
12918 * _.findLastKey(users, 'active');
12921 function findLastKey(object, predicate) {
12922 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
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`.
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
12946 * Foo.prototype.c = 3;
12948 * _.forIn(new Foo, function(value, key) {
12949 * console.log(key);
12951 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
12953 function forIn(object, iteratee) {
12954 return object == null
12956 : baseFor(object, getIteratee(iteratee, 3), keysIn);
12960 * This method is like `_.forIn` except that it iterates over properties of
12961 * `object` in the opposite order.
12967 * @param {Object} object The object to iterate over.
12968 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12969 * @returns {Object} Returns `object`.
12978 * Foo.prototype.c = 3;
12980 * _.forInRight(new Foo, function(value, key) {
12981 * console.log(key);
12983 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
12985 function forInRight(object, iteratee) {
12986 return object == null
12988 : baseForRight(object, getIteratee(iteratee, 3), keysIn);
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`.
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
13012 * Foo.prototype.c = 3;
13014 * _.forOwn(new Foo, function(value, key) {
13015 * console.log(key);
13017 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
13019 function forOwn(object, iteratee) {
13020 return object && baseForOwn(object, getIteratee(iteratee, 3));
13024 * This method is like `_.forOwn` except that it iterates over properties of
13025 * `object` in the opposite order.
13031 * @param {Object} object The object to iterate over.
13032 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13033 * @returns {Object} Returns `object`.
13042 * Foo.prototype.c = 3;
13044 * _.forOwnRight(new Foo, function(value, key) {
13045 * console.log(key);
13047 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
13049 function forOwnRight(object, iteratee) {
13050 return object && baseForOwnRight(object, getIteratee(iteratee, 3));
13054 * Creates an array of function property names from own enumerable properties
13061 * @param {Object} object The object to inspect.
13062 * @returns {Array} Returns the function names.
13063 * @see _.functionsIn
13067 * this.a = _.constant('a');
13068 * this.b = _.constant('b');
13071 * Foo.prototype.c = _.constant('c');
13073 * _.functions(new Foo);
13076 function functions(object) {
13077 return object == null ? [] : baseFunctions(object, keys(object));
13081 * Creates an array of function property names from own and inherited
13082 * enumerable properties of `object`.
13088 * @param {Object} object The object to inspect.
13089 * @returns {Array} Returns the function names.
13094 * this.a = _.constant('a');
13095 * this.b = _.constant('b');
13098 * Foo.prototype.c = _.constant('c');
13100 * _.functionsIn(new Foo);
13101 * // => ['a', 'b', 'c']
13103 function functionsIn(object) {
13104 return object == null ? [] : baseFunctions(object, keysIn(object));
13108 * Gets the value at `path` of `object`. If the resolved value is
13109 * `undefined`, the `defaultValue` is returned in its place.
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.
13121 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13123 * _.get(object, 'a[0].b.c');
13126 * _.get(object, ['a', '0', 'b', 'c']);
13129 * _.get(object, 'a.b.c', 'default');
13132 function get(object, path, defaultValue) {
13133 var result = object == null ? undefined : baseGet(object, path);
13134 return result === undefined ? defaultValue : result;
13138 * Checks if `path` is a direct property of `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`.
13149 * var object = { 'a': { 'b': 2 } };
13150 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13152 * _.has(object, 'a');
13155 * _.has(object, 'a.b');
13158 * _.has(object, ['a', 'b']);
13161 * _.has(other, 'a');
13164 function has(object, path) {
13165 return object != null && hasPath(object, path, baseHas);
13169 * Checks if `path` is a direct or inherited property of `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`.
13180 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13182 * _.hasIn(object, 'a');
13185 * _.hasIn(object, 'a.b');
13188 * _.hasIn(object, ['a', 'b']);
13191 * _.hasIn(object, 'b');
13194 function hasIn(object, path) {
13195 return object != null && hasPath(object, path, baseHasIn);
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.
13207 * @param {Object} object The object to invert.
13208 * @returns {Object} Returns the new inverted object.
13211 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13213 * _.invert(object);
13214 * // => { '1': 'c', '2': 'b' }
13216 var invert = createInverter(function(result, value, key) {
13217 if (value != null &&
13218 typeof value.toString != 'function') {
13219 value = nativeObjectToString.call(value);
13222 result[value] = key;
13223 }, constant(identity));
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).
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.
13241 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13243 * _.invertBy(object);
13244 * // => { '1': ['a', 'c'], '2': ['b'] }
13246 * _.invertBy(object, function(value) {
13247 * return 'group' + value;
13249 * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13251 var invertBy = createInverter(function(result, value, key) {
13252 if (value != null &&
13253 typeof value.toString != 'function') {
13254 value = nativeObjectToString.call(value);
13257 if (hasOwnProperty.call(result, value)) {
13258 result[value].push(key);
13260 result[value] = [key];
13265 * Invokes the method at `path` of `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.
13277 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13279 * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13282 var invoke = baseRest(baseInvoke);
13285 * Creates an array of the own enumerable property names of `object`.
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.
13295 * @param {Object} object The object to query.
13296 * @returns {Array} Returns the array of property names.
13304 * Foo.prototype.c = 3;
13307 * // => ['a', 'b'] (iteration order is not guaranteed)
13312 function keys(object) {
13313 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13317 * Creates an array of the own and inherited enumerable property names of `object`.
13319 * **Note:** Non-object values are coerced to objects.
13325 * @param {Object} object The object to query.
13326 * @returns {Array} Returns the array of property names.
13334 * Foo.prototype.c = 3;
13336 * _.keysIn(new Foo);
13337 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13339 function keysIn(object) {
13340 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
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).
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.
13359 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13360 * return key + value;
13362 * // => { 'a1': 1, 'b2': 2 }
13364 function mapKeys(object, iteratee) {
13366 iteratee = getIteratee(iteratee, 3);
13368 baseForOwn(object, function(value, key, object) {
13369 baseAssignValue(result, iteratee(value, key, object), value);
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).
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.
13391 * 'fred': { 'user': 'fred', 'age': 40 },
13392 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
13395 * _.mapValues(users, function(o) { return o.age; });
13396 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13398 * // The `_.property` iteratee shorthand.
13399 * _.mapValues(users, 'age');
13400 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13402 function mapValues(object, iteratee) {
13404 iteratee = getIteratee(iteratee, 3);
13406 baseForOwn(object, function(value, key, object) {
13407 baseAssignValue(result, key, iteratee(value, key, object));
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.
13421 * **Note:** This method mutates `object`.
13427 * @param {Object} object The destination object.
13428 * @param {...Object} [sources] The source objects.
13429 * @returns {Object} Returns `object`.
13433 * 'a': [{ 'b': 2 }, { 'd': 4 }]
13437 * 'a': [{ 'c': 3 }, { 'e': 5 }]
13440 * _.merge(object, other);
13441 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13443 var merge = createAssigner(function(object, source, srcIndex) {
13444 baseMerge(object, source, srcIndex);
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).
13454 * **Note:** This method mutates `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`.
13466 * function customizer(objValue, srcValue) {
13467 * if (_.isArray(objValue)) {
13468 * return objValue.concat(srcValue);
13472 * var object = { 'a': [1], 'b': [2] };
13473 * var other = { 'a': [3], 'b': [4] };
13475 * _.mergeWith(object, other, customizer);
13476 * // => { 'a': [1, 3], 'b': [2, 4] }
13478 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13479 baseMerge(object, source, srcIndex, customizer);
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.
13486 * **Note:** This method is considerably slower than `_.pick`.
13492 * @param {Object} object The source object.
13493 * @param {...(string|string[])} [paths] The property paths to omit.
13494 * @returns {Object} Returns the new object.
13497 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13499 * _.omit(object, ['a', 'c']);
13500 * // => { 'b': '2' }
13502 var omit = flatRest(function(object, paths) {
13504 if (object == null) {
13507 var isDeep = false;
13508 paths = arrayMap(paths, function(path) {
13509 path = castPath(path, object);
13510 isDeep || (isDeep = path.length > 1);
13513 copyObject(object, getAllKeysIn(object), result);
13515 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
13517 var length = paths.length;
13519 baseUnset(result, paths[length]);
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).
13534 * @param {Object} object The source object.
13535 * @param {Function} [predicate=_.identity] The function invoked per property.
13536 * @returns {Object} Returns the new object.
13539 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13541 * _.omitBy(object, _.isNumber);
13542 * // => { 'b': '2' }
13544 function omitBy(object, predicate) {
13545 return pickBy(object, negate(getIteratee(predicate)));
13549 * Creates an object composed of the picked `object` properties.
13555 * @param {Object} object The source object.
13556 * @param {...(string|string[])} [paths] The property paths to pick.
13557 * @returns {Object} Returns the new object.
13560 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13562 * _.pick(object, ['a', 'c']);
13563 * // => { 'a': 1, 'c': 3 }
13565 var pick = flatRest(function(object, paths) {
13566 return object == null ? {} : basePick(object, paths);
13570 * Creates an object composed of the `object` properties `predicate` returns
13571 * truthy for. The predicate is invoked with two arguments: (value, key).
13577 * @param {Object} object The source object.
13578 * @param {Function} [predicate=_.identity] The function invoked per property.
13579 * @returns {Object} Returns the new object.
13582 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13584 * _.pickBy(object, _.isNumber);
13585 * // => { 'a': 1, 'c': 3 }
13587 function pickBy(object, predicate) {
13588 if (object == null) {
13591 var props = arrayMap(getAllKeysIn(object), function(prop) {
13594 predicate = getIteratee(predicate);
13595 return basePickBy(object, props, function(value, path) {
13596 return predicate(value, path[0]);
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.
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.
13615 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13617 * _.result(object, 'a[0].b.c1');
13620 * _.result(object, 'a[0].b.c2');
13623 * _.result(object, 'a[0].b.c3', 'default');
13626 * _.result(object, 'a[0].b.c3', _.constant('default'));
13629 function result(object, path, defaultValue) {
13630 path = castPath(path, object);
13633 length = path.length;
13635 // Ensure the loop is entered when path is empty.
13638 object = undefined;
13640 while (++index < length) {
13641 var value = object == null ? undefined : object[toKey(path[index])];
13642 if (value === undefined) {
13644 value = defaultValue;
13646 object = isFunction(value) ? value.call(object) : value;
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
13657 * **Note:** This method mutates `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`.
13669 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13671 * _.set(object, 'a[0].b.c', 4);
13672 * console.log(object.a[0].b.c);
13675 * _.set(object, ['x', '0', 'y', 'z'], 5);
13676 * console.log(object.x[0].y.z);
13679 function set(object, path, value) {
13680 return object == null ? object : baseSet(object, path, value);
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).
13689 * **Note:** This method mutates `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`.
13704 * _.setWith(object, '[0][1]', 'a', Object);
13705 * // => { '0': { '1': 'a' } }
13707 function setWith(object, path, value, customizer) {
13708 customizer = typeof customizer == 'function' ? customizer : undefined;
13709 return object == null ? object : baseSet(object, path, value, customizer);
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.
13722 * @param {Object} object The object to query.
13723 * @returns {Array} Returns the key-value pairs.
13731 * Foo.prototype.c = 3;
13733 * _.toPairs(new Foo);
13734 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
13736 var toPairs = createToPairs(keys);
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.
13748 * @param {Object} object The object to query.
13749 * @returns {Array} Returns the key-value pairs.
13757 * Foo.prototype.c = 3;
13759 * _.toPairsIn(new Foo);
13760 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
13762 var toPairsIn = createToPairs(keysIn);
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`.
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.
13783 * _.transform([2, 3, 4], function(result, n) {
13784 * result.push(n *= n);
13785 * return n % 2 == 0;
13789 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
13790 * (result[value] || (result[value] = [])).push(key);
13792 * // => { '1': ['a', 'c'], '2': ['b'] }
13794 function transform(object, iteratee, accumulator) {
13795 var isArr = isArray(object),
13796 isArrLike = isArr || isBuffer(object) || isTypedArray(object);
13798 iteratee = getIteratee(iteratee, 4);
13799 if (accumulator == null) {
13800 var Ctor = object && object.constructor;
13802 accumulator = isArr ? new Ctor : [];
13804 else if (isObject(object)) {
13805 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
13811 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
13812 return iteratee(accumulator, value, index, object);
13814 return accumulator;
13818 * Removes the property at `path` of `object`.
13820 * **Note:** This method mutates `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`.
13831 * var object = { 'a': [{ 'b': { 'c': 7 } }] };
13832 * _.unset(object, 'a[0].b.c');
13835 * console.log(object);
13836 * // => { 'a': [{ 'b': {} }] };
13838 * _.unset(object, ['a', '0', 'b', 'c']);
13841 * console.log(object);
13842 * // => { 'a': [{ 'b': {} }] };
13844 function unset(object, path) {
13845 return object == null ? true : baseUnset(object, path);
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).
13853 * **Note:** This method mutates `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`.
13865 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13867 * _.update(object, 'a[0].b.c', function(n) { return n * n; });
13868 * console.log(object.a[0].b.c);
13871 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
13872 * console.log(object.x[0].y.z);
13875 function update(object, path, updater) {
13876 return object == null ? object : baseUpdate(object, path, castFunction(updater));
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).
13885 * **Note:** This method mutates `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`.
13900 * _.updateWith(object, '[0][1]', _.constant('a'), Object);
13901 * // => { '0': { '1': 'a' } }
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);
13909 * Creates an array of the own enumerable string keyed property values of `object`.
13911 * **Note:** Non-object values are coerced to objects.
13917 * @param {Object} object The object to query.
13918 * @returns {Array} Returns the array of property values.
13926 * Foo.prototype.c = 3;
13928 * _.values(new Foo);
13929 * // => [1, 2] (iteration order is not guaranteed)
13934 function values(object) {
13935 return object == null ? [] : baseValues(object, keys(object));
13939 * Creates an array of the own and inherited enumerable string keyed property
13940 * values of `object`.
13942 * **Note:** Non-object values are coerced to objects.
13948 * @param {Object} object The object to query.
13949 * @returns {Array} Returns the array of property values.
13957 * Foo.prototype.c = 3;
13959 * _.valuesIn(new Foo);
13960 * // => [1, 2, 3] (iteration order is not guaranteed)
13962 function valuesIn(object) {
13963 return object == null ? [] : baseValues(object, keysIn(object));
13966 /*------------------------------------------------------------------------*/
13969 * Clamps `number` within the inclusive `lower` and `upper` bounds.
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.
13981 * _.clamp(-10, -5, 5);
13984 * _.clamp(10, -5, 5);
13987 function clamp(number, lower, upper) {
13988 if (upper === undefined) {
13992 if (upper !== undefined) {
13993 upper = toNumber(upper);
13994 upper = upper === upper ? upper : 0;
13996 if (lower !== undefined) {
13997 lower = toNumber(lower);
13998 lower = lower === lower ? lower : 0;
14000 return baseClamp(toNumber(number), lower, upper);
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
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
14020 * _.inRange(3, 2, 4);
14032 * _.inRange(1.2, 2);
14035 * _.inRange(5.2, 4);
14038 * _.inRange(-3, -2, -6);
14041 function inRange(number, start, end) {
14042 start = toFinite(start);
14043 if (end === undefined) {
14047 end = toFinite(end);
14049 number = toNumber(number);
14050 return baseInRange(number, start, end);
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.
14059 * **Note:** JavaScript follows the IEEE-754 standard for resolving
14060 * floating-point values which can produce unexpected results.
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.
14073 * // => an integer between 0 and 5
14076 * // => also an integer between 0 and 5
14078 * _.random(5, true);
14079 * // => a floating-point number between 0 and 5
14081 * _.random(1.2, 5.2);
14082 * // => a floating-point number between 1.2 and 5.2
14084 function random(lower, upper, floating) {
14085 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
14086 upper = floating = undefined;
14088 if (floating === undefined) {
14089 if (typeof upper == 'boolean') {
14093 else if (typeof lower == 'boolean') {
14098 if (lower === undefined && upper === undefined) {
14103 lower = toFinite(lower);
14104 if (upper === undefined) {
14108 upper = toFinite(upper);
14111 if (lower > upper) {
14116 if (floating || lower % 1 || upper % 1) {
14117 var rand = nativeRandom();
14118 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14120 return baseRandom(lower, upper);
14123 /*------------------------------------------------------------------------*/
14126 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14132 * @param {string} [string=''] The string to convert.
14133 * @returns {string} Returns the camel cased string.
14136 * _.camelCase('Foo Bar');
14139 * _.camelCase('--foo-bar--');
14142 * _.camelCase('__FOO_BAR__');
14145 var camelCase = createCompounder(function(result, word, index) {
14146 word = word.toLowerCase();
14147 return result + (index ? capitalize(word) : word);
14151 * Converts the first character of `string` to upper case and the remaining
14158 * @param {string} [string=''] The string to capitalize.
14159 * @returns {string} Returns the capitalized string.
14162 * _.capitalize('FRED');
14165 function capitalize(string) {
14166 return upperFirst(toString(string).toLowerCase());
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).
14180 * @param {string} [string=''] The string to deburr.
14181 * @returns {string} Returns the deburred string.
14184 * _.deburr('déjà vu');
14187 function deburr(string) {
14188 string = toString(string);
14189 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14193 * Checks if `string` ends with the given target 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`,
14206 * _.endsWith('abc', 'c');
14209 * _.endsWith('abc', 'b');
14212 * _.endsWith('abc', 'b', 2);
14215 function endsWith(string, target, position) {
14216 string = toString(string);
14217 target = baseToString(target);
14219 var length = string.length;
14220 position = position === undefined
14222 : baseClamp(toInteger(position), 0, length);
14224 var end = position;
14225 position -= target.length;
14226 return position >= 0 && string.slice(position, end) == target;
14230 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14231 * corresponding HTML entities.
14233 * **Note:** No other characters are escaped. To escape additional
14234 * characters use a third-party library like [_he_](https://mths.be/he).
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.
14242 * When working with HTML you should always
14243 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14250 * @param {string} [string=''] The string to escape.
14251 * @returns {string} Returns the escaped string.
14254 * _.escape('fred, barney, & pebbles');
14255 * // => 'fred, barney, & pebbles'
14257 function escape(string) {
14258 string = toString(string);
14259 return (string && reHasUnescapedHtml.test(string))
14260 ? string.replace(reUnescapedHtml, escapeHtmlChar)
14265 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14266 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14272 * @param {string} [string=''] The string to escape.
14273 * @returns {string} Returns the escaped string.
14276 * _.escapeRegExp('[lodash](https://lodash.com/)');
14277 * // => '\[lodash\]\(https://lodash\.com/\)'
14279 function escapeRegExp(string) {
14280 string = toString(string);
14281 return (string && reHasRegExpChar.test(string))
14282 ? string.replace(reRegExpChar, '\\$&')
14287 * Converts `string` to
14288 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14294 * @param {string} [string=''] The string to convert.
14295 * @returns {string} Returns the kebab cased string.
14298 * _.kebabCase('Foo Bar');
14301 * _.kebabCase('fooBar');
14304 * _.kebabCase('__FOO_BAR__');
14307 var kebabCase = createCompounder(function(result, word, index) {
14308 return result + (index ? '-' : '') + word.toLowerCase();
14312 * Converts `string`, as space separated words, to lower case.
14318 * @param {string} [string=''] The string to convert.
14319 * @returns {string} Returns the lower cased string.
14322 * _.lowerCase('--Foo-Bar--');
14325 * _.lowerCase('fooBar');
14328 * _.lowerCase('__FOO_BAR__');
14331 var lowerCase = createCompounder(function(result, word, index) {
14332 return result + (index ? ' ' : '') + word.toLowerCase();
14336 * Converts the first character of `string` to lower case.
14342 * @param {string} [string=''] The string to convert.
14343 * @returns {string} Returns the converted string.
14346 * _.lowerFirst('Fred');
14349 * _.lowerFirst('FRED');
14352 var lowerFirst = createCaseFirst('toLowerCase');
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`.
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.
14371 * _.pad('abc', 8, '_-');
14377 function pad(string, length, chars) {
14378 string = toString(string);
14379 length = toInteger(length);
14381 var strLength = length ? stringSize(string) : 0;
14382 if (!length || strLength >= length) {
14385 var mid = (length - strLength) / 2;
14387 createPadding(nativeFloor(mid), chars) +
14389 createPadding(nativeCeil(mid), chars)
14394 * Pads `string` on the right side if it's shorter than `length`. Padding
14395 * characters are truncated if they exceed `length`.
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.
14407 * _.padEnd('abc', 6);
14410 * _.padEnd('abc', 6, '_-');
14413 * _.padEnd('abc', 3);
14416 function padEnd(string, length, chars) {
14417 string = toString(string);
14418 length = toInteger(length);
14420 var strLength = length ? stringSize(string) : 0;
14421 return (length && strLength < length)
14422 ? (string + createPadding(length - strLength, chars))
14427 * Pads `string` on the left side if it's shorter than `length`. Padding
14428 * characters are truncated if they exceed `length`.
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.
14440 * _.padStart('abc', 6);
14443 * _.padStart('abc', 6, '_-');
14446 * _.padStart('abc', 3);
14449 function padStart(string, length, chars) {
14450 string = toString(string);
14451 length = toInteger(length);
14453 var strLength = length ? stringSize(string) : 0;
14454 return (length && strLength < length)
14455 ? (createPadding(length - strLength, chars) + string)
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.
14464 * **Note:** This method aligns with the
14465 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
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.
14477 * _.parseInt('08');
14480 * _.map(['6', '08', '10'], _.parseInt);
14483 function parseInt(string, radix, guard) {
14484 if (guard || radix == null) {
14486 } else if (radix) {
14489 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14493 * Repeats the given string `n` times.
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.
14505 * _.repeat('*', 3);
14508 * _.repeat('abc', 2);
14511 * _.repeat('abc', 0);
14514 function repeat(string, n, guard) {
14515 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
14520 return baseRepeat(toString(string), n);
14524 * Replaces matches for `pattern` in `string` with `replacement`.
14526 * **Note:** This method is based on
14527 * [`String#replace`](https://mdn.io/String/replace).
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.
14539 * _.replace('Hi Fred', 'Fred', 'Barney');
14540 * // => 'Hi Barney'
14542 function replace() {
14543 var args = arguments,
14544 string = toString(args[0]);
14546 return args.length < 3 ? string : string.replace(args[1], args[2]);
14550 * Converts `string` to
14551 * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14557 * @param {string} [string=''] The string to convert.
14558 * @returns {string} Returns the snake cased string.
14561 * _.snakeCase('Foo Bar');
14564 * _.snakeCase('fooBar');
14567 * _.snakeCase('--FOO-BAR--');
14570 var snakeCase = createCompounder(function(result, word, index) {
14571 return result + (index ? '_' : '') + word.toLowerCase();
14575 * Splits `string` by `separator`.
14577 * **Note:** This method is based on
14578 * [`String#split`](https://mdn.io/String/split).
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.
14590 * _.split('a-b-c', '-', 2);
14593 function split(string, separator, limit) {
14594 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14595 separator = limit = undefined;
14597 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
14601 string = toString(string);
14603 typeof separator == 'string' ||
14604 (separator != null && !isRegExp(separator))
14606 separator = baseToString(separator);
14607 if (!separator && hasUnicode(string)) {
14608 return castSlice(stringToArray(string), 0, limit);
14611 return string.split(separator, limit);
14615 * Converts `string` to
14616 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14622 * @param {string} [string=''] The string to convert.
14623 * @returns {string} Returns the start cased string.
14626 * _.startCase('--foo-bar--');
14629 * _.startCase('fooBar');
14632 * _.startCase('__FOO_BAR__');
14635 var startCase = createCompounder(function(result, word, index) {
14636 return result + (index ? ' ' : '') + upperFirst(word);
14640 * Checks if `string` starts with the given target 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`,
14653 * _.startsWith('abc', 'a');
14656 * _.startsWith('abc', 'b');
14659 * _.startsWith('abc', 'b', 1);
14662 function startsWith(string, target, position) {
14663 string = toString(string);
14664 position = position == null
14666 : baseClamp(toInteger(position), 0, string.length);
14668 target = baseToString(target);
14669 return string.slice(position, position + target.length) == target;
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.
14679 * **Note:** In the development build `_.template` utilizes
14680 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
14681 * for easier debugging.
14683 * For more information on precompiling templates see
14684 * [lodash's custom builds documentation](https://lodash.com/custom-builds).
14686 * For more information on Chrome extension sandboxes see
14687 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
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.
14711 * // Use the "interpolate" delimiter to create a compiled template.
14712 * var compiled = _.template('hello <%= user %>!');
14713 * compiled({ 'user': 'fred' });
14714 * // => 'hello fred!'
14716 * // Use the HTML "escape" delimiter to escape data property values.
14717 * var compiled = _.template('<b><%- value %></b>');
14718 * compiled({ 'value': '<script>' });
14719 * // => '<b><script></b>'
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>'
14726 * // Use the internal `print` function in "evaluate" delimiters.
14727 * var compiled = _.template('<% print("hello " + user); %>!');
14728 * compiled({ 'user': 'barney' });
14729 * // => 'hello barney!'
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!'
14737 * // Use backslashes to treat delimiters as plain text.
14738 * var compiled = _.template('<%= "\\<%- value %\\>" %>');
14739 * compiled({ 'value': 'ignored' });
14740 * // => '<%- value %>'
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>'
14748 * // Use the `sourceURL` option to specify a custom sourceURL for the template.
14749 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
14751 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
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' });
14756 * // => function(data) {
14757 * // var __t, __p = '';
14758 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
14762 * // Use custom template delimiters.
14763 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
14764 * var compiled = _.template('hello {{ user }}!');
14765 * compiled({ 'user': 'mustache' });
14766 * // => 'hello mustache!'
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'), '\
14772 * "main": ' + _.template(mainText).source + '\
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;
14782 if (guard && isIterateeCall(string, options, guard)) {
14783 options = undefined;
14785 string = toString(string);
14786 options = assignInWith({}, options, settings, customDefaultsAssignIn);
14788 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
14789 importsKeys = keys(imports),
14790 importsValues = baseValues(imports, importsKeys);
14795 interpolate = options.interpolate || reNoMatch,
14796 source = "__p += '";
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 + '|$'
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) + ']')
14816 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
14817 interpolateValue || (interpolateValue = esTemplateValue);
14819 // Escape characters that can't be included in string literals.
14820 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
14822 // Replace delimiters with snippets.
14825 source += "' +\n__e(" + escapeValue + ") +\n'";
14827 if (evaluateValue) {
14828 isEvaluating = true;
14829 source += "';\n" + evaluateValue + ";\n__p += '";
14831 if (interpolateValue) {
14832 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
14834 index = offset + match.length;
14836 // The JS engine embedded in Adobe products needs `match` returned in
14837 // order to produce the correct `offset` value.
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;
14849 source = 'with (obj) {\n' + source + '\n}\n';
14851 // Cleanup code by stripping empty strings.
14852 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
14853 .replace(reEmptyStringMiddle, '$1')
14854 .replace(reEmptyStringTrailing, '$1;');
14856 // Frame code as the function body.
14857 source = 'function(' + (variable || 'obj') + ') {\n' +
14860 : 'obj || (obj = {});\n'
14862 "var __t, __p = ''" +
14864 ? ', __e = _.escape'
14868 ? ', __j = Array.prototype.join;\n' +
14869 "function print() { __p += __j.call(arguments, '') }\n"
14875 var result = attempt(function() {
14876 return Function(importsKeys, sourceURL + 'return ' + source)
14877 .apply(undefined, importsValues);
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)) {
14890 * Converts `string`, as a whole, to lower case just like
14891 * [String#toLowerCase](https://mdn.io/toLowerCase).
14897 * @param {string} [string=''] The string to convert.
14898 * @returns {string} Returns the lower cased string.
14901 * _.toLower('--Foo-Bar--');
14902 * // => '--foo-bar--'
14904 * _.toLower('fooBar');
14907 * _.toLower('__FOO_BAR__');
14908 * // => '__foo_bar__'
14910 function toLower(value) {
14911 return toString(value).toLowerCase();
14915 * Converts `string`, as a whole, to upper case just like
14916 * [String#toUpperCase](https://mdn.io/toUpperCase).
14922 * @param {string} [string=''] The string to convert.
14923 * @returns {string} Returns the upper cased string.
14926 * _.toUpper('--foo-bar--');
14927 * // => '--FOO-BAR--'
14929 * _.toUpper('fooBar');
14932 * _.toUpper('__foo_bar__');
14933 * // => '__FOO_BAR__'
14935 function toUpper(value) {
14936 return toString(value).toUpperCase();
14940 * Removes leading and trailing whitespace or specified characters from `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.
14955 * _.trim('-_-abc-_-', '_-');
14958 * _.map([' foo ', ' bar '], _.trim);
14959 * // => ['foo', 'bar']
14961 function trim(string, chars, guard) {
14962 string = toString(string);
14963 if (string && (guard || chars === undefined)) {
14964 return string.replace(reTrim, '');
14966 if (!string || !(chars = baseToString(chars))) {
14969 var strSymbols = stringToArray(string),
14970 chrSymbols = stringToArray(chars),
14971 start = charsStartIndex(strSymbols, chrSymbols),
14972 end = charsEndIndex(strSymbols, chrSymbols) + 1;
14974 return castSlice(strSymbols, start, end).join('');
14978 * Removes trailing whitespace or specified characters from `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.
14990 * _.trimEnd(' abc ');
14993 * _.trimEnd('-_-abc-_-', '_-');
14996 function trimEnd(string, chars, guard) {
14997 string = toString(string);
14998 if (string && (guard || chars === undefined)) {
14999 return string.replace(reTrimEnd, '');
15001 if (!string || !(chars = baseToString(chars))) {
15004 var strSymbols = stringToArray(string),
15005 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
15007 return castSlice(strSymbols, 0, end).join('');
15011 * Removes leading whitespace or specified characters from `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.
15023 * _.trimStart(' abc ');
15026 * _.trimStart('-_-abc-_-', '_-');
15029 function trimStart(string, chars, guard) {
15030 string = toString(string);
15031 if (string && (guard || chars === undefined)) {
15032 return string.replace(reTrimStart, '');
15034 if (!string || !(chars = baseToString(chars))) {
15037 var strSymbols = stringToArray(string),
15038 start = charsStartIndex(strSymbols, stringToArray(chars));
15040 return castSlice(strSymbols, start).join('');
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 "...".
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.
15060 * _.truncate('hi-diddly-ho there, neighborino');
15061 * // => 'hi-diddly-ho there, neighbo...'
15063 * _.truncate('hi-diddly-ho there, neighborino', {
15067 * // => 'hi-diddly-ho there,...'
15069 * _.truncate('hi-diddly-ho there, neighborino', {
15071 * 'separator': /,? +/
15073 * // => 'hi-diddly-ho there...'
15075 * _.truncate('hi-diddly-ho there, neighborino', {
15076 * 'omission': ' [...]'
15078 * // => 'hi-diddly-ho there, neig [...]'
15080 function truncate(string, options) {
15081 var length = DEFAULT_TRUNC_LENGTH,
15082 omission = DEFAULT_TRUNC_OMISSION;
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;
15089 string = toString(string);
15091 var strLength = string.length;
15092 if (hasUnicode(string)) {
15093 var strSymbols = stringToArray(string);
15094 strLength = strSymbols.length;
15096 if (length >= strLength) {
15099 var end = length - stringSize(omission);
15103 var result = strSymbols
15104 ? castSlice(strSymbols, 0, end).join('')
15105 : string.slice(0, end);
15107 if (separator === undefined) {
15108 return result + omission;
15111 end += (result.length - end);
15113 if (isRegExp(separator)) {
15114 if (string.slice(end).search(separator)) {
15116 substring = result;
15118 if (!separator.global) {
15119 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15121 separator.lastIndex = 0;
15122 while ((match = separator.exec(substring))) {
15123 var newEnd = match.index;
15125 result = result.slice(0, newEnd === undefined ? end : newEnd);
15127 } else if (string.indexOf(baseToString(separator), end) != end) {
15128 var index = result.lastIndexOf(separator);
15130 result = result.slice(0, index);
15133 return result + omission;
15137 * The inverse of `_.escape`; this method converts the HTML entities
15138 * `&`, `<`, `>`, `"`, and `'` in `string` to
15139 * their corresponding characters.
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).
15148 * @param {string} [string=''] The string to unescape.
15149 * @returns {string} Returns the unescaped string.
15152 * _.unescape('fred, barney, & pebbles');
15153 * // => 'fred, barney, & pebbles'
15155 function unescape(string) {
15156 string = toString(string);
15157 return (string && reHasEscapedHtml.test(string))
15158 ? string.replace(reEscapedHtml, unescapeHtmlChar)
15163 * Converts `string`, as space separated words, to upper case.
15169 * @param {string} [string=''] The string to convert.
15170 * @returns {string} Returns the upper cased string.
15173 * _.upperCase('--foo-bar');
15176 * _.upperCase('fooBar');
15179 * _.upperCase('__foo_bar__');
15182 var upperCase = createCompounder(function(result, word, index) {
15183 return result + (index ? ' ' : '') + word.toUpperCase();
15187 * Converts the first character of `string` to upper case.
15193 * @param {string} [string=''] The string to convert.
15194 * @returns {string} Returns the converted string.
15197 * _.upperFirst('fred');
15200 * _.upperFirst('FRED');
15203 var upperFirst = createCaseFirst('toUpperCase');
15206 * Splits `string` into an array of its words.
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`.
15218 * _.words('fred, barney, & pebbles');
15219 * // => ['fred', 'barney', 'pebbles']
15221 * _.words('fred, barney, & pebbles', /[^, ]+/g);
15222 * // => ['fred', 'barney', '&', 'pebbles']
15224 function words(string, pattern, guard) {
15225 string = toString(string);
15226 pattern = guard ? undefined : pattern;
15228 if (pattern === undefined) {
15229 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15231 return string.match(pattern) || [];
15234 /*------------------------------------------------------------------------*/
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.
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.
15249 * // Avoid throwing errors for invalid selectors.
15250 * var elements = _.attempt(function(selector) {
15251 * return document.querySelectorAll(selector);
15254 * if (_.isError(elements)) {
15258 var attempt = baseRest(function(func, args) {
15260 return apply(func, undefined, args);
15262 return isError(e) ? e : new Error(e);
15267 * Binds methods of an object to the object itself, overwriting the existing
15270 * **Note:** This method doesn't set the "length" property of bound functions.
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`.
15283 * 'click': function() {
15284 * console.log('clicked ' + this.label);
15288 * _.bindAll(view, ['click']);
15289 * jQuery(element).on('click', view.click);
15290 * // => Logs 'clicked docs' when clicked.
15292 var bindAll = flatRest(function(object, methodNames) {
15293 arrayEach(methodNames, function(key) {
15295 baseAssignValue(object, key, bind(object[key], object));
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
15310 * @param {Array} pairs The predicate-function pairs.
15311 * @returns {Function} Returns the new composite function.
15314 * var func = _.cond([
15315 * [_.matches({ 'a': 1 }), _.constant('matches A')],
15316 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15317 * [_.stubTrue, _.constant('no match')]
15320 * func({ 'a': 1, 'b': 2 });
15321 * // => 'matches A'
15323 * func({ 'a': 0, 'b': 1 });
15324 * // => 'matches B'
15326 * func({ 'a': '1', 'b': '2' });
15329 function cond(pairs) {
15330 var length = pairs == null ? 0 : pairs.length,
15331 toIteratee = getIteratee();
15333 pairs = !length ? [] : arrayMap(pairs, function(pair) {
15334 if (typeof pair[1] != 'function') {
15335 throw new TypeError(FUNC_ERROR_TEXT);
15337 return [toIteratee(pair[0]), pair[1]];
15340 return baseRest(function(args) {
15342 while (++index < length) {
15343 var pair = pairs[index];
15344 if (apply(pair[0], this, args)) {
15345 return apply(pair[1], this, args);
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`.
15356 * **Note:** The created function is equivalent to `_.conformsTo` with
15357 * `source` partially applied.
15363 * @param {Object} source The object of property predicates to conform to.
15364 * @returns {Function} Returns the new spec function.
15368 * { 'a': 2, 'b': 1 },
15369 * { 'a': 1, 'b': 2 }
15372 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15373 * // => [{ 'a': 1, 'b': 2 }]
15375 function conforms(source) {
15376 return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
15380 * Creates a function that returns `value`.
15386 * @param {*} value The value to return from the new function.
15387 * @returns {Function} Returns the new constant function.
15390 * var objects = _.times(2, _.constant({ 'a': 1 }));
15392 * console.log(objects);
15393 * // => [{ 'a': 1 }, { 'a': 1 }]
15395 * console.log(objects[0] === objects[1]);
15398 function constant(value) {
15399 return function() {
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`,
15413 * @param {*} value The value to check.
15414 * @param {*} defaultValue The default value.
15415 * @returns {*} Returns the resolved value.
15418 * _.defaultTo(1, 10);
15421 * _.defaultTo(undefined, 10);
15424 function defaultTo(value, defaultValue) {
15425 return (value == null || value !== value) ? defaultValue : value;
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.
15437 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15438 * @returns {Function} Returns the new composite function.
15442 * function square(n) {
15446 * var addSquare = _.flow([_.add, square]);
15450 var flow = createFlow();
15453 * This method is like `_.flow` except that it creates a function that
15454 * invokes the given functions from right to left.
15460 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15461 * @returns {Function} Returns the new composite function.
15465 * function square(n) {
15469 * var addSquare = _.flowRight([square, _.add]);
15473 var flowRight = createFlow(true);
15476 * This method returns the first argument it receives.
15482 * @param {*} value Any value.
15483 * @returns {*} Returns `value`.
15486 * var object = { 'a': 1 };
15488 * console.log(_.identity(object) === object);
15491 function identity(value) {
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`.
15506 * @param {*} [func=_.identity] The value to convert to a callback.
15507 * @returns {Function} Returns the callback.
15511 * { 'user': 'barney', 'age': 36, 'active': true },
15512 * { 'user': 'fred', 'age': 40, 'active': false }
15515 * // The `_.matches` iteratee shorthand.
15516 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15517 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15519 * // The `_.matchesProperty` iteratee shorthand.
15520 * _.filter(users, _.iteratee(['user', 'fred']));
15521 * // => [{ 'user': 'fred', 'age': 40 }]
15523 * // The `_.property` iteratee shorthand.
15524 * _.map(users, _.iteratee('user'));
15525 * // => ['barney', 'fred']
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);
15534 * _.filter(['abc', 'def'], /ef/);
15537 function iteratee(func) {
15538 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
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`.
15546 * **Note:** The created function is equivalent to `_.isMatch` with `source`
15547 * partially applied.
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.
15557 * @param {Object} source The object of property values to match.
15558 * @returns {Function} Returns the new spec function.
15562 * { 'a': 1, 'b': 2, 'c': 3 },
15563 * { 'a': 4, 'b': 5, 'c': 6 }
15566 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15567 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15569 function matches(source) {
15570 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
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`.
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.
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.
15592 * { 'a': 1, 'b': 2, 'c': 3 },
15593 * { 'a': 4, 'b': 5, 'c': 6 }
15596 * _.find(objects, _.matchesProperty('a', 4));
15597 * // => { 'a': 4, 'b': 5, 'c': 6 }
15599 function matchesProperty(path, srcValue) {
15600 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
15604 * Creates a function that invokes the method at `path` of a given object.
15605 * Any additional arguments are provided to the invoked method.
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.
15617 * { 'a': { 'b': _.constant(2) } },
15618 * { 'a': { 'b': _.constant(1) } }
15621 * _.map(objects, _.method('a.b'));
15624 * _.map(objects, _.method(['a', 'b']));
15627 var method = baseRest(function(path, args) {
15628 return function(object) {
15629 return baseInvoke(object, path, args);
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.
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.
15647 * var array = _.times(3, _.constant),
15648 * object = { 'a': array, 'b': array, 'c': array };
15650 * _.map(['a[2]', 'c[0]'], _.methodOf(object));
15653 * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
15656 var methodOf = baseRest(function(object, args) {
15657 return function(path) {
15658 return baseInvoke(object, path, args);
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.
15667 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
15668 * avoid conflicts caused by modifying the original.
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`.
15681 * function vowels(string) {
15682 * return _.filter(string, function(v) {
15683 * return /[aeiou]/i.test(v);
15687 * _.mixin({ 'vowels': vowels });
15688 * _.vowels('fred');
15691 * _('fred').vowels().value();
15694 * _.mixin({ 'vowels': vowels }, { 'chain': false });
15695 * _('fred').vowels();
15698 function mixin(object, source, options) {
15699 var props = keys(source),
15700 methodNames = baseFunctions(source, props);
15702 if (options == null &&
15703 !(isObject(source) && (methodNames.length || !props.length))) {
15707 methodNames = baseFunctions(source, keys(source));
15709 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
15710 isFunc = isFunction(object);
15712 arrayEach(methodNames, function(methodName) {
15713 var func = source[methodName];
15714 object[methodName] = func;
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__);
15722 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
15723 result.__chain__ = chainAll;
15726 return func.apply(object, arrayPush([this.value()], arguments));
15735 * Reverts the `_` variable to its previous value and returns a reference to
15736 * the `lodash` function.
15742 * @returns {Function} Returns the `lodash` function.
15745 * var lodash = _.noConflict();
15747 function noConflict() {
15748 if (root._ === this) {
15755 * This method returns `undefined`.
15763 * _.times(2, _.noop);
15764 * // => [undefined, undefined]
15767 // No operation performed.
15771 * Creates a function that gets the argument at index `n`. If `n` is negative,
15772 * the nth argument from the end is returned.
15778 * @param {number} [n=0] The index of the argument to return.
15779 * @returns {Function} Returns the new pass-thru function.
15782 * var func = _.nthArg(1);
15783 * func('a', 'b', 'c', 'd');
15786 * var func = _.nthArg(-2);
15787 * func('a', 'b', 'c', 'd');
15790 function nthArg(n) {
15792 return baseRest(function(args) {
15793 return baseNth(args, n);
15798 * Creates a function that invokes `iteratees` with the arguments it receives
15799 * and returns their results.
15805 * @param {...(Function|Function[])} [iteratees=[_.identity]]
15806 * The iteratees to invoke.
15807 * @returns {Function} Returns the new function.
15810 * var func = _.over([Math.max, Math.min]);
15812 * func(1, 2, 3, 4);
15815 var over = createOver(arrayMap);
15818 * Creates a function that checks if **all** of the `predicates` return
15819 * truthy when invoked with the arguments it receives.
15825 * @param {...(Function|Function[])} [predicates=[_.identity]]
15826 * The predicates to check.
15827 * @returns {Function} Returns the new function.
15830 * var func = _.overEvery([Boolean, isFinite]);
15841 var overEvery = createOver(arrayEvery);
15844 * Creates a function that checks if **any** of the `predicates` return
15845 * truthy when invoked with the arguments it receives.
15851 * @param {...(Function|Function[])} [predicates=[_.identity]]
15852 * The predicates to check.
15853 * @returns {Function} Returns the new function.
15856 * var func = _.overSome([Boolean, isFinite]);
15867 var overSome = createOver(arraySome);
15870 * Creates a function that returns the value at `path` of a given object.
15876 * @param {Array|string} path The path of the property to get.
15877 * @returns {Function} Returns the new accessor function.
15881 * { 'a': { 'b': 2 } },
15882 * { 'a': { 'b': 1 } }
15885 * _.map(objects, _.property('a.b'));
15888 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
15891 function property(path) {
15892 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
15896 * The opposite of `_.property`; this method creates a function that returns
15897 * the value at a given path of `object`.
15903 * @param {Object} object The object to query.
15904 * @returns {Function} Returns the new accessor function.
15907 * var array = [0, 1, 2],
15908 * object = { 'a': array, 'b': array, 'c': array };
15910 * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
15913 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
15916 function propertyOf(object) {
15917 return function(path) {
15918 return object == null ? undefined : baseGet(object, path);
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`.
15928 * **Note:** JavaScript follows the IEEE-754 standard for resolving
15929 * floating-point values which can produce unexpected results.
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
15943 * // => [0, 1, 2, 3]
15946 * // => [0, -1, -2, -3]
15949 * // => [1, 2, 3, 4]
15951 * _.range(0, 20, 5);
15952 * // => [0, 5, 10, 15]
15954 * _.range(0, -4, -1);
15955 * // => [0, -1, -2, -3]
15957 * _.range(1, 4, 0);
15963 var range = createRange();
15966 * This method is like `_.range` except that it populates values in
15967 * descending order.
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
15981 * // => [3, 2, 1, 0]
15983 * _.rangeRight(-4);
15984 * // => [-3, -2, -1, 0]
15986 * _.rangeRight(1, 5);
15987 * // => [4, 3, 2, 1]
15989 * _.rangeRight(0, 20, 5);
15990 * // => [15, 10, 5, 0]
15992 * _.rangeRight(0, -4, -1);
15993 * // => [-3, -2, -1, 0]
15995 * _.rangeRight(1, 4, 0);
16001 var rangeRight = createRange(true);
16004 * This method returns a new empty array.
16010 * @returns {Array} Returns the new empty array.
16013 * var arrays = _.times(2, _.stubArray);
16015 * console.log(arrays);
16018 * console.log(arrays[0] === arrays[1]);
16021 function stubArray() {
16026 * This method returns `false`.
16032 * @returns {boolean} Returns `false`.
16035 * _.times(2, _.stubFalse);
16036 * // => [false, false]
16038 function stubFalse() {
16043 * This method returns a new empty object.
16049 * @returns {Object} Returns the new empty object.
16052 * var objects = _.times(2, _.stubObject);
16054 * console.log(objects);
16057 * console.log(objects[0] === objects[1]);
16060 function stubObject() {
16065 * This method returns an empty string.
16071 * @returns {string} Returns the empty string.
16074 * _.times(2, _.stubString);
16077 function stubString() {
16082 * This method returns `true`.
16088 * @returns {boolean} Returns `true`.
16091 * _.times(2, _.stubTrue);
16092 * // => [true, true]
16094 function stubTrue() {
16099 * Invokes the iteratee `n` times, returning an array of the results of
16100 * each invocation. The iteratee is invoked with one argument; (index).
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.
16111 * _.times(3, String);
16112 * // => ['0', '1', '2']
16114 * _.times(4, _.constant(0));
16115 * // => [0, 0, 0, 0]
16117 function times(n, iteratee) {
16119 if (n < 1 || n > MAX_SAFE_INTEGER) {
16122 var index = MAX_ARRAY_LENGTH,
16123 length = nativeMin(n, MAX_ARRAY_LENGTH);
16125 iteratee = getIteratee(iteratee);
16126 n -= MAX_ARRAY_LENGTH;
16128 var result = baseTimes(length, iteratee);
16129 while (++index < n) {
16136 * Converts `value` to a property path array.
16142 * @param {*} value The value to convert.
16143 * @returns {Array} Returns the new property path array.
16146 * _.toPath('a.b.c');
16147 * // => ['a', 'b', 'c']
16149 * _.toPath('a[0].b.c');
16150 * // => ['a', '0', 'b', 'c']
16152 function toPath(value) {
16153 if (isArray(value)) {
16154 return arrayMap(value, toKey);
16156 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
16160 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16166 * @param {string} [prefix=''] The value to prefix the ID with.
16167 * @returns {string} Returns the unique ID.
16170 * _.uniqueId('contact_');
16171 * // => 'contact_104'
16176 function uniqueId(prefix) {
16177 var id = ++idCounter;
16178 return toString(prefix) + id;
16181 /*------------------------------------------------------------------------*/
16184 * Adds two numbers.
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.
16198 var add = createMathOperation(function(augend, addend) {
16199 return augend + addend;
16203 * Computes `number` rounded up to `precision`.
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.
16217 * _.ceil(6.004, 2);
16220 * _.ceil(6040, -2);
16223 var ceil = createRound('ceil');
16226 * Divide two numbers.
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.
16240 var divide = createMathOperation(function(dividend, divisor) {
16241 return dividend / divisor;
16245 * Computes `number` rounded down to `precision`.
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.
16259 * _.floor(0.046, 2);
16262 * _.floor(4060, -2);
16265 var floor = createRound('floor');
16268 * Computes the maximum value of `array`. If `array` is empty or falsey,
16269 * `undefined` is returned.
16275 * @param {Array} array The array to iterate over.
16276 * @returns {*} Returns the maximum value.
16279 * _.max([4, 2, 8, 6]);
16285 function max(array) {
16286 return (array && array.length)
16287 ? baseExtremum(array, identity, baseGt)
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).
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.
16305 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16307 * _.maxBy(objects, function(o) { return o.n; });
16310 * // The `_.property` iteratee shorthand.
16311 * _.maxBy(objects, 'n');
16314 function maxBy(array, iteratee) {
16315 return (array && array.length)
16316 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
16321 * Computes the mean of the values in `array`.
16327 * @param {Array} array The array to iterate over.
16328 * @returns {number} Returns the mean.
16331 * _.mean([4, 2, 8, 6]);
16334 function mean(array) {
16335 return baseMean(array, identity);
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).
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.
16352 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16354 * _.meanBy(objects, function(o) { return o.n; });
16357 * // The `_.property` iteratee shorthand.
16358 * _.meanBy(objects, 'n');
16361 function meanBy(array, iteratee) {
16362 return baseMean(array, getIteratee(iteratee, 2));
16366 * Computes the minimum value of `array`. If `array` is empty or falsey,
16367 * `undefined` is returned.
16373 * @param {Array} array The array to iterate over.
16374 * @returns {*} Returns the minimum value.
16377 * _.min([4, 2, 8, 6]);
16383 function min(array) {
16384 return (array && array.length)
16385 ? baseExtremum(array, identity, baseLt)
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).
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.
16403 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16405 * _.minBy(objects, function(o) { return o.n; });
16408 * // The `_.property` iteratee shorthand.
16409 * _.minBy(objects, 'n');
16412 function minBy(array, iteratee) {
16413 return (array && array.length)
16414 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
16419 * Multiply two numbers.
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.
16430 * _.multiply(6, 4);
16433 var multiply = createMathOperation(function(multiplier, multiplicand) {
16434 return multiplier * multiplicand;
16438 * Computes `number` rounded to `precision`.
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.
16452 * _.round(4.006, 2);
16455 * _.round(4060, -2);
16458 var round = createRound('round');
16461 * Subtract two numbers.
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.
16472 * _.subtract(6, 4);
16475 var subtract = createMathOperation(function(minuend, subtrahend) {
16476 return minuend - subtrahend;
16480 * Computes the sum of the values in `array`.
16486 * @param {Array} array The array to iterate over.
16487 * @returns {number} Returns the sum.
16490 * _.sum([4, 2, 8, 6]);
16493 function sum(array) {
16494 return (array && array.length)
16495 ? baseSum(array, identity)
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).
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.
16513 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16515 * _.sumBy(objects, function(o) { return o.n; });
16518 * // The `_.property` iteratee shorthand.
16519 * _.sumBy(objects, 'n');
16522 function sumBy(array, iteratee) {
16523 return (array && array.length)
16524 ? baseSum(array, getIteratee(iteratee, 2))
16528 /*------------------------------------------------------------------------*/
16530 // Add methods that return wrapped values in chain sequences.
16531 lodash.after = after;
16533 lodash.assign = assign;
16534 lodash.assignIn = assignIn;
16535 lodash.assignInWith = assignInWith;
16536 lodash.assignWith = assignWith;
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;
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;
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;
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;
16674 lodash.xorBy = xorBy;
16675 lodash.xorWith = xorWith;
16677 lodash.zipObject = zipObject;
16678 lodash.zipObjectDeep = zipObjectDeep;
16679 lodash.zipWith = zipWith;
16682 lodash.entries = toPairs;
16683 lodash.entriesIn = toPairsIn;
16684 lodash.extend = assignIn;
16685 lodash.extendWith = assignInWith;
16687 // Add methods to `lodash.prototype`.
16688 mixin(lodash, lodash);
16690 /*------------------------------------------------------------------------*/
16692 // Add methods that return unwrapped values in chain sequences.
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;
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;
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;
16782 lodash.maxBy = maxBy;
16783 lodash.mean = mean;
16784 lodash.meanBy = meanBy;
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;
16794 lodash.noConflict = noConflict;
16795 lodash.noop = noop;
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;
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;
16844 lodash.each = forEach;
16845 lodash.eachRight = forEachRight;
16846 lodash.first = head;
16848 mixin(lodash, (function() {
16850 baseForOwn(lodash, function(func, methodName) {
16851 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
16852 source[methodName] = func;
16856 }()), { 'chain': false });
16858 /*------------------------------------------------------------------------*/
16861 * The semantic version number.
16867 lodash.VERSION = VERSION;
16869 // Assign default placeholders.
16870 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
16871 lodash[methodName].placeholder = lodash;
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);
16879 var result = (this.__filtered__ && !index)
16880 ? new LazyWrapper(this)
16883 if (result.__filtered__) {
16884 result.__takeCount__ = nativeMin(n, result.__takeCount__);
16886 result.__views__.push({
16887 'size': nativeMin(n, MAX_ARRAY_LENGTH),
16888 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
16894 LazyWrapper.prototype[methodName + 'Right'] = function(n) {
16895 return this.reverse()[methodName](n).reverse();
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;
16904 LazyWrapper.prototype[methodName] = function(iteratee) {
16905 var result = this.clone();
16906 result.__iteratees__.push({
16907 'iteratee': getIteratee(iteratee, 3),
16910 result.__filtered__ = result.__filtered__ || isFilter;
16915 // Add `LazyWrapper` methods for `_.head` and `_.last`.
16916 arrayEach(['head', 'last'], function(methodName, index) {
16917 var takeName = 'take' + (index ? 'Right' : '');
16919 LazyWrapper.prototype[methodName] = function() {
16920 return this[takeName](1).value()[0];
16924 // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
16925 arrayEach(['initial', 'tail'], function(methodName, index) {
16926 var dropName = 'drop' + (index ? '' : 'Right');
16928 LazyWrapper.prototype[methodName] = function() {
16929 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
16933 LazyWrapper.prototype.compact = function() {
16934 return this.filter(identity);
16937 LazyWrapper.prototype.find = function(predicate) {
16938 return this.filter(predicate).head();
16941 LazyWrapper.prototype.findLast = function(predicate) {
16942 return this.reverse().find(predicate);
16945 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
16946 if (typeof path == 'function') {
16947 return new LazyWrapper(this);
16949 return this.map(function(value) {
16950 return baseInvoke(value, path, args);
16954 LazyWrapper.prototype.reject = function(predicate) {
16955 return this.filter(negate(getIteratee(predicate)));
16958 LazyWrapper.prototype.slice = function(start, end) {
16959 start = toInteger(start);
16962 if (result.__filtered__ && (start > 0 || end < 0)) {
16963 return new LazyWrapper(result);
16966 result = result.takeRight(-start);
16967 } else if (start) {
16968 result = result.drop(start);
16970 if (end !== undefined) {
16971 end = toInteger(end);
16972 result = end < 0 ? result.dropRight(-end) : result.take(end - start);
16977 LazyWrapper.prototype.takeRightWhile = function(predicate) {
16978 return this.reverse().takeWhile(predicate).reverse();
16981 LazyWrapper.prototype.toArray = function() {
16982 return this.take(MAX_ARRAY_LENGTH);
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);
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);
17002 var interceptor = function(value) {
17003 var result = lodashFunc.apply(lodash, arrayPush([value], args));
17004 return (isTaker && chainAll) ? result[0] : result;
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;
17011 var chainAll = this.__chain__,
17012 isHybrid = !!this.__actions__.length,
17013 isUnwrapped = retUnwrapped && !chainAll,
17014 onlyLazy = isLazy && !isHybrid;
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);
17022 if (isUnwrapped && onlyLazy) {
17023 return func.apply(this, args);
17025 result = this.thru(interceptor);
17026 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
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);
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);
17042 return this[chainName](function(value) {
17043 return func.apply(isArray(value) ? value : [], args);
17048 // Map minified method names to their real names.
17049 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17050 var lodashFunc = lodash[methodName];
17052 var key = lodashFunc.name + '';
17053 if (!hasOwnProperty.call(realNames, key)) {
17054 realNames[key] = [];
17056 realNames[key].push({ 'name': methodName, 'func': lodashFunc });
17060 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
17065 // Add methods to `LazyWrapper`.
17066 LazyWrapper.prototype.clone = lazyClone;
17067 LazyWrapper.prototype.reverse = lazyReverse;
17068 LazyWrapper.prototype.value = lazyValue;
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;
17079 // Add lazy aliases.
17080 lodash.prototype.first = lodash.prototype.head;
17083 lodash.prototype[symIterator] = wrapperToIterator;
17088 /*--------------------------------------------------------------------------*/
17091 var _ = runInContext();
17093 // Some AMD build optimizers, like r.js, check for condition patterns like:
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.
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() {
17105 }).call(exports, __webpack_require__, exports, module),
17106 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
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.
17116 // Export to the global object.
17121 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(128)(module)))
17126 /***/ (function(module, exports, __webpack_require__) {
17131 exports.__esModule = true;
17133 var _assign = __webpack_require__(69);
17135 var _assign2 = _interopRequireDefault(_assign);
17137 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17139 exports.default = _assign2.default || function (target) {
17140 for (var i = 1; i < arguments.length; i++) {
17141 var source = arguments[i];
17143 for (var key in source) {
17144 if (Object.prototype.hasOwnProperty.call(source, key)) {
17145 target[key] = source[key];
17156 /***/ (function(module, __webpack_exports__, __webpack_require__) {
17159 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
17160 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_assetList_vue__ = __webpack_require__(595);
17161 /* empty harmony namespace reexport */
17162 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_9beabd34_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_assetList_vue__ = __webpack_require__(629);
17163 function injectStyle (ssrContext) {
17164 __webpack_require__(627)
17166 var normalizeComponent = __webpack_require__(266)
17172 /* template functional */
17173 var __vue_template_functional__ = false
17175 var __vue_styles__ = injectStyle
17177 var __vue_scopeId__ = "data-v-9beabd34"
17178 /* moduleIdentifier (server only) */
17179 var __vue_module_identifier__ = null
17180 var Component = normalizeComponent(
17181 __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_assetList_vue__["a" /* default */],
17182 __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_9beabd34_hasScoped_true_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_assetList_vue__["a" /* default */],
17183 __vue_template_functional__,
17186 __vue_module_identifier__
17189 /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
17195 /***/ (function(module, exports, __webpack_require__) {
17197 var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalObject) {
\r
17201 * bignumber.js v9.0.0
\r
17202 * A JavaScript library for arbitrary-precision arithmetic.
\r
17203 * https://github.com/MikeMcl/bignumber.js
\r
17204 * Copyright (c) 2019 Michael Mclaughlin <M8ch88l@gmail.com>
\r
17207 * BigNumber.prototype methods | BigNumber methods
\r
17209 * absoluteValue abs | clone
\r
17210 * comparedTo | config set
\r
17211 * decimalPlaces dp | DECIMAL_PLACES
\r
17212 * dividedBy div | ROUNDING_MODE
\r
17213 * dividedToIntegerBy idiv | EXPONENTIAL_AT
\r
17214 * exponentiatedBy pow | RANGE
\r
17215 * integerValue | CRYPTO
\r
17216 * isEqualTo eq | MODULO_MODE
\r
17217 * isFinite | POW_PRECISION
\r
17218 * isGreaterThan gt | FORMAT
\r
17219 * isGreaterThanOrEqualTo gte | ALPHABET
\r
17220 * isInteger | isBigNumber
\r
17221 * isLessThan lt | maximum max
\r
17222 * isLessThanOrEqualTo lte | minimum min
\r
17224 * isNegative | sum
\r
17229 * multipliedBy times |
\r
17234 * squareRoot sqrt |
\r
17235 * toExponential |
\r
17249 isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
\r
17250 mathceil = Math.ceil,
\r
17251 mathfloor = Math.floor,
\r
17253 bignumberError = '[BigNumber Error] ',
\r
17254 tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
\r
17258 MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
\r
17259 // MAX_INT32 = 0x7fffffff, // 2^31 - 1
\r
17260 POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
\r
17264 // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
\r
17265 // the arguments to toExponential, toFixed, toFormat, and toPrecision.
\r
17266 MAX = 1E9; // 0 to MAX_INT32
\r
17270 * Create and return a BigNumber constructor.
\r
17272 function clone(configObject) {
\r
17273 var div, convertBase, parseNumeric,
\r
17274 P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
\r
17275 ONE = new BigNumber(1),
\r
17278 //----------------------------- EDITABLE CONFIG DEFAULTS -------------------------------
\r
17281 // The default values below must be integers within the inclusive ranges stated.
\r
17282 // The values can also be changed at run-time using BigNumber.set.
\r
17284 // The maximum number of decimal places for operations involving division.
\r
17285 DECIMAL_PLACES = 20, // 0 to MAX
\r
17287 // The rounding mode used when rounding to the above decimal places, and when using
\r
17288 // toExponential, toFixed, toFormat and toPrecision, and round (default value).
\r
17289 // UP 0 Away from zero.
\r
17290 // DOWN 1 Towards zero.
\r
17291 // CEIL 2 Towards +Infinity.
\r
17292 // FLOOR 3 Towards -Infinity.
\r
17293 // HALF_UP 4 Towards nearest neighbour. If equidistant, up.
\r
17294 // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
\r
17295 // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
\r
17296 // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
\r
17297 // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
\r
17298 ROUNDING_MODE = 4, // 0 to 8
\r
17300 // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
\r
17302 // The exponent value at and beneath which toString returns exponential notation.
\r
17303 // Number type: -7
\r
17304 TO_EXP_NEG = -7, // 0 to -MAX
\r
17306 // The exponent value at and above which toString returns exponential notation.
\r
17307 // Number type: 21
\r
17308 TO_EXP_POS = 21, // 0 to MAX
\r
17310 // RANGE : [MIN_EXP, MAX_EXP]
\r
17312 // The minimum exponent value, beneath which underflow to zero occurs.
\r
17313 // Number type: -324 (5e-324)
\r
17314 MIN_EXP = -1e7, // -1 to -MAX
\r
17316 // The maximum exponent value, above which overflow to Infinity occurs.
\r
17317 // Number type: 308 (1.7976931348623157e+308)
\r
17318 // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
\r
17319 MAX_EXP = 1e7, // 1 to MAX
\r
17321 // Whether to use cryptographically-secure random number generation, if available.
\r
17322 CRYPTO = false, // true or false
\r
17324 // The modulo mode used when calculating the modulus: a mod n.
\r
17325 // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
\r
17326 // The remainder (r) is calculated as: r = a - n * q.
\r
17328 // UP 0 The remainder is positive if the dividend is negative, else is negative.
\r
17329 // DOWN 1 The remainder has the same sign as the dividend.
\r
17330 // This modulo mode is commonly known as 'truncated division' and is
\r
17331 // equivalent to (a % n) in JavaScript.
\r
17332 // FLOOR 3 The remainder has the same sign as the divisor (Python %).
\r
17333 // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
\r
17334 // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
\r
17335 // The remainder is always positive.
\r
17337 // The truncated division, floored division, Euclidian division and IEEE 754 remainder
\r
17338 // modes are commonly used for the modulus operation.
\r
17339 // Although the other rounding modes can also be used, they may not give useful results.
\r
17340 MODULO_MODE = 1, // 0 to 9
\r
17342 // The maximum number of significant digits of the result of the exponentiatedBy operation.
\r
17343 // If POW_PRECISION is 0, there will be unlimited significant digits.
\r
17344 POW_PRECISION = 0, // 0 to MAX
\r
17346 // The format specification used by the BigNumber.prototype.toFormat method.
\r
17350 secondaryGroupSize: 0,
\r
17351 groupSeparator: ',',
\r
17352 decimalSeparator: '.',
\r
17353 fractionGroupSize: 0,
\r
17354 fractionGroupSeparator: '\xA0', // non-breaking space
\r
17358 // The alphabet used for base conversion. It must be at least 2 characters long, with no '+',
\r
17359 // '-', '.', whitespace, or repeated character.
\r
17360 // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
\r
17361 ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
\r
17364 //------------------------------------------------------------------------------------------
\r
17371 * The BigNumber constructor and exported function.
\r
17372 * Create and return a new instance of a BigNumber object.
\r
17374 * v {number|string|BigNumber} A numeric value.
\r
17375 * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
\r
17377 function BigNumber(v, b) {
\r
17378 var alphabet, c, caseChanged, e, i, isNum, len, str,
\r
17381 // Enable constructor call without `new`.
\r
17382 if (!(x instanceof BigNumber)) return new BigNumber(v, b);
\r
17386 if (v && v._isBigNumber === true) {
\r
17389 if (!v.c || v.e > MAX_EXP) {
\r
17390 x.c = x.e = null;
\r
17391 } else if (v.e < MIN_EXP) {
\r
17395 x.c = v.c.slice();
\r
17401 if ((isNum = typeof v == 'number') && v * 0 == 0) {
\r
17403 // Use `1 / n` to handle minus zero also.
\r
17404 x.s = 1 / v < 0 ? (v = -v, -1) : 1;
\r
17406 // Fast path for integers, where n < 2147483648 (2**31).
\r
17408 for (e = 0, i = v; i >= 10; i /= 10, e++);
\r
17410 if (e > MAX_EXP) {
\r
17411 x.c = x.e = null;
\r
17423 if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
\r
17425 x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
\r
17428 // Decimal point?
\r
17429 if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
\r
17431 // Exponential form?
\r
17432 if ((i = str.search(/e/i)) > 0) {
\r
17434 // Determine exponent.
\r
17435 if (e < 0) e = i;
\r
17436 e += +str.slice(i + 1);
\r
17437 str = str.substring(0, i);
\r
17438 } else if (e < 0) {
\r
17446 // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
\r
17447 intCheck(b, 2, ALPHABET.length, 'Base');
\r
17449 // Allow exponential notation to be used with base 10 argument, while
\r
17450 // also rounding to DECIMAL_PLACES as with other bases.
\r
17452 x = new BigNumber(v);
\r
17453 return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
\r
17458 if (isNum = typeof v == 'number') {
\r
17460 // Avoid potential interpretation of Infinity and NaN as base 44+ values.
\r
17461 if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
\r
17463 x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
\r
17465 // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
\r
17466 if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {
\r
17468 (tooManyDigits + v);
\r
17471 x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
\r
17474 alphabet = ALPHABET.slice(0, b);
\r
17477 // Check that str is a valid base b number.
\r
17478 // Don't use RegExp, so alphabet can contain special characters.
\r
17479 for (len = str.length; i < len; i++) {
\r
17480 if (alphabet.indexOf(c = str.charAt(i)) < 0) {
\r
17483 // If '.' is not the first character and it has not be found before.
\r
17488 } else if (!caseChanged) {
\r
17490 // Allow e.g. hexadecimal 'FF' as well as 'ff'.
\r
17491 if (str == str.toUpperCase() && (str = str.toLowerCase()) ||
\r
17492 str == str.toLowerCase() && (str = str.toUpperCase())) {
\r
17493 caseChanged = true;
\r
17500 return parseNumeric(x, String(v), isNum, b);
\r
17504 // Prevent later check for length on converted number.
\r
17506 str = convertBase(str, b, 10, x.s);
\r
17508 // Decimal point?
\r
17509 if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
\r
17510 else e = str.length;
\r
17513 // Determine leading zeros.
\r
17514 for (i = 0; str.charCodeAt(i) === 48; i++);
\r
17516 // Determine trailing zeros.
\r
17517 for (len = str.length; str.charCodeAt(--len) === 48;);
\r
17519 if (str = str.slice(i, ++len)) {
\r
17522 // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
\r
17523 if (isNum && BigNumber.DEBUG &&
\r
17524 len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
\r
17526 (tooManyDigits + (x.s * v));
\r
17530 if ((e = e - i - 1) > MAX_EXP) {
\r
17533 x.c = x.e = null;
\r
17536 } else if (e < MIN_EXP) {
\r
17544 // Transform base
\r
17546 // e is the base 10 exponent.
\r
17547 // i is where to slice str to get the first element of the coefficient array.
\r
17548 i = (e + 1) % LOG_BASE;
\r
17549 if (e < 0) i += LOG_BASE; // i < 1
\r
17552 if (i) x.c.push(+str.slice(0, i));
\r
17554 for (len -= LOG_BASE; i < len;) {
\r
17555 x.c.push(+str.slice(i, i += LOG_BASE));
\r
17558 i = LOG_BASE - (str = str.slice(i)).length;
\r
17563 for (; i--; str += '0');
\r
17574 // CONSTRUCTOR PROPERTIES
\r
17577 BigNumber.clone = clone;
\r
17579 BigNumber.ROUND_UP = 0;
\r
17580 BigNumber.ROUND_DOWN = 1;
\r
17581 BigNumber.ROUND_CEIL = 2;
\r
17582 BigNumber.ROUND_FLOOR = 3;
\r
17583 BigNumber.ROUND_HALF_UP = 4;
\r
17584 BigNumber.ROUND_HALF_DOWN = 5;
\r
17585 BigNumber.ROUND_HALF_EVEN = 6;
\r
17586 BigNumber.ROUND_HALF_CEIL = 7;
\r
17587 BigNumber.ROUND_HALF_FLOOR = 8;
\r
17588 BigNumber.EUCLID = 9;
\r
17592 * Configure infrequently-changing library-wide settings.
\r
17594 * Accept an object with the following optional properties (if the value of a property is
\r
17595 * a number, it must be an integer within the inclusive range stated):
\r
17597 * DECIMAL_PLACES {number} 0 to MAX
\r
17598 * ROUNDING_MODE {number} 0 to 8
\r
17599 * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX]
\r
17600 * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX]
\r
17601 * CRYPTO {boolean} true or false
\r
17602 * MODULO_MODE {number} 0 to 9
\r
17603 * POW_PRECISION {number} 0 to MAX
\r
17604 * ALPHABET {string} A string of two or more unique characters which does
\r
17605 * not contain '.'.
\r
17606 * FORMAT {object} An object with some of the following properties:
\r
17607 * prefix {string}
\r
17608 * groupSize {number}
\r
17609 * secondaryGroupSize {number}
\r
17610 * groupSeparator {string}
\r
17611 * decimalSeparator {string}
\r
17612 * fractionGroupSize {number}
\r
17613 * fractionGroupSeparator {string}
\r
17614 * suffix {string}
\r
17616 * (The values assigned to the above FORMAT object properties are not checked for validity.)
\r
17619 * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
\r
17621 * Ignore properties/parameters set to null or undefined, except for ALPHABET.
\r
17623 * Return an object with the properties current values.
\r
17625 BigNumber.config = BigNumber.set = function (obj) {
\r
17628 if (obj != null) {
\r
17630 if (typeof obj == 'object') {
\r
17632 // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
\r
17633 // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}'
\r
17634 if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) {
\r
17636 intCheck(v, 0, MAX, p);
\r
17637 DECIMAL_PLACES = v;
\r
17640 // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
\r
17641 // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}'
\r
17642 if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) {
\r
17644 intCheck(v, 0, 8, p);
\r
17645 ROUNDING_MODE = v;
\r
17648 // EXPONENTIAL_AT {number|number[]}
\r
17649 // Integer, -MAX to MAX inclusive or
\r
17650 // [integer -MAX to 0 inclusive, 0 to MAX inclusive].
\r
17651 // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}'
\r
17652 if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) {
\r
17654 if (v && v.pop) {
\r
17655 intCheck(v[0], -MAX, 0, p);
\r
17656 intCheck(v[1], 0, MAX, p);
\r
17657 TO_EXP_NEG = v[0];
\r
17658 TO_EXP_POS = v[1];
\r
17660 intCheck(v, -MAX, MAX, p);
\r
17661 TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
\r
17665 // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
\r
17666 // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
\r
17667 // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}'
\r
17668 if (obj.hasOwnProperty(p = 'RANGE')) {
\r
17670 if (v && v.pop) {
\r
17671 intCheck(v[0], -MAX, -1, p);
\r
17672 intCheck(v[1], 1, MAX, p);
\r
17676 intCheck(v, -MAX, MAX, p);
\r
17678 MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
\r
17681 (bignumberError + p + ' cannot be zero: ' + v);
\r
17686 // CRYPTO {boolean} true or false.
\r
17687 // '[BigNumber Error] CRYPTO not true or false: {v}'
\r
17688 // '[BigNumber Error] crypto unavailable'
\r
17689 if (obj.hasOwnProperty(p = 'CRYPTO')) {
\r
17693 if (typeof crypto != 'undefined' && crypto &&
\r
17694 (crypto.getRandomValues || crypto.randomBytes)) {
\r
17699 (bignumberError + 'crypto unavailable');
\r
17706 (bignumberError + p + ' not true or false: ' + v);
\r
17710 // MODULO_MODE {number} Integer, 0 to 9 inclusive.
\r
17711 // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}'
\r
17712 if (obj.hasOwnProperty(p = 'MODULO_MODE')) {
\r
17714 intCheck(v, 0, 9, p);
\r
17718 // POW_PRECISION {number} Integer, 0 to MAX inclusive.
\r
17719 // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}'
\r
17720 if (obj.hasOwnProperty(p = 'POW_PRECISION')) {
\r
17722 intCheck(v, 0, MAX, p);
\r
17723 POW_PRECISION = v;
\r
17726 // FORMAT {object}
\r
17727 // '[BigNumber Error] FORMAT not an object: {v}'
\r
17728 if (obj.hasOwnProperty(p = 'FORMAT')) {
\r
17730 if (typeof v == 'object') FORMAT = v;
\r
17732 (bignumberError + p + ' not an object: ' + v);
\r
17735 // ALPHABET {string}
\r
17736 // '[BigNumber Error] ALPHABET invalid: {v}'
\r
17737 if (obj.hasOwnProperty(p = 'ALPHABET')) {
\r
17740 // Disallow if only one character,
\r
17741 // or if it contains '+', '-', '.', whitespace, or a repeated character.
\r
17742 if (typeof v == 'string' && !/^.$|[+-.\s]|(.).*\1/.test(v)) {
\r
17746 (bignumberError + p + ' invalid: ' + v);
\r
17752 // '[BigNumber Error] Object expected: {v}'
\r
17754 (bignumberError + 'Object expected: ' + obj);
\r
17759 DECIMAL_PLACES: DECIMAL_PLACES,
\r
17760 ROUNDING_MODE: ROUNDING_MODE,
\r
17761 EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
\r
17762 RANGE: [MIN_EXP, MAX_EXP],
\r
17764 MODULO_MODE: MODULO_MODE,
\r
17765 POW_PRECISION: POW_PRECISION,
\r
17767 ALPHABET: ALPHABET
\r
17773 * Return true if v is a BigNumber instance, otherwise return false.
\r
17775 * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
\r
17779 * '[BigNumber Error] Invalid BigNumber: {v}'
\r
17781 BigNumber.isBigNumber = function (v) {
\r
17782 if (!v || v._isBigNumber !== true) return false;
\r
17783 if (!BigNumber.DEBUG) return true;
\r
17790 out: if ({}.toString.call(c) == '[object Array]') {
\r
17792 if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
\r
17794 // If the first element is zero, the BigNumber value must be zero.
\r
17795 if (c[0] === 0) {
\r
17796 if (e === 0 && c.length === 1) return true;
\r
17800 // Calculate number of digits that c[0] should have, based on the exponent.
\r
17801 i = (e + 1) % LOG_BASE;
\r
17802 if (i < 1) i += LOG_BASE;
\r
17804 // Calculate number of digits of c[0].
\r
17805 //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {
\r
17806 if (String(c[0]).length == i) {
\r
17808 for (i = 0; i < c.length; i++) {
\r
17810 if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
\r
17813 // Last element cannot be zero, unless it is the only element.
\r
17814 if (n !== 0) return true;
\r
17819 } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
\r
17824 (bignumberError + 'Invalid BigNumber: ' + v);
\r
17829 * Return a new BigNumber whose value is the maximum of the arguments.
\r
17831 * arguments {number|string|BigNumber}
\r
17833 BigNumber.maximum = BigNumber.max = function () {
\r
17834 return maxOrMin(arguments, P.lt);
\r
17839 * Return a new BigNumber whose value is the minimum of the arguments.
\r
17841 * arguments {number|string|BigNumber}
\r
17843 BigNumber.minimum = BigNumber.min = function () {
\r
17844 return maxOrMin(arguments, P.gt);
\r
17849 * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
\r
17850 * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
\r
17851 * zeros are produced).
\r
17853 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
17855 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}'
\r
17856 * '[BigNumber Error] crypto unavailable'
\r
17858 BigNumber.random = (function () {
\r
17859 var pow2_53 = 0x20000000000000;
\r
17861 // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
\r
17862 // Check if Math.random() produces more than 32 bits of randomness.
\r
17863 // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
\r
17864 // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
\r
17865 var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
\r
17866 ? function () { return mathfloor(Math.random() * pow2_53); }
\r
17867 : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
\r
17868 (Math.random() * 0x800000 | 0); };
\r
17870 return function (dp) {
\r
17871 var a, b, e, k, v,
\r
17874 rand = new BigNumber(ONE);
\r
17876 if (dp == null) dp = DECIMAL_PLACES;
\r
17877 else intCheck(dp, 0, MAX);
\r
17879 k = mathceil(dp / LOG_BASE);
\r
17883 // Browsers supporting crypto.getRandomValues.
\r
17884 if (crypto.getRandomValues) {
\r
17886 a = crypto.getRandomValues(new Uint32Array(k *= 2));
\r
17891 // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
\r
17892 // 11111 11111111 11111111 11111111 11100000 00000000 00000000
\r
17893 // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
\r
17894 // 11111 11111111 11111111
\r
17895 // 0x20000 is 2^21.
\r
17896 v = a[i] * 0x20000 + (a[i + 1] >>> 11);
\r
17898 // Rejection sampling:
\r
17899 // 0 <= v < 9007199254740992
\r
17900 // Probability that v >= 9e15, is
\r
17901 // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
\r
17903 b = crypto.getRandomValues(new Uint32Array(2));
\r
17908 // 0 <= v <= 8999999999999999
\r
17909 // 0 <= (v % 1e14) <= 99999999999999
\r
17910 c.push(v % 1e14);
\r
17916 // Node.js supporting crypto.randomBytes.
\r
17917 } else if (crypto.randomBytes) {
\r
17920 a = crypto.randomBytes(k *= 7);
\r
17924 // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
\r
17925 // 0x100000000 is 2^32, 0x1000000 is 2^24
\r
17926 // 11111 11111111 11111111 11111111 11111111 11111111 11111111
\r
17927 // 0 <= v < 9007199254740992
\r
17928 v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) +
\r
17929 (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) +
\r
17930 (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
\r
17933 crypto.randomBytes(7).copy(a, i);
\r
17936 // 0 <= (v % 1e14) <= 99999999999999
\r
17937 c.push(v % 1e14);
\r
17945 (bignumberError + 'crypto unavailable');
\r
17949 // Use Math.random.
\r
17953 v = random53bitInt();
\r
17954 if (v < 9e15) c[i++] = v % 1e14;
\r
17961 // Convert trailing digits to zeros according to dp.
\r
17963 v = POWS_TEN[LOG_BASE - dp];
\r
17964 c[i] = mathfloor(k / v) * v;
\r
17967 // Remove trailing elements which are zero.
\r
17968 for (; c[i] === 0; c.pop(), i--);
\r
17975 // Remove leading elements which are zero and adjust exponent accordingly.
\r
17976 for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
\r
17978 // Count the digits of the first element of c to determine leading zeros, and...
\r
17979 for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
\r
17981 // adjust the exponent accordingly.
\r
17982 if (i < LOG_BASE) e -= LOG_BASE - i;
\r
17993 * Return a BigNumber whose value is the sum of the arguments.
\r
17995 * arguments {number|string|BigNumber}
\r
17997 BigNumber.sum = function () {
\r
17999 args = arguments,
\r
18000 sum = new BigNumber(args[0]);
\r
18001 for (; i < args.length;) sum = sum.plus(args[i++]);
\r
18006 // PRIVATE FUNCTIONS
\r
18009 // Called by BigNumber and BigNumber.prototype.toString.
\r
18010 convertBase = (function () {
\r
18011 var decimal = '0123456789';
\r
18014 * Convert string of baseIn to an array of numbers of baseOut.
\r
18015 * Eg. toBaseOut('255', 10, 16) returns [15, 15].
\r
18016 * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5].
\r
18018 function toBaseOut(str, baseIn, baseOut, alphabet) {
\r
18023 len = str.length;
\r
18025 for (; i < len;) {
\r
18026 for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
\r
18028 arr[0] += alphabet.indexOf(str.charAt(i++));
\r
18030 for (j = 0; j < arr.length; j++) {
\r
18032 if (arr[j] > baseOut - 1) {
\r
18033 if (arr[j + 1] == null) arr[j + 1] = 0;
\r
18034 arr[j + 1] += arr[j] / baseOut | 0;
\r
18035 arr[j] %= baseOut;
\r
18040 return arr.reverse();
\r
18043 // Convert a numeric string of baseIn to a numeric string of baseOut.
\r
18044 // If the caller is toString, we are converting from base 10 to baseOut.
\r
18045 // If the caller is BigNumber, we are converting from baseIn to base 10.
\r
18046 return function (str, baseIn, baseOut, sign, callerIsToString) {
\r
18047 var alphabet, d, e, k, r, x, xc, y,
\r
18048 i = str.indexOf('.'),
\r
18049 dp = DECIMAL_PLACES,
\r
18050 rm = ROUNDING_MODE;
\r
18054 k = POW_PRECISION;
\r
18056 // Unlimited precision.
\r
18057 POW_PRECISION = 0;
\r
18058 str = str.replace('.', '');
\r
18059 y = new BigNumber(baseIn);
\r
18060 x = y.pow(str.length - i);
\r
18061 POW_PRECISION = k;
\r
18063 // Convert str as if an integer, then restore the fraction part by dividing the
\r
18064 // result by its base raised to a power.
\r
18066 y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'),
\r
18067 10, baseOut, decimal);
\r
18068 y.e = y.c.length;
\r
18071 // Convert the number as integer.
\r
18073 xc = toBaseOut(str, baseIn, baseOut, callerIsToString
\r
18074 ? (alphabet = ALPHABET, decimal)
\r
18075 : (alphabet = decimal, ALPHABET));
\r
18077 // xc now represents str as an integer and converted to baseOut. e is the exponent.
\r
18078 e = k = xc.length;
\r
18080 // Remove trailing zeros.
\r
18081 for (; xc[--k] == 0; xc.pop());
\r
18084 if (!xc[0]) return alphabet.charAt(0);
\r
18086 // Does str represent an integer? If so, no need for the division.
\r
18093 // The sign is needed for correct rounding.
\r
18095 x = div(x, y, dp, rm, baseOut);
\r
18101 // xc now represents str converted to baseOut.
\r
18103 // THe index of the rounding digit.
\r
18106 // The rounding digit: the digit to the right of the digit that may be rounded up.
\r
18109 // Look at the rounding digits and mode to determine whether to round up.
\r
18112 r = r || d < 0 || xc[d + 1] != null;
\r
18114 r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
\r
18115 : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
\r
18116 rm == (x.s < 0 ? 8 : 7));
\r
18118 // If the index of the rounding digit is not greater than zero, or xc represents
\r
18119 // zero, then the result of the base conversion is zero or, if rounding up, a value
\r
18120 // such as 0.00001.
\r
18121 if (d < 1 || !xc[0]) {
\r
18124 str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
\r
18127 // Truncate xc to the required number of decimal places.
\r
18133 // Rounding up may mean the previous digit has to be rounded up and so on.
\r
18134 for (--baseOut; ++xc[--d] > baseOut;) {
\r
18139 xc = [1].concat(xc);
\r
18144 // Determine trailing zeros.
\r
18145 for (k = xc.length; !xc[--k];);
\r
18147 // E.g. [4, 11, 15] becomes 4bf.
\r
18148 for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++]));
\r
18150 // Add leading zeros, decimal point and trailing zeros as required.
\r
18151 str = toFixedPoint(str, e, alphabet.charAt(0));
\r
18154 // The caller will add the sign.
\r
18160 // Perform division in the specified base. Called by div and convertBase.
\r
18161 div = (function () {
\r
18163 // Assume non-zero x and k.
\r
18164 function multiply(x, k, base) {
\r
18165 var m, temp, xlo, xhi,
\r
18168 klo = k % SQRT_BASE,
\r
18169 khi = k / SQRT_BASE | 0;
\r
18171 for (x = x.slice(); i--;) {
\r
18172 xlo = x[i] % SQRT_BASE;
\r
18173 xhi = x[i] / SQRT_BASE | 0;
\r
18174 m = khi * xlo + xhi * klo;
\r
18175 temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
\r
18176 carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
\r
18177 x[i] = temp % base;
\r
18180 if (carry) x = [carry].concat(x);
\r
18185 function compare(a, b, aL, bL) {
\r
18189 cmp = aL > bL ? 1 : -1;
\r
18192 for (i = cmp = 0; i < aL; i++) {
\r
18194 if (a[i] != b[i]) {
\r
18195 cmp = a[i] > b[i] ? 1 : -1;
\r
18204 function subtract(a, b, aL, base) {
\r
18207 // Subtract b from a.
\r
18210 i = a[aL] < b[aL] ? 1 : 0;
\r
18211 a[aL] = i * base + a[aL] - b[aL];
\r
18214 // Remove leading zeros.
\r
18215 for (; !a[0] && a.length > 1; a.splice(0, 1));
\r
18218 // x: dividend, y: divisor.
\r
18219 return function (x, y, dp, rm, base) {
\r
18220 var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
\r
18222 s = x.s == y.s ? 1 : -1,
\r
18226 // Either NaN, Infinity or 0?
\r
18227 if (!xc || !xc[0] || !yc || !yc[0]) {
\r
18229 return new BigNumber(
\r
18231 // Return NaN if either NaN, or both Infinity or 0.
\r
18232 !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN :
\r
18234 // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
\r
18235 xc && xc[0] == 0 || !yc ? s * 0 : s / 0
\r
18239 q = new BigNumber(s);
\r
18246 e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
\r
18247 s = s / LOG_BASE | 0;
\r
18250 // Result exponent may be one less then the current value of e.
\r
18251 // The coefficients of the BigNumbers from convertBase may have trailing zeros.
\r
18252 for (i = 0; yc[i] == (xc[i] || 0); i++);
\r
18254 if (yc[i] > (xc[i] || 0)) e--;
\r
18265 // Normalise xc and yc so highest order digit of yc is >= base / 2.
\r
18267 n = mathfloor(base / (yc[0] + 1));
\r
18269 // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1.
\r
18270 // if (n > 1 || n++ == 1 && yc[0] < base / 2) {
\r
18272 yc = multiply(yc, n, base);
\r
18273 xc = multiply(xc, n, base);
\r
18279 rem = xc.slice(0, yL);
\r
18280 remL = rem.length;
\r
18282 // Add zeros to make remainder as long as divisor.
\r
18283 for (; remL < yL; rem[remL++] = 0);
\r
18285 yz = [0].concat(yz);
\r
18287 if (yc[1] >= base / 2) yc0++;
\r
18288 // Not necessary, but to prevent trial digit n > base, when using base 3.
\r
18289 // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15;
\r
18294 // Compare divisor and remainder.
\r
18295 cmp = compare(yc, rem, yL, remL);
\r
18297 // If divisor < remainder.
\r
18300 // Calculate trial digit, n.
\r
18303 if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
\r
18305 // n is how many times the divisor goes into the current remainder.
\r
18306 n = mathfloor(rem0 / yc0);
\r
18309 // product = divisor multiplied by trial digit (n).
\r
18310 // Compare product and remainder.
\r
18311 // If product is greater than remainder:
\r
18312 // Subtract divisor from product, decrement trial digit.
\r
18313 // Subtract product from remainder.
\r
18314 // If product was less than remainder at the last compare:
\r
18315 // Compare new remainder and divisor.
\r
18316 // If remainder is greater than divisor:
\r
18317 // Subtract divisor from remainder, increment trial digit.
\r
18321 // n may be > base only when base is 3.
\r
18322 if (n >= base) n = base - 1;
\r
18324 // product = divisor * trial digit.
\r
18325 prod = multiply(yc, n, base);
\r
18326 prodL = prod.length;
\r
18327 remL = rem.length;
\r
18329 // Compare product and remainder.
\r
18330 // If product > remainder then trial digit n too high.
\r
18331 // n is 1 too high about 5% of the time, and is not known to have
\r
18332 // ever been more than 1 too high.
\r
18333 while (compare(prod, rem, prodL, remL) == 1) {
\r
18336 // Subtract divisor from product.
\r
18337 subtract(prod, yL < prodL ? yz : yc, prodL, base);
\r
18338 prodL = prod.length;
\r
18343 // n is 0 or 1, cmp is -1.
\r
18344 // If n is 0, there is no need to compare yc and rem again below,
\r
18345 // so change cmp to 1 to avoid it.
\r
18346 // If n is 1, leave cmp as -1, so yc and rem are compared again.
\r
18349 // divisor < remainder, so n must be at least 1.
\r
18353 // product = divisor
\r
18354 prod = yc.slice();
\r
18355 prodL = prod.length;
\r
18358 if (prodL < remL) prod = [0].concat(prod);
\r
18360 // Subtract product from remainder.
\r
18361 subtract(rem, prod, remL, base);
\r
18362 remL = rem.length;
\r
18364 // If product was < remainder.
\r
18367 // Compare divisor and new remainder.
\r
18368 // If divisor < new remainder, subtract divisor from remainder.
\r
18369 // Trial digit n too low.
\r
18370 // n is 1 too low about 5% of the time, and very rarely 2 too low.
\r
18371 while (compare(yc, rem, yL, remL) < 1) {
\r
18374 // Subtract divisor from remainder.
\r
18375 subtract(rem, yL < remL ? yz : yc, remL, base);
\r
18376 remL = rem.length;
\r
18379 } else if (cmp === 0) {
\r
18382 } // else cmp === 1 and n will be 0
\r
18384 // Add the next digit, n, to the result array.
\r
18387 // Update the remainder.
\r
18389 rem[remL++] = xc[xi] || 0;
\r
18394 } while ((xi++ < xL || rem[0] != null) && s--);
\r
18396 more = rem[0] != null;
\r
18399 if (!qc[0]) qc.splice(0, 1);
\r
18402 if (base == BASE) {
\r
18404 // To calculate q.e, first get the number of digits of qc[0].
\r
18405 for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
\r
18407 round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
\r
18409 // Caller is convertBase.
\r
18421 * Return a string representing the value of BigNumber n in fixed-point or exponential
\r
18422 * notation rounded to the specified decimal places or significant digits.
\r
18424 * n: a BigNumber.
\r
18425 * i: the index of the last digit required (i.e. the digit that may be rounded up).
\r
18426 * rm: the rounding mode.
\r
18427 * id: 1 (toExponential) or 2 (toPrecision).
\r
18429 function format(n, i, rm, id) {
\r
18430 var c0, e, ne, len, str;
\r
18432 if (rm == null) rm = ROUNDING_MODE;
\r
18433 else intCheck(rm, 0, 8);
\r
18435 if (!n.c) return n.toString();
\r
18441 str = coeffToString(n.c);
\r
18442 str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS)
\r
18443 ? toExponential(str, ne)
\r
18444 : toFixedPoint(str, ne, '0');
\r
18446 n = round(new BigNumber(n), i, rm);
\r
18448 // n.e may have changed if the value was rounded up.
\r
18451 str = coeffToString(n.c);
\r
18452 len = str.length;
\r
18454 // toPrecision returns exponential notation if the number of significant digits
\r
18455 // specified is less than the number of digits necessary to represent the integer
\r
18456 // part of the value in fixed-point notation.
\r
18458 // Exponential notation.
\r
18459 if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
\r
18462 for (; len < i; str += '0', len++);
\r
18463 str = toExponential(str, e);
\r
18465 // Fixed-point notation.
\r
18468 str = toFixedPoint(str, e, '0');
\r
18471 if (e + 1 > len) {
\r
18472 if (--i > 0) for (str += '.'; i--; str += '0');
\r
18476 if (e + 1 == len) str += '.';
\r
18477 for (; i--; str += '0');
\r
18483 return n.s < 0 && c0 ? '-' + str : str;
\r
18487 // Handle BigNumber.max and BigNumber.min.
\r
18488 function maxOrMin(args, method) {
\r
18491 m = new BigNumber(args[0]);
\r
18493 for (; i < args.length; i++) {
\r
18494 n = new BigNumber(args[i]);
\r
18496 // If any number is NaN, return NaN.
\r
18500 } else if (method.call(m, n)) {
\r
18510 * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
\r
18511 * Called by minus, plus and times.
\r
18513 function normalise(n, c, e) {
\r
18517 // Remove trailing zeros.
\r
18518 for (; !c[--j]; c.pop());
\r
18520 // Calculate the base 10 exponent. First get the number of digits of c[0].
\r
18521 for (j = c[0]; j >= 10; j /= 10, i++);
\r
18524 if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
\r
18527 n.c = n.e = null;
\r
18530 } else if (e < MIN_EXP) {
\r
18543 // Handle values that fail the validity test in BigNumber.
\r
18544 parseNumeric = (function () {
\r
18545 var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
\r
18546 dotAfter = /^([^.]+)\.$/,
\r
18547 dotBefore = /^\.([^.]+)$/,
\r
18548 isInfinityOrNaN = /^-?(Infinity|NaN)$/,
\r
18549 whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
\r
18551 return function (x, str, isNum, b) {
\r
18553 s = isNum ? str : str.replace(whitespaceOrPlus, '');
\r
18555 // No exception on ±Infinity or NaN.
\r
18556 if (isInfinityOrNaN.test(s)) {
\r
18557 x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
\r
18561 // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
\r
18562 s = s.replace(basePrefix, function (m, p1, p2) {
\r
18563 base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
\r
18564 return !b || b == base ? p1 : m;
\r
18570 // E.g. '1.' to '1', '.1' to '0.1'
\r
18571 s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
\r
18574 if (str != s) return new BigNumber(s, base);
\r
18577 // '[BigNumber Error] Not a number: {n}'
\r
18578 // '[BigNumber Error] Not a base {b} number: {n}'
\r
18579 if (BigNumber.DEBUG) {
\r
18581 (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
\r
18588 x.c = x.e = null;
\r
18594 * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
\r
18595 * If r is truthy, it is known that there are more digits after the rounding digit.
\r
18597 function round(x, sd, rm, r) {
\r
18598 var d, i, j, k, n, ni, rd,
\r
18600 pows10 = POWS_TEN;
\r
18602 // if x is not Infinity or NaN...
\r
18605 // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
\r
18606 // n is a base 1e14 number, the value of the element of array x.c containing rd.
\r
18607 // ni is the index of n within x.c.
\r
18608 // d is the number of digits of n.
\r
18609 // i is the index of rd within n including leading zeros.
\r
18610 // j is the actual index of rd within n (if < 0, rd is a leading zero).
\r
18613 // Get the number of digits of the first element of xc.
\r
18614 for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
\r
18617 // If the rounding digit is in the first element of xc...
\r
18623 // Get the rounding digit at index j of n.
\r
18624 rd = n / pows10[d - j - 1] % 10 | 0;
\r
18626 ni = mathceil((i + 1) / LOG_BASE);
\r
18628 if (ni >= xc.length) {
\r
18632 // Needed by sqrt.
\r
18633 for (; xc.length <= ni; xc.push(0));
\r
18637 j = i - LOG_BASE + 1;
\r
18644 // Get the number of digits of n.
\r
18645 for (d = 1; k >= 10; k /= 10, d++);
\r
18647 // Get the index of rd within n.
\r
18650 // Get the index of rd within n, adjusted for leading zeros.
\r
18651 // The number of leading zeros of n is given by LOG_BASE - d.
\r
18652 j = i - LOG_BASE + d;
\r
18654 // Get the rounding digit at index j of n.
\r
18655 rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0;
\r
18659 r = r || sd < 0 ||
\r
18661 // Are there any non-zero digits after the rounding digit?
\r
18662 // The expression n % pows10[d - j - 1] returns all digits of n to the right
\r
18663 // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
\r
18664 xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
\r
18667 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
\r
18668 : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 &&
\r
18670 // Check whether the digit to the left of the rounding digit is odd.
\r
18671 ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 ||
\r
18672 rm == (x.s < 0 ? 8 : 7));
\r
18674 if (sd < 1 || !xc[0]) {
\r
18679 // Convert sd to decimal places.
\r
18682 // 1, 0.1, 0.01, 0.001, 0.0001 etc.
\r
18683 xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
\r
18694 // Remove excess digits.
\r
18700 xc.length = ni + 1;
\r
18701 k = pows10[LOG_BASE - i];
\r
18703 // E.g. 56700 becomes 56000 if 7 is the rounding digit.
\r
18704 // j > 0 means i > number of leading zeros of n.
\r
18705 xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
\r
18713 // If the digit to be rounded up is in the first element of xc...
\r
18716 // i will be the length of xc[0] before k is added.
\r
18717 for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
\r
18719 for (k = 1; j >= 10; j /= 10, k++);
\r
18721 // if i != k the length has increased.
\r
18724 if (xc[0] == BASE) xc[0] = 1;
\r
18730 if (xc[ni] != BASE) break;
\r
18737 // Remove trailing zeros.
\r
18738 for (i = xc.length; xc[--i] === 0; xc.pop());
\r
18741 // Overflow? Infinity.
\r
18742 if (x.e > MAX_EXP) {
\r
18743 x.c = x.e = null;
\r
18745 // Underflow? Zero.
\r
18746 } else if (x.e < MIN_EXP) {
\r
18755 function valueOf(n) {
\r
18759 if (e === null) return n.toString();
\r
18761 str = coeffToString(n.c);
\r
18763 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
\r
18764 ? toExponential(str, e)
\r
18765 : toFixedPoint(str, e, '0');
\r
18767 return n.s < 0 ? '-' + str : str;
\r
18771 // PROTOTYPE/INSTANCE METHODS
\r
18775 * Return a new BigNumber whose value is the absolute value of this BigNumber.
\r
18777 P.absoluteValue = P.abs = function () {
\r
18778 var x = new BigNumber(this);
\r
18779 if (x.s < 0) x.s = 1;
\r
18786 * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
\r
18787 * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
\r
18788 * 0 if they have the same value,
\r
18789 * or null if the value of either is NaN.
\r
18791 P.comparedTo = function (y, b) {
\r
18792 return compare(this, new BigNumber(y, b));
\r
18797 * If dp is undefined or null or true or false, return the number of decimal places of the
\r
18798 * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
\r
18800 * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this
\r
18801 * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or
\r
18802 * ROUNDING_MODE if rm is omitted.
\r
18804 * [dp] {number} Decimal places: integer, 0 to MAX inclusive.
\r
18805 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
18807 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
18809 P.decimalPlaces = P.dp = function (dp, rm) {
\r
18813 if (dp != null) {
\r
18814 intCheck(dp, 0, MAX);
\r
18815 if (rm == null) rm = ROUNDING_MODE;
\r
18816 else intCheck(rm, 0, 8);
\r
18818 return round(new BigNumber(x), dp + x.e + 1, rm);
\r
18821 if (!(c = x.c)) return null;
\r
18822 n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
\r
18824 // Subtract the number of trailing zeros of the last number.
\r
18825 if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
\r
18826 if (n < 0) n = 0;
\r
18849 * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
\r
18850 * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
\r
18852 P.dividedBy = P.div = function (y, b) {
\r
18853 return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE);
\r
18858 * Return a new BigNumber whose value is the integer part of dividing the value of this
\r
18859 * BigNumber by the value of BigNumber(y, b).
\r
18861 P.dividedToIntegerBy = P.idiv = function (y, b) {
\r
18862 return div(this, new BigNumber(y, b), 0, 1);
\r
18867 * Return a BigNumber whose value is the value of this BigNumber exponentiated by n.
\r
18869 * If m is present, return the result modulo m.
\r
18870 * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
\r
18871 * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE.
\r
18873 * The modular power operation works efficiently when x, n, and m are integers, otherwise it
\r
18874 * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0.
\r
18876 * n {number|string|BigNumber} The exponent. An integer.
\r
18877 * [m] {number|string|BigNumber} The modulus.
\r
18879 * '[BigNumber Error] Exponent not an integer: {n}'
\r
18881 P.exponentiatedBy = P.pow = function (n, m) {
\r
18882 var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y,
\r
18885 n = new BigNumber(n);
\r
18887 // Allow NaN and ±Infinity, but not other non-integers.
\r
18888 if (n.c && !n.isInteger()) {
\r
18890 (bignumberError + 'Exponent not an integer: ' + valueOf(n));
\r
18893 if (m != null) m = new BigNumber(m);
\r
18895 // Exponent of MAX_SAFE_INTEGER is 15.
\r
18896 nIsBig = n.e > 14;
\r
18898 // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0.
\r
18899 if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
\r
18901 // The sign of the result of pow when x is negative depends on the evenness of n.
\r
18902 // If +n overflows to ±Infinity, the evenness of n would be not be known.
\r
18903 y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? 2 - isOdd(n) : +valueOf(n)));
\r
18904 return m ? y.mod(m) : y;
\r
18907 nIsNeg = n.s < 0;
\r
18911 // x % m returns NaN if abs(m) is zero, or m is NaN.
\r
18912 if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN);
\r
18914 isModExp = !nIsNeg && x.isInteger() && m.isInteger();
\r
18916 if (isModExp) x = x.mod(m);
\r
18918 // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15.
\r
18919 // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15.
\r
18920 } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0
\r
18921 // [1, 240000000]
\r
18922 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7
\r
18923 // [80000000000000] [99999750000000]
\r
18924 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
\r
18926 // If x is negative and n is odd, k = -0, else k = 0.
\r
18927 k = x.s < 0 && isOdd(n) ? -0 : 0;
\r
18929 // If x >= 1, k = ±Infinity.
\r
18930 if (x.e > -1) k = 1 / k;
\r
18932 // If n is negative return ±0, else return ±Infinity.
\r
18933 return new BigNumber(nIsNeg ? 1 / k : k);
\r
18935 } else if (POW_PRECISION) {
\r
18937 // Truncating each coefficient array to a length of k after each multiplication
\r
18938 // equates to truncating significant digits to POW_PRECISION + [28, 41],
\r
18939 // i.e. there will be a minimum of 28 guard digits retained.
\r
18940 k = mathceil(POW_PRECISION / LOG_BASE + 2);
\r
18944 half = new BigNumber(0.5);
\r
18945 if (nIsNeg) n.s = 1;
\r
18946 nIsOdd = isOdd(n);
\r
18948 i = Math.abs(+valueOf(n));
\r
18952 y = new BigNumber(ONE);
\r
18954 // Performs 54 loop iterations for n of 9007199254740991.
\r
18962 if (y.c.length > k) y.c.length = k;
\r
18963 } else if (isModExp) {
\r
18964 y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m));
\r
18969 i = mathfloor(i / 2);
\r
18970 if (i === 0) break;
\r
18973 n = n.times(half);
\r
18974 round(n, n.e + 1, 1);
\r
18977 nIsOdd = isOdd(n);
\r
18980 if (i === 0) break;
\r
18988 if (x.c && x.c.length > k) x.c.length = k;
\r
18989 } else if (isModExp) {
\r
18990 x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m));
\r
18994 if (isModExp) return y;
\r
18995 if (nIsNeg) y = ONE.div(y);
\r
18997 return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
\r
19002 * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer
\r
19003 * using rounding mode rm, or ROUNDING_MODE if rm is omitted.
\r
19005 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
19007 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}'
\r
19009 P.integerValue = function (rm) {
\r
19010 var n = new BigNumber(this);
\r
19011 if (rm == null) rm = ROUNDING_MODE;
\r
19012 else intCheck(rm, 0, 8);
\r
19013 return round(n, n.e + 1, rm);
\r
19018 * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
\r
19019 * otherwise return false.
\r
19021 P.isEqualTo = P.eq = function (y, b) {
\r
19022 return compare(this, new BigNumber(y, b)) === 0;
\r
19027 * Return true if the value of this BigNumber is a finite number, otherwise return false.
\r
19029 P.isFinite = function () {
\r
19035 * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
\r
19036 * otherwise return false.
\r
19038 P.isGreaterThan = P.gt = function (y, b) {
\r
19039 return compare(this, new BigNumber(y, b)) > 0;
\r
19044 * Return true if the value of this BigNumber is greater than or equal to the value of
\r
19045 * BigNumber(y, b), otherwise return false.
\r
19047 P.isGreaterThanOrEqualTo = P.gte = function (y, b) {
\r
19048 return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0;
\r
19054 * Return true if the value of this BigNumber is an integer, otherwise return false.
\r
19056 P.isInteger = function () {
\r
19057 return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
\r
19062 * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
\r
19063 * otherwise return false.
\r
19065 P.isLessThan = P.lt = function (y, b) {
\r
19066 return compare(this, new BigNumber(y, b)) < 0;
\r
19071 * Return true if the value of this BigNumber is less than or equal to the value of
\r
19072 * BigNumber(y, b), otherwise return false.
\r
19074 P.isLessThanOrEqualTo = P.lte = function (y, b) {
\r
19075 return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0;
\r
19080 * Return true if the value of this BigNumber is NaN, otherwise return false.
\r
19082 P.isNaN = function () {
\r
19088 * Return true if the value of this BigNumber is negative, otherwise return false.
\r
19090 P.isNegative = function () {
\r
19091 return this.s < 0;
\r
19096 * Return true if the value of this BigNumber is positive, otherwise return false.
\r
19098 P.isPositive = function () {
\r
19099 return this.s > 0;
\r
19104 * Return true if the value of this BigNumber is 0 or -0, otherwise return false.
\r
19106 P.isZero = function () {
\r
19107 return !!this.c && this.c[0] == 0;
\r
19128 * Return a new BigNumber whose value is the value of this BigNumber minus the value of
\r
19129 * BigNumber(y, b).
\r
19131 P.minus = function (y, b) {
\r
19132 var i, j, t, xLTy,
\r
19136 y = new BigNumber(y, b);
\r
19140 if (!a || !b) return new BigNumber(NaN);
\r
19145 return x.plus(y);
\r
19148 var xe = x.e / LOG_BASE,
\r
19149 ye = y.e / LOG_BASE,
\r
19153 if (!xe || !ye) {
\r
19155 // Either Infinity?
\r
19156 if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN);
\r
19159 if (!xc[0] || !yc[0]) {
\r
19161 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
\r
19162 return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x :
\r
19164 // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
\r
19165 ROUNDING_MODE == 3 ? -0 : 0);
\r
19169 xe = bitFloor(xe);
\r
19170 ye = bitFloor(ye);
\r
19173 // Determine which is the bigger number.
\r
19174 if (a = xe - ye) {
\r
19176 if (xLTy = a < 0) {
\r
19186 // Prepend zeros to equalise exponents.
\r
19187 for (b = a; b--; t.push(0));
\r
19191 // Exponents equal. Check digit by digit.
\r
19192 j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
\r
19194 for (a = b = 0; b < j; b++) {
\r
19196 if (xc[b] != yc[b]) {
\r
19197 xLTy = xc[b] < yc[b];
\r
19203 // x < y? Point xc to the array of the bigger number.
\r
19204 if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
\r
19206 b = (j = yc.length) - (i = xc.length);
\r
19208 // Append zeros to xc if shorter.
\r
19209 // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
\r
19210 if (b > 0) for (; b--; xc[i++] = 0);
\r
19213 // Subtract yc from xc.
\r
19216 if (xc[--j] < yc[j]) {
\r
19217 for (i = j; i && !xc[--i]; xc[i] = b);
\r
19225 // Remove leading zeros and adjust exponent accordingly.
\r
19226 for (; xc[0] == 0; xc.splice(0, 1), --ye);
\r
19231 // Following IEEE 754 (2008) 6.3,
\r
19232 // n - n = +0 but n - n = -0 when rounding towards -Infinity.
\r
19233 y.s = ROUNDING_MODE == 3 ? -1 : 1;
\r
19238 // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
\r
19239 // for finite x and y.
\r
19240 return normalise(y, xc, ye);
\r
19262 * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
\r
19263 * BigNumber(y, b). The result depends on the value of MODULO_MODE.
\r
19265 P.modulo = P.mod = function (y, b) {
\r
19269 y = new BigNumber(y, b);
\r
19271 // Return NaN if x is Infinity or NaN, or y is NaN or zero.
\r
19272 if (!x.c || !y.s || y.c && !y.c[0]) {
\r
19273 return new BigNumber(NaN);
\r
19275 // Return x if y is Infinity or x is zero.
\r
19276 } else if (!y.c || x.c && !x.c[0]) {
\r
19277 return new BigNumber(x);
\r
19280 if (MODULO_MODE == 9) {
\r
19282 // Euclidian division: q = sign(y) * floor(x / abs(y))
\r
19283 // r = x - qy where 0 <= r < abs(y)
\r
19286 q = div(x, y, 0, 3);
\r
19290 q = div(x, y, 0, MODULO_MODE);
\r
19293 y = x.minus(q.times(y));
\r
19295 // To match JavaScript %, ensure sign of zero is sign of dividend.
\r
19296 if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
\r
19319 * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value
\r
19320 * of BigNumber(y, b).
\r
19322 P.multipliedBy = P.times = function (y, b) {
\r
19323 var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
\r
19327 yc = (y = new BigNumber(y, b)).c;
\r
19329 // Either NaN, ±Infinity or ±0?
\r
19330 if (!xc || !yc || !xc[0] || !yc[0]) {
\r
19332 // Return NaN if either is NaN, or one is 0 and the other is Infinity.
\r
19333 if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
\r
19334 y.c = y.e = y.s = null;
\r
19338 // Return ±Infinity if either is ±Infinity.
\r
19339 if (!xc || !yc) {
\r
19340 y.c = y.e = null;
\r
19342 // Return ±0 if either is ±0.
\r
19352 e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
\r
19357 // Ensure xc points to longer array and xcL to its length.
\r
19358 if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
\r
19360 // Initialise the result array with zeros.
\r
19361 for (i = xcL + ycL, zc = []; i--; zc.push(0));
\r
19364 sqrtBase = SQRT_BASE;
\r
19366 for (i = ycL; --i >= 0;) {
\r
19368 ylo = yc[i] % sqrtBase;
\r
19369 yhi = yc[i] / sqrtBase | 0;
\r
19371 for (k = xcL, j = i + k; j > i;) {
\r
19372 xlo = xc[--k] % sqrtBase;
\r
19373 xhi = xc[k] / sqrtBase | 0;
\r
19374 m = yhi * xlo + xhi * ylo;
\r
19375 xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c;
\r
19376 c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
\r
19377 zc[j--] = xlo % base;
\r
19389 return normalise(y, zc, e);
\r
19394 * Return a new BigNumber whose value is the value of this BigNumber negated,
\r
19395 * i.e. multiplied by -1.
\r
19397 P.negated = function () {
\r
19398 var x = new BigNumber(this);
\r
19399 x.s = -x.s || null;
\r
19421 * Return a new BigNumber whose value is the value of this BigNumber plus the value of
\r
19422 * BigNumber(y, b).
\r
19424 P.plus = function (y, b) {
\r
19429 y = new BigNumber(y, b);
\r
19433 if (!a || !b) return new BigNumber(NaN);
\r
19438 return x.minus(y);
\r
19441 var xe = x.e / LOG_BASE,
\r
19442 ye = y.e / LOG_BASE,
\r
19446 if (!xe || !ye) {
\r
19448 // Return ±Infinity if either ±Infinity.
\r
19449 if (!xc || !yc) return new BigNumber(a / 0);
\r
19452 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
\r
19453 if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0);
\r
19456 xe = bitFloor(xe);
\r
19457 ye = bitFloor(ye);
\r
19460 // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
\r
19461 if (a = xe - ye) {
\r
19471 for (; a--; t.push(0));
\r
19478 // Point xc to the longer array, and b to the shorter length.
\r
19479 if (a - b < 0) t = yc, yc = xc, xc = t, b = a;
\r
19481 // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
\r
19482 for (a = 0; b;) {
\r
19483 a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
\r
19484 xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
\r
19488 xc = [a].concat(xc);
\r
19492 // No need to check for zero, as +x + +y != 0 && -x + -y != 0
\r
19493 // ye = MAX_EXP + 1 possible
\r
19494 return normalise(y, xc, ye);
\r
19499 * If sd is undefined or null or true or false, return the number of significant digits of
\r
19500 * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
\r
19501 * If sd is true include integer-part trailing zeros in the count.
\r
19503 * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this
\r
19504 * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or
\r
19505 * ROUNDING_MODE if rm is omitted.
\r
19507 * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive.
\r
19508 * boolean: whether to count integer-part trailing zeros: true or false.
\r
19509 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
19511 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
\r
19513 P.precision = P.sd = function (sd, rm) {
\r
19517 if (sd != null && sd !== !!sd) {
\r
19518 intCheck(sd, 1, MAX);
\r
19519 if (rm == null) rm = ROUNDING_MODE;
\r
19520 else intCheck(rm, 0, 8);
\r
19522 return round(new BigNumber(x), sd, rm);
\r
19525 if (!(c = x.c)) return null;
\r
19526 v = c.length - 1;
\r
19527 n = v * LOG_BASE + 1;
\r
19531 // Subtract the number of trailing zeros of the last element.
\r
19532 for (; v % 10 == 0; v /= 10, n--);
\r
19534 // Add the number of digits of the first element.
\r
19535 for (v = c[0]; v >= 10; v /= 10, n++);
\r
19538 if (sd && x.e + 1 > n) n = x.e + 1;
\r
19545 * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
\r
19546 * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
\r
19548 * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
\r
19550 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}'
\r
19552 P.shiftedBy = function (k) {
\r
19553 intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
\r
19554 return this.times('1e' + k);
\r
19566 * Return a new BigNumber whose value is the square root of the value of this BigNumber,
\r
19567 * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
\r
19569 P.squareRoot = P.sqrt = function () {
\r
19570 var m, n, r, rep, t,
\r
19575 dp = DECIMAL_PLACES + 4,
\r
19576 half = new BigNumber('0.5');
\r
19578 // Negative/NaN/Infinity/zero?
\r
19579 if (s !== 1 || !c || !c[0]) {
\r
19580 return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
\r
19583 // Initial estimate.
\r
19584 s = Math.sqrt(+valueOf(x));
\r
19586 // Math.sqrt underflow/overflow?
\r
19587 // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
\r
19588 if (s == 0 || s == 1 / 0) {
\r
19589 n = coeffToString(c);
\r
19590 if ((n.length + e) % 2 == 0) n += '0';
\r
19591 s = Math.sqrt(+n);
\r
19592 e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
\r
19594 if (s == 1 / 0) {
\r
19597 n = s.toExponential();
\r
19598 n = n.slice(0, n.indexOf('e') + 1) + e;
\r
19601 r = new BigNumber(n);
\r
19603 r = new BigNumber(s + '');
\r
19606 // Check for zero.
\r
19607 // r could be zero if MIN_EXP is changed after the this value was created.
\r
19608 // This would cause a division by zero (x/t) and hence Infinity below, which would cause
\r
19609 // coeffToString to throw.
\r
19613 if (s < 3) s = 0;
\r
19615 // Newton-Raphson iteration.
\r
19618 r = half.times(t.plus(div(x, t, dp, 1)));
\r
19620 if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
\r
19622 // The exponent of r may here be one less than the final result exponent,
\r
19623 // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
\r
19624 // are indexed correctly.
\r
19625 if (r.e < e) --s;
\r
19626 n = n.slice(s - 3, s + 1);
\r
19628 // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
\r
19629 // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
\r
19631 if (n == '9999' || !rep && n == '4999') {
\r
19633 // On the first iteration only, check to see if rounding up gives the
\r
19634 // exact result as the nines may infinitely repeat.
\r
19636 round(t, t.e + DECIMAL_PLACES + 2, 0);
\r
19638 if (t.times(t).eq(x)) {
\r
19649 // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
\r
19650 // result. If not, then there are further digits and m will be truthy.
\r
19651 if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
\r
19653 // Truncate to the first rounding digit.
\r
19654 round(r, r.e + DECIMAL_PLACES + 2, 1);
\r
19655 m = !r.times(r).eq(x);
\r
19664 return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
\r
19669 * Return a string representing the value of this BigNumber in exponential notation and
\r
19670 * rounded using ROUNDING_MODE to dp fixed decimal places.
\r
19672 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
19673 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
19675 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
19677 P.toExponential = function (dp, rm) {
\r
19678 if (dp != null) {
\r
19679 intCheck(dp, 0, MAX);
\r
19682 return format(this, dp, rm, 1);
\r
19687 * Return a string representing the value of this BigNumber in fixed-point notation rounding
\r
19688 * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
\r
19690 * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
\r
19691 * but e.g. (-0.00001).toFixed(0) is '-0'.
\r
19693 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
19694 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
19696 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
19698 P.toFixed = function (dp, rm) {
\r
19699 if (dp != null) {
\r
19700 intCheck(dp, 0, MAX);
\r
19701 dp = dp + this.e + 1;
\r
19703 return format(this, dp, rm);
\r
19708 * Return a string representing the value of this BigNumber in fixed-point notation rounded
\r
19709 * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
\r
19710 * of the format or FORMAT object (see BigNumber.set).
\r
19712 * The formatting object may contain some or all of the properties shown below.
\r
19717 * secondaryGroupSize: 0,
\r
19718 * groupSeparator: ',',
\r
19719 * decimalSeparator: '.',
\r
19720 * fractionGroupSize: 0,
\r
19721 * fractionGroupSeparator: '\xA0', // non-breaking space
\r
19725 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
\r
19726 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
19727 * [format] {object} Formatting options. See FORMAT pbject above.
\r
19729 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
\r
19730 * '[BigNumber Error] Argument not an object: {format}'
\r
19732 P.toFormat = function (dp, rm, format) {
\r
19736 if (format == null) {
\r
19737 if (dp != null && rm && typeof rm == 'object') {
\r
19740 } else if (dp && typeof dp == 'object') {
\r
19746 } else if (typeof format != 'object') {
\r
19748 (bignumberError + 'Argument not an object: ' + format);
\r
19751 str = x.toFixed(dp, rm);
\r
19755 arr = str.split('.'),
\r
19756 g1 = +format.groupSize,
\r
19757 g2 = +format.secondaryGroupSize,
\r
19758 groupSeparator = format.groupSeparator || '',
\r
19759 intPart = arr[0],
\r
19760 fractionPart = arr[1],
\r
19762 intDigits = isNeg ? intPart.slice(1) : intPart,
\r
19763 len = intDigits.length;
\r
19765 if (g2) i = g1, g1 = g2, g2 = i, len -= i;
\r
19767 if (g1 > 0 && len > 0) {
\r
19768 i = len % g1 || g1;
\r
19769 intPart = intDigits.substr(0, i);
\r
19770 for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
\r
19771 if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
\r
19772 if (isNeg) intPart = '-' + intPart;
\r
19775 str = fractionPart
\r
19776 ? intPart + (format.decimalSeparator || '') + ((g2 = +format.fractionGroupSize)
\r
19777 ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'),
\r
19778 '$&' + (format.fractionGroupSeparator || ''))
\r
19783 return (format.prefix || '') + str + (format.suffix || '');
\r
19788 * Return an array of two BigNumbers representing the value of this BigNumber as a simple
\r
19789 * fraction with an integer numerator and an integer denominator.
\r
19790 * The denominator will be a positive non-zero value less than or equal to the specified
\r
19791 * maximum denominator. If a maximum denominator is not specified, the denominator will be
\r
19792 * the lowest value necessary to represent the number exactly.
\r
19794 * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator.
\r
19796 * '[BigNumber Error] Argument {not an integer|out of range} : {md}'
\r
19798 P.toFraction = function (md) {
\r
19799 var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s,
\r
19803 if (md != null) {
\r
19804 n = new BigNumber(md);
\r
19806 // Throw if md is less than one or is not an integer, unless it is Infinity.
\r
19807 if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
\r
19809 (bignumberError + 'Argument ' +
\r
19810 (n.isInteger() ? 'out of range: ' : 'not an integer: ') + valueOf(n));
\r
19814 if (!xc) return new BigNumber(x);
\r
19816 d = new BigNumber(ONE);
\r
19817 n1 = d0 = new BigNumber(ONE);
\r
19818 d1 = n0 = new BigNumber(ONE);
\r
19819 s = coeffToString(xc);
\r
19821 // Determine initial denominator.
\r
19822 // d is a power of 10 and the minimum max denominator that specifies the value exactly.
\r
19823 e = d.e = s.length - x.e - 1;
\r
19824 d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
\r
19825 md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n;
\r
19829 n = new BigNumber(s);
\r
19835 q = div(n, d, 0, 1);
\r
19836 d2 = d0.plus(q.times(d1));
\r
19837 if (d2.comparedTo(md) == 1) break;
\r
19840 n1 = n0.plus(q.times(d2 = n1));
\r
19842 d = n.minus(q.times(d2 = d));
\r
19846 d2 = div(md.minus(d0), d1, 0, 1);
\r
19847 n0 = n0.plus(d2.times(n1));
\r
19848 d0 = d0.plus(d2.times(d1));
\r
19849 n0.s = n1.s = x.s;
\r
19852 // Determine which fraction is closer to x, n0/d0 or n1/d1
\r
19853 r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
\r
19854 div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
\r
19863 * Return the value of this BigNumber converted to a number primitive.
\r
19865 P.toNumber = function () {
\r
19866 return +valueOf(this);
\r
19871 * Return a string representing the value of this BigNumber rounded to sd significant digits
\r
19872 * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
\r
19873 * necessary to represent the integer part of the value in fixed-point notation, then use
\r
19874 * exponential notation.
\r
19876 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
\r
19877 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
\r
19879 * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
\r
19881 P.toPrecision = function (sd, rm) {
\r
19882 if (sd != null) intCheck(sd, 1, MAX);
\r
19883 return format(this, sd, rm, 2);
\r
19888 * Return a string representing the value of this BigNumber in base b, or base 10 if b is
\r
19889 * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
\r
19890 * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
\r
19891 * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
\r
19892 * TO_EXP_NEG, return exponential notation.
\r
19894 * [b] {number} Integer, 2 to ALPHABET.length inclusive.
\r
19896 * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
\r
19898 P.toString = function (b) {
\r
19904 // Infinity or NaN?
\r
19905 if (e === null) {
\r
19907 str = 'Infinity';
\r
19908 if (s < 0) str = '-' + str;
\r
19914 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
\r
19915 ? toExponential(coeffToString(n.c), e)
\r
19916 : toFixedPoint(coeffToString(n.c), e, '0');
\r
19917 } else if (b === 10) {
\r
19918 n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
\r
19919 str = toFixedPoint(coeffToString(n.c), n.e, '0');
\r
19921 intCheck(b, 2, ALPHABET.length, 'Base');
\r
19922 str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
\r
19925 if (s < 0 && n.c[0]) str = '-' + str;
\r
19933 * Return as toString, but do not accept a base argument, and include the minus sign for
\r
19936 P.valueOf = P.toJSON = function () {
\r
19937 return valueOf(this);
\r
19941 P._isBigNumber = true;
\r
19943 if (configObject != null) BigNumber.set(configObject);
\r
19945 return BigNumber;
\r
19949 // PRIVATE HELPER FUNCTIONS
\r
19951 // These functions don't need access to variables,
\r
19952 // e.g. DECIMAL_PLACES, in the scope of the `clone` function above.
\r
19955 function bitFloor(n) {
\r
19957 return n > 0 || n === i ? i : i - 1;
\r
19961 // Return a coefficient array as a string of base 10 digits.
\r
19962 function coeffToString(a) {
\r
19970 z = LOG_BASE - s.length;
\r
19971 for (; z--; s = '0' + s);
\r
19975 // Determine trailing zeros.
\r
19976 for (j = r.length; r.charCodeAt(--j) === 48;);
\r
19978 return r.slice(0, j + 1 || 1);
\r
19982 // Compare the value of BigNumbers x and y.
\r
19983 function compare(x, y) {
\r
19993 if (!i || !j) return null;
\r
19995 a = xc && !xc[0];
\r
19996 b = yc && !yc[0];
\r
19999 if (a || b) return a ? b ? 0 : -j : i;
\r
20002 if (i != j) return i;
\r
20007 // Either Infinity?
\r
20008 if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
\r
20010 // Compare exponents.
\r
20011 if (!b) return k > l ^ a ? 1 : -1;
\r
20013 j = (k = xc.length) < (l = yc.length) ? k : l;
\r
20015 // Compare digit by digit.
\r
20016 for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
\r
20018 // Compare lengths.
\r
20019 return k == l ? 0 : k > l ^ a ? 1 : -1;
\r
20024 * Check that n is a primitive number, an integer, and in range, otherwise throw.
\r
20026 function intCheck(n, min, max, name) {
\r
20027 if (n < min || n > max || n !== mathfloor(n)) {
\r
20029 (bignumberError + (name || 'Argument') + (typeof n == 'number'
\r
20030 ? n < min || n > max ? ' out of range: ' : ' not an integer: '
\r
20031 : ' not a primitive number: ') + String(n));
\r
20036 // Assumes finite n.
\r
20037 function isOdd(n) {
\r
20038 var k = n.c.length - 1;
\r
20039 return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
\r
20043 function toExponential(str, e) {
\r
20044 return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) +
\r
20045 (e < 0 ? 'e' : 'e+') + e;
\r
20049 function toFixedPoint(str, e, z) {
\r
20052 // Negative exponent?
\r
20055 // Prepend zeros.
\r
20056 for (zs = z + '.'; ++e; zs += z);
\r
20059 // Positive exponent
\r
20061 len = str.length;
\r
20065 for (zs = z, e -= len; --e; zs += z);
\r
20067 } else if (e < len) {
\r
20068 str = str.slice(0, e) + '.' + str.slice(e);
\r
20079 BigNumber = clone();
\r
20080 BigNumber['default'] = BigNumber.BigNumber = BigNumber;
\r
20084 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return BigNumber; }).call(exports, __webpack_require__, exports, module),
20085 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
\r
20087 // Node.js and other environments that support module.exports.
\r
20088 } else if (typeof module != 'undefined' && module.exports) {
\r
20089 module.exports = BigNumber;
\r
20093 if (!globalObject) {
\r
20094 globalObject = typeof self != 'undefined' && self ? self : window;
\r
20097 globalObject.BigNumber = BigNumber;
\r
20105 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20108 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__ = __webpack_require__(144);
20109 /* 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__);
20110 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise__ = __webpack_require__(76);
20111 /* 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__);
20112 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__bytom__ = __webpack_require__(436);
20113 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_utils__ = __webpack_require__(578);
20119 var transaction = {};
20121 transaction.list = function (guid, asset_id, start, limit, tx_types) {
20122 var filter = { asset_id: asset_id };
20124 filter.tx_types = tx_types;
20126 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.list(guid, filter, null, start, limit);
20129 transaction.convertArgument = function (argArray) {
20130 var fn = function asyncConvert(object) {
20131 var type = object.type;
20132 var value = object.value;
20133 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.convertArgument(type, value).then(function (resp) {
20138 var actionFunction = argArray.map(fn);
20139 return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a.all(actionFunction);
20142 transaction.chainStatus = function () {
20143 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].query.getblockcount();
20146 transaction.asset = function (asset_id) {
20147 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].query.asset(asset_id);
20150 transaction.build = function (address, to, asset, amount, fee, confirmations) {
20151 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20152 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildPayment(address, to, asset, amount.toString(), fee, confirmations).then(function (res) {
20154 }).catch(function (error) {
20161 transaction.buildCrossChain = function (address, to, asset, amount, confirmations) {
20162 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20163 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildCrossChain(address, to, asset, amount.toString(), confirmations).then(function (res) {
20165 }).catch(function (error) {
20172 transaction.buildVote = function (address, vote, amount, confirmations, memo) {
20173 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20174 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildVote(address, vote, amount.toString(), confirmations, memo).then(function (res) {
20176 }).catch(function (error) {
20183 transaction.buildVeto = function (address, vote, amount, confirmations, memo) {
20184 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20185 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildVeto(address, vote, amount.toString(), confirmations, memo).then(function (res) {
20187 }).catch(function (error) {
20194 transaction.buildTransaction = function (address, inputs, outputs, gas, confirmations) {
20195 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20196 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.buildTransaction(address, inputs, outputs, gas, confirmations).then(function (res) {
20198 }).catch(function (error) {
20205 transaction.signTransaction = function (guid, transaction, password) {
20206 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20207 __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) {
20209 }).catch(function (error) {
20216 transaction.transfer = function (guid, transaction, password, address) {
20217 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20218 __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) {
20219 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.submitPayment(address, ret.raw_transaction, ret.signatures).then(function (res3) {
20221 transactionHash: res3.txHash
20224 }).catch(function (error) {
20227 }).catch(function (error) {
20235 transaction.signMessage = function (message, password, address) {
20236 return __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].keys.signMessage(message, password, address);
20239 transaction.advancedTransfer = function (guid, transaction, password, arrayData, address) {
20240 var retPromise = new __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20241 __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) {
20242 var signatures = ret.signatures;
20244 signatures[0] = arrayData;
20246 __WEBPACK_IMPORTED_MODULE_2__bytom__["a" /* default */].transaction.submitPayment(address, ret.raw_transaction, signatures).then(function (res3) {
20248 transactionHash: res3.txHash
20251 }).catch(function (error) {
20254 }).catch(function (error) {
20262 /* harmony default export */ __webpack_exports__["a"] = (transaction);
20267 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20270 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return camelize; });
20271 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return snakeize; });
20272 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__ = __webpack_require__(145);
20273 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__);
20275 var camelize = function camelize(object) {
20276 if ((typeof object === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(object)) == 'object') {
20277 for (var key in object) {
20278 var value = object[key];
20281 if (/_/.test(key)) {
20282 newKey = key.replace(/([_][a-z])/g, function (v) {
20283 return v[1].toUpperCase();
20285 delete object[key];
20288 if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(value)) == 'object') {
20289 value = camelize(value);
20292 object[newKey] = value;
20297 return object.replace(/([_][a-z])/g, function (v) {
20298 return v[1].toUpperCase();
20303 var snakeize = function snakeize(object) {
20304 for (var key in object) {
20305 var value = object[key];
20308 // Skip all-caps keys
20309 if (/^[A-Z]+$/.test(key)) {
20313 if (/[A-Z]/.test(key)) {
20314 newKey = key.replace(/([A-Z])/g, function (v) {
20315 return '_' + v.toLowerCase();
20317 delete object[key];
20320 if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(value)) == 'object') {
20321 value = snakeize(value);
20324 object[newKey] = value;
20333 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20336 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Number; });
20337 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
20338 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
20339 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(36);
20340 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
20341 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_bignumber_js__ = __webpack_require__(576);
20342 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_bignumber_js__);
20347 var Number = function () {
20348 function Number() {
20349 __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, Number);
20352 __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(Number, null, [{
20356 * format num to BTM
20359 value: function formatNue(num, dec, exp) {
20360 var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(num);
20367 return result.toFormat(dec);
20371 * convert num to Nue
20376 key: "convertToNue",
20377 value: function convertToNue(num, dec) {
20378 var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(num);
20379 var base = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(10).exponentiatedBy(dec);
20381 var result = n.multipliedBy(base);
20383 return result.toNumber().toFixed(0);
20387 * format num to percent
20388 * @returns percentage
20392 key: "fractionalNum",
20393 value: function fractionalNum(upper, lower) {
20394 var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(upper).div(lower);
20396 var result = n.shiftedBy(2).decimalPlaces(2);
20397 return result + '%';
20401 * format num to currency value
20402 * @returns percentage
20406 key: "formatCurrency",
20407 value: function formatCurrency(num, type) {
20408 var n = new __WEBPACK_IMPORTED_MODULE_2_bignumber_js___default.a(num);
20412 return "\xA5 " + n.toFormat(2);
20415 return "$ " + n.toFormat();
20418 return "\u20BF " + n.toFormat();
20420 return "\xA5 " + n.toFormat(2);
20428 /* harmony default export */ __webpack_exports__["b"] = (Number);
20433 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20436 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__bytom__ = __webpack_require__(436);
20441 query.chainStatus = function () {
20442 return __WEBPACK_IMPORTED_MODULE_0__bytom__["a" /* default */].query.getVoteStatus();
20445 /* harmony default export */ __webpack_exports__["a"] = (query);
20450 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20453 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise__ = __webpack_require__(76);
20454 /* 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__);
20455 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends__ = __webpack_require__(532);
20456 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends__);
20457 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_address__ = __webpack_require__(437);
20458 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__models_query__ = __webpack_require__(591);
20459 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__models_transaction__ = __webpack_require__(577);
20460 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_utils__ = __webpack_require__(578);
20461 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_constants__ = __webpack_require__(268);
20462 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_vuex__ = __webpack_require__(433);
20463 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__store_constants__ = __webpack_require__(269);
20464 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_lodash__ = __webpack_require__(434);
20465 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9_lodash__);
20466 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_Number__ = __webpack_require__(580);
20631 var EnterActive = 'animated faster fadeInLeft';
20632 var LeaveActive = 'animated faster fadeOutLeft';
20633 /* harmony default export */ __webpack_exports__["a"] = ({
20635 data: function data() {
20642 enterActive: EnterActive,
20643 leaveActive: LeaveActive
20648 '$route': function $route(to, from) {
20649 if (to.name.startsWith('menu')) {
20650 this.maskShow = true;
20651 } else if (from.name.startsWith('menu')) {
20652 this.maskShow = false;
20655 // remove transition for some page
20656 this.enterActive = EnterActive;
20657 this.leaveActive = LeaveActive;
20659 'currentAccount.balances': function currentAccountBalances() {
20662 this.$refs['vs'].scrollTo({
20664 }, 500, 'easeInQuad');
20666 this.refreshTransactions(this.start, this.limit).then(function (transactions) {
20667 _this.transactions = transactions;
20671 computed: __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends___default()({
20672 address: function address() {
20673 if (this.netType === 'vapor') {
20674 return this.currentAccount.vpAddress;
20676 return this.currentAccount.address;
20679 }, Object(__WEBPACK_IMPORTED_MODULE_7_vuex__["d" /* mapState */])(['bytom', 'currentAsset', 'listVote']), Object(__WEBPACK_IMPORTED_MODULE_7_vuex__["c" /* mapGetters */])(['currentAccount', 'currency', 'netType'])),
20680 methods: __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends___default()({
20681 camelize: function camelize(object) {
20682 return Object(__WEBPACK_IMPORTED_MODULE_5__utils_utils__["a" /* camelize */])(object);
20684 close: function close() {
20685 this.$router.go(-1);
20687 shortAddress: function shortAddress(add) {
20688 return __WEBPACK_IMPORTED_MODULE_2__utils_address__["a" /* default */].short(add);
20690 formatCurrency: function formatCurrency(num) {
20691 return __WEBPACK_IMPORTED_MODULE_10__utils_Number__["a" /* Number */].formatCurrency(num, this.currency);
20693 itemBalance: function itemBalance(asset) {
20694 if (asset.asset === __WEBPACK_IMPORTED_MODULE_6__utils_constants__["a" /* BTM */]) {
20695 return __WEBPACK_IMPORTED_MODULE_10__utils_Number__["a" /* Number */].formatNue(asset.availableBalance, 8);
20697 return __WEBPACK_IMPORTED_MODULE_10__utils_Number__["a" /* Number */].formatNue(asset.availableBalance, asset.decimals);
20700 handleScroll: function handleScroll(vertical, horizontal, nativeEvent) {
20703 if (vertical.process == 0) {
20705 this.refreshTransactions(this.start, this.limit).then(function (transactions) {
20706 _this2.transactions = transactions;
20711 if (vertical.process == 1 && this.transactions.length == (this.start + 1) * this.limit) {
20712 this.start += this.limit;
20713 this.refreshTransactions(this.start, this.limit).then(function (transactions) {
20714 transactions.forEach(function (transaction) {
20715 _this2.transactions.push(transaction);
20721 refreshTransactions: function refreshTransactions(start, limit) {
20724 return new __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_promise___default.a(function (resolve, reject) {
20725 __WEBPACK_IMPORTED_MODULE_4__models_transaction__["a" /* default */].list(_this3.address, _this3.currentAsset.asset.assetId, start, limit).then(function (transactions) {
20726 if (transactions == null) {
20730 var formattedTx = _this3.transactionsFormat(transactions);
20731 resolve(formattedTx);
20732 }).catch(function (error) {
20733 console.log(error);
20738 transactionsFormat: function transactionsFormat(transactions) {
20741 var formattedTransactions = [];
20742 var assetID = this.currentAsset.asset.assetId;
20744 transactions.forEach(function (transaction) {
20745 var balanceObject = transaction.balances.filter(function (b) {
20746 return b.asset.assetId === assetID;
20749 var filterInput = __WEBPACK_IMPORTED_MODULE_9_lodash___default.a.find(transaction.inputs, function (o) {
20750 return o.type == 'veto';
20752 var filterOutput = __WEBPACK_IMPORTED_MODULE_9_lodash___default.a.find(transaction.outputs, function (o) {
20753 return o.type == 'vote';
20757 transaction.type = 'veto';
20758 var inAmount = __WEBPACK_IMPORTED_MODULE_9_lodash___default.a.sumBy(transaction.inputs.filter(function (i) {
20759 return i.type === 'veto';
20761 var outAmount = __WEBPACK_IMPORTED_MODULE_9_lodash___default.a.sumBy(transaction.outputs.filter(function (i) {
20762 return i.type === 'vote';
20764 transaction.pubkey = filterInput.vote;
20765 transaction.vAmount = __WEBPACK_IMPORTED_MODULE_10__utils_Number__["a" /* Number */].formatNue(inAmount - outAmount, 8);
20766 } else if (filterOutput) {
20767 var _outAmount = __WEBPACK_IMPORTED_MODULE_9_lodash___default.a.sumBy(transaction.outputs.filter(function (i) {
20768 return i.type === 'vote';
20770 transaction.pubkey = filterOutput.vote;
20771 transaction.vAmount = __WEBPACK_IMPORTED_MODULE_10__utils_Number__["a" /* Number */].formatNue(_outAmount, 8);
20772 transaction.type = 'vote';
20773 } else if (transaction.types.includes('out_crosschain')) {
20774 transaction.type = 'crossChain';
20775 if (_this4.netType === 'vapor') {
20776 transaction.cDirection = 'Vapor -> Bytom';
20778 transaction.cDirection = 'Bytom -> Vapor';
20780 } else if (transaction.types.includes('in_crosschain')) {
20781 transaction.type = 'crossChain';
20782 if (_this4.netType === 'vapor') {
20783 transaction.cDirection = 'Bytom -> Vapor';
20785 transaction.cDirection = 'Vapor -> Bytom';
20789 var inputAddresses = transaction.inputs.filter(function (input) {
20790 return input.asset.assetId === assetID && input.address !== _this4.currentAccount.address;
20791 }).map(function (input) {
20792 return input.address;
20795 var outputAddresses = transaction.outputs.filter(function (output) {
20796 return output.asset.assetId === assetID && output.address !== _this4.currentAccount.address;
20797 }).map(function (output) {
20798 return output.address;
20801 if (balanceObject.length === 1) {
20802 var val = Math.abs(balanceObject[0].amount);
20804 if (Number(balanceObject[0].amount) > 0) {
20805 transaction.direct = "+";
20806 var resultAddr = inputAddresses.pop();
20807 transaction.address = resultAddr && resultAddr.includes(' ') ? resultAddr : __WEBPACK_IMPORTED_MODULE_2__utils_address__["a" /* default */].short(resultAddr);
20809 transaction.direct = "-";
20810 var _resultAddr = outputAddresses.pop();
20811 transaction.address = _resultAddr && _resultAddr.includes(' ') ? _resultAddr : __WEBPACK_IMPORTED_MODULE_2__utils_address__["a" /* default */].short(_resultAddr);
20814 transaction.val = val;
20816 formattedTransactions.push(transaction);
20818 transaction.val = 0;
20819 transaction.address = __WEBPACK_IMPORTED_MODULE_2__utils_address__["a" /* default */].short(_this4.address);
20821 formattedTransactions.push(transaction);
20824 return formattedTransactions;
20826 }, Object(__WEBPACK_IMPORTED_MODULE_7_vuex__["b" /* mapActions */])([__WEBPACK_IMPORTED_MODULE_8__store_constants__["n" /* UPDATE_STORED_BYTOM */], __WEBPACK_IMPORTED_MODULE_8__store_constants__["l" /* SET_LIST_VOTE */]])),
20827 mounted: function mounted() {
20830 this.refreshTransactions(this.start, this.limit).then(function (transactions) {
20831 _this5.transactions = transactions;
20833 if (this.listVote.length == 0 && this.netType === 'vapor') {
20834 __WEBPACK_IMPORTED_MODULE_3__models_query__["a" /* default */].chainStatus().then(function (resp) {
20836 var votes = resp.consensusNodes.map(function (item, index) {
20837 item.rank = index + 1;
20840 _this5[__WEBPACK_IMPORTED_MODULE_8__store_constants__["l" /* SET_LIST_VOTE */]](votes);
20850 /***/ (function(module, exports, __webpack_require__) {
20852 // style-loader: Adds some css to the DOM by adding a <style> tag
20855 var content = __webpack_require__(628);
20856 if(typeof content === 'string') content = [[module.i, content, '']];
20857 if(content.locals) module.exports = content.locals;
20858 // add the styles to the DOM
20859 var update = __webpack_require__(84)("c4e8352e", content, true, {});
20864 /***/ (function(module, exports, __webpack_require__) {
20866 exports = module.exports = __webpack_require__(83)(false);
20871 exports.push([module.i, ".topbar[data-v-9beabd34]{font-size:19px;display:flex}.topbar .topbar-left[data-v-9beabd34]{overflow:hidden;white-space:nowrap}.topbar .topbar-middle[data-v-9beabd34]{margin-top:10px;padding:0 20px;text-align:center;width:245px}.topbar-left .btn-menu i[data-v-9beabd34]{font-size:100%}.alias[data-v-9beabd34]{font-size:13px}.content[data-v-9beabd34]{text-align:center;padding:20px 30px}.content .amount[data-v-9beabd34]{padding-bottom:10px}.content .token-amount[data-v-9beabd34]{font-size:32px;line-height:45px}.transaction-title h3[data-v-9beabd34]{font-size:16px;font-weight:inherit;padding:10px 0 10px 20px}.transactions[data-v-9beabd34]{font-size:15px;height:340px}.list-item[data-v-9beabd34]{padding:10px 20px;display:flex;justify-content:space-between;position:relative}.list-item[data-v-9beabd34]:after{content:\"\";background:#e0e0e0;position:absolute;bottom:0;left:20px;height:1px;width:90%}.addr[data-v-9beabd34]{font-size:12px}.no-record[data-v-9beabd34]{display:block}.symbol[data-v-9beabd34]{margin-bottom:-8px;font-size:15px}", ""]);
20879 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20882 var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"warp-chlid bg-white"},[_c('section',{staticClass:"bg-image"},[_c('div',{staticClass:"topbar"},[_c('div',{staticClass:"topbar-left"},[_c('i',{staticClass:"iconfont icon-back",on:{"click":_vm.close}})]),_vm._v(" "),_c('div',{staticClass:"topbar-middle"},[(_vm.currentAsset!=undefined)?_c('div',{staticClass:"amount color-white"},[(_vm.currentAsset.asset.symbol!=='Asset')?_c('div',[_c('div',{staticClass:"symbol"},[_vm._v("\n "+_vm._s(_vm.currentAsset.asset.symbol)+"\n ")]),_vm._v(" "),_c('div',{staticClass:"alias color-grey"},[_vm._v(_vm._s(_vm.currentAsset.asset.name))])]):_c('div',[_c('div',{staticClass:"symbol"},[_vm._v("\n Asset\n ")]),_vm._v(" "),_c('div',{staticClass:"alias color-grey"},[_vm._v(_vm._s(_vm.shortAddress(_vm.currentAsset.asset.asset)))])])]):_vm._e()])]),_vm._v(" "),_c('div',{staticClass:"content"},[(_vm.currentAsset!=undefined)?_c('div',{staticClass:"amount color-white"},[_c('div',{staticClass:"token-amount"},[_vm._v("\n "+_vm._s(_vm.itemBalance(_vm.currentAsset))+"\n ")]),_vm._v(" "),_c('div',[_vm._v(_vm._s(_vm.formatCurrency(_vm.currentAsset[ _vm.camelize(_vm.currency) ])))])]):_vm._e()])]),_vm._v(" "),_c('section',{staticClass:"transaction-title"},[_c('h3',{staticClass:"bg-gray color-grey"},[_vm._v(_vm._s(_vm.$t('main.record')))])]),_vm._v(" "),_c('section',{staticClass:"transactions"},[(_vm.transactions.length != 0)?_c('div',{staticClass:"transactions"},[_c('vue-scroll',{ref:"vs",on:{"handle-scroll":_vm.handleScroll}},[_c('ul',{staticClass:"list"},_vm._l((_vm.transactions),function(transaction,index){return _c('li',{key:index,staticClass:"list-item",on:{"click":function($event){_vm.$router.push({name: 'transfer-info', params: {transaction: transaction, address: _vm.currentAccount.address}})}}},[_c('div',[_c('div',[_vm._v(_vm._s(transaction.address))]),_vm._v(" "),(transaction.hasOwnProperty('blockTimestamp'))?_c('div',{staticClass:"addr color-grey"},[_vm._v("\n "+_vm._s(_vm._f("moment")(transaction.submissionTimestamp))+"\n ")]):_c('div',{staticClass:"addr color-grey"},[_vm._v("\n "+_vm._s(_vm.$t('main.unconfirmed'))+"\n ")])]),_vm._v(" "),_c('div',{staticClass:"text-align-right"},[_c('div',{staticClass:"value"},[_vm._v(_vm._s(transaction.direct)+" "+_vm._s(transaction.val))]),_vm._v(" "),(transaction.type == 'vote')?_c('div',{staticClass:"addr color-grey"},[_vm._v(_vm._s(_vm.$t('listVote.vote'))+" "+_vm._s(transaction.vAmount))]):(transaction.type == 'veto')?_c('div',{staticClass:"addr color-grey"},[_vm._v(_vm._s(_vm.$t('listVote.cancelVote'))+" "+_vm._s(transaction.vAmount))]):(transaction.type == 'crossChain')?_c('div',{staticClass:"addr color-grey"},[_vm._v(_vm._s(_vm.$t('crossChain.title')))]):_vm._e()])])}))])],1):_c('div',[_c('div',{staticClass:"bg-emptytx"}),_vm._v(" "),_c('div',[_c('span',{staticClass:"color-lightgrey center-text no-record"},[_vm._v(_vm._s(_vm.$t('main.noRecord')))])])])])])}
20883 var staticRenderFns = []
20884 var esExports = { render: render, staticRenderFns: staticRenderFns }
20885 /* harmony default export */ __webpack_exports__["a"] = (esExports);
20890 //# sourceMappingURL=11.js.map