3 * Lodash <https://lodash.com/>
4 * Copyright JS Foundation and other contributors <https://js.foundation/>
5 * Released under MIT license <https://lodash.com/license>
6 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11 /** Used as a safe reference for `undefined` in pre-ES5 environments. */
14 /** Used as the semantic version number. */
15 var VERSION = '4.17.4';
17 /** Used as the size to enable large array optimizations. */
18 var LARGE_ARRAY_SIZE = 200;
20 /** Error message constants. */
21 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
22 FUNC_ERROR_TEXT = 'Expected a function';
24 /** Used to stand-in for `undefined` hash values. */
25 var HASH_UNDEFINED = '__lodash_hash_undefined__';
27 /** Used as the maximum memoize cache size. */
28 var MAX_MEMOIZE_SIZE = 500;
30 /** Used as the internal argument placeholder. */
31 var PLACEHOLDER = '__lodash_placeholder__';
33 /** Used to compose bitmasks for cloning. */
34 var CLONE_DEEP_FLAG = 1,
36 CLONE_SYMBOLS_FLAG = 4;
38 /** Used to compose bitmasks for value comparisons. */
39 var COMPARE_PARTIAL_FLAG = 1,
40 COMPARE_UNORDERED_FLAG = 2;
42 /** Used to compose bitmasks for function metadata. */
43 var WRAP_BIND_FLAG = 1,
44 WRAP_BIND_KEY_FLAG = 2,
45 WRAP_CURRY_BOUND_FLAG = 4,
47 WRAP_CURRY_RIGHT_FLAG = 16,
48 WRAP_PARTIAL_FLAG = 32,
49 WRAP_PARTIAL_RIGHT_FLAG = 64,
51 WRAP_REARG_FLAG = 256,
54 /** Used as default options for `_.truncate`. */
55 var DEFAULT_TRUNC_LENGTH = 30,
56 DEFAULT_TRUNC_OMISSION = '...';
58 /** Used to detect hot functions by number of calls within a span of milliseconds. */
62 /** Used to indicate the type of lazy iteratees. */
63 var LAZY_FILTER_FLAG = 1,
67 /** Used as references for various `Number` constants. */
69 MAX_SAFE_INTEGER = 9007199254740991,
70 MAX_INTEGER = 1.7976931348623157e+308,
73 /** Used as references for the maximum length and index of an array. */
74 var MAX_ARRAY_LENGTH = 4294967295,
75 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
76 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
78 /** Used to associate wrap methods with their bit flags. */
80 ['ary', WRAP_ARY_FLAG],
81 ['bind', WRAP_BIND_FLAG],
82 ['bindKey', WRAP_BIND_KEY_FLAG],
83 ['curry', WRAP_CURRY_FLAG],
84 ['curryRight', WRAP_CURRY_RIGHT_FLAG],
85 ['flip', WRAP_FLIP_FLAG],
86 ['partial', WRAP_PARTIAL_FLAG],
87 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
88 ['rearg', WRAP_REARG_FLAG]
91 /** `Object#toString` result references. */
92 var argsTag = '[object Arguments]',
93 arrayTag = '[object Array]',
94 asyncTag = '[object AsyncFunction]',
95 boolTag = '[object Boolean]',
96 dateTag = '[object Date]',
97 domExcTag = '[object DOMException]',
98 errorTag = '[object Error]',
99 funcTag = '[object Function]',
100 genTag = '[object GeneratorFunction]',
101 mapTag = '[object Map]',
102 numberTag = '[object Number]',
103 nullTag = '[object Null]',
104 objectTag = '[object Object]',
105 promiseTag = '[object Promise]',
106 proxyTag = '[object Proxy]',
107 regexpTag = '[object RegExp]',
108 setTag = '[object Set]',
109 stringTag = '[object String]',
110 symbolTag = '[object Symbol]',
111 undefinedTag = '[object Undefined]',
112 weakMapTag = '[object WeakMap]',
113 weakSetTag = '[object WeakSet]';
115 var arrayBufferTag = '[object ArrayBuffer]',
116 dataViewTag = '[object DataView]',
117 float32Tag = '[object Float32Array]',
118 float64Tag = '[object Float64Array]',
119 int8Tag = '[object Int8Array]',
120 int16Tag = '[object Int16Array]',
121 int32Tag = '[object Int32Array]',
122 uint8Tag = '[object Uint8Array]',
123 uint8ClampedTag = '[object Uint8ClampedArray]',
124 uint16Tag = '[object Uint16Array]',
125 uint32Tag = '[object Uint32Array]';
127 /** Used to match empty string literals in compiled template source. */
128 var reEmptyStringLeading = /\b__p \+= '';/g,
129 reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
130 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
132 /** Used to match HTML entities and HTML characters. */
133 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
134 reUnescapedHtml = /[&<>"']/g,
135 reHasEscapedHtml = RegExp(reEscapedHtml.source),
136 reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
138 /** Used to match template delimiters. */
139 var reEscape = /<%-([\s\S]+?)%>/g,
140 reEvaluate = /<%([\s\S]+?)%>/g,
141 reInterpolate = /<%=([\s\S]+?)%>/g;
143 /** Used to match property names within property paths. */
144 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
145 reIsPlainProp = /^\w*$/,
146 reLeadingDot = /^\./,
147 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
150 * Used to match `RegExp`
151 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
153 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
154 reHasRegExpChar = RegExp(reRegExpChar.source);
156 /** Used to match leading and trailing whitespace. */
157 var reTrim = /^\s+|\s+$/g,
158 reTrimStart = /^\s+/,
161 /** Used to match wrap detail comments. */
162 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
163 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
164 reSplitDetails = /,? & /;
166 /** Used to match words composed of alphanumeric characters. */
167 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
169 /** Used to match backslashes in property paths. */
170 var reEscapeChar = /\\(\\)?/g;
174 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
176 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
178 /** Used to match `RegExp` flags from their coerced string values. */
179 var reFlags = /\w*$/;
181 /** Used to detect bad signed hexadecimal string values. */
182 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
184 /** Used to detect binary string values. */
185 var reIsBinary = /^0b[01]+$/i;
187 /** Used to detect host constructors (Safari). */
188 var reIsHostCtor = /^\[object .+?Constructor\]$/;
190 /** Used to detect octal string values. */
191 var reIsOctal = /^0o[0-7]+$/i;
193 /** Used to detect unsigned integer values. */
194 var reIsUint = /^(?:0|[1-9]\d*)$/;
196 /** Used to match Latin Unicode letters (excluding mathematical operators). */
197 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
199 /** Used to ensure capturing order of template delimiters. */
200 var reNoMatch = /($^)/;
202 /** Used to match unescaped characters in compiled string literals. */
203 var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
205 /** Used to compose unicode character classes. */
206 var rsAstralRange = '\\ud800-\\udfff',
207 rsComboMarksRange = '\\u0300-\\u036f',
208 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
209 rsComboSymbolsRange = '\\u20d0-\\u20ff',
210 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
211 rsDingbatRange = '\\u2700-\\u27bf',
212 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
213 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
214 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
215 rsPunctuationRange = '\\u2000-\\u206f',
216 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
217 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
218 rsVarRange = '\\ufe0e\\ufe0f',
219 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
221 /** Used to compose unicode capture groups. */
222 var rsApos = "['\u2019]",
223 rsAstral = '[' + rsAstralRange + ']',
224 rsBreak = '[' + rsBreakRange + ']',
225 rsCombo = '[' + rsComboRange + ']',
227 rsDingbat = '[' + rsDingbatRange + ']',
228 rsLower = '[' + rsLowerRange + ']',
229 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
230 rsFitz = '\\ud83c[\\udffb-\\udfff]',
231 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
232 rsNonAstral = '[^' + rsAstralRange + ']',
233 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
234 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
235 rsUpper = '[' + rsUpperRange + ']',
238 /** Used to compose unicode regexes. */
239 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
240 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
241 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
242 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
243 reOptMod = rsModifier + '?',
244 rsOptVar = '[' + rsVarRange + ']?',
245 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
246 rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
247 rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
248 rsSeq = rsOptVar + reOptMod + rsOptJoin,
249 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
250 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
252 /** Used to match apostrophes. */
253 var reApos = RegExp(rsApos, 'g');
256 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
257 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
259 var reComboMark = RegExp(rsCombo, 'g');
261 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
262 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
264 /** Used to match complex or compound words. */
265 var reUnicodeWord = RegExp([
266 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
267 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
268 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
269 rsUpper + '+' + rsOptContrUpper,
276 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
277 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
279 /** Used to detect strings that need a more robust regexp to match words. */
280 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
282 /** Used to assign default `context` object properties. */
284 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
285 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
286 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
287 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
288 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
291 /** Used to make template sourceURLs easier to identify. */
292 var templateCounter = -1;
294 /** Used to identify `toStringTag` values of typed arrays. */
295 var typedArrayTags = {};
296 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
297 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
298 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
299 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
300 typedArrayTags[uint32Tag] = true;
301 typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
302 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
303 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
304 typedArrayTags[errorTag] = typedArrayTags[funcTag] =
305 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
306 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
307 typedArrayTags[setTag] = typedArrayTags[stringTag] =
308 typedArrayTags[weakMapTag] = false;
310 /** Used to identify `toStringTag` values supported by `_.clone`. */
311 var cloneableTags = {};
312 cloneableTags[argsTag] = cloneableTags[arrayTag] =
313 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
314 cloneableTags[boolTag] = cloneableTags[dateTag] =
315 cloneableTags[float32Tag] = cloneableTags[float64Tag] =
316 cloneableTags[int8Tag] = cloneableTags[int16Tag] =
317 cloneableTags[int32Tag] = cloneableTags[mapTag] =
318 cloneableTags[numberTag] = cloneableTags[objectTag] =
319 cloneableTags[regexpTag] = cloneableTags[setTag] =
320 cloneableTags[stringTag] = cloneableTags[symbolTag] =
321 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
322 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
323 cloneableTags[errorTag] = cloneableTags[funcTag] =
324 cloneableTags[weakMapTag] = false;
326 /** Used to map Latin Unicode letters to basic Latin letters. */
327 var deburredLetters = {
328 // Latin-1 Supplement block.
329 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
330 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
331 '\xc7': 'C', '\xe7': 'c',
332 '\xd0': 'D', '\xf0': 'd',
333 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
334 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
335 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
336 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
337 '\xd1': 'N', '\xf1': 'n',
338 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
339 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
340 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
341 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
342 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
343 '\xc6': 'Ae', '\xe6': 'ae',
344 '\xde': 'Th', '\xfe': 'th',
346 // Latin Extended-A block.
347 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
348 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
349 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
350 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
351 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
352 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
353 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
354 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
355 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
356 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
357 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
358 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
359 '\u0134': 'J', '\u0135': 'j',
360 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
361 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
362 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
363 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
364 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
365 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
366 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
367 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
368 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
369 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
370 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
371 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
372 '\u0163': 't', '\u0165': 't', '\u0167': 't',
373 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
374 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
375 '\u0174': 'W', '\u0175': 'w',
376 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
377 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
378 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
379 '\u0132': 'IJ', '\u0133': 'ij',
380 '\u0152': 'Oe', '\u0153': 'oe',
381 '\u0149': "'n", '\u017f': 's'
384 /** Used to map characters to HTML entities. */
393 /** Used to map HTML entities to characters. */
394 var htmlUnescapes = {
402 /** Used to escape characters for inclusion in compiled string literals. */
403 var stringEscapes = {
412 /** Built-in method references without a dependency on `root`. */
413 var freeParseFloat = parseFloat,
414 freeParseInt = parseInt;
416 /** Detect free variable `global` from Node.js. */
417 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
419 /** Detect free variable `self`. */
420 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
422 /** Used as a reference to the global object. */
423 var root = freeGlobal || freeSelf || Function('return this')();
425 /** Detect free variable `exports`. */
426 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
428 /** Detect free variable `module`. */
429 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
431 /** Detect the popular CommonJS extension `module.exports`. */
432 var moduleExports = freeModule && freeModule.exports === freeExports;
434 /** Detect free variable `process` from Node.js. */
435 var freeProcess = moduleExports && freeGlobal.process;
437 /** Used to access faster Node.js helpers. */
438 var nodeUtil = (function() {
440 return freeProcess && freeProcess.binding && freeProcess.binding('util');
444 /* Node.js helper references. */
445 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
446 nodeIsDate = nodeUtil && nodeUtil.isDate,
447 nodeIsMap = nodeUtil && nodeUtil.isMap,
448 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
449 nodeIsSet = nodeUtil && nodeUtil.isSet,
450 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
452 /*--------------------------------------------------------------------------*/
455 * Adds the key-value `pair` to `map`.
458 * @param {Object} map The map to modify.
459 * @param {Array} pair The key-value pair to add.
460 * @returns {Object} Returns `map`.
462 function addMapEntry(map, pair) {
463 // Don't return `map.set` because it's not chainable in IE 11.
464 map.set(pair[0], pair[1]);
469 * Adds `value` to `set`.
472 * @param {Object} set The set to modify.
473 * @param {*} value The value to add.
474 * @returns {Object} Returns `set`.
476 function addSetEntry(set, value) {
477 // Don't return `set.add` because it's not chainable in IE 11.
483 * A faster alternative to `Function#apply`, this function invokes `func`
484 * with the `this` binding of `thisArg` and the arguments of `args`.
487 * @param {Function} func The function to invoke.
488 * @param {*} thisArg The `this` binding of `func`.
489 * @param {Array} args The arguments to invoke `func` with.
490 * @returns {*} Returns the result of `func`.
492 function apply(func, thisArg, args) {
493 switch (args.length) {
494 case 0: return func.call(thisArg);
495 case 1: return func.call(thisArg, args[0]);
496 case 2: return func.call(thisArg, args[0], args[1]);
497 case 3: return func.call(thisArg, args[0], args[1], args[2]);
499 return func.apply(thisArg, args);
503 * A specialized version of `baseAggregator` for arrays.
506 * @param {Array} [array] The array to iterate over.
507 * @param {Function} setter The function to set `accumulator` values.
508 * @param {Function} iteratee The iteratee to transform keys.
509 * @param {Object} accumulator The initial aggregated object.
510 * @returns {Function} Returns `accumulator`.
512 function arrayAggregator(array, setter, iteratee, accumulator) {
514 length = array == null ? 0 : array.length;
516 while (++index < length) {
517 var value = array[index];
518 setter(accumulator, value, iteratee(value), array);
524 * A specialized version of `_.forEach` for arrays without support for
525 * iteratee shorthands.
528 * @param {Array} [array] The array to iterate over.
529 * @param {Function} iteratee The function invoked per iteration.
530 * @returns {Array} Returns `array`.
532 function arrayEach(array, iteratee) {
534 length = array == null ? 0 : array.length;
536 while (++index < length) {
537 if (iteratee(array[index], index, array) === false) {
545 * A specialized version of `_.forEachRight` for arrays without support for
546 * iteratee shorthands.
549 * @param {Array} [array] The array to iterate over.
550 * @param {Function} iteratee The function invoked per iteration.
551 * @returns {Array} Returns `array`.
553 function arrayEachRight(array, iteratee) {
554 var length = array == null ? 0 : array.length;
557 if (iteratee(array[length], length, array) === false) {
565 * A specialized version of `_.every` for arrays without support for
566 * iteratee shorthands.
569 * @param {Array} [array] The array to iterate over.
570 * @param {Function} predicate The function invoked per iteration.
571 * @returns {boolean} Returns `true` if all elements pass the predicate check,
574 function arrayEvery(array, predicate) {
576 length = array == null ? 0 : array.length;
578 while (++index < length) {
579 if (!predicate(array[index], index, array)) {
587 * A specialized version of `_.filter` for arrays without support for
588 * iteratee shorthands.
591 * @param {Array} [array] The array to iterate over.
592 * @param {Function} predicate The function invoked per iteration.
593 * @returns {Array} Returns the new filtered array.
595 function arrayFilter(array, predicate) {
597 length = array == null ? 0 : array.length,
601 while (++index < length) {
602 var value = array[index];
603 if (predicate(value, index, array)) {
604 result[resIndex++] = value;
611 * A specialized version of `_.includes` for arrays without support for
612 * specifying an index to search from.
615 * @param {Array} [array] The array to inspect.
616 * @param {*} target The value to search for.
617 * @returns {boolean} Returns `true` if `target` is found, else `false`.
619 function arrayIncludes(array, value) {
620 var length = array == null ? 0 : array.length;
621 return !!length && baseIndexOf(array, value, 0) > -1;
625 * This function is like `arrayIncludes` except that it accepts a comparator.
628 * @param {Array} [array] The array to inspect.
629 * @param {*} target The value to search for.
630 * @param {Function} comparator The comparator invoked per element.
631 * @returns {boolean} Returns `true` if `target` is found, else `false`.
633 function arrayIncludesWith(array, value, comparator) {
635 length = array == null ? 0 : array.length;
637 while (++index < length) {
638 if (comparator(value, array[index])) {
646 * A specialized version of `_.map` for arrays without support for iteratee
650 * @param {Array} [array] The array to iterate over.
651 * @param {Function} iteratee The function invoked per iteration.
652 * @returns {Array} Returns the new mapped array.
654 function arrayMap(array, iteratee) {
656 length = array == null ? 0 : array.length,
657 result = Array(length);
659 while (++index < length) {
660 result[index] = iteratee(array[index], index, array);
666 * Appends the elements of `values` to `array`.
669 * @param {Array} array The array to modify.
670 * @param {Array} values The values to append.
671 * @returns {Array} Returns `array`.
673 function arrayPush(array, values) {
675 length = values.length,
676 offset = array.length;
678 while (++index < length) {
679 array[offset + index] = values[index];
685 * A specialized version of `_.reduce` for arrays without support for
686 * iteratee shorthands.
689 * @param {Array} [array] The array to iterate over.
690 * @param {Function} iteratee The function invoked per iteration.
691 * @param {*} [accumulator] The initial value.
692 * @param {boolean} [initAccum] Specify using the first element of `array` as
694 * @returns {*} Returns the accumulated value.
696 function arrayReduce(array, iteratee, accumulator, initAccum) {
698 length = array == null ? 0 : array.length;
700 if (initAccum && length) {
701 accumulator = array[++index];
703 while (++index < length) {
704 accumulator = iteratee(accumulator, array[index], index, array);
710 * A specialized version of `_.reduceRight` for arrays without support for
711 * iteratee shorthands.
714 * @param {Array} [array] The array to iterate over.
715 * @param {Function} iteratee The function invoked per iteration.
716 * @param {*} [accumulator] The initial value.
717 * @param {boolean} [initAccum] Specify using the last element of `array` as
719 * @returns {*} Returns the accumulated value.
721 function arrayReduceRight(array, iteratee, accumulator, initAccum) {
722 var length = array == null ? 0 : array.length;
723 if (initAccum && length) {
724 accumulator = array[--length];
727 accumulator = iteratee(accumulator, array[length], length, array);
733 * A specialized version of `_.some` for arrays without support for iteratee
737 * @param {Array} [array] The array to iterate over.
738 * @param {Function} predicate The function invoked per iteration.
739 * @returns {boolean} Returns `true` if any element passes the predicate check,
742 function arraySome(array, predicate) {
744 length = array == null ? 0 : array.length;
746 while (++index < length) {
747 if (predicate(array[index], index, array)) {
755 * Gets the size of an ASCII `string`.
758 * @param {string} string The string inspect.
759 * @returns {number} Returns the string size.
761 var asciiSize = baseProperty('length');
764 * Converts an ASCII `string` to an array.
767 * @param {string} string The string to convert.
768 * @returns {Array} Returns the converted array.
770 function asciiToArray(string) {
771 return string.split('');
775 * Splits an ASCII `string` into an array of its words.
778 * @param {string} The string to inspect.
779 * @returns {Array} Returns the words of `string`.
781 function asciiWords(string) {
782 return string.match(reAsciiWord) || [];
786 * The base implementation of methods like `_.findKey` and `_.findLastKey`,
787 * without support for iteratee shorthands, which iterates over `collection`
791 * @param {Array|Object} collection The collection to inspect.
792 * @param {Function} predicate The function invoked per iteration.
793 * @param {Function} eachFunc The function to iterate over `collection`.
794 * @returns {*} Returns the found element or its key, else `undefined`.
796 function baseFindKey(collection, predicate, eachFunc) {
798 eachFunc(collection, function(value, key, collection) {
799 if (predicate(value, key, collection)) {
808 * The base implementation of `_.findIndex` and `_.findLastIndex` without
809 * support for iteratee shorthands.
812 * @param {Array} array The array to inspect.
813 * @param {Function} predicate The function invoked per iteration.
814 * @param {number} fromIndex The index to search from.
815 * @param {boolean} [fromRight] Specify iterating from right to left.
816 * @returns {number} Returns the index of the matched value, else `-1`.
818 function baseFindIndex(array, predicate, fromIndex, fromRight) {
819 var length = array.length,
820 index = fromIndex + (fromRight ? 1 : -1);
822 while ((fromRight ? index-- : ++index < length)) {
823 if (predicate(array[index], index, array)) {
831 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
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 * @returns {number} Returns the index of the matched value, else `-1`.
839 function baseIndexOf(array, value, fromIndex) {
840 return value === value
841 ? strictIndexOf(array, value, fromIndex)
842 : baseFindIndex(array, baseIsNaN, fromIndex);
846 * This function is like `baseIndexOf` except that it accepts a comparator.
849 * @param {Array} array The array to inspect.
850 * @param {*} value The value to search for.
851 * @param {number} fromIndex The index to search from.
852 * @param {Function} comparator The comparator invoked per element.
853 * @returns {number} Returns the index of the matched value, else `-1`.
855 function baseIndexOfWith(array, value, fromIndex, comparator) {
856 var index = fromIndex - 1,
857 length = array.length;
859 while (++index < length) {
860 if (comparator(array[index], value)) {
868 * The base implementation of `_.isNaN` without support for number objects.
871 * @param {*} value The value to check.
872 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
874 function baseIsNaN(value) {
875 return value !== value;
879 * The base implementation of `_.mean` and `_.meanBy` without support for
880 * iteratee shorthands.
883 * @param {Array} array The array to iterate over.
884 * @param {Function} iteratee The function invoked per iteration.
885 * @returns {number} Returns the mean.
887 function baseMean(array, iteratee) {
888 var length = array == null ? 0 : array.length;
889 return length ? (baseSum(array, iteratee) / length) : NAN;
893 * The base implementation of `_.property` without support for deep paths.
896 * @param {string} key The key of the property to get.
897 * @returns {Function} Returns the new accessor function.
899 function baseProperty(key) {
900 return function(object) {
901 return object == null ? undefined : object[key];
906 * The base implementation of `_.propertyOf` without support for deep paths.
909 * @param {Object} object The object to query.
910 * @returns {Function} Returns the new accessor function.
912 function basePropertyOf(object) {
913 return function(key) {
914 return object == null ? undefined : object[key];
919 * The base implementation of `_.reduce` and `_.reduceRight`, without support
920 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
923 * @param {Array|Object} collection The collection to iterate over.
924 * @param {Function} iteratee The function invoked per iteration.
925 * @param {*} accumulator The initial value.
926 * @param {boolean} initAccum Specify using the first or last element of
927 * `collection` as the initial value.
928 * @param {Function} eachFunc The function to iterate over `collection`.
929 * @returns {*} Returns the accumulated value.
931 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
932 eachFunc(collection, function(value, index, collection) {
933 accumulator = initAccum
934 ? (initAccum = false, value)
935 : iteratee(accumulator, value, index, collection);
941 * The base implementation of `_.sortBy` which uses `comparer` to define the
942 * sort order of `array` and replaces criteria objects with their corresponding
946 * @param {Array} array The array to sort.
947 * @param {Function} comparer The function to define sort order.
948 * @returns {Array} Returns `array`.
950 function baseSortBy(array, comparer) {
951 var length = array.length;
953 array.sort(comparer);
955 array[length] = array[length].value;
961 * The base implementation of `_.sum` and `_.sumBy` without support for
962 * iteratee shorthands.
965 * @param {Array} array The array to iterate over.
966 * @param {Function} iteratee The function invoked per iteration.
967 * @returns {number} Returns the sum.
969 function baseSum(array, iteratee) {
972 length = array.length;
974 while (++index < length) {
975 var current = iteratee(array[index]);
976 if (current !== undefined) {
977 result = result === undefined ? current : (result + current);
984 * The base implementation of `_.times` without support for iteratee shorthands
985 * or max array length checks.
988 * @param {number} n The number of times to invoke `iteratee`.
989 * @param {Function} iteratee The function invoked per iteration.
990 * @returns {Array} Returns the array of results.
992 function baseTimes(n, iteratee) {
996 while (++index < n) {
997 result[index] = iteratee(index);
1003 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
1004 * of key-value pairs for `object` corresponding to the property names of `props`.
1007 * @param {Object} object The object to query.
1008 * @param {Array} props The property names to get values for.
1009 * @returns {Object} Returns the key-value pairs.
1011 function baseToPairs(object, props) {
1012 return arrayMap(props, function(key) {
1013 return [key, object[key]];
1018 * The base implementation of `_.unary` without support for storing metadata.
1021 * @param {Function} func The function to cap arguments for.
1022 * @returns {Function} Returns the new capped function.
1024 function baseUnary(func) {
1025 return function(value) {
1031 * The base implementation of `_.values` and `_.valuesIn` which creates an
1032 * array of `object` property values corresponding to the property names
1036 * @param {Object} object The object to query.
1037 * @param {Array} props The property names to get values for.
1038 * @returns {Object} Returns the array of property values.
1040 function baseValues(object, props) {
1041 return arrayMap(props, function(key) {
1047 * Checks if a `cache` value for `key` exists.
1050 * @param {Object} cache The cache to query.
1051 * @param {string} key The key of the entry to check.
1052 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1054 function cacheHas(cache, key) {
1055 return cache.has(key);
1059 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1060 * that is not found in the character symbols.
1063 * @param {Array} strSymbols The string symbols to inspect.
1064 * @param {Array} chrSymbols The character symbols to find.
1065 * @returns {number} Returns the index of the first unmatched string symbol.
1067 function charsStartIndex(strSymbols, chrSymbols) {
1069 length = strSymbols.length;
1071 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1076 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1077 * that is not found in the character symbols.
1080 * @param {Array} strSymbols The string symbols to inspect.
1081 * @param {Array} chrSymbols The character symbols to find.
1082 * @returns {number} Returns the index of the last unmatched string symbol.
1084 function charsEndIndex(strSymbols, chrSymbols) {
1085 var index = strSymbols.length;
1087 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1092 * Gets the number of `placeholder` occurrences in `array`.
1095 * @param {Array} array The array to inspect.
1096 * @param {*} placeholder The placeholder to search for.
1097 * @returns {number} Returns the placeholder count.
1099 function countHolders(array, placeholder) {
1100 var length = array.length,
1104 if (array[length] === placeholder) {
1112 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1113 * letters to basic Latin letters.
1116 * @param {string} letter The matched letter to deburr.
1117 * @returns {string} Returns the deburred letter.
1119 var deburrLetter = basePropertyOf(deburredLetters);
1122 * Used by `_.escape` to convert characters to HTML entities.
1125 * @param {string} chr The matched character to escape.
1126 * @returns {string} Returns the escaped character.
1128 var escapeHtmlChar = basePropertyOf(htmlEscapes);
1131 * Used by `_.template` to escape characters for inclusion in compiled string literals.
1134 * @param {string} chr The matched character to escape.
1135 * @returns {string} Returns the escaped character.
1137 function escapeStringChar(chr) {
1138 return '\\' + stringEscapes[chr];
1142 * Gets the value at `key` of `object`.
1145 * @param {Object} [object] The object to query.
1146 * @param {string} key The key of the property to get.
1147 * @returns {*} Returns the property value.
1149 function getValue(object, key) {
1150 return object == null ? undefined : object[key];
1154 * Checks if `string` contains Unicode symbols.
1157 * @param {string} string The string to inspect.
1158 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1160 function hasUnicode(string) {
1161 return reHasUnicode.test(string);
1165 * Checks if `string` contains a word composed of Unicode symbols.
1168 * @param {string} string The string to inspect.
1169 * @returns {boolean} Returns `true` if a word is found, else `false`.
1171 function hasUnicodeWord(string) {
1172 return reHasUnicodeWord.test(string);
1176 * Converts `iterator` to an array.
1179 * @param {Object} iterator The iterator to convert.
1180 * @returns {Array} Returns the converted array.
1182 function iteratorToArray(iterator) {
1186 while (!(data = iterator.next()).done) {
1187 result.push(data.value);
1193 * Converts `map` to its key-value pairs.
1196 * @param {Object} map The map to convert.
1197 * @returns {Array} Returns the key-value pairs.
1199 function mapToArray(map) {
1201 result = Array(map.size);
1203 map.forEach(function(value, key) {
1204 result[++index] = [key, value];
1210 * Creates a unary function that invokes `func` with its argument transformed.
1213 * @param {Function} func The function to wrap.
1214 * @param {Function} transform The argument transform.
1215 * @returns {Function} Returns the new function.
1217 function overArg(func, transform) {
1218 return function(arg) {
1219 return func(transform(arg));
1224 * Replaces all `placeholder` elements in `array` with an internal placeholder
1225 * and returns an array of their indexes.
1228 * @param {Array} array The array to modify.
1229 * @param {*} placeholder The placeholder to replace.
1230 * @returns {Array} Returns the new array of placeholder indexes.
1232 function replaceHolders(array, placeholder) {
1234 length = array.length,
1238 while (++index < length) {
1239 var value = array[index];
1240 if (value === placeholder || value === PLACEHOLDER) {
1241 array[index] = PLACEHOLDER;
1242 result[resIndex++] = index;
1249 * Converts `set` to an array of its values.
1252 * @param {Object} set The set to convert.
1253 * @returns {Array} Returns the values.
1255 function setToArray(set) {
1257 result = Array(set.size);
1259 set.forEach(function(value) {
1260 result[++index] = value;
1266 * Converts `set` to its value-value pairs.
1269 * @param {Object} set The set to convert.
1270 * @returns {Array} Returns the value-value pairs.
1272 function setToPairs(set) {
1274 result = Array(set.size);
1276 set.forEach(function(value) {
1277 result[++index] = [value, value];
1283 * A specialized version of `_.indexOf` which performs strict equality
1284 * comparisons of values, i.e. `===`.
1287 * @param {Array} array The array to inspect.
1288 * @param {*} value The value to search for.
1289 * @param {number} fromIndex The index to search from.
1290 * @returns {number} Returns the index of the matched value, else `-1`.
1292 function strictIndexOf(array, value, fromIndex) {
1293 var index = fromIndex - 1,
1294 length = array.length;
1296 while (++index < length) {
1297 if (array[index] === value) {
1305 * A specialized version of `_.lastIndexOf` which performs strict equality
1306 * comparisons of values, i.e. `===`.
1309 * @param {Array} array The array to inspect.
1310 * @param {*} value The value to search for.
1311 * @param {number} fromIndex The index to search from.
1312 * @returns {number} Returns the index of the matched value, else `-1`.
1314 function strictLastIndexOf(array, value, fromIndex) {
1315 var index = fromIndex + 1;
1317 if (array[index] === value) {
1325 * Gets the number of symbols in `string`.
1328 * @param {string} string The string to inspect.
1329 * @returns {number} Returns the string size.
1331 function stringSize(string) {
1332 return hasUnicode(string)
1333 ? unicodeSize(string)
1334 : asciiSize(string);
1338 * Converts `string` to an array.
1341 * @param {string} string The string to convert.
1342 * @returns {Array} Returns the converted array.
1344 function stringToArray(string) {
1345 return hasUnicode(string)
1346 ? unicodeToArray(string)
1347 : asciiToArray(string);
1351 * Used by `_.unescape` to convert HTML entities to characters.
1354 * @param {string} chr The matched character to unescape.
1355 * @returns {string} Returns the unescaped character.
1357 var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1360 * Gets the size of a Unicode `string`.
1363 * @param {string} string The string inspect.
1364 * @returns {number} Returns the string size.
1366 function unicodeSize(string) {
1367 var result = reUnicode.lastIndex = 0;
1368 while (reUnicode.test(string)) {
1375 * Converts a Unicode `string` to an array.
1378 * @param {string} string The string to convert.
1379 * @returns {Array} Returns the converted array.
1381 function unicodeToArray(string) {
1382 return string.match(reUnicode) || [];
1386 * Splits a Unicode `string` into an array of its words.
1389 * @param {string} The string to inspect.
1390 * @returns {Array} Returns the words of `string`.
1392 function unicodeWords(string) {
1393 return string.match(reUnicodeWord) || [];
1396 /*--------------------------------------------------------------------------*/
1399 * Create a new pristine `lodash` function using the `context` object.
1405 * @param {Object} [context=root] The context object.
1406 * @returns {Function} Returns a new `lodash` function.
1409 * _.mixin({ 'foo': _.constant('foo') });
1411 * var lodash = _.runInContext();
1412 * lodash.mixin({ 'bar': lodash.constant('bar') });
1414 * _.isFunction(_.foo);
1416 * _.isFunction(_.bar);
1419 * lodash.isFunction(lodash.foo);
1421 * lodash.isFunction(lodash.bar);
1424 * // Create a suped-up `defer` in Node.js.
1425 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1427 var runInContext = (function runInContext(context) {
1428 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1430 /** Built-in constructor references. */
1431 var Array = context.Array,
1432 Date = context.Date,
1433 Error = context.Error,
1434 Function = context.Function,
1435 Math = context.Math,
1436 Object = context.Object,
1437 RegExp = context.RegExp,
1438 String = context.String,
1439 TypeError = context.TypeError;
1441 /** Used for built-in method references. */
1442 var arrayProto = Array.prototype,
1443 funcProto = Function.prototype,
1444 objectProto = Object.prototype;
1446 /** Used to detect overreaching core-js shims. */
1447 var coreJsData = context['__core-js_shared__'];
1449 /** Used to resolve the decompiled source of functions. */
1450 var funcToString = funcProto.toString;
1452 /** Used to check objects for own properties. */
1453 var hasOwnProperty = objectProto.hasOwnProperty;
1455 /** Used to generate unique IDs. */
1458 /** Used to detect methods masquerading as native. */
1459 var maskSrcKey = (function() {
1460 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1461 return uid ? ('Symbol(src)_1.' + uid) : '';
1465 * Used to resolve the
1466 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1469 var nativeObjectToString = objectProto.toString;
1471 /** Used to infer the `Object` constructor. */
1472 var objectCtorString = funcToString.call(Object);
1474 /** Used to restore the original `_` reference in `_.noConflict`. */
1475 var oldDash = root._;
1477 /** Used to detect if a method is native. */
1478 var reIsNative = RegExp('^' +
1479 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1480 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1483 /** Built-in value references. */
1484 var Buffer = moduleExports ? context.Buffer : undefined,
1485 Symbol = context.Symbol,
1486 Uint8Array = context.Uint8Array,
1487 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
1488 getPrototype = overArg(Object.getPrototypeOf, Object),
1489 objectCreate = Object.create,
1490 propertyIsEnumerable = objectProto.propertyIsEnumerable,
1491 splice = arrayProto.splice,
1492 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
1493 symIterator = Symbol ? Symbol.iterator : undefined,
1494 symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1496 var defineProperty = (function() {
1498 var func = getNative(Object, 'defineProperty');
1504 /** Mocked built-ins. */
1505 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
1506 ctxNow = Date && Date.now !== root.Date.now && Date.now,
1507 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1509 /* Built-in method references for those with the same name as other `lodash` methods. */
1510 var nativeCeil = Math.ceil,
1511 nativeFloor = Math.floor,
1512 nativeGetSymbols = Object.getOwnPropertySymbols,
1513 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
1514 nativeIsFinite = context.isFinite,
1515 nativeJoin = arrayProto.join,
1516 nativeKeys = overArg(Object.keys, Object),
1517 nativeMax = Math.max,
1518 nativeMin = Math.min,
1519 nativeNow = Date.now,
1520 nativeParseInt = context.parseInt,
1521 nativeRandom = Math.random,
1522 nativeReverse = arrayProto.reverse;
1524 /* Built-in method references that are verified to be native. */
1525 var DataView = getNative(context, 'DataView'),
1526 Map = getNative(context, 'Map'),
1527 Promise = getNative(context, 'Promise'),
1528 Set = getNative(context, 'Set'),
1529 WeakMap = getNative(context, 'WeakMap'),
1530 nativeCreate = getNative(Object, 'create');
1532 /** Used to store function metadata. */
1533 var metaMap = WeakMap && new WeakMap;
1535 /** Used to lookup unminified function names. */
1538 /** Used to detect maps, sets, and weakmaps. */
1539 var dataViewCtorString = toSource(DataView),
1540 mapCtorString = toSource(Map),
1541 promiseCtorString = toSource(Promise),
1542 setCtorString = toSource(Set),
1543 weakMapCtorString = toSource(WeakMap);
1545 /** Used to convert symbols to primitives and strings. */
1546 var symbolProto = Symbol ? Symbol.prototype : undefined,
1547 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
1548 symbolToString = symbolProto ? symbolProto.toString : undefined;
1550 /*------------------------------------------------------------------------*/
1553 * Creates a `lodash` object which wraps `value` to enable implicit method
1554 * chain sequences. Methods that operate on and return arrays, collections,
1555 * and functions can be chained together. Methods that retrieve a single value
1556 * or may return a primitive value will automatically end the chain sequence
1557 * and return the unwrapped value. Otherwise, the value must be unwrapped
1560 * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1561 * enabled using `_.chain`.
1563 * The execution of chained methods is lazy, that is, it's deferred until
1564 * `_#value` is implicitly or explicitly called.
1566 * Lazy evaluation allows several methods to support shortcut fusion.
1567 * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1568 * the creation of intermediate arrays and can greatly reduce the number of
1569 * iteratee executions. Sections of a chain sequence qualify for shortcut
1570 * fusion if the section is applied to an array and iteratees accept only
1571 * one argument. The heuristic for whether a section qualifies for shortcut
1572 * fusion is subject to change.
1574 * Chaining is supported in custom builds as long as the `_#value` method is
1575 * directly or indirectly included in the build.
1577 * In addition to lodash methods, wrappers have `Array` and `String` methods.
1579 * The wrapper `Array` methods are:
1580 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1582 * The wrapper `String` methods are:
1583 * `replace` and `split`
1585 * The wrapper methods that support shortcut fusion are:
1586 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1587 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1588 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1590 * The chainable wrapper methods are:
1591 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1592 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1593 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1594 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1595 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1596 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1597 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1598 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1599 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1600 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1601 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1602 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1603 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1604 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1605 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1606 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1607 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1608 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1609 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1610 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1611 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1612 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1613 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1614 * `zipObject`, `zipObjectDeep`, and `zipWith`
1616 * The wrapper methods that are **not** chainable by default are:
1617 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1618 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
1619 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
1620 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
1621 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
1622 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
1623 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
1624 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
1625 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
1626 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
1627 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
1628 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
1629 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
1630 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
1631 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
1632 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
1633 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
1634 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
1635 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
1636 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
1637 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
1638 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
1639 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
1640 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
1641 * `upperFirst`, `value`, and `words`
1646 * @param {*} value The value to wrap in a `lodash` instance.
1647 * @returns {Object} Returns the new `lodash` wrapper instance.
1650 * function square(n) {
1654 * var wrapped = _([1, 2, 3]);
1656 * // Returns an unwrapped value.
1657 * wrapped.reduce(_.add);
1660 * // Returns a wrapped value.
1661 * var squares = wrapped.map(square);
1663 * _.isArray(squares);
1666 * _.isArray(squares.value());
1669 function lodash(value) {
1670 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1671 if (value instanceof LodashWrapper) {
1674 if (hasOwnProperty.call(value, '__wrapped__')) {
1675 return wrapperClone(value);
1678 return new LodashWrapper(value);
1682 * The base implementation of `_.create` without support for assigning
1683 * properties to the created object.
1686 * @param {Object} proto The object to inherit from.
1687 * @returns {Object} Returns the new object.
1689 var baseCreate = (function() {
1690 function object() {}
1691 return function(proto) {
1692 if (!isObject(proto)) {
1696 return objectCreate(proto);
1698 object.prototype = proto;
1699 var result = new object;
1700 object.prototype = undefined;
1706 * The function whose prototype chain sequence wrappers inherit from.
1710 function baseLodash() {
1711 // No operation performed.
1715 * The base constructor for creating `lodash` wrapper objects.
1718 * @param {*} value The value to wrap.
1719 * @param {boolean} [chainAll] Enable explicit method chain sequences.
1721 function LodashWrapper(value, chainAll) {
1722 this.__wrapped__ = value;
1723 this.__actions__ = [];
1724 this.__chain__ = !!chainAll;
1726 this.__values__ = undefined;
1730 * By default, the template delimiters used by lodash are like those in
1731 * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1732 * following template settings to use alternative delimiters.
1738 lodash.templateSettings = {
1741 * Used to detect `data` property values to be HTML-escaped.
1743 * @memberOf _.templateSettings
1749 * Used to detect code to be evaluated.
1751 * @memberOf _.templateSettings
1754 'evaluate': reEvaluate,
1757 * Used to detect `data` property values to inject.
1759 * @memberOf _.templateSettings
1762 'interpolate': reInterpolate,
1765 * Used to reference the data object in the template text.
1767 * @memberOf _.templateSettings
1773 * Used to import variables into the compiled template.
1775 * @memberOf _.templateSettings
1781 * A reference to the `lodash` function.
1783 * @memberOf _.templateSettings.imports
1790 // Ensure wrappers are instances of `baseLodash`.
1791 lodash.prototype = baseLodash.prototype;
1792 lodash.prototype.constructor = lodash;
1794 LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1795 LodashWrapper.prototype.constructor = LodashWrapper;
1797 /*------------------------------------------------------------------------*/
1800 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1804 * @param {*} value The value to wrap.
1806 function LazyWrapper(value) {
1807 this.__wrapped__ = value;
1808 this.__actions__ = [];
1810 this.__filtered__ = false;
1811 this.__iteratees__ = [];
1812 this.__takeCount__ = MAX_ARRAY_LENGTH;
1813 this.__views__ = [];
1817 * Creates a clone of the lazy wrapper object.
1821 * @memberOf LazyWrapper
1822 * @returns {Object} Returns the cloned `LazyWrapper` object.
1824 function lazyClone() {
1825 var result = new LazyWrapper(this.__wrapped__);
1826 result.__actions__ = copyArray(this.__actions__);
1827 result.__dir__ = this.__dir__;
1828 result.__filtered__ = this.__filtered__;
1829 result.__iteratees__ = copyArray(this.__iteratees__);
1830 result.__takeCount__ = this.__takeCount__;
1831 result.__views__ = copyArray(this.__views__);
1836 * Reverses the direction of lazy iteration.
1840 * @memberOf LazyWrapper
1841 * @returns {Object} Returns the new reversed `LazyWrapper` object.
1843 function lazyReverse() {
1844 if (this.__filtered__) {
1845 var result = new LazyWrapper(this);
1846 result.__dir__ = -1;
1847 result.__filtered__ = true;
1849 result = this.clone();
1850 result.__dir__ *= -1;
1856 * Extracts the unwrapped value from its lazy wrapper.
1860 * @memberOf LazyWrapper
1861 * @returns {*} Returns the unwrapped value.
1863 function lazyValue() {
1864 var array = this.__wrapped__.value(),
1866 isArr = isArray(array),
1868 arrLength = isArr ? array.length : 0,
1869 view = getView(0, arrLength, this.__views__),
1872 length = end - start,
1873 index = isRight ? end : (start - 1),
1874 iteratees = this.__iteratees__,
1875 iterLength = iteratees.length,
1877 takeCount = nativeMin(length, this.__takeCount__);
1879 if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
1880 return baseWrapperValue(array, this.__actions__);
1885 while (length-- && resIndex < takeCount) {
1889 value = array[index];
1891 while (++iterIndex < iterLength) {
1892 var data = iteratees[iterIndex],
1893 iteratee = data.iteratee,
1895 computed = iteratee(value);
1897 if (type == LAZY_MAP_FLAG) {
1899 } else if (!computed) {
1900 if (type == LAZY_FILTER_FLAG) {
1907 result[resIndex++] = value;
1912 // Ensure `LazyWrapper` is an instance of `baseLodash`.
1913 LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1914 LazyWrapper.prototype.constructor = LazyWrapper;
1916 /*------------------------------------------------------------------------*/
1919 * Creates a hash object.
1923 * @param {Array} [entries] The key-value pairs to cache.
1925 function Hash(entries) {
1927 length = entries == null ? 0 : entries.length;
1930 while (++index < length) {
1931 var entry = entries[index];
1932 this.set(entry[0], entry[1]);
1937 * Removes all key-value entries from the hash.
1943 function hashClear() {
1944 this.__data__ = nativeCreate ? nativeCreate(null) : {};
1949 * Removes `key` and its value from the hash.
1954 * @param {Object} hash The hash to modify.
1955 * @param {string} key The key of the value to remove.
1956 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1958 function hashDelete(key) {
1959 var result = this.has(key) && delete this.__data__[key];
1960 this.size -= result ? 1 : 0;
1965 * Gets the hash value for `key`.
1970 * @param {string} key The key of the value to get.
1971 * @returns {*} Returns the entry value.
1973 function hashGet(key) {
1974 var data = this.__data__;
1976 var result = data[key];
1977 return result === HASH_UNDEFINED ? undefined : result;
1979 return hasOwnProperty.call(data, key) ? data[key] : undefined;
1983 * Checks if a hash value for `key` exists.
1988 * @param {string} key The key of the entry to check.
1989 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1991 function hashHas(key) {
1992 var data = this.__data__;
1993 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
1997 * Sets the hash `key` to `value`.
2002 * @param {string} key The key of the value to set.
2003 * @param {*} value The value to set.
2004 * @returns {Object} Returns the hash instance.
2006 function hashSet(key, value) {
2007 var data = this.__data__;
2008 this.size += this.has(key) ? 0 : 1;
2009 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
2013 // Add methods to `Hash`.
2014 Hash.prototype.clear = hashClear;
2015 Hash.prototype['delete'] = hashDelete;
2016 Hash.prototype.get = hashGet;
2017 Hash.prototype.has = hashHas;
2018 Hash.prototype.set = hashSet;
2020 /*------------------------------------------------------------------------*/
2023 * Creates an list cache object.
2027 * @param {Array} [entries] The key-value pairs to cache.
2029 function ListCache(entries) {
2031 length = entries == null ? 0 : entries.length;
2034 while (++index < length) {
2035 var entry = entries[index];
2036 this.set(entry[0], entry[1]);
2041 * Removes all key-value entries from the list cache.
2045 * @memberOf ListCache
2047 function listCacheClear() {
2053 * Removes `key` and its value from the list cache.
2057 * @memberOf ListCache
2058 * @param {string} key The key of the value to remove.
2059 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2061 function listCacheDelete(key) {
2062 var data = this.__data__,
2063 index = assocIndexOf(data, key);
2068 var lastIndex = data.length - 1;
2069 if (index == lastIndex) {
2072 splice.call(data, index, 1);
2079 * Gets the list cache value for `key`.
2083 * @memberOf ListCache
2084 * @param {string} key The key of the value to get.
2085 * @returns {*} Returns the entry value.
2087 function listCacheGet(key) {
2088 var data = this.__data__,
2089 index = assocIndexOf(data, key);
2091 return index < 0 ? undefined : data[index][1];
2095 * Checks if a list cache value for `key` exists.
2099 * @memberOf ListCache
2100 * @param {string} key The key of the entry to check.
2101 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2103 function listCacheHas(key) {
2104 return assocIndexOf(this.__data__, key) > -1;
2108 * Sets the list cache `key` to `value`.
2112 * @memberOf ListCache
2113 * @param {string} key The key of the value to set.
2114 * @param {*} value The value to set.
2115 * @returns {Object} Returns the list cache instance.
2117 function listCacheSet(key, value) {
2118 var data = this.__data__,
2119 index = assocIndexOf(data, key);
2123 data.push([key, value]);
2125 data[index][1] = value;
2130 // Add methods to `ListCache`.
2131 ListCache.prototype.clear = listCacheClear;
2132 ListCache.prototype['delete'] = listCacheDelete;
2133 ListCache.prototype.get = listCacheGet;
2134 ListCache.prototype.has = listCacheHas;
2135 ListCache.prototype.set = listCacheSet;
2137 /*------------------------------------------------------------------------*/
2140 * Creates a map cache object to store key-value pairs.
2144 * @param {Array} [entries] The key-value pairs to cache.
2146 function MapCache(entries) {
2148 length = entries == null ? 0 : entries.length;
2151 while (++index < length) {
2152 var entry = entries[index];
2153 this.set(entry[0], entry[1]);
2158 * Removes all key-value entries from the map.
2162 * @memberOf MapCache
2164 function mapCacheClear() {
2168 'map': new (Map || ListCache),
2174 * Removes `key` and its value from the map.
2178 * @memberOf MapCache
2179 * @param {string} key The key of the value to remove.
2180 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2182 function mapCacheDelete(key) {
2183 var result = getMapData(this, key)['delete'](key);
2184 this.size -= result ? 1 : 0;
2189 * Gets the map value for `key`.
2193 * @memberOf MapCache
2194 * @param {string} key The key of the value to get.
2195 * @returns {*} Returns the entry value.
2197 function mapCacheGet(key) {
2198 return getMapData(this, key).get(key);
2202 * Checks if a map value for `key` exists.
2206 * @memberOf MapCache
2207 * @param {string} key The key of the entry to check.
2208 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2210 function mapCacheHas(key) {
2211 return getMapData(this, key).has(key);
2215 * Sets the map `key` to `value`.
2219 * @memberOf MapCache
2220 * @param {string} key The key of the value to set.
2221 * @param {*} value The value to set.
2222 * @returns {Object} Returns the map cache instance.
2224 function mapCacheSet(key, value) {
2225 var data = getMapData(this, key),
2228 data.set(key, value);
2229 this.size += data.size == size ? 0 : 1;
2233 // Add methods to `MapCache`.
2234 MapCache.prototype.clear = mapCacheClear;
2235 MapCache.prototype['delete'] = mapCacheDelete;
2236 MapCache.prototype.get = mapCacheGet;
2237 MapCache.prototype.has = mapCacheHas;
2238 MapCache.prototype.set = mapCacheSet;
2240 /*------------------------------------------------------------------------*/
2244 * Creates an array cache object to store unique values.
2248 * @param {Array} [values] The values to cache.
2250 function SetCache(values) {
2252 length = values == null ? 0 : values.length;
2254 this.__data__ = new MapCache;
2255 while (++index < length) {
2256 this.add(values[index]);
2261 * Adds `value` to the array cache.
2265 * @memberOf SetCache
2267 * @param {*} value The value to cache.
2268 * @returns {Object} Returns the cache instance.
2270 function setCacheAdd(value) {
2271 this.__data__.set(value, HASH_UNDEFINED);
2276 * Checks if `value` is in the array cache.
2280 * @memberOf SetCache
2281 * @param {*} value The value to search for.
2282 * @returns {number} Returns `true` if `value` is found, else `false`.
2284 function setCacheHas(value) {
2285 return this.__data__.has(value);
2288 // Add methods to `SetCache`.
2289 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2290 SetCache.prototype.has = setCacheHas;
2292 /*------------------------------------------------------------------------*/
2295 * Creates a stack cache object to store key-value pairs.
2299 * @param {Array} [entries] The key-value pairs to cache.
2301 function Stack(entries) {
2302 var data = this.__data__ = new ListCache(entries);
2303 this.size = data.size;
2307 * Removes all key-value entries from the stack.
2313 function stackClear() {
2314 this.__data__ = new ListCache;
2319 * Removes `key` and its value from the stack.
2324 * @param {string} key The key of the value to remove.
2325 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2327 function stackDelete(key) {
2328 var data = this.__data__,
2329 result = data['delete'](key);
2331 this.size = data.size;
2336 * Gets the stack value for `key`.
2341 * @param {string} key The key of the value to get.
2342 * @returns {*} Returns the entry value.
2344 function stackGet(key) {
2345 return this.__data__.get(key);
2349 * Checks if a stack value for `key` exists.
2354 * @param {string} key The key of the entry to check.
2355 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2357 function stackHas(key) {
2358 return this.__data__.has(key);
2362 * Sets the stack `key` to `value`.
2367 * @param {string} key The key of the value to set.
2368 * @param {*} value The value to set.
2369 * @returns {Object} Returns the stack cache instance.
2371 function stackSet(key, value) {
2372 var data = this.__data__;
2373 if (data instanceof ListCache) {
2374 var pairs = data.__data__;
2375 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2376 pairs.push([key, value]);
2377 this.size = ++data.size;
2380 data = this.__data__ = new MapCache(pairs);
2382 data.set(key, value);
2383 this.size = data.size;
2387 // Add methods to `Stack`.
2388 Stack.prototype.clear = stackClear;
2389 Stack.prototype['delete'] = stackDelete;
2390 Stack.prototype.get = stackGet;
2391 Stack.prototype.has = stackHas;
2392 Stack.prototype.set = stackSet;
2394 /*------------------------------------------------------------------------*/
2397 * Creates an array of the enumerable property names of the array-like `value`.
2400 * @param {*} value The value to query.
2401 * @param {boolean} inherited Specify returning inherited property names.
2402 * @returns {Array} Returns the array of property names.
2404 function arrayLikeKeys(value, inherited) {
2405 var isArr = isArray(value),
2406 isArg = !isArr && isArguments(value),
2407 isBuff = !isArr && !isArg && isBuffer(value),
2408 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2409 skipIndexes = isArr || isArg || isBuff || isType,
2410 result = skipIndexes ? baseTimes(value.length, String) : [],
2411 length = result.length;
2413 for (var key in value) {
2414 if ((inherited || hasOwnProperty.call(value, key)) &&
2416 // Safari 9 has enumerable `arguments.length` in strict mode.
2418 // Node.js 0.10 has enumerable non-index properties on buffers.
2419 (isBuff && (key == 'offset' || key == 'parent')) ||
2420 // PhantomJS 2 has enumerable non-index properties on typed arrays.
2421 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2422 // Skip index properties.
2423 isIndex(key, length)
2432 * A specialized version of `_.sample` for arrays.
2435 * @param {Array} array The array to sample.
2436 * @returns {*} Returns the random element.
2438 function arraySample(array) {
2439 var length = array.length;
2440 return length ? array[baseRandom(0, length - 1)] : undefined;
2444 * A specialized version of `_.sampleSize` for arrays.
2447 * @param {Array} array The array to sample.
2448 * @param {number} n The number of elements to sample.
2449 * @returns {Array} Returns the random elements.
2451 function arraySampleSize(array, n) {
2452 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2456 * A specialized version of `_.shuffle` for arrays.
2459 * @param {Array} array The array to shuffle.
2460 * @returns {Array} Returns the new shuffled array.
2462 function arrayShuffle(array) {
2463 return shuffleSelf(copyArray(array));
2467 * This function is like `assignValue` except that it doesn't assign
2468 * `undefined` values.
2471 * @param {Object} object The object to modify.
2472 * @param {string} key The key of the property to assign.
2473 * @param {*} value The value to assign.
2475 function assignMergeValue(object, key, value) {
2476 if ((value !== undefined && !eq(object[key], value)) ||
2477 (value === undefined && !(key in object))) {
2478 baseAssignValue(object, key, value);
2483 * Assigns `value` to `key` of `object` if the existing value is not equivalent
2484 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2485 * for equality comparisons.
2488 * @param {Object} object The object to modify.
2489 * @param {string} key The key of the property to assign.
2490 * @param {*} value The value to assign.
2492 function assignValue(object, key, value) {
2493 var objValue = object[key];
2494 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2495 (value === undefined && !(key in object))) {
2496 baseAssignValue(object, key, value);
2501 * Gets the index at which the `key` is found in `array` of key-value pairs.
2504 * @param {Array} array The array to inspect.
2505 * @param {*} key The key to search for.
2506 * @returns {number} Returns the index of the matched value, else `-1`.
2508 function assocIndexOf(array, key) {
2509 var length = array.length;
2511 if (eq(array[length][0], key)) {
2519 * Aggregates elements of `collection` on `accumulator` with keys transformed
2520 * by `iteratee` and values set by `setter`.
2523 * @param {Array|Object} collection The collection to iterate over.
2524 * @param {Function} setter The function to set `accumulator` values.
2525 * @param {Function} iteratee The iteratee to transform keys.
2526 * @param {Object} accumulator The initial aggregated object.
2527 * @returns {Function} Returns `accumulator`.
2529 function baseAggregator(collection, setter, iteratee, accumulator) {
2530 baseEach(collection, function(value, key, collection) {
2531 setter(accumulator, value, iteratee(value), collection);
2537 * The base implementation of `_.assign` without support for multiple sources
2538 * or `customizer` functions.
2541 * @param {Object} object The destination object.
2542 * @param {Object} source The source object.
2543 * @returns {Object} Returns `object`.
2545 function baseAssign(object, source) {
2546 return object && copyObject(source, keys(source), object);
2550 * The base implementation of `_.assignIn` without support for multiple sources
2551 * or `customizer` functions.
2554 * @param {Object} object The destination object.
2555 * @param {Object} source The source object.
2556 * @returns {Object} Returns `object`.
2558 function baseAssignIn(object, source) {
2559 return object && copyObject(source, keysIn(source), object);
2563 * The base implementation of `assignValue` and `assignMergeValue` without
2567 * @param {Object} object The object to modify.
2568 * @param {string} key The key of the property to assign.
2569 * @param {*} value The value to assign.
2571 function baseAssignValue(object, key, value) {
2572 if (key == '__proto__' && defineProperty) {
2573 defineProperty(object, key, {
2574 'configurable': true,
2580 object[key] = value;
2585 * The base implementation of `_.at` without support for individual paths.
2588 * @param {Object} object The object to iterate over.
2589 * @param {string[]} paths The property paths to pick.
2590 * @returns {Array} Returns the picked elements.
2592 function baseAt(object, paths) {
2594 length = paths.length,
2595 result = Array(length),
2596 skip = object == null;
2598 while (++index < length) {
2599 result[index] = skip ? undefined : get(object, paths[index]);
2605 * The base implementation of `_.clamp` which doesn't coerce arguments.
2608 * @param {number} number The number to clamp.
2609 * @param {number} [lower] The lower bound.
2610 * @param {number} upper The upper bound.
2611 * @returns {number} Returns the clamped number.
2613 function baseClamp(number, lower, upper) {
2614 if (number === number) {
2615 if (upper !== undefined) {
2616 number = number <= upper ? number : upper;
2618 if (lower !== undefined) {
2619 number = number >= lower ? number : lower;
2626 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2627 * traversed objects.
2630 * @param {*} value The value to clone.
2631 * @param {boolean} bitmask The bitmask flags.
2633 * 2 - Flatten inherited properties
2635 * @param {Function} [customizer] The function to customize cloning.
2636 * @param {string} [key] The key of `value`.
2637 * @param {Object} [object] The parent object of `value`.
2638 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2639 * @returns {*} Returns the cloned value.
2641 function baseClone(value, bitmask, customizer, key, object, stack) {
2643 isDeep = bitmask & CLONE_DEEP_FLAG,
2644 isFlat = bitmask & CLONE_FLAT_FLAG,
2645 isFull = bitmask & CLONE_SYMBOLS_FLAG;
2648 result = object ? customizer(value, key, object, stack) : customizer(value);
2650 if (result !== undefined) {
2653 if (!isObject(value)) {
2656 var isArr = isArray(value);
2658 result = initCloneArray(value);
2660 return copyArray(value, result);
2663 var tag = getTag(value),
2664 isFunc = tag == funcTag || tag == genTag;
2666 if (isBuffer(value)) {
2667 return cloneBuffer(value, isDeep);
2669 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2670 result = (isFlat || isFunc) ? {} : initCloneObject(value);
2673 ? copySymbolsIn(value, baseAssignIn(result, value))
2674 : copySymbols(value, baseAssign(result, value));
2677 if (!cloneableTags[tag]) {
2678 return object ? value : {};
2680 result = initCloneByTag(value, tag, baseClone, isDeep);
2683 // Check for circular references and return its corresponding clone.
2684 stack || (stack = new Stack);
2685 var stacked = stack.get(value);
2689 stack.set(value, result);
2691 var keysFunc = isFull
2692 ? (isFlat ? getAllKeysIn : getAllKeys)
2693 : (isFlat ? keysIn : keys);
2695 var props = isArr ? undefined : keysFunc(value);
2696 arrayEach(props || value, function(subValue, key) {
2699 subValue = value[key];
2701 // Recursively populate clone (susceptible to call stack limits).
2702 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
2708 * The base implementation of `_.conforms` which doesn't clone `source`.
2711 * @param {Object} source The object of property predicates to conform to.
2712 * @returns {Function} Returns the new spec function.
2714 function baseConforms(source) {
2715 var props = keys(source);
2716 return function(object) {
2717 return baseConformsTo(object, source, props);
2722 * The base implementation of `_.conformsTo` which accepts `props` to check.
2725 * @param {Object} object The object to inspect.
2726 * @param {Object} source The object of property predicates to conform to.
2727 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
2729 function baseConformsTo(object, source, props) {
2730 var length = props.length;
2731 if (object == null) {
2734 object = Object(object);
2736 var key = props[length],
2737 predicate = source[key],
2738 value = object[key];
2740 if ((value === undefined && !(key in object)) || !predicate(value)) {
2748 * The base implementation of `_.delay` and `_.defer` which accepts `args`
2749 * to provide to `func`.
2752 * @param {Function} func The function to delay.
2753 * @param {number} wait The number of milliseconds to delay invocation.
2754 * @param {Array} args The arguments to provide to `func`.
2755 * @returns {number|Object} Returns the timer id or timeout object.
2757 function baseDelay(func, wait, args) {
2758 if (typeof func != 'function') {
2759 throw new TypeError(FUNC_ERROR_TEXT);
2761 return setTimeout(function() { func.apply(undefined, args); }, wait);
2765 * The base implementation of methods like `_.difference` without support
2766 * for excluding multiple arrays or iteratee shorthands.
2769 * @param {Array} array The array to inspect.
2770 * @param {Array} values The values to exclude.
2771 * @param {Function} [iteratee] The iteratee invoked per element.
2772 * @param {Function} [comparator] The comparator invoked per element.
2773 * @returns {Array} Returns the new array of filtered values.
2775 function baseDifference(array, values, iteratee, comparator) {
2777 includes = arrayIncludes,
2779 length = array.length,
2781 valuesLength = values.length;
2787 values = arrayMap(values, baseUnary(iteratee));
2790 includes = arrayIncludesWith;
2793 else if (values.length >= LARGE_ARRAY_SIZE) {
2794 includes = cacheHas;
2796 values = new SetCache(values);
2799 while (++index < length) {
2800 var value = array[index],
2801 computed = iteratee == null ? value : iteratee(value);
2803 value = (comparator || value !== 0) ? value : 0;
2804 if (isCommon && computed === computed) {
2805 var valuesIndex = valuesLength;
2806 while (valuesIndex--) {
2807 if (values[valuesIndex] === computed) {
2813 else if (!includes(values, computed, comparator)) {
2821 * The base implementation of `_.forEach` without support for iteratee shorthands.
2824 * @param {Array|Object} collection The collection to iterate over.
2825 * @param {Function} iteratee The function invoked per iteration.
2826 * @returns {Array|Object} Returns `collection`.
2828 var baseEach = createBaseEach(baseForOwn);
2831 * The base implementation of `_.forEachRight` without support for iteratee shorthands.
2834 * @param {Array|Object} collection The collection to iterate over.
2835 * @param {Function} iteratee The function invoked per iteration.
2836 * @returns {Array|Object} Returns `collection`.
2838 var baseEachRight = createBaseEach(baseForOwnRight, true);
2841 * The base implementation of `_.every` without support for iteratee shorthands.
2844 * @param {Array|Object} collection The collection to iterate over.
2845 * @param {Function} predicate The function invoked per iteration.
2846 * @returns {boolean} Returns `true` if all elements pass the predicate check,
2849 function baseEvery(collection, predicate) {
2851 baseEach(collection, function(value, index, collection) {
2852 result = !!predicate(value, index, collection);
2859 * The base implementation of methods like `_.max` and `_.min` which accepts a
2860 * `comparator` to determine the extremum value.
2863 * @param {Array} array The array to iterate over.
2864 * @param {Function} iteratee The iteratee invoked per iteration.
2865 * @param {Function} comparator The comparator used to compare values.
2866 * @returns {*} Returns the extremum value.
2868 function baseExtremum(array, iteratee, comparator) {
2870 length = array.length;
2872 while (++index < length) {
2873 var value = array[index],
2874 current = iteratee(value);
2876 if (current != null && (computed === undefined
2877 ? (current === current && !isSymbol(current))
2878 : comparator(current, computed)
2880 var computed = current,
2888 * The base implementation of `_.fill` without an iteratee call guard.
2891 * @param {Array} array The array to fill.
2892 * @param {*} value The value to fill `array` with.
2893 * @param {number} [start=0] The start position.
2894 * @param {number} [end=array.length] The end position.
2895 * @returns {Array} Returns `array`.
2897 function baseFill(array, value, start, end) {
2898 var length = array.length;
2900 start = toInteger(start);
2902 start = -start > length ? 0 : (length + start);
2904 end = (end === undefined || end > length) ? length : toInteger(end);
2908 end = start > end ? 0 : toLength(end);
2909 while (start < end) {
2910 array[start++] = value;
2916 * The base implementation of `_.filter` without support for iteratee shorthands.
2919 * @param {Array|Object} collection The collection to iterate over.
2920 * @param {Function} predicate The function invoked per iteration.
2921 * @returns {Array} Returns the new filtered array.
2923 function baseFilter(collection, predicate) {
2925 baseEach(collection, function(value, index, collection) {
2926 if (predicate(value, index, collection)) {
2934 * The base implementation of `_.flatten` with support for restricting flattening.
2937 * @param {Array} array The array to flatten.
2938 * @param {number} depth The maximum recursion depth.
2939 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
2940 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
2941 * @param {Array} [result=[]] The initial result value.
2942 * @returns {Array} Returns the new flattened array.
2944 function baseFlatten(array, depth, predicate, isStrict, result) {
2946 length = array.length;
2948 predicate || (predicate = isFlattenable);
2949 result || (result = []);
2951 while (++index < length) {
2952 var value = array[index];
2953 if (depth > 0 && predicate(value)) {
2955 // Recursively flatten arrays (susceptible to call stack limits).
2956 baseFlatten(value, depth - 1, predicate, isStrict, result);
2958 arrayPush(result, value);
2960 } else if (!isStrict) {
2961 result[result.length] = value;
2968 * The base implementation of `baseForOwn` which iterates over `object`
2969 * properties returned by `keysFunc` and invokes `iteratee` for each property.
2970 * Iteratee functions may exit iteration early by explicitly returning `false`.
2973 * @param {Object} object The object to iterate over.
2974 * @param {Function} iteratee The function invoked per iteration.
2975 * @param {Function} keysFunc The function to get the keys of `object`.
2976 * @returns {Object} Returns `object`.
2978 var baseFor = createBaseFor();
2981 * This function is like `baseFor` except that it iterates over properties
2982 * in the opposite order.
2985 * @param {Object} object The object to iterate over.
2986 * @param {Function} iteratee The function invoked per iteration.
2987 * @param {Function} keysFunc The function to get the keys of `object`.
2988 * @returns {Object} Returns `object`.
2990 var baseForRight = createBaseFor(true);
2993 * The base implementation of `_.forOwn` without support for iteratee shorthands.
2996 * @param {Object} object The object to iterate over.
2997 * @param {Function} iteratee The function invoked per iteration.
2998 * @returns {Object} Returns `object`.
3000 function baseForOwn(object, iteratee) {
3001 return object && baseFor(object, iteratee, keys);
3005 * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
3008 * @param {Object} object The object to iterate over.
3009 * @param {Function} iteratee The function invoked per iteration.
3010 * @returns {Object} Returns `object`.
3012 function baseForOwnRight(object, iteratee) {
3013 return object && baseForRight(object, iteratee, keys);
3017 * The base implementation of `_.functions` which creates an array of
3018 * `object` function property names filtered from `props`.
3021 * @param {Object} object The object to inspect.
3022 * @param {Array} props The property names to filter.
3023 * @returns {Array} Returns the function names.
3025 function baseFunctions(object, props) {
3026 return arrayFilter(props, function(key) {
3027 return isFunction(object[key]);
3032 * The base implementation of `_.get` without support for default values.
3035 * @param {Object} object The object to query.
3036 * @param {Array|string} path The path of the property to get.
3037 * @returns {*} Returns the resolved value.
3039 function baseGet(object, path) {
3040 path = castPath(path, object);
3043 length = path.length;
3045 while (object != null && index < length) {
3046 object = object[toKey(path[index++])];
3048 return (index && index == length) ? object : undefined;
3052 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3053 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3054 * symbols of `object`.
3057 * @param {Object} object The object to query.
3058 * @param {Function} keysFunc The function to get the keys of `object`.
3059 * @param {Function} symbolsFunc The function to get the symbols of `object`.
3060 * @returns {Array} Returns the array of property names and symbols.
3062 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3063 var result = keysFunc(object);
3064 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3068 * The base implementation of `getTag` without fallbacks for buggy environments.
3071 * @param {*} value The value to query.
3072 * @returns {string} Returns the `toStringTag`.
3074 function baseGetTag(value) {
3075 if (value == null) {
3076 return value === undefined ? undefinedTag : nullTag;
3078 return (symToStringTag && symToStringTag in Object(value))
3080 : objectToString(value);
3084 * The base implementation of `_.gt` which doesn't coerce arguments.
3087 * @param {*} value The value to compare.
3088 * @param {*} other The other value to compare.
3089 * @returns {boolean} Returns `true` if `value` is greater than `other`,
3092 function baseGt(value, other) {
3093 return value > other;
3097 * The base implementation of `_.has` without support for deep paths.
3100 * @param {Object} [object] The object to query.
3101 * @param {Array|string} key The key to check.
3102 * @returns {boolean} Returns `true` if `key` exists, else `false`.
3104 function baseHas(object, key) {
3105 return object != null && hasOwnProperty.call(object, key);
3109 * The base implementation of `_.hasIn` without support for deep paths.
3112 * @param {Object} [object] The object to query.
3113 * @param {Array|string} key The key to check.
3114 * @returns {boolean} Returns `true` if `key` exists, else `false`.
3116 function baseHasIn(object, key) {
3117 return object != null && key in Object(object);
3121 * The base implementation of `_.inRange` which doesn't coerce arguments.
3124 * @param {number} number The number to check.
3125 * @param {number} start The start of the range.
3126 * @param {number} end The end of the range.
3127 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
3129 function baseInRange(number, start, end) {
3130 return number >= nativeMin(start, end) && number < nativeMax(start, end);
3134 * The base implementation of methods like `_.intersection`, without support
3135 * for iteratee shorthands, that accepts an array of arrays to inspect.
3138 * @param {Array} arrays The arrays to inspect.
3139 * @param {Function} [iteratee] The iteratee invoked per element.
3140 * @param {Function} [comparator] The comparator invoked per element.
3141 * @returns {Array} Returns the new array of shared values.
3143 function baseIntersection(arrays, iteratee, comparator) {
3144 var includes = comparator ? arrayIncludesWith : arrayIncludes,
3145 length = arrays[0].length,
3146 othLength = arrays.length,
3147 othIndex = othLength,
3148 caches = Array(othLength),
3149 maxLength = Infinity,
3152 while (othIndex--) {
3153 var array = arrays[othIndex];
3154 if (othIndex && iteratee) {
3155 array = arrayMap(array, baseUnary(iteratee));
3157 maxLength = nativeMin(array.length, maxLength);
3158 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3159 ? new SetCache(othIndex && array)
3168 while (++index < length && result.length < maxLength) {
3169 var value = array[index],
3170 computed = iteratee ? iteratee(value) : value;
3172 value = (comparator || value !== 0) ? value : 0;
3174 ? cacheHas(seen, computed)
3175 : includes(result, computed, comparator)
3177 othIndex = othLength;
3178 while (--othIndex) {
3179 var cache = caches[othIndex];
3181 ? cacheHas(cache, computed)
3182 : includes(arrays[othIndex], computed, comparator))
3188 seen.push(computed);
3197 * The base implementation of `_.invert` and `_.invertBy` which inverts
3198 * `object` with values transformed by `iteratee` and set by `setter`.
3201 * @param {Object} object The object to iterate over.
3202 * @param {Function} setter The function to set `accumulator` values.
3203 * @param {Function} iteratee The iteratee to transform values.
3204 * @param {Object} accumulator The initial inverted object.
3205 * @returns {Function} Returns `accumulator`.
3207 function baseInverter(object, setter, iteratee, accumulator) {
3208 baseForOwn(object, function(value, key, object) {
3209 setter(accumulator, iteratee(value), key, object);
3215 * The base implementation of `_.invoke` without support for individual
3219 * @param {Object} object The object to query.
3220 * @param {Array|string} path The path of the method to invoke.
3221 * @param {Array} args The arguments to invoke the method with.
3222 * @returns {*} Returns the result of the invoked method.
3224 function baseInvoke(object, path, args) {
3225 path = castPath(path, object);
3226 object = parent(object, path);
3227 var func = object == null ? object : object[toKey(last(path))];
3228 return func == null ? undefined : apply(func, object, args);
3232 * The base implementation of `_.isArguments`.
3235 * @param {*} value The value to check.
3236 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3238 function baseIsArguments(value) {
3239 return isObjectLike(value) && baseGetTag(value) == argsTag;
3243 * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3246 * @param {*} value The value to check.
3247 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3249 function baseIsArrayBuffer(value) {
3250 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3254 * The base implementation of `_.isDate` without Node.js optimizations.
3257 * @param {*} value The value to check.
3258 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3260 function baseIsDate(value) {
3261 return isObjectLike(value) && baseGetTag(value) == dateTag;
3265 * The base implementation of `_.isEqual` which supports partial comparisons
3266 * and tracks traversed objects.
3269 * @param {*} value The value to compare.
3270 * @param {*} other The other value to compare.
3271 * @param {boolean} bitmask The bitmask flags.
3272 * 1 - Unordered comparison
3273 * 2 - Partial comparison
3274 * @param {Function} [customizer] The function to customize comparisons.
3275 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3276 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3278 function baseIsEqual(value, other, bitmask, customizer, stack) {
3279 if (value === other) {
3282 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3283 return value !== value && other !== other;
3285 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3289 * A specialized version of `baseIsEqual` for arrays and objects which performs
3290 * deep comparisons and tracks traversed objects enabling objects with circular
3291 * references to be compared.
3294 * @param {Object} object The object to compare.
3295 * @param {Object} other The other object to compare.
3296 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3297 * @param {Function} customizer The function to customize comparisons.
3298 * @param {Function} equalFunc The function to determine equivalents of values.
3299 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3300 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3302 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3303 var objIsArr = isArray(object),
3304 othIsArr = isArray(other),
3305 objTag = objIsArr ? arrayTag : getTag(object),
3306 othTag = othIsArr ? arrayTag : getTag(other);
3308 objTag = objTag == argsTag ? objectTag : objTag;
3309 othTag = othTag == argsTag ? objectTag : othTag;
3311 var objIsObj = objTag == objectTag,
3312 othIsObj = othTag == objectTag,
3313 isSameTag = objTag == othTag;
3315 if (isSameTag && isBuffer(object)) {
3316 if (!isBuffer(other)) {
3322 if (isSameTag && !objIsObj) {
3323 stack || (stack = new Stack);
3324 return (objIsArr || isTypedArray(object))
3325 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3326 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3328 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3329 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3330 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3332 if (objIsWrapped || othIsWrapped) {
3333 var objUnwrapped = objIsWrapped ? object.value() : object,
3334 othUnwrapped = othIsWrapped ? other.value() : other;
3336 stack || (stack = new Stack);
3337 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3343 stack || (stack = new Stack);
3344 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3348 * The base implementation of `_.isMap` without Node.js optimizations.
3351 * @param {*} value The value to check.
3352 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3354 function baseIsMap(value) {
3355 return isObjectLike(value) && getTag(value) == mapTag;
3359 * The base implementation of `_.isMatch` without support for iteratee shorthands.
3362 * @param {Object} object The object to inspect.
3363 * @param {Object} source The object of property values to match.
3364 * @param {Array} matchData The property names, values, and compare flags to match.
3365 * @param {Function} [customizer] The function to customize comparisons.
3366 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3368 function baseIsMatch(object, source, matchData, customizer) {
3369 var index = matchData.length,
3371 noCustomizer = !customizer;
3373 if (object == null) {
3376 object = Object(object);
3378 var data = matchData[index];
3379 if ((noCustomizer && data[2])
3380 ? data[1] !== object[data[0]]
3381 : !(data[0] in object)
3386 while (++index < length) {
3387 data = matchData[index];
3389 objValue = object[key],
3392 if (noCustomizer && data[2]) {
3393 if (objValue === undefined && !(key in object)) {
3397 var stack = new Stack;
3399 var result = customizer(objValue, srcValue, key, object, source, stack);
3401 if (!(result === undefined
3402 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
3413 * The base implementation of `_.isNative` without bad shim checks.
3416 * @param {*} value The value to check.
3417 * @returns {boolean} Returns `true` if `value` is a native function,
3420 function baseIsNative(value) {
3421 if (!isObject(value) || isMasked(value)) {
3424 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3425 return pattern.test(toSource(value));
3429 * The base implementation of `_.isRegExp` without Node.js optimizations.
3432 * @param {*} value The value to check.
3433 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3435 function baseIsRegExp(value) {
3436 return isObjectLike(value) && baseGetTag(value) == regexpTag;
3440 * The base implementation of `_.isSet` without Node.js optimizations.
3443 * @param {*} value The value to check.
3444 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3446 function baseIsSet(value) {
3447 return isObjectLike(value) && getTag(value) == setTag;
3451 * The base implementation of `_.isTypedArray` without Node.js optimizations.
3454 * @param {*} value The value to check.
3455 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3457 function baseIsTypedArray(value) {
3458 return isObjectLike(value) &&
3459 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3463 * The base implementation of `_.iteratee`.
3466 * @param {*} [value=_.identity] The value to convert to an iteratee.
3467 * @returns {Function} Returns the iteratee.
3469 function baseIteratee(value) {
3470 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3471 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3472 if (typeof value == 'function') {
3475 if (value == null) {
3478 if (typeof value == 'object') {
3479 return isArray(value)
3480 ? baseMatchesProperty(value[0], value[1])
3481 : baseMatches(value);
3483 return property(value);
3487 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3490 * @param {Object} object The object to query.
3491 * @returns {Array} Returns the array of property names.
3493 function baseKeys(object) {
3494 if (!isPrototype(object)) {
3495 return nativeKeys(object);
3498 for (var key in Object(object)) {
3499 if (hasOwnProperty.call(object, key) && key != 'constructor') {
3507 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3510 * @param {Object} object The object to query.
3511 * @returns {Array} Returns the array of property names.
3513 function baseKeysIn(object) {
3514 if (!isObject(object)) {
3515 return nativeKeysIn(object);
3517 var isProto = isPrototype(object),
3520 for (var key in object) {
3521 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3529 * The base implementation of `_.lt` which doesn't coerce arguments.
3532 * @param {*} value The value to compare.
3533 * @param {*} other The other value to compare.
3534 * @returns {boolean} Returns `true` if `value` is less than `other`,
3537 function baseLt(value, other) {
3538 return value < other;
3542 * The base implementation of `_.map` without support for iteratee shorthands.
3545 * @param {Array|Object} collection The collection to iterate over.
3546 * @param {Function} iteratee The function invoked per iteration.
3547 * @returns {Array} Returns the new mapped array.
3549 function baseMap(collection, iteratee) {
3551 result = isArrayLike(collection) ? Array(collection.length) : [];
3553 baseEach(collection, function(value, key, collection) {
3554 result[++index] = iteratee(value, key, collection);
3560 * The base implementation of `_.matches` which doesn't clone `source`.
3563 * @param {Object} source The object of property values to match.
3564 * @returns {Function} Returns the new spec function.
3566 function baseMatches(source) {
3567 var matchData = getMatchData(source);
3568 if (matchData.length == 1 && matchData[0][2]) {
3569 return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3571 return function(object) {
3572 return object === source || baseIsMatch(object, source, matchData);
3577 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3580 * @param {string} path The path of the property to get.
3581 * @param {*} srcValue The value to match.
3582 * @returns {Function} Returns the new spec function.
3584 function baseMatchesProperty(path, srcValue) {
3585 if (isKey(path) && isStrictComparable(srcValue)) {
3586 return matchesStrictComparable(toKey(path), srcValue);
3588 return function(object) {
3589 var objValue = get(object, path);
3590 return (objValue === undefined && objValue === srcValue)
3591 ? hasIn(object, path)
3592 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3597 * The base implementation of `_.merge` without support for multiple sources.
3600 * @param {Object} object The destination object.
3601 * @param {Object} source The source object.
3602 * @param {number} srcIndex The index of `source`.
3603 * @param {Function} [customizer] The function to customize merged values.
3604 * @param {Object} [stack] Tracks traversed source values and their merged
3607 function baseMerge(object, source, srcIndex, customizer, stack) {
3608 if (object === source) {
3611 baseFor(source, function(srcValue, key) {
3612 if (isObject(srcValue)) {
3613 stack || (stack = new Stack);
3614 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3617 var newValue = customizer
3618 ? customizer(object[key], srcValue, (key + ''), object, source, stack)
3621 if (newValue === undefined) {
3622 newValue = srcValue;
3624 assignMergeValue(object, key, newValue);
3630 * A specialized version of `baseMerge` for arrays and objects which performs
3631 * deep merges and tracks traversed objects enabling objects with circular
3632 * references to be merged.
3635 * @param {Object} object The destination object.
3636 * @param {Object} source The source object.
3637 * @param {string} key The key of the value to merge.
3638 * @param {number} srcIndex The index of `source`.
3639 * @param {Function} mergeFunc The function to merge values.
3640 * @param {Function} [customizer] The function to customize assigned values.
3641 * @param {Object} [stack] Tracks traversed source values and their merged
3644 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3645 var objValue = object[key],
3646 srcValue = source[key],
3647 stacked = stack.get(srcValue);
3650 assignMergeValue(object, key, stacked);
3653 var newValue = customizer
3654 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3657 var isCommon = newValue === undefined;
3660 var isArr = isArray(srcValue),
3661 isBuff = !isArr && isBuffer(srcValue),
3662 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3664 newValue = srcValue;
3665 if (isArr || isBuff || isTyped) {
3666 if (isArray(objValue)) {
3667 newValue = objValue;
3669 else if (isArrayLikeObject(objValue)) {
3670 newValue = copyArray(objValue);
3674 newValue = cloneBuffer(srcValue, true);
3678 newValue = cloneTypedArray(srcValue, true);
3684 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3685 newValue = objValue;
3686 if (isArguments(objValue)) {
3687 newValue = toPlainObject(objValue);
3689 else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
3690 newValue = initCloneObject(srcValue);
3698 // Recursively merge objects and arrays (susceptible to call stack limits).
3699 stack.set(srcValue, newValue);
3700 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3701 stack['delete'](srcValue);
3703 assignMergeValue(object, key, newValue);
3707 * The base implementation of `_.nth` which doesn't coerce arguments.
3710 * @param {Array} array The array to query.
3711 * @param {number} n The index of the element to return.
3712 * @returns {*} Returns the nth element of `array`.
3714 function baseNth(array, n) {
3715 var length = array.length;
3719 n += n < 0 ? length : 0;
3720 return isIndex(n, length) ? array[n] : undefined;
3724 * The base implementation of `_.orderBy` without param guards.
3727 * @param {Array|Object} collection The collection to iterate over.
3728 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
3729 * @param {string[]} orders The sort orders of `iteratees`.
3730 * @returns {Array} Returns the new sorted array.
3732 function baseOrderBy(collection, iteratees, orders) {
3734 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
3736 var result = baseMap(collection, function(value, key, collection) {
3737 var criteria = arrayMap(iteratees, function(iteratee) {
3738 return iteratee(value);
3740 return { 'criteria': criteria, 'index': ++index, 'value': value };
3743 return baseSortBy(result, function(object, other) {
3744 return compareMultiple(object, other, orders);
3749 * The base implementation of `_.pick` without support for individual
3750 * property identifiers.
3753 * @param {Object} object The source object.
3754 * @param {string[]} paths The property paths to pick.
3755 * @returns {Object} Returns the new object.
3757 function basePick(object, paths) {
3758 return basePickBy(object, paths, function(value, path) {
3759 return hasIn(object, path);
3764 * The base implementation of `_.pickBy` without support for iteratee shorthands.
3767 * @param {Object} object The source object.
3768 * @param {string[]} paths The property paths to pick.
3769 * @param {Function} predicate The function invoked per property.
3770 * @returns {Object} Returns the new object.
3772 function basePickBy(object, paths, predicate) {
3774 length = paths.length,
3777 while (++index < length) {
3778 var path = paths[index],
3779 value = baseGet(object, path);
3781 if (predicate(value, path)) {
3782 baseSet(result, castPath(path, object), value);
3789 * A specialized version of `baseProperty` which supports deep paths.
3792 * @param {Array|string} path The path of the property to get.
3793 * @returns {Function} Returns the new accessor function.
3795 function basePropertyDeep(path) {
3796 return function(object) {
3797 return baseGet(object, path);
3802 * The base implementation of `_.pullAllBy` without support for iteratee
3806 * @param {Array} array The array to modify.
3807 * @param {Array} values The values to remove.
3808 * @param {Function} [iteratee] The iteratee invoked per element.
3809 * @param {Function} [comparator] The comparator invoked per element.
3810 * @returns {Array} Returns `array`.
3812 function basePullAll(array, values, iteratee, comparator) {
3813 var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3815 length = values.length,
3818 if (array === values) {
3819 values = copyArray(values);
3822 seen = arrayMap(array, baseUnary(iteratee));
3824 while (++index < length) {
3826 value = values[index],
3827 computed = iteratee ? iteratee(value) : value;
3829 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3830 if (seen !== array) {
3831 splice.call(seen, fromIndex, 1);
3833 splice.call(array, fromIndex, 1);
3840 * The base implementation of `_.pullAt` without support for individual
3841 * indexes or capturing the removed elements.
3844 * @param {Array} array The array to modify.
3845 * @param {number[]} indexes The indexes of elements to remove.
3846 * @returns {Array} Returns `array`.
3848 function basePullAt(array, indexes) {
3849 var length = array ? indexes.length : 0,
3850 lastIndex = length - 1;
3853 var index = indexes[length];
3854 if (length == lastIndex || index !== previous) {
3855 var previous = index;
3856 if (isIndex(index)) {
3857 splice.call(array, index, 1);
3859 baseUnset(array, index);
3867 * The base implementation of `_.random` without support for returning
3868 * floating-point numbers.
3871 * @param {number} lower The lower bound.
3872 * @param {number} upper The upper bound.
3873 * @returns {number} Returns the random number.
3875 function baseRandom(lower, upper) {
3876 return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
3880 * The base implementation of `_.range` and `_.rangeRight` which doesn't
3884 * @param {number} start The start of the range.
3885 * @param {number} end The end of the range.
3886 * @param {number} step The value to increment or decrement by.
3887 * @param {boolean} [fromRight] Specify iterating from right to left.
3888 * @returns {Array} Returns the range of numbers.
3890 function baseRange(start, end, step, fromRight) {
3892 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
3893 result = Array(length);
3896 result[fromRight ? length : ++index] = start;
3903 * The base implementation of `_.repeat` which doesn't coerce arguments.
3906 * @param {string} string The string to repeat.
3907 * @param {number} n The number of times to repeat the string.
3908 * @returns {string} Returns the repeated string.
3910 function baseRepeat(string, n) {
3912 if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
3915 // Leverage the exponentiation by squaring algorithm for a faster repeat.
3916 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
3921 n = nativeFloor(n / 2);
3931 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
3934 * @param {Function} func The function to apply a rest parameter to.
3935 * @param {number} [start=func.length-1] The start position of the rest parameter.
3936 * @returns {Function} Returns the new function.
3938 function baseRest(func, start) {
3939 return setToString(overRest(func, start, identity), func + '');
3943 * The base implementation of `_.sample`.
3946 * @param {Array|Object} collection The collection to sample.
3947 * @returns {*} Returns the random element.
3949 function baseSample(collection) {
3950 return arraySample(values(collection));
3954 * The base implementation of `_.sampleSize` without param guards.
3957 * @param {Array|Object} collection The collection to sample.
3958 * @param {number} n The number of elements to sample.
3959 * @returns {Array} Returns the random elements.
3961 function baseSampleSize(collection, n) {
3962 var array = values(collection);
3963 return shuffleSelf(array, baseClamp(n, 0, array.length));
3967 * The base implementation of `_.set`.
3970 * @param {Object} object The object to modify.
3971 * @param {Array|string} path The path of the property to set.
3972 * @param {*} value The value to set.
3973 * @param {Function} [customizer] The function to customize path creation.
3974 * @returns {Object} Returns `object`.
3976 function baseSet(object, path, value, customizer) {
3977 if (!isObject(object)) {
3980 path = castPath(path, object);
3983 length = path.length,
3984 lastIndex = length - 1,
3987 while (nested != null && ++index < length) {
3988 var key = toKey(path[index]),
3991 if (index != lastIndex) {
3992 var objValue = nested[key];
3993 newValue = customizer ? customizer(objValue, key, nested) : undefined;
3994 if (newValue === undefined) {
3995 newValue = isObject(objValue)
3997 : (isIndex(path[index + 1]) ? [] : {});
4000 assignValue(nested, key, newValue);
4001 nested = nested[key];
4007 * The base implementation of `setData` without support for hot loop shorting.
4010 * @param {Function} func The function to associate metadata with.
4011 * @param {*} data The metadata.
4012 * @returns {Function} Returns `func`.
4014 var baseSetData = !metaMap ? identity : function(func, data) {
4015 metaMap.set(func, data);
4020 * The base implementation of `setToString` without support for hot loop shorting.
4023 * @param {Function} func The function to modify.
4024 * @param {Function} string The `toString` result.
4025 * @returns {Function} Returns `func`.
4027 var baseSetToString = !defineProperty ? identity : function(func, string) {
4028 return defineProperty(func, 'toString', {
4029 'configurable': true,
4030 'enumerable': false,
4031 'value': constant(string),
4037 * The base implementation of `_.shuffle`.
4040 * @param {Array|Object} collection The collection to shuffle.
4041 * @returns {Array} Returns the new shuffled array.
4043 function baseShuffle(collection) {
4044 return shuffleSelf(values(collection));
4048 * The base implementation of `_.slice` without an iteratee call guard.
4051 * @param {Array} array The array to slice.
4052 * @param {number} [start=0] The start position.
4053 * @param {number} [end=array.length] The end position.
4054 * @returns {Array} Returns the slice of `array`.
4056 function baseSlice(array, start, end) {
4058 length = array.length;
4061 start = -start > length ? 0 : (length + start);
4063 end = end > length ? length : end;
4067 length = start > end ? 0 : ((end - start) >>> 0);
4070 var result = Array(length);
4071 while (++index < length) {
4072 result[index] = array[index + start];
4078 * The base implementation of `_.some` without support for iteratee shorthands.
4081 * @param {Array|Object} collection The collection to iterate over.
4082 * @param {Function} predicate The function invoked per iteration.
4083 * @returns {boolean} Returns `true` if any element passes the predicate check,
4086 function baseSome(collection, predicate) {
4089 baseEach(collection, function(value, index, collection) {
4090 result = predicate(value, index, collection);
4097 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
4098 * performs a binary search of `array` to determine the index at which `value`
4099 * should be inserted into `array` in order to maintain its sort order.
4102 * @param {Array} array The sorted array to inspect.
4103 * @param {*} value The value to evaluate.
4104 * @param {boolean} [retHighest] Specify returning the highest qualified index.
4105 * @returns {number} Returns the index at which `value` should be inserted
4108 function baseSortedIndex(array, value, retHighest) {
4110 high = array == null ? low : array.length;
4112 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4113 while (low < high) {
4114 var mid = (low + high) >>> 1,
4115 computed = array[mid];
4117 if (computed !== null && !isSymbol(computed) &&
4118 (retHighest ? (computed <= value) : (computed < value))) {
4126 return baseSortedIndexBy(array, value, identity, retHighest);
4130 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
4131 * which invokes `iteratee` for `value` and each element of `array` to compute
4132 * their sort ranking. The iteratee is invoked with one argument; (value).
4135 * @param {Array} array The sorted array to inspect.
4136 * @param {*} value The value to evaluate.
4137 * @param {Function} iteratee The iteratee invoked per element.
4138 * @param {boolean} [retHighest] Specify returning the highest qualified index.
4139 * @returns {number} Returns the index at which `value` should be inserted
4142 function baseSortedIndexBy(array, value, iteratee, retHighest) {
4143 value = iteratee(value);
4146 high = array == null ? 0 : array.length,
4147 valIsNaN = value !== value,
4148 valIsNull = value === null,
4149 valIsSymbol = isSymbol(value),
4150 valIsUndefined = value === undefined;
4152 while (low < high) {
4153 var mid = nativeFloor((low + high) / 2),
4154 computed = iteratee(array[mid]),
4155 othIsDefined = computed !== undefined,
4156 othIsNull = computed === null,
4157 othIsReflexive = computed === computed,
4158 othIsSymbol = isSymbol(computed);
4161 var setLow = retHighest || othIsReflexive;
4162 } else if (valIsUndefined) {
4163 setLow = othIsReflexive && (retHighest || othIsDefined);
4164 } else if (valIsNull) {
4165 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
4166 } else if (valIsSymbol) {
4167 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
4168 } else if (othIsNull || othIsSymbol) {
4171 setLow = retHighest ? (computed <= value) : (computed < value);
4179 return nativeMin(high, MAX_ARRAY_INDEX);
4183 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4184 * support for iteratee shorthands.
4187 * @param {Array} array The array to inspect.
4188 * @param {Function} [iteratee] The iteratee invoked per element.
4189 * @returns {Array} Returns the new duplicate free array.
4191 function baseSortedUniq(array, iteratee) {
4193 length = array.length,
4197 while (++index < length) {
4198 var value = array[index],
4199 computed = iteratee ? iteratee(value) : value;
4201 if (!index || !eq(computed, seen)) {
4202 var seen = computed;
4203 result[resIndex++] = value === 0 ? 0 : value;
4210 * The base implementation of `_.toNumber` which doesn't ensure correct
4211 * conversions of binary, hexadecimal, or octal string values.
4214 * @param {*} value The value to process.
4215 * @returns {number} Returns the number.
4217 function baseToNumber(value) {
4218 if (typeof value == 'number') {
4221 if (isSymbol(value)) {
4228 * The base implementation of `_.toString` which doesn't convert nullish
4229 * values to empty strings.
4232 * @param {*} value The value to process.
4233 * @returns {string} Returns the string.
4235 function baseToString(value) {
4236 // Exit early for strings to avoid a performance hit in some environments.
4237 if (typeof value == 'string') {
4240 if (isArray(value)) {
4241 // Recursively convert values (susceptible to call stack limits).
4242 return arrayMap(value, baseToString) + '';
4244 if (isSymbol(value)) {
4245 return symbolToString ? symbolToString.call(value) : '';
4247 var result = (value + '');
4248 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4252 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
4255 * @param {Array} array The array to inspect.
4256 * @param {Function} [iteratee] The iteratee invoked per element.
4257 * @param {Function} [comparator] The comparator invoked per element.
4258 * @returns {Array} Returns the new duplicate free array.
4260 function baseUniq(array, iteratee, comparator) {
4262 includes = arrayIncludes,
4263 length = array.length,
4270 includes = arrayIncludesWith;
4272 else if (length >= LARGE_ARRAY_SIZE) {
4273 var set = iteratee ? null : createSet(array);
4275 return setToArray(set);
4278 includes = cacheHas;
4279 seen = new SetCache;
4282 seen = iteratee ? [] : result;
4285 while (++index < length) {
4286 var value = array[index],
4287 computed = iteratee ? iteratee(value) : value;
4289 value = (comparator || value !== 0) ? value : 0;
4290 if (isCommon && computed === computed) {
4291 var seenIndex = seen.length;
4292 while (seenIndex--) {
4293 if (seen[seenIndex] === computed) {
4298 seen.push(computed);
4302 else if (!includes(seen, computed, comparator)) {
4303 if (seen !== result) {
4304 seen.push(computed);
4313 * The base implementation of `_.unset`.
4316 * @param {Object} object The object to modify.
4317 * @param {Array|string} path The property path to unset.
4318 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
4320 function baseUnset(object, path) {
4321 path = castPath(path, object);
4322 object = parent(object, path);
4323 return object == null || delete object[toKey(last(path))];
4327 * The base implementation of `_.update`.
4330 * @param {Object} object The object to modify.
4331 * @param {Array|string} path The path of the property to update.
4332 * @param {Function} updater The function to produce the updated value.
4333 * @param {Function} [customizer] The function to customize path creation.
4334 * @returns {Object} Returns `object`.
4336 function baseUpdate(object, path, updater, customizer) {
4337 return baseSet(object, path, updater(baseGet(object, path)), customizer);
4341 * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4342 * without support for iteratee shorthands.
4345 * @param {Array} array The array to query.
4346 * @param {Function} predicate The function invoked per iteration.
4347 * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
4348 * @param {boolean} [fromRight] Specify iterating from right to left.
4349 * @returns {Array} Returns the slice of `array`.
4351 function baseWhile(array, predicate, isDrop, fromRight) {
4352 var length = array.length,
4353 index = fromRight ? length : -1;
4355 while ((fromRight ? index-- : ++index < length) &&
4356 predicate(array[index], index, array)) {}
4359 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
4360 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
4364 * The base implementation of `wrapperValue` which returns the result of
4365 * performing a sequence of actions on the unwrapped `value`, where each
4366 * successive action is supplied the return value of the previous.
4369 * @param {*} value The unwrapped value.
4370 * @param {Array} actions Actions to perform to resolve the unwrapped value.
4371 * @returns {*} Returns the resolved value.
4373 function baseWrapperValue(value, actions) {
4375 if (result instanceof LazyWrapper) {
4376 result = result.value();
4378 return arrayReduce(actions, function(result, action) {
4379 return action.func.apply(action.thisArg, arrayPush([result], action.args));
4384 * The base implementation of methods like `_.xor`, without support for
4385 * iteratee shorthands, that accepts an array of arrays to inspect.
4388 * @param {Array} arrays The arrays to inspect.
4389 * @param {Function} [iteratee] The iteratee invoked per element.
4390 * @param {Function} [comparator] The comparator invoked per element.
4391 * @returns {Array} Returns the new array of values.
4393 function baseXor(arrays, iteratee, comparator) {
4394 var length = arrays.length;
4396 return length ? baseUniq(arrays[0]) : [];
4399 result = Array(length);
4401 while (++index < length) {
4402 var array = arrays[index],
4405 while (++othIndex < length) {
4406 if (othIndex != index) {
4407 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4411 return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4415 * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
4418 * @param {Array} props The property identifiers.
4419 * @param {Array} values The property values.
4420 * @param {Function} assignFunc The function to assign values.
4421 * @returns {Object} Returns the new object.
4423 function baseZipObject(props, values, assignFunc) {
4425 length = props.length,
4426 valsLength = values.length,
4429 while (++index < length) {
4430 var value = index < valsLength ? values[index] : undefined;
4431 assignFunc(result, props[index], value);
4437 * Casts `value` to an empty array if it's not an array like object.
4440 * @param {*} value The value to inspect.
4441 * @returns {Array|Object} Returns the cast array-like object.
4443 function castArrayLikeObject(value) {
4444 return isArrayLikeObject(value) ? value : [];
4448 * Casts `value` to `identity` if it's not a function.
4451 * @param {*} value The value to inspect.
4452 * @returns {Function} Returns cast function.
4454 function castFunction(value) {
4455 return typeof value == 'function' ? value : identity;
4459 * Casts `value` to a path array if it's not one.
4462 * @param {*} value The value to inspect.
4463 * @param {Object} [object] The object to query keys on.
4464 * @returns {Array} Returns the cast property path array.
4466 function castPath(value, object) {
4467 if (isArray(value)) {
4470 return isKey(value, object) ? [value] : stringToPath(toString(value));
4474 * A `baseRest` alias which can be replaced with `identity` by module
4475 * replacement plugins.
4479 * @param {Function} func The function to apply a rest parameter to.
4480 * @returns {Function} Returns the new function.
4482 var castRest = baseRest;
4485 * Casts `array` to a slice if it's needed.
4488 * @param {Array} array The array to inspect.
4489 * @param {number} start The start position.
4490 * @param {number} [end=array.length] The end position.
4491 * @returns {Array} Returns the cast slice.
4493 function castSlice(array, start, end) {
4494 var length = array.length;
4495 end = end === undefined ? length : end;
4496 return (!start && end >= length) ? array : baseSlice(array, start, end);
4500 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4503 * @param {number|Object} id The timer id or timeout object of the timer to clear.
4505 var clearTimeout = ctxClearTimeout || function(id) {
4506 return root.clearTimeout(id);
4510 * Creates a clone of `buffer`.
4513 * @param {Buffer} buffer The buffer to clone.
4514 * @param {boolean} [isDeep] Specify a deep clone.
4515 * @returns {Buffer} Returns the cloned buffer.
4517 function cloneBuffer(buffer, isDeep) {
4519 return buffer.slice();
4521 var length = buffer.length,
4522 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4524 buffer.copy(result);
4529 * Creates a clone of `arrayBuffer`.
4532 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4533 * @returns {ArrayBuffer} Returns the cloned array buffer.
4535 function cloneArrayBuffer(arrayBuffer) {
4536 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4537 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4542 * Creates a clone of `dataView`.
4545 * @param {Object} dataView The data view to clone.
4546 * @param {boolean} [isDeep] Specify a deep clone.
4547 * @returns {Object} Returns the cloned data view.
4549 function cloneDataView(dataView, isDeep) {
4550 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4551 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4555 * Creates a clone of `map`.
4558 * @param {Object} map The map to clone.
4559 * @param {Function} cloneFunc The function to clone values.
4560 * @param {boolean} [isDeep] Specify a deep clone.
4561 * @returns {Object} Returns the cloned map.
4563 function cloneMap(map, isDeep, cloneFunc) {
4564 var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
4565 return arrayReduce(array, addMapEntry, new map.constructor);
4569 * Creates a clone of `regexp`.
4572 * @param {Object} regexp The regexp to clone.
4573 * @returns {Object} Returns the cloned regexp.
4575 function cloneRegExp(regexp) {
4576 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4577 result.lastIndex = regexp.lastIndex;
4582 * Creates a clone of `set`.
4585 * @param {Object} set The set to clone.
4586 * @param {Function} cloneFunc The function to clone values.
4587 * @param {boolean} [isDeep] Specify a deep clone.
4588 * @returns {Object} Returns the cloned set.
4590 function cloneSet(set, isDeep, cloneFunc) {
4591 var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
4592 return arrayReduce(array, addSetEntry, new set.constructor);
4596 * Creates a clone of the `symbol` object.
4599 * @param {Object} symbol The symbol object to clone.
4600 * @returns {Object} Returns the cloned symbol object.
4602 function cloneSymbol(symbol) {
4603 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4607 * Creates a clone of `typedArray`.
4610 * @param {Object} typedArray The typed array to clone.
4611 * @param {boolean} [isDeep] Specify a deep clone.
4612 * @returns {Object} Returns the cloned typed array.
4614 function cloneTypedArray(typedArray, isDeep) {
4615 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4616 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4620 * Compares values to sort them in ascending order.
4623 * @param {*} value The value to compare.
4624 * @param {*} other The other value to compare.
4625 * @returns {number} Returns the sort order indicator for `value`.
4627 function compareAscending(value, other) {
4628 if (value !== other) {
4629 var valIsDefined = value !== undefined,
4630 valIsNull = value === null,
4631 valIsReflexive = value === value,
4632 valIsSymbol = isSymbol(value);
4634 var othIsDefined = other !== undefined,
4635 othIsNull = other === null,
4636 othIsReflexive = other === other,
4637 othIsSymbol = isSymbol(other);
4639 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4640 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4641 (valIsNull && othIsDefined && othIsReflexive) ||
4642 (!valIsDefined && othIsReflexive) ||
4646 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4647 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4648 (othIsNull && valIsDefined && valIsReflexive) ||
4649 (!othIsDefined && valIsReflexive) ||
4658 * Used by `_.orderBy` to compare multiple properties of a value to another
4659 * and stable sort them.
4661 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4662 * specify an order of "desc" for descending or "asc" for ascending sort order
4663 * of corresponding values.
4666 * @param {Object} object The object to compare.
4667 * @param {Object} other The other object to compare.
4668 * @param {boolean[]|string[]} orders The order to sort by for each property.
4669 * @returns {number} Returns the sort order indicator for `object`.
4671 function compareMultiple(object, other, orders) {
4673 objCriteria = object.criteria,
4674 othCriteria = other.criteria,
4675 length = objCriteria.length,
4676 ordersLength = orders.length;
4678 while (++index < length) {
4679 var result = compareAscending(objCriteria[index], othCriteria[index]);
4681 if (index >= ordersLength) {
4684 var order = orders[index];
4685 return result * (order == 'desc' ? -1 : 1);
4688 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
4689 // that causes it, under certain circumstances, to provide the same value for
4690 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
4691 // for more details.
4693 // This also ensures a stable sort in V8 and other engines.
4694 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
4695 return object.index - other.index;
4699 * Creates an array that is the composition of partially applied arguments,
4700 * placeholders, and provided arguments into a single array of arguments.
4703 * @param {Array} args The provided arguments.
4704 * @param {Array} partials The arguments to prepend to those provided.
4705 * @param {Array} holders The `partials` placeholder indexes.
4706 * @params {boolean} [isCurried] Specify composing for a curried function.
4707 * @returns {Array} Returns the new array of composed arguments.
4709 function composeArgs(args, partials, holders, isCurried) {
4711 argsLength = args.length,
4712 holdersLength = holders.length,
4714 leftLength = partials.length,
4715 rangeLength = nativeMax(argsLength - holdersLength, 0),
4716 result = Array(leftLength + rangeLength),
4717 isUncurried = !isCurried;
4719 while (++leftIndex < leftLength) {
4720 result[leftIndex] = partials[leftIndex];
4722 while (++argsIndex < holdersLength) {
4723 if (isUncurried || argsIndex < argsLength) {
4724 result[holders[argsIndex]] = args[argsIndex];
4727 while (rangeLength--) {
4728 result[leftIndex++] = args[argsIndex++];
4734 * This function is like `composeArgs` except that the arguments composition
4735 * is tailored for `_.partialRight`.
4738 * @param {Array} args The provided arguments.
4739 * @param {Array} partials The arguments to append to those provided.
4740 * @param {Array} holders The `partials` placeholder indexes.
4741 * @params {boolean} [isCurried] Specify composing for a curried function.
4742 * @returns {Array} Returns the new array of composed arguments.
4744 function composeArgsRight(args, partials, holders, isCurried) {
4746 argsLength = args.length,
4748 holdersLength = holders.length,
4750 rightLength = partials.length,
4751 rangeLength = nativeMax(argsLength - holdersLength, 0),
4752 result = Array(rangeLength + rightLength),
4753 isUncurried = !isCurried;
4755 while (++argsIndex < rangeLength) {
4756 result[argsIndex] = args[argsIndex];
4758 var offset = argsIndex;
4759 while (++rightIndex < rightLength) {
4760 result[offset + rightIndex] = partials[rightIndex];
4762 while (++holdersIndex < holdersLength) {
4763 if (isUncurried || argsIndex < argsLength) {
4764 result[offset + holders[holdersIndex]] = args[argsIndex++];
4771 * Copies the values of `source` to `array`.
4774 * @param {Array} source The array to copy values from.
4775 * @param {Array} [array=[]] The array to copy values to.
4776 * @returns {Array} Returns `array`.
4778 function copyArray(source, array) {
4780 length = source.length;
4782 array || (array = Array(length));
4783 while (++index < length) {
4784 array[index] = source[index];
4790 * Copies properties of `source` to `object`.
4793 * @param {Object} source The object to copy properties from.
4794 * @param {Array} props The property identifiers to copy.
4795 * @param {Object} [object={}] The object to copy properties to.
4796 * @param {Function} [customizer] The function to customize copied values.
4797 * @returns {Object} Returns `object`.
4799 function copyObject(source, props, object, customizer) {
4800 var isNew = !object;
4801 object || (object = {});
4804 length = props.length;
4806 while (++index < length) {
4807 var key = props[index];
4809 var newValue = customizer
4810 ? customizer(object[key], source[key], key, object, source)
4813 if (newValue === undefined) {
4814 newValue = source[key];
4817 baseAssignValue(object, key, newValue);
4819 assignValue(object, key, newValue);
4826 * Copies own symbols of `source` to `object`.
4829 * @param {Object} source The object to copy symbols from.
4830 * @param {Object} [object={}] The object to copy symbols to.
4831 * @returns {Object} Returns `object`.
4833 function copySymbols(source, object) {
4834 return copyObject(source, getSymbols(source), object);
4838 * Copies own and inherited symbols of `source` to `object`.
4841 * @param {Object} source The object to copy symbols from.
4842 * @param {Object} [object={}] The object to copy symbols to.
4843 * @returns {Object} Returns `object`.
4845 function copySymbolsIn(source, object) {
4846 return copyObject(source, getSymbolsIn(source), object);
4850 * Creates a function like `_.groupBy`.
4853 * @param {Function} setter The function to set accumulator values.
4854 * @param {Function} [initializer] The accumulator object initializer.
4855 * @returns {Function} Returns the new aggregator function.
4857 function createAggregator(setter, initializer) {
4858 return function(collection, iteratee) {
4859 var func = isArray(collection) ? arrayAggregator : baseAggregator,
4860 accumulator = initializer ? initializer() : {};
4862 return func(collection, setter, getIteratee(iteratee, 2), accumulator);
4867 * Creates a function like `_.assign`.
4870 * @param {Function} assigner The function to assign values.
4871 * @returns {Function} Returns the new assigner function.
4873 function createAssigner(assigner) {
4874 return baseRest(function(object, sources) {
4876 length = sources.length,
4877 customizer = length > 1 ? sources[length - 1] : undefined,
4878 guard = length > 2 ? sources[2] : undefined;
4880 customizer = (assigner.length > 3 && typeof customizer == 'function')
4881 ? (length--, customizer)
4884 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
4885 customizer = length < 3 ? undefined : customizer;
4888 object = Object(object);
4889 while (++index < length) {
4890 var source = sources[index];
4892 assigner(object, source, index, customizer);
4900 * Creates a `baseEach` or `baseEachRight` function.
4903 * @param {Function} eachFunc The function to iterate over a collection.
4904 * @param {boolean} [fromRight] Specify iterating from right to left.
4905 * @returns {Function} Returns the new base function.
4907 function createBaseEach(eachFunc, fromRight) {
4908 return function(collection, iteratee) {
4909 if (collection == null) {
4912 if (!isArrayLike(collection)) {
4913 return eachFunc(collection, iteratee);
4915 var length = collection.length,
4916 index = fromRight ? length : -1,
4917 iterable = Object(collection);
4919 while ((fromRight ? index-- : ++index < length)) {
4920 if (iteratee(iterable[index], index, iterable) === false) {
4929 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
4932 * @param {boolean} [fromRight] Specify iterating from right to left.
4933 * @returns {Function} Returns the new base function.
4935 function createBaseFor(fromRight) {
4936 return function(object, iteratee, keysFunc) {
4938 iterable = Object(object),
4939 props = keysFunc(object),
4940 length = props.length;
4943 var key = props[fromRight ? length : ++index];
4944 if (iteratee(iterable[key], key, iterable) === false) {
4953 * Creates a function that wraps `func` to invoke it with the optional `this`
4954 * binding of `thisArg`.
4957 * @param {Function} func The function to wrap.
4958 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
4959 * @param {*} [thisArg] The `this` binding of `func`.
4960 * @returns {Function} Returns the new wrapped function.
4962 function createBind(func, bitmask, thisArg) {
4963 var isBind = bitmask & WRAP_BIND_FLAG,
4964 Ctor = createCtor(func);
4966 function wrapper() {
4967 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4968 return fn.apply(isBind ? thisArg : this, arguments);
4974 * Creates a function like `_.lowerFirst`.
4977 * @param {string} methodName The name of the `String` case method to use.
4978 * @returns {Function} Returns the new case function.
4980 function createCaseFirst(methodName) {
4981 return function(string) {
4982 string = toString(string);
4984 var strSymbols = hasUnicode(string)
4985 ? stringToArray(string)
4988 var chr = strSymbols
4992 var trailing = strSymbols
4993 ? castSlice(strSymbols, 1).join('')
4996 return chr[methodName]() + trailing;
5001 * Creates a function like `_.camelCase`.
5004 * @param {Function} callback The function to combine each word.
5005 * @returns {Function} Returns the new compounder function.
5007 function createCompounder(callback) {
5008 return function(string) {
5009 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
5014 * Creates a function that produces an instance of `Ctor` regardless of
5015 * whether it was invoked as part of a `new` expression or by `call` or `apply`.
5018 * @param {Function} Ctor The constructor to wrap.
5019 * @returns {Function} Returns the new wrapped function.
5021 function createCtor(Ctor) {
5023 // Use a `switch` statement to work with class constructors. See
5024 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
5025 // for more details.
5026 var args = arguments;
5027 switch (args.length) {
5028 case 0: return new Ctor;
5029 case 1: return new Ctor(args[0]);
5030 case 2: return new Ctor(args[0], args[1]);
5031 case 3: return new Ctor(args[0], args[1], args[2]);
5032 case 4: return new Ctor(args[0], args[1], args[2], args[3]);
5033 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5034 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5035 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5037 var thisBinding = baseCreate(Ctor.prototype),
5038 result = Ctor.apply(thisBinding, args);
5040 // Mimic the constructor's `return` behavior.
5041 // See https://es5.github.io/#x13.2.2 for more details.
5042 return isObject(result) ? result : thisBinding;
5047 * Creates a function that wraps `func` to enable currying.
5050 * @param {Function} func The function to wrap.
5051 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5052 * @param {number} arity The arity of `func`.
5053 * @returns {Function} Returns the new wrapped function.
5055 function createCurry(func, bitmask, arity) {
5056 var Ctor = createCtor(func);
5058 function wrapper() {
5059 var length = arguments.length,
5060 args = Array(length),
5062 placeholder = getHolder(wrapper);
5065 args[index] = arguments[index];
5067 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5069 : replaceHolders(args, placeholder);
5071 length -= holders.length;
5072 if (length < arity) {
5073 return createRecurry(
5074 func, bitmask, createHybrid, wrapper.placeholder, undefined,
5075 args, holders, undefined, undefined, arity - length);
5077 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5078 return apply(fn, this, args);
5084 * Creates a `_.find` or `_.findLast` function.
5087 * @param {Function} findIndexFunc The function to find the collection index.
5088 * @returns {Function} Returns the new find function.
5090 function createFind(findIndexFunc) {
5091 return function(collection, predicate, fromIndex) {
5092 var iterable = Object(collection);
5093 if (!isArrayLike(collection)) {
5094 var iteratee = getIteratee(predicate, 3);
5095 collection = keys(collection);
5096 predicate = function(key) { return iteratee(iterable[key], key, iterable); };
5098 var index = findIndexFunc(collection, predicate, fromIndex);
5099 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
5104 * Creates a `_.flow` or `_.flowRight` function.
5107 * @param {boolean} [fromRight] Specify iterating from right to left.
5108 * @returns {Function} Returns the new flow function.
5110 function createFlow(fromRight) {
5111 return flatRest(function(funcs) {
5112 var length = funcs.length,
5114 prereq = LodashWrapper.prototype.thru;
5120 var func = funcs[index];
5121 if (typeof func != 'function') {
5122 throw new TypeError(FUNC_ERROR_TEXT);
5124 if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5125 var wrapper = new LodashWrapper([], true);
5128 index = wrapper ? index : length;
5129 while (++index < length) {
5130 func = funcs[index];
5132 var funcName = getFuncName(func),
5133 data = funcName == 'wrapper' ? getData(func) : undefined;
5135 if (data && isLaziable(data[0]) &&
5136 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
5137 !data[4].length && data[9] == 1
5139 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5141 wrapper = (func.length == 1 && isLaziable(func))
5142 ? wrapper[funcName]()
5143 : wrapper.thru(func);
5147 var args = arguments,
5150 if (wrapper && args.length == 1 && isArray(value)) {
5151 return wrapper.plant(value).value();
5154 result = length ? funcs[index].apply(this, args) : value;
5156 while (++index < length) {
5157 result = funcs[index].call(this, result);
5165 * Creates a function that wraps `func` to invoke it with optional `this`
5166 * binding of `thisArg`, partial application, and currying.
5169 * @param {Function|string} func The function or method name to wrap.
5170 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5171 * @param {*} [thisArg] The `this` binding of `func`.
5172 * @param {Array} [partials] The arguments to prepend to those provided to
5174 * @param {Array} [holders] The `partials` placeholder indexes.
5175 * @param {Array} [partialsRight] The arguments to append to those provided
5176 * to the new function.
5177 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
5178 * @param {Array} [argPos] The argument positions of the new function.
5179 * @param {number} [ary] The arity cap of `func`.
5180 * @param {number} [arity] The arity of `func`.
5181 * @returns {Function} Returns the new wrapped function.
5183 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5184 var isAry = bitmask & WRAP_ARY_FLAG,
5185 isBind = bitmask & WRAP_BIND_FLAG,
5186 isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
5187 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
5188 isFlip = bitmask & WRAP_FLIP_FLAG,
5189 Ctor = isBindKey ? undefined : createCtor(func);
5191 function wrapper() {
5192 var length = arguments.length,
5193 args = Array(length),
5197 args[index] = arguments[index];
5200 var placeholder = getHolder(wrapper),
5201 holdersCount = countHolders(args, placeholder);
5204 args = composeArgs(args, partials, holders, isCurried);
5206 if (partialsRight) {
5207 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
5209 length -= holdersCount;
5210 if (isCurried && length < arity) {
5211 var newHolders = replaceHolders(args, placeholder);
5212 return createRecurry(
5213 func, bitmask, createHybrid, wrapper.placeholder, thisArg,
5214 args, newHolders, argPos, ary, arity - length
5217 var thisBinding = isBind ? thisArg : this,
5218 fn = isBindKey ? thisBinding[func] : func;
5220 length = args.length;
5222 args = reorder(args, argPos);
5223 } else if (isFlip && length > 1) {
5226 if (isAry && ary < length) {
5229 if (this && this !== root && this instanceof wrapper) {
5230 fn = Ctor || createCtor(fn);
5232 return fn.apply(thisBinding, args);
5238 * Creates a function like `_.invertBy`.
5241 * @param {Function} setter The function to set accumulator values.
5242 * @param {Function} toIteratee The function to resolve iteratees.
5243 * @returns {Function} Returns the new inverter function.
5245 function createInverter(setter, toIteratee) {
5246 return function(object, iteratee) {
5247 return baseInverter(object, setter, toIteratee(iteratee), {});
5252 * Creates a function that performs a mathematical operation on two values.
5255 * @param {Function} operator The function to perform the operation.
5256 * @param {number} [defaultValue] The value used for `undefined` arguments.
5257 * @returns {Function} Returns the new mathematical operation function.
5259 function createMathOperation(operator, defaultValue) {
5260 return function(value, other) {
5262 if (value === undefined && other === undefined) {
5263 return defaultValue;
5265 if (value !== undefined) {
5268 if (other !== undefined) {
5269 if (result === undefined) {
5272 if (typeof value == 'string' || typeof other == 'string') {
5273 value = baseToString(value);
5274 other = baseToString(other);
5276 value = baseToNumber(value);
5277 other = baseToNumber(other);
5279 result = operator(value, other);
5286 * Creates a function like `_.over`.
5289 * @param {Function} arrayFunc The function to iterate over iteratees.
5290 * @returns {Function} Returns the new over function.
5292 function createOver(arrayFunc) {
5293 return flatRest(function(iteratees) {
5294 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5295 return baseRest(function(args) {
5297 return arrayFunc(iteratees, function(iteratee) {
5298 return apply(iteratee, thisArg, args);
5305 * Creates the padding for `string` based on `length`. The `chars` string
5306 * is truncated if the number of characters exceeds `length`.
5309 * @param {number} length The padding length.
5310 * @param {string} [chars=' '] The string used as padding.
5311 * @returns {string} Returns the padding for `string`.
5313 function createPadding(length, chars) {
5314 chars = chars === undefined ? ' ' : baseToString(chars);
5316 var charsLength = chars.length;
5317 if (charsLength < 2) {
5318 return charsLength ? baseRepeat(chars, length) : chars;
5320 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
5321 return hasUnicode(chars)
5322 ? castSlice(stringToArray(result), 0, length).join('')
5323 : result.slice(0, length);
5327 * Creates a function that wraps `func` to invoke it with the `this` binding
5328 * of `thisArg` and `partials` prepended to the arguments it receives.
5331 * @param {Function} func The function to wrap.
5332 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5333 * @param {*} thisArg The `this` binding of `func`.
5334 * @param {Array} partials The arguments to prepend to those provided to
5336 * @returns {Function} Returns the new wrapped function.
5338 function createPartial(func, bitmask, thisArg, partials) {
5339 var isBind = bitmask & WRAP_BIND_FLAG,
5340 Ctor = createCtor(func);
5342 function wrapper() {
5344 argsLength = arguments.length,
5346 leftLength = partials.length,
5347 args = Array(leftLength + argsLength),
5348 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5350 while (++leftIndex < leftLength) {
5351 args[leftIndex] = partials[leftIndex];
5353 while (argsLength--) {
5354 args[leftIndex++] = arguments[++argsIndex];
5356 return apply(fn, isBind ? thisArg : this, args);
5362 * Creates a `_.range` or `_.rangeRight` function.
5365 * @param {boolean} [fromRight] Specify iterating from right to left.
5366 * @returns {Function} Returns the new range function.
5368 function createRange(fromRight) {
5369 return function(start, end, step) {
5370 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5371 end = step = undefined;
5373 // Ensure the sign of `-0` is preserved.
5374 start = toFinite(start);
5375 if (end === undefined) {
5379 end = toFinite(end);
5381 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
5382 return baseRange(start, end, step, fromRight);
5387 * Creates a function that performs a relational operation on two values.
5390 * @param {Function} operator The function to perform the operation.
5391 * @returns {Function} Returns the new relational operation function.
5393 function createRelationalOperation(operator) {
5394 return function(value, other) {
5395 if (!(typeof value == 'string' && typeof other == 'string')) {
5396 value = toNumber(value);
5397 other = toNumber(other);
5399 return operator(value, other);
5404 * Creates a function that wraps `func` to continue currying.
5407 * @param {Function} func The function to wrap.
5408 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5409 * @param {Function} wrapFunc The function to create the `func` wrapper.
5410 * @param {*} placeholder The placeholder value.
5411 * @param {*} [thisArg] The `this` binding of `func`.
5412 * @param {Array} [partials] The arguments to prepend to those provided to
5414 * @param {Array} [holders] The `partials` placeholder indexes.
5415 * @param {Array} [argPos] The argument positions of the new function.
5416 * @param {number} [ary] The arity cap of `func`.
5417 * @param {number} [arity] The arity of `func`.
5418 * @returns {Function} Returns the new wrapped function.
5420 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
5421 var isCurry = bitmask & WRAP_CURRY_FLAG,
5422 newHolders = isCurry ? holders : undefined,
5423 newHoldersRight = isCurry ? undefined : holders,
5424 newPartials = isCurry ? partials : undefined,
5425 newPartialsRight = isCurry ? undefined : partials;
5427 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
5428 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
5430 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
5431 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
5434 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5435 newHoldersRight, argPos, ary, arity
5438 var result = wrapFunc.apply(undefined, newData);
5439 if (isLaziable(func)) {
5440 setData(result, newData);
5442 result.placeholder = placeholder;
5443 return setWrapToString(result, func, bitmask);
5447 * Creates a function like `_.round`.
5450 * @param {string} methodName The name of the `Math` method to use when rounding.
5451 * @returns {Function} Returns the new round function.
5453 function createRound(methodName) {
5454 var func = Math[methodName];
5455 return function(number, precision) {
5456 number = toNumber(number);
5457 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
5459 // Shift with exponential notation to avoid floating-point issues.
5460 // See [MDN](https://mdn.io/round#Examples) for more details.
5461 var pair = (toString(number) + 'e').split('e'),
5462 value = func(pair[0] + 'e' + (+pair[1] + precision));
5464 pair = (toString(value) + 'e').split('e');
5465 return +(pair[0] + 'e' + (+pair[1] - precision));
5467 return func(number);
5472 * Creates a set object of `values`.
5475 * @param {Array} values The values to add to the set.
5476 * @returns {Object} Returns the new set.
5478 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
5479 return new Set(values);
5483 * Creates a `_.toPairs` or `_.toPairsIn` function.
5486 * @param {Function} keysFunc The function to get the keys of a given object.
5487 * @returns {Function} Returns the new pairs function.
5489 function createToPairs(keysFunc) {
5490 return function(object) {
5491 var tag = getTag(object);
5492 if (tag == mapTag) {
5493 return mapToArray(object);
5495 if (tag == setTag) {
5496 return setToPairs(object);
5498 return baseToPairs(object, keysFunc(object));
5503 * Creates a function that either curries or invokes `func` with optional
5504 * `this` binding and partially applied arguments.
5507 * @param {Function|string} func The function or method name to wrap.
5508 * @param {number} bitmask The bitmask flags.
5511 * 4 - `_.curry` or `_.curryRight` of a bound function
5513 * 16 - `_.curryRight`
5515 * 64 - `_.partialRight`
5519 * @param {*} [thisArg] The `this` binding of `func`.
5520 * @param {Array} [partials] The arguments to be partially applied.
5521 * @param {Array} [holders] The `partials` placeholder indexes.
5522 * @param {Array} [argPos] The argument positions of the new function.
5523 * @param {number} [ary] The arity cap of `func`.
5524 * @param {number} [arity] The arity of `func`.
5525 * @returns {Function} Returns the new wrapped function.
5527 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5528 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
5529 if (!isBindKey && typeof func != 'function') {
5530 throw new TypeError(FUNC_ERROR_TEXT);
5532 var length = partials ? partials.length : 0;
5534 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
5535 partials = holders = undefined;
5537 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
5538 arity = arity === undefined ? arity : toInteger(arity);
5539 length -= holders ? holders.length : 0;
5541 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
5542 var partialsRight = partials,
5543 holdersRight = holders;
5545 partials = holders = undefined;
5547 var data = isBindKey ? undefined : getData(func);
5550 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5555 mergeData(newData, data);
5558 bitmask = newData[1];
5559 thisArg = newData[2];
5560 partials = newData[3];
5561 holders = newData[4];
5562 arity = newData[9] = newData[9] === undefined
5563 ? (isBindKey ? 0 : func.length)
5564 : nativeMax(newData[9] - length, 0);
5566 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
5567 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
5569 if (!bitmask || bitmask == WRAP_BIND_FLAG) {
5570 var result = createBind(func, bitmask, thisArg);
5571 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
5572 result = createCurry(func, bitmask, arity);
5573 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
5574 result = createPartial(func, bitmask, thisArg, partials);
5576 result = createHybrid.apply(undefined, newData);
5578 var setter = data ? baseSetData : setData;
5579 return setWrapToString(setter(result, newData), func, bitmask);
5583 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
5584 * of source objects to the destination object for all destination properties
5585 * that resolve to `undefined`.
5588 * @param {*} objValue The destination value.
5589 * @param {*} srcValue The source value.
5590 * @param {string} key The key of the property to assign.
5591 * @param {Object} object The parent object of `objValue`.
5592 * @returns {*} Returns the value to assign.
5594 function customDefaultsAssignIn(objValue, srcValue, key, object) {
5595 if (objValue === undefined ||
5596 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
5603 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
5604 * objects into destination objects that are passed thru.
5607 * @param {*} objValue The destination value.
5608 * @param {*} srcValue The source value.
5609 * @param {string} key The key of the property to merge.
5610 * @param {Object} object The parent object of `objValue`.
5611 * @param {Object} source The parent object of `srcValue`.
5612 * @param {Object} [stack] Tracks traversed source values and their merged
5614 * @returns {*} Returns the value to assign.
5616 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
5617 if (isObject(objValue) && isObject(srcValue)) {
5618 // Recursively merge objects and arrays (susceptible to call stack limits).
5619 stack.set(srcValue, objValue);
5620 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
5621 stack['delete'](srcValue);
5627 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
5631 * @param {*} value The value to inspect.
5632 * @param {string} key The key of the property to inspect.
5633 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
5635 function customOmitClone(value) {
5636 return isPlainObject(value) ? undefined : value;
5640 * A specialized version of `baseIsEqualDeep` for arrays with support for
5641 * partial deep comparisons.
5644 * @param {Array} array The array to compare.
5645 * @param {Array} other The other array to compare.
5646 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5647 * @param {Function} customizer The function to customize comparisons.
5648 * @param {Function} equalFunc The function to determine equivalents of values.
5649 * @param {Object} stack Tracks traversed `array` and `other` objects.
5650 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
5652 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
5653 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5654 arrLength = array.length,
5655 othLength = other.length;
5657 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5660 // Assume cyclic values are equal.
5661 var stacked = stack.get(array);
5662 if (stacked && stack.get(other)) {
5663 return stacked == other;
5667 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
5669 stack.set(array, other);
5670 stack.set(other, array);
5672 // Ignore non-index properties.
5673 while (++index < arrLength) {
5674 var arrValue = array[index],
5675 othValue = other[index];
5678 var compared = isPartial
5679 ? customizer(othValue, arrValue, index, other, array, stack)
5680 : customizer(arrValue, othValue, index, array, other, stack);
5682 if (compared !== undefined) {
5689 // Recursively compare arrays (susceptible to call stack limits).
5691 if (!arraySome(other, function(othValue, othIndex) {
5692 if (!cacheHas(seen, othIndex) &&
5693 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
5694 return seen.push(othIndex);
5701 arrValue === othValue ||
5702 equalFunc(arrValue, othValue, bitmask, customizer, stack)
5708 stack['delete'](array);
5709 stack['delete'](other);
5714 * A specialized version of `baseIsEqualDeep` for comparing objects of
5715 * the same `toStringTag`.
5717 * **Note:** This function only supports comparing values with tags of
5718 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5721 * @param {Object} object The object to compare.
5722 * @param {Object} other The other object to compare.
5723 * @param {string} tag The `toStringTag` of the objects to compare.
5724 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5725 * @param {Function} customizer The function to customize comparisons.
5726 * @param {Function} equalFunc The function to determine equivalents of values.
5727 * @param {Object} stack Tracks traversed `object` and `other` objects.
5728 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5730 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
5733 if ((object.byteLength != other.byteLength) ||
5734 (object.byteOffset != other.byteOffset)) {
5737 object = object.buffer;
5738 other = other.buffer;
5740 case arrayBufferTag:
5741 if ((object.byteLength != other.byteLength) ||
5742 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5750 // Coerce booleans to `1` or `0` and dates to milliseconds.
5751 // Invalid dates are coerced to `NaN`.
5752 return eq(+object, +other);
5755 return object.name == other.name && object.message == other.message;
5759 // Coerce regexes to strings and treat strings, primitives and objects,
5760 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
5761 // for more details.
5762 return object == (other + '');
5765 var convert = mapToArray;
5768 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
5769 convert || (convert = setToArray);
5771 if (object.size != other.size && !isPartial) {
5774 // Assume cyclic values are equal.
5775 var stacked = stack.get(object);
5777 return stacked == other;
5779 bitmask |= COMPARE_UNORDERED_FLAG;
5781 // Recursively compare objects (susceptible to call stack limits).
5782 stack.set(object, other);
5783 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
5784 stack['delete'](object);
5788 if (symbolValueOf) {
5789 return symbolValueOf.call(object) == symbolValueOf.call(other);
5796 * A specialized version of `baseIsEqualDeep` for objects with support for
5797 * partial deep comparisons.
5800 * @param {Object} object The object to compare.
5801 * @param {Object} other The other object to compare.
5802 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5803 * @param {Function} customizer The function to customize comparisons.
5804 * @param {Function} equalFunc The function to determine equivalents of values.
5805 * @param {Object} stack Tracks traversed `object` and `other` objects.
5806 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5808 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
5809 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5810 objProps = getAllKeys(object),
5811 objLength = objProps.length,
5812 othProps = getAllKeys(other),
5813 othLength = othProps.length;
5815 if (objLength != othLength && !isPartial) {
5818 var index = objLength;
5820 var key = objProps[index];
5821 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
5825 // Assume cyclic values are equal.
5826 var stacked = stack.get(object);
5827 if (stacked && stack.get(other)) {
5828 return stacked == other;
5831 stack.set(object, other);
5832 stack.set(other, object);
5834 var skipCtor = isPartial;
5835 while (++index < objLength) {
5836 key = objProps[index];
5837 var objValue = object[key],
5838 othValue = other[key];
5841 var compared = isPartial
5842 ? customizer(othValue, objValue, key, other, object, stack)
5843 : customizer(objValue, othValue, key, object, other, stack);
5845 // Recursively compare objects (susceptible to call stack limits).
5846 if (!(compared === undefined
5847 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
5853 skipCtor || (skipCtor = key == 'constructor');
5855 if (result && !skipCtor) {
5856 var objCtor = object.constructor,
5857 othCtor = other.constructor;
5859 // Non `Object` object instances with different constructors are not equal.
5860 if (objCtor != othCtor &&
5861 ('constructor' in object && 'constructor' in other) &&
5862 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
5863 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
5867 stack['delete'](object);
5868 stack['delete'](other);
5873 * A specialized version of `baseRest` which flattens the rest array.
5876 * @param {Function} func The function to apply a rest parameter to.
5877 * @returns {Function} Returns the new function.
5879 function flatRest(func) {
5880 return setToString(overRest(func, undefined, flatten), func + '');
5884 * Creates an array of own enumerable property names and symbols of `object`.
5887 * @param {Object} object The object to query.
5888 * @returns {Array} Returns the array of property names and symbols.
5890 function getAllKeys(object) {
5891 return baseGetAllKeys(object, keys, getSymbols);
5895 * Creates an array of own and inherited enumerable property names and
5896 * symbols of `object`.
5899 * @param {Object} object The object to query.
5900 * @returns {Array} Returns the array of property names and symbols.
5902 function getAllKeysIn(object) {
5903 return baseGetAllKeys(object, keysIn, getSymbolsIn);
5907 * Gets metadata for `func`.
5910 * @param {Function} func The function to query.
5911 * @returns {*} Returns the metadata for `func`.
5913 var getData = !metaMap ? noop : function(func) {
5914 return metaMap.get(func);
5918 * Gets the name of `func`.
5921 * @param {Function} func The function to query.
5922 * @returns {string} Returns the function name.
5924 function getFuncName(func) {
5925 var result = (func.name + ''),
5926 array = realNames[result],
5927 length = hasOwnProperty.call(realNames, result) ? array.length : 0;
5930 var data = array[length],
5931 otherFunc = data.func;
5932 if (otherFunc == null || otherFunc == func) {
5940 * Gets the argument placeholder value for `func`.
5943 * @param {Function} func The function to inspect.
5944 * @returns {*} Returns the placeholder value.
5946 function getHolder(func) {
5947 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
5948 return object.placeholder;
5952 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
5953 * this function returns the custom method, otherwise it returns `baseIteratee`.
5954 * If arguments are provided, the chosen function is invoked with them and
5955 * its result is returned.
5958 * @param {*} [value] The value to convert to an iteratee.
5959 * @param {number} [arity] The arity of the created iteratee.
5960 * @returns {Function} Returns the chosen function or its result.
5962 function getIteratee() {
5963 var result = lodash.iteratee || iteratee;
5964 result = result === iteratee ? baseIteratee : result;
5965 return arguments.length ? result(arguments[0], arguments[1]) : result;
5969 * Gets the data for `map`.
5972 * @param {Object} map The map to query.
5973 * @param {string} key The reference key.
5974 * @returns {*} Returns the map data.
5976 function getMapData(map, key) {
5977 var data = map.__data__;
5978 return isKeyable(key)
5979 ? data[typeof key == 'string' ? 'string' : 'hash']
5984 * Gets the property names, values, and compare flags of `object`.
5987 * @param {Object} object The object to query.
5988 * @returns {Array} Returns the match data of `object`.
5990 function getMatchData(object) {
5991 var result = keys(object),
5992 length = result.length;
5995 var key = result[length],
5996 value = object[key];
5998 result[length] = [key, value, isStrictComparable(value)];
6004 * Gets the native function at `key` of `object`.
6007 * @param {Object} object The object to query.
6008 * @param {string} key The key of the method to get.
6009 * @returns {*} Returns the function if it's native, else `undefined`.
6011 function getNative(object, key) {
6012 var value = getValue(object, key);
6013 return baseIsNative(value) ? value : undefined;
6017 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
6020 * @param {*} value The value to query.
6021 * @returns {string} Returns the raw `toStringTag`.
6023 function getRawTag(value) {
6024 var isOwn = hasOwnProperty.call(value, symToStringTag),
6025 tag = value[symToStringTag];
6028 value[symToStringTag] = undefined;
6029 var unmasked = true;
6032 var result = nativeObjectToString.call(value);
6035 value[symToStringTag] = tag;
6037 delete value[symToStringTag];
6044 * Creates an array of the own enumerable symbols of `object`.
6047 * @param {Object} object The object to query.
6048 * @returns {Array} Returns the array of symbols.
6050 var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
6051 if (object == null) {
6054 object = Object(object);
6055 return arrayFilter(nativeGetSymbols(object), function(symbol) {
6056 return propertyIsEnumerable.call(object, symbol);
6061 * Creates an array of the own and inherited enumerable symbols of `object`.
6064 * @param {Object} object The object to query.
6065 * @returns {Array} Returns the array of symbols.
6067 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6070 arrayPush(result, getSymbols(object));
6071 object = getPrototype(object);
6077 * Gets the `toStringTag` of `value`.
6080 * @param {*} value The value to query.
6081 * @returns {string} Returns the `toStringTag`.
6083 var getTag = baseGetTag;
6085 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
6086 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
6087 (Map && getTag(new Map) != mapTag) ||
6088 (Promise && getTag(Promise.resolve()) != promiseTag) ||
6089 (Set && getTag(new Set) != setTag) ||
6090 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
6091 getTag = function(value) {
6092 var result = baseGetTag(value),
6093 Ctor = result == objectTag ? value.constructor : undefined,
6094 ctorString = Ctor ? toSource(Ctor) : '';
6097 switch (ctorString) {
6098 case dataViewCtorString: return dataViewTag;
6099 case mapCtorString: return mapTag;
6100 case promiseCtorString: return promiseTag;
6101 case setCtorString: return setTag;
6102 case weakMapCtorString: return weakMapTag;
6110 * Gets the view, applying any `transforms` to the `start` and `end` positions.
6113 * @param {number} start The start of the view.
6114 * @param {number} end The end of the view.
6115 * @param {Array} transforms The transformations to apply to the view.
6116 * @returns {Object} Returns an object containing the `start` and `end`
6117 * positions of the view.
6119 function getView(start, end, transforms) {
6121 length = transforms.length;
6123 while (++index < length) {
6124 var data = transforms[index],
6127 switch (data.type) {
6128 case 'drop': start += size; break;
6129 case 'dropRight': end -= size; break;
6130 case 'take': end = nativeMin(end, start + size); break;
6131 case 'takeRight': start = nativeMax(start, end - size); break;
6134 return { 'start': start, 'end': end };
6138 * Extracts wrapper details from the `source` body comment.
6141 * @param {string} source The source to inspect.
6142 * @returns {Array} Returns the wrapper details.
6144 function getWrapDetails(source) {
6145 var match = source.match(reWrapDetails);
6146 return match ? match[1].split(reSplitDetails) : [];
6150 * Checks if `path` exists on `object`.
6153 * @param {Object} object The object to query.
6154 * @param {Array|string} path The path to check.
6155 * @param {Function} hasFunc The function to check properties.
6156 * @returns {boolean} Returns `true` if `path` exists, else `false`.
6158 function hasPath(object, path, hasFunc) {
6159 path = castPath(path, object);
6162 length = path.length,
6165 while (++index < length) {
6166 var key = toKey(path[index]);
6167 if (!(result = object != null && hasFunc(object, key))) {
6170 object = object[key];
6172 if (result || ++index != length) {
6175 length = object == null ? 0 : object.length;
6176 return !!length && isLength(length) && isIndex(key, length) &&
6177 (isArray(object) || isArguments(object));
6181 * Initializes an array clone.
6184 * @param {Array} array The array to clone.
6185 * @returns {Array} Returns the initialized clone.
6187 function initCloneArray(array) {
6188 var length = array.length,
6189 result = array.constructor(length);
6191 // Add properties assigned by `RegExp#exec`.
6192 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
6193 result.index = array.index;
6194 result.input = array.input;
6200 * Initializes an object clone.
6203 * @param {Object} object The object to clone.
6204 * @returns {Object} Returns the initialized clone.
6206 function initCloneObject(object) {
6207 return (typeof object.constructor == 'function' && !isPrototype(object))
6208 ? baseCreate(getPrototype(object))
6213 * Initializes an object clone based on its `toStringTag`.
6215 * **Note:** This function only supports cloning values with tags of
6216 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
6219 * @param {Object} object The object to clone.
6220 * @param {string} tag The `toStringTag` of the object to clone.
6221 * @param {Function} cloneFunc The function to clone values.
6222 * @param {boolean} [isDeep] Specify a deep clone.
6223 * @returns {Object} Returns the initialized clone.
6225 function initCloneByTag(object, tag, cloneFunc, isDeep) {
6226 var Ctor = object.constructor;
6228 case arrayBufferTag:
6229 return cloneArrayBuffer(object);
6233 return new Ctor(+object);
6236 return cloneDataView(object, isDeep);
6238 case float32Tag: case float64Tag:
6239 case int8Tag: case int16Tag: case int32Tag:
6240 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
6241 return cloneTypedArray(object, isDeep);
6244 return cloneMap(object, isDeep, cloneFunc);
6248 return new Ctor(object);
6251 return cloneRegExp(object);
6254 return cloneSet(object, isDeep, cloneFunc);
6257 return cloneSymbol(object);
6262 * Inserts wrapper `details` in a comment at the top of the `source` body.
6265 * @param {string} source The source to modify.
6266 * @returns {Array} details The details to insert.
6267 * @returns {string} Returns the modified source.
6269 function insertWrapDetails(source, details) {
6270 var length = details.length;
6274 var lastIndex = length - 1;
6275 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
6276 details = details.join(length > 2 ? ', ' : ' ');
6277 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
6281 * Checks if `value` is a flattenable `arguments` object or array.
6284 * @param {*} value The value to check.
6285 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6287 function isFlattenable(value) {
6288 return isArray(value) || isArguments(value) ||
6289 !!(spreadableSymbol && value && value[spreadableSymbol]);
6293 * Checks if `value` is a valid array-like index.
6296 * @param {*} value The value to check.
6297 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
6298 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
6300 function isIndex(value, length) {
6301 length = length == null ? MAX_SAFE_INTEGER : length;
6303 (typeof value == 'number' || reIsUint.test(value)) &&
6304 (value > -1 && value % 1 == 0 && value < length);
6308 * Checks if the given arguments are from an iteratee call.
6311 * @param {*} value The potential iteratee value argument.
6312 * @param {*} index The potential iteratee index or key argument.
6313 * @param {*} object The potential iteratee object argument.
6314 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
6317 function isIterateeCall(value, index, object) {
6318 if (!isObject(object)) {
6321 var type = typeof index;
6322 if (type == 'number'
6323 ? (isArrayLike(object) && isIndex(index, object.length))
6324 : (type == 'string' && index in object)
6326 return eq(object[index], value);
6332 * Checks if `value` is a property name and not a property path.
6335 * @param {*} value The value to check.
6336 * @param {Object} [object] The object to query keys on.
6337 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
6339 function isKey(value, object) {
6340 if (isArray(value)) {
6343 var type = typeof value;
6344 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6345 value == null || isSymbol(value)) {
6348 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6349 (object != null && value in Object(object));
6353 * Checks if `value` is suitable for use as unique object key.
6356 * @param {*} value The value to check.
6357 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6359 function isKeyable(value) {
6360 var type = typeof value;
6361 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
6362 ? (value !== '__proto__')
6367 * Checks if `func` has a lazy counterpart.
6370 * @param {Function} func The function to check.
6371 * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6374 function isLaziable(func) {
6375 var funcName = getFuncName(func),
6376 other = lodash[funcName];
6378 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6381 if (func === other) {
6384 var data = getData(other);
6385 return !!data && func === data[0];
6389 * Checks if `func` has its source masked.
6392 * @param {Function} func The function to check.
6393 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6395 function isMasked(func) {
6396 return !!maskSrcKey && (maskSrcKey in func);
6400 * Checks if `func` is capable of being masked.
6403 * @param {*} value The value to check.
6404 * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6406 var isMaskable = coreJsData ? isFunction : stubFalse;
6409 * Checks if `value` is likely a prototype object.
6412 * @param {*} value The value to check.
6413 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6415 function isPrototype(value) {
6416 var Ctor = value && value.constructor,
6417 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6419 return value === proto;
6423 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6426 * @param {*} value The value to check.
6427 * @returns {boolean} Returns `true` if `value` if suitable for strict
6428 * equality comparisons, else `false`.
6430 function isStrictComparable(value) {
6431 return value === value && !isObject(value);
6435 * A specialized version of `matchesProperty` for source values suitable
6436 * for strict equality comparisons, i.e. `===`.
6439 * @param {string} key The key of the property to get.
6440 * @param {*} srcValue The value to match.
6441 * @returns {Function} Returns the new spec function.
6443 function matchesStrictComparable(key, srcValue) {
6444 return function(object) {
6445 if (object == null) {
6448 return object[key] === srcValue &&
6449 (srcValue !== undefined || (key in Object(object)));
6454 * A specialized version of `_.memoize` which clears the memoized function's
6455 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6458 * @param {Function} func The function to have its output memoized.
6459 * @returns {Function} Returns the new memoized function.
6461 function memoizeCapped(func) {
6462 var result = memoize(func, function(key) {
6463 if (cache.size === MAX_MEMOIZE_SIZE) {
6469 var cache = result.cache;
6474 * Merges the function metadata of `source` into `data`.
6476 * Merging metadata reduces the number of wrappers used to invoke a function.
6477 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
6478 * may be applied regardless of execution order. Methods like `_.ary` and
6479 * `_.rearg` modify function arguments, making the order in which they are
6480 * executed important, preventing the merging of metadata. However, we make
6481 * an exception for a safe combined case where curried functions have `_.ary`
6482 * and or `_.rearg` applied.
6485 * @param {Array} data The destination metadata.
6486 * @param {Array} source The source metadata.
6487 * @returns {Array} Returns `data`.
6489 function mergeData(data, source) {
6490 var bitmask = data[1],
6491 srcBitmask = source[1],
6492 newBitmask = bitmask | srcBitmask,
6493 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6496 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
6497 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
6498 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
6500 // Exit early if metadata can't be merged.
6501 if (!(isCommon || isCombo)) {
6504 // Use source `thisArg` if available.
6505 if (srcBitmask & WRAP_BIND_FLAG) {
6506 data[2] = source[2];
6507 // Set when currying a bound function.
6508 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6510 // Compose partial arguments.
6511 var value = source[3];
6513 var partials = data[3];
6514 data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6515 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6517 // Compose partial right arguments.
6521 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6522 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6524 // Use source `argPos` if available.
6529 // Use source `ary` if it's smaller.
6530 if (srcBitmask & WRAP_ARY_FLAG) {
6531 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
6533 // Use source `arity` if one is not provided.
6534 if (data[9] == null) {
6535 data[9] = source[9];
6537 // Use source `func` and merge bitmasks.
6538 data[0] = source[0];
6539 data[1] = newBitmask;
6545 * This function is like
6546 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
6547 * except that it includes inherited enumerable properties.
6550 * @param {Object} object The object to query.
6551 * @returns {Array} Returns the array of property names.
6553 function nativeKeysIn(object) {
6555 if (object != null) {
6556 for (var key in Object(object)) {
6564 * Converts `value` to a string using `Object.prototype.toString`.
6567 * @param {*} value The value to convert.
6568 * @returns {string} Returns the converted string.
6570 function objectToString(value) {
6571 return nativeObjectToString.call(value);
6575 * A specialized version of `baseRest` which transforms the rest array.
6578 * @param {Function} func The function to apply a rest parameter to.
6579 * @param {number} [start=func.length-1] The start position of the rest parameter.
6580 * @param {Function} transform The rest array transform.
6581 * @returns {Function} Returns the new function.
6583 function overRest(func, start, transform) {
6584 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
6586 var args = arguments,
6588 length = nativeMax(args.length - start, 0),
6589 array = Array(length);
6591 while (++index < length) {
6592 array[index] = args[start + index];
6595 var otherArgs = Array(start + 1);
6596 while (++index < start) {
6597 otherArgs[index] = args[index];
6599 otherArgs[start] = transform(array);
6600 return apply(func, this, otherArgs);
6605 * Gets the parent value at `path` of `object`.
6608 * @param {Object} object The object to query.
6609 * @param {Array} path The path to get the parent value of.
6610 * @returns {*} Returns the parent value.
6612 function parent(object, path) {
6613 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6617 * Reorder `array` according to the specified indexes where the element at
6618 * the first index is assigned as the first element, the element at
6619 * the second index is assigned as the second element, and so on.
6622 * @param {Array} array The array to reorder.
6623 * @param {Array} indexes The arranged array indexes.
6624 * @returns {Array} Returns `array`.
6626 function reorder(array, indexes) {
6627 var arrLength = array.length,
6628 length = nativeMin(indexes.length, arrLength),
6629 oldArray = copyArray(array);
6632 var index = indexes[length];
6633 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
6639 * Sets metadata for `func`.
6641 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
6642 * period of time, it will trip its breaker and transition to an identity
6643 * function to avoid garbage collection pauses in V8. See
6644 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
6648 * @param {Function} func The function to associate metadata with.
6649 * @param {*} data The metadata.
6650 * @returns {Function} Returns `func`.
6652 var setData = shortOut(baseSetData);
6655 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
6658 * @param {Function} func The function to delay.
6659 * @param {number} wait The number of milliseconds to delay invocation.
6660 * @returns {number|Object} Returns the timer id or timeout object.
6662 var setTimeout = ctxSetTimeout || function(func, wait) {
6663 return root.setTimeout(func, wait);
6667 * Sets the `toString` method of `func` to return `string`.
6670 * @param {Function} func The function to modify.
6671 * @param {Function} string The `toString` result.
6672 * @returns {Function} Returns `func`.
6674 var setToString = shortOut(baseSetToString);
6677 * Sets the `toString` method of `wrapper` to mimic the source of `reference`
6678 * with wrapper details in a comment at the top of the source body.
6681 * @param {Function} wrapper The function to modify.
6682 * @param {Function} reference The reference function.
6683 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6684 * @returns {Function} Returns `wrapper`.
6686 function setWrapToString(wrapper, reference, bitmask) {
6687 var source = (reference + '');
6688 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6692 * Creates a function that'll short out and invoke `identity` instead
6693 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
6697 * @param {Function} func The function to restrict.
6698 * @returns {Function} Returns the new shortable function.
6700 function shortOut(func) {
6705 var stamp = nativeNow(),
6706 remaining = HOT_SPAN - (stamp - lastCalled);
6709 if (remaining > 0) {
6710 if (++count >= HOT_COUNT) {
6711 return arguments[0];
6716 return func.apply(undefined, arguments);
6721 * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
6724 * @param {Array} array The array to shuffle.
6725 * @param {number} [size=array.length] The size of `array`.
6726 * @returns {Array} Returns `array`.
6728 function shuffleSelf(array, size) {
6730 length = array.length,
6731 lastIndex = length - 1;
6733 size = size === undefined ? length : size;
6734 while (++index < size) {
6735 var rand = baseRandom(index, lastIndex),
6736 value = array[rand];
6738 array[rand] = array[index];
6739 array[index] = value;
6741 array.length = size;
6746 * Converts `string` to a property path array.
6749 * @param {string} string The string to convert.
6750 * @returns {Array} Returns the property path array.
6752 var stringToPath = memoizeCapped(function(string) {
6754 if (reLeadingDot.test(string)) {
6757 string.replace(rePropName, function(match, number, quote, string) {
6758 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
6764 * Converts `value` to a string key if it's not a string or symbol.
6767 * @param {*} value The value to inspect.
6768 * @returns {string|symbol} Returns the key.
6770 function toKey(value) {
6771 if (typeof value == 'string' || isSymbol(value)) {
6774 var result = (value + '');
6775 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
6779 * Converts `func` to its source code.
6782 * @param {Function} func The function to convert.
6783 * @returns {string} Returns the source code.
6785 function toSource(func) {
6788 return funcToString.call(func);
6798 * Updates wrapper `details` based on `bitmask` flags.
6801 * @returns {Array} details The details to modify.
6802 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6803 * @returns {Array} Returns `details`.
6805 function updateWrapDetails(details, bitmask) {
6806 arrayEach(wrapFlags, function(pair) {
6807 var value = '_.' + pair[0];
6808 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
6809 details.push(value);
6812 return details.sort();
6816 * Creates a clone of `wrapper`.
6819 * @param {Object} wrapper The wrapper to clone.
6820 * @returns {Object} Returns the cloned wrapper.
6822 function wrapperClone(wrapper) {
6823 if (wrapper instanceof LazyWrapper) {
6824 return wrapper.clone();
6826 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6827 result.__actions__ = copyArray(wrapper.__actions__);
6828 result.__index__ = wrapper.__index__;
6829 result.__values__ = wrapper.__values__;
6833 /*------------------------------------------------------------------------*/
6836 * Creates an array of elements split into groups the length of `size`.
6837 * If `array` can't be split evenly, the final chunk will be the remaining
6844 * @param {Array} array The array to process.
6845 * @param {number} [size=1] The length of each chunk
6846 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
6847 * @returns {Array} Returns the new array of chunks.
6850 * _.chunk(['a', 'b', 'c', 'd'], 2);
6851 * // => [['a', 'b'], ['c', 'd']]
6853 * _.chunk(['a', 'b', 'c', 'd'], 3);
6854 * // => [['a', 'b', 'c'], ['d']]
6856 function chunk(array, size, guard) {
6857 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
6860 size = nativeMax(toInteger(size), 0);
6862 var length = array == null ? 0 : array.length;
6863 if (!length || size < 1) {
6868 result = Array(nativeCeil(length / size));
6870 while (index < length) {
6871 result[resIndex++] = baseSlice(array, index, (index += size));
6877 * Creates an array with all falsey values removed. The values `false`, `null`,
6878 * `0`, `""`, `undefined`, and `NaN` are falsey.
6884 * @param {Array} array The array to compact.
6885 * @returns {Array} Returns the new array of filtered values.
6888 * _.compact([0, 1, false, 2, '', 3]);
6891 function compact(array) {
6893 length = array == null ? 0 : array.length,
6897 while (++index < length) {
6898 var value = array[index];
6900 result[resIndex++] = value;
6907 * Creates a new array concatenating `array` with any additional arrays
6914 * @param {Array} array The array to concatenate.
6915 * @param {...*} [values] The values to concatenate.
6916 * @returns {Array} Returns the new concatenated array.
6920 * var other = _.concat(array, 2, [3], [[4]]);
6922 * console.log(other);
6923 * // => [1, 2, 3, [4]]
6925 * console.log(array);
6929 var length = arguments.length;
6933 var args = Array(length - 1),
6934 array = arguments[0],
6938 args[index - 1] = arguments[index];
6940 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
6944 * Creates an array of `array` values not included in the other given arrays
6945 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
6946 * for equality comparisons. The order and references of result values are
6947 * determined by the first array.
6949 * **Note:** Unlike `_.pullAll`, this method returns a new array.
6955 * @param {Array} array The array to inspect.
6956 * @param {...Array} [values] The values to exclude.
6957 * @returns {Array} Returns the new array of filtered values.
6958 * @see _.without, _.xor
6961 * _.difference([2, 1], [2, 3]);
6964 var difference = baseRest(function(array, values) {
6965 return isArrayLikeObject(array)
6966 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
6971 * This method is like `_.difference` except that it accepts `iteratee` which
6972 * is invoked for each element of `array` and `values` to generate the criterion
6973 * by which they're compared. The order and references of result values are
6974 * determined by the first array. The iteratee is invoked with one argument:
6977 * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
6983 * @param {Array} array The array to inspect.
6984 * @param {...Array} [values] The values to exclude.
6985 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
6986 * @returns {Array} Returns the new array of filtered values.
6989 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
6992 * // The `_.property` iteratee shorthand.
6993 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
6994 * // => [{ 'x': 2 }]
6996 var differenceBy = baseRest(function(array, values) {
6997 var iteratee = last(values);
6998 if (isArrayLikeObject(iteratee)) {
6999 iteratee = undefined;
7001 return isArrayLikeObject(array)
7002 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
7007 * This method is like `_.difference` except that it accepts `comparator`
7008 * which is invoked to compare elements of `array` to `values`. The order and
7009 * references of result values are determined by the first array. The comparator
7010 * is invoked with two arguments: (arrVal, othVal).
7012 * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
7018 * @param {Array} array The array to inspect.
7019 * @param {...Array} [values] The values to exclude.
7020 * @param {Function} [comparator] The comparator invoked per element.
7021 * @returns {Array} Returns the new array of filtered values.
7024 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7026 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
7027 * // => [{ 'x': 2, 'y': 1 }]
7029 var differenceWith = baseRest(function(array, values) {
7030 var comparator = last(values);
7031 if (isArrayLikeObject(comparator)) {
7032 comparator = undefined;
7034 return isArrayLikeObject(array)
7035 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
7040 * Creates a slice of `array` with `n` elements dropped from the beginning.
7046 * @param {Array} array The array to query.
7047 * @param {number} [n=1] The number of elements to drop.
7048 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7049 * @returns {Array} Returns the slice of `array`.
7052 * _.drop([1, 2, 3]);
7055 * _.drop([1, 2, 3], 2);
7058 * _.drop([1, 2, 3], 5);
7061 * _.drop([1, 2, 3], 0);
7064 function drop(array, n, guard) {
7065 var length = array == null ? 0 : array.length;
7069 n = (guard || n === undefined) ? 1 : toInteger(n);
7070 return baseSlice(array, n < 0 ? 0 : n, length);
7074 * Creates a slice of `array` with `n` elements dropped from the end.
7080 * @param {Array} array The array to query.
7081 * @param {number} [n=1] The number of elements to drop.
7082 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7083 * @returns {Array} Returns the slice of `array`.
7086 * _.dropRight([1, 2, 3]);
7089 * _.dropRight([1, 2, 3], 2);
7092 * _.dropRight([1, 2, 3], 5);
7095 * _.dropRight([1, 2, 3], 0);
7098 function dropRight(array, n, guard) {
7099 var length = array == null ? 0 : array.length;
7103 n = (guard || n === undefined) ? 1 : toInteger(n);
7105 return baseSlice(array, 0, n < 0 ? 0 : n);
7109 * Creates a slice of `array` excluding elements dropped from the end.
7110 * Elements are dropped until `predicate` returns falsey. The predicate is
7111 * invoked with three arguments: (value, index, array).
7117 * @param {Array} array The array to query.
7118 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7119 * @returns {Array} Returns the slice of `array`.
7123 * { 'user': 'barney', 'active': true },
7124 * { 'user': 'fred', 'active': false },
7125 * { 'user': 'pebbles', 'active': false }
7128 * _.dropRightWhile(users, function(o) { return !o.active; });
7129 * // => objects for ['barney']
7131 * // The `_.matches` iteratee shorthand.
7132 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7133 * // => objects for ['barney', 'fred']
7135 * // The `_.matchesProperty` iteratee shorthand.
7136 * _.dropRightWhile(users, ['active', false]);
7137 * // => objects for ['barney']
7139 * // The `_.property` iteratee shorthand.
7140 * _.dropRightWhile(users, 'active');
7141 * // => objects for ['barney', 'fred', 'pebbles']
7143 function dropRightWhile(array, predicate) {
7144 return (array && array.length)
7145 ? baseWhile(array, getIteratee(predicate, 3), true, true)
7150 * Creates a slice of `array` excluding elements dropped from the beginning.
7151 * Elements are dropped until `predicate` returns falsey. The predicate is
7152 * invoked with three arguments: (value, index, array).
7158 * @param {Array} array The array to query.
7159 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7160 * @returns {Array} Returns the slice of `array`.
7164 * { 'user': 'barney', 'active': false },
7165 * { 'user': 'fred', 'active': false },
7166 * { 'user': 'pebbles', 'active': true }
7169 * _.dropWhile(users, function(o) { return !o.active; });
7170 * // => objects for ['pebbles']
7172 * // The `_.matches` iteratee shorthand.
7173 * _.dropWhile(users, { 'user': 'barney', 'active': false });
7174 * // => objects for ['fred', 'pebbles']
7176 * // The `_.matchesProperty` iteratee shorthand.
7177 * _.dropWhile(users, ['active', false]);
7178 * // => objects for ['pebbles']
7180 * // The `_.property` iteratee shorthand.
7181 * _.dropWhile(users, 'active');
7182 * // => objects for ['barney', 'fred', 'pebbles']
7184 function dropWhile(array, predicate) {
7185 return (array && array.length)
7186 ? baseWhile(array, getIteratee(predicate, 3), true)
7191 * Fills elements of `array` with `value` from `start` up to, but not
7194 * **Note:** This method mutates `array`.
7200 * @param {Array} array The array to fill.
7201 * @param {*} value The value to fill `array` with.
7202 * @param {number} [start=0] The start position.
7203 * @param {number} [end=array.length] The end position.
7204 * @returns {Array} Returns `array`.
7207 * var array = [1, 2, 3];
7209 * _.fill(array, 'a');
7210 * console.log(array);
7211 * // => ['a', 'a', 'a']
7213 * _.fill(Array(3), 2);
7216 * _.fill([4, 6, 8, 10], '*', 1, 3);
7217 * // => [4, '*', '*', 10]
7219 function fill(array, value, start, end) {
7220 var length = array == null ? 0 : array.length;
7224 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7228 return baseFill(array, value, start, end);
7232 * This method is like `_.find` except that it returns the index of the first
7233 * element `predicate` returns truthy for instead of the element itself.
7239 * @param {Array} array The array to inspect.
7240 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7241 * @param {number} [fromIndex=0] The index to search from.
7242 * @returns {number} Returns the index of the found element, else `-1`.
7246 * { 'user': 'barney', 'active': false },
7247 * { 'user': 'fred', 'active': false },
7248 * { 'user': 'pebbles', 'active': true }
7251 * _.findIndex(users, function(o) { return o.user == 'barney'; });
7254 * // The `_.matches` iteratee shorthand.
7255 * _.findIndex(users, { 'user': 'fred', 'active': false });
7258 * // The `_.matchesProperty` iteratee shorthand.
7259 * _.findIndex(users, ['active', false]);
7262 * // The `_.property` iteratee shorthand.
7263 * _.findIndex(users, 'active');
7266 function findIndex(array, predicate, fromIndex) {
7267 var length = array == null ? 0 : array.length;
7271 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7273 index = nativeMax(length + index, 0);
7275 return baseFindIndex(array, getIteratee(predicate, 3), index);
7279 * This method is like `_.findIndex` except that it iterates over elements
7280 * of `collection` from right to left.
7286 * @param {Array} array The array to inspect.
7287 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7288 * @param {number} [fromIndex=array.length-1] The index to search from.
7289 * @returns {number} Returns the index of the found element, else `-1`.
7293 * { 'user': 'barney', 'active': true },
7294 * { 'user': 'fred', 'active': false },
7295 * { 'user': 'pebbles', 'active': false }
7298 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7301 * // The `_.matches` iteratee shorthand.
7302 * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7305 * // The `_.matchesProperty` iteratee shorthand.
7306 * _.findLastIndex(users, ['active', false]);
7309 * // The `_.property` iteratee shorthand.
7310 * _.findLastIndex(users, 'active');
7313 function findLastIndex(array, predicate, fromIndex) {
7314 var length = array == null ? 0 : array.length;
7318 var index = length - 1;
7319 if (fromIndex !== undefined) {
7320 index = toInteger(fromIndex);
7321 index = fromIndex < 0
7322 ? nativeMax(length + index, 0)
7323 : nativeMin(index, length - 1);
7325 return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7329 * Flattens `array` a single level deep.
7335 * @param {Array} array The array to flatten.
7336 * @returns {Array} Returns the new flattened array.
7339 * _.flatten([1, [2, [3, [4]], 5]]);
7340 * // => [1, 2, [3, [4]], 5]
7342 function flatten(array) {
7343 var length = array == null ? 0 : array.length;
7344 return length ? baseFlatten(array, 1) : [];
7348 * Recursively flattens `array`.
7354 * @param {Array} array The array to flatten.
7355 * @returns {Array} Returns the new flattened array.
7358 * _.flattenDeep([1, [2, [3, [4]], 5]]);
7359 * // => [1, 2, 3, 4, 5]
7361 function flattenDeep(array) {
7362 var length = array == null ? 0 : array.length;
7363 return length ? baseFlatten(array, INFINITY) : [];
7367 * Recursively flatten `array` up to `depth` times.
7373 * @param {Array} array The array to flatten.
7374 * @param {number} [depth=1] The maximum recursion depth.
7375 * @returns {Array} Returns the new flattened array.
7378 * var array = [1, [2, [3, [4]], 5]];
7380 * _.flattenDepth(array, 1);
7381 * // => [1, 2, [3, [4]], 5]
7383 * _.flattenDepth(array, 2);
7384 * // => [1, 2, 3, [4], 5]
7386 function flattenDepth(array, depth) {
7387 var length = array == null ? 0 : array.length;
7391 depth = depth === undefined ? 1 : toInteger(depth);
7392 return baseFlatten(array, depth);
7396 * The inverse of `_.toPairs`; this method returns an object composed
7397 * from key-value `pairs`.
7403 * @param {Array} pairs The key-value pairs.
7404 * @returns {Object} Returns the new object.
7407 * _.fromPairs([['a', 1], ['b', 2]]);
7408 * // => { 'a': 1, 'b': 2 }
7410 function fromPairs(pairs) {
7412 length = pairs == null ? 0 : pairs.length,
7415 while (++index < length) {
7416 var pair = pairs[index];
7417 result[pair[0]] = pair[1];
7423 * Gets the first element of `array`.
7430 * @param {Array} array The array to query.
7431 * @returns {*} Returns the first element of `array`.
7434 * _.head([1, 2, 3]);
7440 function head(array) {
7441 return (array && array.length) ? array[0] : undefined;
7445 * Gets the index at which the first occurrence of `value` is found in `array`
7446 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7447 * for equality comparisons. If `fromIndex` is negative, it's used as the
7448 * offset from the end of `array`.
7454 * @param {Array} array The array to inspect.
7455 * @param {*} value The value to search for.
7456 * @param {number} [fromIndex=0] The index to search from.
7457 * @returns {number} Returns the index of the matched value, else `-1`.
7460 * _.indexOf([1, 2, 1, 2], 2);
7463 * // Search from the `fromIndex`.
7464 * _.indexOf([1, 2, 1, 2], 2, 2);
7467 function indexOf(array, value, fromIndex) {
7468 var length = array == null ? 0 : array.length;
7472 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7474 index = nativeMax(length + index, 0);
7476 return baseIndexOf(array, value, index);
7480 * Gets all but the last element of `array`.
7486 * @param {Array} array The array to query.
7487 * @returns {Array} Returns the slice of `array`.
7490 * _.initial([1, 2, 3]);
7493 function initial(array) {
7494 var length = array == null ? 0 : array.length;
7495 return length ? baseSlice(array, 0, -1) : [];
7499 * Creates an array of unique values that are included in all given arrays
7500 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7501 * for equality comparisons. The order and references of result values are
7502 * determined by the first array.
7508 * @param {...Array} [arrays] The arrays to inspect.
7509 * @returns {Array} Returns the new array of intersecting values.
7512 * _.intersection([2, 1], [2, 3]);
7515 var intersection = baseRest(function(arrays) {
7516 var mapped = arrayMap(arrays, castArrayLikeObject);
7517 return (mapped.length && mapped[0] === arrays[0])
7518 ? baseIntersection(mapped)
7523 * This method is like `_.intersection` except that it accepts `iteratee`
7524 * which is invoked for each element of each `arrays` to generate the criterion
7525 * by which they're compared. The order and references of result values are
7526 * determined by the first array. The iteratee is invoked with one argument:
7533 * @param {...Array} [arrays] The arrays to inspect.
7534 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7535 * @returns {Array} Returns the new array of intersecting values.
7538 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7541 * // The `_.property` iteratee shorthand.
7542 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7543 * // => [{ 'x': 1 }]
7545 var intersectionBy = baseRest(function(arrays) {
7546 var iteratee = last(arrays),
7547 mapped = arrayMap(arrays, castArrayLikeObject);
7549 if (iteratee === last(mapped)) {
7550 iteratee = undefined;
7554 return (mapped.length && mapped[0] === arrays[0])
7555 ? baseIntersection(mapped, getIteratee(iteratee, 2))
7560 * This method is like `_.intersection` except that it accepts `comparator`
7561 * which is invoked to compare elements of `arrays`. The order and references
7562 * of result values are determined by the first array. The comparator is
7563 * invoked with two arguments: (arrVal, othVal).
7569 * @param {...Array} [arrays] The arrays to inspect.
7570 * @param {Function} [comparator] The comparator invoked per element.
7571 * @returns {Array} Returns the new array of intersecting values.
7574 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7575 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7577 * _.intersectionWith(objects, others, _.isEqual);
7578 * // => [{ 'x': 1, 'y': 2 }]
7580 var intersectionWith = baseRest(function(arrays) {
7581 var comparator = last(arrays),
7582 mapped = arrayMap(arrays, castArrayLikeObject);
7584 comparator = typeof comparator == 'function' ? comparator : undefined;
7588 return (mapped.length && mapped[0] === arrays[0])
7589 ? baseIntersection(mapped, undefined, comparator)
7594 * Converts all elements in `array` into a string separated by `separator`.
7600 * @param {Array} array The array to convert.
7601 * @param {string} [separator=','] The element separator.
7602 * @returns {string} Returns the joined string.
7605 * _.join(['a', 'b', 'c'], '~');
7608 function join(array, separator) {
7609 return array == null ? '' : nativeJoin.call(array, separator);
7613 * Gets the last element of `array`.
7619 * @param {Array} array The array to query.
7620 * @returns {*} Returns the last element of `array`.
7623 * _.last([1, 2, 3]);
7626 function last(array) {
7627 var length = array == null ? 0 : array.length;
7628 return length ? array[length - 1] : undefined;
7632 * This method is like `_.indexOf` except that it iterates over elements of
7633 * `array` from right to left.
7639 * @param {Array} array The array to inspect.
7640 * @param {*} value The value to search for.
7641 * @param {number} [fromIndex=array.length-1] The index to search from.
7642 * @returns {number} Returns the index of the matched value, else `-1`.
7645 * _.lastIndexOf([1, 2, 1, 2], 2);
7648 * // Search from the `fromIndex`.
7649 * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7652 function lastIndexOf(array, value, fromIndex) {
7653 var length = array == null ? 0 : array.length;
7658 if (fromIndex !== undefined) {
7659 index = toInteger(fromIndex);
7660 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7662 return value === value
7663 ? strictLastIndexOf(array, value, index)
7664 : baseFindIndex(array, baseIsNaN, index, true);
7668 * Gets the element at index `n` of `array`. If `n` is negative, the nth
7669 * element from the end is returned.
7675 * @param {Array} array The array to query.
7676 * @param {number} [n=0] The index of the element to return.
7677 * @returns {*} Returns the nth element of `array`.
7680 * var array = ['a', 'b', 'c', 'd'];
7688 function nth(array, n) {
7689 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
7693 * Removes all given values from `array` using
7694 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7695 * for equality comparisons.
7697 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
7698 * to remove elements from an array by predicate.
7704 * @param {Array} array The array to modify.
7705 * @param {...*} [values] The values to remove.
7706 * @returns {Array} Returns `array`.
7709 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7711 * _.pull(array, 'a', 'c');
7712 * console.log(array);
7715 var pull = baseRest(pullAll);
7718 * This method is like `_.pull` except that it accepts an array of values to remove.
7720 * **Note:** Unlike `_.difference`, this method mutates `array`.
7726 * @param {Array} array The array to modify.
7727 * @param {Array} values The values to remove.
7728 * @returns {Array} Returns `array`.
7731 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7733 * _.pullAll(array, ['a', 'c']);
7734 * console.log(array);
7737 function pullAll(array, values) {
7738 return (array && array.length && values && values.length)
7739 ? basePullAll(array, values)
7744 * This method is like `_.pullAll` except that it accepts `iteratee` which is
7745 * invoked for each element of `array` and `values` to generate the criterion
7746 * by which they're compared. The iteratee is invoked with one argument: (value).
7748 * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
7754 * @param {Array} array The array to modify.
7755 * @param {Array} values The values to remove.
7756 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7757 * @returns {Array} Returns `array`.
7760 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
7762 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
7763 * console.log(array);
7764 * // => [{ 'x': 2 }]
7766 function pullAllBy(array, values, iteratee) {
7767 return (array && array.length && values && values.length)
7768 ? basePullAll(array, values, getIteratee(iteratee, 2))
7773 * This method is like `_.pullAll` except that it accepts `comparator` which
7774 * is invoked to compare elements of `array` to `values`. The comparator is
7775 * invoked with two arguments: (arrVal, othVal).
7777 * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
7783 * @param {Array} array The array to modify.
7784 * @param {Array} values The values to remove.
7785 * @param {Function} [comparator] The comparator invoked per element.
7786 * @returns {Array} Returns `array`.
7789 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
7791 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
7792 * console.log(array);
7793 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
7795 function pullAllWith(array, values, comparator) {
7796 return (array && array.length && values && values.length)
7797 ? basePullAll(array, values, undefined, comparator)
7802 * Removes elements from `array` corresponding to `indexes` and returns an
7803 * array of removed elements.
7805 * **Note:** Unlike `_.at`, this method mutates `array`.
7811 * @param {Array} array The array to modify.
7812 * @param {...(number|number[])} [indexes] The indexes of elements to remove.
7813 * @returns {Array} Returns the new array of removed elements.
7816 * var array = ['a', 'b', 'c', 'd'];
7817 * var pulled = _.pullAt(array, [1, 3]);
7819 * console.log(array);
7822 * console.log(pulled);
7825 var pullAt = flatRest(function(array, indexes) {
7826 var length = array == null ? 0 : array.length,
7827 result = baseAt(array, indexes);
7829 basePullAt(array, arrayMap(indexes, function(index) {
7830 return isIndex(index, length) ? +index : index;
7831 }).sort(compareAscending));
7837 * Removes all elements from `array` that `predicate` returns truthy for
7838 * and returns an array of the removed elements. The predicate is invoked
7839 * with three arguments: (value, index, array).
7841 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
7842 * to pull elements from an array by value.
7848 * @param {Array} array The array to modify.
7849 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7850 * @returns {Array} Returns the new array of removed elements.
7853 * var array = [1, 2, 3, 4];
7854 * var evens = _.remove(array, function(n) {
7855 * return n % 2 == 0;
7858 * console.log(array);
7861 * console.log(evens);
7864 function remove(array, predicate) {
7866 if (!(array && array.length)) {
7871 length = array.length;
7873 predicate = getIteratee(predicate, 3);
7874 while (++index < length) {
7875 var value = array[index];
7876 if (predicate(value, index, array)) {
7878 indexes.push(index);
7881 basePullAt(array, indexes);
7886 * Reverses `array` so that the first element becomes the last, the second
7887 * element becomes the second to last, and so on.
7889 * **Note:** This method mutates `array` and is based on
7890 * [`Array#reverse`](https://mdn.io/Array/reverse).
7896 * @param {Array} array The array to modify.
7897 * @returns {Array} Returns `array`.
7900 * var array = [1, 2, 3];
7905 * console.log(array);
7908 function reverse(array) {
7909 return array == null ? array : nativeReverse.call(array);
7913 * Creates a slice of `array` from `start` up to, but not including, `end`.
7915 * **Note:** This method is used instead of
7916 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
7923 * @param {Array} array The array to slice.
7924 * @param {number} [start=0] The start position.
7925 * @param {number} [end=array.length] The end position.
7926 * @returns {Array} Returns the slice of `array`.
7928 function slice(array, start, end) {
7929 var length = array == null ? 0 : array.length;
7933 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
7938 start = start == null ? 0 : toInteger(start);
7939 end = end === undefined ? length : toInteger(end);
7941 return baseSlice(array, start, end);
7945 * Uses a binary search to determine the lowest index at which `value`
7946 * should be inserted into `array` in order to maintain its sort order.
7952 * @param {Array} array The sorted array to inspect.
7953 * @param {*} value The value to evaluate.
7954 * @returns {number} Returns the index at which `value` should be inserted
7958 * _.sortedIndex([30, 50], 40);
7961 function sortedIndex(array, value) {
7962 return baseSortedIndex(array, value);
7966 * This method is like `_.sortedIndex` except that it accepts `iteratee`
7967 * which is invoked for `value` and each element of `array` to compute their
7968 * sort ranking. The iteratee is invoked with one argument: (value).
7974 * @param {Array} array The sorted array to inspect.
7975 * @param {*} value The value to evaluate.
7976 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7977 * @returns {number} Returns the index at which `value` should be inserted
7981 * var objects = [{ 'x': 4 }, { 'x': 5 }];
7983 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
7986 * // The `_.property` iteratee shorthand.
7987 * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
7990 function sortedIndexBy(array, value, iteratee) {
7991 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
7995 * This method is like `_.indexOf` except that it performs a binary
7996 * search on a sorted `array`.
8002 * @param {Array} array The array to inspect.
8003 * @param {*} value The value to search for.
8004 * @returns {number} Returns the index of the matched value, else `-1`.
8007 * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
8010 function sortedIndexOf(array, value) {
8011 var length = array == null ? 0 : array.length;
8013 var index = baseSortedIndex(array, value);
8014 if (index < length && eq(array[index], value)) {
8022 * This method is like `_.sortedIndex` except that it returns the highest
8023 * index at which `value` should be inserted into `array` in order to
8024 * maintain its sort order.
8030 * @param {Array} array The sorted array to inspect.
8031 * @param {*} value The value to evaluate.
8032 * @returns {number} Returns the index at which `value` should be inserted
8036 * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
8039 function sortedLastIndex(array, value) {
8040 return baseSortedIndex(array, value, true);
8044 * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
8045 * which is invoked for `value` and each element of `array` to compute their
8046 * sort ranking. The iteratee is invoked with one argument: (value).
8052 * @param {Array} array The sorted array to inspect.
8053 * @param {*} value The value to evaluate.
8054 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8055 * @returns {number} Returns the index at which `value` should be inserted
8059 * var objects = [{ 'x': 4 }, { 'x': 5 }];
8061 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8064 * // The `_.property` iteratee shorthand.
8065 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8068 function sortedLastIndexBy(array, value, iteratee) {
8069 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8073 * This method is like `_.lastIndexOf` except that it performs a binary
8074 * search on a sorted `array`.
8080 * @param {Array} array The array to inspect.
8081 * @param {*} value The value to search for.
8082 * @returns {number} Returns the index of the matched value, else `-1`.
8085 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8088 function sortedLastIndexOf(array, value) {
8089 var length = array == null ? 0 : array.length;
8091 var index = baseSortedIndex(array, value, true) - 1;
8092 if (eq(array[index], value)) {
8100 * This method is like `_.uniq` except that it's designed and optimized
8101 * for sorted arrays.
8107 * @param {Array} array The array to inspect.
8108 * @returns {Array} Returns the new duplicate free array.
8111 * _.sortedUniq([1, 1, 2]);
8114 function sortedUniq(array) {
8115 return (array && array.length)
8116 ? baseSortedUniq(array)
8121 * This method is like `_.uniqBy` except that it's designed and optimized
8122 * for sorted arrays.
8128 * @param {Array} array The array to inspect.
8129 * @param {Function} [iteratee] The iteratee invoked per element.
8130 * @returns {Array} Returns the new duplicate free array.
8133 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8136 function sortedUniqBy(array, iteratee) {
8137 return (array && array.length)
8138 ? baseSortedUniq(array, getIteratee(iteratee, 2))
8143 * Gets all but the first element of `array`.
8149 * @param {Array} array The array to query.
8150 * @returns {Array} Returns the slice of `array`.
8153 * _.tail([1, 2, 3]);
8156 function tail(array) {
8157 var length = array == null ? 0 : array.length;
8158 return length ? baseSlice(array, 1, length) : [];
8162 * Creates a slice of `array` with `n` elements taken from the beginning.
8168 * @param {Array} array The array to query.
8169 * @param {number} [n=1] The number of elements to take.
8170 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8171 * @returns {Array} Returns the slice of `array`.
8174 * _.take([1, 2, 3]);
8177 * _.take([1, 2, 3], 2);
8180 * _.take([1, 2, 3], 5);
8183 * _.take([1, 2, 3], 0);
8186 function take(array, n, guard) {
8187 if (!(array && array.length)) {
8190 n = (guard || n === undefined) ? 1 : toInteger(n);
8191 return baseSlice(array, 0, n < 0 ? 0 : n);
8195 * Creates a slice of `array` with `n` elements taken from the end.
8201 * @param {Array} array The array to query.
8202 * @param {number} [n=1] The number of elements to take.
8203 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8204 * @returns {Array} Returns the slice of `array`.
8207 * _.takeRight([1, 2, 3]);
8210 * _.takeRight([1, 2, 3], 2);
8213 * _.takeRight([1, 2, 3], 5);
8216 * _.takeRight([1, 2, 3], 0);
8219 function takeRight(array, n, guard) {
8220 var length = array == null ? 0 : array.length;
8224 n = (guard || n === undefined) ? 1 : toInteger(n);
8226 return baseSlice(array, n < 0 ? 0 : n, length);
8230 * Creates a slice of `array` with elements taken from the end. Elements are
8231 * taken until `predicate` returns falsey. The predicate is invoked with
8232 * three arguments: (value, index, array).
8238 * @param {Array} array The array to query.
8239 * @param {Function} [predicate=_.identity] The function invoked per iteration.
8240 * @returns {Array} Returns the slice of `array`.
8244 * { 'user': 'barney', 'active': true },
8245 * { 'user': 'fred', 'active': false },
8246 * { 'user': 'pebbles', 'active': false }
8249 * _.takeRightWhile(users, function(o) { return !o.active; });
8250 * // => objects for ['fred', 'pebbles']
8252 * // The `_.matches` iteratee shorthand.
8253 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8254 * // => objects for ['pebbles']
8256 * // The `_.matchesProperty` iteratee shorthand.
8257 * _.takeRightWhile(users, ['active', false]);
8258 * // => objects for ['fred', 'pebbles']
8260 * // The `_.property` iteratee shorthand.
8261 * _.takeRightWhile(users, 'active');
8264 function takeRightWhile(array, predicate) {
8265 return (array && array.length)
8266 ? baseWhile(array, getIteratee(predicate, 3), false, true)
8271 * Creates a slice of `array` with elements taken from the beginning. Elements
8272 * are taken until `predicate` returns falsey. The predicate is invoked with
8273 * three arguments: (value, index, array).
8279 * @param {Array} array The array to query.
8280 * @param {Function} [predicate=_.identity] The function invoked per iteration.
8281 * @returns {Array} Returns the slice of `array`.
8285 * { 'user': 'barney', 'active': false },
8286 * { 'user': 'fred', 'active': false },
8287 * { 'user': 'pebbles', 'active': true }
8290 * _.takeWhile(users, function(o) { return !o.active; });
8291 * // => objects for ['barney', 'fred']
8293 * // The `_.matches` iteratee shorthand.
8294 * _.takeWhile(users, { 'user': 'barney', 'active': false });
8295 * // => objects for ['barney']
8297 * // The `_.matchesProperty` iteratee shorthand.
8298 * _.takeWhile(users, ['active', false]);
8299 * // => objects for ['barney', 'fred']
8301 * // The `_.property` iteratee shorthand.
8302 * _.takeWhile(users, 'active');
8305 function takeWhile(array, predicate) {
8306 return (array && array.length)
8307 ? baseWhile(array, getIteratee(predicate, 3))
8312 * Creates an array of unique values, in order, from all given arrays using
8313 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8314 * for equality comparisons.
8320 * @param {...Array} [arrays] The arrays to inspect.
8321 * @returns {Array} Returns the new array of combined values.
8324 * _.union([2], [1, 2]);
8327 var union = baseRest(function(arrays) {
8328 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8332 * This method is like `_.union` except that it accepts `iteratee` which is
8333 * invoked for each element of each `arrays` to generate the criterion by
8334 * which uniqueness is computed. Result values are chosen from the first
8335 * array in which the value occurs. The iteratee is invoked with one argument:
8342 * @param {...Array} [arrays] The arrays to inspect.
8343 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8344 * @returns {Array} Returns the new array of combined values.
8347 * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8350 * // The `_.property` iteratee shorthand.
8351 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8352 * // => [{ 'x': 1 }, { 'x': 2 }]
8354 var unionBy = baseRest(function(arrays) {
8355 var iteratee = last(arrays);
8356 if (isArrayLikeObject(iteratee)) {
8357 iteratee = undefined;
8359 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
8363 * This method is like `_.union` except that it accepts `comparator` which
8364 * is invoked to compare elements of `arrays`. Result values are chosen from
8365 * the first array in which the value occurs. The comparator is invoked
8366 * with two arguments: (arrVal, othVal).
8372 * @param {...Array} [arrays] The arrays to inspect.
8373 * @param {Function} [comparator] The comparator invoked per element.
8374 * @returns {Array} Returns the new array of combined values.
8377 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8378 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8380 * _.unionWith(objects, others, _.isEqual);
8381 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8383 var unionWith = baseRest(function(arrays) {
8384 var comparator = last(arrays);
8385 comparator = typeof comparator == 'function' ? comparator : undefined;
8386 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
8390 * Creates a duplicate-free version of an array, using
8391 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8392 * for equality comparisons, in which only the first occurrence of each element
8393 * is kept. The order of result values is determined by the order they occur
8400 * @param {Array} array The array to inspect.
8401 * @returns {Array} Returns the new duplicate free array.
8404 * _.uniq([2, 1, 2]);
8407 function uniq(array) {
8408 return (array && array.length) ? baseUniq(array) : [];
8412 * This method is like `_.uniq` except that it accepts `iteratee` which is
8413 * invoked for each element in `array` to generate the criterion by which
8414 * uniqueness is computed. The order of result values is determined by the
8415 * order they occur in the array. The iteratee is invoked with one argument:
8422 * @param {Array} array The array to inspect.
8423 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8424 * @returns {Array} Returns the new duplicate free array.
8427 * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8430 * // The `_.property` iteratee shorthand.
8431 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8432 * // => [{ 'x': 1 }, { 'x': 2 }]
8434 function uniqBy(array, iteratee) {
8435 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
8439 * This method is like `_.uniq` except that it accepts `comparator` which
8440 * is invoked to compare elements of `array`. The order of result values is
8441 * determined by the order they occur in the array.The comparator is invoked
8442 * with two arguments: (arrVal, othVal).
8448 * @param {Array} array The array to inspect.
8449 * @param {Function} [comparator] The comparator invoked per element.
8450 * @returns {Array} Returns the new duplicate free array.
8453 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8455 * _.uniqWith(objects, _.isEqual);
8456 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8458 function uniqWith(array, comparator) {
8459 comparator = typeof comparator == 'function' ? comparator : undefined;
8460 return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
8464 * This method is like `_.zip` except that it accepts an array of grouped
8465 * elements and creates an array regrouping the elements to their pre-zip
8472 * @param {Array} array The array of grouped elements to process.
8473 * @returns {Array} Returns the new array of regrouped elements.
8476 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8477 * // => [['a', 1, true], ['b', 2, false]]
8480 * // => [['a', 'b'], [1, 2], [true, false]]
8482 function unzip(array) {
8483 if (!(array && array.length)) {
8487 array = arrayFilter(array, function(group) {
8488 if (isArrayLikeObject(group)) {
8489 length = nativeMax(group.length, length);
8493 return baseTimes(length, function(index) {
8494 return arrayMap(array, baseProperty(index));
8499 * This method is like `_.unzip` except that it accepts `iteratee` to specify
8500 * how regrouped values should be combined. The iteratee is invoked with the
8501 * elements of each group: (...group).
8507 * @param {Array} array The array of grouped elements to process.
8508 * @param {Function} [iteratee=_.identity] The function to combine
8510 * @returns {Array} Returns the new array of regrouped elements.
8513 * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8514 * // => [[1, 10, 100], [2, 20, 200]]
8516 * _.unzipWith(zipped, _.add);
8517 * // => [3, 30, 300]
8519 function unzipWith(array, iteratee) {
8520 if (!(array && array.length)) {
8523 var result = unzip(array);
8524 if (iteratee == null) {
8527 return arrayMap(result, function(group) {
8528 return apply(iteratee, undefined, group);
8533 * Creates an array excluding all given values using
8534 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8535 * for equality comparisons.
8537 * **Note:** Unlike `_.pull`, this method returns a new array.
8543 * @param {Array} array The array to inspect.
8544 * @param {...*} [values] The values to exclude.
8545 * @returns {Array} Returns the new array of filtered values.
8546 * @see _.difference, _.xor
8549 * _.without([2, 1, 2, 3], 1, 2);
8552 var without = baseRest(function(array, values) {
8553 return isArrayLikeObject(array)
8554 ? baseDifference(array, values)
8559 * Creates an array of unique values that is the
8560 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
8561 * of the given arrays. The order of result values is determined by the order
8562 * they occur in the arrays.
8568 * @param {...Array} [arrays] The arrays to inspect.
8569 * @returns {Array} Returns the new array of filtered values.
8570 * @see _.difference, _.without
8573 * _.xor([2, 1], [2, 3]);
8576 var xor = baseRest(function(arrays) {
8577 return baseXor(arrayFilter(arrays, isArrayLikeObject));
8581 * This method is like `_.xor` except that it accepts `iteratee` which is
8582 * invoked for each element of each `arrays` to generate the criterion by
8583 * which by which they're compared. The order of result values is determined
8584 * by the order they occur in the arrays. The iteratee is invoked with one
8585 * argument: (value).
8591 * @param {...Array} [arrays] The arrays to inspect.
8592 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8593 * @returns {Array} Returns the new array of filtered values.
8596 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8599 * // The `_.property` iteratee shorthand.
8600 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8601 * // => [{ 'x': 2 }]
8603 var xorBy = baseRest(function(arrays) {
8604 var iteratee = last(arrays);
8605 if (isArrayLikeObject(iteratee)) {
8606 iteratee = undefined;
8608 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
8612 * This method is like `_.xor` except that it accepts `comparator` which is
8613 * invoked to compare elements of `arrays`. The order of result values is
8614 * determined by the order they occur in the arrays. The comparator is invoked
8615 * with two arguments: (arrVal, othVal).
8621 * @param {...Array} [arrays] The arrays to inspect.
8622 * @param {Function} [comparator] The comparator invoked per element.
8623 * @returns {Array} Returns the new array of filtered values.
8626 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8627 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8629 * _.xorWith(objects, others, _.isEqual);
8630 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8632 var xorWith = baseRest(function(arrays) {
8633 var comparator = last(arrays);
8634 comparator = typeof comparator == 'function' ? comparator : undefined;
8635 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
8639 * Creates an array of grouped elements, the first of which contains the
8640 * first elements of the given arrays, the second of which contains the
8641 * second elements of the given arrays, and so on.
8647 * @param {...Array} [arrays] The arrays to process.
8648 * @returns {Array} Returns the new array of grouped elements.
8651 * _.zip(['a', 'b'], [1, 2], [true, false]);
8652 * // => [['a', 1, true], ['b', 2, false]]
8654 var zip = baseRest(unzip);
8657 * This method is like `_.fromPairs` except that it accepts two arrays,
8658 * one of property identifiers and one of corresponding values.
8664 * @param {Array} [props=[]] The property identifiers.
8665 * @param {Array} [values=[]] The property values.
8666 * @returns {Object} Returns the new object.
8669 * _.zipObject(['a', 'b'], [1, 2]);
8670 * // => { 'a': 1, 'b': 2 }
8672 function zipObject(props, values) {
8673 return baseZipObject(props || [], values || [], assignValue);
8677 * This method is like `_.zipObject` except that it supports property paths.
8683 * @param {Array} [props=[]] The property identifiers.
8684 * @param {Array} [values=[]] The property values.
8685 * @returns {Object} Returns the new object.
8688 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
8689 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
8691 function zipObjectDeep(props, values) {
8692 return baseZipObject(props || [], values || [], baseSet);
8696 * This method is like `_.zip` except that it accepts `iteratee` to specify
8697 * how grouped values should be combined. The iteratee is invoked with the
8698 * elements of each group: (...group).
8704 * @param {...Array} [arrays] The arrays to process.
8705 * @param {Function} [iteratee=_.identity] The function to combine
8707 * @returns {Array} Returns the new array of grouped elements.
8710 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
8715 var zipWith = baseRest(function(arrays) {
8716 var length = arrays.length,
8717 iteratee = length > 1 ? arrays[length - 1] : undefined;
8719 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
8720 return unzipWith(arrays, iteratee);
8723 /*------------------------------------------------------------------------*/
8726 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
8727 * chain sequences enabled. The result of such sequences must be unwrapped
8734 * @param {*} value The value to wrap.
8735 * @returns {Object} Returns the new `lodash` wrapper instance.
8739 * { 'user': 'barney', 'age': 36 },
8740 * { 'user': 'fred', 'age': 40 },
8741 * { 'user': 'pebbles', 'age': 1 }
8747 * .map(function(o) {
8748 * return o.user + ' is ' + o.age;
8752 * // => 'pebbles is 1'
8754 function chain(value) {
8755 var result = lodash(value);
8756 result.__chain__ = true;
8761 * This method invokes `interceptor` and returns `value`. The interceptor
8762 * is invoked with one argument; (value). The purpose of this method is to
8763 * "tap into" a method chain sequence in order to modify intermediate results.
8769 * @param {*} value The value to provide to `interceptor`.
8770 * @param {Function} interceptor The function to invoke.
8771 * @returns {*} Returns `value`.
8775 * .tap(function(array) {
8776 * // Mutate input array.
8783 function tap(value, interceptor) {
8789 * This method is like `_.tap` except that it returns the result of `interceptor`.
8790 * The purpose of this method is to "pass thru" values replacing intermediate
8791 * results in a method chain sequence.
8797 * @param {*} value The value to provide to `interceptor`.
8798 * @param {Function} interceptor The function to invoke.
8799 * @returns {*} Returns the result of `interceptor`.
8805 * .thru(function(value) {
8811 function thru(value, interceptor) {
8812 return interceptor(value);
8816 * This method is the wrapper version of `_.at`.
8822 * @param {...(string|string[])} [paths] The property paths to pick.
8823 * @returns {Object} Returns the new `lodash` wrapper instance.
8826 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
8828 * _(object).at(['a[0].b.c', 'a[1]']).value();
8831 var wrapperAt = flatRest(function(paths) {
8832 var length = paths.length,
8833 start = length ? paths[0] : 0,
8834 value = this.__wrapped__,
8835 interceptor = function(object) { return baseAt(object, paths); };
8837 if (length > 1 || this.__actions__.length ||
8838 !(value instanceof LazyWrapper) || !isIndex(start)) {
8839 return this.thru(interceptor);
8841 value = value.slice(start, +start + (length ? 1 : 0));
8842 value.__actions__.push({
8844 'args': [interceptor],
8845 'thisArg': undefined
8847 return new LodashWrapper(value, this.__chain__).thru(function(array) {
8848 if (length && !array.length) {
8849 array.push(undefined);
8856 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
8862 * @returns {Object} Returns the new `lodash` wrapper instance.
8866 * { 'user': 'barney', 'age': 36 },
8867 * { 'user': 'fred', 'age': 40 }
8870 * // A sequence without explicit chaining.
8872 * // => { 'user': 'barney', 'age': 36 }
8874 * // A sequence with explicit chaining.
8880 * // => { 'user': 'barney' }
8882 function wrapperChain() {
8887 * Executes the chain sequence and returns the wrapped result.
8893 * @returns {Object} Returns the new `lodash` wrapper instance.
8896 * var array = [1, 2];
8897 * var wrapped = _(array).push(3);
8899 * console.log(array);
8902 * wrapped = wrapped.commit();
8903 * console.log(array);
8909 * console.log(array);
8912 function wrapperCommit() {
8913 return new LodashWrapper(this.value(), this.__chain__);
8917 * Gets the next value on a wrapped object following the
8918 * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
8924 * @returns {Object} Returns the next iterator value.
8927 * var wrapped = _([1, 2]);
8930 * // => { 'done': false, 'value': 1 }
8933 * // => { 'done': false, 'value': 2 }
8936 * // => { 'done': true, 'value': undefined }
8938 function wrapperNext() {
8939 if (this.__values__ === undefined) {
8940 this.__values__ = toArray(this.value());
8942 var done = this.__index__ >= this.__values__.length,
8943 value = done ? undefined : this.__values__[this.__index__++];
8945 return { 'done': done, 'value': value };
8949 * Enables the wrapper to be iterable.
8951 * @name Symbol.iterator
8955 * @returns {Object} Returns the wrapper object.
8958 * var wrapped = _([1, 2]);
8960 * wrapped[Symbol.iterator]() === wrapped;
8963 * Array.from(wrapped);
8966 function wrapperToIterator() {
8971 * Creates a clone of the chain sequence planting `value` as the wrapped value.
8977 * @param {*} value The value to plant.
8978 * @returns {Object} Returns the new `lodash` wrapper instance.
8981 * function square(n) {
8985 * var wrapped = _([1, 2]).map(square);
8986 * var other = wrapped.plant([3, 4]);
8994 function wrapperPlant(value) {
8998 while (parent instanceof baseLodash) {
8999 var clone = wrapperClone(parent);
9000 clone.__index__ = 0;
9001 clone.__values__ = undefined;
9003 previous.__wrapped__ = clone;
9007 var previous = clone;
9008 parent = parent.__wrapped__;
9010 previous.__wrapped__ = value;
9015 * This method is the wrapper version of `_.reverse`.
9017 * **Note:** This method mutates the wrapped array.
9023 * @returns {Object} Returns the new `lodash` wrapper instance.
9026 * var array = [1, 2, 3];
9028 * _(array).reverse().value()
9031 * console.log(array);
9034 function wrapperReverse() {
9035 var value = this.__wrapped__;
9036 if (value instanceof LazyWrapper) {
9037 var wrapped = value;
9038 if (this.__actions__.length) {
9039 wrapped = new LazyWrapper(this);
9041 wrapped = wrapped.reverse();
9042 wrapped.__actions__.push({
9045 'thisArg': undefined
9047 return new LodashWrapper(wrapped, this.__chain__);
9049 return this.thru(reverse);
9053 * Executes the chain sequence to resolve the unwrapped value.
9058 * @alias toJSON, valueOf
9060 * @returns {*} Returns the resolved unwrapped value.
9063 * _([1, 2, 3]).value();
9066 function wrapperValue() {
9067 return baseWrapperValue(this.__wrapped__, this.__actions__);
9070 /*------------------------------------------------------------------------*/
9073 * Creates an object composed of keys generated from the results of running
9074 * each element of `collection` thru `iteratee`. The corresponding value of
9075 * each key is the number of times the key was returned by `iteratee`. The
9076 * iteratee is invoked with one argument: (value).
9081 * @category Collection
9082 * @param {Array|Object} collection The collection to iterate over.
9083 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9084 * @returns {Object} Returns the composed aggregate object.
9087 * _.countBy([6.1, 4.2, 6.3], Math.floor);
9088 * // => { '4': 1, '6': 2 }
9090 * // The `_.property` iteratee shorthand.
9091 * _.countBy(['one', 'two', 'three'], 'length');
9092 * // => { '3': 2, '5': 1 }
9094 var countBy = createAggregator(function(result, value, key) {
9095 if (hasOwnProperty.call(result, key)) {
9098 baseAssignValue(result, key, 1);
9103 * Checks if `predicate` returns truthy for **all** elements of `collection`.
9104 * Iteration is stopped once `predicate` returns falsey. The predicate is
9105 * invoked with three arguments: (value, index|key, collection).
9107 * **Note:** This method returns `true` for
9108 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
9109 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
9110 * elements of empty collections.
9115 * @category Collection
9116 * @param {Array|Object} collection The collection to iterate over.
9117 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9118 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9119 * @returns {boolean} Returns `true` if all elements pass the predicate check,
9123 * _.every([true, 1, null, 'yes'], Boolean);
9127 * { 'user': 'barney', 'age': 36, 'active': false },
9128 * { 'user': 'fred', 'age': 40, 'active': false }
9131 * // The `_.matches` iteratee shorthand.
9132 * _.every(users, { 'user': 'barney', 'active': false });
9135 * // The `_.matchesProperty` iteratee shorthand.
9136 * _.every(users, ['active', false]);
9139 * // The `_.property` iteratee shorthand.
9140 * _.every(users, 'active');
9143 function every(collection, predicate, guard) {
9144 var func = isArray(collection) ? arrayEvery : baseEvery;
9145 if (guard && isIterateeCall(collection, predicate, guard)) {
9146 predicate = undefined;
9148 return func(collection, getIteratee(predicate, 3));
9152 * Iterates over elements of `collection`, returning an array of all elements
9153 * `predicate` returns truthy for. The predicate is invoked with three
9154 * arguments: (value, index|key, collection).
9156 * **Note:** Unlike `_.remove`, this method returns a new array.
9161 * @category Collection
9162 * @param {Array|Object} collection The collection to iterate over.
9163 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9164 * @returns {Array} Returns the new filtered array.
9169 * { 'user': 'barney', 'age': 36, 'active': true },
9170 * { 'user': 'fred', 'age': 40, 'active': false }
9173 * _.filter(users, function(o) { return !o.active; });
9174 * // => objects for ['fred']
9176 * // The `_.matches` iteratee shorthand.
9177 * _.filter(users, { 'age': 36, 'active': true });
9178 * // => objects for ['barney']
9180 * // The `_.matchesProperty` iteratee shorthand.
9181 * _.filter(users, ['active', false]);
9182 * // => objects for ['fred']
9184 * // The `_.property` iteratee shorthand.
9185 * _.filter(users, 'active');
9186 * // => objects for ['barney']
9188 function filter(collection, predicate) {
9189 var func = isArray(collection) ? arrayFilter : baseFilter;
9190 return func(collection, getIteratee(predicate, 3));
9194 * Iterates over elements of `collection`, returning the first element
9195 * `predicate` returns truthy for. The predicate is invoked with three
9196 * arguments: (value, index|key, collection).
9201 * @category Collection
9202 * @param {Array|Object} collection The collection to inspect.
9203 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9204 * @param {number} [fromIndex=0] The index to search from.
9205 * @returns {*} Returns the matched element, else `undefined`.
9209 * { 'user': 'barney', 'age': 36, 'active': true },
9210 * { 'user': 'fred', 'age': 40, 'active': false },
9211 * { 'user': 'pebbles', 'age': 1, 'active': true }
9214 * _.find(users, function(o) { return o.age < 40; });
9215 * // => object for 'barney'
9217 * // The `_.matches` iteratee shorthand.
9218 * _.find(users, { 'age': 1, 'active': true });
9219 * // => object for 'pebbles'
9221 * // The `_.matchesProperty` iteratee shorthand.
9222 * _.find(users, ['active', false]);
9223 * // => object for 'fred'
9225 * // The `_.property` iteratee shorthand.
9226 * _.find(users, 'active');
9227 * // => object for 'barney'
9229 var find = createFind(findIndex);
9232 * This method is like `_.find` except that it iterates over elements of
9233 * `collection` from right to left.
9238 * @category Collection
9239 * @param {Array|Object} collection The collection to inspect.
9240 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9241 * @param {number} [fromIndex=collection.length-1] The index to search from.
9242 * @returns {*} Returns the matched element, else `undefined`.
9245 * _.findLast([1, 2, 3, 4], function(n) {
9246 * return n % 2 == 1;
9250 var findLast = createFind(findLastIndex);
9253 * Creates a flattened array of values by running each element in `collection`
9254 * thru `iteratee` and flattening the mapped results. The iteratee is invoked
9255 * with three arguments: (value, index|key, collection).
9260 * @category Collection
9261 * @param {Array|Object} collection The collection to iterate over.
9262 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9263 * @returns {Array} Returns the new flattened array.
9266 * function duplicate(n) {
9270 * _.flatMap([1, 2], duplicate);
9271 * // => [1, 1, 2, 2]
9273 function flatMap(collection, iteratee) {
9274 return baseFlatten(map(collection, iteratee), 1);
9278 * This method is like `_.flatMap` except that it recursively flattens the
9284 * @category Collection
9285 * @param {Array|Object} collection The collection to iterate over.
9286 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9287 * @returns {Array} Returns the new flattened array.
9290 * function duplicate(n) {
9291 * return [[[n, n]]];
9294 * _.flatMapDeep([1, 2], duplicate);
9295 * // => [1, 1, 2, 2]
9297 function flatMapDeep(collection, iteratee) {
9298 return baseFlatten(map(collection, iteratee), INFINITY);
9302 * This method is like `_.flatMap` except that it recursively flattens the
9303 * mapped results up to `depth` times.
9308 * @category Collection
9309 * @param {Array|Object} collection The collection to iterate over.
9310 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9311 * @param {number} [depth=1] The maximum recursion depth.
9312 * @returns {Array} Returns the new flattened array.
9315 * function duplicate(n) {
9316 * return [[[n, n]]];
9319 * _.flatMapDepth([1, 2], duplicate, 2);
9320 * // => [[1, 1], [2, 2]]
9322 function flatMapDepth(collection, iteratee, depth) {
9323 depth = depth === undefined ? 1 : toInteger(depth);
9324 return baseFlatten(map(collection, iteratee), depth);
9328 * Iterates over elements of `collection` and invokes `iteratee` for each element.
9329 * The iteratee is invoked with three arguments: (value, index|key, collection).
9330 * Iteratee functions may exit iteration early by explicitly returning `false`.
9332 * **Note:** As with other "Collections" methods, objects with a "length"
9333 * property are iterated like arrays. To avoid this behavior use `_.forIn`
9334 * or `_.forOwn` for object iteration.
9340 * @category Collection
9341 * @param {Array|Object} collection The collection to iterate over.
9342 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9343 * @returns {Array|Object} Returns `collection`.
9344 * @see _.forEachRight
9347 * _.forEach([1, 2], function(value) {
9348 * console.log(value);
9350 * // => Logs `1` then `2`.
9352 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9355 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9357 function forEach(collection, iteratee) {
9358 var func = isArray(collection) ? arrayEach : baseEach;
9359 return func(collection, getIteratee(iteratee, 3));
9363 * This method is like `_.forEach` except that it iterates over elements of
9364 * `collection` from right to left.
9370 * @category Collection
9371 * @param {Array|Object} collection The collection to iterate over.
9372 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9373 * @returns {Array|Object} Returns `collection`.
9377 * _.forEachRight([1, 2], function(value) {
9378 * console.log(value);
9380 * // => Logs `2` then `1`.
9382 function forEachRight(collection, iteratee) {
9383 var func = isArray(collection) ? arrayEachRight : baseEachRight;
9384 return func(collection, getIteratee(iteratee, 3));
9388 * Creates an object composed of keys generated from the results of running
9389 * each element of `collection` thru `iteratee`. The order of grouped values
9390 * is determined by the order they occur in `collection`. The corresponding
9391 * value of each key is an array of elements responsible for generating the
9392 * key. The iteratee is invoked with one argument: (value).
9397 * @category Collection
9398 * @param {Array|Object} collection The collection to iterate over.
9399 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9400 * @returns {Object} Returns the composed aggregate object.
9403 * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9404 * // => { '4': [4.2], '6': [6.1, 6.3] }
9406 * // The `_.property` iteratee shorthand.
9407 * _.groupBy(['one', 'two', 'three'], 'length');
9408 * // => { '3': ['one', 'two'], '5': ['three'] }
9410 var groupBy = createAggregator(function(result, value, key) {
9411 if (hasOwnProperty.call(result, key)) {
9412 result[key].push(value);
9414 baseAssignValue(result, key, [value]);
9419 * Checks if `value` is in `collection`. If `collection` is a string, it's
9420 * checked for a substring of `value`, otherwise
9421 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9422 * is used for equality comparisons. If `fromIndex` is negative, it's used as
9423 * the offset from the end of `collection`.
9428 * @category Collection
9429 * @param {Array|Object|string} collection The collection to inspect.
9430 * @param {*} value The value to search for.
9431 * @param {number} [fromIndex=0] The index to search from.
9432 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9433 * @returns {boolean} Returns `true` if `value` is found, else `false`.
9436 * _.includes([1, 2, 3], 1);
9439 * _.includes([1, 2, 3], 1, 2);
9442 * _.includes({ 'a': 1, 'b': 2 }, 1);
9445 * _.includes('abcd', 'bc');
9448 function includes(collection, value, fromIndex, guard) {
9449 collection = isArrayLike(collection) ? collection : values(collection);
9450 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9452 var length = collection.length;
9453 if (fromIndex < 0) {
9454 fromIndex = nativeMax(length + fromIndex, 0);
9456 return isString(collection)
9457 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9458 : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9462 * Invokes the method at `path` of each element in `collection`, returning
9463 * an array of the results of each invoked method. Any additional arguments
9464 * are provided to each invoked method. If `path` is a function, it's invoked
9465 * for, and `this` bound to, each element in `collection`.
9470 * @category Collection
9471 * @param {Array|Object} collection The collection to iterate over.
9472 * @param {Array|Function|string} path The path of the method to invoke or
9473 * the function invoked per iteration.
9474 * @param {...*} [args] The arguments to invoke each method with.
9475 * @returns {Array} Returns the array of results.
9478 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9479 * // => [[1, 5, 7], [1, 2, 3]]
9481 * _.invokeMap([123, 456], String.prototype.split, '');
9482 * // => [['1', '2', '3'], ['4', '5', '6']]
9484 var invokeMap = baseRest(function(collection, path, args) {
9486 isFunc = typeof path == 'function',
9487 result = isArrayLike(collection) ? Array(collection.length) : [];
9489 baseEach(collection, function(value) {
9490 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
9496 * Creates an object composed of keys generated from the results of running
9497 * each element of `collection` thru `iteratee`. The corresponding value of
9498 * each key is the last element responsible for generating the key. The
9499 * iteratee is invoked with one argument: (value).
9504 * @category Collection
9505 * @param {Array|Object} collection The collection to iterate over.
9506 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9507 * @returns {Object} Returns the composed aggregate object.
9511 * { 'dir': 'left', 'code': 97 },
9512 * { 'dir': 'right', 'code': 100 }
9515 * _.keyBy(array, function(o) {
9516 * return String.fromCharCode(o.code);
9518 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9520 * _.keyBy(array, 'dir');
9521 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9523 var keyBy = createAggregator(function(result, value, key) {
9524 baseAssignValue(result, key, value);
9528 * Creates an array of values by running each element in `collection` thru
9529 * `iteratee`. The iteratee is invoked with three arguments:
9530 * (value, index|key, collection).
9532 * Many lodash methods are guarded to work as iteratees for methods like
9533 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9535 * The guarded methods are:
9536 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9537 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9538 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9539 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9544 * @category Collection
9545 * @param {Array|Object} collection The collection to iterate over.
9546 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9547 * @returns {Array} Returns the new mapped array.
9550 * function square(n) {
9554 * _.map([4, 8], square);
9557 * _.map({ 'a': 4, 'b': 8 }, square);
9558 * // => [16, 64] (iteration order is not guaranteed)
9561 * { 'user': 'barney' },
9562 * { 'user': 'fred' }
9565 * // The `_.property` iteratee shorthand.
9566 * _.map(users, 'user');
9567 * // => ['barney', 'fred']
9569 function map(collection, iteratee) {
9570 var func = isArray(collection) ? arrayMap : baseMap;
9571 return func(collection, getIteratee(iteratee, 3));
9575 * This method is like `_.sortBy` except that it allows specifying the sort
9576 * orders of the iteratees to sort by. If `orders` is unspecified, all values
9577 * are sorted in ascending order. Otherwise, specify an order of "desc" for
9578 * descending or "asc" for ascending sort order of corresponding values.
9583 * @category Collection
9584 * @param {Array|Object} collection The collection to iterate over.
9585 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
9586 * The iteratees to sort by.
9587 * @param {string[]} [orders] The sort orders of `iteratees`.
9588 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9589 * @returns {Array} Returns the new sorted array.
9593 * { 'user': 'fred', 'age': 48 },
9594 * { 'user': 'barney', 'age': 34 },
9595 * { 'user': 'fred', 'age': 40 },
9596 * { 'user': 'barney', 'age': 36 }
9599 * // Sort by `user` in ascending order and by `age` in descending order.
9600 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
9601 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9603 function orderBy(collection, iteratees, orders, guard) {
9604 if (collection == null) {
9607 if (!isArray(iteratees)) {
9608 iteratees = iteratees == null ? [] : [iteratees];
9610 orders = guard ? undefined : orders;
9611 if (!isArray(orders)) {
9612 orders = orders == null ? [] : [orders];
9614 return baseOrderBy(collection, iteratees, orders);
9618 * Creates an array of elements split into two groups, the first of which
9619 * contains elements `predicate` returns truthy for, the second of which
9620 * contains elements `predicate` returns falsey for. The predicate is
9621 * invoked with one argument: (value).
9626 * @category Collection
9627 * @param {Array|Object} collection The collection to iterate over.
9628 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9629 * @returns {Array} Returns the array of grouped elements.
9633 * { 'user': 'barney', 'age': 36, 'active': false },
9634 * { 'user': 'fred', 'age': 40, 'active': true },
9635 * { 'user': 'pebbles', 'age': 1, 'active': false }
9638 * _.partition(users, function(o) { return o.active; });
9639 * // => objects for [['fred'], ['barney', 'pebbles']]
9641 * // The `_.matches` iteratee shorthand.
9642 * _.partition(users, { 'age': 1, 'active': false });
9643 * // => objects for [['pebbles'], ['barney', 'fred']]
9645 * // The `_.matchesProperty` iteratee shorthand.
9646 * _.partition(users, ['active', false]);
9647 * // => objects for [['barney', 'pebbles'], ['fred']]
9649 * // The `_.property` iteratee shorthand.
9650 * _.partition(users, 'active');
9651 * // => objects for [['fred'], ['barney', 'pebbles']]
9653 var partition = createAggregator(function(result, value, key) {
9654 result[key ? 0 : 1].push(value);
9655 }, function() { return [[], []]; });
9658 * Reduces `collection` to a value which is the accumulated result of running
9659 * each element in `collection` thru `iteratee`, where each successive
9660 * invocation is supplied the return value of the previous. If `accumulator`
9661 * is not given, the first element of `collection` is used as the initial
9662 * value. The iteratee is invoked with four arguments:
9663 * (accumulator, value, index|key, collection).
9665 * Many lodash methods are guarded to work as iteratees for methods like
9666 * `_.reduce`, `_.reduceRight`, and `_.transform`.
9668 * The guarded methods are:
9669 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
9675 * @category Collection
9676 * @param {Array|Object} collection The collection to iterate over.
9677 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9678 * @param {*} [accumulator] The initial value.
9679 * @returns {*} Returns the accumulated value.
9680 * @see _.reduceRight
9683 * _.reduce([1, 2], function(sum, n) {
9688 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
9689 * (result[value] || (result[value] = [])).push(key);
9692 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
9694 function reduce(collection, iteratee, accumulator) {
9695 var func = isArray(collection) ? arrayReduce : baseReduce,
9696 initAccum = arguments.length < 3;
9698 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
9702 * This method is like `_.reduce` except that it iterates over elements of
9703 * `collection` from right to left.
9708 * @category Collection
9709 * @param {Array|Object} collection The collection to iterate over.
9710 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9711 * @param {*} [accumulator] The initial value.
9712 * @returns {*} Returns the accumulated value.
9716 * var array = [[0, 1], [2, 3], [4, 5]];
9718 * _.reduceRight(array, function(flattened, other) {
9719 * return flattened.concat(other);
9721 * // => [4, 5, 2, 3, 0, 1]
9723 function reduceRight(collection, iteratee, accumulator) {
9724 var func = isArray(collection) ? arrayReduceRight : baseReduce,
9725 initAccum = arguments.length < 3;
9727 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
9731 * The opposite of `_.filter`; this method returns the elements of `collection`
9732 * that `predicate` does **not** return truthy for.
9737 * @category Collection
9738 * @param {Array|Object} collection The collection to iterate over.
9739 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9740 * @returns {Array} Returns the new filtered array.
9745 * { 'user': 'barney', 'age': 36, 'active': false },
9746 * { 'user': 'fred', 'age': 40, 'active': true }
9749 * _.reject(users, function(o) { return !o.active; });
9750 * // => objects for ['fred']
9752 * // The `_.matches` iteratee shorthand.
9753 * _.reject(users, { 'age': 40, 'active': true });
9754 * // => objects for ['barney']
9756 * // The `_.matchesProperty` iteratee shorthand.
9757 * _.reject(users, ['active', false]);
9758 * // => objects for ['fred']
9760 * // The `_.property` iteratee shorthand.
9761 * _.reject(users, 'active');
9762 * // => objects for ['barney']
9764 function reject(collection, predicate) {
9765 var func = isArray(collection) ? arrayFilter : baseFilter;
9766 return func(collection, negate(getIteratee(predicate, 3)));
9770 * Gets a random element from `collection`.
9775 * @category Collection
9776 * @param {Array|Object} collection The collection to sample.
9777 * @returns {*} Returns the random element.
9780 * _.sample([1, 2, 3, 4]);
9783 function sample(collection) {
9784 var func = isArray(collection) ? arraySample : baseSample;
9785 return func(collection);
9789 * Gets `n` random elements at unique keys from `collection` up to the
9790 * size of `collection`.
9795 * @category Collection
9796 * @param {Array|Object} collection The collection to sample.
9797 * @param {number} [n=1] The number of elements to sample.
9798 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9799 * @returns {Array} Returns the random elements.
9802 * _.sampleSize([1, 2, 3], 2);
9805 * _.sampleSize([1, 2, 3], 4);
9808 function sampleSize(collection, n, guard) {
9809 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
9814 var func = isArray(collection) ? arraySampleSize : baseSampleSize;
9815 return func(collection, n);
9819 * Creates an array of shuffled values, using a version of the
9820 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9825 * @category Collection
9826 * @param {Array|Object} collection The collection to shuffle.
9827 * @returns {Array} Returns the new shuffled array.
9830 * _.shuffle([1, 2, 3, 4]);
9831 * // => [4, 1, 3, 2]
9833 function shuffle(collection) {
9834 var func = isArray(collection) ? arrayShuffle : baseShuffle;
9835 return func(collection);
9839 * Gets the size of `collection` by returning its length for array-like
9840 * values or the number of own enumerable string keyed properties for objects.
9845 * @category Collection
9846 * @param {Array|Object|string} collection The collection to inspect.
9847 * @returns {number} Returns the collection size.
9850 * _.size([1, 2, 3]);
9853 * _.size({ 'a': 1, 'b': 2 });
9856 * _.size('pebbles');
9859 function size(collection) {
9860 if (collection == null) {
9863 if (isArrayLike(collection)) {
9864 return isString(collection) ? stringSize(collection) : collection.length;
9866 var tag = getTag(collection);
9867 if (tag == mapTag || tag == setTag) {
9868 return collection.size;
9870 return baseKeys(collection).length;
9874 * Checks if `predicate` returns truthy for **any** element of `collection`.
9875 * Iteration is stopped once `predicate` returns truthy. The predicate is
9876 * invoked with three arguments: (value, index|key, collection).
9881 * @category Collection
9882 * @param {Array|Object} collection The collection to iterate over.
9883 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9884 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9885 * @returns {boolean} Returns `true` if any element passes the predicate check,
9889 * _.some([null, 0, 'yes', false], Boolean);
9893 * { 'user': 'barney', 'active': true },
9894 * { 'user': 'fred', 'active': false }
9897 * // The `_.matches` iteratee shorthand.
9898 * _.some(users, { 'user': 'barney', 'active': false });
9901 * // The `_.matchesProperty` iteratee shorthand.
9902 * _.some(users, ['active', false]);
9905 * // The `_.property` iteratee shorthand.
9906 * _.some(users, 'active');
9909 function some(collection, predicate, guard) {
9910 var func = isArray(collection) ? arraySome : baseSome;
9911 if (guard && isIterateeCall(collection, predicate, guard)) {
9912 predicate = undefined;
9914 return func(collection, getIteratee(predicate, 3));
9918 * Creates an array of elements, sorted in ascending order by the results of
9919 * running each element in a collection thru each iteratee. This method
9920 * performs a stable sort, that is, it preserves the original sort order of
9921 * equal elements. The iteratees are invoked with one argument: (value).
9926 * @category Collection
9927 * @param {Array|Object} collection The collection to iterate over.
9928 * @param {...(Function|Function[])} [iteratees=[_.identity]]
9929 * The iteratees to sort by.
9930 * @returns {Array} Returns the new sorted array.
9934 * { 'user': 'fred', 'age': 48 },
9935 * { 'user': 'barney', 'age': 36 },
9936 * { 'user': 'fred', 'age': 40 },
9937 * { 'user': 'barney', 'age': 34 }
9940 * _.sortBy(users, [function(o) { return o.user; }]);
9941 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9943 * _.sortBy(users, ['user', 'age']);
9944 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
9946 var sortBy = baseRest(function(collection, iteratees) {
9947 if (collection == null) {
9950 var length = iteratees.length;
9951 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
9953 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
9954 iteratees = [iteratees[0]];
9956 return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
9959 /*------------------------------------------------------------------------*/
9962 * Gets the timestamp of the number of milliseconds that have elapsed since
9963 * the Unix epoch (1 January 1970 00:00:00 UTC).
9969 * @returns {number} Returns the timestamp.
9972 * _.defer(function(stamp) {
9973 * console.log(_.now() - stamp);
9975 * // => Logs the number of milliseconds it took for the deferred invocation.
9977 var now = ctxNow || function() {
9978 return root.Date.now();
9981 /*------------------------------------------------------------------------*/
9984 * The opposite of `_.before`; this method creates a function that invokes
9985 * `func` once it's called `n` or more times.
9990 * @category Function
9991 * @param {number} n The number of calls before `func` is invoked.
9992 * @param {Function} func The function to restrict.
9993 * @returns {Function} Returns the new restricted function.
9996 * var saves = ['profile', 'settings'];
9998 * var done = _.after(saves.length, function() {
9999 * console.log('done saving!');
10002 * _.forEach(saves, function(type) {
10003 * asyncSave({ 'type': type, 'complete': done });
10005 * // => Logs 'done saving!' after the two async saves have completed.
10007 function after(n, func) {
10008 if (typeof func != 'function') {
10009 throw new TypeError(FUNC_ERROR_TEXT);
10012 return function() {
10014 return func.apply(this, arguments);
10020 * Creates a function that invokes `func`, with up to `n` arguments,
10021 * ignoring any additional arguments.
10026 * @category Function
10027 * @param {Function} func The function to cap arguments for.
10028 * @param {number} [n=func.length] The arity cap.
10029 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10030 * @returns {Function} Returns the new capped function.
10033 * _.map(['6', '8', '10'], _.ary(parseInt, 1));
10036 function ary(func, n, guard) {
10037 n = guard ? undefined : n;
10038 n = (func && n == null) ? func.length : n;
10039 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
10043 * Creates a function that invokes `func`, with the `this` binding and arguments
10044 * of the created function, while it's called less than `n` times. Subsequent
10045 * calls to the created function return the result of the last `func` invocation.
10050 * @category Function
10051 * @param {number} n The number of calls at which `func` is no longer invoked.
10052 * @param {Function} func The function to restrict.
10053 * @returns {Function} Returns the new restricted function.
10056 * jQuery(element).on('click', _.before(5, addContactToList));
10057 * // => Allows adding up to 4 contacts to the list.
10059 function before(n, func) {
10061 if (typeof func != 'function') {
10062 throw new TypeError(FUNC_ERROR_TEXT);
10065 return function() {
10067 result = func.apply(this, arguments);
10077 * Creates a function that invokes `func` with the `this` binding of `thisArg`
10078 * and `partials` prepended to the arguments it receives.
10080 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10081 * may be used as a placeholder for partially applied arguments.
10083 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10084 * property of bound functions.
10089 * @category Function
10090 * @param {Function} func The function to bind.
10091 * @param {*} thisArg The `this` binding of `func`.
10092 * @param {...*} [partials] The arguments to be partially applied.
10093 * @returns {Function} Returns the new bound function.
10096 * function greet(greeting, punctuation) {
10097 * return greeting + ' ' + this.user + punctuation;
10100 * var object = { 'user': 'fred' };
10102 * var bound = _.bind(greet, object, 'hi');
10106 * // Bound with placeholders.
10107 * var bound = _.bind(greet, object, _, '!');
10111 var bind = baseRest(function(func, thisArg, partials) {
10112 var bitmask = WRAP_BIND_FLAG;
10113 if (partials.length) {
10114 var holders = replaceHolders(partials, getHolder(bind));
10115 bitmask |= WRAP_PARTIAL_FLAG;
10117 return createWrap(func, bitmask, thisArg, partials, holders);
10121 * Creates a function that invokes the method at `object[key]` with `partials`
10122 * prepended to the arguments it receives.
10124 * This method differs from `_.bind` by allowing bound functions to reference
10125 * methods that may be redefined or don't yet exist. See
10126 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
10127 * for more details.
10129 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10130 * builds, may be used as a placeholder for partially applied arguments.
10135 * @category Function
10136 * @param {Object} object The object to invoke the method on.
10137 * @param {string} key The key of the method.
10138 * @param {...*} [partials] The arguments to be partially applied.
10139 * @returns {Function} Returns the new bound function.
10144 * 'greet': function(greeting, punctuation) {
10145 * return greeting + ' ' + this.user + punctuation;
10149 * var bound = _.bindKey(object, 'greet', 'hi');
10153 * object.greet = function(greeting, punctuation) {
10154 * return greeting + 'ya ' + this.user + punctuation;
10158 * // => 'hiya fred!'
10160 * // Bound with placeholders.
10161 * var bound = _.bindKey(object, 'greet', _, '!');
10163 * // => 'hiya fred!'
10165 var bindKey = baseRest(function(object, key, partials) {
10166 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
10167 if (partials.length) {
10168 var holders = replaceHolders(partials, getHolder(bindKey));
10169 bitmask |= WRAP_PARTIAL_FLAG;
10171 return createWrap(key, bitmask, object, partials, holders);
10175 * Creates a function that accepts arguments of `func` and either invokes
10176 * `func` returning its result, if at least `arity` number of arguments have
10177 * been provided, or returns a function that accepts the remaining `func`
10178 * arguments, and so on. The arity of `func` may be specified if `func.length`
10179 * is not sufficient.
10181 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10182 * may be used as a placeholder for provided arguments.
10184 * **Note:** This method doesn't set the "length" property of curried functions.
10189 * @category Function
10190 * @param {Function} func The function to curry.
10191 * @param {number} [arity=func.length] The arity of `func`.
10192 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10193 * @returns {Function} Returns the new curried function.
10196 * var abc = function(a, b, c) {
10197 * return [a, b, c];
10200 * var curried = _.curry(abc);
10202 * curried(1)(2)(3);
10205 * curried(1, 2)(3);
10208 * curried(1, 2, 3);
10211 * // Curried with placeholders.
10212 * curried(1)(_, 3)(2);
10215 function curry(func, arity, guard) {
10216 arity = guard ? undefined : arity;
10217 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10218 result.placeholder = curry.placeholder;
10223 * This method is like `_.curry` except that arguments are applied to `func`
10224 * in the manner of `_.partialRight` instead of `_.partial`.
10226 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10227 * builds, may be used as a placeholder for provided arguments.
10229 * **Note:** This method doesn't set the "length" property of curried functions.
10234 * @category Function
10235 * @param {Function} func The function to curry.
10236 * @param {number} [arity=func.length] The arity of `func`.
10237 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10238 * @returns {Function} Returns the new curried function.
10241 * var abc = function(a, b, c) {
10242 * return [a, b, c];
10245 * var curried = _.curryRight(abc);
10247 * curried(3)(2)(1);
10250 * curried(2, 3)(1);
10253 * curried(1, 2, 3);
10256 * // Curried with placeholders.
10257 * curried(3)(1, _)(2);
10260 function curryRight(func, arity, guard) {
10261 arity = guard ? undefined : arity;
10262 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
10263 result.placeholder = curryRight.placeholder;
10268 * Creates a debounced function that delays invoking `func` until after `wait`
10269 * milliseconds have elapsed since the last time the debounced function was
10270 * invoked. The debounced function comes with a `cancel` method to cancel
10271 * delayed `func` invocations and a `flush` method to immediately invoke them.
10272 * Provide `options` to indicate whether `func` should be invoked on the
10273 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
10274 * with the last arguments provided to the debounced function. Subsequent
10275 * calls to the debounced function return the result of the last `func`
10278 * **Note:** If `leading` and `trailing` options are `true`, `func` is
10279 * invoked on the trailing edge of the timeout only if the debounced function
10280 * is invoked more than once during the `wait` timeout.
10282 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10283 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10285 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10286 * for details over the differences between `_.debounce` and `_.throttle`.
10291 * @category Function
10292 * @param {Function} func The function to debounce.
10293 * @param {number} [wait=0] The number of milliseconds to delay.
10294 * @param {Object} [options={}] The options object.
10295 * @param {boolean} [options.leading=false]
10296 * Specify invoking on the leading edge of the timeout.
10297 * @param {number} [options.maxWait]
10298 * The maximum time `func` is allowed to be delayed before it's invoked.
10299 * @param {boolean} [options.trailing=true]
10300 * Specify invoking on the trailing edge of the timeout.
10301 * @returns {Function} Returns the new debounced function.
10304 * // Avoid costly calculations while the window size is in flux.
10305 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10307 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10308 * jQuery(element).on('click', _.debounce(sendMail, 300, {
10310 * 'trailing': false
10313 * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
10314 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
10315 * var source = new EventSource('/stream');
10316 * jQuery(source).on('message', debounced);
10318 * // Cancel the trailing debounced invocation.
10319 * jQuery(window).on('popstate', debounced.cancel);
10321 function debounce(func, wait, options) {
10328 lastInvokeTime = 0,
10333 if (typeof func != 'function') {
10334 throw new TypeError(FUNC_ERROR_TEXT);
10336 wait = toNumber(wait) || 0;
10337 if (isObject(options)) {
10338 leading = !!options.leading;
10339 maxing = 'maxWait' in options;
10340 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
10341 trailing = 'trailing' in options ? !!options.trailing : trailing;
10344 function invokeFunc(time) {
10345 var args = lastArgs,
10346 thisArg = lastThis;
10348 lastArgs = lastThis = undefined;
10349 lastInvokeTime = time;
10350 result = func.apply(thisArg, args);
10354 function leadingEdge(time) {
10355 // Reset any `maxWait` timer.
10356 lastInvokeTime = time;
10357 // Start the timer for the trailing edge.
10358 timerId = setTimeout(timerExpired, wait);
10359 // Invoke the leading edge.
10360 return leading ? invokeFunc(time) : result;
10363 function remainingWait(time) {
10364 var timeSinceLastCall = time - lastCallTime,
10365 timeSinceLastInvoke = time - lastInvokeTime,
10366 result = wait - timeSinceLastCall;
10368 return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
10371 function shouldInvoke(time) {
10372 var timeSinceLastCall = time - lastCallTime,
10373 timeSinceLastInvoke = time - lastInvokeTime;
10375 // Either this is the first call, activity has stopped and we're at the
10376 // trailing edge, the system time has gone backwards and we're treating
10377 // it as the trailing edge, or we've hit the `maxWait` limit.
10378 return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
10379 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
10382 function timerExpired() {
10384 if (shouldInvoke(time)) {
10385 return trailingEdge(time);
10387 // Restart the timer.
10388 timerId = setTimeout(timerExpired, remainingWait(time));
10391 function trailingEdge(time) {
10392 timerId = undefined;
10394 // Only invoke if we have `lastArgs` which means `func` has been
10395 // debounced at least once.
10396 if (trailing && lastArgs) {
10397 return invokeFunc(time);
10399 lastArgs = lastThis = undefined;
10403 function cancel() {
10404 if (timerId !== undefined) {
10405 clearTimeout(timerId);
10407 lastInvokeTime = 0;
10408 lastArgs = lastCallTime = lastThis = timerId = undefined;
10412 return timerId === undefined ? result : trailingEdge(now());
10415 function debounced() {
10417 isInvoking = shouldInvoke(time);
10419 lastArgs = arguments;
10421 lastCallTime = time;
10424 if (timerId === undefined) {
10425 return leadingEdge(lastCallTime);
10428 // Handle invocations in a tight loop.
10429 timerId = setTimeout(timerExpired, wait);
10430 return invokeFunc(lastCallTime);
10433 if (timerId === undefined) {
10434 timerId = setTimeout(timerExpired, wait);
10438 debounced.cancel = cancel;
10439 debounced.flush = flush;
10444 * Defers invoking the `func` until the current call stack has cleared. Any
10445 * additional arguments are provided to `func` when it's invoked.
10450 * @category Function
10451 * @param {Function} func The function to defer.
10452 * @param {...*} [args] The arguments to invoke `func` with.
10453 * @returns {number} Returns the timer id.
10456 * _.defer(function(text) {
10457 * console.log(text);
10459 * // => Logs 'deferred' after one millisecond.
10461 var defer = baseRest(function(func, args) {
10462 return baseDelay(func, 1, args);
10466 * Invokes `func` after `wait` milliseconds. Any additional arguments are
10467 * provided to `func` when it's invoked.
10472 * @category Function
10473 * @param {Function} func The function to delay.
10474 * @param {number} wait The number of milliseconds to delay invocation.
10475 * @param {...*} [args] The arguments to invoke `func` with.
10476 * @returns {number} Returns the timer id.
10479 * _.delay(function(text) {
10480 * console.log(text);
10481 * }, 1000, 'later');
10482 * // => Logs 'later' after one second.
10484 var delay = baseRest(function(func, wait, args) {
10485 return baseDelay(func, toNumber(wait) || 0, args);
10489 * Creates a function that invokes `func` with arguments reversed.
10494 * @category Function
10495 * @param {Function} func The function to flip arguments for.
10496 * @returns {Function} Returns the new flipped function.
10499 * var flipped = _.flip(function() {
10500 * return _.toArray(arguments);
10503 * flipped('a', 'b', 'c', 'd');
10504 * // => ['d', 'c', 'b', 'a']
10506 function flip(func) {
10507 return createWrap(func, WRAP_FLIP_FLAG);
10511 * Creates a function that memoizes the result of `func`. If `resolver` is
10512 * provided, it determines the cache key for storing the result based on the
10513 * arguments provided to the memoized function. By default, the first argument
10514 * provided to the memoized function is used as the map cache key. The `func`
10515 * is invoked with the `this` binding of the memoized function.
10517 * **Note:** The cache is exposed as the `cache` property on the memoized
10518 * function. Its creation may be customized by replacing the `_.memoize.Cache`
10519 * constructor with one whose instances implement the
10520 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
10521 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
10526 * @category Function
10527 * @param {Function} func The function to have its output memoized.
10528 * @param {Function} [resolver] The function to resolve the cache key.
10529 * @returns {Function} Returns the new memoized function.
10532 * var object = { 'a': 1, 'b': 2 };
10533 * var other = { 'c': 3, 'd': 4 };
10535 * var values = _.memoize(_.values);
10546 * // Modify the result cache.
10547 * values.cache.set(object, ['a', 'b']);
10551 * // Replace `_.memoize.Cache`.
10552 * _.memoize.Cache = WeakMap;
10554 function memoize(func, resolver) {
10555 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10556 throw new TypeError(FUNC_ERROR_TEXT);
10558 var memoized = function() {
10559 var args = arguments,
10560 key = resolver ? resolver.apply(this, args) : args[0],
10561 cache = memoized.cache;
10563 if (cache.has(key)) {
10564 return cache.get(key);
10566 var result = func.apply(this, args);
10567 memoized.cache = cache.set(key, result) || cache;
10570 memoized.cache = new (memoize.Cache || MapCache);
10574 // Expose `MapCache`.
10575 memoize.Cache = MapCache;
10578 * Creates a function that negates the result of the predicate `func`. The
10579 * `func` predicate is invoked with the `this` binding and arguments of the
10580 * created function.
10585 * @category Function
10586 * @param {Function} predicate The predicate to negate.
10587 * @returns {Function} Returns the new negated function.
10590 * function isEven(n) {
10591 * return n % 2 == 0;
10594 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10597 function negate(predicate) {
10598 if (typeof predicate != 'function') {
10599 throw new TypeError(FUNC_ERROR_TEXT);
10601 return function() {
10602 var args = arguments;
10603 switch (args.length) {
10604 case 0: return !predicate.call(this);
10605 case 1: return !predicate.call(this, args[0]);
10606 case 2: return !predicate.call(this, args[0], args[1]);
10607 case 3: return !predicate.call(this, args[0], args[1], args[2]);
10609 return !predicate.apply(this, args);
10614 * Creates a function that is restricted to invoking `func` once. Repeat calls
10615 * to the function return the value of the first invocation. The `func` is
10616 * invoked with the `this` binding and arguments of the created function.
10621 * @category Function
10622 * @param {Function} func The function to restrict.
10623 * @returns {Function} Returns the new restricted function.
10626 * var initialize = _.once(createApplication);
10629 * // => `createApplication` is invoked once
10631 function once(func) {
10632 return before(2, func);
10636 * Creates a function that invokes `func` with its arguments transformed.
10641 * @category Function
10642 * @param {Function} func The function to wrap.
10643 * @param {...(Function|Function[])} [transforms=[_.identity]]
10644 * The argument transforms.
10645 * @returns {Function} Returns the new function.
10648 * function doubled(n) {
10652 * function square(n) {
10656 * var func = _.overArgs(function(x, y) {
10658 * }, [square, doubled]);
10666 var overArgs = castRest(function(func, transforms) {
10667 transforms = (transforms.length == 1 && isArray(transforms[0]))
10668 ? arrayMap(transforms[0], baseUnary(getIteratee()))
10669 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
10671 var funcsLength = transforms.length;
10672 return baseRest(function(args) {
10674 length = nativeMin(args.length, funcsLength);
10676 while (++index < length) {
10677 args[index] = transforms[index].call(this, args[index]);
10679 return apply(func, this, args);
10684 * Creates a function that invokes `func` with `partials` prepended to the
10685 * arguments it receives. This method is like `_.bind` except it does **not**
10686 * alter the `this` binding.
10688 * The `_.partial.placeholder` value, which defaults to `_` in monolithic
10689 * builds, may be used as a placeholder for partially applied arguments.
10691 * **Note:** This method doesn't set the "length" property of partially
10692 * applied functions.
10697 * @category Function
10698 * @param {Function} func The function to partially apply arguments to.
10699 * @param {...*} [partials] The arguments to be partially applied.
10700 * @returns {Function} Returns the new partially applied function.
10703 * function greet(greeting, name) {
10704 * return greeting + ' ' + name;
10707 * var sayHelloTo = _.partial(greet, 'hello');
10708 * sayHelloTo('fred');
10709 * // => 'hello fred'
10711 * // Partially applied with placeholders.
10712 * var greetFred = _.partial(greet, _, 'fred');
10716 var partial = baseRest(function(func, partials) {
10717 var holders = replaceHolders(partials, getHolder(partial));
10718 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
10722 * This method is like `_.partial` except that partially applied arguments
10723 * are appended to the arguments it receives.
10725 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
10726 * builds, may be used as a placeholder for partially applied arguments.
10728 * **Note:** This method doesn't set the "length" property of partially
10729 * applied functions.
10734 * @category Function
10735 * @param {Function} func The function to partially apply arguments to.
10736 * @param {...*} [partials] The arguments to be partially applied.
10737 * @returns {Function} Returns the new partially applied function.
10740 * function greet(greeting, name) {
10741 * return greeting + ' ' + name;
10744 * var greetFred = _.partialRight(greet, 'fred');
10748 * // Partially applied with placeholders.
10749 * var sayHelloTo = _.partialRight(greet, 'hello', _);
10750 * sayHelloTo('fred');
10751 * // => 'hello fred'
10753 var partialRight = baseRest(function(func, partials) {
10754 var holders = replaceHolders(partials, getHolder(partialRight));
10755 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
10759 * Creates a function that invokes `func` with arguments arranged according
10760 * to the specified `indexes` where the argument value at the first index is
10761 * provided as the first argument, the argument value at the second index is
10762 * provided as the second argument, and so on.
10767 * @category Function
10768 * @param {Function} func The function to rearrange arguments for.
10769 * @param {...(number|number[])} indexes The arranged argument indexes.
10770 * @returns {Function} Returns the new function.
10773 * var rearged = _.rearg(function(a, b, c) {
10774 * return [a, b, c];
10777 * rearged('b', 'c', 'a')
10778 * // => ['a', 'b', 'c']
10780 var rearg = flatRest(function(func, indexes) {
10781 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
10785 * Creates a function that invokes `func` with the `this` binding of the
10786 * created function and arguments from `start` and beyond provided as
10789 * **Note:** This method is based on the
10790 * [rest parameter](https://mdn.io/rest_parameters).
10795 * @category Function
10796 * @param {Function} func The function to apply a rest parameter to.
10797 * @param {number} [start=func.length-1] The start position of the rest parameter.
10798 * @returns {Function} Returns the new function.
10801 * var say = _.rest(function(what, names) {
10802 * return what + ' ' + _.initial(names).join(', ') +
10803 * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
10806 * say('hello', 'fred', 'barney', 'pebbles');
10807 * // => 'hello fred, barney, & pebbles'
10809 function rest(func, start) {
10810 if (typeof func != 'function') {
10811 throw new TypeError(FUNC_ERROR_TEXT);
10813 start = start === undefined ? start : toInteger(start);
10814 return baseRest(func, start);
10818 * Creates a function that invokes `func` with the `this` binding of the
10819 * create function and an array of arguments much like
10820 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
10822 * **Note:** This method is based on the
10823 * [spread operator](https://mdn.io/spread_operator).
10828 * @category Function
10829 * @param {Function} func The function to spread arguments over.
10830 * @param {number} [start=0] The start position of the spread.
10831 * @returns {Function} Returns the new function.
10834 * var say = _.spread(function(who, what) {
10835 * return who + ' says ' + what;
10838 * say(['fred', 'hello']);
10839 * // => 'fred says hello'
10841 * var numbers = Promise.all([
10842 * Promise.resolve(40),
10843 * Promise.resolve(36)
10846 * numbers.then(_.spread(function(x, y) {
10849 * // => a Promise of 76
10851 function spread(func, start) {
10852 if (typeof func != 'function') {
10853 throw new TypeError(FUNC_ERROR_TEXT);
10855 start = start == null ? 0 : nativeMax(toInteger(start), 0);
10856 return baseRest(function(args) {
10857 var array = args[start],
10858 otherArgs = castSlice(args, 0, start);
10861 arrayPush(otherArgs, array);
10863 return apply(func, this, otherArgs);
10868 * Creates a throttled function that only invokes `func` at most once per
10869 * every `wait` milliseconds. The throttled function comes with a `cancel`
10870 * method to cancel delayed `func` invocations and a `flush` method to
10871 * immediately invoke them. Provide `options` to indicate whether `func`
10872 * should be invoked on the leading and/or trailing edge of the `wait`
10873 * timeout. The `func` is invoked with the last arguments provided to the
10874 * throttled function. Subsequent calls to the throttled function return the
10875 * result of the last `func` invocation.
10877 * **Note:** If `leading` and `trailing` options are `true`, `func` is
10878 * invoked on the trailing edge of the timeout only if the throttled function
10879 * is invoked more than once during the `wait` timeout.
10881 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10882 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10884 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10885 * for details over the differences between `_.throttle` and `_.debounce`.
10890 * @category Function
10891 * @param {Function} func The function to throttle.
10892 * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
10893 * @param {Object} [options={}] The options object.
10894 * @param {boolean} [options.leading=true]
10895 * Specify invoking on the leading edge of the timeout.
10896 * @param {boolean} [options.trailing=true]
10897 * Specify invoking on the trailing edge of the timeout.
10898 * @returns {Function} Returns the new throttled function.
10901 * // Avoid excessively updating the position while scrolling.
10902 * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
10904 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
10905 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
10906 * jQuery(element).on('click', throttled);
10908 * // Cancel the trailing throttled invocation.
10909 * jQuery(window).on('popstate', throttled.cancel);
10911 function throttle(func, wait, options) {
10912 var leading = true,
10915 if (typeof func != 'function') {
10916 throw new TypeError(FUNC_ERROR_TEXT);
10918 if (isObject(options)) {
10919 leading = 'leading' in options ? !!options.leading : leading;
10920 trailing = 'trailing' in options ? !!options.trailing : trailing;
10922 return debounce(func, wait, {
10923 'leading': leading,
10925 'trailing': trailing
10930 * Creates a function that accepts up to one argument, ignoring any
10931 * additional arguments.
10936 * @category Function
10937 * @param {Function} func The function to cap arguments for.
10938 * @returns {Function} Returns the new capped function.
10941 * _.map(['6', '8', '10'], _.unary(parseInt));
10944 function unary(func) {
10945 return ary(func, 1);
10949 * Creates a function that provides `value` to `wrapper` as its first
10950 * argument. Any additional arguments provided to the function are appended
10951 * to those provided to the `wrapper`. The wrapper is invoked with the `this`
10952 * binding of the created function.
10957 * @category Function
10958 * @param {*} value The value to wrap.
10959 * @param {Function} [wrapper=identity] The wrapper function.
10960 * @returns {Function} Returns the new function.
10963 * var p = _.wrap(_.escape, function(func, text) {
10964 * return '<p>' + func(text) + '</p>';
10967 * p('fred, barney, & pebbles');
10968 * // => '<p>fred, barney, & pebbles</p>'
10970 function wrap(value, wrapper) {
10971 return partial(castFunction(wrapper), value);
10974 /*------------------------------------------------------------------------*/
10977 * Casts `value` as an array if it's not one.
10983 * @param {*} value The value to inspect.
10984 * @returns {Array} Returns the cast array.
10990 * _.castArray({ 'a': 1 });
10991 * // => [{ 'a': 1 }]
10993 * _.castArray('abc');
10996 * _.castArray(null);
10999 * _.castArray(undefined);
11000 * // => [undefined]
11005 * var array = [1, 2, 3];
11006 * console.log(_.castArray(array) === array);
11009 function castArray() {
11010 if (!arguments.length) {
11013 var value = arguments[0];
11014 return isArray(value) ? value : [value];
11018 * Creates a shallow clone of `value`.
11020 * **Note:** This method is loosely based on the
11021 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
11022 * and supports cloning arrays, array buffers, booleans, date objects, maps,
11023 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
11024 * arrays. The own enumerable properties of `arguments` objects are cloned
11025 * as plain objects. An empty object is returned for uncloneable values such
11026 * as error objects, functions, DOM nodes, and WeakMaps.
11032 * @param {*} value The value to clone.
11033 * @returns {*} Returns the cloned value.
11037 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11039 * var shallow = _.clone(objects);
11040 * console.log(shallow[0] === objects[0]);
11043 function clone(value) {
11044 return baseClone(value, CLONE_SYMBOLS_FLAG);
11048 * This method is like `_.clone` except that it accepts `customizer` which
11049 * is invoked to produce the cloned value. If `customizer` returns `undefined`,
11050 * cloning is handled by the method instead. The `customizer` is invoked with
11051 * up to four arguments; (value [, index|key, object, stack]).
11057 * @param {*} value The value to clone.
11058 * @param {Function} [customizer] The function to customize cloning.
11059 * @returns {*} Returns the cloned value.
11060 * @see _.cloneDeepWith
11063 * function customizer(value) {
11064 * if (_.isElement(value)) {
11065 * return value.cloneNode(false);
11069 * var el = _.cloneWith(document.body, customizer);
11071 * console.log(el === document.body);
11073 * console.log(el.nodeName);
11075 * console.log(el.childNodes.length);
11078 function cloneWith(value, customizer) {
11079 customizer = typeof customizer == 'function' ? customizer : undefined;
11080 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
11084 * This method is like `_.clone` except that it recursively clones `value`.
11090 * @param {*} value The value to recursively clone.
11091 * @returns {*} Returns the deep cloned value.
11095 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11097 * var deep = _.cloneDeep(objects);
11098 * console.log(deep[0] === objects[0]);
11101 function cloneDeep(value) {
11102 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
11106 * This method is like `_.cloneWith` except that it recursively clones `value`.
11112 * @param {*} value The value to recursively clone.
11113 * @param {Function} [customizer] The function to customize cloning.
11114 * @returns {*} Returns the deep cloned value.
11118 * function customizer(value) {
11119 * if (_.isElement(value)) {
11120 * return value.cloneNode(true);
11124 * var el = _.cloneDeepWith(document.body, customizer);
11126 * console.log(el === document.body);
11128 * console.log(el.nodeName);
11130 * console.log(el.childNodes.length);
11133 function cloneDeepWith(value, customizer) {
11134 customizer = typeof customizer == 'function' ? customizer : undefined;
11135 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
11139 * Checks if `object` conforms to `source` by invoking the predicate
11140 * properties of `source` with the corresponding property values of `object`.
11142 * **Note:** This method is equivalent to `_.conforms` when `source` is
11143 * partially applied.
11149 * @param {Object} object The object to inspect.
11150 * @param {Object} source The object of property predicates to conform to.
11151 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
11154 * var object = { 'a': 1, 'b': 2 };
11156 * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11159 * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11162 function conformsTo(object, source) {
11163 return source == null || baseConformsTo(object, source, keys(source));
11168 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11169 * comparison between two values to determine if they are equivalent.
11175 * @param {*} value The value to compare.
11176 * @param {*} other The other value to compare.
11177 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11180 * var object = { 'a': 1 };
11181 * var other = { 'a': 1 };
11183 * _.eq(object, object);
11186 * _.eq(object, other);
11192 * _.eq('a', Object('a'));
11198 function eq(value, other) {
11199 return value === other || (value !== value && other !== other);
11203 * Checks if `value` is greater than `other`.
11209 * @param {*} value The value to compare.
11210 * @param {*} other The other value to compare.
11211 * @returns {boolean} Returns `true` if `value` is greater than `other`,
11225 var gt = createRelationalOperation(baseGt);
11228 * Checks if `value` is greater than or equal to `other`.
11234 * @param {*} value The value to compare.
11235 * @param {*} other The other value to compare.
11236 * @returns {boolean} Returns `true` if `value` is greater than or equal to
11237 * `other`, else `false`.
11250 var gte = createRelationalOperation(function(value, other) {
11251 return value >= other;
11255 * Checks if `value` is likely an `arguments` object.
11261 * @param {*} value The value to check.
11262 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11266 * _.isArguments(function() { return arguments; }());
11269 * _.isArguments([1, 2, 3]);
11272 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11273 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11274 !propertyIsEnumerable.call(value, 'callee');
11278 * Checks if `value` is classified as an `Array` object.
11284 * @param {*} value The value to check.
11285 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11288 * _.isArray([1, 2, 3]);
11291 * _.isArray(document.body.children);
11294 * _.isArray('abc');
11297 * _.isArray(_.noop);
11300 var isArray = Array.isArray;
11303 * Checks if `value` is classified as an `ArrayBuffer` object.
11309 * @param {*} value The value to check.
11310 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11313 * _.isArrayBuffer(new ArrayBuffer(2));
11316 * _.isArrayBuffer(new Array(2));
11319 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
11322 * Checks if `value` is array-like. A value is considered array-like if it's
11323 * not a function and has a `value.length` that's an integer greater than or
11324 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
11330 * @param {*} value The value to check.
11331 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11334 * _.isArrayLike([1, 2, 3]);
11337 * _.isArrayLike(document.body.children);
11340 * _.isArrayLike('abc');
11343 * _.isArrayLike(_.noop);
11346 function isArrayLike(value) {
11347 return value != null && isLength(value.length) && !isFunction(value);
11351 * This method is like `_.isArrayLike` except that it also checks if `value`
11358 * @param {*} value The value to check.
11359 * @returns {boolean} Returns `true` if `value` is an array-like object,
11363 * _.isArrayLikeObject([1, 2, 3]);
11366 * _.isArrayLikeObject(document.body.children);
11369 * _.isArrayLikeObject('abc');
11372 * _.isArrayLikeObject(_.noop);
11375 function isArrayLikeObject(value) {
11376 return isObjectLike(value) && isArrayLike(value);
11380 * Checks if `value` is classified as a boolean primitive or object.
11386 * @param {*} value The value to check.
11387 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11390 * _.isBoolean(false);
11393 * _.isBoolean(null);
11396 function isBoolean(value) {
11397 return value === true || value === false ||
11398 (isObjectLike(value) && baseGetTag(value) == boolTag);
11402 * Checks if `value` is a buffer.
11408 * @param {*} value The value to check.
11409 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11412 * _.isBuffer(new Buffer(2));
11415 * _.isBuffer(new Uint8Array(2));
11418 var isBuffer = nativeIsBuffer || stubFalse;
11421 * Checks if `value` is classified as a `Date` object.
11427 * @param {*} value The value to check.
11428 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11431 * _.isDate(new Date);
11434 * _.isDate('Mon April 23 2012');
11437 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11440 * Checks if `value` is likely a DOM element.
11446 * @param {*} value The value to check.
11447 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11450 * _.isElement(document.body);
11453 * _.isElement('<body>');
11456 function isElement(value) {
11457 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11461 * Checks if `value` is an empty object, collection, map, or set.
11463 * Objects are considered empty if they have no own enumerable string keyed
11466 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
11467 * jQuery-like collections are considered empty if they have a `length` of `0`.
11468 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
11474 * @param {*} value The value to check.
11475 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11487 * _.isEmpty([1, 2, 3]);
11490 * _.isEmpty({ 'a': 1 });
11493 function isEmpty(value) {
11494 if (value == null) {
11497 if (isArrayLike(value) &&
11498 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
11499 isBuffer(value) || isTypedArray(value) || isArguments(value))) {
11500 return !value.length;
11502 var tag = getTag(value);
11503 if (tag == mapTag || tag == setTag) {
11504 return !value.size;
11506 if (isPrototype(value)) {
11507 return !baseKeys(value).length;
11509 for (var key in value) {
11510 if (hasOwnProperty.call(value, key)) {
11518 * Performs a deep comparison between two values to determine if they are
11521 * **Note:** This method supports comparing arrays, array buffers, booleans,
11522 * date objects, error objects, maps, numbers, `Object` objects, regexes,
11523 * sets, strings, symbols, and typed arrays. `Object` objects are compared
11524 * by their own, not inherited, enumerable properties. Functions and DOM
11525 * nodes are compared by strict equality, i.e. `===`.
11531 * @param {*} value The value to compare.
11532 * @param {*} other The other value to compare.
11533 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11536 * var object = { 'a': 1 };
11537 * var other = { 'a': 1 };
11539 * _.isEqual(object, other);
11542 * object === other;
11545 function isEqual(value, other) {
11546 return baseIsEqual(value, other);
11550 * This method is like `_.isEqual` except that it accepts `customizer` which
11551 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11552 * are handled by the method instead. The `customizer` is invoked with up to
11553 * six arguments: (objValue, othValue [, index|key, object, other, stack]).
11559 * @param {*} value The value to compare.
11560 * @param {*} other The other value to compare.
11561 * @param {Function} [customizer] The function to customize comparisons.
11562 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11565 * function isGreeting(value) {
11566 * return /^h(?:i|ello)$/.test(value);
11569 * function customizer(objValue, othValue) {
11570 * if (isGreeting(objValue) && isGreeting(othValue)) {
11575 * var array = ['hello', 'goodbye'];
11576 * var other = ['hi', 'goodbye'];
11578 * _.isEqualWith(array, other, customizer);
11581 function isEqualWith(value, other, customizer) {
11582 customizer = typeof customizer == 'function' ? customizer : undefined;
11583 var result = customizer ? customizer(value, other) : undefined;
11584 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
11588 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11589 * `SyntaxError`, `TypeError`, or `URIError` object.
11595 * @param {*} value The value to check.
11596 * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11599 * _.isError(new Error);
11602 * _.isError(Error);
11605 function isError(value) {
11606 if (!isObjectLike(value)) {
11609 var tag = baseGetTag(value);
11610 return tag == errorTag || tag == domExcTag ||
11611 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11615 * Checks if `value` is a finite primitive number.
11617 * **Note:** This method is based on
11618 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11624 * @param {*} value The value to check.
11625 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11631 * _.isFinite(Number.MIN_VALUE);
11634 * _.isFinite(Infinity);
11640 function isFinite(value) {
11641 return typeof value == 'number' && nativeIsFinite(value);
11645 * Checks if `value` is classified as a `Function` object.
11651 * @param {*} value The value to check.
11652 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11658 * _.isFunction(/abc/);
11661 function isFunction(value) {
11662 if (!isObject(value)) {
11665 // The use of `Object#toString` avoids issues with the `typeof` operator
11666 // in Safari 9 which returns 'object' for typed arrays and other constructors.
11667 var tag = baseGetTag(value);
11668 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11672 * Checks if `value` is an integer.
11674 * **Note:** This method is based on
11675 * [`Number.isInteger`](https://mdn.io/Number/isInteger).
11681 * @param {*} value The value to check.
11682 * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
11688 * _.isInteger(Number.MIN_VALUE);
11691 * _.isInteger(Infinity);
11694 * _.isInteger('3');
11697 function isInteger(value) {
11698 return typeof value == 'number' && value == toInteger(value);
11702 * Checks if `value` is a valid array-like length.
11704 * **Note:** This method is loosely based on
11705 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
11711 * @param {*} value The value to check.
11712 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11718 * _.isLength(Number.MIN_VALUE);
11721 * _.isLength(Infinity);
11727 function isLength(value) {
11728 return typeof value == 'number' &&
11729 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
11733 * Checks if `value` is the
11734 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11735 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11741 * @param {*} value The value to check.
11742 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11748 * _.isObject([1, 2, 3]);
11751 * _.isObject(_.noop);
11754 * _.isObject(null);
11757 function isObject(value) {
11758 var type = typeof value;
11759 return value != null && (type == 'object' || type == 'function');
11763 * Checks if `value` is object-like. A value is object-like if it's not `null`
11764 * and has a `typeof` result of "object".
11770 * @param {*} value The value to check.
11771 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11774 * _.isObjectLike({});
11777 * _.isObjectLike([1, 2, 3]);
11780 * _.isObjectLike(_.noop);
11783 * _.isObjectLike(null);
11786 function isObjectLike(value) {
11787 return value != null && typeof value == 'object';
11791 * Checks if `value` is classified as a `Map` object.
11797 * @param {*} value The value to check.
11798 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
11801 * _.isMap(new Map);
11804 * _.isMap(new WeakMap);
11807 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
11810 * Performs a partial deep comparison between `object` and `source` to
11811 * determine if `object` contains equivalent property values.
11813 * **Note:** This method is equivalent to `_.matches` when `source` is
11814 * partially applied.
11816 * Partial comparisons will match empty array and empty object `source`
11817 * values against any array or object value, respectively. See `_.isEqual`
11818 * for a list of supported value comparisons.
11824 * @param {Object} object The object to inspect.
11825 * @param {Object} source The object of property values to match.
11826 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11829 * var object = { 'a': 1, 'b': 2 };
11831 * _.isMatch(object, { 'b': 2 });
11834 * _.isMatch(object, { 'b': 1 });
11837 function isMatch(object, source) {
11838 return object === source || baseIsMatch(object, source, getMatchData(source));
11842 * This method is like `_.isMatch` except that it accepts `customizer` which
11843 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11844 * are handled by the method instead. The `customizer` is invoked with five
11845 * arguments: (objValue, srcValue, index|key, object, source).
11851 * @param {Object} object The object to inspect.
11852 * @param {Object} source The object of property values to match.
11853 * @param {Function} [customizer] The function to customize comparisons.
11854 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11857 * function isGreeting(value) {
11858 * return /^h(?:i|ello)$/.test(value);
11861 * function customizer(objValue, srcValue) {
11862 * if (isGreeting(objValue) && isGreeting(srcValue)) {
11867 * var object = { 'greeting': 'hello' };
11868 * var source = { 'greeting': 'hi' };
11870 * _.isMatchWith(object, source, customizer);
11873 function isMatchWith(object, source, customizer) {
11874 customizer = typeof customizer == 'function' ? customizer : undefined;
11875 return baseIsMatch(object, source, getMatchData(source), customizer);
11879 * Checks if `value` is `NaN`.
11881 * **Note:** This method is based on
11882 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
11883 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
11884 * `undefined` and other non-number values.
11890 * @param {*} value The value to check.
11891 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
11897 * _.isNaN(new Number(NaN));
11900 * isNaN(undefined);
11903 * _.isNaN(undefined);
11906 function isNaN(value) {
11907 // An `NaN` primitive is the only value that is not equal to itself.
11908 // Perform the `toStringTag` check first to avoid errors with some
11909 // ActiveX objects in IE.
11910 return isNumber(value) && value != +value;
11914 * Checks if `value` is a pristine native function.
11916 * **Note:** This method can't reliably detect native functions in the presence
11917 * of the core-js package because core-js circumvents this kind of detection.
11918 * Despite multiple requests, the core-js maintainer has made it clear: any
11919 * attempt to fix the detection will be obstructed. As a result, we're left
11920 * with little choice but to throw an error. Unfortunately, this also affects
11921 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
11922 * which rely on core-js.
11928 * @param {*} value The value to check.
11929 * @returns {boolean} Returns `true` if `value` is a native function,
11933 * _.isNative(Array.prototype.push);
11939 function isNative(value) {
11940 if (isMaskable(value)) {
11941 throw new Error(CORE_ERROR_TEXT);
11943 return baseIsNative(value);
11947 * Checks if `value` is `null`.
11953 * @param {*} value The value to check.
11954 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
11960 * _.isNull(void 0);
11963 function isNull(value) {
11964 return value === null;
11968 * Checks if `value` is `null` or `undefined`.
11974 * @param {*} value The value to check.
11975 * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
11987 function isNil(value) {
11988 return value == null;
11992 * Checks if `value` is classified as a `Number` primitive or object.
11994 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
11995 * classified as numbers, use the `_.isFinite` method.
12001 * @param {*} value The value to check.
12002 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
12008 * _.isNumber(Number.MIN_VALUE);
12011 * _.isNumber(Infinity);
12017 function isNumber(value) {
12018 return typeof value == 'number' ||
12019 (isObjectLike(value) && baseGetTag(value) == numberTag);
12023 * Checks if `value` is a plain object, that is, an object created by the
12024 * `Object` constructor or one with a `[[Prototype]]` of `null`.
12030 * @param {*} value The value to check.
12031 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
12038 * _.isPlainObject(new Foo);
12041 * _.isPlainObject([1, 2, 3]);
12044 * _.isPlainObject({ 'x': 0, 'y': 0 });
12047 * _.isPlainObject(Object.create(null));
12050 function isPlainObject(value) {
12051 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12054 var proto = getPrototype(value);
12055 if (proto === null) {
12058 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12059 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12060 funcToString.call(Ctor) == objectCtorString;
12064 * Checks if `value` is classified as a `RegExp` object.
12070 * @param {*} value The value to check.
12071 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12074 * _.isRegExp(/abc/);
12077 * _.isRegExp('/abc/');
12080 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
12083 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
12084 * double precision number which isn't the result of a rounded unsafe integer.
12086 * **Note:** This method is based on
12087 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12093 * @param {*} value The value to check.
12094 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12097 * _.isSafeInteger(3);
12100 * _.isSafeInteger(Number.MIN_VALUE);
12103 * _.isSafeInteger(Infinity);
12106 * _.isSafeInteger('3');
12109 function isSafeInteger(value) {
12110 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12114 * Checks if `value` is classified as a `Set` object.
12120 * @param {*} value The value to check.
12121 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12124 * _.isSet(new Set);
12127 * _.isSet(new WeakSet);
12130 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12133 * Checks if `value` is classified as a `String` primitive or object.
12139 * @param {*} value The value to check.
12140 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12143 * _.isString('abc');
12149 function isString(value) {
12150 return typeof value == 'string' ||
12151 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12155 * Checks if `value` is classified as a `Symbol` primitive or object.
12161 * @param {*} value The value to check.
12162 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12165 * _.isSymbol(Symbol.iterator);
12168 * _.isSymbol('abc');
12171 function isSymbol(value) {
12172 return typeof value == 'symbol' ||
12173 (isObjectLike(value) && baseGetTag(value) == symbolTag);
12177 * Checks if `value` is classified as a typed array.
12183 * @param {*} value The value to check.
12184 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12187 * _.isTypedArray(new Uint8Array);
12190 * _.isTypedArray([]);
12193 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12196 * Checks if `value` is `undefined`.
12202 * @param {*} value The value to check.
12203 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12206 * _.isUndefined(void 0);
12209 * _.isUndefined(null);
12212 function isUndefined(value) {
12213 return value === undefined;
12217 * Checks if `value` is classified as a `WeakMap` object.
12223 * @param {*} value The value to check.
12224 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12227 * _.isWeakMap(new WeakMap);
12230 * _.isWeakMap(new Map);
12233 function isWeakMap(value) {
12234 return isObjectLike(value) && getTag(value) == weakMapTag;
12238 * Checks if `value` is classified as a `WeakSet` object.
12244 * @param {*} value The value to check.
12245 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12248 * _.isWeakSet(new WeakSet);
12251 * _.isWeakSet(new Set);
12254 function isWeakSet(value) {
12255 return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12259 * Checks if `value` is less than `other`.
12265 * @param {*} value The value to compare.
12266 * @param {*} other The other value to compare.
12267 * @returns {boolean} Returns `true` if `value` is less than `other`,
12281 var lt = createRelationalOperation(baseLt);
12284 * Checks if `value` is less than or equal to `other`.
12290 * @param {*} value The value to compare.
12291 * @param {*} other The other value to compare.
12292 * @returns {boolean} Returns `true` if `value` is less than or equal to
12293 * `other`, else `false`.
12306 var lte = createRelationalOperation(function(value, other) {
12307 return value <= other;
12311 * Converts `value` to an array.
12317 * @param {*} value The value to convert.
12318 * @returns {Array} Returns the converted array.
12321 * _.toArray({ 'a': 1, 'b': 2 });
12324 * _.toArray('abc');
12325 * // => ['a', 'b', 'c']
12333 function toArray(value) {
12337 if (isArrayLike(value)) {
12338 return isString(value) ? stringToArray(value) : copyArray(value);
12340 if (symIterator && value[symIterator]) {
12341 return iteratorToArray(value[symIterator]());
12343 var tag = getTag(value),
12344 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12346 return func(value);
12350 * Converts `value` to a finite number.
12356 * @param {*} value The value to convert.
12357 * @returns {number} Returns the converted number.
12363 * _.toFinite(Number.MIN_VALUE);
12366 * _.toFinite(Infinity);
12367 * // => 1.7976931348623157e+308
12369 * _.toFinite('3.2');
12372 function toFinite(value) {
12374 return value === 0 ? value : 0;
12376 value = toNumber(value);
12377 if (value === INFINITY || value === -INFINITY) {
12378 var sign = (value < 0 ? -1 : 1);
12379 return sign * MAX_INTEGER;
12381 return value === value ? value : 0;
12385 * Converts `value` to an integer.
12387 * **Note:** This method is loosely based on
12388 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12394 * @param {*} value The value to convert.
12395 * @returns {number} Returns the converted integer.
12398 * _.toInteger(3.2);
12401 * _.toInteger(Number.MIN_VALUE);
12404 * _.toInteger(Infinity);
12405 * // => 1.7976931348623157e+308
12407 * _.toInteger('3.2');
12410 function toInteger(value) {
12411 var result = toFinite(value),
12412 remainder = result % 1;
12414 return result === result ? (remainder ? result - remainder : result) : 0;
12418 * Converts `value` to an integer suitable for use as the length of an
12419 * array-like object.
12421 * **Note:** This method is based on
12422 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12428 * @param {*} value The value to convert.
12429 * @returns {number} Returns the converted integer.
12435 * _.toLength(Number.MIN_VALUE);
12438 * _.toLength(Infinity);
12441 * _.toLength('3.2');
12444 function toLength(value) {
12445 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12449 * Converts `value` to a number.
12455 * @param {*} value The value to process.
12456 * @returns {number} Returns the number.
12462 * _.toNumber(Number.MIN_VALUE);
12465 * _.toNumber(Infinity);
12468 * _.toNumber('3.2');
12471 function toNumber(value) {
12472 if (typeof value == 'number') {
12475 if (isSymbol(value)) {
12478 if (isObject(value)) {
12479 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12480 value = isObject(other) ? (other + '') : other;
12482 if (typeof value != 'string') {
12483 return value === 0 ? value : +value;
12485 value = value.replace(reTrim, '');
12486 var isBinary = reIsBinary.test(value);
12487 return (isBinary || reIsOctal.test(value))
12488 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
12489 : (reIsBadHex.test(value) ? NAN : +value);
12493 * Converts `value` to a plain object flattening inherited enumerable string
12494 * keyed properties of `value` to own properties of the plain object.
12500 * @param {*} value The value to convert.
12501 * @returns {Object} Returns the converted plain object.
12508 * Foo.prototype.c = 3;
12510 * _.assign({ 'a': 1 }, new Foo);
12511 * // => { 'a': 1, 'b': 2 }
12513 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12514 * // => { 'a': 1, 'b': 2, 'c': 3 }
12516 function toPlainObject(value) {
12517 return copyObject(value, keysIn(value));
12521 * Converts `value` to a safe integer. A safe integer can be compared and
12522 * represented correctly.
12528 * @param {*} value The value to convert.
12529 * @returns {number} Returns the converted integer.
12532 * _.toSafeInteger(3.2);
12535 * _.toSafeInteger(Number.MIN_VALUE);
12538 * _.toSafeInteger(Infinity);
12539 * // => 9007199254740991
12541 * _.toSafeInteger('3.2');
12544 function toSafeInteger(value) {
12546 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
12547 : (value === 0 ? value : 0);
12551 * Converts `value` to a string. An empty string is returned for `null`
12552 * and `undefined` values. The sign of `-0` is preserved.
12558 * @param {*} value The value to convert.
12559 * @returns {string} Returns the converted string.
12562 * _.toString(null);
12568 * _.toString([1, 2, 3]);
12571 function toString(value) {
12572 return value == null ? '' : baseToString(value);
12575 /*------------------------------------------------------------------------*/
12578 * Assigns own enumerable string keyed properties of source objects to the
12579 * destination object. Source objects are applied from left to right.
12580 * Subsequent sources overwrite property assignments of previous sources.
12582 * **Note:** This method mutates `object` and is loosely based on
12583 * [`Object.assign`](https://mdn.io/Object/assign).
12589 * @param {Object} object The destination object.
12590 * @param {...Object} [sources] The source objects.
12591 * @returns {Object} Returns `object`.
12603 * Foo.prototype.b = 2;
12604 * Bar.prototype.d = 4;
12606 * _.assign({ 'a': 0 }, new Foo, new Bar);
12607 * // => { 'a': 1, 'c': 3 }
12609 var assign = createAssigner(function(object, source) {
12610 if (isPrototype(source) || isArrayLike(source)) {
12611 copyObject(source, keys(source), object);
12614 for (var key in source) {
12615 if (hasOwnProperty.call(source, key)) {
12616 assignValue(object, key, source[key]);
12622 * This method is like `_.assign` except that it iterates over own and
12623 * inherited source properties.
12625 * **Note:** This method mutates `object`.
12632 * @param {Object} object The destination object.
12633 * @param {...Object} [sources] The source objects.
12634 * @returns {Object} Returns `object`.
12646 * Foo.prototype.b = 2;
12647 * Bar.prototype.d = 4;
12649 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12650 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12652 var assignIn = createAssigner(function(object, source) {
12653 copyObject(source, keysIn(source), object);
12657 * This method is like `_.assignIn` except that it accepts `customizer`
12658 * which is invoked to produce the assigned values. If `customizer` returns
12659 * `undefined`, assignment is handled by the method instead. The `customizer`
12660 * is invoked with five arguments: (objValue, srcValue, key, object, source).
12662 * **Note:** This method mutates `object`.
12667 * @alias extendWith
12669 * @param {Object} object The destination object.
12670 * @param {...Object} sources The source objects.
12671 * @param {Function} [customizer] The function to customize assigned values.
12672 * @returns {Object} Returns `object`.
12673 * @see _.assignWith
12676 * function customizer(objValue, srcValue) {
12677 * return _.isUndefined(objValue) ? srcValue : objValue;
12680 * var defaults = _.partialRight(_.assignInWith, customizer);
12682 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12683 * // => { 'a': 1, 'b': 2 }
12685 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
12686 copyObject(source, keysIn(source), object, customizer);
12690 * This method is like `_.assign` except that it accepts `customizer`
12691 * which is invoked to produce the assigned values. If `customizer` returns
12692 * `undefined`, assignment is handled by the method instead. The `customizer`
12693 * is invoked with five arguments: (objValue, srcValue, key, object, source).
12695 * **Note:** This method mutates `object`.
12701 * @param {Object} object The destination object.
12702 * @param {...Object} sources The source objects.
12703 * @param {Function} [customizer] The function to customize assigned values.
12704 * @returns {Object} Returns `object`.
12705 * @see _.assignInWith
12708 * function customizer(objValue, srcValue) {
12709 * return _.isUndefined(objValue) ? srcValue : objValue;
12712 * var defaults = _.partialRight(_.assignWith, customizer);
12714 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12715 * // => { 'a': 1, 'b': 2 }
12717 var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
12718 copyObject(source, keys(source), object, customizer);
12722 * Creates an array of values corresponding to `paths` of `object`.
12728 * @param {Object} object The object to iterate over.
12729 * @param {...(string|string[])} [paths] The property paths to pick.
12730 * @returns {Array} Returns the picked values.
12733 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
12735 * _.at(object, ['a[0].b.c', 'a[1]']);
12738 var at = flatRest(baseAt);
12741 * Creates an object that inherits from the `prototype` object. If a
12742 * `properties` object is given, its own enumerable string keyed properties
12743 * are assigned to the created object.
12749 * @param {Object} prototype The object to inherit from.
12750 * @param {Object} [properties] The properties to assign to the object.
12751 * @returns {Object} Returns the new object.
12754 * function Shape() {
12759 * function Circle() {
12760 * Shape.call(this);
12763 * Circle.prototype = _.create(Shape.prototype, {
12764 * 'constructor': Circle
12767 * var circle = new Circle;
12768 * circle instanceof Circle;
12771 * circle instanceof Shape;
12774 function create(prototype, properties) {
12775 var result = baseCreate(prototype);
12776 return properties == null ? result : baseAssign(result, properties);
12780 * Assigns own and inherited enumerable string keyed properties of source
12781 * objects to the destination object for all destination properties that
12782 * resolve to `undefined`. Source objects are applied from left to right.
12783 * Once a property is set, additional values of the same property are ignored.
12785 * **Note:** This method mutates `object`.
12791 * @param {Object} object The destination object.
12792 * @param {...Object} [sources] The source objects.
12793 * @returns {Object} Returns `object`.
12794 * @see _.defaultsDeep
12797 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12798 * // => { 'a': 1, 'b': 2 }
12800 var defaults = baseRest(function(args) {
12801 args.push(undefined, customDefaultsAssignIn);
12802 return apply(assignInWith, undefined, args);
12806 * This method is like `_.defaults` except that it recursively assigns
12807 * default properties.
12809 * **Note:** This method mutates `object`.
12815 * @param {Object} object The destination object.
12816 * @param {...Object} [sources] The source objects.
12817 * @returns {Object} Returns `object`.
12821 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
12822 * // => { 'a': { 'b': 2, 'c': 3 } }
12824 var defaultsDeep = baseRest(function(args) {
12825 args.push(undefined, customDefaultsMerge);
12826 return apply(mergeWith, undefined, args);
12830 * This method is like `_.find` except that it returns the key of the first
12831 * element `predicate` returns truthy for instead of the element itself.
12837 * @param {Object} object The object to inspect.
12838 * @param {Function} [predicate=_.identity] The function invoked per iteration.
12839 * @returns {string|undefined} Returns the key of the matched element,
12840 * else `undefined`.
12844 * 'barney': { 'age': 36, 'active': true },
12845 * 'fred': { 'age': 40, 'active': false },
12846 * 'pebbles': { 'age': 1, 'active': true }
12849 * _.findKey(users, function(o) { return o.age < 40; });
12850 * // => 'barney' (iteration order is not guaranteed)
12852 * // The `_.matches` iteratee shorthand.
12853 * _.findKey(users, { 'age': 1, 'active': true });
12856 * // The `_.matchesProperty` iteratee shorthand.
12857 * _.findKey(users, ['active', false]);
12860 * // The `_.property` iteratee shorthand.
12861 * _.findKey(users, 'active');
12864 function findKey(object, predicate) {
12865 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
12869 * This method is like `_.findKey` except that it iterates over elements of
12870 * a collection in the opposite order.
12876 * @param {Object} object The object to inspect.
12877 * @param {Function} [predicate=_.identity] The function invoked per iteration.
12878 * @returns {string|undefined} Returns the key of the matched element,
12879 * else `undefined`.
12883 * 'barney': { 'age': 36, 'active': true },
12884 * 'fred': { 'age': 40, 'active': false },
12885 * 'pebbles': { 'age': 1, 'active': true }
12888 * _.findLastKey(users, function(o) { return o.age < 40; });
12889 * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
12891 * // The `_.matches` iteratee shorthand.
12892 * _.findLastKey(users, { 'age': 36, 'active': true });
12895 * // The `_.matchesProperty` iteratee shorthand.
12896 * _.findLastKey(users, ['active', false]);
12899 * // The `_.property` iteratee shorthand.
12900 * _.findLastKey(users, 'active');
12903 function findLastKey(object, predicate) {
12904 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
12908 * Iterates over own and inherited enumerable string keyed properties of an
12909 * object and invokes `iteratee` for each property. The iteratee is invoked
12910 * with three arguments: (value, key, object). Iteratee functions may exit
12911 * iteration early by explicitly returning `false`.
12917 * @param {Object} object The object to iterate over.
12918 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12919 * @returns {Object} Returns `object`.
12920 * @see _.forInRight
12928 * Foo.prototype.c = 3;
12930 * _.forIn(new Foo, function(value, key) {
12931 * console.log(key);
12933 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
12935 function forIn(object, iteratee) {
12936 return object == null
12938 : baseFor(object, getIteratee(iteratee, 3), keysIn);
12942 * This method is like `_.forIn` except that it iterates over properties of
12943 * `object` in the opposite order.
12949 * @param {Object} object The object to iterate over.
12950 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12951 * @returns {Object} Returns `object`.
12960 * Foo.prototype.c = 3;
12962 * _.forInRight(new Foo, function(value, key) {
12963 * console.log(key);
12965 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
12967 function forInRight(object, iteratee) {
12968 return object == null
12970 : baseForRight(object, getIteratee(iteratee, 3), keysIn);
12974 * Iterates over own enumerable string keyed properties of an object and
12975 * invokes `iteratee` for each property. The iteratee is invoked with three
12976 * arguments: (value, key, object). Iteratee functions may exit iteration
12977 * early by explicitly returning `false`.
12983 * @param {Object} object The object to iterate over.
12984 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12985 * @returns {Object} Returns `object`.
12986 * @see _.forOwnRight
12994 * Foo.prototype.c = 3;
12996 * _.forOwn(new Foo, function(value, key) {
12997 * console.log(key);
12999 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
13001 function forOwn(object, iteratee) {
13002 return object && baseForOwn(object, getIteratee(iteratee, 3));
13006 * This method is like `_.forOwn` except that it iterates over properties of
13007 * `object` in the opposite order.
13013 * @param {Object} object The object to iterate over.
13014 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13015 * @returns {Object} Returns `object`.
13024 * Foo.prototype.c = 3;
13026 * _.forOwnRight(new Foo, function(value, key) {
13027 * console.log(key);
13029 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
13031 function forOwnRight(object, iteratee) {
13032 return object && baseForOwnRight(object, getIteratee(iteratee, 3));
13036 * Creates an array of function property names from own enumerable properties
13043 * @param {Object} object The object to inspect.
13044 * @returns {Array} Returns the function names.
13045 * @see _.functionsIn
13049 * this.a = _.constant('a');
13050 * this.b = _.constant('b');
13053 * Foo.prototype.c = _.constant('c');
13055 * _.functions(new Foo);
13058 function functions(object) {
13059 return object == null ? [] : baseFunctions(object, keys(object));
13063 * Creates an array of function property names from own and inherited
13064 * enumerable properties of `object`.
13070 * @param {Object} object The object to inspect.
13071 * @returns {Array} Returns the function names.
13076 * this.a = _.constant('a');
13077 * this.b = _.constant('b');
13080 * Foo.prototype.c = _.constant('c');
13082 * _.functionsIn(new Foo);
13083 * // => ['a', 'b', 'c']
13085 function functionsIn(object) {
13086 return object == null ? [] : baseFunctions(object, keysIn(object));
13090 * Gets the value at `path` of `object`. If the resolved value is
13091 * `undefined`, the `defaultValue` is returned in its place.
13097 * @param {Object} object The object to query.
13098 * @param {Array|string} path The path of the property to get.
13099 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13100 * @returns {*} Returns the resolved value.
13103 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13105 * _.get(object, 'a[0].b.c');
13108 * _.get(object, ['a', '0', 'b', 'c']);
13111 * _.get(object, 'a.b.c', 'default');
13114 function get(object, path, defaultValue) {
13115 var result = object == null ? undefined : baseGet(object, path);
13116 return result === undefined ? defaultValue : result;
13120 * Checks if `path` is a direct property of `object`.
13126 * @param {Object} object The object to query.
13127 * @param {Array|string} path The path to check.
13128 * @returns {boolean} Returns `true` if `path` exists, else `false`.
13131 * var object = { 'a': { 'b': 2 } };
13132 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13134 * _.has(object, 'a');
13137 * _.has(object, 'a.b');
13140 * _.has(object, ['a', 'b']);
13143 * _.has(other, 'a');
13146 function has(object, path) {
13147 return object != null && hasPath(object, path, baseHas);
13151 * Checks if `path` is a direct or inherited property of `object`.
13157 * @param {Object} object The object to query.
13158 * @param {Array|string} path The path to check.
13159 * @returns {boolean} Returns `true` if `path` exists, else `false`.
13162 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13164 * _.hasIn(object, 'a');
13167 * _.hasIn(object, 'a.b');
13170 * _.hasIn(object, ['a', 'b']);
13173 * _.hasIn(object, 'b');
13176 function hasIn(object, path) {
13177 return object != null && hasPath(object, path, baseHasIn);
13181 * Creates an object composed of the inverted keys and values of `object`.
13182 * If `object` contains duplicate values, subsequent values overwrite
13183 * property assignments of previous values.
13189 * @param {Object} object The object to invert.
13190 * @returns {Object} Returns the new inverted object.
13193 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13195 * _.invert(object);
13196 * // => { '1': 'c', '2': 'b' }
13198 var invert = createInverter(function(result, value, key) {
13199 result[value] = key;
13200 }, constant(identity));
13203 * This method is like `_.invert` except that the inverted object is generated
13204 * from the results of running each element of `object` thru `iteratee`. The
13205 * corresponding inverted value of each inverted key is an array of keys
13206 * responsible for generating the inverted value. The iteratee is invoked
13207 * with one argument: (value).
13213 * @param {Object} object The object to invert.
13214 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
13215 * @returns {Object} Returns the new inverted object.
13218 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13220 * _.invertBy(object);
13221 * // => { '1': ['a', 'c'], '2': ['b'] }
13223 * _.invertBy(object, function(value) {
13224 * return 'group' + value;
13226 * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13228 var invertBy = createInverter(function(result, value, key) {
13229 if (hasOwnProperty.call(result, value)) {
13230 result[value].push(key);
13232 result[value] = [key];
13237 * Invokes the method at `path` of `object`.
13243 * @param {Object} object The object to query.
13244 * @param {Array|string} path The path of the method to invoke.
13245 * @param {...*} [args] The arguments to invoke the method with.
13246 * @returns {*} Returns the result of the invoked method.
13249 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13251 * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13254 var invoke = baseRest(baseInvoke);
13257 * Creates an array of the own enumerable property names of `object`.
13259 * **Note:** Non-object values are coerced to objects. See the
13260 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
13261 * for more details.
13267 * @param {Object} object The object to query.
13268 * @returns {Array} Returns the array of property names.
13276 * Foo.prototype.c = 3;
13279 * // => ['a', 'b'] (iteration order is not guaranteed)
13284 function keys(object) {
13285 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13289 * Creates an array of the own and inherited enumerable property names of `object`.
13291 * **Note:** Non-object values are coerced to objects.
13297 * @param {Object} object The object to query.
13298 * @returns {Array} Returns the array of property names.
13306 * Foo.prototype.c = 3;
13308 * _.keysIn(new Foo);
13309 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13311 function keysIn(object) {
13312 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
13316 * The opposite of `_.mapValues`; this method creates an object with the
13317 * same values as `object` and keys generated by running each own enumerable
13318 * string keyed property of `object` thru `iteratee`. The iteratee is invoked
13319 * with three arguments: (value, key, object).
13325 * @param {Object} object The object to iterate over.
13326 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13327 * @returns {Object} Returns the new mapped object.
13331 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13332 * return key + value;
13334 * // => { 'a1': 1, 'b2': 2 }
13336 function mapKeys(object, iteratee) {
13338 iteratee = getIteratee(iteratee, 3);
13340 baseForOwn(object, function(value, key, object) {
13341 baseAssignValue(result, iteratee(value, key, object), value);
13347 * Creates an object with the same keys as `object` and values generated
13348 * by running each own enumerable string keyed property of `object` thru
13349 * `iteratee`. The iteratee is invoked with three arguments:
13350 * (value, key, object).
13356 * @param {Object} object The object to iterate over.
13357 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13358 * @returns {Object} Returns the new mapped object.
13363 * 'fred': { 'user': 'fred', 'age': 40 },
13364 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
13367 * _.mapValues(users, function(o) { return o.age; });
13368 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13370 * // The `_.property` iteratee shorthand.
13371 * _.mapValues(users, 'age');
13372 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13374 function mapValues(object, iteratee) {
13376 iteratee = getIteratee(iteratee, 3);
13378 baseForOwn(object, function(value, key, object) {
13379 baseAssignValue(result, key, iteratee(value, key, object));
13385 * This method is like `_.assign` except that it recursively merges own and
13386 * inherited enumerable string keyed properties of source objects into the
13387 * destination object. Source properties that resolve to `undefined` are
13388 * skipped if a destination value exists. Array and plain object properties
13389 * are merged recursively. Other objects and value types are overridden by
13390 * assignment. Source objects are applied from left to right. Subsequent
13391 * sources overwrite property assignments of previous sources.
13393 * **Note:** This method mutates `object`.
13399 * @param {Object} object The destination object.
13400 * @param {...Object} [sources] The source objects.
13401 * @returns {Object} Returns `object`.
13405 * 'a': [{ 'b': 2 }, { 'd': 4 }]
13409 * 'a': [{ 'c': 3 }, { 'e': 5 }]
13412 * _.merge(object, other);
13413 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13415 var merge = createAssigner(function(object, source, srcIndex) {
13416 baseMerge(object, source, srcIndex);
13420 * This method is like `_.merge` except that it accepts `customizer` which
13421 * is invoked to produce the merged values of the destination and source
13422 * properties. If `customizer` returns `undefined`, merging is handled by the
13423 * method instead. The `customizer` is invoked with six arguments:
13424 * (objValue, srcValue, key, object, source, stack).
13426 * **Note:** This method mutates `object`.
13432 * @param {Object} object The destination object.
13433 * @param {...Object} sources The source objects.
13434 * @param {Function} customizer The function to customize assigned values.
13435 * @returns {Object} Returns `object`.
13438 * function customizer(objValue, srcValue) {
13439 * if (_.isArray(objValue)) {
13440 * return objValue.concat(srcValue);
13444 * var object = { 'a': [1], 'b': [2] };
13445 * var other = { 'a': [3], 'b': [4] };
13447 * _.mergeWith(object, other, customizer);
13448 * // => { 'a': [1, 3], 'b': [2, 4] }
13450 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13451 baseMerge(object, source, srcIndex, customizer);
13455 * The opposite of `_.pick`; this method creates an object composed of the
13456 * own and inherited enumerable property paths of `object` that are not omitted.
13458 * **Note:** This method is considerably slower than `_.pick`.
13464 * @param {Object} object The source object.
13465 * @param {...(string|string[])} [paths] The property paths to omit.
13466 * @returns {Object} Returns the new object.
13469 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13471 * _.omit(object, ['a', 'c']);
13472 * // => { 'b': '2' }
13474 var omit = flatRest(function(object, paths) {
13476 if (object == null) {
13479 var isDeep = false;
13480 paths = arrayMap(paths, function(path) {
13481 path = castPath(path, object);
13482 isDeep || (isDeep = path.length > 1);
13485 copyObject(object, getAllKeysIn(object), result);
13487 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
13489 var length = paths.length;
13491 baseUnset(result, paths[length]);
13497 * The opposite of `_.pickBy`; this method creates an object composed of
13498 * the own and inherited enumerable string keyed properties of `object` that
13499 * `predicate` doesn't return truthy for. The predicate is invoked with two
13500 * arguments: (value, key).
13506 * @param {Object} object The source object.
13507 * @param {Function} [predicate=_.identity] The function invoked per property.
13508 * @returns {Object} Returns the new object.
13511 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13513 * _.omitBy(object, _.isNumber);
13514 * // => { 'b': '2' }
13516 function omitBy(object, predicate) {
13517 return pickBy(object, negate(getIteratee(predicate)));
13521 * Creates an object composed of the picked `object` properties.
13527 * @param {Object} object The source object.
13528 * @param {...(string|string[])} [paths] The property paths to pick.
13529 * @returns {Object} Returns the new object.
13532 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13534 * _.pick(object, ['a', 'c']);
13535 * // => { 'a': 1, 'c': 3 }
13537 var pick = flatRest(function(object, paths) {
13538 return object == null ? {} : basePick(object, paths);
13542 * Creates an object composed of the `object` properties `predicate` returns
13543 * truthy for. The predicate is invoked with two arguments: (value, key).
13549 * @param {Object} object The source object.
13550 * @param {Function} [predicate=_.identity] The function invoked per property.
13551 * @returns {Object} Returns the new object.
13554 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13556 * _.pickBy(object, _.isNumber);
13557 * // => { 'a': 1, 'c': 3 }
13559 function pickBy(object, predicate) {
13560 if (object == null) {
13563 var props = arrayMap(getAllKeysIn(object), function(prop) {
13566 predicate = getIteratee(predicate);
13567 return basePickBy(object, props, function(value, path) {
13568 return predicate(value, path[0]);
13573 * This method is like `_.get` except that if the resolved value is a
13574 * function it's invoked with the `this` binding of its parent object and
13575 * its result is returned.
13581 * @param {Object} object The object to query.
13582 * @param {Array|string} path The path of the property to resolve.
13583 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13584 * @returns {*} Returns the resolved value.
13587 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13589 * _.result(object, 'a[0].b.c1');
13592 * _.result(object, 'a[0].b.c2');
13595 * _.result(object, 'a[0].b.c3', 'default');
13598 * _.result(object, 'a[0].b.c3', _.constant('default'));
13601 function result(object, path, defaultValue) {
13602 path = castPath(path, object);
13605 length = path.length;
13607 // Ensure the loop is entered when path is empty.
13610 object = undefined;
13612 while (++index < length) {
13613 var value = object == null ? undefined : object[toKey(path[index])];
13614 if (value === undefined) {
13616 value = defaultValue;
13618 object = isFunction(value) ? value.call(object) : value;
13624 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
13625 * it's created. Arrays are created for missing index properties while objects
13626 * are created for all other missing properties. Use `_.setWith` to customize
13629 * **Note:** This method mutates `object`.
13635 * @param {Object} object The object to modify.
13636 * @param {Array|string} path The path of the property to set.
13637 * @param {*} value The value to set.
13638 * @returns {Object} Returns `object`.
13641 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13643 * _.set(object, 'a[0].b.c', 4);
13644 * console.log(object.a[0].b.c);
13647 * _.set(object, ['x', '0', 'y', 'z'], 5);
13648 * console.log(object.x[0].y.z);
13651 function set(object, path, value) {
13652 return object == null ? object : baseSet(object, path, value);
13656 * This method is like `_.set` except that it accepts `customizer` which is
13657 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
13658 * path creation is handled by the method instead. The `customizer` is invoked
13659 * with three arguments: (nsValue, key, nsObject).
13661 * **Note:** This method mutates `object`.
13667 * @param {Object} object The object to modify.
13668 * @param {Array|string} path The path of the property to set.
13669 * @param {*} value The value to set.
13670 * @param {Function} [customizer] The function to customize assigned values.
13671 * @returns {Object} Returns `object`.
13676 * _.setWith(object, '[0][1]', 'a', Object);
13677 * // => { '0': { '1': 'a' } }
13679 function setWith(object, path, value, customizer) {
13680 customizer = typeof customizer == 'function' ? customizer : undefined;
13681 return object == null ? object : baseSet(object, path, value, customizer);
13685 * Creates an array of own enumerable string keyed-value pairs for `object`
13686 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
13687 * entries are returned.
13694 * @param {Object} object The object to query.
13695 * @returns {Array} Returns the key-value pairs.
13703 * Foo.prototype.c = 3;
13705 * _.toPairs(new Foo);
13706 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
13708 var toPairs = createToPairs(keys);
13711 * Creates an array of own and inherited enumerable string keyed-value pairs
13712 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
13713 * or set, its entries are returned.
13720 * @param {Object} object The object to query.
13721 * @returns {Array} Returns the key-value pairs.
13729 * Foo.prototype.c = 3;
13731 * _.toPairsIn(new Foo);
13732 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
13734 var toPairsIn = createToPairs(keysIn);
13737 * An alternative to `_.reduce`; this method transforms `object` to a new
13738 * `accumulator` object which is the result of running each of its own
13739 * enumerable string keyed properties thru `iteratee`, with each invocation
13740 * potentially mutating the `accumulator` object. If `accumulator` is not
13741 * provided, a new object with the same `[[Prototype]]` will be used. The
13742 * iteratee is invoked with four arguments: (accumulator, value, key, object).
13743 * Iteratee functions may exit iteration early by explicitly returning `false`.
13749 * @param {Object} object The object to iterate over.
13750 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13751 * @param {*} [accumulator] The custom accumulator value.
13752 * @returns {*} Returns the accumulated value.
13755 * _.transform([2, 3, 4], function(result, n) {
13756 * result.push(n *= n);
13757 * return n % 2 == 0;
13761 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
13762 * (result[value] || (result[value] = [])).push(key);
13764 * // => { '1': ['a', 'c'], '2': ['b'] }
13766 function transform(object, iteratee, accumulator) {
13767 var isArr = isArray(object),
13768 isArrLike = isArr || isBuffer(object) || isTypedArray(object);
13770 iteratee = getIteratee(iteratee, 4);
13771 if (accumulator == null) {
13772 var Ctor = object && object.constructor;
13774 accumulator = isArr ? new Ctor : [];
13776 else if (isObject(object)) {
13777 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
13783 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
13784 return iteratee(accumulator, value, index, object);
13786 return accumulator;
13790 * Removes the property at `path` of `object`.
13792 * **Note:** This method mutates `object`.
13798 * @param {Object} object The object to modify.
13799 * @param {Array|string} path The path of the property to unset.
13800 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
13803 * var object = { 'a': [{ 'b': { 'c': 7 } }] };
13804 * _.unset(object, 'a[0].b.c');
13807 * console.log(object);
13808 * // => { 'a': [{ 'b': {} }] };
13810 * _.unset(object, ['a', '0', 'b', 'c']);
13813 * console.log(object);
13814 * // => { 'a': [{ 'b': {} }] };
13816 function unset(object, path) {
13817 return object == null ? true : baseUnset(object, path);
13821 * This method is like `_.set` except that accepts `updater` to produce the
13822 * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
13823 * is invoked with one argument: (value).
13825 * **Note:** This method mutates `object`.
13831 * @param {Object} object The object to modify.
13832 * @param {Array|string} path The path of the property to set.
13833 * @param {Function} updater The function to produce the updated value.
13834 * @returns {Object} Returns `object`.
13837 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13839 * _.update(object, 'a[0].b.c', function(n) { return n * n; });
13840 * console.log(object.a[0].b.c);
13843 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
13844 * console.log(object.x[0].y.z);
13847 function update(object, path, updater) {
13848 return object == null ? object : baseUpdate(object, path, castFunction(updater));
13852 * This method is like `_.update` except that it accepts `customizer` which is
13853 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
13854 * path creation is handled by the method instead. The `customizer` is invoked
13855 * with three arguments: (nsValue, key, nsObject).
13857 * **Note:** This method mutates `object`.
13863 * @param {Object} object The object to modify.
13864 * @param {Array|string} path The path of the property to set.
13865 * @param {Function} updater The function to produce the updated value.
13866 * @param {Function} [customizer] The function to customize assigned values.
13867 * @returns {Object} Returns `object`.
13872 * _.updateWith(object, '[0][1]', _.constant('a'), Object);
13873 * // => { '0': { '1': 'a' } }
13875 function updateWith(object, path, updater, customizer) {
13876 customizer = typeof customizer == 'function' ? customizer : undefined;
13877 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
13881 * Creates an array of the own enumerable string keyed property values of `object`.
13883 * **Note:** Non-object values are coerced to objects.
13889 * @param {Object} object The object to query.
13890 * @returns {Array} Returns the array of property values.
13898 * Foo.prototype.c = 3;
13900 * _.values(new Foo);
13901 * // => [1, 2] (iteration order is not guaranteed)
13906 function values(object) {
13907 return object == null ? [] : baseValues(object, keys(object));
13911 * Creates an array of the own and inherited enumerable string keyed property
13912 * values of `object`.
13914 * **Note:** Non-object values are coerced to objects.
13920 * @param {Object} object The object to query.
13921 * @returns {Array} Returns the array of property values.
13929 * Foo.prototype.c = 3;
13931 * _.valuesIn(new Foo);
13932 * // => [1, 2, 3] (iteration order is not guaranteed)
13934 function valuesIn(object) {
13935 return object == null ? [] : baseValues(object, keysIn(object));
13938 /*------------------------------------------------------------------------*/
13941 * Clamps `number` within the inclusive `lower` and `upper` bounds.
13947 * @param {number} number The number to clamp.
13948 * @param {number} [lower] The lower bound.
13949 * @param {number} upper The upper bound.
13950 * @returns {number} Returns the clamped number.
13953 * _.clamp(-10, -5, 5);
13956 * _.clamp(10, -5, 5);
13959 function clamp(number, lower, upper) {
13960 if (upper === undefined) {
13964 if (upper !== undefined) {
13965 upper = toNumber(upper);
13966 upper = upper === upper ? upper : 0;
13968 if (lower !== undefined) {
13969 lower = toNumber(lower);
13970 lower = lower === lower ? lower : 0;
13972 return baseClamp(toNumber(number), lower, upper);
13976 * Checks if `n` is between `start` and up to, but not including, `end`. If
13977 * `end` is not specified, it's set to `start` with `start` then set to `0`.
13978 * If `start` is greater than `end` the params are swapped to support
13985 * @param {number} number The number to check.
13986 * @param {number} [start=0] The start of the range.
13987 * @param {number} end The end of the range.
13988 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
13989 * @see _.range, _.rangeRight
13992 * _.inRange(3, 2, 4);
14004 * _.inRange(1.2, 2);
14007 * _.inRange(5.2, 4);
14010 * _.inRange(-3, -2, -6);
14013 function inRange(number, start, end) {
14014 start = toFinite(start);
14015 if (end === undefined) {
14019 end = toFinite(end);
14021 number = toNumber(number);
14022 return baseInRange(number, start, end);
14026 * Produces a random number between the inclusive `lower` and `upper` bounds.
14027 * If only one argument is provided a number between `0` and the given number
14028 * is returned. If `floating` is `true`, or either `lower` or `upper` are
14029 * floats, a floating-point number is returned instead of an integer.
14031 * **Note:** JavaScript follows the IEEE-754 standard for resolving
14032 * floating-point values which can produce unexpected results.
14038 * @param {number} [lower=0] The lower bound.
14039 * @param {number} [upper=1] The upper bound.
14040 * @param {boolean} [floating] Specify returning a floating-point number.
14041 * @returns {number} Returns the random number.
14045 * // => an integer between 0 and 5
14048 * // => also an integer between 0 and 5
14050 * _.random(5, true);
14051 * // => a floating-point number between 0 and 5
14053 * _.random(1.2, 5.2);
14054 * // => a floating-point number between 1.2 and 5.2
14056 function random(lower, upper, floating) {
14057 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
14058 upper = floating = undefined;
14060 if (floating === undefined) {
14061 if (typeof upper == 'boolean') {
14065 else if (typeof lower == 'boolean') {
14070 if (lower === undefined && upper === undefined) {
14075 lower = toFinite(lower);
14076 if (upper === undefined) {
14080 upper = toFinite(upper);
14083 if (lower > upper) {
14088 if (floating || lower % 1 || upper % 1) {
14089 var rand = nativeRandom();
14090 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14092 return baseRandom(lower, upper);
14095 /*------------------------------------------------------------------------*/
14098 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14104 * @param {string} [string=''] The string to convert.
14105 * @returns {string} Returns the camel cased string.
14108 * _.camelCase('Foo Bar');
14111 * _.camelCase('--foo-bar--');
14114 * _.camelCase('__FOO_BAR__');
14117 var camelCase = createCompounder(function(result, word, index) {
14118 word = word.toLowerCase();
14119 return result + (index ? capitalize(word) : word);
14123 * Converts the first character of `string` to upper case and the remaining
14130 * @param {string} [string=''] The string to capitalize.
14131 * @returns {string} Returns the capitalized string.
14134 * _.capitalize('FRED');
14137 function capitalize(string) {
14138 return upperFirst(toString(string).toLowerCase());
14142 * Deburrs `string` by converting
14143 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
14144 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
14145 * letters to basic Latin letters and removing
14146 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
14152 * @param {string} [string=''] The string to deburr.
14153 * @returns {string} Returns the deburred string.
14156 * _.deburr('déjà vu');
14159 function deburr(string) {
14160 string = toString(string);
14161 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14165 * Checks if `string` ends with the given target string.
14171 * @param {string} [string=''] The string to inspect.
14172 * @param {string} [target] The string to search for.
14173 * @param {number} [position=string.length] The position to search up to.
14174 * @returns {boolean} Returns `true` if `string` ends with `target`,
14178 * _.endsWith('abc', 'c');
14181 * _.endsWith('abc', 'b');
14184 * _.endsWith('abc', 'b', 2);
14187 function endsWith(string, target, position) {
14188 string = toString(string);
14189 target = baseToString(target);
14191 var length = string.length;
14192 position = position === undefined
14194 : baseClamp(toInteger(position), 0, length);
14196 var end = position;
14197 position -= target.length;
14198 return position >= 0 && string.slice(position, end) == target;
14202 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14203 * corresponding HTML entities.
14205 * **Note:** No other characters are escaped. To escape additional
14206 * characters use a third-party library like [_he_](https://mths.be/he).
14208 * Though the ">" character is escaped for symmetry, characters like
14209 * ">" and "/" don't need escaping in HTML and have no special meaning
14210 * unless they're part of a tag or unquoted attribute value. See
14211 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
14212 * (under "semi-related fun fact") for more details.
14214 * When working with HTML you should always
14215 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14222 * @param {string} [string=''] The string to escape.
14223 * @returns {string} Returns the escaped string.
14226 * _.escape('fred, barney, & pebbles');
14227 * // => 'fred, barney, & pebbles'
14229 function escape(string) {
14230 string = toString(string);
14231 return (string && reHasUnescapedHtml.test(string))
14232 ? string.replace(reUnescapedHtml, escapeHtmlChar)
14237 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14238 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14244 * @param {string} [string=''] The string to escape.
14245 * @returns {string} Returns the escaped string.
14248 * _.escapeRegExp('[lodash](https://lodash.com/)');
14249 * // => '\[lodash\]\(https://lodash\.com/\)'
14251 function escapeRegExp(string) {
14252 string = toString(string);
14253 return (string && reHasRegExpChar.test(string))
14254 ? string.replace(reRegExpChar, '\\$&')
14259 * Converts `string` to
14260 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14266 * @param {string} [string=''] The string to convert.
14267 * @returns {string} Returns the kebab cased string.
14270 * _.kebabCase('Foo Bar');
14273 * _.kebabCase('fooBar');
14276 * _.kebabCase('__FOO_BAR__');
14279 var kebabCase = createCompounder(function(result, word, index) {
14280 return result + (index ? '-' : '') + word.toLowerCase();
14284 * Converts `string`, as space separated words, to lower case.
14290 * @param {string} [string=''] The string to convert.
14291 * @returns {string} Returns the lower cased string.
14294 * _.lowerCase('--Foo-Bar--');
14297 * _.lowerCase('fooBar');
14300 * _.lowerCase('__FOO_BAR__');
14303 var lowerCase = createCompounder(function(result, word, index) {
14304 return result + (index ? ' ' : '') + word.toLowerCase();
14308 * Converts the first character of `string` to lower case.
14314 * @param {string} [string=''] The string to convert.
14315 * @returns {string} Returns the converted string.
14318 * _.lowerFirst('Fred');
14321 * _.lowerFirst('FRED');
14324 var lowerFirst = createCaseFirst('toLowerCase');
14327 * Pads `string` on the left and right sides if it's shorter than `length`.
14328 * Padding characters are truncated if they can't be evenly divided by `length`.
14334 * @param {string} [string=''] The string to pad.
14335 * @param {number} [length=0] The padding length.
14336 * @param {string} [chars=' '] The string used as padding.
14337 * @returns {string} Returns the padded string.
14343 * _.pad('abc', 8, '_-');
14349 function pad(string, length, chars) {
14350 string = toString(string);
14351 length = toInteger(length);
14353 var strLength = length ? stringSize(string) : 0;
14354 if (!length || strLength >= length) {
14357 var mid = (length - strLength) / 2;
14359 createPadding(nativeFloor(mid), chars) +
14361 createPadding(nativeCeil(mid), chars)
14366 * Pads `string` on the right side if it's shorter than `length`. Padding
14367 * characters are truncated if they exceed `length`.
14373 * @param {string} [string=''] The string to pad.
14374 * @param {number} [length=0] The padding length.
14375 * @param {string} [chars=' '] The string used as padding.
14376 * @returns {string} Returns the padded string.
14379 * _.padEnd('abc', 6);
14382 * _.padEnd('abc', 6, '_-');
14385 * _.padEnd('abc', 3);
14388 function padEnd(string, length, chars) {
14389 string = toString(string);
14390 length = toInteger(length);
14392 var strLength = length ? stringSize(string) : 0;
14393 return (length && strLength < length)
14394 ? (string + createPadding(length - strLength, chars))
14399 * Pads `string` on the left side if it's shorter than `length`. Padding
14400 * characters are truncated if they exceed `length`.
14406 * @param {string} [string=''] The string to pad.
14407 * @param {number} [length=0] The padding length.
14408 * @param {string} [chars=' '] The string used as padding.
14409 * @returns {string} Returns the padded string.
14412 * _.padStart('abc', 6);
14415 * _.padStart('abc', 6, '_-');
14418 * _.padStart('abc', 3);
14421 function padStart(string, length, chars) {
14422 string = toString(string);
14423 length = toInteger(length);
14425 var strLength = length ? stringSize(string) : 0;
14426 return (length && strLength < length)
14427 ? (createPadding(length - strLength, chars) + string)
14432 * Converts `string` to an integer of the specified radix. If `radix` is
14433 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
14434 * hexadecimal, in which case a `radix` of `16` is used.
14436 * **Note:** This method aligns with the
14437 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
14443 * @param {string} string The string to convert.
14444 * @param {number} [radix=10] The radix to interpret `value` by.
14445 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14446 * @returns {number} Returns the converted integer.
14449 * _.parseInt('08');
14452 * _.map(['6', '08', '10'], _.parseInt);
14455 function parseInt(string, radix, guard) {
14456 if (guard || radix == null) {
14458 } else if (radix) {
14461 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14465 * Repeats the given string `n` times.
14471 * @param {string} [string=''] The string to repeat.
14472 * @param {number} [n=1] The number of times to repeat the string.
14473 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14474 * @returns {string} Returns the repeated string.
14477 * _.repeat('*', 3);
14480 * _.repeat('abc', 2);
14483 * _.repeat('abc', 0);
14486 function repeat(string, n, guard) {
14487 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
14492 return baseRepeat(toString(string), n);
14496 * Replaces matches for `pattern` in `string` with `replacement`.
14498 * **Note:** This method is based on
14499 * [`String#replace`](https://mdn.io/String/replace).
14505 * @param {string} [string=''] The string to modify.
14506 * @param {RegExp|string} pattern The pattern to replace.
14507 * @param {Function|string} replacement The match replacement.
14508 * @returns {string} Returns the modified string.
14511 * _.replace('Hi Fred', 'Fred', 'Barney');
14512 * // => 'Hi Barney'
14514 function replace() {
14515 var args = arguments,
14516 string = toString(args[0]);
14518 return args.length < 3 ? string : string.replace(args[1], args[2]);
14522 * Converts `string` to
14523 * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14529 * @param {string} [string=''] The string to convert.
14530 * @returns {string} Returns the snake cased string.
14533 * _.snakeCase('Foo Bar');
14536 * _.snakeCase('fooBar');
14539 * _.snakeCase('--FOO-BAR--');
14542 var snakeCase = createCompounder(function(result, word, index) {
14543 return result + (index ? '_' : '') + word.toLowerCase();
14547 * Splits `string` by `separator`.
14549 * **Note:** This method is based on
14550 * [`String#split`](https://mdn.io/String/split).
14556 * @param {string} [string=''] The string to split.
14557 * @param {RegExp|string} separator The separator pattern to split by.
14558 * @param {number} [limit] The length to truncate results to.
14559 * @returns {Array} Returns the string segments.
14562 * _.split('a-b-c', '-', 2);
14565 function split(string, separator, limit) {
14566 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14567 separator = limit = undefined;
14569 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
14573 string = toString(string);
14575 typeof separator == 'string' ||
14576 (separator != null && !isRegExp(separator))
14578 separator = baseToString(separator);
14579 if (!separator && hasUnicode(string)) {
14580 return castSlice(stringToArray(string), 0, limit);
14583 return string.split(separator, limit);
14587 * Converts `string` to
14588 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14594 * @param {string} [string=''] The string to convert.
14595 * @returns {string} Returns the start cased string.
14598 * _.startCase('--foo-bar--');
14601 * _.startCase('fooBar');
14604 * _.startCase('__FOO_BAR__');
14607 var startCase = createCompounder(function(result, word, index) {
14608 return result + (index ? ' ' : '') + upperFirst(word);
14612 * Checks if `string` starts with the given target string.
14618 * @param {string} [string=''] The string to inspect.
14619 * @param {string} [target] The string to search for.
14620 * @param {number} [position=0] The position to search from.
14621 * @returns {boolean} Returns `true` if `string` starts with `target`,
14625 * _.startsWith('abc', 'a');
14628 * _.startsWith('abc', 'b');
14631 * _.startsWith('abc', 'b', 1);
14634 function startsWith(string, target, position) {
14635 string = toString(string);
14636 position = position == null
14638 : baseClamp(toInteger(position), 0, string.length);
14640 target = baseToString(target);
14641 return string.slice(position, position + target.length) == target;
14645 * Creates a compiled template function that can interpolate data properties
14646 * in "interpolate" delimiters, HTML-escape interpolated data properties in
14647 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
14648 * properties may be accessed as free variables in the template. If a setting
14649 * object is given, it takes precedence over `_.templateSettings` values.
14651 * **Note:** In the development build `_.template` utilizes
14652 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
14653 * for easier debugging.
14655 * For more information on precompiling templates see
14656 * [lodash's custom builds documentation](https://lodash.com/custom-builds).
14658 * For more information on Chrome extension sandboxes see
14659 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
14665 * @param {string} [string=''] The template string.
14666 * @param {Object} [options={}] The options object.
14667 * @param {RegExp} [options.escape=_.templateSettings.escape]
14668 * The HTML "escape" delimiter.
14669 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
14670 * The "evaluate" delimiter.
14671 * @param {Object} [options.imports=_.templateSettings.imports]
14672 * An object to import into the template as free variables.
14673 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
14674 * The "interpolate" delimiter.
14675 * @param {string} [options.sourceURL='lodash.templateSources[n]']
14676 * The sourceURL of the compiled template.
14677 * @param {string} [options.variable='obj']
14678 * The data object variable name.
14679 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14680 * @returns {Function} Returns the compiled template function.
14683 * // Use the "interpolate" delimiter to create a compiled template.
14684 * var compiled = _.template('hello <%= user %>!');
14685 * compiled({ 'user': 'fred' });
14686 * // => 'hello fred!'
14688 * // Use the HTML "escape" delimiter to escape data property values.
14689 * var compiled = _.template('<b><%- value %></b>');
14690 * compiled({ 'value': '<script>' });
14691 * // => '<b><script></b>'
14693 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
14694 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
14695 * compiled({ 'users': ['fred', 'barney'] });
14696 * // => '<li>fred</li><li>barney</li>'
14698 * // Use the internal `print` function in "evaluate" delimiters.
14699 * var compiled = _.template('<% print("hello " + user); %>!');
14700 * compiled({ 'user': 'barney' });
14701 * // => 'hello barney!'
14703 * // Use the ES template literal delimiter as an "interpolate" delimiter.
14704 * // Disable support by replacing the "interpolate" delimiter.
14705 * var compiled = _.template('hello ${ user }!');
14706 * compiled({ 'user': 'pebbles' });
14707 * // => 'hello pebbles!'
14709 * // Use backslashes to treat delimiters as plain text.
14710 * var compiled = _.template('<%= "\\<%- value %\\>" %>');
14711 * compiled({ 'value': 'ignored' });
14712 * // => '<%- value %>'
14714 * // Use the `imports` option to import `jQuery` as `jq`.
14715 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
14716 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
14717 * compiled({ 'users': ['fred', 'barney'] });
14718 * // => '<li>fred</li><li>barney</li>'
14720 * // Use the `sourceURL` option to specify a custom sourceURL for the template.
14721 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
14723 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
14725 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
14726 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
14728 * // => function(data) {
14729 * // var __t, __p = '';
14730 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
14734 * // Use custom template delimiters.
14735 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
14736 * var compiled = _.template('hello {{ user }}!');
14737 * compiled({ 'user': 'mustache' });
14738 * // => 'hello mustache!'
14740 * // Use the `source` property to inline compiled templates for meaningful
14741 * // line numbers in error messages and stack traces.
14742 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
14744 * "main": ' + _.template(mainText).source + '\
14748 function template(string, options, guard) {
14749 // Based on John Resig's `tmpl` implementation
14750 // (http://ejohn.org/blog/javascript-micro-templating/)
14751 // and Laura Doktorova's doT.js (https://github.com/olado/doT).
14752 var settings = lodash.templateSettings;
14754 if (guard && isIterateeCall(string, options, guard)) {
14755 options = undefined;
14757 string = toString(string);
14758 options = assignInWith({}, options, settings, customDefaultsAssignIn);
14760 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
14761 importsKeys = keys(imports),
14762 importsValues = baseValues(imports, importsKeys);
14767 interpolate = options.interpolate || reNoMatch,
14768 source = "__p += '";
14770 // Compile the regexp to match each delimiter.
14771 var reDelimiters = RegExp(
14772 (options.escape || reNoMatch).source + '|' +
14773 interpolate.source + '|' +
14774 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
14775 (options.evaluate || reNoMatch).source + '|$'
14778 // Use a sourceURL for easier debugging.
14779 var sourceURL = '//# sourceURL=' +
14780 ('sourceURL' in options
14781 ? options.sourceURL
14782 : ('lodash.templateSources[' + (++templateCounter) + ']')
14785 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
14786 interpolateValue || (interpolateValue = esTemplateValue);
14788 // Escape characters that can't be included in string literals.
14789 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
14791 // Replace delimiters with snippets.
14794 source += "' +\n__e(" + escapeValue + ") +\n'";
14796 if (evaluateValue) {
14797 isEvaluating = true;
14798 source += "';\n" + evaluateValue + ";\n__p += '";
14800 if (interpolateValue) {
14801 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
14803 index = offset + match.length;
14805 // The JS engine embedded in Adobe products needs `match` returned in
14806 // order to produce the correct `offset` value.
14812 // If `variable` is not specified wrap a with-statement around the generated
14813 // code to add the data object to the top of the scope chain.
14814 var variable = options.variable;
14816 source = 'with (obj) {\n' + source + '\n}\n';
14818 // Cleanup code by stripping empty strings.
14819 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
14820 .replace(reEmptyStringMiddle, '$1')
14821 .replace(reEmptyStringTrailing, '$1;');
14823 // Frame code as the function body.
14824 source = 'function(' + (variable || 'obj') + ') {\n' +
14827 : 'obj || (obj = {});\n'
14829 "var __t, __p = ''" +
14831 ? ', __e = _.escape'
14835 ? ', __j = Array.prototype.join;\n' +
14836 "function print() { __p += __j.call(arguments, '') }\n"
14842 var result = attempt(function() {
14843 return Function(importsKeys, sourceURL + 'return ' + source)
14844 .apply(undefined, importsValues);
14847 // Provide the compiled function's source by its `toString` method or
14848 // the `source` property as a convenience for inlining compiled templates.
14849 result.source = source;
14850 if (isError(result)) {
14857 * Converts `string`, as a whole, to lower case just like
14858 * [String#toLowerCase](https://mdn.io/toLowerCase).
14864 * @param {string} [string=''] The string to convert.
14865 * @returns {string} Returns the lower cased string.
14868 * _.toLower('--Foo-Bar--');
14869 * // => '--foo-bar--'
14871 * _.toLower('fooBar');
14874 * _.toLower('__FOO_BAR__');
14875 * // => '__foo_bar__'
14877 function toLower(value) {
14878 return toString(value).toLowerCase();
14882 * Converts `string`, as a whole, to upper case just like
14883 * [String#toUpperCase](https://mdn.io/toUpperCase).
14889 * @param {string} [string=''] The string to convert.
14890 * @returns {string} Returns the upper cased string.
14893 * _.toUpper('--foo-bar--');
14894 * // => '--FOO-BAR--'
14896 * _.toUpper('fooBar');
14899 * _.toUpper('__foo_bar__');
14900 * // => '__FOO_BAR__'
14902 function toUpper(value) {
14903 return toString(value).toUpperCase();
14907 * Removes leading and trailing whitespace or specified characters from `string`.
14913 * @param {string} [string=''] The string to trim.
14914 * @param {string} [chars=whitespace] The characters to trim.
14915 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14916 * @returns {string} Returns the trimmed string.
14922 * _.trim('-_-abc-_-', '_-');
14925 * _.map([' foo ', ' bar '], _.trim);
14926 * // => ['foo', 'bar']
14928 function trim(string, chars, guard) {
14929 string = toString(string);
14930 if (string && (guard || chars === undefined)) {
14931 return string.replace(reTrim, '');
14933 if (!string || !(chars = baseToString(chars))) {
14936 var strSymbols = stringToArray(string),
14937 chrSymbols = stringToArray(chars),
14938 start = charsStartIndex(strSymbols, chrSymbols),
14939 end = charsEndIndex(strSymbols, chrSymbols) + 1;
14941 return castSlice(strSymbols, start, end).join('');
14945 * Removes trailing whitespace or specified characters from `string`.
14951 * @param {string} [string=''] The string to trim.
14952 * @param {string} [chars=whitespace] The characters to trim.
14953 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14954 * @returns {string} Returns the trimmed string.
14957 * _.trimEnd(' abc ');
14960 * _.trimEnd('-_-abc-_-', '_-');
14963 function trimEnd(string, chars, guard) {
14964 string = toString(string);
14965 if (string && (guard || chars === undefined)) {
14966 return string.replace(reTrimEnd, '');
14968 if (!string || !(chars = baseToString(chars))) {
14971 var strSymbols = stringToArray(string),
14972 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
14974 return castSlice(strSymbols, 0, end).join('');
14978 * Removes leading 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 * _.trimStart(' abc ');
14993 * _.trimStart('-_-abc-_-', '_-');
14996 function trimStart(string, chars, guard) {
14997 string = toString(string);
14998 if (string && (guard || chars === undefined)) {
14999 return string.replace(reTrimStart, '');
15001 if (!string || !(chars = baseToString(chars))) {
15004 var strSymbols = stringToArray(string),
15005 start = charsStartIndex(strSymbols, stringToArray(chars));
15007 return castSlice(strSymbols, start).join('');
15011 * Truncates `string` if it's longer than the given maximum string length.
15012 * The last characters of the truncated string are replaced with the omission
15013 * string which defaults to "...".
15019 * @param {string} [string=''] The string to truncate.
15020 * @param {Object} [options={}] The options object.
15021 * @param {number} [options.length=30] The maximum string length.
15022 * @param {string} [options.omission='...'] The string to indicate text is omitted.
15023 * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
15024 * @returns {string} Returns the truncated string.
15027 * _.truncate('hi-diddly-ho there, neighborino');
15028 * // => 'hi-diddly-ho there, neighbo...'
15030 * _.truncate('hi-diddly-ho there, neighborino', {
15034 * // => 'hi-diddly-ho there,...'
15036 * _.truncate('hi-diddly-ho there, neighborino', {
15038 * 'separator': /,? +/
15040 * // => 'hi-diddly-ho there...'
15042 * _.truncate('hi-diddly-ho there, neighborino', {
15043 * 'omission': ' [...]'
15045 * // => 'hi-diddly-ho there, neig [...]'
15047 function truncate(string, options) {
15048 var length = DEFAULT_TRUNC_LENGTH,
15049 omission = DEFAULT_TRUNC_OMISSION;
15051 if (isObject(options)) {
15052 var separator = 'separator' in options ? options.separator : separator;
15053 length = 'length' in options ? toInteger(options.length) : length;
15054 omission = 'omission' in options ? baseToString(options.omission) : omission;
15056 string = toString(string);
15058 var strLength = string.length;
15059 if (hasUnicode(string)) {
15060 var strSymbols = stringToArray(string);
15061 strLength = strSymbols.length;
15063 if (length >= strLength) {
15066 var end = length - stringSize(omission);
15070 var result = strSymbols
15071 ? castSlice(strSymbols, 0, end).join('')
15072 : string.slice(0, end);
15074 if (separator === undefined) {
15075 return result + omission;
15078 end += (result.length - end);
15080 if (isRegExp(separator)) {
15081 if (string.slice(end).search(separator)) {
15083 substring = result;
15085 if (!separator.global) {
15086 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15088 separator.lastIndex = 0;
15089 while ((match = separator.exec(substring))) {
15090 var newEnd = match.index;
15092 result = result.slice(0, newEnd === undefined ? end : newEnd);
15094 } else if (string.indexOf(baseToString(separator), end) != end) {
15095 var index = result.lastIndexOf(separator);
15097 result = result.slice(0, index);
15100 return result + omission;
15104 * The inverse of `_.escape`; this method converts the HTML entities
15105 * `&`, `<`, `>`, `"`, and `'` in `string` to
15106 * their corresponding characters.
15108 * **Note:** No other HTML entities are unescaped. To unescape additional
15109 * HTML entities use a third-party library like [_he_](https://mths.be/he).
15115 * @param {string} [string=''] The string to unescape.
15116 * @returns {string} Returns the unescaped string.
15119 * _.unescape('fred, barney, & pebbles');
15120 * // => 'fred, barney, & pebbles'
15122 function unescape(string) {
15123 string = toString(string);
15124 return (string && reHasEscapedHtml.test(string))
15125 ? string.replace(reEscapedHtml, unescapeHtmlChar)
15130 * Converts `string`, as space separated words, to upper case.
15136 * @param {string} [string=''] The string to convert.
15137 * @returns {string} Returns the upper cased string.
15140 * _.upperCase('--foo-bar');
15143 * _.upperCase('fooBar');
15146 * _.upperCase('__foo_bar__');
15149 var upperCase = createCompounder(function(result, word, index) {
15150 return result + (index ? ' ' : '') + word.toUpperCase();
15154 * Converts the first character of `string` to upper case.
15160 * @param {string} [string=''] The string to convert.
15161 * @returns {string} Returns the converted string.
15164 * _.upperFirst('fred');
15167 * _.upperFirst('FRED');
15170 var upperFirst = createCaseFirst('toUpperCase');
15173 * Splits `string` into an array of its words.
15179 * @param {string} [string=''] The string to inspect.
15180 * @param {RegExp|string} [pattern] The pattern to match words.
15181 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15182 * @returns {Array} Returns the words of `string`.
15185 * _.words('fred, barney, & pebbles');
15186 * // => ['fred', 'barney', 'pebbles']
15188 * _.words('fred, barney, & pebbles', /[^, ]+/g);
15189 * // => ['fred', 'barney', '&', 'pebbles']
15191 function words(string, pattern, guard) {
15192 string = toString(string);
15193 pattern = guard ? undefined : pattern;
15195 if (pattern === undefined) {
15196 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15198 return string.match(pattern) || [];
15201 /*------------------------------------------------------------------------*/
15204 * Attempts to invoke `func`, returning either the result or the caught error
15205 * object. Any additional arguments are provided to `func` when it's invoked.
15211 * @param {Function} func The function to attempt.
15212 * @param {...*} [args] The arguments to invoke `func` with.
15213 * @returns {*} Returns the `func` result or error object.
15216 * // Avoid throwing errors for invalid selectors.
15217 * var elements = _.attempt(function(selector) {
15218 * return document.querySelectorAll(selector);
15221 * if (_.isError(elements)) {
15225 var attempt = baseRest(function(func, args) {
15227 return apply(func, undefined, args);
15229 return isError(e) ? e : new Error(e);
15234 * Binds methods of an object to the object itself, overwriting the existing
15237 * **Note:** This method doesn't set the "length" property of bound functions.
15243 * @param {Object} object The object to bind and assign the bound methods to.
15244 * @param {...(string|string[])} methodNames The object method names to bind.
15245 * @returns {Object} Returns `object`.
15250 * 'click': function() {
15251 * console.log('clicked ' + this.label);
15255 * _.bindAll(view, ['click']);
15256 * jQuery(element).on('click', view.click);
15257 * // => Logs 'clicked docs' when clicked.
15259 var bindAll = flatRest(function(object, methodNames) {
15260 arrayEach(methodNames, function(key) {
15262 baseAssignValue(object, key, bind(object[key], object));
15268 * Creates a function that iterates over `pairs` and invokes the corresponding
15269 * function of the first predicate to return truthy. The predicate-function
15270 * pairs are invoked with the `this` binding and arguments of the created
15277 * @param {Array} pairs The predicate-function pairs.
15278 * @returns {Function} Returns the new composite function.
15281 * var func = _.cond([
15282 * [_.matches({ 'a': 1 }), _.constant('matches A')],
15283 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15284 * [_.stubTrue, _.constant('no match')]
15287 * func({ 'a': 1, 'b': 2 });
15288 * // => 'matches A'
15290 * func({ 'a': 0, 'b': 1 });
15291 * // => 'matches B'
15293 * func({ 'a': '1', 'b': '2' });
15296 function cond(pairs) {
15297 var length = pairs == null ? 0 : pairs.length,
15298 toIteratee = getIteratee();
15300 pairs = !length ? [] : arrayMap(pairs, function(pair) {
15301 if (typeof pair[1] != 'function') {
15302 throw new TypeError(FUNC_ERROR_TEXT);
15304 return [toIteratee(pair[0]), pair[1]];
15307 return baseRest(function(args) {
15309 while (++index < length) {
15310 var pair = pairs[index];
15311 if (apply(pair[0], this, args)) {
15312 return apply(pair[1], this, args);
15319 * Creates a function that invokes the predicate properties of `source` with
15320 * the corresponding property values of a given object, returning `true` if
15321 * all predicates return truthy, else `false`.
15323 * **Note:** The created function is equivalent to `_.conformsTo` with
15324 * `source` partially applied.
15330 * @param {Object} source The object of property predicates to conform to.
15331 * @returns {Function} Returns the new spec function.
15335 * { 'a': 2, 'b': 1 },
15336 * { 'a': 1, 'b': 2 }
15339 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15340 * // => [{ 'a': 1, 'b': 2 }]
15342 function conforms(source) {
15343 return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
15347 * Creates a function that returns `value`.
15353 * @param {*} value The value to return from the new function.
15354 * @returns {Function} Returns the new constant function.
15357 * var objects = _.times(2, _.constant({ 'a': 1 }));
15359 * console.log(objects);
15360 * // => [{ 'a': 1 }, { 'a': 1 }]
15362 * console.log(objects[0] === objects[1]);
15365 function constant(value) {
15366 return function() {
15372 * Checks `value` to determine whether a default value should be returned in
15373 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
15380 * @param {*} value The value to check.
15381 * @param {*} defaultValue The default value.
15382 * @returns {*} Returns the resolved value.
15385 * _.defaultTo(1, 10);
15388 * _.defaultTo(undefined, 10);
15391 function defaultTo(value, defaultValue) {
15392 return (value == null || value !== value) ? defaultValue : value;
15396 * Creates a function that returns the result of invoking the given functions
15397 * with the `this` binding of the created function, where each successive
15398 * invocation is supplied the return value of the previous.
15404 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15405 * @returns {Function} Returns the new composite function.
15409 * function square(n) {
15413 * var addSquare = _.flow([_.add, square]);
15417 var flow = createFlow();
15420 * This method is like `_.flow` except that it creates a function that
15421 * invokes the given functions from right to left.
15427 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15428 * @returns {Function} Returns the new composite function.
15432 * function square(n) {
15436 * var addSquare = _.flowRight([square, _.add]);
15440 var flowRight = createFlow(true);
15443 * This method returns the first argument it receives.
15449 * @param {*} value Any value.
15450 * @returns {*} Returns `value`.
15453 * var object = { 'a': 1 };
15455 * console.log(_.identity(object) === object);
15458 function identity(value) {
15463 * Creates a function that invokes `func` with the arguments of the created
15464 * function. If `func` is a property name, the created function returns the
15465 * property value for a given element. If `func` is an array or object, the
15466 * created function returns `true` for elements that contain the equivalent
15467 * source properties, otherwise it returns `false`.
15473 * @param {*} [func=_.identity] The value to convert to a callback.
15474 * @returns {Function} Returns the callback.
15478 * { 'user': 'barney', 'age': 36, 'active': true },
15479 * { 'user': 'fred', 'age': 40, 'active': false }
15482 * // The `_.matches` iteratee shorthand.
15483 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15484 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15486 * // The `_.matchesProperty` iteratee shorthand.
15487 * _.filter(users, _.iteratee(['user', 'fred']));
15488 * // => [{ 'user': 'fred', 'age': 40 }]
15490 * // The `_.property` iteratee shorthand.
15491 * _.map(users, _.iteratee('user'));
15492 * // => ['barney', 'fred']
15494 * // Create custom iteratee shorthands.
15495 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
15496 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
15497 * return func.test(string);
15501 * _.filter(['abc', 'def'], /ef/);
15504 function iteratee(func) {
15505 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
15509 * Creates a function that performs a partial deep comparison between a given
15510 * object and `source`, returning `true` if the given object has equivalent
15511 * property values, else `false`.
15513 * **Note:** The created function is equivalent to `_.isMatch` with `source`
15514 * partially applied.
15516 * Partial comparisons will match empty array and empty object `source`
15517 * values against any array or object value, respectively. See `_.isEqual`
15518 * for a list of supported value comparisons.
15524 * @param {Object} source The object of property values to match.
15525 * @returns {Function} Returns the new spec function.
15529 * { 'a': 1, 'b': 2, 'c': 3 },
15530 * { 'a': 4, 'b': 5, 'c': 6 }
15533 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15534 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15536 function matches(source) {
15537 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
15541 * Creates a function that performs a partial deep comparison between the
15542 * value at `path` of a given object to `srcValue`, returning `true` if the
15543 * object value is equivalent, else `false`.
15545 * **Note:** Partial comparisons will match empty array and empty object
15546 * `srcValue` values against any array or object value, respectively. See
15547 * `_.isEqual` for a list of supported value comparisons.
15553 * @param {Array|string} path The path of the property to get.
15554 * @param {*} srcValue The value to match.
15555 * @returns {Function} Returns the new spec function.
15559 * { 'a': 1, 'b': 2, 'c': 3 },
15560 * { 'a': 4, 'b': 5, 'c': 6 }
15563 * _.find(objects, _.matchesProperty('a', 4));
15564 * // => { 'a': 4, 'b': 5, 'c': 6 }
15566 function matchesProperty(path, srcValue) {
15567 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
15571 * Creates a function that invokes the method at `path` of a given object.
15572 * Any additional arguments are provided to the invoked method.
15578 * @param {Array|string} path The path of the method to invoke.
15579 * @param {...*} [args] The arguments to invoke the method with.
15580 * @returns {Function} Returns the new invoker function.
15584 * { 'a': { 'b': _.constant(2) } },
15585 * { 'a': { 'b': _.constant(1) } }
15588 * _.map(objects, _.method('a.b'));
15591 * _.map(objects, _.method(['a', 'b']));
15594 var method = baseRest(function(path, args) {
15595 return function(object) {
15596 return baseInvoke(object, path, args);
15601 * The opposite of `_.method`; this method creates a function that invokes
15602 * the method at a given path of `object`. Any additional arguments are
15603 * provided to the invoked method.
15609 * @param {Object} object The object to query.
15610 * @param {...*} [args] The arguments to invoke the method with.
15611 * @returns {Function} Returns the new invoker function.
15614 * var array = _.times(3, _.constant),
15615 * object = { 'a': array, 'b': array, 'c': array };
15617 * _.map(['a[2]', 'c[0]'], _.methodOf(object));
15620 * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
15623 var methodOf = baseRest(function(object, args) {
15624 return function(path) {
15625 return baseInvoke(object, path, args);
15630 * Adds all own enumerable string keyed function properties of a source
15631 * object to the destination object. If `object` is a function, then methods
15632 * are added to its prototype as well.
15634 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
15635 * avoid conflicts caused by modifying the original.
15641 * @param {Function|Object} [object=lodash] The destination object.
15642 * @param {Object} source The object of functions to add.
15643 * @param {Object} [options={}] The options object.
15644 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
15645 * @returns {Function|Object} Returns `object`.
15648 * function vowels(string) {
15649 * return _.filter(string, function(v) {
15650 * return /[aeiou]/i.test(v);
15654 * _.mixin({ 'vowels': vowels });
15655 * _.vowels('fred');
15658 * _('fred').vowels().value();
15661 * _.mixin({ 'vowels': vowels }, { 'chain': false });
15662 * _('fred').vowels();
15665 function mixin(object, source, options) {
15666 var props = keys(source),
15667 methodNames = baseFunctions(source, props);
15669 if (options == null &&
15670 !(isObject(source) && (methodNames.length || !props.length))) {
15674 methodNames = baseFunctions(source, keys(source));
15676 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
15677 isFunc = isFunction(object);
15679 arrayEach(methodNames, function(methodName) {
15680 var func = source[methodName];
15681 object[methodName] = func;
15683 object.prototype[methodName] = function() {
15684 var chainAll = this.__chain__;
15685 if (chain || chainAll) {
15686 var result = object(this.__wrapped__),
15687 actions = result.__actions__ = copyArray(this.__actions__);
15689 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
15690 result.__chain__ = chainAll;
15693 return func.apply(object, arrayPush([this.value()], arguments));
15702 * Reverts the `_` variable to its previous value and returns a reference to
15703 * the `lodash` function.
15709 * @returns {Function} Returns the `lodash` function.
15712 * var lodash = _.noConflict();
15714 function noConflict() {
15715 if (root._ === this) {
15722 * This method returns `undefined`.
15730 * _.times(2, _.noop);
15731 * // => [undefined, undefined]
15734 // No operation performed.
15738 * Creates a function that gets the argument at index `n`. If `n` is negative,
15739 * the nth argument from the end is returned.
15745 * @param {number} [n=0] The index of the argument to return.
15746 * @returns {Function} Returns the new pass-thru function.
15749 * var func = _.nthArg(1);
15750 * func('a', 'b', 'c', 'd');
15753 * var func = _.nthArg(-2);
15754 * func('a', 'b', 'c', 'd');
15757 function nthArg(n) {
15759 return baseRest(function(args) {
15760 return baseNth(args, n);
15765 * Creates a function that invokes `iteratees` with the arguments it receives
15766 * and returns their results.
15772 * @param {...(Function|Function[])} [iteratees=[_.identity]]
15773 * The iteratees to invoke.
15774 * @returns {Function} Returns the new function.
15777 * var func = _.over([Math.max, Math.min]);
15779 * func(1, 2, 3, 4);
15782 var over = createOver(arrayMap);
15785 * Creates a function that checks if **all** of the `predicates` return
15786 * truthy when invoked with the arguments it receives.
15792 * @param {...(Function|Function[])} [predicates=[_.identity]]
15793 * The predicates to check.
15794 * @returns {Function} Returns the new function.
15797 * var func = _.overEvery([Boolean, isFinite]);
15808 var overEvery = createOver(arrayEvery);
15811 * Creates a function that checks if **any** of the `predicates` return
15812 * truthy when invoked with the arguments it receives.
15818 * @param {...(Function|Function[])} [predicates=[_.identity]]
15819 * The predicates to check.
15820 * @returns {Function} Returns the new function.
15823 * var func = _.overSome([Boolean, isFinite]);
15834 var overSome = createOver(arraySome);
15837 * Creates a function that returns the value at `path` of a given object.
15843 * @param {Array|string} path The path of the property to get.
15844 * @returns {Function} Returns the new accessor function.
15848 * { 'a': { 'b': 2 } },
15849 * { 'a': { 'b': 1 } }
15852 * _.map(objects, _.property('a.b'));
15855 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
15858 function property(path) {
15859 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
15863 * The opposite of `_.property`; this method creates a function that returns
15864 * the value at a given path of `object`.
15870 * @param {Object} object The object to query.
15871 * @returns {Function} Returns the new accessor function.
15874 * var array = [0, 1, 2],
15875 * object = { 'a': array, 'b': array, 'c': array };
15877 * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
15880 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
15883 function propertyOf(object) {
15884 return function(path) {
15885 return object == null ? undefined : baseGet(object, path);
15890 * Creates an array of numbers (positive and/or negative) progressing from
15891 * `start` up to, but not including, `end`. A step of `-1` is used if a negative
15892 * `start` is specified without an `end` or `step`. If `end` is not specified,
15893 * it's set to `start` with `start` then set to `0`.
15895 * **Note:** JavaScript follows the IEEE-754 standard for resolving
15896 * floating-point values which can produce unexpected results.
15902 * @param {number} [start=0] The start of the range.
15903 * @param {number} end The end of the range.
15904 * @param {number} [step=1] The value to increment or decrement by.
15905 * @returns {Array} Returns the range of numbers.
15906 * @see _.inRange, _.rangeRight
15910 * // => [0, 1, 2, 3]
15913 * // => [0, -1, -2, -3]
15916 * // => [1, 2, 3, 4]
15918 * _.range(0, 20, 5);
15919 * // => [0, 5, 10, 15]
15921 * _.range(0, -4, -1);
15922 * // => [0, -1, -2, -3]
15924 * _.range(1, 4, 0);
15930 var range = createRange();
15933 * This method is like `_.range` except that it populates values in
15934 * descending order.
15940 * @param {number} [start=0] The start of the range.
15941 * @param {number} end The end of the range.
15942 * @param {number} [step=1] The value to increment or decrement by.
15943 * @returns {Array} Returns the range of numbers.
15944 * @see _.inRange, _.range
15948 * // => [3, 2, 1, 0]
15950 * _.rangeRight(-4);
15951 * // => [-3, -2, -1, 0]
15953 * _.rangeRight(1, 5);
15954 * // => [4, 3, 2, 1]
15956 * _.rangeRight(0, 20, 5);
15957 * // => [15, 10, 5, 0]
15959 * _.rangeRight(0, -4, -1);
15960 * // => [-3, -2, -1, 0]
15962 * _.rangeRight(1, 4, 0);
15968 var rangeRight = createRange(true);
15971 * This method returns a new empty array.
15977 * @returns {Array} Returns the new empty array.
15980 * var arrays = _.times(2, _.stubArray);
15982 * console.log(arrays);
15985 * console.log(arrays[0] === arrays[1]);
15988 function stubArray() {
15993 * This method returns `false`.
15999 * @returns {boolean} Returns `false`.
16002 * _.times(2, _.stubFalse);
16003 * // => [false, false]
16005 function stubFalse() {
16010 * This method returns a new empty object.
16016 * @returns {Object} Returns the new empty object.
16019 * var objects = _.times(2, _.stubObject);
16021 * console.log(objects);
16024 * console.log(objects[0] === objects[1]);
16027 function stubObject() {
16032 * This method returns an empty string.
16038 * @returns {string} Returns the empty string.
16041 * _.times(2, _.stubString);
16044 function stubString() {
16049 * This method returns `true`.
16055 * @returns {boolean} Returns `true`.
16058 * _.times(2, _.stubTrue);
16059 * // => [true, true]
16061 function stubTrue() {
16066 * Invokes the iteratee `n` times, returning an array of the results of
16067 * each invocation. The iteratee is invoked with one argument; (index).
16073 * @param {number} n The number of times to invoke `iteratee`.
16074 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16075 * @returns {Array} Returns the array of results.
16078 * _.times(3, String);
16079 * // => ['0', '1', '2']
16081 * _.times(4, _.constant(0));
16082 * // => [0, 0, 0, 0]
16084 function times(n, iteratee) {
16086 if (n < 1 || n > MAX_SAFE_INTEGER) {
16089 var index = MAX_ARRAY_LENGTH,
16090 length = nativeMin(n, MAX_ARRAY_LENGTH);
16092 iteratee = getIteratee(iteratee);
16093 n -= MAX_ARRAY_LENGTH;
16095 var result = baseTimes(length, iteratee);
16096 while (++index < n) {
16103 * Converts `value` to a property path array.
16109 * @param {*} value The value to convert.
16110 * @returns {Array} Returns the new property path array.
16113 * _.toPath('a.b.c');
16114 * // => ['a', 'b', 'c']
16116 * _.toPath('a[0].b.c');
16117 * // => ['a', '0', 'b', 'c']
16119 function toPath(value) {
16120 if (isArray(value)) {
16121 return arrayMap(value, toKey);
16123 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
16127 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16133 * @param {string} [prefix=''] The value to prefix the ID with.
16134 * @returns {string} Returns the unique ID.
16137 * _.uniqueId('contact_');
16138 * // => 'contact_104'
16143 function uniqueId(prefix) {
16144 var id = ++idCounter;
16145 return toString(prefix) + id;
16148 /*------------------------------------------------------------------------*/
16151 * Adds two numbers.
16157 * @param {number} augend The first number in an addition.
16158 * @param {number} addend The second number in an addition.
16159 * @returns {number} Returns the total.
16165 var add = createMathOperation(function(augend, addend) {
16166 return augend + addend;
16170 * Computes `number` rounded up to `precision`.
16176 * @param {number} number The number to round up.
16177 * @param {number} [precision=0] The precision to round up to.
16178 * @returns {number} Returns the rounded up number.
16184 * _.ceil(6.004, 2);
16187 * _.ceil(6040, -2);
16190 var ceil = createRound('ceil');
16193 * Divide two numbers.
16199 * @param {number} dividend The first number in a division.
16200 * @param {number} divisor The second number in a division.
16201 * @returns {number} Returns the quotient.
16207 var divide = createMathOperation(function(dividend, divisor) {
16208 return dividend / divisor;
16212 * Computes `number` rounded down to `precision`.
16218 * @param {number} number The number to round down.
16219 * @param {number} [precision=0] The precision to round down to.
16220 * @returns {number} Returns the rounded down number.
16226 * _.floor(0.046, 2);
16229 * _.floor(4060, -2);
16232 var floor = createRound('floor');
16235 * Computes the maximum value of `array`. If `array` is empty or falsey,
16236 * `undefined` is returned.
16242 * @param {Array} array The array to iterate over.
16243 * @returns {*} Returns the maximum value.
16246 * _.max([4, 2, 8, 6]);
16252 function max(array) {
16253 return (array && array.length)
16254 ? baseExtremum(array, identity, baseGt)
16259 * This method is like `_.max` except that it accepts `iteratee` which is
16260 * invoked for each element in `array` to generate the criterion by which
16261 * the value is ranked. The iteratee is invoked with one argument: (value).
16267 * @param {Array} array The array to iterate over.
16268 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16269 * @returns {*} Returns the maximum value.
16272 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16274 * _.maxBy(objects, function(o) { return o.n; });
16277 * // The `_.property` iteratee shorthand.
16278 * _.maxBy(objects, 'n');
16281 function maxBy(array, iteratee) {
16282 return (array && array.length)
16283 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
16288 * Computes the mean of the values in `array`.
16294 * @param {Array} array The array to iterate over.
16295 * @returns {number} Returns the mean.
16298 * _.mean([4, 2, 8, 6]);
16301 function mean(array) {
16302 return baseMean(array, identity);
16306 * This method is like `_.mean` except that it accepts `iteratee` which is
16307 * invoked for each element in `array` to generate the value to be averaged.
16308 * The iteratee is invoked with one argument: (value).
16314 * @param {Array} array The array to iterate over.
16315 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16316 * @returns {number} Returns the mean.
16319 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16321 * _.meanBy(objects, function(o) { return o.n; });
16324 * // The `_.property` iteratee shorthand.
16325 * _.meanBy(objects, 'n');
16328 function meanBy(array, iteratee) {
16329 return baseMean(array, getIteratee(iteratee, 2));
16333 * Computes the minimum value of `array`. If `array` is empty or falsey,
16334 * `undefined` is returned.
16340 * @param {Array} array The array to iterate over.
16341 * @returns {*} Returns the minimum value.
16344 * _.min([4, 2, 8, 6]);
16350 function min(array) {
16351 return (array && array.length)
16352 ? baseExtremum(array, identity, baseLt)
16357 * This method is like `_.min` except that it accepts `iteratee` which is
16358 * invoked for each element in `array` to generate the criterion by which
16359 * the value is ranked. The iteratee is invoked with one argument: (value).
16365 * @param {Array} array The array to iterate over.
16366 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16367 * @returns {*} Returns the minimum value.
16370 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16372 * _.minBy(objects, function(o) { return o.n; });
16375 * // The `_.property` iteratee shorthand.
16376 * _.minBy(objects, 'n');
16379 function minBy(array, iteratee) {
16380 return (array && array.length)
16381 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
16386 * Multiply two numbers.
16392 * @param {number} multiplier The first number in a multiplication.
16393 * @param {number} multiplicand The second number in a multiplication.
16394 * @returns {number} Returns the product.
16397 * _.multiply(6, 4);
16400 var multiply = createMathOperation(function(multiplier, multiplicand) {
16401 return multiplier * multiplicand;
16405 * Computes `number` rounded to `precision`.
16411 * @param {number} number The number to round.
16412 * @param {number} [precision=0] The precision to round to.
16413 * @returns {number} Returns the rounded number.
16419 * _.round(4.006, 2);
16422 * _.round(4060, -2);
16425 var round = createRound('round');
16428 * Subtract two numbers.
16434 * @param {number} minuend The first number in a subtraction.
16435 * @param {number} subtrahend The second number in a subtraction.
16436 * @returns {number} Returns the difference.
16439 * _.subtract(6, 4);
16442 var subtract = createMathOperation(function(minuend, subtrahend) {
16443 return minuend - subtrahend;
16447 * Computes the sum of the values in `array`.
16453 * @param {Array} array The array to iterate over.
16454 * @returns {number} Returns the sum.
16457 * _.sum([4, 2, 8, 6]);
16460 function sum(array) {
16461 return (array && array.length)
16462 ? baseSum(array, identity)
16467 * This method is like `_.sum` except that it accepts `iteratee` which is
16468 * invoked for each element in `array` to generate the value to be summed.
16469 * The iteratee is invoked with one argument: (value).
16475 * @param {Array} array The array to iterate over.
16476 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16477 * @returns {number} Returns the sum.
16480 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16482 * _.sumBy(objects, function(o) { return o.n; });
16485 * // The `_.property` iteratee shorthand.
16486 * _.sumBy(objects, 'n');
16489 function sumBy(array, iteratee) {
16490 return (array && array.length)
16491 ? baseSum(array, getIteratee(iteratee, 2))
16495 /*------------------------------------------------------------------------*/
16497 // Add methods that return wrapped values in chain sequences.
16498 lodash.after = after;
16500 lodash.assign = assign;
16501 lodash.assignIn = assignIn;
16502 lodash.assignInWith = assignInWith;
16503 lodash.assignWith = assignWith;
16505 lodash.before = before;
16506 lodash.bind = bind;
16507 lodash.bindAll = bindAll;
16508 lodash.bindKey = bindKey;
16509 lodash.castArray = castArray;
16510 lodash.chain = chain;
16511 lodash.chunk = chunk;
16512 lodash.compact = compact;
16513 lodash.concat = concat;
16514 lodash.cond = cond;
16515 lodash.conforms = conforms;
16516 lodash.constant = constant;
16517 lodash.countBy = countBy;
16518 lodash.create = create;
16519 lodash.curry = curry;
16520 lodash.curryRight = curryRight;
16521 lodash.debounce = debounce;
16522 lodash.defaults = defaults;
16523 lodash.defaultsDeep = defaultsDeep;
16524 lodash.defer = defer;
16525 lodash.delay = delay;
16526 lodash.difference = difference;
16527 lodash.differenceBy = differenceBy;
16528 lodash.differenceWith = differenceWith;
16529 lodash.drop = drop;
16530 lodash.dropRight = dropRight;
16531 lodash.dropRightWhile = dropRightWhile;
16532 lodash.dropWhile = dropWhile;
16533 lodash.fill = fill;
16534 lodash.filter = filter;
16535 lodash.flatMap = flatMap;
16536 lodash.flatMapDeep = flatMapDeep;
16537 lodash.flatMapDepth = flatMapDepth;
16538 lodash.flatten = flatten;
16539 lodash.flattenDeep = flattenDeep;
16540 lodash.flattenDepth = flattenDepth;
16541 lodash.flip = flip;
16542 lodash.flow = flow;
16543 lodash.flowRight = flowRight;
16544 lodash.fromPairs = fromPairs;
16545 lodash.functions = functions;
16546 lodash.functionsIn = functionsIn;
16547 lodash.groupBy = groupBy;
16548 lodash.initial = initial;
16549 lodash.intersection = intersection;
16550 lodash.intersectionBy = intersectionBy;
16551 lodash.intersectionWith = intersectionWith;
16552 lodash.invert = invert;
16553 lodash.invertBy = invertBy;
16554 lodash.invokeMap = invokeMap;
16555 lodash.iteratee = iteratee;
16556 lodash.keyBy = keyBy;
16557 lodash.keys = keys;
16558 lodash.keysIn = keysIn;
16560 lodash.mapKeys = mapKeys;
16561 lodash.mapValues = mapValues;
16562 lodash.matches = matches;
16563 lodash.matchesProperty = matchesProperty;
16564 lodash.memoize = memoize;
16565 lodash.merge = merge;
16566 lodash.mergeWith = mergeWith;
16567 lodash.method = method;
16568 lodash.methodOf = methodOf;
16569 lodash.mixin = mixin;
16570 lodash.negate = negate;
16571 lodash.nthArg = nthArg;
16572 lodash.omit = omit;
16573 lodash.omitBy = omitBy;
16574 lodash.once = once;
16575 lodash.orderBy = orderBy;
16576 lodash.over = over;
16577 lodash.overArgs = overArgs;
16578 lodash.overEvery = overEvery;
16579 lodash.overSome = overSome;
16580 lodash.partial = partial;
16581 lodash.partialRight = partialRight;
16582 lodash.partition = partition;
16583 lodash.pick = pick;
16584 lodash.pickBy = pickBy;
16585 lodash.property = property;
16586 lodash.propertyOf = propertyOf;
16587 lodash.pull = pull;
16588 lodash.pullAll = pullAll;
16589 lodash.pullAllBy = pullAllBy;
16590 lodash.pullAllWith = pullAllWith;
16591 lodash.pullAt = pullAt;
16592 lodash.range = range;
16593 lodash.rangeRight = rangeRight;
16594 lodash.rearg = rearg;
16595 lodash.reject = reject;
16596 lodash.remove = remove;
16597 lodash.rest = rest;
16598 lodash.reverse = reverse;
16599 lodash.sampleSize = sampleSize;
16601 lodash.setWith = setWith;
16602 lodash.shuffle = shuffle;
16603 lodash.slice = slice;
16604 lodash.sortBy = sortBy;
16605 lodash.sortedUniq = sortedUniq;
16606 lodash.sortedUniqBy = sortedUniqBy;
16607 lodash.split = split;
16608 lodash.spread = spread;
16609 lodash.tail = tail;
16610 lodash.take = take;
16611 lodash.takeRight = takeRight;
16612 lodash.takeRightWhile = takeRightWhile;
16613 lodash.takeWhile = takeWhile;
16615 lodash.throttle = throttle;
16616 lodash.thru = thru;
16617 lodash.toArray = toArray;
16618 lodash.toPairs = toPairs;
16619 lodash.toPairsIn = toPairsIn;
16620 lodash.toPath = toPath;
16621 lodash.toPlainObject = toPlainObject;
16622 lodash.transform = transform;
16623 lodash.unary = unary;
16624 lodash.union = union;
16625 lodash.unionBy = unionBy;
16626 lodash.unionWith = unionWith;
16627 lodash.uniq = uniq;
16628 lodash.uniqBy = uniqBy;
16629 lodash.uniqWith = uniqWith;
16630 lodash.unset = unset;
16631 lodash.unzip = unzip;
16632 lodash.unzipWith = unzipWith;
16633 lodash.update = update;
16634 lodash.updateWith = updateWith;
16635 lodash.values = values;
16636 lodash.valuesIn = valuesIn;
16637 lodash.without = without;
16638 lodash.words = words;
16639 lodash.wrap = wrap;
16641 lodash.xorBy = xorBy;
16642 lodash.xorWith = xorWith;
16644 lodash.zipObject = zipObject;
16645 lodash.zipObjectDeep = zipObjectDeep;
16646 lodash.zipWith = zipWith;
16649 lodash.entries = toPairs;
16650 lodash.entriesIn = toPairsIn;
16651 lodash.extend = assignIn;
16652 lodash.extendWith = assignInWith;
16654 // Add methods to `lodash.prototype`.
16655 mixin(lodash, lodash);
16657 /*------------------------------------------------------------------------*/
16659 // Add methods that return unwrapped values in chain sequences.
16661 lodash.attempt = attempt;
16662 lodash.camelCase = camelCase;
16663 lodash.capitalize = capitalize;
16664 lodash.ceil = ceil;
16665 lodash.clamp = clamp;
16666 lodash.clone = clone;
16667 lodash.cloneDeep = cloneDeep;
16668 lodash.cloneDeepWith = cloneDeepWith;
16669 lodash.cloneWith = cloneWith;
16670 lodash.conformsTo = conformsTo;
16671 lodash.deburr = deburr;
16672 lodash.defaultTo = defaultTo;
16673 lodash.divide = divide;
16674 lodash.endsWith = endsWith;
16676 lodash.escape = escape;
16677 lodash.escapeRegExp = escapeRegExp;
16678 lodash.every = every;
16679 lodash.find = find;
16680 lodash.findIndex = findIndex;
16681 lodash.findKey = findKey;
16682 lodash.findLast = findLast;
16683 lodash.findLastIndex = findLastIndex;
16684 lodash.findLastKey = findLastKey;
16685 lodash.floor = floor;
16686 lodash.forEach = forEach;
16687 lodash.forEachRight = forEachRight;
16688 lodash.forIn = forIn;
16689 lodash.forInRight = forInRight;
16690 lodash.forOwn = forOwn;
16691 lodash.forOwnRight = forOwnRight;
16696 lodash.hasIn = hasIn;
16697 lodash.head = head;
16698 lodash.identity = identity;
16699 lodash.includes = includes;
16700 lodash.indexOf = indexOf;
16701 lodash.inRange = inRange;
16702 lodash.invoke = invoke;
16703 lodash.isArguments = isArguments;
16704 lodash.isArray = isArray;
16705 lodash.isArrayBuffer = isArrayBuffer;
16706 lodash.isArrayLike = isArrayLike;
16707 lodash.isArrayLikeObject = isArrayLikeObject;
16708 lodash.isBoolean = isBoolean;
16709 lodash.isBuffer = isBuffer;
16710 lodash.isDate = isDate;
16711 lodash.isElement = isElement;
16712 lodash.isEmpty = isEmpty;
16713 lodash.isEqual = isEqual;
16714 lodash.isEqualWith = isEqualWith;
16715 lodash.isError = isError;
16716 lodash.isFinite = isFinite;
16717 lodash.isFunction = isFunction;
16718 lodash.isInteger = isInteger;
16719 lodash.isLength = isLength;
16720 lodash.isMap = isMap;
16721 lodash.isMatch = isMatch;
16722 lodash.isMatchWith = isMatchWith;
16723 lodash.isNaN = isNaN;
16724 lodash.isNative = isNative;
16725 lodash.isNil = isNil;
16726 lodash.isNull = isNull;
16727 lodash.isNumber = isNumber;
16728 lodash.isObject = isObject;
16729 lodash.isObjectLike = isObjectLike;
16730 lodash.isPlainObject = isPlainObject;
16731 lodash.isRegExp = isRegExp;
16732 lodash.isSafeInteger = isSafeInteger;
16733 lodash.isSet = isSet;
16734 lodash.isString = isString;
16735 lodash.isSymbol = isSymbol;
16736 lodash.isTypedArray = isTypedArray;
16737 lodash.isUndefined = isUndefined;
16738 lodash.isWeakMap = isWeakMap;
16739 lodash.isWeakSet = isWeakSet;
16740 lodash.join = join;
16741 lodash.kebabCase = kebabCase;
16742 lodash.last = last;
16743 lodash.lastIndexOf = lastIndexOf;
16744 lodash.lowerCase = lowerCase;
16745 lodash.lowerFirst = lowerFirst;
16749 lodash.maxBy = maxBy;
16750 lodash.mean = mean;
16751 lodash.meanBy = meanBy;
16753 lodash.minBy = minBy;
16754 lodash.stubArray = stubArray;
16755 lodash.stubFalse = stubFalse;
16756 lodash.stubObject = stubObject;
16757 lodash.stubString = stubString;
16758 lodash.stubTrue = stubTrue;
16759 lodash.multiply = multiply;
16761 lodash.noConflict = noConflict;
16762 lodash.noop = noop;
16765 lodash.padEnd = padEnd;
16766 lodash.padStart = padStart;
16767 lodash.parseInt = parseInt;
16768 lodash.random = random;
16769 lodash.reduce = reduce;
16770 lodash.reduceRight = reduceRight;
16771 lodash.repeat = repeat;
16772 lodash.replace = replace;
16773 lodash.result = result;
16774 lodash.round = round;
16775 lodash.runInContext = runInContext;
16776 lodash.sample = sample;
16777 lodash.size = size;
16778 lodash.snakeCase = snakeCase;
16779 lodash.some = some;
16780 lodash.sortedIndex = sortedIndex;
16781 lodash.sortedIndexBy = sortedIndexBy;
16782 lodash.sortedIndexOf = sortedIndexOf;
16783 lodash.sortedLastIndex = sortedLastIndex;
16784 lodash.sortedLastIndexBy = sortedLastIndexBy;
16785 lodash.sortedLastIndexOf = sortedLastIndexOf;
16786 lodash.startCase = startCase;
16787 lodash.startsWith = startsWith;
16788 lodash.subtract = subtract;
16790 lodash.sumBy = sumBy;
16791 lodash.template = template;
16792 lodash.times = times;
16793 lodash.toFinite = toFinite;
16794 lodash.toInteger = toInteger;
16795 lodash.toLength = toLength;
16796 lodash.toLower = toLower;
16797 lodash.toNumber = toNumber;
16798 lodash.toSafeInteger = toSafeInteger;
16799 lodash.toString = toString;
16800 lodash.toUpper = toUpper;
16801 lodash.trim = trim;
16802 lodash.trimEnd = trimEnd;
16803 lodash.trimStart = trimStart;
16804 lodash.truncate = truncate;
16805 lodash.unescape = unescape;
16806 lodash.uniqueId = uniqueId;
16807 lodash.upperCase = upperCase;
16808 lodash.upperFirst = upperFirst;
16811 lodash.each = forEach;
16812 lodash.eachRight = forEachRight;
16813 lodash.first = head;
16815 mixin(lodash, (function() {
16817 baseForOwn(lodash, function(func, methodName) {
16818 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
16819 source[methodName] = func;
16823 }()), { 'chain': false });
16825 /*------------------------------------------------------------------------*/
16828 * The semantic version number.
16834 lodash.VERSION = VERSION;
16836 // Assign default placeholders.
16837 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
16838 lodash[methodName].placeholder = lodash;
16841 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
16842 arrayEach(['drop', 'take'], function(methodName, index) {
16843 LazyWrapper.prototype[methodName] = function(n) {
16844 n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
16846 var result = (this.__filtered__ && !index)
16847 ? new LazyWrapper(this)
16850 if (result.__filtered__) {
16851 result.__takeCount__ = nativeMin(n, result.__takeCount__);
16853 result.__views__.push({
16854 'size': nativeMin(n, MAX_ARRAY_LENGTH),
16855 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
16861 LazyWrapper.prototype[methodName + 'Right'] = function(n) {
16862 return this.reverse()[methodName](n).reverse();
16866 // Add `LazyWrapper` methods that accept an `iteratee` value.
16867 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
16868 var type = index + 1,
16869 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
16871 LazyWrapper.prototype[methodName] = function(iteratee) {
16872 var result = this.clone();
16873 result.__iteratees__.push({
16874 'iteratee': getIteratee(iteratee, 3),
16877 result.__filtered__ = result.__filtered__ || isFilter;
16882 // Add `LazyWrapper` methods for `_.head` and `_.last`.
16883 arrayEach(['head', 'last'], function(methodName, index) {
16884 var takeName = 'take' + (index ? 'Right' : '');
16886 LazyWrapper.prototype[methodName] = function() {
16887 return this[takeName](1).value()[0];
16891 // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
16892 arrayEach(['initial', 'tail'], function(methodName, index) {
16893 var dropName = 'drop' + (index ? '' : 'Right');
16895 LazyWrapper.prototype[methodName] = function() {
16896 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
16900 LazyWrapper.prototype.compact = function() {
16901 return this.filter(identity);
16904 LazyWrapper.prototype.find = function(predicate) {
16905 return this.filter(predicate).head();
16908 LazyWrapper.prototype.findLast = function(predicate) {
16909 return this.reverse().find(predicate);
16912 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
16913 if (typeof path == 'function') {
16914 return new LazyWrapper(this);
16916 return this.map(function(value) {
16917 return baseInvoke(value, path, args);
16921 LazyWrapper.prototype.reject = function(predicate) {
16922 return this.filter(negate(getIteratee(predicate)));
16925 LazyWrapper.prototype.slice = function(start, end) {
16926 start = toInteger(start);
16929 if (result.__filtered__ && (start > 0 || end < 0)) {
16930 return new LazyWrapper(result);
16933 result = result.takeRight(-start);
16934 } else if (start) {
16935 result = result.drop(start);
16937 if (end !== undefined) {
16938 end = toInteger(end);
16939 result = end < 0 ? result.dropRight(-end) : result.take(end - start);
16944 LazyWrapper.prototype.takeRightWhile = function(predicate) {
16945 return this.reverse().takeWhile(predicate).reverse();
16948 LazyWrapper.prototype.toArray = function() {
16949 return this.take(MAX_ARRAY_LENGTH);
16952 // Add `LazyWrapper` methods to `lodash.prototype`.
16953 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
16954 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
16955 isTaker = /^(?:head|last)$/.test(methodName),
16956 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
16957 retUnwrapped = isTaker || /^find/.test(methodName);
16962 lodash.prototype[methodName] = function() {
16963 var value = this.__wrapped__,
16964 args = isTaker ? [1] : arguments,
16965 isLazy = value instanceof LazyWrapper,
16966 iteratee = args[0],
16967 useLazy = isLazy || isArray(value);
16969 var interceptor = function(value) {
16970 var result = lodashFunc.apply(lodash, arrayPush([value], args));
16971 return (isTaker && chainAll) ? result[0] : result;
16974 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
16975 // Avoid lazy use if the iteratee has a "length" value other than `1`.
16976 isLazy = useLazy = false;
16978 var chainAll = this.__chain__,
16979 isHybrid = !!this.__actions__.length,
16980 isUnwrapped = retUnwrapped && !chainAll,
16981 onlyLazy = isLazy && !isHybrid;
16983 if (!retUnwrapped && useLazy) {
16984 value = onlyLazy ? value : new LazyWrapper(this);
16985 var result = func.apply(value, args);
16986 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
16987 return new LodashWrapper(result, chainAll);
16989 if (isUnwrapped && onlyLazy) {
16990 return func.apply(this, args);
16992 result = this.thru(interceptor);
16993 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
16997 // Add `Array` methods to `lodash.prototype`.
16998 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
16999 var func = arrayProto[methodName],
17000 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
17001 retUnwrapped = /^(?:pop|shift)$/.test(methodName);
17003 lodash.prototype[methodName] = function() {
17004 var args = arguments;
17005 if (retUnwrapped && !this.__chain__) {
17006 var value = this.value();
17007 return func.apply(isArray(value) ? value : [], args);
17009 return this[chainName](function(value) {
17010 return func.apply(isArray(value) ? value : [], args);
17015 // Map minified method names to their real names.
17016 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17017 var lodashFunc = lodash[methodName];
17019 var key = (lodashFunc.name + ''),
17020 names = realNames[key] || (realNames[key] = []);
17022 names.push({ 'name': methodName, 'func': lodashFunc });
17026 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
17031 // Add methods to `LazyWrapper`.
17032 LazyWrapper.prototype.clone = lazyClone;
17033 LazyWrapper.prototype.reverse = lazyReverse;
17034 LazyWrapper.prototype.value = lazyValue;
17036 // Add chain sequence methods to the `lodash` wrapper.
17037 lodash.prototype.at = wrapperAt;
17038 lodash.prototype.chain = wrapperChain;
17039 lodash.prototype.commit = wrapperCommit;
17040 lodash.prototype.next = wrapperNext;
17041 lodash.prototype.plant = wrapperPlant;
17042 lodash.prototype.reverse = wrapperReverse;
17043 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
17045 // Add lazy aliases.
17046 lodash.prototype.first = lodash.prototype.head;
17049 lodash.prototype[symIterator] = wrapperToIterator;
17054 /*--------------------------------------------------------------------------*/
17057 var _ = runInContext();
17059 // Some AMD build optimizers, like r.js, check for condition patterns like:
17060 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
17061 // Expose Lodash on the global object to prevent errors when Lodash is
17062 // loaded by a script tag in the presence of an AMD loader.
17063 // See http://requirejs.org/docs/errors.html#mismatch for more details.
17064 // Use `_.noConflict` to remove Lodash from the global object.
17067 // Define as an anonymous module so, through path mapping, it can be
17068 // referenced as the "underscore" module.
17069 define(function() {
17073 // Check for `exports` after `define` in case a build optimizer adds it.
17074 else if (freeModule) {
17075 // Export for Node.js.
17076 (freeModule.exports = _)._ = _;
17077 // Export for CommonJS support.
17081 // Export to the global object.