1/*1732796878000*/ 2/** 3 * @license 4 * Lodash <https://lodash.com/> 5 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 6 * Released under MIT license <https://lodash.com/license> 7 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 8 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 9 */ 10;(function() { 11 12 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 13 var undefined
vendor: 12,195 bytes, lines 13-316
13; 14 15 /** Used as the semantic version number. */ 16 var VERSION = '4.17.21'; 17 18 /** Used as the size to enable large array optimizations. */ 19 var LARGE_ARRAY_SIZE = 200; 20 21 /** Error message constants. */ 22 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 23 FUNC_ERROR_TEXT = 'Expected a function', 24 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; 25 26 /** Used to stand-in for `undefined` hash values. */ 27 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 28 29 /** Used as the maximum memoize cache size. */ 30 var MAX_MEMOIZE_SIZE = 500; 31 32 /** Used as the internal argument placeholder. */ 33 var PLACEHOLDER = '__lodash_placeholder__'; 34 35 /** Used to compose bitmasks for cloning. */ 36 var CLONE_DEEP_FLAG = 1, 37 CLONE_FLAT_FLAG = 2, 38 CLONE_SYMBOLS_FLAG = 4; 39 40 /** Used to compose bitmasks for value comparisons. */ 41 var COMPARE_PARTIAL_FLAG = 1, 42 COMPARE_UNORDERED_FLAG = 2; 43 44 /** Used to compose bitmasks for function metadata. */ 45 var WRAP_BIND_FLAG = 1, 46 WRAP_BIND_KEY_FLAG = 2, 47 WRAP_CURRY_BOUND_FLAG = 4, 48 WRAP_CURRY_FLAG = 8, 49 WRAP_CURRY_RIGHT_FLAG = 16, 50 WRAP_PARTIAL_FLAG = 32, 51 WRAP_PARTIAL_RIGHT_FLAG = 64, 52 WRAP_ARY_FLAG = 128, 53 WRAP_REARG_FLAG = 256, 54 WRAP_FLIP_FLAG = 512; 55 56 /** Used as default options for `_.truncate`. */ 57 var DEFAULT_TRUNC_LENGTH = 30, 58 DEFAULT_TRUNC_OMISSION = '...'; 59 60 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 61 var HOT_COUNT = 800, 62 HOT_SPAN = 16; 63 64 /** Used to indicate the type of lazy iteratees. */ 65 var LAZY_FILTER_FLAG = 1, 66 LAZY_MAP_FLAG = 2, 67 LAZY_WHILE_FLAG = 3; 68 69 /** Used as references for various `Number` constants. */ 70 var INFINITY = 1 / 0, 71 MAX_SAFE_INTEGER = 9007199254740991, 72 MAX_INTEGER = 1.7976931348623157e+308, 73 NAN = 0 / 0; 74 75 /** Used as references for the maximum length and index of an array. */ 76 var MAX_ARRAY_LENGTH = 4294967295, 77 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 78 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 79 80 /** Used to associate wrap methods with their bit flags. */ 81 var wrapFlags = [ 82 ['ary', WRAP_ARY_FLAG], 83 ['bind', WRAP_BIND_FLAG], 84 ['bindKey', WRAP_BIND_KEY_FLAG], 85 ['curry', WRAP_CURRY_FLAG], 86 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 87 ['flip', WRAP_FLIP_FLAG], 88 ['partial', WRAP_PARTIAL_FLAG], 89 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 90 ['rearg', WRAP_REARG_FLAG] 91 ]; 92 93 /** `Object#toString` result references. */ 94 var argsTag = '[object Arguments]', 95 arrayTag = '[object Array]', 96 asyncTag = '[object AsyncFunction]', 97 boolTag = '[object Boolean]', 98 dateTag = '[object Date]', 99 domExcTag = '[object DOMException]', 100 errorTag = '[object Error]', 101 funcTag = '[object Function]', 102 genTag = '[object GeneratorFunction]', 103 mapTag = '[object Map]', 104 numberTag = '[object Number]', 105 nullTag = '[object Null]', 106 objectTag = '[object Object]', 107 promiseTag = '[object Promise]', 108 proxyTag = '[object Proxy]', 109 regexpTag = '[object RegExp]', 110 setTag = '[object Set]', 111 stringTag = '[object String]', 112 symbolTag = '[object Symbol]', 113 undefinedTag = '[object Undefined]', 114 weakMapTag = '[object WeakMap]', 115 weakSetTag = '[object WeakSet]'; 116 117 var arrayBufferTag = '[object ArrayBuffer]', 118 dataViewTag = '[object DataView]', 119 float32Tag = '[object Float32Array]', 120 float64Tag = '[object Float64Array]', 121 int8Tag = '[object Int8Array]', 122 int16Tag = '[object Int16Array]', 123 int32Tag = '[object Int32Array]', 124 uint8Tag = '[object Uint8Array]', 125 uint8ClampedTag = '[object Uint8ClampedArray]', 126 uint16Tag = '[object Uint16Array]', 127 uint32Tag = '[object Uint32Array]'; 128 129 /** Used to match empty string literals in compiled template source. */ 130 var reEmptyStringLeading = /\b__p \+= '';/g, 131 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 132 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 133 134 /** Used to match HTML entities and HTML characters. */ 135 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 136 reUnescapedHtml = /[&<>"']/g, 137 reHasEscapedHtml = RegExp(reEscapedHtml.source), 138 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 139 140 /** Used to match template delimiters. */ 141 var reEscape = /<%-([\s\S]+?)%>/g, 142 reEvaluate = /<%([\s\S]+?)%>/g, 143 reInterpolate = /<%=([\s\S]+?)%>/g; 144 145 /** Used to match property names within property paths. */ 146 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 147 reIsPlainProp = /^\w*$/, 148 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 149 150 /** 151 * Used to match `RegExp` 152 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 153 */ 154 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 155 reHasRegExpChar = RegExp(reRegExpChar.source); 156 157 /** Used to match leading whitespace. */ 158 var reTrimStart = /^\s+/; 159 160 /** Used to match a single whitespace character. */ 161 var reWhitespace = /\s/; 162 163 /** Used to match wrap detail comments. */ 164 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 165 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 166 reSplitDetails = /,? & /; 167 168 /** Used to match words composed of alphanumeric characters. */ 169 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 170 171 /** 172 * Used to validate the `validate` option in `_.template` variable. 173 * 174 * Forbids characters which could potentially change the meaning of the function argument definition: 175 * - "()," (modification of function parameters) 176 * - "=" (default value) 177 * - "[]{}" (destructuring of function parameters) 178 * - "/" (beginning of a comment) 179 * - whitespace 180 */ 181 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; 182 183 /** Used to match backslashes in property paths. */ 184 var reEscapeChar = /\\(\\)?/g; 185 186 /** 187 * Used to match 188 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 189 */ 190 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 191 192 /** Used to match `RegExp` flags from their coerced string values. */ 193 var reFlags = /\w*$/; 194 195 /** Used to detect bad signed hexadecimal string values. */ 196 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 197 198 /** Used to detect binary string values. */ 199 var reIsBinary = /^0b[01]+$/i; 200 201 /** Used to detect host constructors (Safari). */ 202 var reIsHostCtor = /^\[object .+?Constructor\]$/; 203 204 /** Used to detect octal string values. */ 205 var reIsOctal = /^0o[0-7]+$/i; 206 207 /** Used to detect unsigned integer values. */ 208 var reIsUint = /^(?:0|[1-9]\d*)$/; 209 210 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 211 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 212 213 /** Used to ensure capturing order of template delimiters. */ 214 var reNoMatch = /($^)/; 215 216 /** Used to match unescaped characters in compiled string literals. */ 217 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 218 219 /** Used to compose unicode character classes. */ 220 var rsAstralRange = '\\ud800-\\udfff', 221 rsComboMarksRange = '\\u0300-\\u036f', 222 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 223 rsComboSymbolsRange = '\\u20d0-\\u20ff', 224 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 225 rsDingbatRange = '\\u2700-\\u27bf', 226 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 227 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 228 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 229 rsPunctuationRange = '\\u2000-\\u206f', 230 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', 231 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 232 rsVarRange = '\\ufe0e\\ufe0f', 233 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 234 235 /** Used to compose unicode capture groups. */ 236 var rsApos = "['\u2019]", 237 rsAstral = '[' + rsAstralRange + ']', 238 rsBreak = '[' + rsBreakRange + ']', 239 rsCombo = '[' + rsComboRange + ']', 240 rsDigits = '\\d+', 241 rsDingbat = '[' + rsDingbatRange + ']', 242 rsLower = '[' + rsLowerRange + ']', 243 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 244 rsFitz = '\\ud83c[\\udffb-\\udfff]', 245 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 246 rsNonAstral = '[^' + rsAstralRange + ']', 247 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 248 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 249 rsUpper = '[' + rsUpperRange + ']', 250 rsZWJ = '\\u200d'; 251 252 /** Used to compose unicode regexes. */ 253 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 254 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 255 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 256 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 257 reOptMod = rsModifier + '?', 258 rsOptVar = '[' + rsVarRange + ']?', 259 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 260 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 261 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 262 rsSeq = rsOptVar + reOptMod + rsOptJoin, 263 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 264 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 265 266 /** Used to match apostrophes. */ 267 var reApos = RegExp(rsApos, 'g'); 268 269 /** 270 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 271 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 272 */ 273 var reComboMark = RegExp(rsCombo, 'g'); 274 275 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 276 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 277 278 /** Used to match complex or compound words. */ 279 var reUnicodeWord = RegExp([ 280 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 281 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 282 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 283 rsUpper + '+' + rsOptContrUpper, 284 rsOrdUpper, 285 rsOrdLower, 286 rsDigits, 287 rsEmoji 288 ].join('|'), 'g'); 289 290 /** 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/). */ 291 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 292 293 /** Used to detect strings that need a more robust regexp to match words. */ 294 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 ]/; 295 296 /** Used to assign default `context` object properties. */ 297 var contextProps = [ 298 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 299 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 300 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 301 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 302 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 303 ]; 304 305 /** Used to make template sourceURLs easier to identify. */ 306 var templateCounter = -1; 307 308 /** Used to identify `toStringTag` values of typed arrays. */ 309 var typedArrayTags = {}; 310 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 311 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 312 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 313 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 314 typedArrayTags[uint32Tag] = true; 315 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 316 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
vendor: 5,923 bytes, lines 317-451
317 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 318 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 319 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 320 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 321 typedArrayTags[setTag] = typedArrayTags[stringTag] = 322 typedArrayTags[weakMapTag] = false; 323 324 /** Used to identify `toStringTag` values supported by `_.clone`. */ 325 var cloneableTags = {}; 326 cloneableTags[argsTag] = cloneableTags[arrayTag] = 327 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 328 cloneableTags[boolTag] = cloneableTags[dateTag] = 329 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 330 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 331 cloneableTags[int32Tag] = cloneableTags[mapTag] = 332 cloneableTags[numberTag] = cloneableTags[objectTag] = 333 cloneableTags[regexpTag] = cloneableTags[setTag] = 334 cloneableTags[stringTag] = cloneableTags[symbolTag] = 335 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 336 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 337 cloneableTags[errorTag] = cloneableTags[funcTag] = 338 cloneableTags[weakMapTag] = false; 339 340 /** Used to map Latin Unicode letters to basic Latin letters. */ 341 var deburredLetters = { 342 // Latin-1 Supplement block. 343 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 344 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 345 '\xc7': 'C', '\xe7': 'c', 346 '\xd0': 'D', '\xf0': 'd', 347 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 348 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 349 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 350 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 351 '\xd1': 'N', '\xf1': 'n', 352 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 353 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 354 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 355 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 356 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 357 '\xc6': 'Ae', '\xe6': 'ae', 358 '\xde': 'Th', '\xfe': 'th', 359 '\xdf': 'ss', 360 // Latin Extended-A block. 361 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 362 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 363 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 364 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 365 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 366 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 367 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 368 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 369 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 370 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 371 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 372 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 373 '\u0134': 'J', '\u0135': 'j', 374 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 375 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 376 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 377 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 378 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 379 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 380 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 381 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 382 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 383 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 384 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 385 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 386 '\u0163': 't', '\u0165': 't', '\u0167': 't', 387 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 388 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 389 '\u0174': 'W', '\u0175': 'w', 390 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 391 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 392 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 393 '\u0132': 'IJ', '\u0133': 'ij', 394 '\u0152': 'Oe', '\u0153': 'oe', 395 '\u0149': "'n", '\u017f': 's' 396 }; 397 398 /** Used to map characters to HTML entities. */ 399 var htmlEscapes = { 400 '&': '&', 401 '<': '<', 402 '>': '>', 403 '"': '"', 404 "'": ''' 405 }; 406 407 /** Used to map HTML entities to characters. */ 408 var htmlUnescapes = { 409 '&': '&', 410 '<': '<', 411 '>': '>', 412 '"': '"', 413 ''': "'" 414 }; 415 416 /** Used to escape characters for inclusion in compiled string literals. */ 417 var stringEscapes = { 418 '\\': '\\', 419 "'": "'", 420 '\n': 'n', 421 '\r': 'r', 422 '\u2028': 'u2028', 423 '\u2029': 'u2029' 424 }; 425 426 /** Built-in method references without a dependency on `root`. */ 427 var freeParseFloat = parseFloat, 428 freeParseInt = parseInt; 429 430 /** Detect free variable `global` from Node.js. */ 431 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 432 433 /** Detect free variable `self`. */ 434 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 435 436 /** Used as a reference to the global object. */ 437 var root = freeGlobal || freeSelf || Function('return this')(); 438 439 /** Detect free variable `exports`. */ 440 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; 441 442 /** Detect free variable `module`. */ 443 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 444 445 /** Detect the popular CommonJS extension `module.exports`. */ 446 var moduleExports = freeModule && freeModule.exports === freeExports; 447 448 /** Detect free variable `process` from Node.js. */ 449 var freeProcess = moduleExports && freeGlobal.process; 450 451 /** Used to access faster Node.js helpers. */
vendor: 8,860 bytes, lines 452-745
452 var nodeUtil = (function() { 453 try { 454 // Use `util.types` for Node.js 10+. 455 var types = freeModule && freeModule.require && freeModule.require('util').types; 456 457 if (types) { 458 return types; 459 } 460 461 // Legacy `process.binding('util')` for Node.js < 10. 462 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 463 } catch (e) {} 464 }()); 465 466 /* Node.js helper references. */ 467 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 468 nodeIsDate = nodeUtil && nodeUtil.isDate, 469 nodeIsMap = nodeUtil && nodeUtil.isMap, 470 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 471 nodeIsSet = nodeUtil && nodeUtil.isSet, 472 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 473 474 /*--------------------------------------------------------------------------*/ 475 476 /** 477 * A faster alternative to `Function#apply`, this function invokes `func` 478 * with the `this` binding of `thisArg` and the arguments of `args`. 479 * 480 * @private 481 * @param {Function} func The function to invoke. 482 * @param {*} thisArg The `this` binding of `func`. 483 * @param {Array} args The arguments to invoke `func` with. 484 * @returns {*} Returns the result of `func`. 485 */ 486 function apply(func, thisArg, args) { 487 switch (args.length) { 488 case 0: return func.call(thisArg); 489 case 1: return func.call(thisArg, args[0]); 490 case 2: return func.call(thisArg, args[0], args[1]); 491 case 3: return func.call(thisArg, args[0], args[1], args[2]); 492 } 493 return func.apply(thisArg, args); 494 } 495 496 /** 497 * A specialized version of `baseAggregator` for arrays. 498 * 499 * @private 500 * @param {Array} [array] The array to iterate over. 501 * @param {Function} setter The function to set `accumulator` values. 502 * @param {Function} iteratee The iteratee to transform keys. 503 * @param {Object} accumulator The initial aggregated object. 504 * @returns {Function} Returns `accumulator`. 505 */ 506 function arrayAggregator(array, setter, iteratee, accumulator) { 507 var index = -1, 508 length = array == null ? 0 : array.length; 509 510 while (++index < length) { 511 var value = array[index]; 512 setter(accumulator, value, iteratee(value), array); 513 } 514 return accumulator; 515 } 516 517 /** 518 * A specialized version of `_.forEach` for arrays without support for 519 * iteratee shorthands. 520 * 521 * @private 522 * @param {Array} [array] The array to iterate over. 523 * @param {Function} iteratee The function invoked per iteration. 524 * @returns {Array} Returns `array`. 525 */ 526 function arrayEach(array, iteratee) { 527 var index = -1, 528 length = array == null ? 0 : array.length; 529 530 while (++index < length) { 531 if (iteratee(array[index], index, array) === false) { 532 break; 533 } 534 } 535 return array; 536 } 537 538 /** 539 * A specialized version of `_.forEachRight` for arrays without support for 540 * iteratee shorthands. 541 * 542 * @private 543 * @param {Array} [array] The array to iterate over. 544 * @param {Function} iteratee The function invoked per iteration. 545 * @returns {Array} Returns `array`. 546 */ 547 function arrayEachRight(array, iteratee) { 548 var length = array == null ? 0 : array.length; 549 550 while (length--) { 551 if (iteratee(array[length], length, array) === false) { 552 break; 553 } 554 } 555 return array; 556 } 557 558 /** 559 * A specialized version of `_.every` for arrays without support for 560 * iteratee shorthands. 561 * 562 * @private 563 * @param {Array} [array] The array to iterate over. 564 * @param {Function} predicate The function invoked per iteration. 565 * @returns {boolean} Returns `true` if all elements pass the predicate check, 566 * else `false`. 567 */ 568 function arrayEvery(array, predicate) { 569 var index = -1, 570 length = array == null ? 0 : array.length; 571 572 while (++index < length) { 573 if (!predicate(array[index], index, array)) { 574 return false; 575 } 576 } 577 return true; 578 } 579 580 /** 581 * A specialized version of `_.filter` for arrays without support for 582 * iteratee shorthands. 583 * 584 * @private 585 * @param {Array} [array] The array to iterate over. 586 * @param {Function} predicate The function invoked per iteration. 587 * @returns {Array} Returns the new filtered array. 588 */ 589 function arrayFilter(array, predicate) { 590 var index = -1, 591 length = array == null ? 0 : array.length, 592 resIndex = 0, 593 result = []; 594 595 while (++index < length) { 596 var value = array[index]; 597 if (predicate(value, index, array)) { 598 result[resIndex++] = value; 599 } 600 } 601 return result; 602 } 603 604 /** 605 * A specialized version of `_.includes` for arrays without support for 606 * specifying an index to search from. 607 * 608 * @private 609 * @param {Array} [array] The array to inspect. 610 * @param {*} target The value to search for. 611 * @returns {boolean} Returns `true` if `target` is found, else `false`. 612 */ 613 function arrayIncludes(array, value) { 614 var length = array == null ? 0 : array.length; 615 return !!length && baseIndexOf(array, value, 0) > -1; 616 } 617 618 /** 619 * This function is like `arrayIncludes` except that it accepts a comparator. 620 * 621 * @private 622 * @param {Array} [array] The array to inspect. 623 * @param {*} target The value to search for. 624 * @param {Function} comparator The comparator invoked per element. 625 * @returns {boolean} Returns `true` if `target` is found, else `false`. 626 */ 627 function arrayIncludesWith(array, value, comparator) { 628 var index = -1, 629 length = array == null ? 0 : array.length; 630 631 while (++index < length) { 632 if (comparator(value, array[index])) { 633 return true; 634 } 635 } 636 return false; 637 } 638 639 /** 640 * A specialized version of `_.map` for arrays without support for iteratee 641 * shorthands. 642 * 643 * @private 644 * @param {Array} [array] The array to iterate over. 645 * @param {Function} iteratee The function invoked per iteration. 646 * @returns {Array} Returns the new mapped array. 647 */ 648 function arrayMap(array, iteratee) { 649 var index = -1, 650 length = array == null ? 0 : array.length, 651 result = Array(length); 652 653 while (++index < length) { 654 result[index] = iteratee(array[index], index, array); 655 } 656 return result; 657 } 658 659 /** 660 * Appends the elements of `values` to `array`. 661 * 662 * @private 663 * @param {Array} array The array to modify. 664 * @param {Array} values The values to append. 665 * @returns {Array} Returns `array`. 666 */ 667 function arrayPush(array, values) { 668 var index = -1, 669 length = values.length, 670 offset = array.length; 671 672 while (++index < length) { 673 array[offset + index] = values[index]; 674 } 675 return array; 676 } 677 678 /** 679 * A specialized version of `_.reduce` for arrays without support for 680 * iteratee shorthands. 681 * 682 * @private 683 * @param {Array} [array] The array to iterate over. 684 * @param {Function} iteratee The function invoked per iteration. 685 * @param {*} [accumulator] The initial value. 686 * @param {boolean} [initAccum] Specify using the first element of `array` as 687 * the initial value. 688 * @returns {*} Returns the accumulated value. 689 */ 690 function arrayReduce(array, iteratee, accumulator, initAccum) { 691 var index = -1, 692 length = array == null ? 0 : array.length; 693 694 if (initAccum && length) { 695 accumulator = array[++index]; 696 } 697 while (++index < length) { 698 accumulator = iteratee(accumulator, array[index], index, array); 699 } 700 return accumulator; 701 } 702 703 /** 704 * A specialized version of `_.reduceRight` for arrays without support for 705 * iteratee shorthands. 706 * 707 * @private 708 * @param {Array} [array] The array to iterate over. 709 * @param {Function} iteratee The function invoked per iteration. 710 * @param {*} [accumulator] The initial value. 711 * @param {boolean} [initAccum] Specify using the last element of `array` as 712 * the initial value. 713 * @returns {*} Returns the accumulated value. 714 */ 715 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 716 var length = array == null ? 0 : array.length; 717 if (initAccum && length) { 718 accumulator = array[--length]; 719 } 720 while (length--) { 721 accumulator = iteratee(accumulator, array[length], length, array); 722 } 723 return accumulator; 724 } 725 726 /** 727 * A specialized version of `_.some` for arrays without support for iteratee 728 * shorthands. 729 * 730 * @private 731 * @param {Array} [array] The array to iterate over. 732 * @param {Function} predicate The function invoked per iteration. 733 * @returns {boolean} Returns `true` if any element passes the predicate check, 734 * else `false`. 735 */ 736 function arraySome(array, predicate) { 737 var index = -1, 738 length = array == null ? 0 : array.length; 739 740 while (++index < length) { 741 if (predicate(array[index], index, array)) { 742 return true; 743 } 744 } 745 return false;
vendor: 12,899 bytes, lines 746-1183
746 } 747 748 /** 749 * Gets the size of an ASCII `string`. 750 * 751 * @private 752 * @param {string} string The string inspect. 753 * @returns {number} Returns the string size. 754 */ 755 var asciiSize = baseProperty('length'); 756 757 /** 758 * Converts an ASCII `string` to an array. 759 * 760 * @private 761 * @param {string} string The string to convert. 762 * @returns {Array} Returns the converted array. 763 */ 764 function asciiToArray(string) { 765 return string.split(''); 766 } 767 768 /** 769 * Splits an ASCII `string` into an array of its words. 770 * 771 * @private 772 * @param {string} The string to inspect. 773 * @returns {Array} Returns the words of `string`. 774 */ 775 function asciiWords(string) { 776 return string.match(reAsciiWord) || []; 777 } 778 779 /** 780 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 781 * without support for iteratee shorthands, which iterates over `collection` 782 * using `eachFunc`. 783 * 784 * @private 785 * @param {Array|Object} collection The collection to inspect. 786 * @param {Function} predicate The function invoked per iteration. 787 * @param {Function} eachFunc The function to iterate over `collection`. 788 * @returns {*} Returns the found element or its key, else `undefined`. 789 */ 790 function baseFindKey(collection, predicate, eachFunc) { 791 var result; 792 eachFunc(collection, function(value, key, collection) { 793 if (predicate(value, key, collection)) { 794 result = key; 795 return false; 796 } 797 }); 798 return result; 799 } 800 801 /** 802 * The base implementation of `_.findIndex` and `_.findLastIndex` without 803 * support for iteratee shorthands. 804 * 805 * @private 806 * @param {Array} array The array to inspect. 807 * @param {Function} predicate The function invoked per iteration. 808 * @param {number} fromIndex The index to search from. 809 * @param {boolean} [fromRight] Specify iterating from right to left. 810 * @returns {number} Returns the index of the matched value, else `-1`. 811 */ 812 function baseFindIndex(array, predicate, fromIndex, fromRight) { 813 var length = array.length, 814 index = fromIndex + (fromRight ? 1 : -1); 815 816 while ((fromRight ? index-- : ++index < length)) { 817 if (predicate(array[index], index, array)) { 818 return index; 819 } 820 } 821 return -1; 822 } 823 824 /** 825 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 826 * 827 * @private 828 * @param {Array} array The array to inspect. 829 * @param {*} value The value to search for. 830 * @param {number} fromIndex The index to search from. 831 * @returns {number} Returns the index of the matched value, else `-1`. 832 */ 833 function baseIndexOf(array, value, fromIndex) { 834 return value === value 835 ? strictIndexOf(array, value, fromIndex) 836 : baseFindIndex(array, baseIsNaN, fromIndex); 837 } 838 839 /** 840 * This function is like `baseIndexOf` except that it accepts a comparator. 841 * 842 * @private 843 * @param {Array} array The array to inspect. 844 * @param {*} value The value to search for. 845 * @param {number} fromIndex The index to search from. 846 * @param {Function} comparator The comparator invoked per element. 847 * @returns {number} Returns the index of the matched value, else `-1`. 848 */ 849 function baseIndexOfWith(array, value, fromIndex, comparator) { 850 var index = fromIndex - 1, 851 length = array.length; 852 853 while (++index < length) { 854 if (comparator(array[index], value)) { 855 return index; 856 } 857 } 858 return -1; 859 } 860 861 /** 862 * The base implementation of `_.isNaN` without support for number objects. 863 * 864 * @private 865 * @param {*} value The value to check. 866 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 867 */ 868 function baseIsNaN(value) { 869 return value !== value; 870 } 871 872 /** 873 * The base implementation of `_.mean` and `_.meanBy` without support for 874 * iteratee shorthands. 875 * 876 * @private 877 * @param {Array} array The array to iterate over. 878 * @param {Function} iteratee The function invoked per iteration. 879 * @returns {number} Returns the mean. 880 */ 881 function baseMean(array, iteratee) { 882 var length = array == null ? 0 : array.length; 883 return length ? (baseSum(array, iteratee) / length) : NAN; 884 } 885 886 /** 887 * The base implementation of `_.property` without support for deep paths. 888 * 889 * @private 890 * @param {string} key The key of the property to get. 891 * @returns {Function} Returns the new accessor function. 892 */ 893 function baseProperty(key) { 894 return function(object) { 895 return object == null ? undefined : object[key]; 896 }; 897 } 898 899 /** 900 * The base implementation of `_.propertyOf` without support for deep paths. 901 * 902 * @private 903 * @param {Object} object The object to query. 904 * @returns {Function} Returns the new accessor function. 905 */ 906 function basePropertyOf(object) { 907 return function(key) { 908 return object == null ? undefined : object[key]; 909 }; 910 } 911 912 /** 913 * The base implementation of `_.reduce` and `_.reduceRight`, without support 914 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 915 * 916 * @private 917 * @param {Array|Object} collection The collection to iterate over. 918 * @param {Function} iteratee The function invoked per iteration. 919 * @param {*} accumulator The initial value. 920 * @param {boolean} initAccum Specify using the first or last element of 921 * `collection` as the initial value. 922 * @param {Function} eachFunc The function to iterate over `collection`. 923 * @returns {*} Returns the accumulated value. 924 */ 925 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 926 eachFunc(collection, function(value, index, collection) { 927 accumulator = initAccum 928 ? (initAccum = false, value) 929 : iteratee(accumulator, value, index, collection); 930 }); 931 return accumulator; 932 } 933 934 /** 935 * The base implementation of `_.sortBy` which uses `comparer` to define the 936 * sort order of `array` and replaces criteria objects with their corresponding 937 * values. 938 * 939 * @private 940 * @param {Array} array The array to sort. 941 * @param {Function} comparer The function to define sort order. 942 * @returns {Array} Returns `array`. 943 */ 944 function baseSortBy(array, comparer) { 945 var length = array.length; 946 947 array.sort(comparer); 948 while (length--) { 949 array[length] = array[length].value; 950 } 951 return array; 952 } 953 954 /** 955 * The base implementation of `_.sum` and `_.sumBy` without support for 956 * iteratee shorthands. 957 * 958 * @private 959 * @param {Array} array The array to iterate over. 960 * @param {Function} iteratee The function invoked per iteration. 961 * @returns {number} Returns the sum. 962 */ 963 function baseSum(array, iteratee) { 964 var result, 965 index = -1, 966 length = array.length; 967 968 while (++index < length) { 969 var current = iteratee(array[index]); 970 if (current !== undefined) { 971 result = result === undefined ? current : (result + current); 972 } 973 } 974 return result; 975 } 976 977 /** 978 * The base implementation of `_.times` without support for iteratee shorthands 979 * or max array length checks. 980 * 981 * @private 982 * @param {number} n The number of times to invoke `iteratee`. 983 * @param {Function} iteratee The function invoked per iteration. 984 * @returns {Array} Returns the array of results. 985 */ 986 function baseTimes(n, iteratee) { 987 var index = -1, 988 result = Array(n); 989 990 while (++index < n) { 991 result[index] = iteratee(index); 992 } 993 return result; 994 } 995 996 /** 997 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 998 * of key-value pairs for `object` corresponding to the property names of `props`. 999 * 1000 * @private 1001 * @param {Object} object The object to query. 1002 * @param {Array} props The property names to get values for. 1003 * @returns {Object} Returns the key-value pairs. 1004 */ 1005 function baseToPairs(object, props) { 1006 return arrayMap(props, function(key) { 1007 return [key, object[key]]; 1008 }); 1009 } 1010 1011 /** 1012 * The base implementation of `_.trim`. 1013 * 1014 * @private 1015 * @param {string} string The string to trim. 1016 * @returns {string} Returns the trimmed string. 1017 */ 1018 function baseTrim(string) { 1019 return string 1020 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 1021 : string; 1022 } 1023 1024 /** 1025 * The base implementation of `_.unary` without support for storing metadata. 1026 * 1027 * @private 1028 * @param {Function} func The function to cap arguments for. 1029 * @returns {Function} Returns the new capped function. 1030 */ 1031 function baseUnary(func) { 1032 return function(value) { 1033 return func(value); 1034 }; 1035 } 1036 1037 /** 1038 * The base implementation of `_.values` and `_.valuesIn` which creates an 1039 * array of `object` property values corresponding to the property names 1040 * of `props`. 1041 * 1042 * @private 1043 * @param {Object} object The object to query. 1044 * @param {Array} props The property names to get values for. 1045 * @returns {Object} Returns the array of property values. 1046 */ 1047 function baseValues(object, props) { 1048 return arrayMap(props, function(key) { 1049 return object[key]; 1050 }); 1051 } 1052 1053 /** 1054 * Checks if a `cache` value for `key` exists. 1055 * 1056 * @private 1057 * @param {Object} cache The cache to query. 1058 * @param {string} key The key of the entry to check. 1059 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 1060 */ 1061 function cacheHas(cache, key) { 1062 return cache.has(key); 1063 } 1064 1065 /** 1066 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 1067 * that is not found in the character symbols. 1068 * 1069 * @private 1070 * @param {Array} strSymbols The string symbols to inspect. 1071 * @param {Array} chrSymbols The character symbols to find. 1072 * @returns {number} Returns the index of the first unmatched string symbol. 1073 */ 1074 function charsStartIndex(strSymbols, chrSymbols) { 1075 var index = -1, 1076 length = strSymbols.length; 1077 1078 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 1079 return index; 1080 } 1081 1082 /** 1083 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 1084 * that is not found in the character symbols. 1085 * 1086 * @private 1087 * @param {Array} strSymbols The string symbols to inspect. 1088 * @param {Array} chrSymbols The character symbols to find. 1089 * @returns {number} Returns the index of the last unmatched string symbol. 1090 */ 1091 function charsEndIndex(strSymbols, chrSymbols) { 1092 var index = strSymbols.length; 1093 1094 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 1095 return index; 1096 } 1097 1098 /** 1099 * Gets the number of `placeholder` occurrences in `array`. 1100 * 1101 * @private 1102 * @param {Array} array The array to inspect. 1103 * @param {*} placeholder The placeholder to search for. 1104 * @returns {number} Returns the placeholder count. 1105 */ 1106 function countHolders(array, placeholder) { 1107 var length = array.length, 1108 result = 0; 1109 1110 while (length--) { 1111 if (array[length] === placeholder) { 1112 ++result; 1113 } 1114 } 1115 return result; 1116 } 1117 1118 /** 1119 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 1120 * letters to basic Latin letters. 1121 * 1122 * @private 1123 * @param {string} letter The matched letter to deburr. 1124 * @returns {string} Returns the deburred letter. 1125 */ 1126 var deburrLetter = basePropertyOf(deburredLetters); 1127 1128 /** 1129 * Used by `_.escape` to convert characters to HTML entities. 1130 * 1131 * @private 1132 * @param {string} chr The matched character to escape. 1133 * @returns {string} Returns the escaped character. 1134 */ 1135 var escapeHtmlChar = basePropertyOf(htmlEscapes); 1136 1137 /** 1138 * Used by `_.template` to escape characters for inclusion in compiled string literals. 1139 * 1140 * @private 1141 * @param {string} chr The matched character to escape. 1142 * @returns {string} Returns the escaped character. 1143 */ 1144 function escapeStringChar(chr) { 1145 return '\\' + stringEscapes[chr]; 1146 } 1147 1148 /** 1149 * Gets the value at `key` of `object`. 1150 * 1151 * @private 1152 * @param {Object} [object] The object to query. 1153 * @param {string} key The key of the property to get. 1154 * @returns {*} Returns the property value. 1155 */ 1156 function getValue(object, key) { 1157 return object == null ? undefined : object[key]; 1158 } 1159 1160 /** 1161 * Checks if `string` contains Unicode symbols. 1162 * 1163 * @private 1164 * @param {string} string The string to inspect. 1165 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 1166 */ 1167 function hasUnicode(string) { 1168 return reHasUnicode.test(string); 1169 } 1170 1171 /** 1172 * Checks if `string` contains a word composed of Unicode symbols. 1173 * 1174 * @private 1175 * @param {string} string The string to inspect. 1176 * @returns {boolean} Returns `true` if a word is found, else `false`. 1177 */ 1178 function hasUnicodeWord(string) { 1179 return reHasUnicodeWord.test(string); 1180 } 1181 1182 /** 1183 * Converts `iterator` to an array.
vendor: 8,214 bytes, lines 1184-1493
1184 * 1185 * @private 1186 * @param {Object} iterator The iterator to convert. 1187 * @returns {Array} Returns the converted array. 1188 */ 1189 function iteratorToArray(iterator) { 1190 var data, 1191 result = []; 1192 1193 while (!(data = iterator.next()).done) { 1194 result.push(data.value); 1195 } 1196 return result; 1197 } 1198 1199 /** 1200 * Converts `map` to its key-value pairs. 1201 * 1202 * @private 1203 * @param {Object} map The map to convert. 1204 * @returns {Array} Returns the key-value pairs. 1205 */ 1206 function mapToArray(map) { 1207 var index = -1, 1208 result = Array(map.size); 1209 1210 map.forEach(function(value, key) { 1211 result[++index] = [key, value]; 1212 }); 1213 return result; 1214 } 1215 1216 /** 1217 * Creates a unary function that invokes `func` with its argument transformed. 1218 * 1219 * @private 1220 * @param {Function} func The function to wrap. 1221 * @param {Function} transform The argument transform. 1222 * @returns {Function} Returns the new function. 1223 */ 1224 function overArg(func, transform) { 1225 return function(arg) { 1226 return func(transform(arg)); 1227 }; 1228 } 1229 1230 /** 1231 * Replaces all `placeholder` elements in `array` with an internal placeholder 1232 * and returns an array of their indexes. 1233 * 1234 * @private 1235 * @param {Array} array The array to modify. 1236 * @param {*} placeholder The placeholder to replace. 1237 * @returns {Array} Returns the new array of placeholder indexes. 1238 */ 1239 function replaceHolders(array, placeholder) { 1240 var index = -1, 1241 length = array.length, 1242 resIndex = 0, 1243 result = []; 1244 1245 while (++index < length) { 1246 var value = array[index]; 1247 if (value === placeholder || value === PLACEHOLDER) { 1248 array[index] = PLACEHOLDER; 1249 result[resIndex++] = index; 1250 } 1251 } 1252 return result; 1253 } 1254 1255 /** 1256 * Converts `set` to an array of its values. 1257 * 1258 * @private 1259 * @param {Object} set The set to convert. 1260 * @returns {Array} Returns the values. 1261 */ 1262 function setToArray(set) { 1263 var index = -1, 1264 result = Array(set.size); 1265 1266 set.forEach(function(value) { 1267 result[++index] = value; 1268 }); 1269 return result; 1270 } 1271 1272 /** 1273 * Converts `set` to its value-value pairs. 1274 * 1275 * @private 1276 * @param {Object} set The set to convert. 1277 * @returns {Array} Returns the value-value pairs. 1278 */ 1279 function setToPairs(set) { 1280 var index = -1, 1281 result = Array(set.size); 1282 1283 set.forEach(function(value) { 1284 result[++index] = [value, value]; 1285 }); 1286 return result; 1287 } 1288 1289 /** 1290 * A specialized version of `_.indexOf` which performs strict equality 1291 * comparisons of values, i.e. `===`. 1292 * 1293 * @private 1294 * @param {Array} array The array to inspect. 1295 * @param {*} value The value to search for. 1296 * @param {number} fromIndex The index to search from. 1297 * @returns {number} Returns the index of the matched value, else `-1`. 1298 */ 1299 function strictIndexOf(array, value, fromIndex) { 1300 var index = fromIndex - 1, 1301 length = array.length; 1302 1303 while (++index < length) { 1304 if (array[index] === value) { 1305 return index; 1306 } 1307 } 1308 return -1; 1309 } 1310 1311 /** 1312 * A specialized version of `_.lastIndexOf` which performs strict equality 1313 * comparisons of values, i.e. `===`. 1314 * 1315 * @private 1316 * @param {Array} array The array to inspect. 1317 * @param {*} value The value to search for. 1318 * @param {number} fromIndex The index to search from. 1319 * @returns {number} Returns the index of the matched value, else `-1`. 1320 */ 1321 function strictLastIndexOf(array, value, fromIndex) { 1322 var index = fromIndex + 1; 1323 while (index--) { 1324 if (array[index] === value) { 1325 return index; 1326 } 1327 } 1328 return index; 1329 } 1330 1331 /** 1332 * Gets the number of symbols in `string`. 1333 * 1334 * @private 1335 * @param {string} string The string to inspect. 1336 * @returns {number} Returns the string size. 1337 */ 1338 function stringSize(string) { 1339 return hasUnicode(string) 1340 ? unicodeSize(string) 1341 : asciiSize(string); 1342 } 1343 1344 /** 1345 * Converts `string` to an array. 1346 * 1347 * @private 1348 * @param {string} string The string to convert. 1349 * @returns {Array} Returns the converted array. 1350 */ 1351 function stringToArray(string) { 1352 return hasUnicode(string) 1353 ? unicodeToArray(string) 1354 : asciiToArray(string); 1355 } 1356 1357 /** 1358 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 1359 * character of `string`. 1360 * 1361 * @private 1362 * @param {string} string The string to inspect. 1363 * @returns {number} Returns the index of the last non-whitespace character. 1364 */ 1365 function trimmedEndIndex(string) { 1366 var index = string.length; 1367 1368 while (index-- && reWhitespace.test(string.charAt(index))) {} 1369 return index; 1370 } 1371 1372 /** 1373 * Used by `_.unescape` to convert HTML entities to characters. 1374 * 1375 * @private 1376 * @param {string} chr The matched character to unescape. 1377 * @returns {string} Returns the unescaped character. 1378 */ 1379 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 1380 1381 /** 1382 * Gets the size of a Unicode `string`. 1383 * 1384 * @private 1385 * @param {string} string The string inspect. 1386 * @returns {number} Returns the string size. 1387 */ 1388 function unicodeSize(string) { 1389 var result = reUnicode.lastIndex = 0; 1390 while (reUnicode.test(string)) { 1391 ++result; 1392 } 1393 return result; 1394 } 1395 1396 /** 1397 * Converts a Unicode `string` to an array. 1398 * 1399 * @private 1400 * @param {string} string The string to convert. 1401 * @returns {Array} Returns the converted array. 1402 */ 1403 function unicodeToArray(string) { 1404 return string.match(reUnicode) || []; 1405 } 1406 1407 /** 1408 * Splits a Unicode `string` into an array of its words. 1409 * 1410 * @private 1411 * @param {string} The string to inspect. 1412 * @returns {Array} Returns the words of `string`. 1413 */ 1414 function unicodeWords(string) { 1415 return string.match(reUnicodeWord) || []; 1416 } 1417 1418 /*--------------------------------------------------------------------------*/ 1419 1420 /** 1421 * Create a new pristine `lodash` function using the `context` object. 1422 * 1423 * @static 1424 * @memberOf _ 1425 * @since 1.1.0 1426 * @category Util 1427 * @param {Object} [context=root] The context object. 1428 * @returns {Function} Returns a new `lodash` function. 1429 * @example 1430 * 1431 * _.mixin({ 'foo': _.constant('foo') }); 1432 * 1433 * var lodash = _.runInContext(); 1434 * lodash.mixin({ 'bar': lodash.constant('bar') }); 1435 * 1436 * _.isFunction(_.foo); 1437 * // => true 1438 * _.isFunction(_.bar); 1439 * // => false 1440 * 1441 * lodash.isFunction(lodash.foo); 1442 * // => false 1443 * lodash.isFunction(lodash.bar); 1444 * // => true 1445 * 1446 * // Create a suped-up `defer` in Node.js. 1447 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 1448 */ 1449 var runInContext = (function runInContext(context) { 1450 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 1451 1452 /** Built-in constructor references. */ 1453 var Array = context.Array, 1454 Date = context.Date, 1455 Error = context.Error, 1456 Function = context.Function, 1457 Math = context.Math, 1458 Object = context.Object, 1459 RegExp = context.RegExp, 1460 String = context.String, 1461 TypeError = context.TypeError; 1462 1463 /** Used for built-in method references. */ 1464 var arrayProto = Array.prototype, 1465 funcProto = Function.prototype, 1466 objectProto = Object.prototype; 1467 1468 /** Used to detect overreaching core-js shims. */ 1469 var coreJsData = context['__core-js_shared__']; 1470 1471 /** Used to resolve the decompiled source of functions. */ 1472 var funcToString = funcProto.toString; 1473 1474 /** Used to check objects for own properties. */ 1475 var hasOwnProperty = objectProto.hasOwnProperty; 1476 1477 /** Used to generate unique IDs. */ 1478 var idCounter = 0; 1479 1480 /** Used to detect methods masquerading as native. */ 1481 var maskSrcKey = (function() { 1482 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 1483 return uid ? ('Symbol(src)_1.' + uid) : ''; 1484 }()); 1485 1486 /** 1487 * Used to resolve the 1488 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 1489 * of values. 1490 */ 1491 var nativeObjectToString = objectProto.toString; 1492 1493 /** Used to infer the `Object` constructor. */
vendor: 25,659 bytes, lines 1494-2291
1494 var objectCtorString = funcToString.call(Object); 1495 1496 /** Used to restore the original `_` reference in `_.noConflict`. */ 1497 var oldDash = root._; 1498 1499 /** Used to detect if a method is native. */ 1500 var reIsNative = RegExp('^' + 1501 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 1502 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 1503 ); 1504 1505 /** Built-in value references. */ 1506 var Buffer = moduleExports ? context.Buffer : undefined, 1507 Symbol = context.Symbol, 1508 Uint8Array = context.Uint8Array, 1509 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 1510 getPrototype = overArg(Object.getPrototypeOf, Object), 1511 objectCreate = Object.create, 1512 propertyIsEnumerable = objectProto.propertyIsEnumerable, 1513 splice = arrayProto.splice, 1514 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 1515 symIterator = Symbol ? Symbol.iterator : undefined, 1516 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 1517 1518 var defineProperty = (function() { 1519 try { 1520 var func = getNative(Object, 'defineProperty'); 1521 func({}, '', {}); 1522 return func; 1523 } catch (e) {} 1524 }()); 1525 1526 /** Mocked built-ins. */ 1527 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 1528 ctxNow = Date && Date.now !== root.Date.now && Date.now, 1529 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 1530 1531 /* Built-in method references for those with the same name as other `lodash` methods. */ 1532 var nativeCeil = Math.ceil, 1533 nativeFloor = Math.floor, 1534 nativeGetSymbols = Object.getOwnPropertySymbols, 1535 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 1536 nativeIsFinite = context.isFinite, 1537 nativeJoin = arrayProto.join, 1538 nativeKeys = overArg(Object.keys, Object), 1539 nativeMax = Math.max, 1540 nativeMin = Math.min, 1541 nativeNow = Date.now, 1542 nativeParseInt = context.parseInt, 1543 nativeRandom = Math.random, 1544 nativeReverse = arrayProto.reverse; 1545 1546 /* Built-in method references that are verified to be native. */ 1547 var DataView = getNative(context, 'DataView'), 1548 Map = getNative(context, 'Map'), 1549 Promise = getNative(context, 'Promise'), 1550 Set = getNative(context, 'Set'), 1551 WeakMap = getNative(context, 'WeakMap'), 1552 nativeCreate = getNative(Object, 'create'); 1553 1554 /** Used to store function metadata. */ 1555 var metaMap = WeakMap && new WeakMap; 1556 1557 /** Used to lookup unminified function names. */ 1558 var realNames = {}; 1559 1560 /** Used to detect maps, sets, and weakmaps. */ 1561 var dataViewCtorString = toSource(DataView), 1562 mapCtorString = toSource(Map), 1563 promiseCtorString = toSource(Promise), 1564 setCtorString = toSource(Set), 1565 weakMapCtorString = toSource(WeakMap); 1566 1567 /** Used to convert symbols to primitives and strings. */ 1568 var symbolProto = Symbol ? Symbol.prototype : undefined, 1569 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 1570 symbolToString = symbolProto ? symbolProto.toString : undefined; 1571 1572 /*------------------------------------------------------------------------*/ 1573 1574 /** 1575 * Creates a `lodash` object which wraps `value` to enable implicit method 1576 * chain sequences. Methods that operate on and return arrays, collections, 1577 * and functions can be chained together. Methods that retrieve a single value 1578 * or may return a primitive value will automatically end the chain sequence 1579 * and return the unwrapped value. Otherwise, the value must be unwrapped 1580 * with `_#value`. 1581 * 1582 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 1583 * enabled using `_.chain`. 1584 * 1585 * The execution of chained methods is lazy, that is, it's deferred until 1586 * `_#value` is implicitly or explicitly called. 1587 * 1588 * Lazy evaluation allows several methods to support shortcut fusion. 1589 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 1590 * the creation of intermediate arrays and can greatly reduce the number of 1591 * iteratee executions. Sections of a chain sequence qualify for shortcut 1592 * fusion if the section is applied to an array and iteratees accept only 1593 * one argument. The heuristic for whether a section qualifies for shortcut 1594 * fusion is subject to change. 1595 * 1596 * Chaining is supported in custom builds as long as the `_#value` method is 1597 * directly or indirectly included in the build. 1598 * 1599 * In addition to lodash methods, wrappers have `Array` and `String` methods. 1600 * 1601 * The wrapper `Array` methods are: 1602 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 1603 * 1604 * The wrapper `String` methods are: 1605 * `replace` and `split` 1606 * 1607 * The wrapper methods that support shortcut fusion are: 1608 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 1609 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 1610 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 1611 * 1612 * The chainable wrapper methods are: 1613 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 1614 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 1615 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 1616 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 1617 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 1618 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 1619 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 1620 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 1621 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 1622 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 1623 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 1624 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 1625 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 1626 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 1627 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 1628 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 1629 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 1630 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 1631 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 1632 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 1633 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 1634 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 1635 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 1636 * `zipObject`, `zipObjectDeep`, and `zipWith` 1637 * 1638 * The wrapper methods that are **not** chainable by default are: 1639 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 1640 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 1641 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 1642 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 1643 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 1644 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 1645 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 1646 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 1647 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 1648 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 1649 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 1650 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 1651 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 1652 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 1653 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 1654 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 1655 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 1656 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 1657 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 1658 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 1659 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 1660 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 1661 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 1662 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 1663 * `upperFirst`, `value`, and `words` 1664 * 1665 * @name _ 1666 * @constructor 1667 * @category Seq 1668 * @param {*} value The value to wrap in a `lodash` instance. 1669 * @returns {Object} Returns the new `lodash` wrapper instance. 1670 * @example 1671 * 1672 * function square(n) { 1673 * return n * n; 1674 * } 1675 * 1676 * var wrapped = _([1, 2, 3]); 1677 * 1678 * // Returns an unwrapped value. 1679 * wrapped.reduce(_.add); 1680 * // => 6 1681 * 1682 * // Returns a wrapped value. 1683 * var squares = wrapped.map(square); 1684 * 1685 * _.isArray(squares); 1686 * // => false 1687 * 1688 * _.isArray(squares.value()); 1689 * // => true 1690 */ 1691 function lodash(value) { 1692 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 1693 if (value instanceof LodashWrapper) { 1694 return value; 1695 } 1696 if (hasOwnProperty.call(value, '__wrapped__')) { 1697 return wrapperClone(value); 1698 } 1699 } 1700 return new LodashWrapper(value); 1701 } 1702 1703 /** 1704 * The base implementation of `_.create` without support for assigning 1705 * properties to the created object. 1706 * 1707 * @private 1708 * @param {Object} proto The object to inherit from. 1709 * @returns {Object} Returns the new object. 1710 */ 1711 var baseCreate = (function() { 1712 function object() {} 1713 return function(proto) { 1714 if (!isObject(proto)) { 1715 return {}; 1716 } 1717 if (objectCreate) { 1718 return objectCreate(proto); 1719 } 1720 object.prototype = proto; 1721 var result = new object; 1722 object.prototype = undefined; 1723 return result; 1724 }; 1725 }()); 1726 1727 /** 1728 * The function whose prototype chain sequence wrappers inherit from. 1729 * 1730 * @private 1731 */ 1732 function baseLodash() { 1733 // No operation performed. 1734 } 1735 1736 /** 1737 * The base constructor for creating `lodash` wrapper objects. 1738 * 1739 * @private 1740 * @param {*} value The value to wrap. 1741 * @param {boolean} [chainAll] Enable explicit method chain sequences. 1742 */ 1743 function LodashWrapper(value, chainAll) { 1744 this.__wrapped__ = value; 1745 this.__actions__ = []; 1746 this.__chain__ = !!chainAll; 1747 this.__index__ = 0; 1748 this.__values__ = undefined; 1749 } 1750 1751 /** 1752 * By default, the template delimiters used by lodash are like those in 1753 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 1754 * following template settings to use alternative delimiters. 1755 * 1756 * @static 1757 * @memberOf _ 1758 * @type {Object} 1759 */ 1760 lodash.templateSettings = { 1761 1762 /** 1763 * Used to detect `data` property values to be HTML-escaped. 1764 * 1765 * @memberOf _.templateSettings 1766 * @type {RegExp} 1767 */ 1768 'escape': reEscape, 1769 1770 /** 1771 * Used to detect code to be evaluated. 1772 * 1773 * @memberOf _.templateSettings 1774 * @type {RegExp} 1775 */ 1776 'evaluate': reEvaluate, 1777 1778 /** 1779 * Used to detect `data` property values to inject. 1780 * 1781 * @memberOf _.templateSettings 1782 * @type {RegExp} 1783 */ 1784 'interpolate': reInterpolate, 1785 1786 /** 1787 * Used to reference the data object in the template text. 1788 * 1789 * @memberOf _.templateSettings 1790 * @type {string} 1791 */ 1792 'variable': '', 1793 1794 /** 1795 * Used to import variables into the compiled template. 1796 * 1797 * @memberOf _.templateSettings 1798 * @type {Object} 1799 */ 1800 'imports': { 1801 1802 /** 1803 * A reference to the `lodash` function. 1804 * 1805 * @memberOf _.templateSettings.imports 1806 * @type {Function} 1807 */ 1808 '_': lodash 1809 } 1810 }; 1811 1812 // Ensure wrappers are instances of `baseLodash`. 1813 lodash.prototype = baseLodash.prototype; 1814 lodash.prototype.constructor = lodash; 1815 1816 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 1817 LodashWrapper.prototype.constructor = LodashWrapper; 1818 1819 /*------------------------------------------------------------------------*/ 1820 1821 /** 1822 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 1823 * 1824 * @private 1825 * @constructor 1826 * @param {*} value The value to wrap. 1827 */ 1828 function LazyWrapper(value) { 1829 this.__wrapped__ = value; 1830 this.__actions__ = []; 1831 this.__dir__ = 1; 1832 this.__filtered__ = false; 1833 this.__iteratees__ = []; 1834 this.__takeCount__ = MAX_ARRAY_LENGTH; 1835 this.__views__ = []; 1836 } 1837 1838 /** 1839 * Creates a clone of the lazy wrapper object. 1840 * 1841 * @private 1842 * @name clone 1843 * @memberOf LazyWrapper 1844 * @returns {Object} Returns the cloned `LazyWrapper` object. 1845 */ 1846 function lazyClone() { 1847 var result = new LazyWrapper(this.__wrapped__); 1848 result.__actions__ = copyArray(this.__actions__); 1849 result.__dir__ = this.__dir__; 1850 result.__filtered__ = this.__filtered__; 1851 result.__iteratees__ = copyArray(this.__iteratees__); 1852 result.__takeCount__ = this.__takeCount__; 1853 result.__views__ = copyArray(this.__views__); 1854 return result; 1855 } 1856 1857 /** 1858 * Reverses the direction of lazy iteration. 1859 * 1860 * @private 1861 * @name reverse 1862 * @memberOf LazyWrapper 1863 * @returns {Object} Returns the new reversed `LazyWrapper` object. 1864 */ 1865 function lazyReverse() { 1866 if (this.__filtered__) { 1867 var result = new LazyWrapper(this); 1868 result.__dir__ = -1; 1869 result.__filtered__ = true; 1870 } else { 1871 result = this.clone(); 1872 result.__dir__ *= -1; 1873 } 1874 return result; 1875 } 1876 1877 /** 1878 * Extracts the unwrapped value from its lazy wrapper. 1879 * 1880 * @private 1881 * @name value 1882 * @memberOf LazyWrapper 1883 * @returns {*} Returns the unwrapped value. 1884 */ 1885 function lazyValue() { 1886 var array = this.__wrapped__.value(), 1887 dir = this.__dir__, 1888 isArr = isArray(array), 1889 isRight = dir < 0, 1890 arrLength = isArr ? array.length : 0, 1891 view = getView(0, arrLength, this.__views__), 1892 start = view.start, 1893 end = view.end, 1894 length = end - start, 1895 index = isRight ? end : (start - 1), 1896 iteratees = this.__iteratees__, 1897 iterLength = iteratees.length, 1898 resIndex = 0, 1899 takeCount = nativeMin(length, this.__takeCount__); 1900 1901 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 1902 return baseWrapperValue(array, this.__actions__); 1903 } 1904 var result = []; 1905 1906 outer: 1907 while (length-- && resIndex < takeCount) { 1908 index += dir; 1909 1910 var iterIndex = -1, 1911 value = array[index]; 1912 1913 while (++iterIndex < iterLength) { 1914 var data = iteratees[iterIndex], 1915 iteratee = data.iteratee, 1916 type = data.type, 1917 computed = iteratee(value); 1918 1919 if (type == LAZY_MAP_FLAG) { 1920 value = computed; 1921 } else if (!computed) { 1922 if (type == LAZY_FILTER_FLAG) { 1923 continue outer; 1924 } else { 1925 break outer; 1926 } 1927 } 1928 } 1929 result[resIndex++] = value; 1930 } 1931 return result; 1932 } 1933 1934 // Ensure `LazyWrapper` is an instance of `baseLodash`. 1935 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 1936 LazyWrapper.prototype.constructor = LazyWrapper; 1937 1938 /*------------------------------------------------------------------------*/ 1939 1940 /** 1941 * Creates a hash object. 1942 * 1943 * @private 1944 * @constructor 1945 * @param {Array} [entries] The key-value pairs to cache. 1946 */ 1947 function Hash(entries) { 1948 var index = -1, 1949 length = entries == null ? 0 : entries.length; 1950 1951 this.clear(); 1952 while (++index < length) { 1953 var entry = entries[index]; 1954 this.set(entry[0], entry[1]); 1955 } 1956 } 1957 1958 /** 1959 * Removes all key-value entries from the hash. 1960 * 1961 * @private 1962 * @name clear 1963 * @memberOf Hash 1964 */ 1965 function hashClear() { 1966 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 1967 this.size = 0; 1968 } 1969 1970 /** 1971 * Removes `key` and its value from the hash. 1972 * 1973 * @private 1974 * @name delete 1975 * @memberOf Hash 1976 * @param {Object} hash The hash to modify. 1977 * @param {string} key The key of the value to remove. 1978 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 1979 */ 1980 function hashDelete(key) { 1981 var result = this.has(key) && delete this.__data__[key]; 1982 this.size -= result ? 1 : 0; 1983 return result; 1984 } 1985 1986 /** 1987 * Gets the hash value for `key`. 1988 * 1989 * @private 1990 * @name get 1991 * @memberOf Hash 1992 * @param {string} key The key of the value to get. 1993 * @returns {*} Returns the entry value. 1994 */ 1995 function hashGet(key) { 1996 var data = this.__data__; 1997 if (nativeCreate) { 1998 var result = data[key]; 1999 return result === HASH_UNDEFINED ? undefined : result; 2000 } 2001 return hasOwnProperty.call(data, key) ? data[key] : undefined; 2002 } 2003 2004 /** 2005 * Checks if a hash value for `key` exists. 2006 * 2007 * @private 2008 * @name has 2009 * @memberOf Hash 2010 * @param {string} key The key of the entry to check. 2011 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2012 */ 2013 function hashHas(key) { 2014 var data = this.__data__; 2015 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 2016 } 2017 2018 /** 2019 * Sets the hash `key` to `value`. 2020 * 2021 * @private 2022 * @name set 2023 * @memberOf Hash 2024 * @param {string} key The key of the value to set. 2025 * @param {*} value The value to set. 2026 * @returns {Object} Returns the hash instance. 2027 */ 2028 function hashSet(key, value) { 2029 var data = this.__data__; 2030 this.size += this.has(key) ? 0 : 1; 2031 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 2032 return this; 2033 } 2034 2035 // Add methods to `Hash`. 2036 Hash.prototype.clear = hashClear; 2037 Hash.prototype['delete'] = hashDelete; 2038 Hash.prototype.get = hashGet; 2039 Hash.prototype.has = hashHas; 2040 Hash.prototype.set = hashSet; 2041 2042 /*------------------------------------------------------------------------*/ 2043 2044 /** 2045 * Creates an list cache object. 2046 * 2047 * @private 2048 * @constructor 2049 * @param {Array} [entries] The key-value pairs to cache. 2050 */ 2051 function ListCache(entries) { 2052 var index = -1, 2053 length = entries == null ? 0 : entries.length; 2054 2055 this.clear(); 2056 while (++index < length) { 2057 var entry = entries[index]; 2058 this.set(entry[0], entry[1]); 2059 } 2060 } 2061 2062 /** 2063 * Removes all key-value entries from the list cache. 2064 * 2065 * @private 2066 * @name clear 2067 * @memberOf ListCache 2068 */ 2069 function listCacheClear() { 2070 this.__data__ = []; 2071 this.size = 0; 2072 } 2073 2074 /** 2075 * Removes `key` and its value from the list cache. 2076 * 2077 * @private 2078 * @name delete 2079 * @memberOf ListCache 2080 * @param {string} key The key of the value to remove. 2081 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 2082 */ 2083 function listCacheDelete(key) { 2084 var data = this.__data__, 2085 index = assocIndexOf(data, key); 2086 2087 if (index < 0) { 2088 return false; 2089 } 2090 var lastIndex = data.length - 1; 2091 if (index == lastIndex) { 2092 data.pop(); 2093 } else { 2094 splice.call(data, index, 1); 2095 } 2096 --this.size; 2097 return true; 2098 } 2099 2100 /** 2101 * Gets the list cache value for `key`. 2102 * 2103 * @private 2104 * @name get 2105 * @memberOf ListCache 2106 * @param {string} key The key of the value to get. 2107 * @returns {*} Returns the entry value. 2108 */ 2109 function listCacheGet(key) { 2110 var data = this.__data__, 2111 index = assocIndexOf(data, key); 2112 2113 return index < 0 ? undefined : data[index][1]; 2114 } 2115 2116 /** 2117 * Checks if a list cache value for `key` exists. 2118 * 2119 * @private 2120 * @name has 2121 * @memberOf ListCache 2122 * @param {string} key The key of the entry to check. 2123 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2124 */ 2125 function listCacheHas(key) { 2126 return assocIndexOf(this.__data__, key) > -1; 2127 } 2128 2129 /** 2130 * Sets the list cache `key` to `value`. 2131 * 2132 * @private 2133 * @name set 2134 * @memberOf ListCache 2135 * @param {string} key The key of the value to set. 2136 * @param {*} value The value to set. 2137 * @returns {Object} Returns the list cache instance. 2138 */ 2139 function listCacheSet(key, value) { 2140 var data = this.__data__, 2141 index = assocIndexOf(data, key); 2142 2143 if (index < 0) { 2144 ++this.size; 2145 data.push([key, value]); 2146 } else { 2147 data[index][1] = value; 2148 } 2149 return this; 2150 } 2151 2152 // Add methods to `ListCache`. 2153 ListCache.prototype.clear = listCacheClear; 2154 ListCache.prototype['delete'] = listCacheDelete; 2155 ListCache.prototype.get = listCacheGet; 2156 ListCache.prototype.has = listCacheHas; 2157 ListCache.prototype.set = listCacheSet; 2158 2159 /*------------------------------------------------------------------------*/ 2160 2161 /** 2162 * Creates a map cache object to store key-value pairs. 2163 * 2164 * @private 2165 * @constructor 2166 * @param {Array} [entries] The key-value pairs to cache. 2167 */ 2168 function MapCache(entries) { 2169 var index = -1, 2170 length = entries == null ? 0 : entries.length; 2171 2172 this.clear(); 2173 while (++index < length) { 2174 var entry = entries[index]; 2175 this.set(entry[0], entry[1]); 2176 } 2177 } 2178 2179 /** 2180 * Removes all key-value entries from the map. 2181 * 2182 * @private 2183 * @name clear 2184 * @memberOf MapCache 2185 */ 2186 function mapCacheClear() { 2187 this.size = 0; 2188 this.__data__ = { 2189 'hash': new Hash, 2190 'map': new (Map || ListCache), 2191 'string': new Hash 2192 }; 2193 } 2194 2195 /** 2196 * Removes `key` and its value from the map. 2197 * 2198 * @private 2199 * @name delete 2200 * @memberOf MapCache 2201 * @param {string} key The key of the value to remove. 2202 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 2203 */ 2204 function mapCacheDelete(key) { 2205 var result = getMapData(this, key)['delete'](key); 2206 this.size -= result ? 1 : 0; 2207 return result; 2208 } 2209 2210 /** 2211 * Gets the map value for `key`. 2212 * 2213 * @private 2214 * @name get 2215 * @memberOf MapCache 2216 * @param {string} key The key of the value to get. 2217 * @returns {*} Returns the entry value. 2218 */ 2219 function mapCacheGet(key) { 2220 return getMapData(this, key).get(key); 2221 } 2222 2223 /** 2224 * Checks if a map value for `key` exists. 2225 * 2226 * @private 2227 * @name has 2228 * @memberOf MapCache 2229 * @param {string} key The key of the entry to check. 2230 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2231 */ 2232 function mapCacheHas(key) { 2233 return getMapData(this, key).has(key); 2234 } 2235 2236 /** 2237 * Sets the map `key` to `value`. 2238 * 2239 * @private 2240 * @name set 2241 * @memberOf MapCache 2242 * @param {string} key The key of the value to set. 2243 * @param {*} value The value to set. 2244 * @returns {Object} Returns the map cache instance. 2245 */ 2246 function mapCacheSet(key, value) { 2247 var data = getMapData(this, key), 2248 size = data.size; 2249 2250 data.set(key, value); 2251 this.size += data.size == size ? 0 : 1; 2252 return this; 2253 } 2254 2255 // Add methods to `MapCache`. 2256 MapCache.prototype.clear = mapCacheClear; 2257 MapCache.prototype['delete'] = mapCacheDelete; 2258 MapCache.prototype.get = mapCacheGet; 2259 MapCache.prototype.has = mapCacheHas; 2260 MapCache.prototype.set = mapCacheSet; 2261 2262 /*------------------------------------------------------------------------*/ 2263 2264 /** 2265 * 2266 * Creates an array cache object to store unique values. 2267 * 2268 * @private 2269 * @constructor 2270 * @param {Array} [values] The values to cache. 2271 */ 2272 function SetCache(values) { 2273 var index = -1, 2274 length = values == null ? 0 : values.length; 2275 2276 this.__data__ = new MapCache; 2277 while (++index < length) { 2278 this.add(values[index]); 2279 } 2280 } 2281 2282 /** 2283 * Adds `value` to the array cache. 2284 * 2285 * @private 2286 * @name add 2287 * @memberOf SetCache 2288 * @alias push 2289 * @param {*} value The value to cache. 2290 * @returns {Object} Returns the cache instance. 2291 */
vendor: 3,741 bytes, lines 2292-2428
2292 function setCacheAdd(value) { 2293 this.__data__.set(value, HASH_UNDEFINED); 2294 return this; 2295 } 2296 2297 /** 2298 * Checks if `value` is in the array cache. 2299 * 2300 * @private 2301 * @name has 2302 * @memberOf SetCache 2303 * @param {*} value The value to search for. 2304 * @returns {number} Returns `true` if `value` is found, else `false`. 2305 */ 2306 function setCacheHas(value) { 2307 return this.__data__.has(value); 2308 } 2309 2310 // Add methods to `SetCache`. 2311 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 2312 SetCache.prototype.has = setCacheHas; 2313 2314 /*------------------------------------------------------------------------*/ 2315 2316 /** 2317 * Creates a stack cache object to store key-value pairs. 2318 * 2319 * @private 2320 * @constructor 2321 * @param {Array} [entries] The key-value pairs to cache. 2322 */ 2323 function Stack(entries) { 2324 var data = this.__data__ = new ListCache(entries); 2325 this.size = data.size; 2326 } 2327 2328 /** 2329 * Removes all key-value entries from the stack. 2330 * 2331 * @private 2332 * @name clear 2333 * @memberOf Stack 2334 */ 2335 function stackClear() { 2336 this.__data__ = new ListCache; 2337 this.size = 0; 2338 } 2339 2340 /** 2341 * Removes `key` and its value from the stack. 2342 * 2343 * @private 2344 * @name delete 2345 * @memberOf Stack 2346 * @param {string} key The key of the value to remove. 2347 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 2348 */ 2349 function stackDelete(key) { 2350 var data = this.__data__, 2351 result = data['delete'](key); 2352 2353 this.size = data.size; 2354 return result; 2355 } 2356 2357 /** 2358 * Gets the stack value for `key`. 2359 * 2360 * @private 2361 * @name get 2362 * @memberOf Stack 2363 * @param {string} key The key of the value to get. 2364 * @returns {*} Returns the entry value. 2365 */ 2366 function stackGet(key) { 2367 return this.__data__.get(key); 2368 } 2369 2370 /** 2371 * Checks if a stack value for `key` exists. 2372 * 2373 * @private 2374 * @name has 2375 * @memberOf Stack 2376 * @param {string} key The key of the entry to check. 2377 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2378 */ 2379 function stackHas(key) { 2380 return this.__data__.has(key); 2381 } 2382 2383 /** 2384 * Sets the stack `key` to `value`. 2385 * 2386 * @private 2387 * @name set 2388 * @memberOf Stack 2389 * @param {string} key The key of the value to set. 2390 * @param {*} value The value to set. 2391 * @returns {Object} Returns the stack cache instance. 2392 */ 2393 function stackSet(key, value) { 2394 var data = this.__data__; 2395 if (data instanceof ListCache) { 2396 var pairs = data.__data__; 2397 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 2398 pairs.push([key, value]); 2399 this.size = ++data.size; 2400 return this; 2401 } 2402 data = this.__data__ = new MapCache(pairs); 2403 } 2404 data.set(key, value); 2405 this.size = data.size; 2406 return this; 2407 } 2408 2409 // Add methods to `Stack`. 2410 Stack.prototype.clear = stackClear; 2411 Stack.prototype['delete'] = stackDelete; 2412 Stack.prototype.get = stackGet; 2413 Stack.prototype.has = stackHas; 2414 Stack.prototype.set = stackSet; 2415 2416 /*------------------------------------------------------------------------*/ 2417 2418 /** 2419 * Creates an array of the enumerable property names of the array-like `value`. 2420 * 2421 * @private 2422 * @param {*} value The value to query. 2423 * @param {boolean} inherited Specify returning inherited property names. 2424 * @returns {Array} Returns the array of property names. 2425 */ 2426 function arrayLikeKeys(value, inherited) { 2427 var isArr = isArray(value), 2428 isArg = !isArr && isArguments(value),
vendor: 111,524 bytes, lines 2429-5722
2429 isBuff = !isArr && !isArg && isBuffer(value), 2430 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 2431 skipIndexes = isArr || isArg || isBuff || isType, 2432 result = skipIndexes ? baseTimes(value.length, String) : [], 2433 length = result.length; 2434 2435 for (var key in value) { 2436 if ((inherited || hasOwnProperty.call(value, key)) && 2437 !(skipIndexes && ( 2438 // Safari 9 has enumerable `arguments.length` in strict mode. 2439 key == 'length' || 2440 // Node.js 0.10 has enumerable non-index properties on buffers. 2441 (isBuff && (key == 'offset' || key == 'parent')) || 2442 // PhantomJS 2 has enumerable non-index properties on typed arrays. 2443 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 2444 // Skip index properties. 2445 isIndex(key, length) 2446 ))) { 2447 result.push(key); 2448 } 2449 } 2450 return result; 2451 } 2452 2453 /** 2454 * A specialized version of `_.sample` for arrays. 2455 * 2456 * @private 2457 * @param {Array} array The array to sample. 2458 * @returns {*} Returns the random element. 2459 */ 2460 function arraySample(array) { 2461 var length = array.length; 2462 return length ? array[baseRandom(0, length - 1)] : undefined; 2463 } 2464 2465 /** 2466 * A specialized version of `_.sampleSize` for arrays. 2467 * 2468 * @private 2469 * @param {Array} array The array to sample. 2470 * @param {number} n The number of elements to sample. 2471 * @returns {Array} Returns the random elements. 2472 */ 2473 function arraySampleSize(array, n) { 2474 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 2475 } 2476 2477 /** 2478 * A specialized version of `_.shuffle` for arrays. 2479 * 2480 * @private 2481 * @param {Array} array The array to shuffle. 2482 * @returns {Array} Returns the new shuffled array. 2483 */ 2484 function arrayShuffle(array) { 2485 return shuffleSelf(copyArray(array)); 2486 } 2487 2488 /** 2489 * This function is like `assignValue` except that it doesn't assign 2490 * `undefined` values. 2491 * 2492 * @private 2493 * @param {Object} object The object to modify. 2494 * @param {string} key The key of the property to assign. 2495 * @param {*} value The value to assign. 2496 */ 2497 function assignMergeValue(object, key, value) { 2498 if ((value !== undefined && !eq(object[key], value)) || 2499 (value === undefined && !(key in object))) { 2500 baseAssignValue(object, key, value); 2501 } 2502 } 2503 2504 /** 2505 * Assigns `value` to `key` of `object` if the existing value is not equivalent 2506 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 2507 * for equality comparisons. 2508 * 2509 * @private 2510 * @param {Object} object The object to modify. 2511 * @param {string} key The key of the property to assign. 2512 * @param {*} value The value to assign. 2513 */ 2514 function assignValue(object, key, value) { 2515 var objValue = object[key]; 2516 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 2517 (value === undefined && !(key in object))) { 2518 baseAssignValue(object, key, value); 2519 } 2520 } 2521 2522 /** 2523 * Gets the index at which the `key` is found in `array` of key-value pairs. 2524 * 2525 * @private 2526 * @param {Array} array The array to inspect. 2527 * @param {*} key The key to search for. 2528 * @returns {number} Returns the index of the matched value, else `-1`. 2529 */ 2530 function assocIndexOf(array, key) { 2531 var length = array.length; 2532 while (length--) { 2533 if (eq(array[length][0], key)) { 2534 return length; 2535 } 2536 } 2537 return -1; 2538 } 2539 2540 /** 2541 * Aggregates elements of `collection` on `accumulator` with keys transformed 2542 * by `iteratee` and values set by `setter`. 2543 * 2544 * @private 2545 * @param {Array|Object} collection The collection to iterate over. 2546 * @param {Function} setter The function to set `accumulator` values. 2547 * @param {Function} iteratee The iteratee to transform keys. 2548 * @param {Object} accumulator The initial aggregated object. 2549 * @returns {Function} Returns `accumulator`. 2550 */ 2551 function baseAggregator(collection, setter, iteratee, accumulator) { 2552 baseEach(collection, function(value, key, collection) { 2553 setter(accumulator, value, iteratee(value), collection); 2554 }); 2555 return accumulator; 2556 } 2557 2558 /** 2559 * The base implementation of `_.assign` without support for multiple sources 2560 * or `customizer` functions. 2561 * 2562 * @private 2563 * @param {Object} object The destination object. 2564 * @param {Object} source The source object. 2565 * @returns {Object} Returns `object`. 2566 */ 2567 function baseAssign(object, source) { 2568 return object && copyObject(source, keys(source), object); 2569 } 2570 2571 /** 2572 * The base implementation of `_.assignIn` without support for multiple sources 2573 * or `customizer` functions. 2574 * 2575 * @private 2576 * @param {Object} object The destination object. 2577 * @param {Object} source The source object. 2578 * @returns {Object} Returns `object`. 2579 */ 2580 function baseAssignIn(object, source) { 2581 return object && copyObject(source, keysIn(source), object); 2582 } 2583 2584 /** 2585 * The base implementation of `assignValue` and `assignMergeValue` without 2586 * value checks. 2587 * 2588 * @private 2589 * @param {Object} object The object to modify. 2590 * @param {string} key The key of the property to assign. 2591 * @param {*} value The value to assign. 2592 */ 2593 function baseAssignValue(object, key, value) { 2594 if (key == '__proto__' && defineProperty) { 2595 defineProperty(object, key, { 2596 'configurable': true, 2597 'enumerable': true, 2598 'value': value, 2599 'writable': true 2600 }); 2601 } else { 2602 object[key] = value; 2603 } 2604 } 2605 2606 /** 2607 * The base implementation of `_.at` without support for individual paths. 2608 * 2609 * @private 2610 * @param {Object} object The object to iterate over. 2611 * @param {string[]} paths The property paths to pick. 2612 * @returns {Array} Returns the picked elements. 2613 */ 2614 function baseAt(object, paths) { 2615 var index = -1, 2616 length = paths.length, 2617 result = Array(length), 2618 skip = object == null; 2619 2620 while (++index < length) { 2621 result[index] = skip ? undefined : get(object, paths[index]); 2622 } 2623 return result; 2624 } 2625 2626 /** 2627 * The base implementation of `_.clamp` which doesn't coerce arguments. 2628 * 2629 * @private 2630 * @param {number} number The number to clamp. 2631 * @param {number} [lower] The lower bound. 2632 * @param {number} upper The upper bound. 2633 * @returns {number} Returns the clamped number. 2634 */ 2635 function baseClamp(number, lower, upper) { 2636 if (number === number) { 2637 if (upper !== undefined) { 2638 number = number <= upper ? number : upper; 2639 } 2640 if (lower !== undefined) { 2641 number = number >= lower ? number : lower; 2642 } 2643 } 2644 return number; 2645 } 2646 2647 /** 2648 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 2649 * traversed objects. 2650 * 2651 * @private 2652 * @param {*} value The value to clone. 2653 * @param {boolean} bitmask The bitmask flags. 2654 * 1 - Deep clone 2655 * 2 - Flatten inherited properties 2656 * 4 - Clone symbols 2657 * @param {Function} [customizer] The function to customize cloning. 2658 * @param {string} [key] The key of `value`. 2659 * @param {Object} [object] The parent object of `value`. 2660 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 2661 * @returns {*} Returns the cloned value. 2662 */ 2663 function baseClone(value, bitmask, customizer, key, object, stack) { 2664 var result, 2665 isDeep = bitmask & CLONE_DEEP_FLAG, 2666 isFlat = bitmask & CLONE_FLAT_FLAG, 2667 isFull = bitmask & CLONE_SYMBOLS_FLAG; 2668 2669 if (customizer) { 2670 result = object ? customizer(value, key, object, stack) : customizer(value); 2671 } 2672 if (result !== undefined) { 2673 return result; 2674 } 2675 if (!isObject(value)) { 2676 return value; 2677 } 2678 var isArr = isArray(value); 2679 if (isArr) { 2680 result = initCloneArray(value); 2681 if (!isDeep) { 2682 return copyArray(value, result); 2683 } 2684 } else { 2685 var tag = getTag(value), 2686 isFunc = tag == funcTag || tag == genTag; 2687 2688 if (isBuffer(value)) { 2689 return cloneBuffer(value, isDeep); 2690 } 2691 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 2692 result = (isFlat || isFunc) ? {} : initCloneObject(value); 2693 if (!isDeep) { 2694 return isFlat 2695 ? copySymbolsIn(value, baseAssignIn(result, value)) 2696 : copySymbols(value, baseAssign(result, value)); 2697 } 2698 } else { 2699 if (!cloneableTags[tag]) { 2700 return object ? value : {}; 2701 } 2702 result = initCloneByTag(value, tag, isDeep); 2703 } 2704 } 2705 // Check for circular references and return its corresponding clone. 2706 stack || (stack = new Stack); 2707 var stacked = stack.get(value); 2708 if (stacked) { 2709 return stacked; 2710 } 2711 stack.set(value, result); 2712 2713 if (isSet(value)) { 2714 value.forEach(function(subValue) { 2715 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 2716 }); 2717 } else if (isMap(value)) { 2718 value.forEach(function(subValue, key) { 2719 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 2720 }); 2721 } 2722 2723 var keysFunc = isFull 2724 ? (isFlat ? getAllKeysIn : getAllKeys) 2725 : (isFlat ? keysIn : keys); 2726 2727 var props = isArr ? undefined : keysFunc(value); 2728 arrayEach(props || value, function(subValue, key) { 2729 if (props) { 2730 key = subValue; 2731 subValue = value[key]; 2732 } 2733 // Recursively populate clone (susceptible to call stack limits). 2734 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 2735 }); 2736 return result; 2737 } 2738 2739 /** 2740 * The base implementation of `_.conforms` which doesn't clone `source`. 2741 * 2742 * @private 2743 * @param {Object} source The object of property predicates to conform to. 2744 * @returns {Function} Returns the new spec function. 2745 */ 2746 function baseConforms(source) { 2747 var props = keys(source); 2748 return function(object) { 2749 return baseConformsTo(object, source, props); 2750 }; 2751 } 2752 2753 /** 2754 * The base implementation of `_.conformsTo` which accepts `props` to check. 2755 * 2756 * @private 2757 * @param {Object} object The object to inspect. 2758 * @param {Object} source The object of property predicates to conform to. 2759 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 2760 */ 2761 function baseConformsTo(object, source, props) { 2762 var length = props.length; 2763 if (object == null) { 2764 return !length; 2765 } 2766 object = Object(object); 2767 while (length--) { 2768 var key = props[length], 2769 predicate = source[key], 2770 value = object[key]; 2771 2772 if ((value === undefined && !(key in object)) || !predicate(value)) { 2773 return false; 2774 } 2775 } 2776 return true; 2777 } 2778 2779 /** 2780 * The base implementation of `_.delay` and `_.defer` which accepts `args` 2781 * to provide to `func`. 2782 * 2783 * @private 2784 * @param {Function} func The function to delay. 2785 * @param {number} wait The number of milliseconds to delay invocation. 2786 * @param {Array} args The arguments to provide to `func`. 2787 * @returns {number|Object} Returns the timer id or timeout object. 2788 */ 2789 function baseDelay(func, wait, args) { 2790 if (typeof func != 'function') { 2791 throw new TypeError(FUNC_ERROR_TEXT); 2792 } 2793 return setTimeout(function() { func.apply(undefined, args); }, wait); 2794 } 2795 2796 /** 2797 * The base implementation of methods like `_.difference` without support 2798 * for excluding multiple arrays or iteratee shorthands. 2799 * 2800 * @private 2801 * @param {Array} array The array to inspect. 2802 * @param {Array} values The values to exclude. 2803 * @param {Function} [iteratee] The iteratee invoked per element. 2804 * @param {Function} [comparator] The comparator invoked per element. 2805 * @returns {Array} Returns the new array of filtered values. 2806 */ 2807 function baseDifference(array, values, iteratee, comparator) { 2808 var index = -1, 2809 includes = arrayIncludes, 2810 isCommon = true, 2811 length = array.length, 2812 result = [], 2813 valuesLength = values.length; 2814 2815 if (!length) { 2816 return result; 2817 } 2818 if (iteratee) { 2819 values = arrayMap(values, baseUnary(iteratee)); 2820 } 2821 if (comparator) { 2822 includes = arrayIncludesWith; 2823 isCommon = false; 2824 } 2825 else if (values.length >= LARGE_ARRAY_SIZE) { 2826 includes = cacheHas; 2827 isCommon = false; 2828 values = new SetCache(values); 2829 } 2830 outer: 2831 while (++index < length) { 2832 var value = array[index], 2833 computed = iteratee == null ? value : iteratee(value); 2834 2835 value = (comparator || value !== 0) ? value : 0; 2836 if (isCommon && computed === computed) { 2837 var valuesIndex = valuesLength; 2838 while (valuesIndex--) { 2839 if (values[valuesIndex] === computed) { 2840 continue outer; 2841 } 2842 } 2843 result.push(value); 2844 } 2845 else if (!includes(values, computed, comparator)) { 2846 result.push(value); 2847 } 2848 } 2849 return result; 2850 } 2851 2852 /** 2853 * The base implementation of `_.forEach` without support for iteratee shorthands. 2854 * 2855 * @private 2856 * @param {Array|Object} collection The collection to iterate over. 2857 * @param {Function} iteratee The function invoked per iteration. 2858 * @returns {Array|Object} Returns `collection`. 2859 */ 2860 var baseEach = createBaseEach(baseForOwn); 2861 2862 /** 2863 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 2864 * 2865 * @private 2866 * @param {Array|Object} collection The collection to iterate over. 2867 * @param {Function} iteratee The function invoked per iteration. 2868 * @returns {Array|Object} Returns `collection`. 2869 */ 2870 var baseEachRight = createBaseEach(baseForOwnRight, true); 2871 2872 /** 2873 * The base implementation of `_.every` without support for iteratee shorthands. 2874 * 2875 * @private 2876 * @param {Array|Object} collection The collection to iterate over. 2877 * @param {Function} predicate The function invoked per iteration. 2878 * @returns {boolean} Returns `true` if all elements pass the predicate check, 2879 * else `false` 2880 */ 2881 function baseEvery(collection, predicate) { 2882 var result = true; 2883 baseEach(collection, function(value, index, collection) { 2884 result = !!predicate(value, index, collection); 2885 return result; 2886 }); 2887 return result; 2888 } 2889 2890 /** 2891 * The base implementation of methods like `_.max` and `_.min` which accepts a 2892 * `comparator` to determine the extremum value. 2893 * 2894 * @private 2895 * @param {Array} array The array to iterate over. 2896 * @param {Function} iteratee The iteratee invoked per iteration. 2897 * @param {Function} comparator The comparator used to compare values. 2898 * @returns {*} Returns the extremum value. 2899 */ 2900 function baseExtremum(array, iteratee, comparator) { 2901 var index = -1, 2902 length = array.length; 2903 2904 while (++index < length) { 2905 var value = array[index], 2906 current = iteratee(value); 2907 2908 if (current != null && (computed === undefined 2909 ? (current === current && !isSymbol(current)) 2910 : comparator(current, computed) 2911 )) { 2912 var computed = current, 2913 result = value; 2914 } 2915 } 2916 return result; 2917 } 2918 2919 /** 2920 * The base implementation of `_.fill` without an iteratee call guard. 2921 * 2922 * @private 2923 * @param {Array} array The array to fill. 2924 * @param {*} value The value to fill `array` with. 2925 * @param {number} [start=0] The start position. 2926 * @param {number} [end=array.length] The end position. 2927 * @returns {Array} Returns `array`. 2928 */ 2929 function baseFill(array, value, start, end) { 2930 var length = array.length; 2931 2932 start = toInteger(start); 2933 if (start < 0) { 2934 start = -start > length ? 0 : (length + start); 2935 } 2936 end = (end === undefined || end > length) ? length : toInteger(end); 2937 if (end < 0) { 2938 end += length; 2939 } 2940 end = start > end ? 0 : toLength(end); 2941 while (start < end) { 2942 array[start++] = value; 2943 } 2944 return array; 2945 } 2946 2947 /** 2948 * The base implementation of `_.filter` without support for iteratee shorthands. 2949 * 2950 * @private 2951 * @param {Array|Object} collection The collection to iterate over. 2952 * @param {Function} predicate The function invoked per iteration. 2953 * @returns {Array} Returns the new filtered array. 2954 */ 2955 function baseFilter(collection, predicate) { 2956 var result = []; 2957 baseEach(collection, function(value, index, collection) { 2958 if (predicate(value, index, collection)) { 2959 result.push(value); 2960 } 2961 }); 2962 return result; 2963 } 2964 2965 /** 2966 * The base implementation of `_.flatten` with support for restricting flattening. 2967 * 2968 * @private 2969 * @param {Array} array The array to flatten. 2970 * @param {number} depth The maximum recursion depth. 2971 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 2972 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 2973 * @param {Array} [result=[]] The initial result value. 2974 * @returns {Array} Returns the new flattened array. 2975 */ 2976 function baseFlatten(array, depth, predicate, isStrict, result) { 2977 var index = -1, 2978 length = array.length; 2979 2980 predicate || (predicate = isFlattenable); 2981 result || (result = []); 2982 2983 while (++index < length) { 2984 var value = array[index]; 2985 if (depth > 0 && predicate(value)) { 2986 if (depth > 1) { 2987 // Recursively flatten arrays (susceptible to call stack limits). 2988 baseFlatten(value, depth - 1, predicate, isStrict, result); 2989 } else { 2990 arrayPush(result, value); 2991 } 2992 } else if (!isStrict) { 2993 result[result.length] = value; 2994 } 2995 } 2996 return result; 2997 } 2998 2999 /** 3000 * The base implementation of `baseForOwn` which iterates over `object` 3001 * properties returned by `keysFunc` and invokes `iteratee` for each property. 3002 * Iteratee functions may exit iteration early by explicitly returning `false`. 3003 * 3004 * @private 3005 * @param {Object} object The object to iterate over. 3006 * @param {Function} iteratee The function invoked per iteration. 3007 * @param {Function} keysFunc The function to get the keys of `object`. 3008 * @returns {Object} Returns `object`. 3009 */ 3010 var baseFor = createBaseFor(); 3011 3012 /** 3013 * This function is like `baseFor` except that it iterates over properties 3014 * in the opposite order. 3015 * 3016 * @private 3017 * @param {Object} object The object to iterate over. 3018 * @param {Function} iteratee The function invoked per iteration. 3019 * @param {Function} keysFunc The function to get the keys of `object`. 3020 * @returns {Object} Returns `object`. 3021 */ 3022 var baseForRight = createBaseFor(true); 3023 3024 /** 3025 * The base implementation of `_.forOwn` without support for iteratee shorthands. 3026 * 3027 * @private 3028 * @param {Object} object The object to iterate over. 3029 * @param {Function} iteratee The function invoked per iteration. 3030 * @returns {Object} Returns `object`. 3031 */ 3032 function baseForOwn(object, iteratee) { 3033 return object && baseFor(object, iteratee, keys); 3034 } 3035 3036 /** 3037 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 3038 * 3039 * @private 3040 * @param {Object} object The object to iterate over. 3041 * @param {Function} iteratee The function invoked per iteration. 3042 * @returns {Object} Returns `object`. 3043 */ 3044 function baseForOwnRight(object, iteratee) { 3045 return object && baseForRight(object, iteratee, keys); 3046 } 3047 3048 /** 3049 * The base implementation of `_.functions` which creates an array of 3050 * `object` function property names filtered from `props`. 3051 * 3052 * @private 3053 * @param {Object} object The object to inspect. 3054 * @param {Array} props The property names to filter. 3055 * @returns {Array} Returns the function names. 3056 */ 3057 function baseFunctions(object, props) { 3058 return arrayFilter(props, function(key) { 3059 return isFunction(object[key]); 3060 }); 3061 } 3062 3063 /** 3064 * The base implementation of `_.get` without support for default values. 3065 * 3066 * @private 3067 * @param {Object} object The object to query. 3068 * @param {Array|string} path The path of the property to get. 3069 * @returns {*} Returns the resolved value. 3070 */ 3071 function baseGet(object, path) { 3072 path = castPath(path, object); 3073 3074 var index = 0, 3075 length = path.length; 3076 3077 while (object != null && index < length) { 3078 object = object[toKey(path[index++])]; 3079 } 3080 return (index && index == length) ? object : undefined; 3081 } 3082 3083 /** 3084 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 3085 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 3086 * symbols of `object`. 3087 * 3088 * @private 3089 * @param {Object} object The object to query. 3090 * @param {Function} keysFunc The function to get the keys of `object`. 3091 * @param {Function} symbolsFunc The function to get the symbols of `object`. 3092 * @returns {Array} Returns the array of property names and symbols. 3093 */ 3094 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 3095 var result = keysFunc(object); 3096 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 3097 } 3098 3099 /** 3100 * The base implementation of `getTag` without fallbacks for buggy environments. 3101 * 3102 * @private 3103 * @param {*} value The value to query. 3104 * @returns {string} Returns the `toStringTag`. 3105 */ 3106 function baseGetTag(value) { 3107 if (value == null) { 3108 return value === undefined ? undefinedTag : nullTag; 3109 } 3110 return (symToStringTag && symToStringTag in Object(value)) 3111 ? getRawTag(value) 3112 : objectToString(value); 3113 } 3114 3115 /** 3116 * The base implementation of `_.gt` which doesn't coerce arguments. 3117 * 3118 * @private 3119 * @param {*} value The value to compare. 3120 * @param {*} other The other value to compare. 3121 * @returns {boolean} Returns `true` if `value` is greater than `other`, 3122 * else `false`. 3123 */ 3124 function baseGt(value, other) { 3125 return value > other; 3126 } 3127 3128 /** 3129 * The base implementation of `_.has` without support for deep paths. 3130 * 3131 * @private 3132 * @param {Object} [object] The object to query. 3133 * @param {Array|string} key The key to check. 3134 * @returns {boolean} Returns `true` if `key` exists, else `false`. 3135 */ 3136 function baseHas(object, key) { 3137 return object != null && hasOwnProperty.call(object, key); 3138 } 3139 3140 /** 3141 * The base implementation of `_.hasIn` without support for deep paths. 3142 * 3143 * @private 3144 * @param {Object} [object] The object to query. 3145 * @param {Array|string} key The key to check. 3146 * @returns {boolean} Returns `true` if `key` exists, else `false`. 3147 */ 3148 function baseHasIn(object, key) { 3149 return object != null && key in Object(object); 3150 } 3151 3152 /** 3153 * The base implementation of `_.inRange` which doesn't coerce arguments. 3154 * 3155 * @private 3156 * @param {number} number The number to check. 3157 * @param {number} start The start of the range. 3158 * @param {number} end The end of the range. 3159 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 3160 */ 3161 function baseInRange(number, start, end) { 3162 return number >= nativeMin(start, end) && number < nativeMax(start, end); 3163 } 3164 3165 /** 3166 * The base implementation of methods like `_.intersection`, without support 3167 * for iteratee shorthands, that accepts an array of arrays to inspect. 3168 * 3169 * @private 3170 * @param {Array} arrays The arrays to inspect. 3171 * @param {Function} [iteratee] The iteratee invoked per element. 3172 * @param {Function} [comparator] The comparator invoked per element. 3173 * @returns {Array} Returns the new array of shared values. 3174 */ 3175 function baseIntersection(arrays, iteratee, comparator) { 3176 var includes = comparator ? arrayIncludesWith : arrayIncludes, 3177 length = arrays[0].length, 3178 othLength = arrays.length, 3179 othIndex = othLength, 3180 caches = Array(othLength), 3181 maxLength = Infinity, 3182 result = []; 3183 3184 while (othIndex--) { 3185 var array = arrays[othIndex]; 3186 if (othIndex && iteratee) { 3187 array = arrayMap(array, baseUnary(iteratee)); 3188 } 3189 maxLength = nativeMin(array.length, maxLength); 3190 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 3191 ? new SetCache(othIndex && array) 3192 : undefined; 3193 } 3194 array = arrays[0]; 3195 3196 var index = -1, 3197 seen = caches[0]; 3198 3199 outer: 3200 while (++index < length && result.length < maxLength) { 3201 var value = array[index], 3202 computed = iteratee ? iteratee(value) : value; 3203 3204 value = (comparator || value !== 0) ? value : 0; 3205 if (!(seen 3206 ? cacheHas(seen, computed) 3207 : includes(result, computed, comparator) 3208 )) { 3209 othIndex = othLength; 3210 while (--othIndex) { 3211 var cache = caches[othIndex]; 3212 if (!(cache 3213 ? cacheHas(cache, computed) 3214 : includes(arrays[othIndex], computed, comparator)) 3215 ) { 3216 continue outer; 3217 } 3218 } 3219 if (seen) { 3220 seen.push(computed); 3221 } 3222 result.push(value); 3223 } 3224 } 3225 return result; 3226 } 3227 3228 /** 3229 * The base implementation of `_.invert` and `_.invertBy` which inverts 3230 * `object` with values transformed by `iteratee` and set by `setter`. 3231 * 3232 * @private 3233 * @param {Object} object The object to iterate over. 3234 * @param {Function} setter The function to set `accumulator` values. 3235 * @param {Function} iteratee The iteratee to transform values. 3236 * @param {Object} accumulator The initial inverted object. 3237 * @returns {Function} Returns `accumulator`. 3238 */ 3239 function baseInverter(object, setter, iteratee, accumulator) { 3240 baseForOwn(object, function(value, key, object) { 3241 setter(accumulator, iteratee(value), key, object); 3242 }); 3243 return accumulator; 3244 } 3245 3246 /** 3247 * The base implementation of `_.invoke` without support for individual 3248 * method arguments. 3249 * 3250 * @private 3251 * @param {Object} object The object to query. 3252 * @param {Array|string} path The path of the method to invoke. 3253 * @param {Array} args The arguments to invoke the method with. 3254 * @returns {*} Returns the result of the invoked method. 3255 */ 3256 function baseInvoke(object, path, args) { 3257 path = castPath(path, object); 3258 object = parent(object, path); 3259 var func = object == null ? object : object[toKey(last(path))]; 3260 return func == null ? undefined : apply(func, object, args); 3261 } 3262 3263 /** 3264 * The base implementation of `_.isArguments`. 3265 * 3266 * @private 3267 * @param {*} value The value to check. 3268 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 3269 */ 3270 function baseIsArguments(value) { 3271 return isObjectLike(value) && baseGetTag(value) == argsTag; 3272 } 3273 3274 /** 3275 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 3276 * 3277 * @private 3278 * @param {*} value The value to check. 3279 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 3280 */ 3281 function baseIsArrayBuffer(value) { 3282 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 3283 } 3284 3285 /** 3286 * The base implementation of `_.isDate` without Node.js optimizations. 3287 * 3288 * @private 3289 * @param {*} value The value to check. 3290 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 3291 */ 3292 function baseIsDate(value) { 3293 return isObjectLike(value) && baseGetTag(value) == dateTag; 3294 } 3295 3296 /** 3297 * The base implementation of `_.isEqual` which supports partial comparisons 3298 * and tracks traversed objects. 3299 * 3300 * @private 3301 * @param {*} value The value to compare. 3302 * @param {*} other The other value to compare. 3303 * @param {boolean} bitmask The bitmask flags. 3304 * 1 - Unordered comparison 3305 * 2 - Partial comparison 3306 * @param {Function} [customizer] The function to customize comparisons. 3307 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 3308 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 3309 */ 3310 function baseIsEqual(value, other, bitmask, customizer, stack) { 3311 if (value === other) { 3312 return true; 3313 } 3314 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 3315 return value !== value && other !== other; 3316 } 3317 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 3318 } 3319 3320 /** 3321 * A specialized version of `baseIsEqual` for arrays and objects which performs 3322 * deep comparisons and tracks traversed objects enabling objects with circular 3323 * references to be compared. 3324 * 3325 * @private 3326 * @param {Object} object The object to compare. 3327 * @param {Object} other The other object to compare. 3328 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 3329 * @param {Function} customizer The function to customize comparisons. 3330 * @param {Function} equalFunc The function to determine equivalents of values. 3331 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 3332 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 3333 */ 3334 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 3335 var objIsArr = isArray(object), 3336 othIsArr = isArray(other), 3337 objTag = objIsArr ? arrayTag : getTag(object), 3338 othTag = othIsArr ? arrayTag : getTag(other); 3339 3340 objTag = objTag == argsTag ? objectTag : objTag; 3341 othTag = othTag == argsTag ? objectTag : othTag; 3342 3343 var objIsObj = objTag == objectTag, 3344 othIsObj = othTag == objectTag, 3345 isSameTag = objTag == othTag; 3346 3347 if (isSameTag && isBuffer(object)) { 3348 if (!isBuffer(other)) { 3349 return false; 3350 } 3351 objIsArr = true; 3352 objIsObj = false; 3353 } 3354 if (isSameTag && !objIsObj) { 3355 stack || (stack = new Stack); 3356 return (objIsArr || isTypedArray(object)) 3357 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 3358 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 3359 } 3360 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 3361 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 3362 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 3363 3364 if (objIsWrapped || othIsWrapped) { 3365 var objUnwrapped = objIsWrapped ? object.value() : object, 3366 othUnwrapped = othIsWrapped ? other.value() : other; 3367 3368 stack || (stack = new Stack); 3369 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 3370 } 3371 } 3372 if (!isSameTag) { 3373 return false; 3374 } 3375 stack || (stack = new Stack); 3376 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 3377 } 3378 3379 /** 3380 * The base implementation of `_.isMap` without Node.js optimizations. 3381 * 3382 * @private 3383 * @param {*} value The value to check. 3384 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 3385 */ 3386 function baseIsMap(value) { 3387 return isObjectLike(value) && getTag(value) == mapTag; 3388 } 3389 3390 /** 3391 * The base implementation of `_.isMatch` without support for iteratee shorthands. 3392 * 3393 * @private 3394 * @param {Object} object The object to inspect. 3395 * @param {Object} source The object of property values to match. 3396 * @param {Array} matchData The property names, values, and compare flags to match. 3397 * @param {Function} [customizer] The function to customize comparisons. 3398 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 3399 */ 3400 function baseIsMatch(object, source, matchData, customizer) { 3401 var index = matchData.length, 3402 length = index, 3403 noCustomizer = !customizer; 3404 3405 if (object == null) { 3406 return !length; 3407 } 3408 object = Object(object); 3409 while (index--) { 3410 var data = matchData[index]; 3411 if ((noCustomizer && data[2]) 3412 ? data[1] !== object[data[0]] 3413 : !(data[0] in object) 3414 ) { 3415 return false; 3416 } 3417 } 3418 while (++index < length) { 3419 data = matchData[index]; 3420 var key = data[0], 3421 objValue = object[key], 3422 srcValue = data[1]; 3423 3424 if (noCustomizer && data[2]) { 3425 if (objValue === undefined && !(key in object)) { 3426 return false; 3427 } 3428 } else { 3429 var stack = new Stack; 3430 if (customizer) { 3431 var result = customizer(objValue, srcValue, key, object, source, stack); 3432 } 3433 if (!(result === undefined 3434 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 3435 : result 3436 )) { 3437 return false; 3438 } 3439 } 3440 } 3441 return true; 3442 } 3443 3444 /** 3445 * The base implementation of `_.isNative` without bad shim checks. 3446 * 3447 * @private 3448 * @param {*} value The value to check. 3449 * @returns {boolean} Returns `true` if `value` is a native function, 3450 * else `false`. 3451 */ 3452 function baseIsNative(value) { 3453 if (!isObject(value) || isMasked(value)) { 3454 return false; 3455 } 3456 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 3457 return pattern.test(toSource(value)); 3458 } 3459 3460 /** 3461 * The base implementation of `_.isRegExp` without Node.js optimizations. 3462 * 3463 * @private 3464 * @param {*} value The value to check. 3465 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 3466 */ 3467 function baseIsRegExp(value) { 3468 return isObjectLike(value) && baseGetTag(value) == regexpTag; 3469 } 3470 3471 /** 3472 * The base implementation of `_.isSet` without Node.js optimizations. 3473 * 3474 * @private 3475 * @param {*} value The value to check. 3476 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 3477 */ 3478 function baseIsSet(value) { 3479 return isObjectLike(value) && getTag(value) == setTag; 3480 } 3481 3482 /** 3483 * The base implementation of `_.isTypedArray` without Node.js optimizations. 3484 * 3485 * @private 3486 * @param {*} value The value to check. 3487 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 3488 */ 3489 function baseIsTypedArray(value) { 3490 return isObjectLike(value) && 3491 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 3492 } 3493 3494 /** 3495 * The base implementation of `_.iteratee`. 3496 * 3497 * @private 3498 * @param {*} [value=_.identity] The value to convert to an iteratee. 3499 * @returns {Function} Returns the iteratee. 3500 */ 3501 function baseIteratee(value) { 3502 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 3503 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 3504 if (typeof value == 'function') { 3505 return value; 3506 } 3507 if (value == null) { 3508 return identity; 3509 } 3510 if (typeof value == 'object') { 3511 return isArray(value) 3512 ? baseMatchesProperty(value[0], value[1]) 3513 : baseMatches(value); 3514 } 3515 return property(value); 3516 } 3517 3518 /** 3519 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 3520 * 3521 * @private 3522 * @param {Object} object The object to query. 3523 * @returns {Array} Returns the array of property names. 3524 */ 3525 function baseKeys(object) { 3526 if (!isPrototype(object)) { 3527 return nativeKeys(object); 3528 } 3529 var result = []; 3530 for (var key in Object(object)) { 3531 if (hasOwnProperty.call(object, key) && key != 'constructor') { 3532 result.push(key); 3533 } 3534 } 3535 return result; 3536 } 3537 3538 /** 3539 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 3540 * 3541 * @private 3542 * @param {Object} object The object to query. 3543 * @returns {Array} Returns the array of property names. 3544 */ 3545 function baseKeysIn(object) { 3546 if (!isObject(object)) { 3547 return nativeKeysIn(object); 3548 } 3549 var isProto = isPrototype(object), 3550 result = []; 3551 3552 for (var key in object) { 3553 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 3554 result.push(key); 3555 } 3556 } 3557 return result; 3558 } 3559 3560 /** 3561 * The base implementation of `_.lt` which doesn't coerce arguments. 3562 * 3563 * @private 3564 * @param {*} value The value to compare. 3565 * @param {*} other The other value to compare. 3566 * @returns {boolean} Returns `true` if `value` is less than `other`, 3567 * else `false`. 3568 */ 3569 function baseLt(value, other) { 3570 return value < other; 3571 } 3572 3573 /** 3574 * The base implementation of `_.map` without support for iteratee shorthands. 3575 * 3576 * @private 3577 * @param {Array|Object} collection The collection to iterate over. 3578 * @param {Function} iteratee The function invoked per iteration. 3579 * @returns {Array} Returns the new mapped array. 3580 */ 3581 function baseMap(collection, iteratee) { 3582 var index = -1, 3583 result = isArrayLike(collection) ? Array(collection.length) : []; 3584 3585 baseEach(collection, function(value, key, collection) { 3586 result[++index] = iteratee(value, key, collection); 3587 }); 3588 return result; 3589 } 3590 3591 /** 3592 * The base implementation of `_.matches` which doesn't clone `source`. 3593 * 3594 * @private 3595 * @param {Object} source The object of property values to match. 3596 * @returns {Function} Returns the new spec function. 3597 */ 3598 function baseMatches(source) { 3599 var matchData = getMatchData(source); 3600 if (matchData.length == 1 && matchData[0][2]) { 3601 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 3602 } 3603 return function(object) { 3604 return object === source || baseIsMatch(object, source, matchData); 3605 }; 3606 } 3607 3608 /** 3609 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 3610 * 3611 * @private 3612 * @param {string} path The path of the property to get. 3613 * @param {*} srcValue The value to match. 3614 * @returns {Function} Returns the new spec function. 3615 */ 3616 function baseMatchesProperty(path, srcValue) { 3617 if (isKey(path) && isStrictComparable(srcValue)) { 3618 return matchesStrictComparable(toKey(path), srcValue); 3619 } 3620 return function(object) { 3621 var objValue = get(object, path); 3622 return (objValue === undefined && objValue === srcValue) 3623 ? hasIn(object, path) 3624 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 3625 }; 3626 } 3627 3628 /** 3629 * The base implementation of `_.merge` without support for multiple sources. 3630 * 3631 * @private 3632 * @param {Object} object The destination object. 3633 * @param {Object} source The source object. 3634 * @param {number} srcIndex The index of `source`. 3635 * @param {Function} [customizer] The function to customize merged values. 3636 * @param {Object} [stack] Tracks traversed source values and their merged 3637 * counterparts. 3638 */ 3639 function baseMerge(object, source, srcIndex, customizer, stack) { 3640 if (object === source) { 3641 return; 3642 } 3643 baseFor(source, function(srcValue, key) { 3644 stack || (stack = new Stack); 3645 if (isObject(srcValue)) { 3646 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 3647 } 3648 else { 3649 var newValue = customizer 3650 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 3651 : undefined; 3652 3653 if (newValue === undefined) { 3654 newValue = srcValue; 3655 } 3656 assignMergeValue(object, key, newValue); 3657 } 3658 }, keysIn); 3659 } 3660 3661 /** 3662 * A specialized version of `baseMerge` for arrays and objects which performs 3663 * deep merges and tracks traversed objects enabling objects with circular 3664 * references to be merged. 3665 * 3666 * @private 3667 * @param {Object} object The destination object. 3668 * @param {Object} source The source object. 3669 * @param {string} key The key of the value to merge. 3670 * @param {number} srcIndex The index of `source`. 3671 * @param {Function} mergeFunc The function to merge values. 3672 * @param {Function} [customizer] The function to customize assigned values. 3673 * @param {Object} [stack] Tracks traversed source values and their merged 3674 * counterparts. 3675 */ 3676 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 3677 var objValue = safeGet(object, key), 3678 srcValue = safeGet(source, key), 3679 stacked = stack.get(srcValue); 3680 3681 if (stacked) { 3682 assignMergeValue(object, key, stacked); 3683 return; 3684 } 3685 var newValue = customizer 3686 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 3687 : undefined; 3688 3689 var isCommon = newValue === undefined; 3690 3691 if (isCommon) { 3692 var isArr = isArray(srcValue), 3693 isBuff = !isArr && isBuffer(srcValue), 3694 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 3695 3696 newValue = srcValue; 3697 if (isArr || isBuff || isTyped) { 3698 if (isArray(objValue)) { 3699 newValue = objValue; 3700 } 3701 else if (isArrayLikeObject(objValue)) { 3702 newValue = copyArray(objValue); 3703 } 3704 else if (isBuff) { 3705 isCommon = false; 3706 newValue = cloneBuffer(srcValue, true); 3707 } 3708 else if (isTyped) { 3709 isCommon = false; 3710 newValue = cloneTypedArray(srcValue, true); 3711 } 3712 else { 3713 newValue = []; 3714 } 3715 } 3716 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 3717 newValue = objValue; 3718 if (isArguments(objValue)) { 3719 newValue = toPlainObject(objValue); 3720 } 3721 else if (!isObject(objValue) || isFunction(objValue)) { 3722 newValue = initCloneObject(srcValue); 3723 } 3724 } 3725 else { 3726 isCommon = false; 3727 } 3728 } 3729 if (isCommon) { 3730 // Recursively merge objects and arrays (susceptible to call stack limits). 3731 stack.set(srcValue, newValue); 3732 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 3733 stack['delete'](srcValue); 3734 } 3735 assignMergeValue(object, key, newValue); 3736 } 3737 3738 /** 3739 * The base implementation of `_.nth` which doesn't coerce arguments. 3740 * 3741 * @private 3742 * @param {Array} array The array to query. 3743 * @param {number} n The index of the element to return. 3744 * @returns {*} Returns the nth element of `array`. 3745 */ 3746 function baseNth(array, n) { 3747 var length = array.length; 3748 if (!length) { 3749 return; 3750 } 3751 n += n < 0 ? length : 0; 3752 return isIndex(n, length) ? array[n] : undefined; 3753 } 3754 3755 /** 3756 * The base implementation of `_.orderBy` without param guards. 3757 * 3758 * @private 3759 * @param {Array|Object} collection The collection to iterate over. 3760 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 3761 * @param {string[]} orders The sort orders of `iteratees`. 3762 * @returns {Array} Returns the new sorted array. 3763 */ 3764 function baseOrderBy(collection, iteratees, orders) { 3765 if (iteratees.length) { 3766 iteratees = arrayMap(iteratees, function(iteratee) { 3767 if (isArray(iteratee)) { 3768 return function(value) { 3769 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 3770 } 3771 } 3772 return iteratee; 3773 }); 3774 } else { 3775 iteratees = [identity]; 3776 } 3777 3778 var index = -1; 3779 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 3780 3781 var result = baseMap(collection, function(value, key, collection) { 3782 var criteria = arrayMap(iteratees, function(iteratee) { 3783 return iteratee(value); 3784 }); 3785 return { 'criteria': criteria, 'index': ++index, 'value': value }; 3786 }); 3787 3788 return baseSortBy(result, function(object, other) { 3789 return compareMultiple(object, other, orders); 3790 }); 3791 } 3792 3793 /** 3794 * The base implementation of `_.pick` without support for individual 3795 * property identifiers. 3796 * 3797 * @private 3798 * @param {Object} object The source object. 3799 * @param {string[]} paths The property paths to pick. 3800 * @returns {Object} Returns the new object. 3801 */ 3802 function basePick(object, paths) { 3803 return basePickBy(object, paths, function(value, path) { 3804 return hasIn(object, path); 3805 }); 3806 } 3807 3808 /** 3809 * The base implementation of `_.pickBy` without support for iteratee shorthands. 3810 * 3811 * @private 3812 * @param {Object} object The source object. 3813 * @param {string[]} paths The property paths to pick. 3814 * @param {Function} predicate The function invoked per property. 3815 * @returns {Object} Returns the new object. 3816 */ 3817 function basePickBy(object, paths, predicate) { 3818 var index = -1, 3819 length = paths.length, 3820 result = {}; 3821 3822 while (++index < length) { 3823 var path = paths[index], 3824 value = baseGet(object, path); 3825 3826 if (predicate(value, path)) { 3827 baseSet(result, castPath(path, object), value); 3828 } 3829 } 3830 return result; 3831 } 3832 3833 /** 3834 * A specialized version of `baseProperty` which supports deep paths. 3835 * 3836 * @private 3837 * @param {Array|string} path The path of the property to get. 3838 * @returns {Function} Returns the new accessor function. 3839 */ 3840 function basePropertyDeep(path) { 3841 return function(object) { 3842 return baseGet(object, path); 3843 }; 3844 } 3845 3846 /** 3847 * The base implementation of `_.pullAllBy` without support for iteratee 3848 * shorthands. 3849 * 3850 * @private 3851 * @param {Array} array The array to modify. 3852 * @param {Array} values The values to remove. 3853 * @param {Function} [iteratee] The iteratee invoked per element. 3854 * @param {Function} [comparator] The comparator invoked per element. 3855 * @returns {Array} Returns `array`. 3856 */ 3857 function basePullAll(array, values, iteratee, comparator) { 3858 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 3859 index = -1, 3860 length = values.length, 3861 seen = array; 3862 3863 if (array === values) { 3864 values = copyArray(values); 3865 } 3866 if (iteratee) { 3867 seen = arrayMap(array, baseUnary(iteratee)); 3868 } 3869 while (++index < length) { 3870 var fromIndex = 0, 3871 value = values[index], 3872 computed = iteratee ? iteratee(value) : value; 3873 3874 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 3875 if (seen !== array) { 3876 splice.call(seen, fromIndex, 1); 3877 } 3878 splice.call(array, fromIndex, 1); 3879 } 3880 } 3881 return array; 3882 } 3883 3884 /** 3885 * The base implementation of `_.pullAt` without support for individual 3886 * indexes or capturing the removed elements. 3887 * 3888 * @private 3889 * @param {Array} array The array to modify. 3890 * @param {number[]} indexes The indexes of elements to remove. 3891 * @returns {Array} Returns `array`. 3892 */ 3893 function basePullAt(array, indexes) { 3894 var length = array ? indexes.length : 0, 3895 lastIndex = length - 1; 3896 3897 while (length--) { 3898 var index = indexes[length]; 3899 if (length == lastIndex || index !== previous) { 3900 var previous = index; 3901 if (isIndex(index)) { 3902 splice.call(array, index, 1); 3903 } else { 3904 baseUnset(array, index); 3905 } 3906 } 3907 } 3908 return array; 3909 } 3910 3911 /** 3912 * The base implementation of `_.random` without support for returning 3913 * floating-point numbers. 3914 * 3915 * @private 3916 * @param {number} lower The lower bound. 3917 * @param {number} upper The upper bound. 3918 * @returns {number} Returns the random number. 3919 */ 3920 function baseRandom(lower, upper) { 3921 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 3922 } 3923 3924 /** 3925 * The base implementation of `_.range` and `_.rangeRight` which doesn't 3926 * coerce arguments. 3927 * 3928 * @private 3929 * @param {number} start The start of the range. 3930 * @param {number} end The end of the range. 3931 * @param {number} step The value to increment or decrement by. 3932 * @param {boolean} [fromRight] Specify iterating from right to left. 3933 * @returns {Array} Returns the range of numbers. 3934 */ 3935 function baseRange(start, end, step, fromRight) { 3936 var index = -1, 3937 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 3938 result = Array(length); 3939 3940 while (length--) { 3941 result[fromRight ? length : ++index] = start; 3942 start += step; 3943 } 3944 return result; 3945 } 3946 3947 /** 3948 * The base implementation of `_.repeat` which doesn't coerce arguments. 3949 * 3950 * @private 3951 * @param {string} string The string to repeat. 3952 * @param {number} n The number of times to repeat the string. 3953 * @returns {string} Returns the repeated string. 3954 */ 3955 function baseRepeat(string, n) { 3956 var result = ''; 3957 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 3958 return result; 3959 } 3960 // Leverage the exponentiation by squaring algorithm for a faster repeat. 3961 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 3962 do { 3963 if (n % 2) { 3964 result += string; 3965 } 3966 n = nativeFloor(n / 2); 3967 if (n) { 3968 string += string; 3969 } 3970 } while (n); 3971 3972 return result; 3973 } 3974 3975 /** 3976 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 3977 * 3978 * @private 3979 * @param {Function} func The function to apply a rest parameter to. 3980 * @param {number} [start=func.length-1] The start position of the rest parameter. 3981 * @returns {Function} Returns the new function. 3982 */ 3983 function baseRest(func, start) { 3984 return setToString(overRest(func, start, identity), func + ''); 3985 } 3986 3987 /** 3988 * The base implementation of `_.sample`. 3989 * 3990 * @private 3991 * @param {Array|Object} collection The collection to sample. 3992 * @returns {*} Returns the random element. 3993 */ 3994 function baseSample(collection) { 3995 return arraySample(values(collection)); 3996 } 3997 3998 /** 3999 * The base implementation of `_.sampleSize` without param guards. 4000 * 4001 * @private 4002 * @param {Array|Object} collection The collection to sample. 4003 * @param {number} n The number of elements to sample. 4004 * @returns {Array} Returns the random elements. 4005 */ 4006 function baseSampleSize(collection, n) { 4007 var array = values(collection); 4008 return shuffleSelf(array, baseClamp(n, 0, array.length)); 4009 } 4010 4011 /** 4012 * The base implementation of `_.set`. 4013 * 4014 * @private 4015 * @param {Object} object The object to modify. 4016 * @param {Array|string} path The path of the property to set. 4017 * @param {*} value The value to set. 4018 * @param {Function} [customizer] The function to customize path creation. 4019 * @returns {Object} Returns `object`. 4020 */ 4021 function baseSet(object, path, value, customizer) { 4022 if (!isObject(object)) { 4023 return object; 4024 } 4025 path = castPath(path, object); 4026 4027 var index = -1, 4028 length = path.length, 4029 lastIndex = length - 1, 4030 nested = object; 4031 4032 while (nested != null && ++index < length) { 4033 var key = toKey(path[index]), 4034 newValue = value; 4035 4036 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 4037 return object; 4038 } 4039 4040 if (index != lastIndex) { 4041 var objValue = nested[key]; 4042 newValue = customizer ? customizer(objValue, key, nested) : undefined; 4043 if (newValue === undefined) { 4044 newValue = isObject(objValue) 4045 ? objValue 4046 : (isIndex(path[index + 1]) ? [] : {}); 4047 } 4048 } 4049 assignValue(nested, key, newValue); 4050 nested = nested[key]; 4051 } 4052 return object; 4053 } 4054 4055 /** 4056 * The base implementation of `setData` without support for hot loop shorting. 4057 * 4058 * @private 4059 * @param {Function} func The function to associate metadata with. 4060 * @param {*} data The metadata. 4061 * @returns {Function} Returns `func`. 4062 */ 4063 var baseSetData = !metaMap ? identity : function(func, data) { 4064 metaMap.set(func, data); 4065 return func; 4066 }; 4067 4068 /** 4069 * The base implementation of `setToString` without support for hot loop shorting. 4070 * 4071 * @private 4072 * @param {Function} func The function to modify. 4073 * @param {Function} string The `toString` result. 4074 * @returns {Function} Returns `func`. 4075 */ 4076 var baseSetToString = !defineProperty ? identity : function(func, string) { 4077 return defineProperty(func, 'toString', { 4078 'configurable': true, 4079 'enumerable': false, 4080 'value': constant(string), 4081 'writable': true 4082 }); 4083 }; 4084 4085 /** 4086 * The base implementation of `_.shuffle`. 4087 * 4088 * @private 4089 * @param {Array|Object} collection The collection to shuffle. 4090 * @returns {Array} Returns the new shuffled array. 4091 */ 4092 function baseShuffle(collection) { 4093 return shuffleSelf(values(collection)); 4094 } 4095 4096 /** 4097 * The base implementation of `_.slice` without an iteratee call guard. 4098 * 4099 * @private 4100 * @param {Array} array The array to slice. 4101 * @param {number} [start=0] The start position. 4102 * @param {number} [end=array.length] The end position. 4103 * @returns {Array} Returns the slice of `array`. 4104 */ 4105 function baseSlice(array, start, end) { 4106 var index = -1, 4107 length = array.length; 4108 4109 if (start < 0) { 4110 start = -start > length ? 0 : (length + start); 4111 } 4112 end = end > length ? length : end; 4113 if (end < 0) { 4114 end += length; 4115 } 4116 length = start > end ? 0 : ((end - start) >>> 0); 4117 start >>>= 0; 4118 4119 var result = Array(length); 4120 while (++index < length) { 4121 result[index] = array[index + start]; 4122 } 4123 return result; 4124 } 4125 4126 /** 4127 * The base implementation of `_.some` without support for iteratee shorthands. 4128 * 4129 * @private 4130 * @param {Array|Object} collection The collection to iterate over. 4131 * @param {Function} predicate The function invoked per iteration. 4132 * @returns {boolean} Returns `true` if any element passes the predicate check, 4133 * else `false`. 4134 */ 4135 function baseSome(collection, predicate) { 4136 var result; 4137 4138 baseEach(collection, function(value, index, collection) { 4139 result = predicate(value, index, collection); 4140 return !result; 4141 }); 4142 return !!result; 4143 } 4144 4145 /** 4146 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 4147 * performs a binary search of `array` to determine the index at which `value` 4148 * should be inserted into `array` in order to maintain its sort order. 4149 * 4150 * @private 4151 * @param {Array} array The sorted array to inspect. 4152 * @param {*} value The value to evaluate. 4153 * @param {boolean} [retHighest] Specify returning the highest qualified index. 4154 * @returns {number} Returns the index at which `value` should be inserted 4155 * into `array`. 4156 */ 4157 function baseSortedIndex(array, value, retHighest) { 4158 var low = 0, 4159 high = array == null ? low : array.length; 4160 4161 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 4162 while (low < high) { 4163 var mid = (low + high) >>> 1, 4164 computed = array[mid]; 4165 4166 if (computed !== null && !isSymbol(computed) && 4167 (retHighest ? (computed <= value) : (computed < value))) { 4168 low = mid + 1; 4169 } else { 4170 high = mid; 4171 } 4172 } 4173 return high; 4174 } 4175 return baseSortedIndexBy(array, value, identity, retHighest); 4176 } 4177 4178 /** 4179 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 4180 * which invokes `iteratee` for `value` and each element of `array` to compute 4181 * their sort ranking. The iteratee is invoked with one argument; (value). 4182 * 4183 * @private 4184 * @param {Array} array The sorted array to inspect. 4185 * @param {*} value The value to evaluate. 4186 * @param {Function} iteratee The iteratee invoked per element. 4187 * @param {boolean} [retHighest] Specify returning the highest qualified index. 4188 * @returns {number} Returns the index at which `value` should be inserted 4189 * into `array`. 4190 */ 4191 function baseSortedIndexBy(array, value, iteratee, retHighest) { 4192 var low = 0, 4193 high = array == null ? 0 : array.length; 4194 if (high === 0) { 4195 return 0; 4196 } 4197 4198 value = iteratee(value); 4199 var valIsNaN = value !== value, 4200 valIsNull = value === null, 4201 valIsSymbol = isSymbol(value), 4202 valIsUndefined = value === undefined; 4203 4204 while (low < high) { 4205 var mid = nativeFloor((low + high) / 2), 4206 computed = iteratee(array[mid]), 4207 othIsDefined = computed !== undefined, 4208 othIsNull = computed === null, 4209 othIsReflexive = computed === computed, 4210 othIsSymbol = isSymbol(computed); 4211 4212 if (valIsNaN) { 4213 var setLow = retHighest || othIsReflexive; 4214 } else if (valIsUndefined) { 4215 setLow = othIsReflexive && (retHighest || othIsDefined); 4216 } else if (valIsNull) { 4217 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 4218 } else if (valIsSymbol) { 4219 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 4220 } else if (othIsNull || othIsSymbol) { 4221 setLow = false; 4222 } else { 4223 setLow = retHighest ? (computed <= value) : (computed < value); 4224 } 4225 if (setLow) { 4226 low = mid + 1; 4227 } else { 4228 high = mid; 4229 } 4230 } 4231 return nativeMin(high, MAX_ARRAY_INDEX); 4232 } 4233 4234 /** 4235 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 4236 * support for iteratee shorthands. 4237 * 4238 * @private 4239 * @param {Array} array The array to inspect. 4240 * @param {Function} [iteratee] The iteratee invoked per element. 4241 * @returns {Array} Returns the new duplicate free array. 4242 */ 4243 function baseSortedUniq(array, iteratee) { 4244 var index = -1, 4245 length = array.length, 4246 resIndex = 0, 4247 result = []; 4248 4249 while (++index < length) { 4250 var value = array[index], 4251 computed = iteratee ? iteratee(value) : value; 4252 4253 if (!index || !eq(computed, seen)) { 4254 var seen = computed; 4255 result[resIndex++] = value === 0 ? 0 : value; 4256 } 4257 } 4258 return result; 4259 } 4260 4261 /** 4262 * The base implementation of `_.toNumber` which doesn't ensure correct 4263 * conversions of binary, hexadecimal, or octal string values. 4264 * 4265 * @private 4266 * @param {*} value The value to process. 4267 * @returns {number} Returns the number. 4268 */ 4269 function baseToNumber(value) { 4270 if (typeof value == 'number') { 4271 return value; 4272 } 4273 if (isSymbol(value)) { 4274 return NAN; 4275 } 4276 return +value; 4277 } 4278 4279 /** 4280 * The base implementation of `_.toString` which doesn't convert nullish 4281 * values to empty strings. 4282 * 4283 * @private 4284 * @param {*} value The value to process. 4285 * @returns {string} Returns the string. 4286 */ 4287 function baseToString(value) { 4288 // Exit early for strings to avoid a performance hit in some environments. 4289 if (typeof value == 'string') { 4290 return value; 4291 } 4292 if (isArray(value)) { 4293 // Recursively convert values (susceptible to call stack limits). 4294 return arrayMap(value, baseToString) + ''; 4295 } 4296 if (isSymbol(value)) { 4297 return symbolToString ? symbolToString.call(value) : ''; 4298 } 4299 var result = (value + ''); 4300 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 4301 } 4302 4303 /** 4304 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 4305 * 4306 * @private 4307 * @param {Array} array The array to inspect. 4308 * @param {Function} [iteratee] The iteratee invoked per element. 4309 * @param {Function} [comparator] The comparator invoked per element. 4310 * @returns {Array} Returns the new duplicate free array. 4311 */ 4312 function baseUniq(array, iteratee, comparator) { 4313 var index = -1, 4314 includes = arrayIncludes, 4315 length = array.length, 4316 isCommon = true, 4317 result = [], 4318 seen = result; 4319 4320 if (comparator) { 4321 isCommon = false; 4322 includes = arrayIncludesWith; 4323 } 4324 else if (length >= LARGE_ARRAY_SIZE) { 4325 var set = iteratee ? null : createSet(array); 4326 if (set) { 4327 return setToArray(set); 4328 } 4329 isCommon = false; 4330 includes = cacheHas; 4331 seen = new SetCache; 4332 } 4333 else { 4334 seen = iteratee ? [] : result; 4335 } 4336 outer: 4337 while (++index < length) { 4338 var value = array[index], 4339 computed = iteratee ? iteratee(value) : value; 4340 4341 value = (comparator || value !== 0) ? value : 0; 4342 if (isCommon && computed === computed) { 4343 var seenIndex = seen.length; 4344 while (seenIndex--) { 4345 if (seen[seenIndex] === computed) { 4346 continue outer; 4347 } 4348 } 4349 if (iteratee) { 4350 seen.push(computed); 4351 } 4352 result.push(value); 4353 } 4354 else if (!includes(seen, computed, comparator)) { 4355 if (seen !== result) { 4356 seen.push(computed); 4357 } 4358 result.push(value); 4359 } 4360 } 4361 return result; 4362 } 4363 4364 /** 4365 * The base implementation of `_.unset`. 4366 * 4367 * @private 4368 * @param {Object} object The object to modify. 4369 * @param {Array|string} path The property path to unset. 4370 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 4371 */ 4372 function baseUnset(object, path) { 4373 path = castPath(path, object); 4374 object = parent(object, path); 4375 return object == null || delete object[toKey(last(path))]; 4376 } 4377 4378 /** 4379 * The base implementation of `_.update`. 4380 * 4381 * @private 4382 * @param {Object} object The object to modify. 4383 * @param {Array|string} path The path of the property to update. 4384 * @param {Function} updater The function to produce the updated value. 4385 * @param {Function} [customizer] The function to customize path creation. 4386 * @returns {Object} Returns `object`. 4387 */ 4388 function baseUpdate(object, path, updater, customizer) { 4389 return baseSet(object, path, updater(baseGet(object, path)), customizer); 4390 } 4391 4392 /** 4393 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 4394 * without support for iteratee shorthands. 4395 * 4396 * @private 4397 * @param {Array} array The array to query. 4398 * @param {Function} predicate The function invoked per iteration. 4399 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 4400 * @param {boolean} [fromRight] Specify iterating from right to left. 4401 * @returns {Array} Returns the slice of `array`. 4402 */ 4403 function baseWhile(array, predicate, isDrop, fromRight) { 4404 var length = array.length, 4405 index = fromRight ? length : -1; 4406 4407 while ((fromRight ? index-- : ++index < length) && 4408 predicate(array[index], index, array)) {} 4409 4410 return isDrop 4411 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 4412 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 4413 } 4414 4415 /** 4416 * The base implementation of `wrapperValue` which returns the result of 4417 * performing a sequence of actions on the unwrapped `value`, where each 4418 * successive action is supplied the return value of the previous. 4419 * 4420 * @private 4421 * @param {*} value The unwrapped value. 4422 * @param {Array} actions Actions to perform to resolve the unwrapped value. 4423 * @returns {*} Returns the resolved value. 4424 */ 4425 function baseWrapperValue(value, actions) { 4426 var result = value; 4427 if (result instanceof LazyWrapper) { 4428 result = result.value(); 4429 } 4430 return arrayReduce(actions, function(result, action) { 4431 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 4432 }, result); 4433 } 4434 4435 /** 4436 * The base implementation of methods like `_.xor`, without support for 4437 * iteratee shorthands, that accepts an array of arrays to inspect. 4438 * 4439 * @private 4440 * @param {Array} arrays The arrays to inspect. 4441 * @param {Function} [iteratee] The iteratee invoked per element. 4442 * @param {Function} [comparator] The comparator invoked per element. 4443 * @returns {Array} Returns the new array of values. 4444 */ 4445 function baseXor(arrays, iteratee, comparator) { 4446 var length = arrays.length; 4447 if (length < 2) { 4448 return length ? baseUniq(arrays[0]) : []; 4449 } 4450 var index = -1, 4451 result = Array(length); 4452 4453 while (++index < length) { 4454 var array = arrays[index], 4455 othIndex = -1; 4456 4457 while (++othIndex < length) { 4458 if (othIndex != index) { 4459 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 4460 } 4461 } 4462 } 4463 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 4464 } 4465 4466 /** 4467 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 4468 * 4469 * @private 4470 * @param {Array} props The property identifiers. 4471 * @param {Array} values The property values. 4472 * @param {Function} assignFunc The function to assign values. 4473 * @returns {Object} Returns the new object. 4474 */ 4475 function baseZipObject(props, values, assignFunc) { 4476 var index = -1, 4477 length = props.length, 4478 valsLength = values.length, 4479 result = {}; 4480 4481 while (++index < length) { 4482 var value = index < valsLength ? values[index] : undefined; 4483 assignFunc(result, props[index], value); 4484 } 4485 return result; 4486 } 4487 4488 /** 4489 * Casts `value` to an empty array if it's not an array like object. 4490 * 4491 * @private 4492 * @param {*} value The value to inspect. 4493 * @returns {Array|Object} Returns the cast array-like object. 4494 */ 4495 function castArrayLikeObject(value) { 4496 return isArrayLikeObject(value) ? value : []; 4497 } 4498 4499 /** 4500 * Casts `value` to `identity` if it's not a function. 4501 * 4502 * @private 4503 * @param {*} value The value to inspect. 4504 * @returns {Function} Returns cast function. 4505 */ 4506 function castFunction(value) { 4507 return typeof value == 'function' ? value : identity; 4508 } 4509 4510 /** 4511 * Casts `value` to a path array if it's not one. 4512 * 4513 * @private 4514 * @param {*} value The value to inspect. 4515 * @param {Object} [object] The object to query keys on. 4516 * @returns {Array} Returns the cast property path array. 4517 */ 4518 function castPath(value, object) { 4519 if (isArray(value)) { 4520 return value; 4521 } 4522 return isKey(value, object) ? [value] : stringToPath(toString(value)); 4523 } 4524 4525 /** 4526 * A `baseRest` alias which can be replaced with `identity` by module 4527 * replacement plugins. 4528 * 4529 * @private 4530 * @type {Function} 4531 * @param {Function} func The function to apply a rest parameter to. 4532 * @returns {Function} Returns the new function. 4533 */ 4534 var castRest = baseRest; 4535 4536 /** 4537 * Casts `array` to a slice if it's needed. 4538 * 4539 * @private 4540 * @param {Array} array The array to inspect. 4541 * @param {number} start The start position. 4542 * @param {number} [end=array.length] The end position. 4543 * @returns {Array} Returns the cast slice. 4544 */ 4545 function castSlice(array, start, end) { 4546 var length = array.length; 4547 end = end === undefined ? length : end; 4548 return (!start && end >= length) ? array : baseSlice(array, start, end); 4549 } 4550 4551 /** 4552 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 4553 * 4554 * @private 4555 * @param {number|Object} id The timer id or timeout object of the timer to clear. 4556 */ 4557 var clearTimeout = ctxClearTimeout || function(id) { 4558 return root.clearTimeout(id); 4559 }; 4560 4561 /** 4562 * Creates a clone of `buffer`. 4563 * 4564 * @private 4565 * @param {Buffer} buffer The buffer to clone. 4566 * @param {boolean} [isDeep] Specify a deep clone. 4567 * @returns {Buffer} Returns the cloned buffer. 4568 */ 4569 function cloneBuffer(buffer, isDeep) { 4570 if (isDeep) { 4571 return buffer.slice(); 4572 } 4573 var length = buffer.length, 4574 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 4575 4576 buffer.copy(result); 4577 return result; 4578 } 4579 4580 /** 4581 * Creates a clone of `arrayBuffer`. 4582 * 4583 * @private 4584 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 4585 * @returns {ArrayBuffer} Returns the cloned array buffer. 4586 */ 4587 function cloneArrayBuffer(arrayBuffer) { 4588 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 4589 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 4590 return result; 4591 } 4592 4593 /** 4594 * Creates a clone of `dataView`. 4595 * 4596 * @private 4597 * @param {Object} dataView The data view to clone. 4598 * @param {boolean} [isDeep] Specify a deep clone. 4599 * @returns {Object} Returns the cloned data view. 4600 */ 4601 function cloneDataView(dataView, isDeep) { 4602 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 4603 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 4604 } 4605 4606 /** 4607 * Creates a clone of `regexp`. 4608 * 4609 * @private 4610 * @param {Object} regexp The regexp to clone. 4611 * @returns {Object} Returns the cloned regexp. 4612 */ 4613 function cloneRegExp(regexp) { 4614 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 4615 result.lastIndex = regexp.lastIndex; 4616 return result; 4617 } 4618 4619 /** 4620 * Creates a clone of the `symbol` object. 4621 * 4622 * @private 4623 * @param {Object} symbol The symbol object to clone. 4624 * @returns {Object} Returns the cloned symbol object. 4625 */ 4626 function cloneSymbol(symbol) { 4627 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 4628 } 4629 4630 /** 4631 * Creates a clone of `typedArray`. 4632 * 4633 * @private 4634 * @param {Object} typedArray The typed array to clone. 4635 * @param {boolean} [isDeep] Specify a deep clone. 4636 * @returns {Object} Returns the cloned typed array. 4637 */ 4638 function cloneTypedArray(typedArray, isDeep) { 4639 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 4640 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 4641 } 4642 4643 /** 4644 * Compares values to sort them in ascending order. 4645 * 4646 * @private 4647 * @param {*} value The value to compare. 4648 * @param {*} other The other value to compare. 4649 * @returns {number} Returns the sort order indicator for `value`. 4650 */ 4651 function compareAscending(value, other) { 4652 if (value !== other) { 4653 var valIsDefined = value !== undefined, 4654 valIsNull = value === null, 4655 valIsReflexive = value === value, 4656 valIsSymbol = isSymbol(value); 4657 4658 var othIsDefined = other !== undefined, 4659 othIsNull = other === null, 4660 othIsReflexive = other === other, 4661 othIsSymbol = isSymbol(other); 4662 4663 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 4664 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 4665 (valIsNull && othIsDefined && othIsReflexive) || 4666 (!valIsDefined && othIsReflexive) || 4667 !valIsReflexive) { 4668 return 1; 4669 } 4670 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 4671 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 4672 (othIsNull && valIsDefined && valIsReflexive) || 4673 (!othIsDefined && valIsReflexive) || 4674 !othIsReflexive) { 4675 return -1; 4676 } 4677 } 4678 return 0; 4679 } 4680 4681 /** 4682 * Used by `_.orderBy` to compare multiple properties of a value to another 4683 * and stable sort them. 4684 * 4685 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 4686 * specify an order of "desc" for descending or "asc" for ascending sort order 4687 * of corresponding values. 4688 * 4689 * @private 4690 * @param {Object} object The object to compare. 4691 * @param {Object} other The other object to compare. 4692 * @param {boolean[]|string[]} orders The order to sort by for each property. 4693 * @returns {number} Returns the sort order indicator for `object`. 4694 */ 4695 function compareMultiple(object, other, orders) { 4696 var index = -1, 4697 objCriteria = object.criteria, 4698 othCriteria = other.criteria, 4699 length = objCriteria.length, 4700 ordersLength = orders.length; 4701 4702 while (++index < length) { 4703 var result = compareAscending(objCriteria[index], othCriteria[index]); 4704 if (result) { 4705 if (index >= ordersLength) { 4706 return result; 4707 } 4708 var order = orders[index]; 4709 return result * (order == 'desc' ? -1 : 1); 4710 } 4711 } 4712 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 4713 // that causes it, under certain circumstances, to provide the same value for 4714 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 4715 // for more details. 4716 // 4717 // This also ensures a stable sort in V8 and other engines. 4718 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 4719 return object.index - other.index; 4720 } 4721 4722 /** 4723 * Creates an array that is the composition of partially applied arguments, 4724 * placeholders, and provided arguments into a single array of arguments. 4725 * 4726 * @private 4727 * @param {Array} args The provided arguments. 4728 * @param {Array} partials The arguments to prepend to those provided. 4729 * @param {Array} holders The `partials` placeholder indexes. 4730 * @params {boolean} [isCurried] Specify composing for a curried function. 4731 * @returns {Array} Returns the new array of composed arguments. 4732 */ 4733 function composeArgs(args, partials, holders, isCurried) { 4734 var argsIndex = -1, 4735 argsLength = args.length, 4736 holdersLength = holders.length, 4737 leftIndex = -1, 4738 leftLength = partials.length, 4739 rangeLength = nativeMax(argsLength - holdersLength, 0), 4740 result = Array(leftLength + rangeLength), 4741 isUncurried = !isCurried; 4742 4743 while (++leftIndex < leftLength) { 4744 result[leftIndex] = partials[leftIndex]; 4745 } 4746 while (++argsIndex < holdersLength) { 4747 if (isUncurried || argsIndex < argsLength) { 4748 result[holders[argsIndex]] = args[argsIndex]; 4749 } 4750 } 4751 while (rangeLength--) { 4752 result[leftIndex++] = args[argsIndex++]; 4753 } 4754 return result; 4755 } 4756 4757 /** 4758 * This function is like `composeArgs` except that the arguments composition 4759 * is tailored for `_.partialRight`. 4760 * 4761 * @private 4762 * @param {Array} args The provided arguments. 4763 * @param {Array} partials The arguments to append to those provided. 4764 * @param {Array} holders The `partials` placeholder indexes. 4765 * @params {boolean} [isCurried] Specify composing for a curried function. 4766 * @returns {Array} Returns the new array of composed arguments. 4767 */ 4768 function composeArgsRight(args, partials, holders, isCurried) { 4769 var argsIndex = -1, 4770 argsLength = args.length, 4771 holdersIndex = -1, 4772 holdersLength = holders.length, 4773 rightIndex = -1, 4774 rightLength = partials.length, 4775 rangeLength = nativeMax(argsLength - holdersLength, 0), 4776 result = Array(rangeLength + rightLength), 4777 isUncurried = !isCurried; 4778 4779 while (++argsIndex < rangeLength) { 4780 result[argsIndex] = args[argsIndex]; 4781 } 4782 var offset = argsIndex; 4783 while (++rightIndex < rightLength) { 4784 result[offset + rightIndex] = partials[rightIndex]; 4785 } 4786 while (++holdersIndex < holdersLength) { 4787 if (isUncurried || argsIndex < argsLength) { 4788 result[offset + holders[holdersIndex]] = args[argsIndex++]; 4789 } 4790 } 4791 return result; 4792 } 4793 4794 /** 4795 * Copies the values of `source` to `array`. 4796 * 4797 * @private 4798 * @param {Array} source The array to copy values from. 4799 * @param {Array} [array=[]] The array to copy values to. 4800 * @returns {Array} Returns `array`. 4801 */ 4802 function copyArray(source, array) { 4803 var index = -1, 4804 length = source.length; 4805 4806 array || (array = Array(length)); 4807 while (++index < length) { 4808 array[index] = source[index]; 4809 } 4810 return array; 4811 } 4812 4813 /** 4814 * Copies properties of `source` to `object`. 4815 * 4816 * @private 4817 * @param {Object} source The object to copy properties from. 4818 * @param {Array} props The property identifiers to copy. 4819 * @param {Object} [object={}] The object to copy properties to. 4820 * @param {Function} [customizer] The function to customize copied values. 4821 * @returns {Object} Returns `object`. 4822 */ 4823 function copyObject(source, props, object, customizer) { 4824 var isNew = !object; 4825 object || (object = {}); 4826 4827 var index = -1, 4828 length = props.length; 4829 4830 while (++index < length) { 4831 var key = props[index]; 4832 4833 var newValue = customizer 4834 ? customizer(object[key], source[key], key, object, source) 4835 : undefined; 4836 4837 if (newValue === undefined) { 4838 newValue = source[key]; 4839 } 4840 if (isNew) { 4841 baseAssignValue(object, key, newValue); 4842 } else { 4843 assignValue(object, key, newValue); 4844 } 4845 } 4846 return object; 4847 } 4848 4849 /** 4850 * Copies own symbols of `source` to `object`. 4851 * 4852 * @private 4853 * @param {Object} source The object to copy symbols from. 4854 * @param {Object} [object={}] The object to copy symbols to. 4855 * @returns {Object} Returns `object`. 4856 */ 4857 function copySymbols(source, object) { 4858 return copyObject(source, getSymbols(source), object); 4859 } 4860 4861 /** 4862 * Copies own and inherited symbols of `source` to `object`. 4863 * 4864 * @private 4865 * @param {Object} source The object to copy symbols from. 4866 * @param {Object} [object={}] The object to copy symbols to. 4867 * @returns {Object} Returns `object`. 4868 */ 4869 function copySymbolsIn(source, object) { 4870 return copyObject(source, getSymbolsIn(source), object); 4871 } 4872 4873 /** 4874 * Creates a function like `_.groupBy`. 4875 * 4876 * @private 4877 * @param {Function} setter The function to set accumulator values. 4878 * @param {Function} [initializer] The accumulator object initializer. 4879 * @returns {Function} Returns the new aggregator function. 4880 */ 4881 function createAggregator(setter, initializer) { 4882 return function(collection, iteratee) { 4883 var func = isArray(collection) ? arrayAggregator : baseAggregator, 4884 accumulator = initializer ? initializer() : {}; 4885 4886 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 4887 }; 4888 } 4889 4890 /** 4891 * Creates a function like `_.assign`. 4892 * 4893 * @private 4894 * @param {Function} assigner The function to assign values. 4895 * @returns {Function} Returns the new assigner function. 4896 */ 4897 function createAssigner(assigner) { 4898 return baseRest(function(object, sources) { 4899 var index = -1, 4900 length = sources.length, 4901 customizer = length > 1 ? sources[length - 1] : undefined, 4902 guard = length > 2 ? sources[2] : undefined; 4903 4904 customizer = (assigner.length > 3 && typeof customizer == 'function') 4905 ? (length--, customizer) 4906 : undefined; 4907 4908 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 4909 customizer = length < 3 ? undefined : customizer; 4910 length = 1; 4911 } 4912 object = Object(object); 4913 while (++index < length) { 4914 var source = sources[index]; 4915 if (source) { 4916 assigner(object, source, index, customizer); 4917 } 4918 } 4919 return object; 4920 }); 4921 } 4922 4923 /** 4924 * Creates a `baseEach` or `baseEachRight` function. 4925 * 4926 * @private 4927 * @param {Function} eachFunc The function to iterate over a collection. 4928 * @param {boolean} [fromRight] Specify iterating from right to left. 4929 * @returns {Function} Returns the new base function. 4930 */ 4931 function createBaseEach(eachFunc, fromRight) { 4932 return function(collection, iteratee) { 4933 if (collection == null) { 4934 return collection; 4935 } 4936 if (!isArrayLike(collection)) { 4937 return eachFunc(collection, iteratee); 4938 } 4939 var length = collection.length, 4940 index = fromRight ? length : -1, 4941 iterable = Object(collection); 4942 4943 while ((fromRight ? index-- : ++index < length)) { 4944 if (iteratee(iterable[index], index, iterable) === false) { 4945 break; 4946 } 4947 } 4948 return collection; 4949 }; 4950 } 4951 4952 /** 4953 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 4954 * 4955 * @private 4956 * @param {boolean} [fromRight] Specify iterating from right to left. 4957 * @returns {Function} Returns the new base function. 4958 */ 4959 function createBaseFor(fromRight) { 4960 return function(object, iteratee, keysFunc) { 4961 var index = -1, 4962 iterable = Object(object), 4963 props = keysFunc(object), 4964 length = props.length; 4965 4966 while (length--) { 4967 var key = props[fromRight ? length : ++index]; 4968 if (iteratee(iterable[key], key, iterable) === false) { 4969 break; 4970 } 4971 } 4972 return object; 4973 }; 4974 } 4975 4976 /** 4977 * Creates a function that wraps `func` to invoke it with the optional `this` 4978 * binding of `thisArg`. 4979 * 4980 * @private 4981 * @param {Function} func The function to wrap. 4982 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 4983 * @param {*} [thisArg] The `this` binding of `func`. 4984 * @returns {Function} Returns the new wrapped function. 4985 */ 4986 function createBind(func, bitmask, thisArg) { 4987 var isBind = bitmask & WRAP_BIND_FLAG, 4988 Ctor = createCtor(func); 4989 4990 function wrapper() { 4991 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 4992 return fn.apply(isBind ? thisArg : this, arguments); 4993 } 4994 return wrapper; 4995 } 4996 4997 /** 4998 * Creates a function like `_.lowerFirst`. 4999 * 5000 * @private 5001 * @param {string} methodName The name of the `String` case method to use. 5002 * @returns {Function} Returns the new case function. 5003 */ 5004 function createCaseFirst(methodName) { 5005 return function(string) { 5006 string = toString(string); 5007 5008 var strSymbols = hasUnicode(string) 5009 ? stringToArray(string) 5010 : undefined; 5011 5012 var chr = strSymbols 5013 ? strSymbols[0] 5014 : string.charAt(0); 5015 5016 var trailing = strSymbols 5017 ? castSlice(strSymbols, 1).join('') 5018 : string.slice(1); 5019 5020 return chr[methodName]() + trailing; 5021 }; 5022 } 5023 5024 /** 5025 * Creates a function like `_.camelCase`. 5026 * 5027 * @private 5028 * @param {Function} callback The function to combine each word. 5029 * @returns {Function} Returns the new compounder function. 5030 */ 5031 function createCompounder(callback) { 5032 return function(string) { 5033 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 5034 }; 5035 } 5036 5037 /** 5038 * Creates a function that produces an instance of `Ctor` regardless of 5039 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 5040 * 5041 * @private 5042 * @param {Function} Ctor The constructor to wrap. 5043 * @returns {Function} Returns the new wrapped function. 5044 */ 5045 function createCtor(Ctor) { 5046 return function() { 5047 // Use a `switch` statement to work with class constructors. See 5048 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 5049 // for more details. 5050 var args = arguments; 5051 switch (args.length) { 5052 case 0: return new Ctor; 5053 case 1: return new Ctor(args[0]); 5054 case 2: return new Ctor(args[0], args[1]); 5055 case 3: return new Ctor(args[0], args[1], args[2]); 5056 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 5057 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 5058 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 5059 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 5060 } 5061 var thisBinding = baseCreate(Ctor.prototype), 5062 result = Ctor.apply(thisBinding, args); 5063 5064 // Mimic the constructor's `return` behavior. 5065 // See https://es5.github.io/#x13.2.2 for more details. 5066 return isObject(result) ? result : thisBinding; 5067 }; 5068 } 5069 5070 /** 5071 * Creates a function that wraps `func` to enable currying. 5072 * 5073 * @private 5074 * @param {Function} func The function to wrap. 5075 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5076 * @param {number} arity The arity of `func`. 5077 * @returns {Function} Returns the new wrapped function. 5078 */ 5079 function createCurry(func, bitmask, arity) { 5080 var Ctor = createCtor(func); 5081 5082 function wrapper() { 5083 var length = arguments.length, 5084 args = Array(length), 5085 index = length, 5086 placeholder = getHolder(wrapper); 5087 5088 while (index--) { 5089 args[index] = arguments[index]; 5090 } 5091 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 5092 ? [] 5093 : replaceHolders(args, placeholder); 5094 5095 length -= holders.length; 5096 if (length < arity) { 5097 return createRecurry( 5098 func, bitmask, createHybrid, wrapper.placeholder, undefined, 5099 args, holders, undefined, undefined, arity - length); 5100 } 5101 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 5102 return apply(fn, this, args); 5103 } 5104 return wrapper; 5105 } 5106 5107 /** 5108 * Creates a `_.find` or `_.findLast` function. 5109 * 5110 * @private 5111 * @param {Function} findIndexFunc The function to find the collection index. 5112 * @returns {Function} Returns the new find function. 5113 */ 5114 function createFind(findIndexFunc) { 5115 return function(collection, predicate, fromIndex) { 5116 var iterable = Object(collection); 5117 if (!isArrayLike(collection)) { 5118 var iteratee = getIteratee(predicate, 3); 5119 collection = keys(collection); 5120 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 5121 } 5122 var index = findIndexFunc(collection, predicate, fromIndex); 5123 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 5124 }; 5125 } 5126 5127 /** 5128 * Creates a `_.flow` or `_.flowRight` function. 5129 * 5130 * @private 5131 * @param {boolean} [fromRight] Specify iterating from right to left. 5132 * @returns {Function} Returns the new flow function. 5133 */ 5134 function createFlow(fromRight) { 5135 return flatRest(function(funcs) { 5136 var length = funcs.length, 5137 index = length, 5138 prereq = LodashWrapper.prototype.thru; 5139 5140 if (fromRight) { 5141 funcs.reverse(); 5142 } 5143 while (index--) { 5144 var func = funcs[index]; 5145 if (typeof func != 'function') { 5146 throw new TypeError(FUNC_ERROR_TEXT); 5147 } 5148 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 5149 var wrapper = new LodashWrapper([], true); 5150 } 5151 } 5152 index = wrapper ? index : length; 5153 while (++index < length) { 5154 func = funcs[index]; 5155 5156 var funcName = getFuncName(func), 5157 data = funcName == 'wrapper' ? getData(func) : undefined; 5158 5159 if (data && isLaziable(data[0]) && 5160 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 5161 !data[4].length && data[9] == 1 5162 ) { 5163 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 5164 } else { 5165 wrapper = (func.length == 1 && isLaziable(func)) 5166 ? wrapper[funcName]() 5167 : wrapper.thru(func); 5168 } 5169 } 5170 return function() { 5171 var args = arguments, 5172 value = args[0]; 5173 5174 if (wrapper && args.length == 1 && isArray(value)) { 5175 return wrapper.plant(value).value(); 5176 } 5177 var index = 0, 5178 result = length ? funcs[index].apply(this, args) : value; 5179 5180 while (++index < length) { 5181 result = funcs[index].call(this, result); 5182 } 5183 return result; 5184 }; 5185 }); 5186 } 5187 5188 /** 5189 * Creates a function that wraps `func` to invoke it with optional `this` 5190 * binding of `thisArg`, partial application, and currying. 5191 * 5192 * @private 5193 * @param {Function|string} func The function or method name to wrap. 5194 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5195 * @param {*} [thisArg] The `this` binding of `func`. 5196 * @param {Array} [partials] The arguments to prepend to those provided to 5197 * the new function. 5198 * @param {Array} [holders] The `partials` placeholder indexes. 5199 * @param {Array} [partialsRight] The arguments to append to those provided 5200 * to the new function. 5201 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 5202 * @param {Array} [argPos] The argument positions of the new function. 5203 * @param {number} [ary] The arity cap of `func`. 5204 * @param {number} [arity] The arity of `func`. 5205 * @returns {Function} Returns the new wrapped function. 5206 */ 5207 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 5208 var isAry = bitmask & WRAP_ARY_FLAG, 5209 isBind = bitmask & WRAP_BIND_FLAG, 5210 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 5211 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 5212 isFlip = bitmask & WRAP_FLIP_FLAG, 5213 Ctor = isBindKey ? undefined : createCtor(func); 5214 5215 function wrapper() { 5216 var length = arguments.length, 5217 args = Array(length), 5218 index = length; 5219 5220 while (index--) { 5221 args[index] = arguments[index]; 5222 } 5223 if (isCurried) { 5224 var placeholder = getHolder(wrapper), 5225 holdersCount = countHolders(args, placeholder); 5226 } 5227 if (partials) { 5228 args = composeArgs(args, partials, holders, isCurried); 5229 } 5230 if (partialsRight) { 5231 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 5232 } 5233 length -= holdersCount; 5234 if (isCurried && length < arity) { 5235 var newHolders = replaceHolders(args, placeholder); 5236 return createRecurry( 5237 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 5238 args, newHolders, argPos, ary, arity - length 5239 ); 5240 } 5241 var thisBinding = isBind ? thisArg : this, 5242 fn = isBindKey ? thisBinding[func] : func; 5243 5244 length = args.length; 5245 if (argPos) { 5246 args = reorder(args, argPos); 5247 } else if (isFlip && length > 1) { 5248 args.reverse(); 5249 } 5250 if (isAry && ary < length) { 5251 args.length = ary; 5252 } 5253 if (this && this !== root && this instanceof wrapper) { 5254 fn = Ctor || createCtor(fn); 5255 } 5256 return fn.apply(thisBinding, args); 5257 } 5258 return wrapper; 5259 } 5260 5261 /** 5262 * Creates a function like `_.invertBy`. 5263 * 5264 * @private 5265 * @param {Function} setter The function to set accumulator values. 5266 * @param {Function} toIteratee The function to resolve iteratees. 5267 * @returns {Function} Returns the new inverter function. 5268 */ 5269 function createInverter(setter, toIteratee) { 5270 return function(object, iteratee) { 5271 return baseInverter(object, setter, toIteratee(iteratee), {}); 5272 }; 5273 } 5274 5275 /** 5276 * Creates a function that performs a mathematical operation on two values. 5277 * 5278 * @private 5279 * @param {Function} operator The function to perform the operation. 5280 * @param {number} [defaultValue] The value used for `undefined` arguments. 5281 * @returns {Function} Returns the new mathematical operation function. 5282 */ 5283 function createMathOperation(operator, defaultValue) { 5284 return function(value, other) { 5285 var result; 5286 if (value === undefined && other === undefined) { 5287 return defaultValue; 5288 } 5289 if (value !== undefined) { 5290 result = value; 5291 } 5292 if (other !== undefined) { 5293 if (result === undefined) { 5294 return other; 5295 } 5296 if (typeof value == 'string' || typeof other == 'string') { 5297 value = baseToString(value); 5298 other = baseToString(other); 5299 } else { 5300 value = baseToNumber(value); 5301 other = baseToNumber(other); 5302 } 5303 result = operator(value, other); 5304 } 5305 return result; 5306 }; 5307 } 5308 5309 /** 5310 * Creates a function like `_.over`. 5311 * 5312 * @private 5313 * @param {Function} arrayFunc The function to iterate over iteratees. 5314 * @returns {Function} Returns the new over function. 5315 */ 5316 function createOver(arrayFunc) { 5317 return flatRest(function(iteratees) { 5318 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 5319 return baseRest(function(args) { 5320 var thisArg = this; 5321 return arrayFunc(iteratees, function(iteratee) { 5322 return apply(iteratee, thisArg, args); 5323 }); 5324 }); 5325 }); 5326 } 5327 5328 /** 5329 * Creates the padding for `string` based on `length`. The `chars` string 5330 * is truncated if the number of characters exceeds `length`. 5331 * 5332 * @private 5333 * @param {number} length The padding length. 5334 * @param {string} [chars=' '] The string used as padding. 5335 * @returns {string} Returns the padding for `string`. 5336 */ 5337 function createPadding(length, chars) { 5338 chars = chars === undefined ? ' ' : baseToString(chars); 5339 5340 var charsLength = chars.length; 5341 if (charsLength < 2) { 5342 return charsLength ? baseRepeat(chars, length) : chars; 5343 } 5344 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 5345 return hasUnicode(chars) 5346 ? castSlice(stringToArray(result), 0, length).join('') 5347 : result.slice(0, length); 5348 } 5349 5350 /** 5351 * Creates a function that wraps `func` to invoke it with the `this` binding 5352 * of `thisArg` and `partials` prepended to the arguments it receives. 5353 * 5354 * @private 5355 * @param {Function} func The function to wrap. 5356 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5357 * @param {*} thisArg The `this` binding of `func`. 5358 * @param {Array} partials The arguments to prepend to those provided to 5359 * the new function. 5360 * @returns {Function} Returns the new wrapped function. 5361 */ 5362 function createPartial(func, bitmask, thisArg, partials) { 5363 var isBind = bitmask & WRAP_BIND_FLAG, 5364 Ctor = createCtor(func); 5365 5366 function wrapper() { 5367 var argsIndex = -1, 5368 argsLength = arguments.length, 5369 leftIndex = -1, 5370 leftLength = partials.length, 5371 args = Array(leftLength + argsLength), 5372 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 5373 5374 while (++leftIndex < leftLength) { 5375 args[leftIndex] = partials[leftIndex]; 5376 } 5377 while (argsLength--) { 5378 args[leftIndex++] = arguments[++argsIndex]; 5379 } 5380 return apply(fn, isBind ? thisArg : this, args); 5381 } 5382 return wrapper; 5383 } 5384 5385 /** 5386 * Creates a `_.range` or `_.rangeRight` function. 5387 * 5388 * @private 5389 * @param {boolean} [fromRight] Specify iterating from right to left. 5390 * @returns {Function} Returns the new range function. 5391 */ 5392 function createRange(fromRight) { 5393 return function(start, end, step) { 5394 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 5395 end = step = undefined; 5396 } 5397 // Ensure the sign of `-0` is preserved. 5398 start = toFinite(start); 5399 if (end === undefined) { 5400 end = start; 5401 start = 0; 5402 } else { 5403 end = toFinite(end); 5404 } 5405 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 5406 return baseRange(start, end, step, fromRight); 5407 }; 5408 } 5409 5410 /** 5411 * Creates a function that performs a relational operation on two values. 5412 * 5413 * @private 5414 * @param {Function} operator The function to perform the operation. 5415 * @returns {Function} Returns the new relational operation function. 5416 */ 5417 function createRelationalOperation(operator) { 5418 return function(value, other) { 5419 if (!(typeof value == 'string' && typeof other == 'string')) { 5420 value = toNumber(value); 5421 other = toNumber(other); 5422 } 5423 return operator(value, other); 5424 }; 5425 } 5426 5427 /** 5428 * Creates a function that wraps `func` to continue currying. 5429 * 5430 * @private 5431 * @param {Function} func The function to wrap. 5432 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5433 * @param {Function} wrapFunc The function to create the `func` wrapper. 5434 * @param {*} placeholder The placeholder value. 5435 * @param {*} [thisArg] The `this` binding of `func`. 5436 * @param {Array} [partials] The arguments to prepend to those provided to 5437 * the new function. 5438 * @param {Array} [holders] The `partials` placeholder indexes. 5439 * @param {Array} [argPos] The argument positions of the new function. 5440 * @param {number} [ary] The arity cap of `func`. 5441 * @param {number} [arity] The arity of `func`. 5442 * @returns {Function} Returns the new wrapped function. 5443 */ 5444 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 5445 var isCurry = bitmask & WRAP_CURRY_FLAG, 5446 newHolders = isCurry ? holders : undefined, 5447 newHoldersRight = isCurry ? undefined : holders, 5448 newPartials = isCurry ? partials : undefined, 5449 newPartialsRight = isCurry ? undefined : partials; 5450 5451 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 5452 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 5453 5454 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 5455 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 5456 } 5457 var newData = [ 5458 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 5459 newHoldersRight, argPos, ary, arity 5460 ]; 5461 5462 var result = wrapFunc.apply(undefined, newData); 5463 if (isLaziable(func)) { 5464 setData(result, newData); 5465 } 5466 result.placeholder = placeholder; 5467 return setWrapToString(result, func, bitmask); 5468 } 5469 5470 /** 5471 * Creates a function like `_.round`. 5472 * 5473 * @private 5474 * @param {string} methodName The name of the `Math` method to use when rounding. 5475 * @returns {Function} Returns the new round function. 5476 */ 5477 function createRound(methodName) { 5478 var func = Math[methodName]; 5479 return function(number, precision) { 5480 number = toNumber(number); 5481 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 5482 if (precision && nativeIsFinite(number)) { 5483 // Shift with exponential notation to avoid floating-point issues. 5484 // See [MDN](https://mdn.io/round#Examples) for more details. 5485 var pair = (toString(number) + 'e').split('e'), 5486 value = func(pair[0] + 'e' + (+pair[1] + precision)); 5487 5488 pair = (toString(value) + 'e').split('e'); 5489 return +(pair[0] + 'e' + (+pair[1] - precision)); 5490 } 5491 return func(number); 5492 }; 5493 } 5494 5495 /** 5496 * Creates a set object of `values`. 5497 * 5498 * @private 5499 * @param {Array} values The values to add to the set. 5500 * @returns {Object} Returns the new set. 5501 */ 5502 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 5503 return new Set(values); 5504 }; 5505 5506 /** 5507 * Creates a `_.toPairs` or `_.toPairsIn` function. 5508 * 5509 * @private 5510 * @param {Function} keysFunc The function to get the keys of a given object. 5511 * @returns {Function} Returns the new pairs function. 5512 */ 5513 function createToPairs(keysFunc) { 5514 return function(object) { 5515 var tag = getTag(object); 5516 if (tag == mapTag) { 5517 return mapToArray(object); 5518 } 5519 if (tag == setTag) { 5520 return setToPairs(object); 5521 } 5522 return baseToPairs(object, keysFunc(object)); 5523 }; 5524 } 5525 5526 /** 5527 * Creates a function that either curries or invokes `func` with optional 5528 * `this` binding and partially applied arguments. 5529 * 5530 * @private 5531 * @param {Function|string} func The function or method name to wrap. 5532 * @param {number} bitmask The bitmask flags. 5533 * 1 - `_.bind` 5534 * 2 - `_.bindKey` 5535 * 4 - `_.curry` or `_.curryRight` of a bound function 5536 * 8 - `_.curry` 5537 * 16 - `_.curryRight` 5538 * 32 - `_.partial` 5539 * 64 - `_.partialRight` 5540 * 128 - `_.rearg` 5541 * 256 - `_.ary` 5542 * 512 - `_.flip` 5543 * @param {*} [thisArg] The `this` binding of `func`. 5544 * @param {Array} [partials] The arguments to be partially applied. 5545 * @param {Array} [holders] The `partials` placeholder indexes. 5546 * @param {Array} [argPos] The argument positions of the new function. 5547 * @param {number} [ary] The arity cap of `func`. 5548 * @param {number} [arity] The arity of `func`. 5549 * @returns {Function} Returns the new wrapped function. 5550 */ 5551 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 5552 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 5553 if (!isBindKey && typeof func != 'function') { 5554 throw new TypeError(FUNC_ERROR_TEXT); 5555 } 5556 var length = partials ? partials.length : 0; 5557 if (!length) { 5558 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 5559 partials = holders = undefined; 5560 } 5561 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 5562 arity = arity === undefined ? arity : toInteger(arity); 5563 length -= holders ? holders.length : 0; 5564 5565 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 5566 var partialsRight = partials, 5567 holdersRight = holders; 5568 5569 partials = holders = undefined; 5570 } 5571 var data = isBindKey ? undefined : getData(func); 5572 5573 var newData = [ 5574 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 5575 argPos, ary, arity 5576 ]; 5577 5578 if (data) { 5579 mergeData(newData, data); 5580 } 5581 func = newData[0]; 5582 bitmask = newData[1]; 5583 thisArg = newData[2]; 5584 partials = newData[3]; 5585 holders = newData[4]; 5586 arity = newData[9] = newData[9] === undefined 5587 ? (isBindKey ? 0 : func.length) 5588 : nativeMax(newData[9] - length, 0); 5589 5590 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 5591 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 5592 } 5593 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 5594 var result = createBind(func, bitmask, thisArg); 5595 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 5596 result = createCurry(func, bitmask, arity); 5597 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 5598 result = createPartial(func, bitmask, thisArg, partials); 5599 } else { 5600 result = createHybrid.apply(undefined, newData); 5601 } 5602 var setter = data ? baseSetData : setData; 5603 return setWrapToString(setter(result, newData), func, bitmask); 5604 } 5605 5606 /** 5607 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 5608 * of source objects to the destination object for all destination properties 5609 * that resolve to `undefined`. 5610 * 5611 * @private 5612 * @param {*} objValue The destination value. 5613 * @param {*} srcValue The source value. 5614 * @param {string} key The key of the property to assign. 5615 * @param {Object} object The parent object of `objValue`. 5616 * @returns {*} Returns the value to assign. 5617 */ 5618 function customDefaultsAssignIn(objValue, srcValue, key, object) { 5619 if (objValue === undefined || 5620 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 5621 return srcValue; 5622 } 5623 return objValue; 5624 } 5625 5626 /** 5627 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 5628 * objects into destination objects that are passed thru. 5629 * 5630 * @private 5631 * @param {*} objValue The destination value. 5632 * @param {*} srcValue The source value. 5633 * @param {string} key The key of the property to merge. 5634 * @param {Object} object The parent object of `objValue`. 5635 * @param {Object} source The parent object of `srcValue`. 5636 * @param {Object} [stack] Tracks traversed source values and their merged 5637 * counterparts. 5638 * @returns {*} Returns the value to assign. 5639 */ 5640 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 5641 if (isObject(objValue) && isObject(srcValue)) { 5642 // Recursively merge objects and arrays (susceptible to call stack limits). 5643 stack.set(srcValue, objValue); 5644 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 5645 stack['delete'](srcValue); 5646 } 5647 return objValue; 5648 } 5649 5650 /** 5651 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 5652 * objects. 5653 * 5654 * @private 5655 * @param {*} value The value to inspect. 5656 * @param {string} key The key of the property to inspect. 5657 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 5658 */ 5659 function customOmitClone(value) { 5660 return isPlainObject(value) ? undefined : value; 5661 } 5662 5663 /** 5664 * A specialized version of `baseIsEqualDeep` for arrays with support for 5665 * partial deep comparisons. 5666 * 5667 * @private 5668 * @param {Array} array The array to compare. 5669 * @param {Array} other The other array to compare. 5670 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5671 * @param {Function} customizer The function to customize comparisons. 5672 * @param {Function} equalFunc The function to determine equivalents of values. 5673 * @param {Object} stack Tracks traversed `array` and `other` objects. 5674 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 5675 */ 5676 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 5677 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 5678 arrLength = array.length, 5679 othLength = other.length; 5680 5681 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 5682 return false; 5683 } 5684 // Check that cyclic values are equal. 5685 var arrStacked = stack.get(array); 5686 var othStacked = stack.get(other); 5687 if (arrStacked && othStacked) { 5688 return arrStacked == other && othStacked == array; 5689 } 5690 var index = -1, 5691 result = true, 5692 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 5693 5694 stack.set(array, other); 5695 stack.set(other, array); 5696 5697 // Ignore non-index properties. 5698 while (++index < arrLength) { 5699 var arrValue = array[index], 5700 othValue = other[index]; 5701 5702 if (customizer) { 5703 var compared = isPartial 5704 ? customizer(othValue, arrValue, index, other, array, stack) 5705 : customizer(arrValue, othValue, index, array, other, stack); 5706 } 5707 if (compared !== undefined) { 5708 if (compared) { 5709 continue; 5710 } 5711 result = false; 5712 break; 5713 } 5714 // Recursively compare arrays (susceptible to call stack limits). 5715 if (seen) { 5716 if (!arraySome(other, function(othValue, othIndex) { 5717 if (!cacheHas(seen, othIndex) && 5718 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 5719 return seen.push(othIndex); 5720 } 5721 })) { 5722 result = false;
vendor: 4,179 bytes, lines 5723-5834
5723 break; 5724 } 5725 } else if (!( 5726 arrValue === othValue || 5727 equalFunc(arrValue, othValue, bitmask, customizer, stack) 5728 )) { 5729 result = false; 5730 break; 5731 } 5732 } 5733 stack['delete'](array); 5734 stack['delete'](other); 5735 return result; 5736 } 5737 5738 /** 5739 * A specialized version of `baseIsEqualDeep` for comparing objects of 5740 * the same `toStringTag`. 5741 * 5742 * **Note:** This function only supports comparing values with tags of 5743 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 5744 * 5745 * @private 5746 * @param {Object} object The object to compare. 5747 * @param {Object} other The other object to compare. 5748 * @param {string} tag The `toStringTag` of the objects to compare. 5749 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5750 * @param {Function} customizer The function to customize comparisons. 5751 * @param {Function} equalFunc The function to determine equivalents of values. 5752 * @param {Object} stack Tracks traversed `object` and `other` objects. 5753 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 5754 */ 5755 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 5756 switch (tag) { 5757 case dataViewTag: 5758 if ((object.byteLength != other.byteLength) || 5759 (object.byteOffset != other.byteOffset)) { 5760 return false; 5761 } 5762 object = object.buffer; 5763 other = other.buffer; 5764 5765 case arrayBufferTag: 5766 if ((object.byteLength != other.byteLength) || 5767 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 5768 return false; 5769 } 5770 return true; 5771 5772 case boolTag: 5773 case dateTag: 5774 case numberTag: 5775 // Coerce booleans to `1` or `0` and dates to milliseconds. 5776 // Invalid dates are coerced to `NaN`. 5777 return eq(+object, +other); 5778 5779 case errorTag: 5780 return object.name == other.name && object.message == other.message; 5781 5782 case regexpTag: 5783 case stringTag: 5784 // Coerce regexes to strings and treat strings, primitives and objects, 5785 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 5786 // for more details. 5787 return object == (other + ''); 5788 5789 case mapTag: 5790 var convert = mapToArray; 5791 5792 case setTag: 5793 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 5794 convert || (convert = setToArray); 5795 5796 if (object.size != other.size && !isPartial) { 5797 return false; 5798 } 5799 // Assume cyclic values are equal. 5800 var stacked = stack.get(object); 5801 if (stacked) { 5802 return stacked == other; 5803 } 5804 bitmask |= COMPARE_UNORDERED_FLAG; 5805 5806 // Recursively compare objects (susceptible to call stack limits). 5807 stack.set(object, other); 5808 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 5809 stack['delete'](object); 5810 return result; 5811 5812 case symbolTag: 5813 if (symbolValueOf) { 5814 return symbolValueOf.call(object) == symbolValueOf.call(other); 5815 } 5816 } 5817 return false; 5818 } 5819 5820 /** 5821 * A specialized version of `baseIsEqualDeep` for objects with support for 5822 * partial deep comparisons. 5823 * 5824 * @private 5825 * @param {Object} object The object to compare. 5826 * @param {Object} other The other object to compare. 5827 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5828 * @param {Function} customizer The function to customize comparisons. 5829 * @param {Function} equalFunc The function to determine equivalents of values. 5830 * @param {Object} stack Tracks traversed `object` and `other` objects. 5831 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 5832 */ 5833 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 5834 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
vendor: 9,614 bytes, lines 5835-6142
5835 objProps = getAllKeys(object), 5836 objLength = objProps.length, 5837 othProps = getAllKeys(other), 5838 othLength = othProps.length; 5839 5840 if (objLength != othLength && !isPartial) { 5841 return false; 5842 } 5843 var index = objLength; 5844 while (index--) { 5845 var key = objProps[index]; 5846 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 5847 return false; 5848 } 5849 } 5850 // Check that cyclic values are equal. 5851 var objStacked = stack.get(object); 5852 var othStacked = stack.get(other); 5853 if (objStacked && othStacked) { 5854 return objStacked == other && othStacked == object; 5855 } 5856 var result = true; 5857 stack.set(object, other); 5858 stack.set(other, object); 5859 5860 var skipCtor = isPartial; 5861 while (++index < objLength) { 5862 key = objProps[index]; 5863 var objValue = object[key], 5864 othValue = other[key]; 5865 5866 if (customizer) { 5867 var compared = isPartial 5868 ? customizer(othValue, objValue, key, other, object, stack) 5869 : customizer(objValue, othValue, key, object, other, stack); 5870 } 5871 // Recursively compare objects (susceptible to call stack limits). 5872 if (!(compared === undefined 5873 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 5874 : compared 5875 )) { 5876 result = false; 5877 break; 5878 } 5879 skipCtor || (skipCtor = key == 'constructor'); 5880 } 5881 if (result && !skipCtor) { 5882 var objCtor = object.constructor, 5883 othCtor = other.constructor; 5884 5885 // Non `Object` object instances with different constructors are not equal. 5886 if (objCtor != othCtor && 5887 ('constructor' in object && 'constructor' in other) && 5888 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 5889 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 5890 result = false; 5891 } 5892 } 5893 stack['delete'](object); 5894 stack['delete'](other); 5895 return result; 5896 } 5897 5898 /** 5899 * A specialized version of `baseRest` which flattens the rest array. 5900 * 5901 * @private 5902 * @param {Function} func The function to apply a rest parameter to. 5903 * @returns {Function} Returns the new function. 5904 */ 5905 function flatRest(func) { 5906 return setToString(overRest(func, undefined, flatten), func + ''); 5907 } 5908 5909 /** 5910 * Creates an array of own enumerable property names and symbols of `object`. 5911 * 5912 * @private 5913 * @param {Object} object The object to query. 5914 * @returns {Array} Returns the array of property names and symbols. 5915 */ 5916 function getAllKeys(object) { 5917 return baseGetAllKeys(object, keys, getSymbols); 5918 } 5919 5920 /** 5921 * Creates an array of own and inherited enumerable property names and 5922 * symbols of `object`. 5923 * 5924 * @private 5925 * @param {Object} object The object to query. 5926 * @returns {Array} Returns the array of property names and symbols. 5927 */ 5928 function getAllKeysIn(object) { 5929 return baseGetAllKeys(object, keysIn, getSymbolsIn); 5930 } 5931 5932 /** 5933 * Gets metadata for `func`. 5934 * 5935 * @private 5936 * @param {Function} func The function to query. 5937 * @returns {*} Returns the metadata for `func`. 5938 */ 5939 var getData = !metaMap ? noop : function(func) { 5940 return metaMap.get(func); 5941 }; 5942 5943 /** 5944 * Gets the name of `func`. 5945 * 5946 * @private 5947 * @param {Function} func The function to query. 5948 * @returns {string} Returns the function name. 5949 */ 5950 function getFuncName(func) { 5951 var result = (func.name + ''), 5952 array = realNames[result], 5953 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 5954 5955 while (length--) { 5956 var data = array[length], 5957 otherFunc = data.func; 5958 if (otherFunc == null || otherFunc == func) { 5959 return data.name; 5960 } 5961 } 5962 return result; 5963 } 5964 5965 /** 5966 * Gets the argument placeholder value for `func`. 5967 * 5968 * @private 5969 * @param {Function} func The function to inspect. 5970 * @returns {*} Returns the placeholder value. 5971 */ 5972 function getHolder(func) { 5973 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 5974 return object.placeholder; 5975 } 5976 5977 /** 5978 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 5979 * this function returns the custom method, otherwise it returns `baseIteratee`. 5980 * If arguments are provided, the chosen function is invoked with them and 5981 * its result is returned. 5982 * 5983 * @private 5984 * @param {*} [value] The value to convert to an iteratee. 5985 * @param {number} [arity] The arity of the created iteratee. 5986 * @returns {Function} Returns the chosen function or its result. 5987 */ 5988 function getIteratee() { 5989 var result = lodash.iteratee || iteratee; 5990 result = result === iteratee ? baseIteratee : result; 5991 return arguments.length ? result(arguments[0], arguments[1]) : result; 5992 } 5993 5994 /** 5995 * Gets the data for `map`. 5996 * 5997 * @private 5998 * @param {Object} map The map to query. 5999 * @param {string} key The reference key. 6000 * @returns {*} Returns the map data. 6001 */ 6002 function getMapData(map, key) { 6003 var data = map.__data__; 6004 return isKeyable(key) 6005 ? data[typeof key == 'string' ? 'string' : 'hash'] 6006 : data.map; 6007 } 6008 6009 /** 6010 * Gets the property names, values, and compare flags of `object`. 6011 * 6012 * @private 6013 * @param {Object} object The object to query. 6014 * @returns {Array} Returns the match data of `object`. 6015 */ 6016 function getMatchData(object) { 6017 var result = keys(object), 6018 length = result.length; 6019 6020 while (length--) { 6021 var key = result[length], 6022 value = object[key]; 6023 6024 result[length] = [key, value, isStrictComparable(value)]; 6025 } 6026 return result; 6027 } 6028 6029 /** 6030 * Gets the native function at `key` of `object`. 6031 * 6032 * @private 6033 * @param {Object} object The object to query. 6034 * @param {string} key The key of the method to get. 6035 * @returns {*} Returns the function if it's native, else `undefined`. 6036 */ 6037 function getNative(object, key) { 6038 var value = getValue(object, key); 6039 return baseIsNative(value) ? value : undefined; 6040 } 6041 6042 /** 6043 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 6044 * 6045 * @private 6046 * @param {*} value The value to query. 6047 * @returns {string} Returns the raw `toStringTag`. 6048 */ 6049 function getRawTag(value) { 6050 var isOwn = hasOwnProperty.call(value, symToStringTag), 6051 tag = value[symToStringTag]; 6052 6053 try { 6054 value[symToStringTag] = undefined; 6055 var unmasked = true; 6056 } catch (e) {} 6057 6058 var result = nativeObjectToString.call(value); 6059 if (unmasked) { 6060 if (isOwn) { 6061 value[symToStringTag] = tag; 6062 } else { 6063 delete value[symToStringTag]; 6064 } 6065 } 6066 return result; 6067 } 6068 6069 /** 6070 * Creates an array of the own enumerable symbols of `object`. 6071 * 6072 * @private 6073 * @param {Object} object The object to query. 6074 * @returns {Array} Returns the array of symbols. 6075 */ 6076 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 6077 if (object == null) { 6078 return []; 6079 } 6080 object = Object(object); 6081 return arrayFilter(nativeGetSymbols(object), function(symbol) { 6082 return propertyIsEnumerable.call(object, symbol); 6083 }); 6084 }; 6085 6086 /** 6087 * Creates an array of the own and inherited enumerable symbols of `object`. 6088 * 6089 * @private 6090 * @param {Object} object The object to query. 6091 * @returns {Array} Returns the array of symbols. 6092 */ 6093 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 6094 var result = []; 6095 while (object) { 6096 arrayPush(result, getSymbols(object)); 6097 object = getPrototype(object); 6098 } 6099 return result; 6100 }; 6101 6102 /** 6103 * Gets the `toStringTag` of `value`. 6104 * 6105 * @private 6106 * @param {*} value The value to query. 6107 * @returns {string} Returns the `toStringTag`. 6108 */ 6109 var getTag = baseGetTag; 6110 6111 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 6112 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 6113 (Map && getTag(new Map) != mapTag) || 6114 (Promise && getTag(Promise.resolve()) != promiseTag) || 6115 (Set && getTag(new Set) != setTag) || 6116 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 6117 getTag = function(value) { 6118 var result = baseGetTag(value), 6119 Ctor = result == objectTag ? value.constructor : undefined, 6120 ctorString = Ctor ? toSource(Ctor) : ''; 6121 6122 if (ctorString) { 6123 switch (ctorString) { 6124 case dataViewCtorString: return dataViewTag; 6125 case mapCtorString: return mapTag; 6126 case promiseCtorString: return promiseTag; 6127 case setCtorString: return setTag; 6128 case weakMapCtorString: return weakMapTag; 6129 } 6130 } 6131 return result; 6132 }; 6133 } 6134 6135 /** 6136 * Gets the view, applying any `transforms` to the `start` and `end` positions. 6137 * 6138 * @private 6139 * @param {number} start The start of the view. 6140 * @param {number} end The end of the view. 6141 * @param {Array} transforms The transformations to apply to the view. 6142 * @returns {Object}
vendor: 6,432 bytes, lines 6142-6347
6142 Returns an object containing the `start` and `end` 6143 * positions of the view. 6144 */ 6145 function getView(start, end, transforms) { 6146 var index = -1, 6147 length = transforms.length; 6148 6149 while (++index < length) { 6150 var data = transforms[index], 6151 size = data.size; 6152 6153 switch (data.type) { 6154 case 'drop': start += size; break; 6155 case 'dropRight': end -= size; break; 6156 case 'take': end = nativeMin(end, start + size); break; 6157 case 'takeRight': start = nativeMax(start, end - size); break; 6158 } 6159 } 6160 return { 'start': start, 'end': end }; 6161 } 6162 6163 /** 6164 * Extracts wrapper details from the `source` body comment. 6165 * 6166 * @private 6167 * @param {string} source The source to inspect. 6168 * @returns {Array} Returns the wrapper details. 6169 */ 6170 function getWrapDetails(source) { 6171 var match = source.match(reWrapDetails); 6172 return match ? match[1].split(reSplitDetails) : []; 6173 } 6174 6175 /** 6176 * Checks if `path` exists on `object`. 6177 * 6178 * @private 6179 * @param {Object} object The object to query. 6180 * @param {Array|string} path The path to check. 6181 * @param {Function} hasFunc The function to check properties. 6182 * @returns {boolean} Returns `true` if `path` exists, else `false`. 6183 */ 6184 function hasPath(object, path, hasFunc) { 6185 path = castPath(path, object); 6186 6187 var index = -1, 6188 length = path.length, 6189 result = false; 6190 6191 while (++index < length) { 6192 var key = toKey(path[index]); 6193 if (!(result = object != null && hasFunc(object, key))) { 6194 break; 6195 } 6196 object = object[key]; 6197 } 6198 if (result || ++index != length) { 6199 return result; 6200 } 6201 length = object == null ? 0 : object.length; 6202 return !!length && isLength(length) && isIndex(key, length) && 6203 (isArray(object) || isArguments(object)); 6204 } 6205 6206 /** 6207 * Initializes an array clone. 6208 * 6209 * @private 6210 * @param {Array} array The array to clone. 6211 * @returns {Array} Returns the initialized clone. 6212 */ 6213 function initCloneArray(array) { 6214 var length = array.length, 6215 result = new array.constructor(length); 6216 6217 // Add properties assigned by `RegExp#exec`. 6218 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 6219 result.index = array.index; 6220 result.input = array.input; 6221 } 6222 return result; 6223 } 6224 6225 /** 6226 * Initializes an object clone. 6227 * 6228 * @private 6229 * @param {Object} object The object to clone. 6230 * @returns {Object} Returns the initialized clone. 6231 */ 6232 function initCloneObject(object) { 6233 return (typeof object.constructor == 'function' && !isPrototype(object)) 6234 ? baseCreate(getPrototype(object)) 6235 : {}; 6236 } 6237 6238 /** 6239 * Initializes an object clone based on its `toStringTag`. 6240 * 6241 * **Note:** This function only supports cloning values with tags of 6242 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 6243 * 6244 * @private 6245 * @param {Object} object The object to clone. 6246 * @param {string} tag The `toStringTag` of the object to clone. 6247 * @param {boolean} [isDeep] Specify a deep clone. 6248 * @returns {Object} Returns the initialized clone. 6249 */ 6250 function initCloneByTag(object, tag, isDeep) { 6251 var Ctor = object.constructor; 6252 switch (tag) { 6253 case arrayBufferTag: 6254 return cloneArrayBuffer(object); 6255 6256 case boolTag: 6257 case dateTag: 6258 return new Ctor(+object); 6259 6260 case dataViewTag: 6261 return cloneDataView(object, isDeep); 6262 6263 case float32Tag: case float64Tag: 6264 case int8Tag: case int16Tag: case int32Tag: 6265 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 6266 return cloneTypedArray(object, isDeep); 6267 6268 case mapTag: 6269 return new Ctor; 6270 6271 case numberTag: 6272 case stringTag: 6273 return new Ctor(object); 6274 6275 case regexpTag: 6276 return cloneRegExp(object); 6277 6278 case setTag: 6279 return new Ctor; 6280 6281 case symbolTag: 6282 return cloneSymbol(object); 6283 } 6284 } 6285 6286 /** 6287 * Inserts wrapper `details` in a comment at the top of the `source` body. 6288 * 6289 * @private 6290 * @param {string} source The source to modify. 6291 * @returns {Array} details The details to insert. 6292 * @returns {string} Returns the modified source. 6293 */ 6294 function insertWrapDetails(source, details) { 6295 var length = details.length; 6296 if (!length) { 6297 return source; 6298 } 6299 var lastIndex = length - 1; 6300 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 6301 details = details.join(length > 2 ? ', ' : ' '); 6302 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 6303 } 6304 6305 /** 6306 * Checks if `value` is a flattenable `arguments` object or array. 6307 * 6308 * @private 6309 * @param {*} value The value to check. 6310 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 6311 */ 6312 function isFlattenable(value) { 6313 return isArray(value) || isArguments(value) || 6314 !!(spreadableSymbol && value && value[spreadableSymbol]); 6315 } 6316 6317 /** 6318 * Checks if `value` is a valid array-like index. 6319 * 6320 * @private 6321 * @param {*} value The value to check. 6322 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 6323 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 6324 */ 6325 function isIndex(value, length) { 6326 var type = typeof value; 6327 length = length == null ? MAX_SAFE_INTEGER : length; 6328 6329 return !!length && 6330 (type == 'number' || 6331 (type != 'symbol' && reIsUint.test(value))) && 6332 (value > -1 && value % 1 == 0 && value < length); 6333 } 6334 6335 /** 6336 * Checks if the given arguments are from an iteratee call. 6337 * 6338 * @private 6339 * @param {*} value The potential iteratee value argument. 6340 * @param {*} index The potential iteratee index or key argument. 6341 * @param {*} object The potential iteratee object argument. 6342 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 6343 * else `false`. 6344 */ 6345 function isIterateeCall(value, index, object) { 6346 if (!isObject(object)) { 6347 return false;
vendor: 14,387 bytes, lines 6348-6794
6348 } 6349 var type = typeof index; 6350 if (type == 'number' 6351 ? (isArrayLike(object) && isIndex(index, object.length)) 6352 : (type == 'string' && index in object) 6353 ) { 6354 return eq(object[index], value); 6355 } 6356 return false; 6357 } 6358 6359 /** 6360 * Checks if `value` is a property name and not a property path. 6361 * 6362 * @private 6363 * @param {*} value The value to check. 6364 * @param {Object} [object] The object to query keys on. 6365 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 6366 */ 6367 function isKey(value, object) { 6368 if (isArray(value)) { 6369 return false; 6370 } 6371 var type = typeof value; 6372 if (type == 'number' || type == 'symbol' || type == 'boolean' || 6373 value == null || isSymbol(value)) { 6374 return true; 6375 } 6376 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 6377 (object != null && value in Object(object)); 6378 } 6379 6380 /** 6381 * Checks if `value` is suitable for use as unique object key. 6382 * 6383 * @private 6384 * @param {*} value The value to check. 6385 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 6386 */ 6387 function isKeyable(value) { 6388 var type = typeof value; 6389 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 6390 ? (value !== '__proto__') 6391 : (value === null); 6392 } 6393 6394 /** 6395 * Checks if `func` has a lazy counterpart. 6396 * 6397 * @private 6398 * @param {Function} func The function to check. 6399 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 6400 * else `false`. 6401 */ 6402 function isLaziable(func) { 6403 var funcName = getFuncName(func), 6404 other = lodash[funcName]; 6405 6406 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 6407 return false; 6408 } 6409 if (func === other) { 6410 return true; 6411 } 6412 var data = getData(other); 6413 return !!data && func === data[0]; 6414 } 6415 6416 /** 6417 * Checks if `func` has its source masked. 6418 * 6419 * @private 6420 * @param {Function} func The function to check. 6421 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 6422 */ 6423 function isMasked(func) { 6424 return !!maskSrcKey && (maskSrcKey in func); 6425 } 6426 6427 /** 6428 * Checks if `func` is capable of being masked. 6429 * 6430 * @private 6431 * @param {*} value The value to check. 6432 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 6433 */ 6434 var isMaskable = coreJsData ? isFunction : stubFalse; 6435 6436 /** 6437 * Checks if `value` is likely a prototype object. 6438 * 6439 * @private 6440 * @param {*} value The value to check. 6441 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 6442 */ 6443 function isPrototype(value) { 6444 var Ctor = value && value.constructor, 6445 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 6446 6447 return value === proto; 6448 } 6449 6450 /** 6451 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 6452 * 6453 * @private 6454 * @param {*} value The value to check. 6455 * @returns {boolean} Returns `true` if `value` if suitable for strict 6456 * equality comparisons, else `false`. 6457 */ 6458 function isStrictComparable(value) { 6459 return value === value && !isObject(value); 6460 } 6461 6462 /** 6463 * A specialized version of `matchesProperty` for source values suitable 6464 * for strict equality comparisons, i.e. `===`. 6465 * 6466 * @private 6467 * @param {string} key The key of the property to get. 6468 * @param {*} srcValue The value to match. 6469 * @returns {Function} Returns the new spec function. 6470 */ 6471 function matchesStrictComparable(key, srcValue) { 6472 return function(object) { 6473 if (object == null) { 6474 return false; 6475 } 6476 return object[key] === srcValue && 6477 (srcValue !== undefined || (key in Object(object))); 6478 }; 6479 } 6480 6481 /** 6482 * A specialized version of `_.memoize` which clears the memoized function's 6483 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 6484 * 6485 * @private 6486 * @param {Function} func The function to have its output memoized. 6487 * @returns {Function} Returns the new memoized function. 6488 */ 6489 function memoizeCapped(func) { 6490 var result = memoize(func, function(key) { 6491 if (cache.size === MAX_MEMOIZE_SIZE) { 6492 cache.clear(); 6493 } 6494 return key; 6495 }); 6496 6497 var cache = result.cache; 6498 return result; 6499 } 6500 6501 /** 6502 * Merges the function metadata of `source` into `data`. 6503 * 6504 * Merging metadata reduces the number of wrappers used to invoke a function. 6505 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 6506 * may be applied regardless of execution order. Methods like `_.ary` and 6507 * `_.rearg` modify function arguments, making the order in which they are 6508 * executed important, preventing the merging of metadata. However, we make 6509 * an exception for a safe combined case where curried functions have `_.ary` 6510 * and or `_.rearg` applied. 6511 * 6512 * @private 6513 * @param {Array} data The destination metadata. 6514 * @param {Array} source The source metadata. 6515 * @returns {Array} Returns `data`. 6516 */ 6517 function mergeData(data, source) { 6518 var bitmask = data[1], 6519 srcBitmask = source[1], 6520 newBitmask = bitmask | srcBitmask, 6521 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 6522 6523 var isCombo = 6524 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 6525 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 6526 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 6527 6528 // Exit early if metadata can't be merged. 6529 if (!(isCommon || isCombo)) { 6530 return data; 6531 } 6532 // Use source `thisArg` if available. 6533 if (srcBitmask & WRAP_BIND_FLAG) { 6534 data[2] = source[2]; 6535 // Set when currying a bound function. 6536 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 6537 } 6538 // Compose partial arguments. 6539 var value = source[3]; 6540 if (value) { 6541 var partials = data[3]; 6542 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 6543 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 6544 } 6545 // Compose partial right arguments. 6546 value = source[5]; 6547 if (value) { 6548 partials = data[5]; 6549 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 6550 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 6551 } 6552 // Use source `argPos` if available. 6553 value = source[7]; 6554 if (value) { 6555 data[7] = value; 6556 } 6557 // Use source `ary` if it's smaller. 6558 if (srcBitmask & WRAP_ARY_FLAG) { 6559 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 6560 } 6561 // Use source `arity` if one is not provided. 6562 if (data[9] == null) { 6563 data[9] = source[9]; 6564 } 6565 // Use source `func` and merge bitmasks. 6566 data[0] = source[0]; 6567 data[1] = newBitmask; 6568 6569 return data; 6570 } 6571 6572 /** 6573 * This function is like 6574 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 6575 * except that it includes inherited enumerable properties. 6576 * 6577 * @private 6578 * @param {Object} object The object to query. 6579 * @returns {Array} Returns the array of property names. 6580 */ 6581 function nativeKeysIn(object) { 6582 var result = []; 6583 if (object != null) { 6584 for (var key in Object(object)) { 6585 result.push(key); 6586 } 6587 } 6588 return result; 6589 } 6590 6591 /** 6592 * Converts `value` to a string using `Object.prototype.toString`. 6593 * 6594 * @private 6595 * @param {*} value The value to convert. 6596 * @returns {string} Returns the converted string. 6597 */ 6598 function objectToString(value) { 6599 return nativeObjectToString.call(value); 6600 } 6601 6602 /** 6603 * A specialized version of `baseRest` which transforms the rest array. 6604 * 6605 * @private 6606 * @param {Function} func The function to apply a rest parameter to. 6607 * @param {number} [start=func.length-1] The start position of the rest parameter. 6608 * @param {Function} transform The rest array transform. 6609 * @returns {Function} Returns the new function. 6610 */ 6611 function overRest(func, start, transform) { 6612 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 6613 return function() { 6614 var args = arguments, 6615 index = -1, 6616 length = nativeMax(args.length - start, 0), 6617 array = Array(length); 6618 6619 while (++index < length) { 6620 array[index] = args[start + index]; 6621 } 6622 index = -1; 6623 var otherArgs = Array(start + 1); 6624 while (++index < start) { 6625 otherArgs[index] = args[index]; 6626 } 6627 otherArgs[start] = transform(array); 6628 return apply(func, this, otherArgs); 6629 }; 6630 } 6631 6632 /** 6633 * Gets the parent value at `path` of `object`. 6634 * 6635 * @private 6636 * @param {Object} object The object to query. 6637 * @param {Array} path The path to get the parent value of. 6638 * @returns {*} Returns the parent value. 6639 */ 6640 function parent(object, path) { 6641 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 6642 } 6643 6644 /** 6645 * Reorder `array` according to the specified indexes where the element at 6646 * the first index is assigned as the first element, the element at 6647 * the second index is assigned as the second element, and so on. 6648 * 6649 * @private 6650 * @param {Array} array The array to reorder. 6651 * @param {Array} indexes The arranged array indexes. 6652 * @returns {Array} Returns `array`. 6653 */ 6654 function reorder(array, indexes) { 6655 var arrLength = array.length, 6656 length = nativeMin(indexes.length, arrLength), 6657 oldArray = copyArray(array); 6658 6659 while (length--) { 6660 var index = indexes[length]; 6661 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 6662 } 6663 return array; 6664 } 6665 6666 /** 6667 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 6668 * 6669 * @private 6670 * @param {Object} object The object to query. 6671 * @param {string} key The key of the property to get. 6672 * @returns {*} Returns the property value. 6673 */ 6674 function safeGet(object, key) { 6675 if (key === 'constructor' && typeof object[key] === 'function') { 6676 return; 6677 } 6678 6679 if (key == '__proto__') { 6680 return; 6681 } 6682 6683 return object[key]; 6684 } 6685 6686 /** 6687 * Sets metadata for `func`. 6688 * 6689 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 6690 * period of time, it will trip its breaker and transition to an identity 6691 * function to avoid garbage collection pauses in V8. See 6692 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 6693 * for more details. 6694 * 6695 * @private 6696 * @param {Function} func The function to associate metadata with. 6697 * @param {*} data The metadata. 6698 * @returns {Function} Returns `func`. 6699 */ 6700 var setData = shortOut(baseSetData); 6701 6702 /** 6703 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 6704 * 6705 * @private 6706 * @param {Function} func The function to delay. 6707 * @param {number} wait The number of milliseconds to delay invocation. 6708 * @returns {number|Object} Returns the timer id or timeout object. 6709 */ 6710 var setTimeout = ctxSetTimeout || function(func, wait) { 6711 return root.setTimeout(func, wait); 6712 }; 6713 6714 /** 6715 * Sets the `toString` method of `func` to return `string`. 6716 * 6717 * @private 6718 * @param {Function} func The function to modify. 6719 * @param {Function} string The `toString` result. 6720 * @returns {Function} Returns `func`. 6721 */ 6722 var setToString = shortOut(baseSetToString); 6723 6724 /** 6725 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 6726 * with wrapper details in a comment at the top of the source body. 6727 * 6728 * @private 6729 * @param {Function} wrapper The function to modify. 6730 * @param {Function} reference The reference function. 6731 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6732 * @returns {Function} Returns `wrapper`. 6733 */ 6734 function setWrapToString(wrapper, reference, bitmask) { 6735 var source = (reference + ''); 6736 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 6737 } 6738 6739 /** 6740 * Creates a function that'll short out and invoke `identity` instead 6741 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 6742 * milliseconds. 6743 * 6744 * @private 6745 * @param {Function} func The function to restrict. 6746 * @returns {Function} Returns the new shortable function. 6747 */ 6748 function shortOut(func) { 6749 var count = 0, 6750 lastCalled = 0; 6751 6752 return function() { 6753 var stamp = nativeNow(), 6754 remaining = HOT_SPAN - (stamp - lastCalled); 6755 6756 lastCalled = stamp; 6757 if (remaining > 0) { 6758 if (++count >= HOT_COUNT) { 6759 return arguments[0]; 6760 } 6761 } else { 6762 count = 0; 6763 } 6764 return func.apply(undefined, arguments); 6765 }; 6766 } 6767 6768 /** 6769 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 6770 * 6771 * @private 6772 * @param {Array} array The array to shuffle. 6773 * @param {number} [size=array.length] The size of `array`. 6774 * @returns {Array} Returns `array`. 6775 */ 6776 function shuffleSelf(array, size) { 6777 var index = -1, 6778 length = array.length, 6779 lastIndex = length - 1; 6780 6781 size = size === undefined ? length : size; 6782 while (++index < size) { 6783 var rand = baseRandom(index, lastIndex), 6784 value = array[rand]; 6785 6786 array[rand] = array[index]; 6787 array[index] = value; 6788 } 6789 array.length = size; 6790 return array; 6791 } 6792 6793 /** 6794 * Converts `string` to a property path array.
vendor: 1,775 bytes, lines 6795-6855
6795 * 6796 * @private 6797 * @param {string} string The string to convert. 6798 * @returns {Array} Returns the property path array. 6799 */ 6800 var stringToPath = memoizeCapped(function(string) { 6801 var result = []; 6802 if (string.charCodeAt(0) === 46 /* . */) { 6803 result.push(''); 6804 } 6805 string.replace(rePropName, function(match, number, quote, subString) { 6806 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 6807 }); 6808 return result; 6809 }); 6810 6811 /** 6812 * Converts `value` to a string key if it's not a string or symbol. 6813 * 6814 * @private 6815 * @param {*} value The value to inspect. 6816 * @returns {string|symbol} Returns the key. 6817 */ 6818 function toKey(value) { 6819 if (typeof value == 'string' || isSymbol(value)) { 6820 return value; 6821 } 6822 var result = (value + ''); 6823 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 6824 } 6825 6826 /** 6827 * Converts `func` to its source code. 6828 * 6829 * @private 6830 * @param {Function} func The function to convert. 6831 * @returns {string} Returns the source code. 6832 */ 6833 function toSource(func) { 6834 if (func != null) { 6835 try { 6836 return funcToString.call(func); 6837 } catch (e) {} 6838 try { 6839 return (func + ''); 6840 } catch (e) {} 6841 } 6842 return ''; 6843 } 6844 6845 /** 6846 * Updates wrapper `details` based on `bitmask` flags. 6847 * 6848 * @private 6849 * @returns {Array} details The details to modify. 6850 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6851 * @returns {Array} Returns `details`. 6852 */ 6853 function updateWrapDetails(details, bitmask) { 6854 arrayEach(wrapFlags, function(pair) { 6855 var value = '_.' + pair[0];
vendor: 80,381 bytes, lines 6856-9439
6856 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 6857 details.push(value); 6858 } 6859 }); 6860 return details.sort(); 6861 } 6862 6863 /** 6864 * Creates a clone of `wrapper`. 6865 * 6866 * @private 6867 * @param {Object} wrapper The wrapper to clone. 6868 * @returns {Object} Returns the cloned wrapper. 6869 */ 6870 function wrapperClone(wrapper) { 6871 if (wrapper instanceof LazyWrapper) { 6872 return wrapper.clone(); 6873 } 6874 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 6875 result.__actions__ = copyArray(wrapper.__actions__); 6876 result.__index__ = wrapper.__index__; 6877 result.__values__ = wrapper.__values__; 6878 return result; 6879 } 6880 6881 /*------------------------------------------------------------------------*/ 6882 6883 /** 6884 * Creates an array of elements split into groups the length of `size`. 6885 * If `array` can't be split evenly, the final chunk will be the remaining 6886 * elements. 6887 * 6888 * @static 6889 * @memberOf _ 6890 * @since 3.0.0 6891 * @category Array 6892 * @param {Array} array The array to process. 6893 * @param {number} [size=1] The length of each chunk 6894 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 6895 * @returns {Array} Returns the new array of chunks. 6896 * @example 6897 * 6898 * _.chunk(['a', 'b', 'c', 'd'], 2); 6899 * // => [['a', 'b'], ['c', 'd']] 6900 * 6901 * _.chunk(['a', 'b', 'c', 'd'], 3); 6902 * // => [['a', 'b', 'c'], ['d']] 6903 */ 6904 function chunk(array, size, guard) { 6905 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 6906 size = 1; 6907 } else { 6908 size = nativeMax(toInteger(size), 0); 6909 } 6910 var length = array == null ? 0 : array.length; 6911 if (!length || size < 1) { 6912 return []; 6913 } 6914 var index = 0, 6915 resIndex = 0, 6916 result = Array(nativeCeil(length / size)); 6917 6918 while (index < length) { 6919 result[resIndex++] = baseSlice(array, index, (index += size)); 6920 } 6921 return result; 6922 } 6923 6924 /** 6925 * Creates an array with all falsey values removed. The values `false`, `null`, 6926 * `0`, `""`, `undefined`, and `NaN` are falsey. 6927 * 6928 * @static 6929 * @memberOf _ 6930 * @since 0.1.0 6931 * @category Array 6932 * @param {Array} array The array to compact. 6933 * @returns {Array} Returns the new array of filtered values. 6934 * @example 6935 * 6936 * _.compact([0, 1, false, 2, '', 3]); 6937 * // => [1, 2, 3] 6938 */ 6939 function compact(array) { 6940 var index = -1, 6941 length = array == null ? 0 : array.length, 6942 resIndex = 0, 6943 result = []; 6944 6945 while (++index < length) { 6946 var value = array[index]; 6947 if (value) { 6948 result[resIndex++] = value; 6949 } 6950 } 6951 return result; 6952 } 6953 6954 /** 6955 * Creates a new array concatenating `array` with any additional arrays 6956 * and/or values. 6957 * 6958 * @static 6959 * @memberOf _ 6960 * @since 4.0.0 6961 * @category Array 6962 * @param {Array} array The array to concatenate. 6963 * @param {...*} [values] The values to concatenate. 6964 * @returns {Array} Returns the new concatenated array. 6965 * @example 6966 * 6967 * var array = [1]; 6968 * var other = _.concat(array, 2, [3], [[4]]); 6969 * 6970 * console.log(other); 6971 * // => [1, 2, 3, [4]] 6972 * 6973 * console.log(array); 6974 * // => [1] 6975 */ 6976 function concat() { 6977 var length = arguments.length; 6978 if (!length) { 6979 return []; 6980 } 6981 var args = Array(length - 1), 6982 array = arguments[0], 6983 index = length; 6984 6985 while (index--) { 6986 args[index - 1] = arguments[index]; 6987 } 6988 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 6989 } 6990 6991 /** 6992 * Creates an array of `array` values not included in the other given arrays 6993 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 6994 * for equality comparisons. The order and references of result values are 6995 * determined by the first array. 6996 * 6997 * **Note:** Unlike `_.pullAll`, this method returns a new array. 6998 * 6999 * @static 7000 * @memberOf _ 7001 * @since 0.1.0 7002 * @category Array 7003 * @param {Array} array The array to inspect. 7004 * @param {...Array} [values] The values to exclude. 7005 * @returns {Array} Returns the new array of filtered values. 7006 * @see _.without, _.xor 7007 * @example 7008 * 7009 * _.difference([2, 1], [2, 3]); 7010 * // => [1] 7011 */ 7012 var difference = baseRest(function(array, values) { 7013 return isArrayLikeObject(array) 7014 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 7015 : []; 7016 }); 7017 7018 /** 7019 * This method is like `_.difference` except that it accepts `iteratee` which 7020 * is invoked for each element of `array` and `values` to generate the criterion 7021 * by which they're compared. The order and references of result values are 7022 * determined by the first array. The iteratee is invoked with one argument: 7023 * (value). 7024 * 7025 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 7026 * 7027 * @static 7028 * @memberOf _ 7029 * @since 4.0.0 7030 * @category Array 7031 * @param {Array} array The array to inspect. 7032 * @param {...Array} [values] The values to exclude. 7033 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 7034 * @returns {Array} Returns the new array of filtered values. 7035 * @example 7036 * 7037 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 7038 * // => [1.2] 7039 * 7040 * // The `_.property` iteratee shorthand. 7041 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 7042 * // => [{ 'x': 2 }] 7043 */ 7044 var differenceBy = baseRest(function(array, values) { 7045 var iteratee = last(values); 7046 if (isArrayLikeObject(iteratee)) { 7047 iteratee = undefined; 7048 } 7049 return isArrayLikeObject(array) 7050 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 7051 : []; 7052 }); 7053 7054 /** 7055 * This method is like `_.difference` except that it accepts `comparator` 7056 * which is invoked to compare elements of `array` to `values`. The order and 7057 * references of result values are determined by the first array. The comparator 7058 * is invoked with two arguments: (arrVal, othVal). 7059 * 7060 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 7061 * 7062 * @static 7063 * @memberOf _ 7064 * @since 4.0.0 7065 * @category Array 7066 * @param {Array} array The array to inspect. 7067 * @param {...Array} [values] The values to exclude. 7068 * @param {Function} [comparator] The comparator invoked per element. 7069 * @returns {Array} Returns the new array of filtered values. 7070 * @example 7071 * 7072 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 7073 * 7074 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 7075 * // => [{ 'x': 2, 'y': 1 }] 7076 */ 7077 var differenceWith = baseRest(function(array, values) { 7078 var comparator = last(values); 7079 if (isArrayLikeObject(comparator)) { 7080 comparator = undefined; 7081 } 7082 return isArrayLikeObject(array) 7083 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 7084 : []; 7085 }); 7086 7087 /** 7088 * Creates a slice of `array` with `n` elements dropped from the beginning. 7089 * 7090 * @static 7091 * @memberOf _ 7092 * @since 0.5.0 7093 * @category Array 7094 * @param {Array} array The array to query. 7095 * @param {number} [n=1] The number of elements to drop. 7096 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 7097 * @returns {Array} Returns the slice of `array`. 7098 * @example 7099 * 7100 * _.drop([1, 2, 3]); 7101 * // => [2, 3] 7102 * 7103 * _.drop([1, 2, 3], 2); 7104 * // => [3] 7105 * 7106 * _.drop([1, 2, 3], 5); 7107 * // => [] 7108 * 7109 * _.drop([1, 2, 3], 0); 7110 * // => [1, 2, 3] 7111 */ 7112 function drop(array, n, guard) { 7113 var length = array == null ? 0 : array.length; 7114 if (!length) { 7115 return []; 7116 } 7117 n = (guard || n === undefined) ? 1 : toInteger(n); 7118 return baseSlice(array, n < 0 ? 0 : n, length); 7119 } 7120 7121 /** 7122 * Creates a slice of `array` with `n` elements dropped from the end. 7123 * 7124 * @static 7125 * @memberOf _ 7126 * @since 3.0.0 7127 * @category Array 7128 * @param {Array} array The array to query. 7129 * @param {number} [n=1] The number of elements to drop. 7130 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 7131 * @returns {Array} Returns the slice of `array`. 7132 * @example 7133 * 7134 * _.dropRight([1, 2, 3]); 7135 * // => [1, 2] 7136 * 7137 * _.dropRight([1, 2, 3], 2); 7138 * // => [1] 7139 * 7140 * _.dropRight([1, 2, 3], 5); 7141 * // => [] 7142 * 7143 * _.dropRight([1, 2, 3], 0); 7144 * // => [1, 2, 3] 7145 */ 7146 function dropRight(array, n, guard) { 7147 var length = array == null ? 0 : array.length; 7148 if (!length) { 7149 return []; 7150 } 7151 n = (guard || n === undefined) ? 1 : toInteger(n); 7152 n = length - n; 7153 return baseSlice(array, 0, n < 0 ? 0 : n); 7154 } 7155 7156 /** 7157 * Creates a slice of `array` excluding elements dropped from the end. 7158 * Elements are dropped until `predicate` returns falsey. The predicate is 7159 * invoked with three arguments: (value, index, array). 7160 * 7161 * @static 7162 * @memberOf _ 7163 * @since 3.0.0 7164 * @category Array 7165 * @param {Array} array The array to query. 7166 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7167 * @returns {Array} Returns the slice of `array`. 7168 * @example 7169 * 7170 * var users = [ 7171 * { 'user': 'barney', 'active': true }, 7172 * { 'user': 'fred', 'active': false }, 7173 * { 'user': 'pebbles', 'active': false } 7174 * ]; 7175 * 7176 * _.dropRightWhile(users, function(o) { return !o.active; }); 7177 * // => objects for ['barney'] 7178 * 7179 * // The `_.matches` iteratee shorthand. 7180 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 7181 * // => objects for ['barney', 'fred'] 7182 * 7183 * // The `_.matchesProperty` iteratee shorthand. 7184 * _.dropRightWhile(users, ['active', false]); 7185 * // => objects for ['barney'] 7186 * 7187 * // The `_.property` iteratee shorthand. 7188 * _.dropRightWhile(users, 'active'); 7189 * // => objects for ['barney', 'fred', 'pebbles'] 7190 */ 7191 function dropRightWhile(array, predicate) { 7192 return (array && array.length) 7193 ? baseWhile(array, getIteratee(predicate, 3), true, true) 7194 : []; 7195 } 7196 7197 /** 7198 * Creates a slice of `array` excluding elements dropped from the beginning. 7199 * Elements are dropped until `predicate` returns falsey. The predicate is 7200 * invoked with three arguments: (value, index, array). 7201 * 7202 * @static 7203 * @memberOf _ 7204 * @since 3.0.0 7205 * @category Array 7206 * @param {Array} array The array to query. 7207 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7208 * @returns {Array} Returns the slice of `array`. 7209 * @example 7210 * 7211 * var users = [ 7212 * { 'user': 'barney', 'active': false }, 7213 * { 'user': 'fred', 'active': false }, 7214 * { 'user': 'pebbles', 'active': true } 7215 * ]; 7216 * 7217 * _.dropWhile(users, function(o) { return !o.active; }); 7218 * // => objects for ['pebbles'] 7219 * 7220 * // The `_.matches` iteratee shorthand. 7221 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 7222 * // => objects for ['fred', 'pebbles'] 7223 * 7224 * // The `_.matchesProperty` iteratee shorthand. 7225 * _.dropWhile(users, ['active', false]); 7226 * // => objects for ['pebbles'] 7227 * 7228 * // The `_.property` iteratee shorthand. 7229 * _.dropWhile(users, 'active'); 7230 * // => objects for ['barney', 'fred', 'pebbles'] 7231 */ 7232 function dropWhile(array, predicate) { 7233 return (array && array.length) 7234 ? baseWhile(array, getIteratee(predicate, 3), true) 7235 : []; 7236 } 7237 7238 /** 7239 * Fills elements of `array` with `value` from `start` up to, but not 7240 * including, `end`. 7241 * 7242 * **Note:** This method mutates `array`. 7243 * 7244 * @static 7245 * @memberOf _ 7246 * @since 3.2.0 7247 * @category Array 7248 * @param {Array} array The array to fill. 7249 * @param {*} value The value to fill `array` with. 7250 * @param {number} [start=0] The start position. 7251 * @param {number} [end=array.length] The end position. 7252 * @returns {Array} Returns `array`. 7253 * @example 7254 * 7255 * var array = [1, 2, 3]; 7256 * 7257 * _.fill(array, 'a'); 7258 * console.log(array); 7259 * // => ['a', 'a', 'a'] 7260 * 7261 * _.fill(Array(3), 2); 7262 * // => [2, 2, 2] 7263 * 7264 * _.fill([4, 6, 8, 10], '*', 1, 3); 7265 * // => [4, '*', '*', 10] 7266 */ 7267 function fill(array, value, start, end) { 7268 var length = array == null ? 0 : array.length; 7269 if (!length) { 7270 return []; 7271 } 7272 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 7273 start = 0; 7274 end = length; 7275 } 7276 return baseFill(array, value, start, end); 7277 } 7278 7279 /** 7280 * This method is like `_.find` except that it returns the index of the first 7281 * element `predicate` returns truthy for instead of the element itself. 7282 * 7283 * @static 7284 * @memberOf _ 7285 * @since 1.1.0 7286 * @category Array 7287 * @param {Array} array The array to inspect. 7288 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7289 * @param {number} [fromIndex=0] The index to search from. 7290 * @returns {number} Returns the index of the found element, else `-1`. 7291 * @example 7292 * 7293 * var users = [ 7294 * { 'user': 'barney', 'active': false }, 7295 * { 'user': 'fred', 'active': false }, 7296 * { 'user': 'pebbles', 'active': true } 7297 * ]; 7298 * 7299 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 7300 * // => 0 7301 * 7302 * // The `_.matches` iteratee shorthand. 7303 * _.findIndex(users, { 'user': 'fred', 'active': false }); 7304 * // => 1 7305 * 7306 * // The `_.matchesProperty` iteratee shorthand. 7307 * _.findIndex(users, ['active', false]); 7308 * // => 0 7309 * 7310 * // The `_.property` iteratee shorthand. 7311 * _.findIndex(users, 'active'); 7312 * // => 2 7313 */ 7314 function findIndex(array, predicate, fromIndex) { 7315 var length = array == null ? 0 : array.length; 7316 if (!length) { 7317 return -1; 7318 } 7319 var index = fromIndex == null ? 0 : toInteger(fromIndex); 7320 if (index < 0) { 7321 index = nativeMax(length + index, 0); 7322 } 7323 return baseFindIndex(array, getIteratee(predicate, 3), index); 7324 } 7325 7326 /** 7327 * This method is like `_.findIndex` except that it iterates over elements 7328 * of `collection` from right to left. 7329 * 7330 * @static 7331 * @memberOf _ 7332 * @since 2.0.0 7333 * @category Array 7334 * @param {Array} array The array to inspect. 7335 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7336 * @param {number} [fromIndex=array.length-1] The index to search from. 7337 * @returns {number} Returns the index of the found element, else `-1`. 7338 * @example 7339 * 7340 * var users = [ 7341 * { 'user': 'barney', 'active': true }, 7342 * { 'user': 'fred', 'active': false }, 7343 * { 'user': 'pebbles', 'active': false } 7344 * ]; 7345 * 7346 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 7347 * // => 2 7348 * 7349 * // The `_.matches` iteratee shorthand. 7350 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 7351 * // => 0 7352 * 7353 * // The `_.matchesProperty` iteratee shorthand. 7354 * _.findLastIndex(users, ['active', false]); 7355 * // => 2 7356 * 7357 * // The `_.property` iteratee shorthand. 7358 * _.findLastIndex(users, 'active'); 7359 * // => 0 7360 */ 7361 function findLastIndex(array, predicate, fromIndex) { 7362 var length = array == null ? 0 : array.length; 7363 if (!length) { 7364 return -1; 7365 } 7366 var index = length - 1; 7367 if (fromIndex !== undefined) { 7368 index = toInteger(fromIndex); 7369 index = fromIndex < 0 7370 ? nativeMax(length + index, 0) 7371 : nativeMin(index, length - 1); 7372 } 7373 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 7374 } 7375 7376 /** 7377 * Flattens `array` a single level deep. 7378 * 7379 * @static 7380 * @memberOf _ 7381 * @since 0.1.0 7382 * @category Array 7383 * @param {Array} array The array to flatten. 7384 * @returns {Array} Returns the new flattened array. 7385 * @example 7386 * 7387 * _.flatten([1, [2, [3, [4]], 5]]); 7388 * // => [1, 2, [3, [4]], 5] 7389 */ 7390 function flatten(array) { 7391 var length = array == null ? 0 : array.length; 7392 return length ? baseFlatten(array, 1) : []; 7393 } 7394 7395 /** 7396 * Recursively flattens `array`. 7397 * 7398 * @static 7399 * @memberOf _ 7400 * @since 3.0.0 7401 * @category Array 7402 * @param {Array} array The array to flatten. 7403 * @returns {Array} Returns the new flattened array. 7404 * @example 7405 * 7406 * _.flattenDeep([1, [2, [3, [4]], 5]]); 7407 * // => [1, 2, 3, 4, 5] 7408 */ 7409 function flattenDeep(array) { 7410 var length = array == null ? 0 : array.length; 7411 return length ? baseFlatten(array, INFINITY) : []; 7412 } 7413 7414 /** 7415 * Recursively flatten `array` up to `depth` times. 7416 * 7417 * @static 7418 * @memberOf _ 7419 * @since 4.4.0 7420 * @category Array 7421 * @param {Array} array The array to flatten. 7422 * @param {number} [depth=1] The maximum recursion depth. 7423 * @returns {Array} Returns the new flattened array. 7424 * @example 7425 * 7426 * var array = [1, [2, [3, [4]], 5]]; 7427 * 7428 * _.flattenDepth(array, 1); 7429 * // => [1, 2, [3, [4]], 5] 7430 * 7431 * _.flattenDepth(array, 2); 7432 * // => [1, 2, 3, [4], 5] 7433 */ 7434 function flattenDepth(array, depth) { 7435 var length = array == null ? 0 : array.length; 7436 if (!length) { 7437 return []; 7438 } 7439 depth = depth === undefined ? 1 : toInteger(depth); 7440 return baseFlatten(array, depth); 7441 } 7442 7443 /** 7444 * The inverse of `_.toPairs`; this method returns an object composed 7445 * from key-value `pairs`. 7446 * 7447 * @static 7448 * @memberOf _ 7449 * @since 4.0.0 7450 * @category Array 7451 * @param {Array} pairs The key-value pairs. 7452 * @returns {Object} Returns the new object. 7453 * @example 7454 * 7455 * _.fromPairs([['a', 1], ['b', 2]]); 7456 * // => { 'a': 1, 'b': 2 } 7457 */ 7458 function fromPairs(pairs) { 7459 var index = -1, 7460 length = pairs == null ? 0 : pairs.length, 7461 result = {}; 7462 7463 while (++index < length) { 7464 var pair = pairs[index]; 7465 result[pair[0]] = pair[1]; 7466 } 7467 return result; 7468 } 7469 7470 /** 7471 * Gets the first element of `array`. 7472 * 7473 * @static 7474 * @memberOf _ 7475 * @since 0.1.0 7476 * @alias first 7477 * @category Array 7478 * @param {Array} array The array to query. 7479 * @returns {*} Returns the first element of `array`. 7480 * @example 7481 * 7482 * _.head([1, 2, 3]); 7483 * // => 1 7484 * 7485 * _.head([]); 7486 * // => undefined 7487 */ 7488 function head(array) { 7489 return (array && array.length) ? array[0] : undefined; 7490 } 7491 7492 /** 7493 * Gets the index at which the first occurrence of `value` is found in `array` 7494 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7495 * for equality comparisons. If `fromIndex` is negative, it's used as the 7496 * offset from the end of `array`. 7497 * 7498 * @static 7499 * @memberOf _ 7500 * @since 0.1.0 7501 * @category Array 7502 * @param {Array} array The array to inspect. 7503 * @param {*} value The value to search for. 7504 * @param {number} [fromIndex=0] The index to search from. 7505 * @returns {number} Returns the index of the matched value, else `-1`. 7506 * @example 7507 * 7508 * _.indexOf([1, 2, 1, 2], 2); 7509 * // => 1 7510 * 7511 * // Search from the `fromIndex`. 7512 * _.indexOf([1, 2, 1, 2], 2, 2); 7513 * // => 3 7514 */ 7515 function indexOf(array, value, fromIndex) { 7516 var length = array == null ? 0 : array.length; 7517 if (!length) { 7518 return -1; 7519 } 7520 var index = fromIndex == null ? 0 : toInteger(fromIndex); 7521 if (index < 0) { 7522 index = nativeMax(length + index, 0); 7523 } 7524 return baseIndexOf(array, value, index); 7525 } 7526 7527 /** 7528 * Gets all but the last element of `array`. 7529 * 7530 * @static 7531 * @memberOf _ 7532 * @since 0.1.0 7533 * @category Array 7534 * @param {Array} array The array to query. 7535 * @returns {Array} Returns the slice of `array`. 7536 * @example 7537 * 7538 * _.initial([1, 2, 3]); 7539 * // => [1, 2] 7540 */ 7541 function initial(array) { 7542 var length = array == null ? 0 : array.length; 7543 return length ? baseSlice(array, 0, -1) : []; 7544 } 7545 7546 /** 7547 * Creates an array of unique values that are included in all given arrays 7548 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7549 * for equality comparisons. The order and references of result values are 7550 * determined by the first array. 7551 * 7552 * @static 7553 * @memberOf _ 7554 * @since 0.1.0 7555 * @category Array 7556 * @param {...Array} [arrays] The arrays to inspect. 7557 * @returns {Array} Returns the new array of intersecting values. 7558 * @example 7559 * 7560 * _.intersection([2, 1], [2, 3]); 7561 * // => [2] 7562 */ 7563 var intersection = baseRest(function(arrays) { 7564 var mapped = arrayMap(arrays, castArrayLikeObject); 7565 return (mapped.length && mapped[0] === arrays[0]) 7566 ? baseIntersection(mapped) 7567 : []; 7568 }); 7569 7570 /** 7571 * This method is like `_.intersection` except that it accepts `iteratee` 7572 * which is invoked for each element of each `arrays` to generate the criterion 7573 * by which they're compared. The order and references of result values are 7574 * determined by the first array. The iteratee is invoked with one argument: 7575 * (value). 7576 * 7577 * @static 7578 * @memberOf _ 7579 * @since 4.0.0 7580 * @category Array 7581 * @param {...Array} [arrays] The arrays to inspect. 7582 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 7583 * @returns {Array} Returns the new array of intersecting values. 7584 * @example 7585 * 7586 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 7587 * // => [2.1] 7588 * 7589 * // The `_.property` iteratee shorthand. 7590 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 7591 * // => [{ 'x': 1 }] 7592 */ 7593 var intersectionBy = baseRest(function(arrays) { 7594 var iteratee = last(arrays), 7595 mapped = arrayMap(arrays, castArrayLikeObject); 7596 7597 if (iteratee === last(mapped)) { 7598 iteratee = undefined; 7599 } else { 7600 mapped.pop(); 7601 } 7602 return (mapped.length && mapped[0] === arrays[0]) 7603 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 7604 : []; 7605 }); 7606 7607 /** 7608 * This method is like `_.intersection` except that it accepts `comparator` 7609 * which is invoked to compare elements of `arrays`. The order and references 7610 * of result values are determined by the first array. The comparator is 7611 * invoked with two arguments: (arrVal, othVal). 7612 * 7613 * @static 7614 * @memberOf _ 7615 * @since 4.0.0 7616 * @category Array 7617 * @param {...Array} [arrays] The arrays to inspect. 7618 * @param {Function} [comparator] The comparator invoked per element. 7619 * @returns {Array} Returns the new array of intersecting values. 7620 * @example 7621 * 7622 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 7623 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 7624 * 7625 * _.intersectionWith(objects, others, _.isEqual); 7626 * // => [{ 'x': 1, 'y': 2 }] 7627 */ 7628 var intersectionWith = baseRest(function(arrays) { 7629 var comparator = last(arrays), 7630 mapped = arrayMap(arrays, castArrayLikeObject); 7631 7632 comparator = typeof comparator == 'function' ? comparator : undefined; 7633 if (comparator) { 7634 mapped.pop(); 7635 } 7636 return (mapped.length && mapped[0] === arrays[0]) 7637 ? baseIntersection(mapped, undefined, comparator) 7638 : []; 7639 }); 7640 7641 /** 7642 * Converts all elements in `array` into a string separated by `separator`. 7643 * 7644 * @static 7645 * @memberOf _ 7646 * @since 4.0.0 7647 * @category Array 7648 * @param {Array} array The array to convert. 7649 * @param {string} [separator=','] The element separator. 7650 * @returns {string} Returns the joined string. 7651 * @example 7652 * 7653 * _.join(['a', 'b', 'c'], '~'); 7654 * // => 'a~b~c' 7655 */ 7656 function join(array, separator) { 7657 return array == null ? '' : nativeJoin.call(array, separator); 7658 } 7659 7660 /** 7661 * Gets the last element of `array`. 7662 * 7663 * @static 7664 * @memberOf _ 7665 * @since 0.1.0 7666 * @category Array 7667 * @param {Array} array The array to query. 7668 * @returns {*} Returns the last element of `array`. 7669 * @example 7670 * 7671 * _.last([1, 2, 3]); 7672 * // => 3 7673 */ 7674 function last(array) { 7675 var length = array == null ? 0 : array.length; 7676 return length ? array[length - 1] : undefined; 7677 } 7678 7679 /** 7680 * This method is like `_.indexOf` except that it iterates over elements of 7681 * `array` from right to left. 7682 * 7683 * @static 7684 * @memberOf _ 7685 * @since 0.1.0 7686 * @category Array 7687 * @param {Array} array The array to inspect. 7688 * @param {*} value The value to search for. 7689 * @param {number} [fromIndex=array.length-1] The index to search from. 7690 * @returns {number} Returns the index of the matched value, else `-1`. 7691 * @example 7692 * 7693 * _.lastIndexOf([1, 2, 1, 2], 2); 7694 * // => 3 7695 * 7696 * // Search from the `fromIndex`. 7697 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 7698 * // => 1 7699 */ 7700 function lastIndexOf(array, value, fromIndex) { 7701 var length = array == null ? 0 : array.length; 7702 if (!length) { 7703 return -1; 7704 } 7705 var index = length; 7706 if (fromIndex !== undefined) { 7707 index = toInteger(fromIndex); 7708 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 7709 } 7710 return value === value 7711 ? strictLastIndexOf(array, value, index) 7712 : baseFindIndex(array, baseIsNaN, index, true); 7713 } 7714 7715 /** 7716 * Gets the element at index `n` of `array`. If `n` is negative, the nth 7717 * element from the end is returned. 7718 * 7719 * @static 7720 * @memberOf _ 7721 * @since 4.11.0 7722 * @category Array 7723 * @param {Array} array The array to query. 7724 * @param {number} [n=0] The index of the element to return. 7725 * @returns {*} Returns the nth element of `array`. 7726 * @example 7727 * 7728 * var array = ['a', 'b', 'c', 'd']; 7729 * 7730 * _.nth(array, 1); 7731 * // => 'b' 7732 * 7733 * _.nth(array, -2); 7734 * // => 'c'; 7735 */ 7736 function nth(array, n) { 7737 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 7738 } 7739 7740 /** 7741 * Removes all given values from `array` using 7742 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7743 * for equality comparisons. 7744 * 7745 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 7746 * to remove elements from an array by predicate. 7747 * 7748 * @static 7749 * @memberOf _ 7750 * @since 2.0.0 7751 * @category Array 7752 * @param {Array} array The array to modify. 7753 * @param {...*} [values] The values to remove. 7754 * @returns {Array} Returns `array`. 7755 * @example 7756 * 7757 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 7758 * 7759 * _.pull(array, 'a', 'c'); 7760 * console.log(array); 7761 * // => ['b', 'b'] 7762 */ 7763 var pull = baseRest(pullAll); 7764 7765 /** 7766 * This method is like `_.pull` except that it accepts an array of values to remove. 7767 * 7768 * **Note:** Unlike `_.difference`, this method mutates `array`. 7769 * 7770 * @static 7771 * @memberOf _ 7772 * @since 4.0.0 7773 * @category Array 7774 * @param {Array} array The array to modify. 7775 * @param {Array} values The values to remove. 7776 * @returns {Array} Returns `array`. 7777 * @example 7778 * 7779 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 7780 * 7781 * _.pullAll(array, ['a', 'c']); 7782 * console.log(array); 7783 * // => ['b', 'b'] 7784 */ 7785 function pullAll(array, values) { 7786 return (array && array.length && values && values.length) 7787 ? basePullAll(array, values) 7788 : array; 7789 } 7790 7791 /** 7792 * This method is like `_.pullAll` except that it accepts `iteratee` which is 7793 * invoked for each element of `array` and `values` to generate the criterion 7794 * by which they're compared. The iteratee is invoked with one argument: (value). 7795 * 7796 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 7797 * 7798 * @static 7799 * @memberOf _ 7800 * @since 4.0.0 7801 * @category Array 7802 * @param {Array} array The array to modify. 7803 * @param {Array} values The values to remove. 7804 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 7805 * @returns {Array} Returns `array`. 7806 * @example 7807 * 7808 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 7809 * 7810 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 7811 * console.log(array); 7812 * // => [{ 'x': 2 }] 7813 */ 7814 function pullAllBy(array, values, iteratee) { 7815 return (array && array.length && values && values.length) 7816 ? basePullAll(array, values, getIteratee(iteratee, 2)) 7817 : array; 7818 } 7819 7820 /** 7821 * This method is like `_.pullAll` except that it accepts `comparator` which 7822 * is invoked to compare elements of `array` to `values`. The comparator is 7823 * invoked with two arguments: (arrVal, othVal). 7824 * 7825 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 7826 * 7827 * @static 7828 * @memberOf _ 7829 * @since 4.6.0 7830 * @category Array 7831 * @param {Array} array The array to modify. 7832 * @param {Array} values The values to remove. 7833 * @param {Function} [comparator] The comparator invoked per element. 7834 * @returns {Array} Returns `array`. 7835 * @example 7836 * 7837 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 7838 * 7839 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 7840 * console.log(array); 7841 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 7842 */ 7843 function pullAllWith(array, values, comparator) { 7844 return (array && array.length && values && values.length) 7845 ? basePullAll(array, values, undefined, comparator) 7846 : array; 7847 } 7848 7849 /** 7850 * Removes elements from `array` corresponding to `indexes` and returns an 7851 * array of removed elements. 7852 * 7853 * **Note:** Unlike `_.at`, this method mutates `array`. 7854 * 7855 * @static 7856 * @memberOf _ 7857 * @since 3.0.0 7858 * @category Array 7859 * @param {Array} array The array to modify. 7860 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 7861 * @returns {Array} Returns the new array of removed elements. 7862 * @example 7863 * 7864 * var array = ['a', 'b', 'c', 'd']; 7865 * var pulled = _.pullAt(array, [1, 3]); 7866 * 7867 * console.log(array); 7868 * // => ['a', 'c'] 7869 * 7870 * console.log(pulled); 7871 * // => ['b', 'd'] 7872 */ 7873 var pullAt = flatRest(function(array, indexes) { 7874 var length = array == null ? 0 : array.length, 7875 result = baseAt(array, indexes); 7876 7877 basePullAt(array, arrayMap(indexes, function(index) { 7878 return isIndex(index, length) ? +index : index; 7879 }).sort(compareAscending)); 7880 7881 return result; 7882 }); 7883 7884 /** 7885 * Removes all elements from `array` that `predicate` returns truthy for 7886 * and returns an array of the removed elements. The predicate is invoked 7887 * with three arguments: (value, index, array). 7888 * 7889 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 7890 * to pull elements from an array by value. 7891 * 7892 * @static 7893 * @memberOf _ 7894 * @since 2.0.0 7895 * @category Array 7896 * @param {Array} array The array to modify. 7897 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7898 * @returns {Array} Returns the new array of removed elements. 7899 * @example 7900 * 7901 * var array = [1, 2, 3, 4]; 7902 * var evens = _.remove(array, function(n) { 7903 * return n % 2 == 0; 7904 * }); 7905 * 7906 * console.log(array); 7907 * // => [1, 3] 7908 * 7909 * console.log(evens); 7910 * // => [2, 4] 7911 */ 7912 function remove(array, predicate) { 7913 var result = []; 7914 if (!(array && array.length)) { 7915 return result; 7916 } 7917 var index = -1, 7918 indexes = [], 7919 length = array.length; 7920 7921 predicate = getIteratee(predicate, 3); 7922 while (++index < length) { 7923 var value = array[index]; 7924 if (predicate(value, index, array)) { 7925 result.push(value); 7926 indexes.push(index); 7927 } 7928 } 7929 basePullAt(array, indexes); 7930 return result; 7931 } 7932 7933 /** 7934 * Reverses `array` so that the first element becomes the last, the second 7935 * element becomes the second to last, and so on. 7936 * 7937 * **Note:** This method mutates `array` and is based on 7938 * [`Array#reverse`](https://mdn.io/Array/reverse). 7939 * 7940 * @static 7941 * @memberOf _ 7942 * @since 4.0.0 7943 * @category Array 7944 * @param {Array} array The array to modify. 7945 * @returns {Array} Returns `array`. 7946 * @example 7947 * 7948 * var array = [1, 2, 3]; 7949 * 7950 * _.reverse(array); 7951 * // => [3, 2, 1] 7952 * 7953 * console.log(array); 7954 * // => [3, 2, 1] 7955 */ 7956 function reverse(array) { 7957 return array == null ? array : nativeReverse.call(array); 7958 } 7959 7960 /** 7961 * Creates a slice of `array` from `start` up to, but not including, `end`. 7962 * 7963 * **Note:** This method is used instead of 7964 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 7965 * returned. 7966 * 7967 * @static 7968 * @memberOf _ 7969 * @since 3.0.0 7970 * @category Array 7971 * @param {Array} array The array to slice. 7972 * @param {number} [start=0] The start position. 7973 * @param {number} [end=array.length] The end position. 7974 * @returns {Array} Returns the slice of `array`. 7975 */ 7976 function slice(array, start, end) { 7977 var length = array == null ? 0 : array.length; 7978 if (!length) { 7979 return []; 7980 } 7981 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 7982 start = 0; 7983 end = length; 7984 } 7985 else { 7986 start = start == null ? 0 : toInteger(start); 7987 end = end === undefined ? length : toInteger(end); 7988 } 7989 return baseSlice(array, start, end); 7990 } 7991 7992 /** 7993 * Uses a binary search to determine the lowest index at which `value` 7994 * should be inserted into `array` in order to maintain its sort order. 7995 * 7996 * @static 7997 * @memberOf _ 7998 * @since 0.1.0 7999 * @category Array 8000 * @param {Array} array The sorted array to inspect. 8001 * @param {*} value The value to evaluate. 8002 * @returns {number} Returns the index at which `value` should be inserted 8003 * into `array`. 8004 * @example 8005 * 8006 * _.sortedIndex([30, 50], 40); 8007 * // => 1 8008 */ 8009 function sortedIndex(array, value) { 8010 return baseSortedIndex(array, value); 8011 } 8012 8013 /** 8014 * This method is like `_.sortedIndex` except that it accepts `iteratee` 8015 * which is invoked for `value` and each element of `array` to compute their 8016 * sort ranking. The iteratee is invoked with one argument: (value). 8017 * 8018 * @static 8019 * @memberOf _ 8020 * @since 4.0.0 8021 * @category Array 8022 * @param {Array} array The sorted array to inspect. 8023 * @param {*} value The value to evaluate. 8024 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8025 * @returns {number} Returns the index at which `value` should be inserted 8026 * into `array`. 8027 * @example 8028 * 8029 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 8030 * 8031 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 8032 * // => 0 8033 * 8034 * // The `_.property` iteratee shorthand. 8035 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 8036 * // => 0 8037 */ 8038 function sortedIndexBy(array, value, iteratee) { 8039 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 8040 } 8041 8042 /** 8043 * This method is like `_.indexOf` except that it performs a binary 8044 * search on a sorted `array`. 8045 * 8046 * @static 8047 * @memberOf _ 8048 * @since 4.0.0 8049 * @category Array 8050 * @param {Array} array The array to inspect. 8051 * @param {*} value The value to search for. 8052 * @returns {number} Returns the index of the matched value, else `-1`. 8053 * @example 8054 * 8055 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 8056 * // => 1 8057 */ 8058 function sortedIndexOf(array, value) { 8059 var length = array == null ? 0 : array.length; 8060 if (length) { 8061 var index = baseSortedIndex(array, value); 8062 if (index < length && eq(array[index], value)) { 8063 return index; 8064 } 8065 } 8066 return -1; 8067 } 8068 8069 /** 8070 * This method is like `_.sortedIndex` except that it returns the highest 8071 * index at which `value` should be inserted into `array` in order to 8072 * maintain its sort order. 8073 * 8074 * @static 8075 * @memberOf _ 8076 * @since 3.0.0 8077 * @category Array 8078 * @param {Array} array The sorted array to inspect. 8079 * @param {*} value The value to evaluate. 8080 * @returns {number} Returns the index at which `value` should be inserted 8081 * into `array`. 8082 * @example 8083 * 8084 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 8085 * // => 4 8086 */ 8087 function sortedLastIndex(array, value) { 8088 return baseSortedIndex(array, value, true); 8089 } 8090 8091 /** 8092 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 8093 * which is invoked for `value` and each element of `array` to compute their 8094 * sort ranking. The iteratee is invoked with one argument: (value). 8095 * 8096 * @static 8097 * @memberOf _ 8098 * @since 4.0.0 8099 * @category Array 8100 * @param {Array} array The sorted array to inspect. 8101 * @param {*} value The value to evaluate. 8102 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8103 * @returns {number} Returns the index at which `value` should be inserted 8104 * into `array`. 8105 * @example 8106 * 8107 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 8108 * 8109 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 8110 * // => 1 8111 * 8112 * // The `_.property` iteratee shorthand. 8113 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 8114 * // => 1 8115 */ 8116 function sortedLastIndexBy(array, value, iteratee) { 8117 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 8118 } 8119 8120 /** 8121 * This method is like `_.lastIndexOf` except that it performs a binary 8122 * search on a sorted `array`. 8123 * 8124 * @static 8125 * @memberOf _ 8126 * @since 4.0.0 8127 * @category Array 8128 * @param {Array} array The array to inspect. 8129 * @param {*} value The value to search for. 8130 * @returns {number} Returns the index of the matched value, else `-1`. 8131 * @example 8132 * 8133 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 8134 * // => 3 8135 */ 8136 function sortedLastIndexOf(array, value) { 8137 var length = array == null ? 0 : array.length; 8138 if (length) { 8139 var index = baseSortedIndex(array, value, true) - 1; 8140 if (eq(array[index], value)) { 8141 return index; 8142 } 8143 } 8144 return -1; 8145 } 8146 8147 /** 8148 * This method is like `_.uniq` except that it's designed and optimized 8149 * for sorted arrays. 8150 * 8151 * @static 8152 * @memberOf _ 8153 * @since 4.0.0 8154 * @category Array 8155 * @param {Array} array The array to inspect. 8156 * @returns {Array} Returns the new duplicate free array. 8157 * @example 8158 * 8159 * _.sortedUniq([1, 1, 2]); 8160 * // => [1, 2] 8161 */ 8162 function sortedUniq(array) { 8163 return (array && array.length) 8164 ? baseSortedUniq(array) 8165 : []; 8166 } 8167 8168 /** 8169 * This method is like `_.uniqBy` except that it's designed and optimized 8170 * for sorted arrays. 8171 * 8172 * @static 8173 * @memberOf _ 8174 * @since 4.0.0 8175 * @category Array 8176 * @param {Array} array The array to inspect. 8177 * @param {Function} [iteratee] The iteratee invoked per element. 8178 * @returns {Array} Returns the new duplicate free array. 8179 * @example 8180 * 8181 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 8182 * // => [1.1, 2.3] 8183 */ 8184 function sortedUniqBy(array, iteratee) { 8185 return (array && array.length) 8186 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 8187 : []; 8188 } 8189 8190 /** 8191 * Gets all but the first element of `array`. 8192 * 8193 * @static 8194 * @memberOf _ 8195 * @since 4.0.0 8196 * @category Array 8197 * @param {Array} array The array to query. 8198 * @returns {Array} Returns the slice of `array`. 8199 * @example 8200 * 8201 * _.tail([1, 2, 3]); 8202 * // => [2, 3] 8203 */ 8204 function tail(array) { 8205 var length = array == null ? 0 : array.length; 8206 return length ? baseSlice(array, 1, length) : []; 8207 } 8208 8209 /** 8210 * Creates a slice of `array` with `n` elements taken from the beginning. 8211 * 8212 * @static 8213 * @memberOf _ 8214 * @since 0.1.0 8215 * @category Array 8216 * @param {Array} array The array to query. 8217 * @param {number} [n=1] The number of elements to take. 8218 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8219 * @returns {Array} Returns the slice of `array`. 8220 * @example 8221 * 8222 * _.take([1, 2, 3]); 8223 * // => [1] 8224 * 8225 * _.take([1, 2, 3], 2); 8226 * // => [1, 2] 8227 * 8228 * _.take([1, 2, 3], 5); 8229 * // => [1, 2, 3] 8230 * 8231 * _.take([1, 2, 3], 0); 8232 * // => [] 8233 */ 8234 function take(array, n, guard) { 8235 if (!(array && array.length)) { 8236 return []; 8237 } 8238 n = (guard || n === undefined) ? 1 : toInteger(n); 8239 return baseSlice(array, 0, n < 0 ? 0 : n); 8240 } 8241 8242 /** 8243 * Creates a slice of `array` with `n` elements taken from the end. 8244 * 8245 * @static 8246 * @memberOf _ 8247 * @since 3.0.0 8248 * @category Array 8249 * @param {Array} array The array to query. 8250 * @param {number} [n=1] The number of elements to take. 8251 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8252 * @returns {Array} Returns the slice of `array`. 8253 * @example 8254 * 8255 * _.takeRight([1, 2, 3]); 8256 * // => [3] 8257 * 8258 * _.takeRight([1, 2, 3], 2); 8259 * // => [2, 3] 8260 * 8261 * _.takeRight([1, 2, 3], 5); 8262 * // => [1, 2, 3] 8263 * 8264 * _.takeRight([1, 2, 3], 0); 8265 * // => [] 8266 */ 8267 function takeRight(array, n, guard) { 8268 var length = array == null ? 0 : array.length; 8269 if (!length) { 8270 return []; 8271 } 8272 n = (guard || n === undefined) ? 1 : toInteger(n); 8273 n = length - n; 8274 return baseSlice(array, n < 0 ? 0 : n, length); 8275 } 8276 8277 /** 8278 * Creates a slice of `array` with elements taken from the end. Elements are 8279 * taken until `predicate` returns falsey. The predicate is invoked with 8280 * three arguments: (value, index, array). 8281 * 8282 * @static 8283 * @memberOf _ 8284 * @since 3.0.0 8285 * @category Array 8286 * @param {Array} array The array to query. 8287 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8288 * @returns {Array} Returns the slice of `array`. 8289 * @example 8290 * 8291 * var users = [ 8292 * { 'user': 'barney', 'active': true }, 8293 * { 'user': 'fred', 'active': false }, 8294 * { 'user': 'pebbles', 'active': false } 8295 * ]; 8296 * 8297 * _.takeRightWhile(users, function(o) { return !o.active; }); 8298 * // => objects for ['fred', 'pebbles'] 8299 * 8300 * // The `_.matches` iteratee shorthand. 8301 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 8302 * // => objects for ['pebbles'] 8303 * 8304 * // The `_.matchesProperty` iteratee shorthand. 8305 * _.takeRightWhile(users, ['active', false]); 8306 * // => objects for ['fred', 'pebbles'] 8307 * 8308 * // The `_.property` iteratee shorthand. 8309 * _.takeRightWhile(users, 'active'); 8310 * // => [] 8311 */ 8312 function takeRightWhile(array, predicate) { 8313 return (array && array.length) 8314 ? baseWhile(array, getIteratee(predicate, 3), false, true) 8315 : []; 8316 } 8317 8318 /** 8319 * Creates a slice of `array` with elements taken from the beginning. Elements 8320 * are taken until `predicate` returns falsey. The predicate is invoked with 8321 * three arguments: (value, index, array). 8322 * 8323 * @static 8324 * @memberOf _ 8325 * @since 3.0.0 8326 * @category Array 8327 * @param {Array} array The array to query. 8328 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8329 * @returns {Array} Returns the slice of `array`. 8330 * @example 8331 * 8332 * var users = [ 8333 * { 'user': 'barney', 'active': false }, 8334 * { 'user': 'fred', 'active': false }, 8335 * { 'user': 'pebbles', 'active': true } 8336 * ]; 8337 * 8338 * _.takeWhile(users, function(o) { return !o.active; }); 8339 * // => objects for ['barney', 'fred'] 8340 * 8341 * // The `_.matches` iteratee shorthand. 8342 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 8343 * // => objects for ['barney'] 8344 * 8345 * // The `_.matchesProperty` iteratee shorthand. 8346 * _.takeWhile(users, ['active', false]); 8347 * // => objects for ['barney', 'fred'] 8348 * 8349 * // The `_.property` iteratee shorthand. 8350 * _.takeWhile(users, 'active'); 8351 * // => [] 8352 */ 8353 function takeWhile(array, predicate) { 8354 return (array && array.length) 8355 ? baseWhile(array, getIteratee(predicate, 3)) 8356 : []; 8357 } 8358 8359 /** 8360 * Creates an array of unique values, in order, from all given arrays using 8361 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8362 * for equality comparisons. 8363 * 8364 * @static 8365 * @memberOf _ 8366 * @since 0.1.0 8367 * @category Array 8368 * @param {...Array} [arrays] The arrays to inspect. 8369 * @returns {Array} Returns the new array of combined values. 8370 * @example 8371 * 8372 * _.union([2], [1, 2]); 8373 * // => [2, 1] 8374 */ 8375 var union = baseRest(function(arrays) { 8376 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 8377 }); 8378 8379 /** 8380 * This method is like `_.union` except that it accepts `iteratee` which is 8381 * invoked for each element of each `arrays` to generate the criterion by 8382 * which uniqueness is computed. Result values are chosen from the first 8383 * array in which the value occurs. The iteratee is invoked with one argument: 8384 * (value). 8385 * 8386 * @static 8387 * @memberOf _ 8388 * @since 4.0.0 8389 * @category Array 8390 * @param {...Array} [arrays] The arrays to inspect. 8391 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8392 * @returns {Array} Returns the new array of combined values. 8393 * @example 8394 * 8395 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 8396 * // => [2.1, 1.2] 8397 * 8398 * // The `_.property` iteratee shorthand. 8399 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 8400 * // => [{ 'x': 1 }, { 'x': 2 }] 8401 */ 8402 var unionBy = baseRest(function(arrays) { 8403 var iteratee = last(arrays); 8404 if (isArrayLikeObject(iteratee)) { 8405 iteratee = undefined; 8406 } 8407 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 8408 }); 8409 8410 /** 8411 * This method is like `_.union` except that it accepts `comparator` which 8412 * is invoked to compare elements of `arrays`. Result values are chosen from 8413 * the first array in which the value occurs. The comparator is invoked 8414 * with two arguments: (arrVal, othVal). 8415 * 8416 * @static 8417 * @memberOf _ 8418 * @since 4.0.0 8419 * @category Array 8420 * @param {...Array} [arrays] The arrays to inspect. 8421 * @param {Function} [comparator] The comparator invoked per element. 8422 * @returns {Array} Returns the new array of combined values. 8423 * @example 8424 * 8425 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 8426 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 8427 * 8428 * _.unionWith(objects, others, _.isEqual); 8429 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 8430 */ 8431 var unionWith = baseRest(function(arrays) { 8432 var comparator = last(arrays); 8433 comparator = typeof comparator == 'function' ? comparator : undefined; 8434 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 8435 }); 8436 8437 /** 8438 * Creates a duplicate-free version of an array, using 8439 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8440 * for equality comparisons, in which only the first occurrence of each element 8441 * is kept. The order of result values is determined by the order they occur 8442 * in the array. 8443 * 8444 * @static 8445 * @memberOf _ 8446 * @since 0.1.0 8447 * @category Array 8448 * @param {Array} array The array to inspect. 8449 * @returns {Array} Returns the new duplicate free array. 8450 * @example 8451 * 8452 * _.uniq([2, 1, 2]); 8453 * // => [2, 1] 8454 */ 8455 function uniq(array) { 8456 return (array && array.length) ? baseUniq(array) : []; 8457 } 8458 8459 /** 8460 * This method is like `_.uniq` except that it accepts `iteratee` which is 8461 * invoked for each element in `array` to generate the criterion by which 8462 * uniqueness is computed. The order of result values is determined by the 8463 * order they occur in the array. The iteratee is invoked with one argument: 8464 * (value). 8465 * 8466 * @static 8467 * @memberOf _ 8468 * @since 4.0.0 8469 * @category Array 8470 * @param {Array} array The array to inspect. 8471 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8472 * @returns {Array} Returns the new duplicate free array. 8473 * @example 8474 * 8475 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 8476 * // => [2.1, 1.2] 8477 * 8478 * // The `_.property` iteratee shorthand. 8479 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 8480 * // => [{ 'x': 1 }, { 'x': 2 }] 8481 */ 8482 function uniqBy(array, iteratee) { 8483 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 8484 } 8485 8486 /** 8487 * This method is like `_.uniq` except that it accepts `comparator` which 8488 * is invoked to compare elements of `array`. The order of result values is 8489 * determined by the order they occur in the array.The comparator is invoked 8490 * with two arguments: (arrVal, othVal). 8491 * 8492 * @static 8493 * @memberOf _ 8494 * @since 4.0.0 8495 * @category Array 8496 * @param {Array} array The array to inspect. 8497 * @param {Function} [comparator] The comparator invoked per element. 8498 * @returns {Array} Returns the new duplicate free array. 8499 * @example 8500 * 8501 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 8502 * 8503 * _.uniqWith(objects, _.isEqual); 8504 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 8505 */ 8506 function uniqWith(array, comparator) { 8507 comparator = typeof comparator == 'function' ? comparator : undefined; 8508 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 8509 } 8510 8511 /** 8512 * This method is like `_.zip` except that it accepts an array of grouped 8513 * elements and creates an array regrouping the elements to their pre-zip 8514 * configuration. 8515 * 8516 * @static 8517 * @memberOf _ 8518 * @since 1.2.0 8519 * @category Array 8520 * @param {Array} array The array of grouped elements to process. 8521 * @returns {Array} Returns the new array of regrouped elements. 8522 * @example 8523 * 8524 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 8525 * // => [['a', 1, true], ['b', 2, false]] 8526 * 8527 * _.unzip(zipped); 8528 * // => [['a', 'b'], [1, 2], [true, false]] 8529 */ 8530 function unzip(array) { 8531 if (!(array && array.length)) { 8532 return []; 8533 } 8534 var length = 0; 8535 array = arrayFilter(array, function(group) { 8536 if (isArrayLikeObject(group)) { 8537 length = nativeMax(group.length, length); 8538 return true; 8539 } 8540 }); 8541 return baseTimes(length, function(index) { 8542 return arrayMap(array, baseProperty(index)); 8543 }); 8544 } 8545 8546 /** 8547 * This method is like `_.unzip` except that it accepts `iteratee` to specify 8548 * how regrouped values should be combined. The iteratee is invoked with the 8549 * elements of each group: (...group). 8550 * 8551 * @static 8552 * @memberOf _ 8553 * @since 3.8.0 8554 * @category Array 8555 * @param {Array} array The array of grouped elements to process. 8556 * @param {Function} [iteratee=_.identity] The function to combine 8557 * regrouped values. 8558 * @returns {Array} Returns the new array of regrouped elements. 8559 * @example 8560 * 8561 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 8562 * // => [[1, 10, 100], [2, 20, 200]] 8563 * 8564 * _.unzipWith(zipped, _.add); 8565 * // => [3, 30, 300] 8566 */ 8567 function unzipWith(array, iteratee) { 8568 if (!(array && array.length)) { 8569 return []; 8570 } 8571 var result = unzip(array); 8572 if (iteratee == null) { 8573 return result; 8574 } 8575 return arrayMap(result, function(group) { 8576 return apply(iteratee, undefined, group); 8577 }); 8578 } 8579 8580 /** 8581 * Creates an array excluding all given values using 8582 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8583 * for equality comparisons. 8584 * 8585 * **Note:** Unlike `_.pull`, this method returns a new array. 8586 * 8587 * @static 8588 * @memberOf _ 8589 * @since 0.1.0 8590 * @category Array 8591 * @param {Array} array The array to inspect. 8592 * @param {...*} [values] The values to exclude. 8593 * @returns {Array} Returns the new array of filtered values. 8594 * @see _.difference, _.xor 8595 * @example 8596 * 8597 * _.without([2, 1, 2, 3], 1, 2); 8598 * // => [3] 8599 */ 8600 var without = baseRest(function(array, values) { 8601 return isArrayLikeObject(array) 8602 ? baseDifference(array, values) 8603 : []; 8604 }); 8605 8606 /** 8607 * Creates an array of unique values that is the 8608 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 8609 * of the given arrays. The order of result values is determined by the order 8610 * they occur in the arrays. 8611 * 8612 * @static 8613 * @memberOf _ 8614 * @since 2.4.0 8615 * @category Array 8616 * @param {...Array} [arrays] The arrays to inspect. 8617 * @returns {Array} Returns the new array of filtered values. 8618 * @see _.difference, _.without 8619 * @example 8620 * 8621 * _.xor([2, 1], [2, 3]); 8622 * // => [1, 3] 8623 */ 8624 var xor = baseRest(function(arrays) { 8625 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 8626 }); 8627 8628 /** 8629 * This method is like `_.xor` except that it accepts `iteratee` which is 8630 * invoked for each element of each `arrays` to generate the criterion by 8631 * which by which they're compared. The order of result values is determined 8632 * by the order they occur in the arrays. The iteratee is invoked with one 8633 * argument: (value). 8634 * 8635 * @static 8636 * @memberOf _ 8637 * @since 4.0.0 8638 * @category Array 8639 * @param {...Array} [arrays] The arrays to inspect. 8640 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8641 * @returns {Array} Returns the new array of filtered values. 8642 * @example 8643 * 8644 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 8645 * // => [1.2, 3.4] 8646 * 8647 * // The `_.property` iteratee shorthand. 8648 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 8649 * // => [{ 'x': 2 }] 8650 */ 8651 var xorBy = baseRest(function(arrays) { 8652 var iteratee = last(arrays); 8653 if (isArrayLikeObject(iteratee)) { 8654 iteratee = undefined; 8655 } 8656 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 8657 }); 8658 8659 /** 8660 * This method is like `_.xor` except that it accepts `comparator` which is 8661 * invoked to compare elements of `arrays`. The order of result values is 8662 * determined by the order they occur in the arrays. The comparator is invoked 8663 * with two arguments: (arrVal, othVal). 8664 * 8665 * @static 8666 * @memberOf _ 8667 * @since 4.0.0 8668 * @category Array 8669 * @param {...Array} [arrays] The arrays to inspect. 8670 * @param {Function} [comparator] The comparator invoked per element. 8671 * @returns {Array} Returns the new array of filtered values. 8672 * @example 8673 * 8674 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 8675 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 8676 * 8677 * _.xorWith(objects, others, _.isEqual); 8678 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 8679 */ 8680 var xorWith = baseRest(function(arrays) { 8681 var comparator = last(arrays); 8682 comparator = typeof comparator == 'function' ? comparator : undefined; 8683 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 8684 }); 8685 8686 /** 8687 * Creates an array of grouped elements, the first of which contains the 8688 * first elements of the given arrays, the second of which contains the 8689 * second elements of the given arrays, and so on. 8690 * 8691 * @static 8692 * @memberOf _ 8693 * @since 0.1.0 8694 * @category Array 8695 * @param {...Array} [arrays] The arrays to process. 8696 * @returns {Array} Returns the new array of grouped elements. 8697 * @example 8698 * 8699 * _.zip(['a', 'b'], [1, 2], [true, false]); 8700 * // => [['a', 1, true], ['b', 2, false]] 8701 */ 8702 var zip = baseRest(unzip); 8703 8704 /** 8705 * This method is like `_.fromPairs` except that it accepts two arrays, 8706 * one of property identifiers and one of corresponding values. 8707 * 8708 * @static 8709 * @memberOf _ 8710 * @since 0.4.0 8711 * @category Array 8712 * @param {Array} [props=[]] The property identifiers. 8713 * @param {Array} [values=[]] The property values. 8714 * @returns {Object} Returns the new object. 8715 * @example 8716 * 8717 * _.zipObject(['a', 'b'], [1, 2]); 8718 * // => { 'a': 1, 'b': 2 } 8719 */ 8720 function zipObject(props, values) { 8721 return baseZipObject(props || [], values || [], assignValue); 8722 } 8723 8724 /** 8725 * This method is like `_.zipObject` except that it supports property paths. 8726 * 8727 * @static 8728 * @memberOf _ 8729 * @since 4.1.0 8730 * @category Array 8731 * @param {Array} [props=[]] The property identifiers. 8732 * @param {Array} [values=[]] The property values. 8733 * @returns {Object} Returns the new object. 8734 * @example 8735 * 8736 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 8737 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 8738 */ 8739 function zipObjectDeep(props, values) { 8740 return baseZipObject(props || [], values || [], baseSet); 8741 } 8742 8743 /** 8744 * This method is like `_.zip` except that it accepts `iteratee` to specify 8745 * how grouped values should be combined. The iteratee is invoked with the 8746 * elements of each group: (...group). 8747 * 8748 * @static 8749 * @memberOf _ 8750 * @since 3.8.0 8751 * @category Array 8752 * @param {...Array} [arrays] The arrays to process. 8753 * @param {Function} [iteratee=_.identity] The function to combine 8754 * grouped values. 8755 * @returns {Array} Returns the new array of grouped elements. 8756 * @example 8757 * 8758 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 8759 * return a + b + c; 8760 * }); 8761 * // => [111, 222] 8762 */ 8763 var zipWith = baseRest(function(arrays) { 8764 var length = arrays.length, 8765 iteratee = length > 1 ? arrays[length - 1] : undefined; 8766 8767 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 8768 return unzipWith(arrays, iteratee); 8769 }); 8770 8771 /*------------------------------------------------------------------------*/ 8772 8773 /** 8774 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 8775 * chain sequences enabled. The result of such sequences must be unwrapped 8776 * with `_#value`. 8777 * 8778 * @static 8779 * @memberOf _ 8780 * @since 1.3.0 8781 * @category Seq 8782 * @param {*} value The value to wrap. 8783 * @returns {Object} Returns the new `lodash` wrapper instance. 8784 * @example 8785 * 8786 * var users = [ 8787 * { 'user': 'barney', 'age': 36 }, 8788 * { 'user': 'fred', 'age': 40 }, 8789 * { 'user': 'pebbles', 'age': 1 } 8790 * ]; 8791 * 8792 * var youngest = _ 8793 * .chain(users) 8794 * .sortBy('age') 8795 * .map(function(o) { 8796 * return o.user + ' is ' + o.age; 8797 * }) 8798 * .head() 8799 * .value(); 8800 * // => 'pebbles is 1' 8801 */ 8802 function chain(value) { 8803 var result = lodash(value); 8804 result.__chain__ = true; 8805 return result; 8806 } 8807 8808 /** 8809 * This method invokes `interceptor` and returns `value`. The interceptor 8810 * is invoked with one argument; (value). The purpose of this method is to 8811 * "tap into" a method chain sequence in order to modify intermediate results. 8812 * 8813 * @static 8814 * @memberOf _ 8815 * @since 0.1.0 8816 * @category Seq 8817 * @param {*} value The value to provide to `interceptor`. 8818 * @param {Function} interceptor The function to invoke. 8819 * @returns {*} Returns `value`. 8820 * @example 8821 * 8822 * _([1, 2, 3]) 8823 * .tap(function(array) { 8824 * // Mutate input array. 8825 * array.pop(); 8826 * }) 8827 * .reverse() 8828 * .value(); 8829 * // => [2, 1] 8830 */ 8831 function tap(value, interceptor) { 8832 interceptor(value); 8833 return value; 8834 } 8835 8836 /** 8837 * This method is like `_.tap` except that it returns the result of `interceptor`. 8838 * The purpose of this method is to "pass thru" values replacing intermediate 8839 * results in a method chain sequence. 8840 * 8841 * @static 8842 * @memberOf _ 8843 * @since 3.0.0 8844 * @category Seq 8845 * @param {*} value The value to provide to `interceptor`. 8846 * @param {Function} interceptor The function to invoke. 8847 * @returns {*} Returns the result of `interceptor`. 8848 * @example 8849 * 8850 * _(' abc ') 8851 * .chain() 8852 * .trim() 8853 * .thru(function(value) { 8854 * return [value]; 8855 * }) 8856 * .value(); 8857 * // => ['abc'] 8858 */ 8859 function thru(value, interceptor) { 8860 return interceptor(value); 8861 } 8862 8863 /** 8864 * This method is the wrapper version of `_.at`. 8865 * 8866 * @name at 8867 * @memberOf _ 8868 * @since 1.0.0 8869 * @category Seq 8870 * @param {...(string|string[])} [paths] The property paths to pick. 8871 * @returns {Object} Returns the new `lodash` wrapper instance. 8872 * @example 8873 * 8874 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 8875 * 8876 * _(object).at(['a[0].b.c', 'a[1]']).value(); 8877 * // => [3, 4] 8878 */ 8879 var wrapperAt = flatRest(function(paths) { 8880 var length = paths.length, 8881 start = length ? paths[0] : 0, 8882 value = this.__wrapped__, 8883 interceptor = function(object) { return baseAt(object, paths); }; 8884 8885 if (length > 1 || this.__actions__.length || 8886 !(value instanceof LazyWrapper) || !isIndex(start)) { 8887 return this.thru(interceptor); 8888 } 8889 value = value.slice(start, +start + (length ? 1 : 0)); 8890 value.__actions__.push({ 8891 'func': thru, 8892 'args': [interceptor], 8893 'thisArg': undefined 8894 }); 8895 return new LodashWrapper(value, this.__chain__).thru(function(array) { 8896 if (length && !array.length) { 8897 array.push(undefined); 8898 } 8899 return array; 8900 }); 8901 }); 8902 8903 /** 8904 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 8905 * 8906 * @name chain 8907 * @memberOf _ 8908 * @since 0.1.0 8909 * @category Seq 8910 * @returns {Object} Returns the new `lodash` wrapper instance. 8911 * @example 8912 * 8913 * var users = [ 8914 * { 'user': 'barney', 'age': 36 }, 8915 * { 'user': 'fred', 'age': 40 } 8916 * ]; 8917 * 8918 * // A sequence without explicit chaining. 8919 * _(users).head(); 8920 * // => { 'user': 'barney', 'age': 36 } 8921 * 8922 * // A sequence with explicit chaining. 8923 * _(users) 8924 * .chain() 8925 * .head() 8926 * .pick('user') 8927 * .value(); 8928 * // => { 'user': 'barney' } 8929 */ 8930 function wrapperChain() { 8931 return chain(this); 8932 } 8933 8934 /** 8935 * Executes the chain sequence and returns the wrapped result. 8936 * 8937 * @name commit 8938 * @memberOf _ 8939 * @since 3.2.0 8940 * @category Seq 8941 * @returns {Object} Returns the new `lodash` wrapper instance. 8942 * @example 8943 * 8944 * var array = [1, 2]; 8945 * var wrapped = _(array).push(3); 8946 * 8947 * console.log(array); 8948 * // => [1, 2] 8949 * 8950 * wrapped = wrapped.commit(); 8951 * console.log(array); 8952 * // => [1, 2, 3] 8953 * 8954 * wrapped.last(); 8955 * // => 3 8956 * 8957 * console.log(array); 8958 * // => [1, 2, 3] 8959 */ 8960 function wrapperCommit() { 8961 return new LodashWrapper(this.value(), this.__chain__); 8962 } 8963 8964 /** 8965 * Gets the next value on a wrapped object following the 8966 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 8967 * 8968 * @name next 8969 * @memberOf _ 8970 * @since 4.0.0 8971 * @category Seq 8972 * @returns {Object} Returns the next iterator value. 8973 * @example 8974 * 8975 * var wrapped = _([1, 2]); 8976 * 8977 * wrapped.next(); 8978 * // => { 'done': false, 'value': 1 } 8979 * 8980 * wrapped.next(); 8981 * // => { 'done': false, 'value': 2 } 8982 * 8983 * wrapped.next(); 8984 * // => { 'done': true, 'value': undefined } 8985 */ 8986 function wrapperNext() { 8987 if (this.__values__ === undefined) { 8988 this.__values__ = toArray(this.value()); 8989 } 8990 var done = this.__index__ >= this.__values__.length, 8991 value = done ? undefined : this.__values__[this.__index__++]; 8992 8993 return { 'done': done, 'value': value }; 8994 } 8995 8996 /** 8997 * Enables the wrapper to be iterable. 8998 * 8999 * @name Symbol.iterator 9000 * @memberOf _ 9001 * @since 4.0.0 9002 * @category Seq 9003 * @returns {Object} Returns the wrapper object. 9004 * @example 9005 * 9006 * var wrapped = _([1, 2]); 9007 * 9008 * wrapped[Symbol.iterator]() === wrapped; 9009 * // => true 9010 * 9011 * Array.from(wrapped); 9012 * // => [1, 2] 9013 */ 9014 function wrapperToIterator() { 9015 return this; 9016 } 9017 9018 /** 9019 * Creates a clone of the chain sequence planting `value` as the wrapped value. 9020 * 9021 * @name plant 9022 * @memberOf _ 9023 * @since 3.2.0 9024 * @category Seq 9025 * @param {*} value The value to plant. 9026 * @returns {Object} Returns the new `lodash` wrapper instance. 9027 * @example 9028 * 9029 * function square(n) { 9030 * return n * n; 9031 * } 9032 * 9033 * var wrapped = _([1, 2]).map(square); 9034 * var other = wrapped.plant([3, 4]); 9035 * 9036 * other.value(); 9037 * // => [9, 16] 9038 * 9039 * wrapped.value(); 9040 * // => [1, 4] 9041 */ 9042 function wrapperPlant(value) { 9043 var result, 9044 parent = this; 9045 9046 while (parent instanceof baseLodash) { 9047 var clone = wrapperClone(parent); 9048 clone.__index__ = 0; 9049 clone.__values__ = undefined; 9050 if (result) { 9051 previous.__wrapped__ = clone; 9052 } else { 9053 result = clone; 9054 } 9055 var previous = clone; 9056 parent = parent.__wrapped__; 9057 } 9058 previous.__wrapped__ = value; 9059 return result; 9060 } 9061 9062 /** 9063 * This method is the wrapper version of `_.reverse`. 9064 * 9065 * **Note:** This method mutates the wrapped array. 9066 * 9067 * @name reverse 9068 * @memberOf _ 9069 * @since 0.1.0 9070 * @category Seq 9071 * @returns {Object} Returns the new `lodash` wrapper instance. 9072 * @example 9073 * 9074 * var array = [1, 2, 3]; 9075 * 9076 * _(array).reverse().value() 9077 * // => [3, 2, 1] 9078 * 9079 * console.log(array); 9080 * // => [3, 2, 1] 9081 */ 9082 function wrapperReverse() { 9083 var value = this.__wrapped__; 9084 if (value instanceof LazyWrapper) { 9085 var wrapped = value; 9086 if (this.__actions__.length) { 9087 wrapped = new LazyWrapper(this); 9088 } 9089 wrapped = wrapped.reverse(); 9090 wrapped.__actions__.push({ 9091 'func': thru, 9092 'args': [reverse], 9093 'thisArg': undefined 9094 }); 9095 return new LodashWrapper(wrapped, this.__chain__); 9096 } 9097 return this.thru(reverse); 9098 } 9099 9100 /** 9101 * Executes the chain sequence to resolve the unwrapped value. 9102 * 9103 * @name value 9104 * @memberOf _ 9105 * @since 0.1.0 9106 * @alias toJSON, valueOf 9107 * @category Seq 9108 * @returns {*} Returns the resolved unwrapped value. 9109 * @example 9110 * 9111 * _([1, 2, 3]).value(); 9112 * // => [1, 2, 3] 9113 */ 9114 function wrapperValue() { 9115 return baseWrapperValue(this.__wrapped__, this.__actions__); 9116 } 9117 9118 /*------------------------------------------------------------------------*/ 9119 9120 /** 9121 * Creates an object composed of keys generated from the results of running 9122 * each element of `collection` thru `iteratee`. The corresponding value of 9123 * each key is the number of times the key was returned by `iteratee`. The 9124 * iteratee is invoked with one argument: (value). 9125 * 9126 * @static 9127 * @memberOf _ 9128 * @since 0.5.0 9129 * @category Collection 9130 * @param {Array|Object} collection The collection to iterate over. 9131 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 9132 * @returns {Object} Returns the composed aggregate object. 9133 * @example 9134 * 9135 * _.countBy([6.1, 4.2, 6.3], Math.floor); 9136 * // => { '4': 1, '6': 2 } 9137 * 9138 * // The `_.property` iteratee shorthand. 9139 * _.countBy(['one', 'two', 'three'], 'length'); 9140 * // => { '3': 2, '5': 1 } 9141 */ 9142 var countBy = createAggregator(function(result, value, key) { 9143 if (hasOwnProperty.call(result, key)) { 9144 ++result[key]; 9145 } else { 9146 baseAssignValue(result, key, 1); 9147 } 9148 }); 9149 9150 /** 9151 * Checks if `predicate` returns truthy for **all** elements of `collection`. 9152 * Iteration is stopped once `predicate` returns falsey. The predicate is 9153 * invoked with three arguments: (value, index|key, collection). 9154 * 9155 * **Note:** This method returns `true` for 9156 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 9157 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 9158 * elements of empty collections. 9159 * 9160 * @static 9161 * @memberOf _ 9162 * @since 0.1.0 9163 * @category Collection 9164 * @param {Array|Object} collection The collection to iterate over. 9165 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9166 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9167 * @returns {boolean} Returns `true` if all elements pass the predicate check, 9168 * else `false`. 9169 * @example 9170 * 9171 * _.every([true, 1, null, 'yes'], Boolean); 9172 * // => false 9173 * 9174 * var users = [ 9175 * { 'user': 'barney', 'age': 36, 'active': false }, 9176 * { 'user': 'fred', 'age': 40, 'active': false } 9177 * ]; 9178 * 9179 * // The `_.matches` iteratee shorthand. 9180 * _.every(users, { 'user': 'barney', 'active': false }); 9181 * // => false 9182 * 9183 * // The `_.matchesProperty` iteratee shorthand. 9184 * _.every(users, ['active', false]); 9185 * // => true 9186 * 9187 * // The `_.property` iteratee shorthand. 9188 * _.every(users, 'active'); 9189 * // => false 9190 */ 9191 function every(collection, predicate, guard) { 9192 var func = isArray(collection) ? arrayEvery : baseEvery; 9193 if (guard && isIterateeCall(collection, predicate, guard)) { 9194 predicate = undefined; 9195 } 9196 return func(collection, getIteratee(predicate, 3)); 9197 } 9198 9199 /** 9200 * Iterates over elements of `collection`, returning an array of all elements 9201 * `predicate` returns truthy for. The predicate is invoked with three 9202 * arguments: (value, index|key, collection). 9203 * 9204 * **Note:** Unlike `_.remove`, this method returns a new array. 9205 * 9206 * @static 9207 * @memberOf _ 9208 * @since 0.1.0 9209 * @category Collection 9210 * @param {Array|Object} collection The collection to iterate over. 9211 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9212 * @returns {Array} Returns the new filtered array. 9213 * @see _.reject 9214 * @example 9215 * 9216 * var users = [ 9217 * { 'user': 'barney', 'age': 36, 'active': true }, 9218 * { 'user': 'fred', 'age': 40, 'active': false } 9219 * ]; 9220 * 9221 * _.filter(users, function(o) { return !o.active; }); 9222 * // => objects for ['fred'] 9223 * 9224 * // The `_.matches` iteratee shorthand. 9225 * _.filter(users, { 'age': 36, 'active': true }); 9226 * // => objects for ['barney'] 9227 * 9228 * // The `_.matchesProperty` iteratee shorthand. 9229 * _.filter(users, ['active', false]); 9230 * // => objects for ['fred'] 9231 * 9232 * // The `_.property` iteratee shorthand. 9233 * _.filter(users, 'active'); 9234 * // => objects for ['barney'] 9235 * 9236 * // Combining several predicates using `_.overEvery` or `_.overSome`. 9237 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 9238 * // => objects for ['fred', 'barney'] 9239 */ 9240 function filter(collection, predicate) { 9241 var func = isArray(collection) ? arrayFilter : baseFilter; 9242 return func(collection, getIteratee(predicate, 3)); 9243 } 9244 9245 /** 9246 * Iterates over elements of `collection`, returning the first element 9247 * `predicate` returns truthy for. The predicate is invoked with three 9248 * arguments: (value, index|key, collection). 9249 * 9250 * @static 9251 * @memberOf _ 9252 * @since 0.1.0 9253 * @category Collection 9254 * @param {Array|Object} collection The collection to inspect. 9255 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9256 * @param {number} [fromIndex=0] The index to search from. 9257 * @returns {*} Returns the matched element, else `undefined`. 9258 * @example 9259 * 9260 * var users = [ 9261 * { 'user': 'barney', 'age': 36, 'active': true }, 9262 * { 'user': 'fred', 'age': 40, 'active': false }, 9263 * { 'user': 'pebbles', 'age': 1, 'active': true } 9264 * ]; 9265 * 9266 * _.find(users, function(o) { return o.age < 40; }); 9267 * // => object for 'barney' 9268 * 9269 * // The `_.matches` iteratee shorthand. 9270 * _.find(users, { 'age': 1, 'active': true }); 9271 * // => object for 'pebbles' 9272 * 9273 * // The `_.matchesProperty` iteratee shorthand. 9274 * _.find(users, ['active', false]); 9275 * // => object for 'fred' 9276 * 9277 * // The `_.property` iteratee shorthand. 9278 * _.find(users, 'active'); 9279 * // => object for 'barney' 9280 */ 9281 var find = createFind(findIndex); 9282 9283 /** 9284 * This method is like `_.find` except that it iterates over elements of 9285 * `collection` from right to left. 9286 * 9287 * @static 9288 * @memberOf _ 9289 * @since 2.0.0 9290 * @category Collection 9291 * @param {Array|Object} collection The collection to inspect. 9292 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9293 * @param {number} [fromIndex=collection.length-1] The index to search from. 9294 * @returns {*} Returns the matched element, else `undefined`. 9295 * @example 9296 * 9297 * _.findLast([1, 2, 3, 4], function(n) { 9298 * return n % 2 == 1; 9299 * }); 9300 * // => 3 9301 */ 9302 var findLast = createFind(findLastIndex); 9303 9304 /** 9305 * Creates a flattened array of values by running each element in `collection` 9306 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 9307 * with three arguments: (value, index|key, collection). 9308 * 9309 * @static 9310 * @memberOf _ 9311 * @since 4.0.0 9312 * @category Collection 9313 * @param {Array|Object} collection The collection to iterate over. 9314 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9315 * @returns {Array} Returns the new flattened array. 9316 * @example 9317 * 9318 * function duplicate(n) { 9319 * return [n, n]; 9320 * } 9321 * 9322 * _.flatMap([1, 2], duplicate); 9323 * // => [1, 1, 2, 2] 9324 */ 9325 function flatMap(collection, iteratee) { 9326 return baseFlatten(map(collection, iteratee), 1); 9327 } 9328 9329 /** 9330 * This method is like `_.flatMap` except that it recursively flattens the 9331 * mapped results. 9332 * 9333 * @static 9334 * @memberOf _ 9335 * @since 4.7.0 9336 * @category Collection 9337 * @param {Array|Object} collection The collection to iterate over. 9338 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9339 * @returns {Array} Returns the new flattened array. 9340 * @example 9341 * 9342 * function duplicate(n) { 9343 * return [[[n, n]]]; 9344 * } 9345 * 9346 * _.flatMapDeep([1, 2], duplicate); 9347 * // => [1, 1, 2, 2] 9348 */ 9349 function flatMapDeep(collection, iteratee) { 9350 return baseFlatten(map(collection, iteratee), INFINITY); 9351 } 9352 9353 /** 9354 * This method is like `_.flatMap` except that it recursively flattens the 9355 * mapped results up to `depth` times. 9356 * 9357 * @static 9358 * @memberOf _ 9359 * @since 4.7.0 9360 * @category Collection 9361 * @param {Array|Object} collection The collection to iterate over. 9362 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9363 * @param {number} [depth=1] The maximum recursion depth. 9364 * @returns {Array} Returns the new flattened array. 9365 * @example 9366 * 9367 * function duplicate(n) { 9368 * return [[[n, n]]]; 9369 * } 9370 * 9371 * _.flatMapDepth([1, 2], duplicate, 2); 9372 * // => [[1, 1], [2, 2]] 9373 */ 9374 function flatMapDepth(collection, iteratee, depth) { 9375 depth = depth === undefined ? 1 : toInteger(depth); 9376 return baseFlatten(map(collection, iteratee), depth); 9377 } 9378 9379 /** 9380 * Iterates over elements of `collection` and invokes `iteratee` for each element. 9381 * The iteratee is invoked with three arguments: (value, index|key, collection). 9382 * Iteratee functions may exit iteration early by explicitly returning `false`. 9383 * 9384 * **Note:** As with other "Collections" methods, objects with a "length" 9385 * property are iterated like arrays. To avoid this behavior use `_.forIn` 9386 * or `_.forOwn` for object iteration. 9387 * 9388 * @static 9389 * @memberOf _ 9390 * @since 0.1.0 9391 * @alias each 9392 * @category Collection 9393 * @param {Array|Object} collection The collection to iterate over. 9394 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9395 * @returns {Array|Object} Returns `collection`. 9396 * @see _.forEachRight 9397 * @example 9398 * 9399 * _.forEach([1, 2], function(value) { 9400 * console.log(value); 9401 * }); 9402 * // => Logs `1` then `2`. 9403 * 9404 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 9405 * console.log(key); 9406 * }); 9407 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 9408 */ 9409 function forEach(collection, iteratee) { 9410 var func = isArray(collection) ? arrayEach : baseEach; 9411 return func(collection, getIteratee(iteratee, 3)); 9412 } 9413 9414 /** 9415 * This method is like `_.forEach` except that it iterates over elements of 9416 * `collection` from right to left. 9417 * 9418 * @static 9419 * @memberOf _ 9420 * @since 2.0.0 9421 * @alias eachRight 9422 * @category Collection 9423 * @param {Array|Object} collection The collection to iterate over. 9424 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9425 * @returns {Array|Object} Returns `collection`. 9426 * @see _.forEach 9427 * @example 9428 * 9429 * _.forEachRight([1, 2], function(value) { 9430 * console.log(value); 9431 * }); 9432 * // => Logs `2` then `1`. 9433 */ 9434 function forEachRight(collection, iteratee) { 9435 var func = isArray(collection) ? arrayEachRight : baseEachRight; 9436 return func(collection, getIteratee(iteratee, 3)); 9437 } 9438 9439 /**
vendor: 4,136 bytes, lines 9440-9547
9440 * Creates an object composed of keys generated from the results of running 9441 * each element of `collection` thru `iteratee`. The order of grouped values 9442 * is determined by the order they occur in `collection`. The corresponding 9443 * value of each key is an array of elements responsible for generating the 9444 * key. The iteratee is invoked with one argument: (value). 9445 * 9446 * @static 9447 * @memberOf _ 9448 * @since 0.1.0 9449 * @category Collection 9450 * @param {Array|Object} collection The collection to iterate over. 9451 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 9452 * @returns {Object} Returns the composed aggregate object. 9453 * @example 9454 * 9455 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 9456 * // => { '4': [4.2], '6': [6.1, 6.3] } 9457 * 9458 * // The `_.property` iteratee shorthand. 9459 * _.groupBy(['one', 'two', 'three'], 'length'); 9460 * // => { '3': ['one', 'two'], '5': ['three'] } 9461 */ 9462 var groupBy = createAggregator(function(result, value, key) { 9463 if (hasOwnProperty.call(result, key)) { 9464 result[key].push(value); 9465 } else { 9466 baseAssignValue(result, key, [value]); 9467 } 9468 }); 9469 9470 /** 9471 * Checks if `value` is in `collection`. If `collection` is a string, it's 9472 * checked for a substring of `value`, otherwise 9473 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9474 * is used for equality comparisons. If `fromIndex` is negative, it's used as 9475 * the offset from the end of `collection`. 9476 * 9477 * @static 9478 * @memberOf _ 9479 * @since 0.1.0 9480 * @category Collection 9481 * @param {Array|Object|string} collection The collection to inspect. 9482 * @param {*} value The value to search for. 9483 * @param {number} [fromIndex=0] The index to search from. 9484 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 9485 * @returns {boolean} Returns `true` if `value` is found, else `false`. 9486 * @example 9487 * 9488 * _.includes([1, 2, 3], 1); 9489 * // => true 9490 * 9491 * _.includes([1, 2, 3], 1, 2); 9492 * // => false 9493 * 9494 * _.includes({ 'a': 1, 'b': 2 }, 1); 9495 * // => true 9496 * 9497 * _.includes('abcd', 'bc'); 9498 * // => true 9499 */ 9500 function includes(collection, value, fromIndex, guard) { 9501 collection = isArrayLike(collection) ? collection : values(collection); 9502 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 9503 9504 var length = collection.length; 9505 if (fromIndex < 0) { 9506 fromIndex = nativeMax(length + fromIndex, 0); 9507 } 9508 return isString(collection) 9509 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 9510 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 9511 } 9512 9513 /** 9514 * Invokes the method at `path` of each element in `collection`, returning 9515 * an array of the results of each invoked method. Any additional arguments 9516 * are provided to each invoked method. If `path` is a function, it's invoked 9517 * for, and `this` bound to, each element in `collection`. 9518 * 9519 * @static 9520 * @memberOf _ 9521 * @since 4.0.0 9522 * @category Collection 9523 * @param {Array|Object} collection The collection to iterate over. 9524 * @param {Array|Function|string} path The path of the method to invoke or 9525 * the function invoked per iteration. 9526 * @param {...*} [args] The arguments to invoke each method with. 9527 * @returns {Array} Returns the array of results. 9528 * @example 9529 * 9530 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 9531 * // => [[1, 5, 7], [1, 2, 3]] 9532 * 9533 * _.invokeMap([123, 456], String.prototype.split, ''); 9534 * // => [['1', '2', '3'], ['4', '5', '6']] 9535 */ 9536 var invokeMap = baseRest(function(collection, path, args) { 9537 var index = -1, 9538 isFunc = typeof path == 'function', 9539 result = isArrayLike(collection) ? Array(collection.length) : []; 9540 9541 baseEach(collection, function(value) { 9542 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 9543 }); 9544 return result; 9545 }); 9546 9547 /**
vendor: 68,500 bytes, lines 9548-11662
9548 * Creates an object composed of keys generated from the results of running 9549 * each element of `collection` thru `iteratee`. The corresponding value of 9550 * each key is the last element responsible for generating the key. The 9551 * iteratee is invoked with one argument: (value). 9552 * 9553 * @static 9554 * @memberOf _ 9555 * @since 4.0.0 9556 * @category Collection 9557 * @param {Array|Object} collection The collection to iterate over. 9558 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 9559 * @returns {Object} Returns the composed aggregate object. 9560 * @example 9561 * 9562 * var array = [ 9563 * { 'dir': 'left', 'code': 97 }, 9564 * { 'dir': 'right', 'code': 100 } 9565 * ]; 9566 * 9567 * _.keyBy(array, function(o) { 9568 * return String.fromCharCode(o.code); 9569 * }); 9570 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 9571 * 9572 * _.keyBy(array, 'dir'); 9573 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 9574 */ 9575 var keyBy = createAggregator(function(result, value, key) { 9576 baseAssignValue(result, key, value); 9577 }); 9578 9579 /** 9580 * Creates an array of values by running each element in `collection` thru 9581 * `iteratee`. The iteratee is invoked with three arguments: 9582 * (value, index|key, collection). 9583 * 9584 * Many lodash methods are guarded to work as iteratees for methods like 9585 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 9586 * 9587 * The guarded methods are: 9588 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 9589 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 9590 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 9591 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 9592 * 9593 * @static 9594 * @memberOf _ 9595 * @since 0.1.0 9596 * @category Collection 9597 * @param {Array|Object} collection The collection to iterate over. 9598 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9599 * @returns {Array} Returns the new mapped array. 9600 * @example 9601 * 9602 * function square(n) { 9603 * return n * n; 9604 * } 9605 * 9606 * _.map([4, 8], square); 9607 * // => [16, 64] 9608 * 9609 * _.map({ 'a': 4, 'b': 8 }, square); 9610 * // => [16, 64] (iteration order is not guaranteed) 9611 * 9612 * var users = [ 9613 * { 'user': 'barney' }, 9614 * { 'user': 'fred' } 9615 * ]; 9616 * 9617 * // The `_.property` iteratee shorthand. 9618 * _.map(users, 'user'); 9619 * // => ['barney', 'fred'] 9620 */ 9621 function map(collection, iteratee) { 9622 var func = isArray(collection) ? arrayMap : baseMap; 9623 return func(collection, getIteratee(iteratee, 3)); 9624 } 9625 9626 /** 9627 * This method is like `_.sortBy` except that it allows specifying the sort 9628 * orders of the iteratees to sort by. If `orders` is unspecified, all values 9629 * are sorted in ascending order. Otherwise, specify an order of "desc" for 9630 * descending or "asc" for ascending sort order of corresponding values. 9631 * 9632 * @static 9633 * @memberOf _ 9634 * @since 4.0.0 9635 * @category Collection 9636 * @param {Array|Object} collection The collection to iterate over. 9637 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 9638 * The iteratees to sort by. 9639 * @param {string[]} [orders] The sort orders of `iteratees`. 9640 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 9641 * @returns {Array} Returns the new sorted array. 9642 * @example 9643 * 9644 * var users = [ 9645 * { 'user': 'fred', 'age': 48 }, 9646 * { 'user': 'barney', 'age': 34 }, 9647 * { 'user': 'fred', 'age': 40 }, 9648 * { 'user': 'barney', 'age': 36 } 9649 * ]; 9650 * 9651 * // Sort by `user` in ascending order and by `age` in descending order. 9652 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 9653 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 9654 */ 9655 function orderBy(collection, iteratees, orders, guard) { 9656 if (collection == null) { 9657 return []; 9658 } 9659 if (!isArray(iteratees)) { 9660 iteratees = iteratees == null ? [] : [iteratees]; 9661 } 9662 orders = guard ? undefined : orders; 9663 if (!isArray(orders)) { 9664 orders = orders == null ? [] : [orders]; 9665 } 9666 return baseOrderBy(collection, iteratees, orders); 9667 } 9668 9669 /** 9670 * Creates an array of elements split into two groups, the first of which 9671 * contains elements `predicate` returns truthy for, the second of which 9672 * contains elements `predicate` returns falsey for. The predicate is 9673 * invoked with one argument: (value). 9674 * 9675 * @static 9676 * @memberOf _ 9677 * @since 3.0.0 9678 * @category Collection 9679 * @param {Array|Object} collection The collection to iterate over. 9680 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9681 * @returns {Array} Returns the array of grouped elements. 9682 * @example 9683 * 9684 * var users = [ 9685 * { 'user': 'barney', 'age': 36, 'active': false }, 9686 * { 'user': 'fred', 'age': 40, 'active': true }, 9687 * { 'user': 'pebbles', 'age': 1, 'active': false } 9688 * ]; 9689 * 9690 * _.partition(users, function(o) { return o.active; }); 9691 * // => objects for [['fred'], ['barney', 'pebbles']] 9692 * 9693 * // The `_.matches` iteratee shorthand. 9694 * _.partition(users, { 'age': 1, 'active': false }); 9695 * // => objects for [['pebbles'], ['barney', 'fred']] 9696 * 9697 * // The `_.matchesProperty` iteratee shorthand. 9698 * _.partition(users, ['active', false]); 9699 * // => objects for [['barney', 'pebbles'], ['fred']] 9700 * 9701 * // The `_.property` iteratee shorthand. 9702 * _.partition(users, 'active'); 9703 * // => objects for [['fred'], ['barney', 'pebbles']] 9704 */ 9705 var partition = createAggregator(function(result, value, key) { 9706 result[key ? 0 : 1].push(value); 9707 }, function() { return [[], []]; }); 9708 9709 /** 9710 * Reduces `collection` to a value which is the accumulated result of running 9711 * each element in `collection` thru `iteratee`, where each successive 9712 * invocation is supplied the return value of the previous. If `accumulator` 9713 * is not given, the first element of `collection` is used as the initial 9714 * value. The iteratee is invoked with four arguments: 9715 * (accumulator, value, index|key, collection). 9716 * 9717 * Many lodash methods are guarded to work as iteratees for methods like 9718 * `_.reduce`, `_.reduceRight`, and `_.transform`. 9719 * 9720 * The guarded methods are: 9721 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 9722 * and `sortBy` 9723 * 9724 * @static 9725 * @memberOf _ 9726 * @since 0.1.0 9727 * @category Collection 9728 * @param {Array|Object} collection The collection to iterate over. 9729 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9730 * @param {*} [accumulator] The initial value. 9731 * @returns {*} Returns the accumulated value. 9732 * @see _.reduceRight 9733 * @example 9734 * 9735 * _.reduce([1, 2], function(sum, n) { 9736 * return sum + n; 9737 * }, 0); 9738 * // => 3 9739 * 9740 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 9741 * (result[value] || (result[value] = [])).push(key); 9742 * return result; 9743 * }, {}); 9744 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 9745 */ 9746 function reduce(collection, iteratee, accumulator) { 9747 var func = isArray(collection) ? arrayReduce : baseReduce, 9748 initAccum = arguments.length < 3; 9749 9750 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 9751 } 9752 9753 /** 9754 * This method is like `_.reduce` except that it iterates over elements of 9755 * `collection` from right to left. 9756 * 9757 * @static 9758 * @memberOf _ 9759 * @since 0.1.0 9760 * @category Collection 9761 * @param {Array|Object} collection The collection to iterate over. 9762 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9763 * @param {*} [accumulator] The initial value. 9764 * @returns {*} Returns the accumulated value. 9765 * @see _.reduce 9766 * @example 9767 * 9768 * var array = [[0, 1], [2, 3], [4, 5]]; 9769 * 9770 * _.reduceRight(array, function(flattened, other) { 9771 * return flattened.concat(other); 9772 * }, []); 9773 * // => [4, 5, 2, 3, 0, 1] 9774 */ 9775 function reduceRight(collection, iteratee, accumulator) { 9776 var func = isArray(collection) ? arrayReduceRight : baseReduce, 9777 initAccum = arguments.length < 3; 9778 9779 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 9780 } 9781 9782 /** 9783 * The opposite of `_.filter`; this method returns the elements of `collection` 9784 * that `predicate` does **not** return truthy for. 9785 * 9786 * @static 9787 * @memberOf _ 9788 * @since 0.1.0 9789 * @category Collection 9790 * @param {Array|Object} collection The collection to iterate over. 9791 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9792 * @returns {Array} Returns the new filtered array. 9793 * @see _.filter 9794 * @example 9795 * 9796 * var users = [ 9797 * { 'user': 'barney', 'age': 36, 'active': false }, 9798 * { 'user': 'fred', 'age': 40, 'active': true } 9799 * ]; 9800 * 9801 * _.reject(users, function(o) { return !o.active; }); 9802 * // => objects for ['fred'] 9803 * 9804 * // The `_.matches` iteratee shorthand. 9805 * _.reject(users, { 'age': 40, 'active': true }); 9806 * // => objects for ['barney'] 9807 * 9808 * // The `_.matchesProperty` iteratee shorthand. 9809 * _.reject(users, ['active', false]); 9810 * // => objects for ['fred'] 9811 * 9812 * // The `_.property` iteratee shorthand. 9813 * _.reject(users, 'active'); 9814 * // => objects for ['barney'] 9815 */ 9816 function reject(collection, predicate) { 9817 var func = isArray(collection) ? arrayFilter : baseFilter; 9818 return func(collection, negate(getIteratee(predicate, 3))); 9819 } 9820 9821 /** 9822 * Gets a random element from `collection`. 9823 * 9824 * @static 9825 * @memberOf _ 9826 * @since 2.0.0 9827 * @category Collection 9828 * @param {Array|Object} collection The collection to sample. 9829 * @returns {*} Returns the random element. 9830 * @example 9831 * 9832 * _.sample([1, 2, 3, 4]); 9833 * // => 2 9834 */ 9835 function sample(collection) { 9836 var func = isArray(collection) ? arraySample : baseSample; 9837 return func(collection); 9838 } 9839 9840 /** 9841 * Gets `n` random elements at unique keys from `collection` up to the 9842 * size of `collection`. 9843 * 9844 * @static 9845 * @memberOf _ 9846 * @since 4.0.0 9847 * @category Collection 9848 * @param {Array|Object} collection The collection to sample. 9849 * @param {number} [n=1] The number of elements to sample. 9850 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9851 * @returns {Array} Returns the random elements. 9852 * @example 9853 * 9854 * _.sampleSize([1, 2, 3], 2); 9855 * // => [3, 1] 9856 * 9857 * _.sampleSize([1, 2, 3], 4); 9858 * // => [2, 3, 1] 9859 */ 9860 function sampleSize(collection, n, guard) { 9861 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 9862 n = 1; 9863 } else { 9864 n = toInteger(n); 9865 } 9866 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 9867 return func(collection, n); 9868 } 9869 9870 /** 9871 * Creates an array of shuffled values, using a version of the 9872 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 9873 * 9874 * @static 9875 * @memberOf _ 9876 * @since 0.1.0 9877 * @category Collection 9878 * @param {Array|Object} collection The collection to shuffle. 9879 * @returns {Array} Returns the new shuffled array. 9880 * @example 9881 * 9882 * _.shuffle([1, 2, 3, 4]); 9883 * // => [4, 1, 3, 2] 9884 */ 9885 function shuffle(collection) { 9886 var func = isArray(collection) ? arrayShuffle : baseShuffle; 9887 return func(collection); 9888 } 9889 9890 /** 9891 * Gets the size of `collection` by returning its length for array-like 9892 * values or the number of own enumerable string keyed properties for objects. 9893 * 9894 * @static 9895 * @memberOf _ 9896 * @since 0.1.0 9897 * @category Collection 9898 * @param {Array|Object|string} collection The collection to inspect. 9899 * @returns {number} Returns the collection size. 9900 * @example 9901 * 9902 * _.size([1, 2, 3]); 9903 * // => 3 9904 * 9905 * _.size({ 'a': 1, 'b': 2 }); 9906 * // => 2 9907 * 9908 * _.size('pebbles'); 9909 * // => 7 9910 */ 9911 function size(collection) { 9912 if (collection == null) { 9913 return 0; 9914 } 9915 if (isArrayLike(collection)) { 9916 return isString(collection) ? stringSize(collection) : collection.length; 9917 } 9918 var tag = getTag(collection); 9919 if (tag == mapTag || tag == setTag) { 9920 return collection.size; 9921 } 9922 return baseKeys(collection).length; 9923 } 9924 9925 /** 9926 * Checks if `predicate` returns truthy for **any** element of `collection`. 9927 * Iteration is stopped once `predicate` returns truthy. The predicate is 9928 * invoked with three arguments: (value, index|key, collection). 9929 * 9930 * @static 9931 * @memberOf _ 9932 * @since 0.1.0 9933 * @category Collection 9934 * @param {Array|Object} collection The collection to iterate over. 9935 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9936 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9937 * @returns {boolean} Returns `true` if any element passes the predicate check, 9938 * else `false`. 9939 * @example 9940 * 9941 * _.some([null, 0, 'yes', false], Boolean); 9942 * // => true 9943 * 9944 * var users = [ 9945 * { 'user': 'barney', 'active': true }, 9946 * { 'user': 'fred', 'active': false } 9947 * ]; 9948 * 9949 * // The `_.matches` iteratee shorthand. 9950 * _.some(users, { 'user': 'barney', 'active': false }); 9951 * // => false 9952 * 9953 * // The `_.matchesProperty` iteratee shorthand. 9954 * _.some(users, ['active', false]); 9955 * // => true 9956 * 9957 * // The `_.property` iteratee shorthand. 9958 * _.some(users, 'active'); 9959 * // => true 9960 */ 9961 function some(collection, predicate, guard) { 9962 var func = isArray(collection) ? arraySome : baseSome; 9963 if (guard && isIterateeCall(collection, predicate, guard)) { 9964 predicate = undefined; 9965 } 9966 return func(collection, getIteratee(predicate, 3)); 9967 } 9968 9969 /** 9970 * Creates an array of elements, sorted in ascending order by the results of 9971 * running each element in a collection thru each iteratee. This method 9972 * performs a stable sort, that is, it preserves the original sort order of 9973 * equal elements. The iteratees are invoked with one argument: (value). 9974 * 9975 * @static 9976 * @memberOf _ 9977 * @since 0.1.0 9978 * @category Collection 9979 * @param {Array|Object} collection The collection to iterate over. 9980 * @param {...(Function|Function[])} [iteratees=[_.identity]] 9981 * The iteratees to sort by. 9982 * @returns {Array} Returns the new sorted array. 9983 * @example 9984 * 9985 * var users = [ 9986 * { 'user': 'fred', 'age': 48 }, 9987 * { 'user': 'barney', 'age': 36 }, 9988 * { 'user': 'fred', 'age': 30 }, 9989 * { 'user': 'barney', 'age': 34 } 9990 * ]; 9991 * 9992 * _.sortBy(users, [function(o) { return o.user; }]); 9993 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 9994 * 9995 * _.sortBy(users, ['user', 'age']); 9996 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 9997 */ 9998 var sortBy = baseRest(function(collection, iteratees) { 9999 if (collection == null) { 10000 return []; 10001 } 10002 var length = iteratees.length; 10003 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 10004 iteratees = []; 10005 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 10006 iteratees = [iteratees[0]]; 10007 } 10008 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 10009 }); 10010 10011 /*------------------------------------------------------------------------*/ 10012 10013 /** 10014 * Gets the timestamp of the number of milliseconds that have elapsed since 10015 * the Unix epoch (1 January 1970 00:00:00 UTC). 10016 * 10017 * @static 10018 * @memberOf _ 10019 * @since 2.4.0 10020 * @category Date 10021 * @returns {number} Returns the timestamp. 10022 * @example 10023 * 10024 * _.defer(function(stamp) { 10025 * console.log(_.now() - stamp); 10026 * }, _.now()); 10027 * // => Logs the number of milliseconds it took for the deferred invocation. 10028 */ 10029 var now = ctxNow || function() { 10030 return root.Date.now(); 10031 }; 10032 10033 /*------------------------------------------------------------------------*/ 10034 10035 /** 10036 * The opposite of `_.before`; this method creates a function that invokes 10037 * `func` once it's called `n` or more times. 10038 * 10039 * @static 10040 * @memberOf _ 10041 * @since 0.1.0 10042 * @category Function 10043 * @param {number} n The number of calls before `func` is invoked. 10044 * @param {Function} func The function to restrict. 10045 * @returns {Function} Returns the new restricted function. 10046 * @example 10047 * 10048 * var saves = ['profile', 'settings']; 10049 * 10050 * var done = _.after(saves.length, function() { 10051 * console.log('done saving!'); 10052 * }); 10053 * 10054 * _.forEach(saves, function(type) { 10055 * asyncSave({ 'type': type, 'complete': done }); 10056 * }); 10057 * // => Logs 'done saving!' after the two async saves have completed. 10058 */ 10059 function after(n, func) { 10060 if (typeof func != 'function') { 10061 throw new TypeError(FUNC_ERROR_TEXT); 10062 } 10063 n = toInteger(n); 10064 return function() { 10065 if (--n < 1) { 10066 return func.apply(this, arguments); 10067 } 10068 }; 10069 } 10070 10071 /** 10072 * Creates a function that invokes `func`, with up to `n` arguments, 10073 * ignoring any additional arguments. 10074 * 10075 * @static 10076 * @memberOf _ 10077 * @since 3.0.0 10078 * @category Function 10079 * @param {Function} func The function to cap arguments for. 10080 * @param {number} [n=func.length] The arity cap. 10081 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10082 * @returns {Function} Returns the new capped function. 10083 * @example 10084 * 10085 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 10086 * // => [6, 8, 10] 10087 */ 10088 function ary(func, n, guard) { 10089 n = guard ? undefined : n; 10090 n = (func && n == null) ? func.length : n; 10091 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 10092 } 10093 10094 /** 10095 * Creates a function that invokes `func`, with the `this` binding and arguments 10096 * of the created function, while it's called less than `n` times. Subsequent 10097 * calls to the created function return the result of the last `func` invocation. 10098 * 10099 * @static 10100 * @memberOf _ 10101 * @since 3.0.0 10102 * @category Function 10103 * @param {number} n The number of calls at which `func` is no longer invoked. 10104 * @param {Function} func The function to restrict. 10105 * @returns {Function} Returns the new restricted function. 10106 * @example 10107 * 10108 * jQuery(element).on('click', _.before(5, addContactToList)); 10109 * // => Allows adding up to 4 contacts to the list. 10110 */ 10111 function before(n, func) { 10112 var result; 10113 if (typeof func != 'function') { 10114 throw new TypeError(FUNC_ERROR_TEXT); 10115 } 10116 n = toInteger(n); 10117 return function() { 10118 if (--n > 0) { 10119 result = func.apply(this, arguments); 10120 } 10121 if (n <= 1) { 10122 func = undefined; 10123 } 10124 return result; 10125 }; 10126 } 10127 10128 /** 10129 * Creates a function that invokes `func` with the `this` binding of `thisArg` 10130 * and `partials` prepended to the arguments it receives. 10131 * 10132 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 10133 * may be used as a placeholder for partially applied arguments. 10134 * 10135 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 10136 * property of bound functions. 10137 * 10138 * @static 10139 * @memberOf _ 10140 * @since 0.1.0 10141 * @category Function 10142 * @param {Function} func The function to bind. 10143 * @param {*} thisArg The `this` binding of `func`. 10144 * @param {...*} [partials] The arguments to be partially applied. 10145 * @returns {Function} Returns the new bound function. 10146 * @example 10147 * 10148 * function greet(greeting, punctuation) { 10149 * return greeting + ' ' + this.user + punctuation; 10150 * } 10151 * 10152 * var object = { 'user': 'fred' }; 10153 * 10154 * var bound = _.bind(greet, object, 'hi'); 10155 * bound('!'); 10156 * // => 'hi fred!' 10157 * 10158 * // Bound with placeholders. 10159 * var bound = _.bind(greet, object, _, '!'); 10160 * bound('hi'); 10161 * // => 'hi fred!' 10162 */ 10163 var bind = baseRest(function(func, thisArg, partials) { 10164 var bitmask = WRAP_BIND_FLAG; 10165 if (partials.length) { 10166 var holders = replaceHolders(partials, getHolder(bind)); 10167 bitmask |= WRAP_PARTIAL_FLAG; 10168 } 10169 return createWrap(func, bitmask, thisArg, partials, holders); 10170 }); 10171 10172 /** 10173 * Creates a function that invokes the method at `object[key]` with `partials` 10174 * prepended to the arguments it receives. 10175 * 10176 * This method differs from `_.bind` by allowing bound functions to reference 10177 * methods that may be redefined or don't yet exist. See 10178 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 10179 * for more details. 10180 * 10181 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 10182 * builds, may be used as a placeholder for partially applied arguments. 10183 * 10184 * @static 10185 * @memberOf _ 10186 * @since 0.10.0 10187 * @category Function 10188 * @param {Object} object The object to invoke the method on. 10189 * @param {string} key The key of the method. 10190 * @param {...*} [partials] The arguments to be partially applied. 10191 * @returns {Function} Returns the new bound function. 10192 * @example 10193 * 10194 * var object = { 10195 * 'user': 'fred', 10196 * 'greet': function(greeting, punctuation) { 10197 * return greeting + ' ' + this.user + punctuation; 10198 * } 10199 * }; 10200 * 10201 * var bound = _.bindKey(object, 'greet', 'hi'); 10202 * bound('!'); 10203 * // => 'hi fred!' 10204 * 10205 * object.greet = function(greeting, punctuation) { 10206 * return greeting + 'ya ' + this.user + punctuation; 10207 * }; 10208 * 10209 * bound('!'); 10210 * // => 'hiya fred!' 10211 * 10212 * // Bound with placeholders. 10213 * var bound = _.bindKey(object, 'greet', _, '!'); 10214 * bound('hi'); 10215 * // => 'hiya fred!' 10216 */ 10217 var bindKey = baseRest(function(object, key, partials) { 10218 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 10219 if (partials.length) { 10220 var holders = replaceHolders(partials, getHolder(bindKey)); 10221 bitmask |= WRAP_PARTIAL_FLAG; 10222 } 10223 return createWrap(key, bitmask, object, partials, holders); 10224 }); 10225 10226 /** 10227 * Creates a function that accepts arguments of `func` and either invokes 10228 * `func` returning its result, if at least `arity` number of arguments have 10229 * been provided, or returns a function that accepts the remaining `func` 10230 * arguments, and so on. The arity of `func` may be specified if `func.length` 10231 * is not sufficient. 10232 * 10233 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 10234 * may be used as a placeholder for provided arguments. 10235 * 10236 * **Note:** This method doesn't set the "length" property of curried functions. 10237 * 10238 * @static 10239 * @memberOf _ 10240 * @since 2.0.0 10241 * @category Function 10242 * @param {Function} func The function to curry. 10243 * @param {number} [arity=func.length] The arity of `func`. 10244 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10245 * @returns {Function} Returns the new curried function. 10246 * @example 10247 * 10248 * var abc = function(a, b, c) { 10249 * return [a, b, c]; 10250 * }; 10251 * 10252 * var curried = _.curry(abc); 10253 * 10254 * curried(1)(2)(3); 10255 * // => [1, 2, 3] 10256 * 10257 * curried(1, 2)(3); 10258 * // => [1, 2, 3] 10259 * 10260 * curried(1, 2, 3); 10261 * // => [1, 2, 3] 10262 * 10263 * // Curried with placeholders. 10264 * curried(1)(_, 3)(2); 10265 * // => [1, 2, 3] 10266 */ 10267 function curry(func, arity, guard) { 10268 arity = guard ? undefined : arity; 10269 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 10270 result.placeholder = curry.placeholder; 10271 return result; 10272 } 10273 10274 /** 10275 * This method is like `_.curry` except that arguments are applied to `func` 10276 * in the manner of `_.partialRight` instead of `_.partial`. 10277 * 10278 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 10279 * builds, may be used as a placeholder for provided arguments. 10280 * 10281 * **Note:** This method doesn't set the "length" property of curried functions. 10282 * 10283 * @static 10284 * @memberOf _ 10285 * @since 3.0.0 10286 * @category Function 10287 * @param {Function} func The function to curry. 10288 * @param {number} [arity=func.length] The arity of `func`. 10289 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10290 * @returns {Function} Returns the new curried function. 10291 * @example 10292 * 10293 * var abc = function(a, b, c) { 10294 * return [a, b, c]; 10295 * }; 10296 * 10297 * var curried = _.curryRight(abc); 10298 * 10299 * curried(3)(2)(1); 10300 * // => [1, 2, 3] 10301 * 10302 * curried(2, 3)(1); 10303 * // => [1, 2, 3] 10304 * 10305 * curried(1, 2, 3); 10306 * // => [1, 2, 3] 10307 * 10308 * // Curried with placeholders. 10309 * curried(3)(1, _)(2); 10310 * // => [1, 2, 3] 10311 */ 10312 function curryRight(func, arity, guard) { 10313 arity = guard ? undefined : arity; 10314 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 10315 result.placeholder = curryRight.placeholder; 10316 return result; 10317 } 10318 10319 /** 10320 * Creates a debounced function that delays invoking `func` until after `wait` 10321 * milliseconds have elapsed since the last time the debounced function was 10322 * invoked. The debounced function comes with a `cancel` method to cancel 10323 * delayed `func` invocations and a `flush` method to immediately invoke them. 10324 * Provide `options` to indicate whether `func` should be invoked on the 10325 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 10326 * with the last arguments provided to the debounced function. Subsequent 10327 * calls to the debounced function return the result of the last `func` 10328 * invocation. 10329 * 10330 * **Note:** If `leading` and `trailing` options are `true`, `func` is 10331 * invoked on the trailing edge of the timeout only if the debounced function 10332 * is invoked more than once during the `wait` timeout. 10333 * 10334 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 10335 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 10336 * 10337 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 10338 * for details over the differences between `_.debounce` and `_.throttle`. 10339 * 10340 * @static 10341 * @memberOf _ 10342 * @since 0.1.0 10343 * @category Function 10344 * @param {Function} func The function to debounce. 10345 * @param {number} [wait=0] The number of milliseconds to delay. 10346 * @param {Object} [options={}] The options object. 10347 * @param {boolean} [options.leading=false] 10348 * Specify invoking on the leading edge of the timeout. 10349 * @param {number} [options.maxWait] 10350 * The maximum time `func` is allowed to be delayed before it's invoked. 10351 * @param {boolean} [options.trailing=true] 10352 * Specify invoking on the trailing edge of the timeout. 10353 * @returns {Function} Returns the new debounced function. 10354 * @example 10355 * 10356 * // Avoid costly calculations while the window size is in flux. 10357 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 10358 * 10359 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 10360 * jQuery(element).on('click', _.debounce(sendMail, 300, { 10361 * 'leading': true, 10362 * 'trailing': false 10363 * })); 10364 * 10365 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 10366 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 10367 * var source = new EventSource('/stream'); 10368 * jQuery(source).on('message', debounced); 10369 * 10370 * // Cancel the trailing debounced invocation. 10371 * jQuery(window).on('popstate', debounced.cancel); 10372 */ 10373 function debounce(func, wait, options) { 10374 var lastArgs, 10375 lastThis, 10376 maxWait, 10377 result, 10378 timerId, 10379 lastCallTime, 10380 lastInvokeTime = 0, 10381 leading = false, 10382 maxing = false, 10383 trailing = true; 10384 10385 if (typeof func != 'function') { 10386 throw new TypeError(FUNC_ERROR_TEXT); 10387 } 10388 wait = toNumber(wait) || 0; 10389 if (isObject(options)) { 10390 leading = !!options.leading; 10391 maxing = 'maxWait' in options; 10392 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 10393 trailing = 'trailing' in options ? !!options.trailing : trailing; 10394 } 10395 10396 function invokeFunc(time) { 10397 var args = lastArgs, 10398 thisArg = lastThis; 10399 10400 lastArgs = lastThis = undefined; 10401 lastInvokeTime = time; 10402 result = func.apply(thisArg, args); 10403 return result; 10404 } 10405 10406 function leadingEdge(time) { 10407 // Reset any `maxWait` timer. 10408 lastInvokeTime = time; 10409 // Start the timer for the trailing edge. 10410 timerId = setTimeout(timerExpired, wait); 10411 // Invoke the leading edge. 10412 return leading ? invokeFunc(time) : result; 10413 } 10414 10415 function remainingWait(time) { 10416 var timeSinceLastCall = time - lastCallTime, 10417 timeSinceLastInvoke = time - lastInvokeTime, 10418 timeWaiting = wait - timeSinceLastCall; 10419 10420 return maxing 10421 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 10422 : timeWaiting; 10423 } 10424 10425 function shouldInvoke(time) { 10426 var timeSinceLastCall = time - lastCallTime, 10427 timeSinceLastInvoke = time - lastInvokeTime; 10428 10429 // Either this is the first call, activity has stopped and we're at the 10430 // trailing edge, the system time has gone backwards and we're treating 10431 // it as the trailing edge, or we've hit the `maxWait` limit. 10432 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 10433 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 10434 } 10435 10436 function timerExpired() { 10437 var time = now(); 10438 if (shouldInvoke(time)) { 10439 return trailingEdge(time); 10440 } 10441 // Restart the timer. 10442 timerId = setTimeout(timerExpired, remainingWait(time)); 10443 } 10444 10445 function trailingEdge(time) { 10446 timerId = undefined; 10447 10448 // Only invoke if we have `lastArgs` which means `func` has been 10449 // debounced at least once. 10450 if (trailing && lastArgs) { 10451 return invokeFunc(time); 10452 } 10453 lastArgs = lastThis = undefined; 10454 return result; 10455 } 10456 10457 function cancel() { 10458 if (timerId !== undefined) { 10459 clearTimeout(timerId); 10460 } 10461 lastInvokeTime = 0; 10462 lastArgs = lastCallTime = lastThis = timerId = undefined; 10463 } 10464 10465 function flush() { 10466 return timerId === undefined ? result : trailingEdge(now()); 10467 } 10468 10469 function debounced() { 10470 var time = now(), 10471 isInvoking = shouldInvoke(time); 10472 10473 lastArgs = arguments; 10474 lastThis = this; 10475 lastCallTime = time; 10476 10477 if (isInvoking) { 10478 if (timerId === undefined) { 10479 return leadingEdge(lastCallTime); 10480 } 10481 if (maxing) { 10482 // Handle invocations in a tight loop. 10483 clearTimeout(timerId); 10484 timerId = setTimeout(timerExpired, wait); 10485 return invokeFunc(lastCallTime); 10486 } 10487 } 10488 if (timerId === undefined) { 10489 timerId = setTimeout(timerExpired, wait); 10490 } 10491 return result; 10492 } 10493 debounced.cancel = cancel; 10494 debounced.flush = flush; 10495 return debounced; 10496 } 10497 10498 /** 10499 * Defers invoking the `func` until the current call stack has cleared. Any 10500 * additional arguments are provided to `func` when it's invoked. 10501 * 10502 * @static 10503 * @memberOf _ 10504 * @since 0.1.0 10505 * @category Function 10506 * @param {Function} func The function to defer. 10507 * @param {...*} [args] The arguments to invoke `func` with. 10508 * @returns {number} Returns the timer id. 10509 * @example 10510 * 10511 * _.defer(function(text) { 10512 * console.log(text); 10513 * }, 'deferred'); 10514 * // => Logs 'deferred' after one millisecond. 10515 */ 10516 var defer = baseRest(function(func, args) { 10517 return baseDelay(func, 1, args); 10518 }); 10519 10520 /** 10521 * Invokes `func` after `wait` milliseconds. Any additional arguments are 10522 * provided to `func` when it's invoked. 10523 * 10524 * @static 10525 * @memberOf _ 10526 * @since 0.1.0 10527 * @category Function 10528 * @param {Function} func The function to delay. 10529 * @param {number} wait The number of milliseconds to delay invocation. 10530 * @param {...*} [args] The arguments to invoke `func` with. 10531 * @returns {number} Returns the timer id. 10532 * @example 10533 * 10534 * _.delay(function(text) { 10535 * console.log(text); 10536 * }, 1000, 'later'); 10537 * // => Logs 'later' after one second. 10538 */ 10539 var delay = baseRest(function(func, wait, args) { 10540 return baseDelay(func, toNumber(wait) || 0, args); 10541 }); 10542 10543 /** 10544 * Creates a function that invokes `func` with arguments reversed. 10545 * 10546 * @static 10547 * @memberOf _ 10548 * @since 4.0.0 10549 * @category Function 10550 * @param {Function} func The function to flip arguments for. 10551 * @returns {Function} Returns the new flipped function. 10552 * @example 10553 * 10554 * var flipped = _.flip(function() { 10555 * return _.toArray(arguments); 10556 * }); 10557 * 10558 * flipped('a', 'b', 'c', 'd'); 10559 * // => ['d', 'c', 'b', 'a'] 10560 */ 10561 function flip(func) { 10562 return createWrap(func, WRAP_FLIP_FLAG); 10563 } 10564 10565 /** 10566 * Creates a function that memoizes the result of `func`. If `resolver` is 10567 * provided, it determines the cache key for storing the result based on the 10568 * arguments provided to the memoized function. By default, the first argument 10569 * provided to the memoized function is used as the map cache key. The `func` 10570 * is invoked with the `this` binding of the memoized function. 10571 * 10572 * **Note:** The cache is exposed as the `cache` property on the memoized 10573 * function. Its creation may be customized by replacing the `_.memoize.Cache` 10574 * constructor with one whose instances implement the 10575 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 10576 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 10577 * 10578 * @static 10579 * @memberOf _ 10580 * @since 0.1.0 10581 * @category Function 10582 * @param {Function} func The function to have its output memoized. 10583 * @param {Function} [resolver] The function to resolve the cache key. 10584 * @returns {Function} Returns the new memoized function. 10585 * @example 10586 * 10587 * var object = { 'a': 1, 'b': 2 }; 10588 * var other = { 'c': 3, 'd': 4 }; 10589 * 10590 * var values = _.memoize(_.values); 10591 * values(object); 10592 * // => [1, 2] 10593 * 10594 * values(other); 10595 * // => [3, 4] 10596 * 10597 * object.a = 2; 10598 * values(object); 10599 * // => [1, 2] 10600 * 10601 * // Modify the result cache. 10602 * values.cache.set(object, ['a', 'b']); 10603 * values(object); 10604 * // => ['a', 'b'] 10605 * 10606 * // Replace `_.memoize.Cache`. 10607 * _.memoize.Cache = WeakMap; 10608 */ 10609 function memoize(func, resolver) { 10610 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 10611 throw new TypeError(FUNC_ERROR_TEXT); 10612 } 10613 var memoized = function() { 10614 var args = arguments, 10615 key = resolver ? resolver.apply(this, args) : args[0], 10616 cache = memoized.cache; 10617 10618 if (cache.has(key)) { 10619 return cache.get(key); 10620 } 10621 var result = func.apply(this, args); 10622 memoized.cache = cache.set(key, result) || cache; 10623 return result; 10624 }; 10625 memoized.cache = new (memoize.Cache || MapCache); 10626 return memoized; 10627 } 10628 10629 // Expose `MapCache`. 10630 memoize.Cache = MapCache; 10631 10632 /** 10633 * Creates a function that negates the result of the predicate `func`. The 10634 * `func` predicate is invoked with the `this` binding and arguments of the 10635 * created function. 10636 * 10637 * @static 10638 * @memberOf _ 10639 * @since 3.0.0 10640 * @category Function 10641 * @param {Function} predicate The predicate to negate. 10642 * @returns {Function} Returns the new negated function. 10643 * @example 10644 * 10645 * function isEven(n) { 10646 * return n % 2 == 0; 10647 * } 10648 * 10649 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 10650 * // => [1, 3, 5] 10651 */ 10652 function negate(predicate) { 10653 if (typeof predicate != 'function') { 10654 throw new TypeError(FUNC_ERROR_TEXT); 10655 } 10656 return function() { 10657 var args = arguments; 10658 switch (args.length) { 10659 case 0: return !predicate.call(this); 10660 case 1: return !predicate.call(this, args[0]); 10661 case 2: return !predicate.call(this, args[0], args[1]); 10662 case 3: return !predicate.call(this, args[0], args[1], args[2]); 10663 } 10664 return !predicate.apply(this, args); 10665 }; 10666 } 10667 10668 /** 10669 * Creates a function that is restricted to invoking `func` once. Repeat calls 10670 * to the function return the value of the first invocation. The `func` is 10671 * invoked with the `this` binding and arguments of the created function. 10672 * 10673 * @static 10674 * @memberOf _ 10675 * @since 0.1.0 10676 * @category Function 10677 * @param {Function} func The function to restrict. 10678 * @returns {Function} Returns the new restricted function. 10679 * @example 10680 * 10681 * var initialize = _.once(createApplication); 10682 * initialize(); 10683 * initialize(); 10684 * // => `createApplication` is invoked once 10685 */ 10686 function once(func) { 10687 return before(2, func); 10688 } 10689 10690 /** 10691 * Creates a function that invokes `func` with its arguments transformed. 10692 * 10693 * @static 10694 * @since 4.0.0 10695 * @memberOf _ 10696 * @category Function 10697 * @param {Function} func The function to wrap. 10698 * @param {...(Function|Function[])} [transforms=[_.identity]] 10699 * The argument transforms. 10700 * @returns {Function} Returns the new function. 10701 * @example 10702 * 10703 * function doubled(n) { 10704 * return n * 2; 10705 * } 10706 * 10707 * function square(n) { 10708 * return n * n; 10709 * } 10710 * 10711 * var func = _.overArgs(function(x, y) { 10712 * return [x, y]; 10713 * }, [square, doubled]); 10714 * 10715 * func(9, 3); 10716 * // => [81, 6] 10717 * 10718 * func(10, 5); 10719 * // => [100, 10] 10720 */ 10721 var overArgs = castRest(function(func, transforms) { 10722 transforms = (transforms.length == 1 && isArray(transforms[0])) 10723 ? arrayMap(transforms[0], baseUnary(getIteratee())) 10724 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 10725 10726 var funcsLength = transforms.length; 10727 return baseRest(function(args) { 10728 var index = -1, 10729 length = nativeMin(args.length, funcsLength); 10730 10731 while (++index < length) { 10732 args[index] = transforms[index].call(this, args[index]); 10733 } 10734 return apply(func, this, args); 10735 }); 10736 }); 10737 10738 /** 10739 * Creates a function that invokes `func` with `partials` prepended to the 10740 * arguments it receives. This method is like `_.bind` except it does **not** 10741 * alter the `this` binding. 10742 * 10743 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 10744 * builds, may be used as a placeholder for partially applied arguments. 10745 * 10746 * **Note:** This method doesn't set the "length" property of partially 10747 * applied functions. 10748 * 10749 * @static 10750 * @memberOf _ 10751 * @since 0.2.0 10752 * @category Function 10753 * @param {Function} func The function to partially apply arguments to. 10754 * @param {...*} [partials] The arguments to be partially applied. 10755 * @returns {Function} Returns the new partially applied function. 10756 * @example 10757 * 10758 * function greet(greeting, name) { 10759 * return greeting + ' ' + name; 10760 * } 10761 * 10762 * var sayHelloTo = _.partial(greet, 'hello'); 10763 * sayHelloTo('fred'); 10764 * // => 'hello fred' 10765 * 10766 * // Partially applied with placeholders. 10767 * var greetFred = _.partial(greet, _, 'fred'); 10768 * greetFred('hi'); 10769 * // => 'hi fred' 10770 */ 10771 var partial = baseRest(function(func, partials) { 10772 var holders = replaceHolders(partials, getHolder(partial)); 10773 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 10774 }); 10775 10776 /** 10777 * This method is like `_.partial` except that partially applied arguments 10778 * are appended to the arguments it receives. 10779 * 10780 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 10781 * builds, may be used as a placeholder for partially applied arguments. 10782 * 10783 * **Note:** This method doesn't set the "length" property of partially 10784 * applied functions. 10785 * 10786 * @static 10787 * @memberOf _ 10788 * @since 1.0.0 10789 * @category Function 10790 * @param {Function} func The function to partially apply arguments to. 10791 * @param {...*} [partials] The arguments to be partially applied. 10792 * @returns {Function} Returns the new partially applied function. 10793 * @example 10794 * 10795 * function greet(greeting, name) { 10796 * return greeting + ' ' + name; 10797 * } 10798 * 10799 * var greetFred = _.partialRight(greet, 'fred'); 10800 * greetFred('hi'); 10801 * // => 'hi fred' 10802 * 10803 * // Partially applied with placeholders. 10804 * var sayHelloTo = _.partialRight(greet, 'hello', _); 10805 * sayHelloTo('fred'); 10806 * // => 'hello fred' 10807 */ 10808 var partialRight = baseRest(function(func, partials) { 10809 var holders = replaceHolders(partials, getHolder(partialRight)); 10810 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 10811 }); 10812 10813 /** 10814 * Creates a function that invokes `func` with arguments arranged according 10815 * to the specified `indexes` where the argument value at the first index is 10816 * provided as the first argument, the argument value at the second index is 10817 * provided as the second argument, and so on. 10818 * 10819 * @static 10820 * @memberOf _ 10821 * @since 3.0.0 10822 * @category Function 10823 * @param {Function} func The function to rearrange arguments for. 10824 * @param {...(number|number[])} indexes The arranged argument indexes. 10825 * @returns {Function} Returns the new function. 10826 * @example 10827 * 10828 * var rearged = _.rearg(function(a, b, c) { 10829 * return [a, b, c]; 10830 * }, [2, 0, 1]); 10831 * 10832 * rearged('b', 'c', 'a') 10833 * // => ['a', 'b', 'c'] 10834 */ 10835 var rearg = flatRest(function(func, indexes) { 10836 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 10837 }); 10838 10839 /** 10840 * Creates a function that invokes `func` with the `this` binding of the 10841 * created function and arguments from `start` and beyond provided as 10842 * an array. 10843 * 10844 * **Note:** This method is based on the 10845 * [rest parameter](https://mdn.io/rest_parameters). 10846 * 10847 * @static 10848 * @memberOf _ 10849 * @since 4.0.0 10850 * @category Function 10851 * @param {Function} func The function to apply a rest parameter to. 10852 * @param {number} [start=func.length-1] The start position of the rest parameter. 10853 * @returns {Function} Returns the new function. 10854 * @example 10855 * 10856 * var say = _.rest(function(what, names) { 10857 * return what + ' ' + _.initial(names).join(', ') + 10858 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 10859 * }); 10860 * 10861 * say('hello', 'fred', 'barney', 'pebbles'); 10862 * // => 'hello fred, barney, & pebbles' 10863 */ 10864 function rest(func, start) { 10865 if (typeof func != 'function') { 10866 throw new TypeError(FUNC_ERROR_TEXT); 10867 } 10868 start = start === undefined ? start : toInteger(start); 10869 return baseRest(func, start); 10870 } 10871 10872 /** 10873 * Creates a function that invokes `func` with the `this` binding of the 10874 * create function and an array of arguments much like 10875 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 10876 * 10877 * **Note:** This method is based on the 10878 * [spread operator](https://mdn.io/spread_operator). 10879 * 10880 * @static 10881 * @memberOf _ 10882 * @since 3.2.0 10883 * @category Function 10884 * @param {Function} func The function to spread arguments over. 10885 * @param {number} [start=0] The start position of the spread. 10886 * @returns {Function} Returns the new function. 10887 * @example 10888 * 10889 * var say = _.spread(function(who, what) { 10890 * return who + ' says ' + what; 10891 * }); 10892 * 10893 * say(['fred', 'hello']); 10894 * // => 'fred says hello' 10895 * 10896 * var numbers = Promise.all([ 10897 * Promise.resolve(40), 10898 * Promise.resolve(36) 10899 * ]); 10900 * 10901 * numbers.then(_.spread(function(x, y) { 10902 * return x + y; 10903 * })); 10904 * // => a Promise of 76 10905 */ 10906 function spread(func, start) { 10907 if (typeof func != 'function') { 10908 throw new TypeError(FUNC_ERROR_TEXT); 10909 } 10910 start = start == null ? 0 : nativeMax(toInteger(start), 0); 10911 return baseRest(function(args) { 10912 var array = args[start], 10913 otherArgs = castSlice(args, 0, start); 10914 10915 if (array) { 10916 arrayPush(otherArgs, array); 10917 } 10918 return apply(func, this, otherArgs); 10919 }); 10920 } 10921 10922 /** 10923 * Creates a throttled function that only invokes `func` at most once per 10924 * every `wait` milliseconds. The throttled function comes with a `cancel` 10925 * method to cancel delayed `func` invocations and a `flush` method to 10926 * immediately invoke them. Provide `options` to indicate whether `func` 10927 * should be invoked on the leading and/or trailing edge of the `wait` 10928 * timeout. The `func` is invoked with the last arguments provided to the 10929 * throttled function. Subsequent calls to the throttled function return the 10930 * result of the last `func` invocation. 10931 * 10932 * **Note:** If `leading` and `trailing` options are `true`, `func` is 10933 * invoked on the trailing edge of the timeout only if the throttled function 10934 * is invoked more than once during the `wait` timeout. 10935 * 10936 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 10937 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 10938 * 10939 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 10940 * for details over the differences between `_.throttle` and `_.debounce`. 10941 * 10942 * @static 10943 * @memberOf _ 10944 * @since 0.1.0 10945 * @category Function 10946 * @param {Function} func The function to throttle. 10947 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 10948 * @param {Object} [options={}] The options object. 10949 * @param {boolean} [options.leading=true] 10950 * Specify invoking on the leading edge of the timeout. 10951 * @param {boolean} [options.trailing=true] 10952 * Specify invoking on the trailing edge of the timeout. 10953 * @returns {Function} Returns the new throttled function. 10954 * @example 10955 * 10956 * // Avoid excessively updating the position while scrolling. 10957 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 10958 * 10959 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 10960 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 10961 * jQuery(element).on('click', throttled); 10962 * 10963 * // Cancel the trailing throttled invocation. 10964 * jQuery(window).on('popstate', throttled.cancel); 10965 */ 10966 function throttle(func, wait, options) { 10967 var leading = true, 10968 trailing = true; 10969 10970 if (typeof func != 'function') { 10971 throw new TypeError(FUNC_ERROR_TEXT); 10972 } 10973 if (isObject(options)) { 10974 leading = 'leading' in options ? !!options.leading : leading; 10975 trailing = 'trailing' in options ? !!options.trailing : trailing; 10976 } 10977 return debounce(func, wait, { 10978 'leading': leading, 10979 'maxWait': wait, 10980 'trailing': trailing 10981 }); 10982 } 10983 10984 /** 10985 * Creates a function that accepts up to one argument, ignoring any 10986 * additional arguments. 10987 * 10988 * @static 10989 * @memberOf _ 10990 * @since 4.0.0 10991 * @category Function 10992 * @param {Function} func The function to cap arguments for. 10993 * @returns {Function} Returns the new capped function. 10994 * @example 10995 * 10996 * _.map(['6', '8', '10'], _.unary(parseInt)); 10997 * // => [6, 8, 10] 10998 */ 10999 function unary(func) { 11000 return ary(func, 1); 11001 } 11002 11003 /** 11004 * Creates a function that provides `value` to `wrapper` as its first 11005 * argument. Any additional arguments provided to the function are appended 11006 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 11007 * binding of the created function. 11008 * 11009 * @static 11010 * @memberOf _ 11011 * @since 0.1.0 11012 * @category Function 11013 * @param {*} value The value to wrap. 11014 * @param {Function} [wrapper=identity] The wrapper function. 11015 * @returns {Function} Returns the new function. 11016 * @example 11017 * 11018 * var p = _.wrap(_.escape, function(func, text) { 11019 * return '<p>' + func(text) + '</p>'; 11020 * }); 11021 * 11022 * p('fred, barney, & pebbles'); 11023 * // => '<p>fred, barney, & pebbles</p>' 11024 */ 11025 function wrap(value, wrapper) { 11026 return partial(castFunction(wrapper), value); 11027 } 11028 11029 /*------------------------------------------------------------------------*/ 11030 11031 /** 11032 * Casts `value` as an array if it's not one. 11033 * 11034 * @static 11035 * @memberOf _ 11036 * @since 4.4.0 11037 * @category Lang 11038 * @param {*} value The value to inspect. 11039 * @returns {Array} Returns the cast array. 11040 * @example 11041 * 11042 * _.castArray(1); 11043 * // => [1] 11044 * 11045 * _.castArray({ 'a': 1 }); 11046 * // => [{ 'a': 1 }] 11047 * 11048 * _.castArray('abc'); 11049 * // => ['abc'] 11050 * 11051 * _.castArray(null); 11052 * // => [null] 11053 * 11054 * _.castArray(undefined); 11055 * // => [undefined] 11056 * 11057 * _.castArray(); 11058 * // => [] 11059 * 11060 * var array = [1, 2, 3]; 11061 * console.log(_.castArray(array) === array); 11062 * // => true 11063 */ 11064 function castArray() { 11065 if (!arguments.length) { 11066 return []; 11067 } 11068 var value = arguments[0]; 11069 return isArray(value) ? value : [value]; 11070 } 11071 11072 /** 11073 * Creates a shallow clone of `value`. 11074 * 11075 * **Note:** This method is loosely based on the 11076 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 11077 * and supports cloning arrays, array buffers, booleans, date objects, maps, 11078 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 11079 * arrays. The own enumerable properties of `arguments` objects are cloned 11080 * as plain objects. An empty object is returned for uncloneable values such 11081 * as error objects, functions, DOM nodes, and WeakMaps. 11082 * 11083 * @static 11084 * @memberOf _ 11085 * @since 0.1.0 11086 * @category Lang 11087 * @param {*} value The value to clone. 11088 * @returns {*} Returns the cloned value. 11089 * @see _.cloneDeep 11090 * @example 11091 * 11092 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 11093 * 11094 * var shallow = _.clone(objects); 11095 * console.log(shallow[0] === objects[0]); 11096 * // => true 11097 */ 11098 function clone(value) { 11099 return baseClone(value, CLONE_SYMBOLS_FLAG); 11100 } 11101 11102 /** 11103 * This method is like `_.clone` except that it accepts `customizer` which 11104 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 11105 * cloning is handled by the method instead. The `customizer` is invoked with 11106 * up to four arguments; (value [, index|key, object, stack]). 11107 * 11108 * @static 11109 * @memberOf _ 11110 * @since 4.0.0 11111 * @category Lang 11112 * @param {*} value The value to clone. 11113 * @param {Function} [customizer] The function to customize cloning. 11114 * @returns {*} Returns the cloned value. 11115 * @see _.cloneDeepWith 11116 * @example 11117 * 11118 * function customizer(value) { 11119 * if (_.isElement(value)) { 11120 * return value.cloneNode(false); 11121 * } 11122 * } 11123 * 11124 * var el = _.cloneWith(document.body, customizer); 11125 * 11126 * console.log(el === document.body); 11127 * // => false 11128 * console.log(el.nodeName); 11129 * // => 'BODY' 11130 * console.log(el.childNodes.length); 11131 * // => 0 11132 */ 11133 function cloneWith(value, customizer) { 11134 customizer = typeof customizer == 'function' ? customizer : undefined; 11135 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 11136 } 11137 11138 /** 11139 * This method is like `_.clone` except that it recursively clones `value`. 11140 * 11141 * @static 11142 * @memberOf _ 11143 * @since 1.0.0 11144 * @category Lang 11145 * @param {*} value The value to recursively clone. 11146 * @returns {*} Returns the deep cloned value. 11147 * @see _.clone 11148 * @example 11149 * 11150 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 11151 * 11152 * var deep = _.cloneDeep(objects); 11153 * console.log(deep[0] === objects[0]); 11154 * // => false 11155 */ 11156 function cloneDeep(value) { 11157 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 11158 } 11159 11160 /** 11161 * This method is like `_.cloneWith` except that it recursively clones `value`. 11162 * 11163 * @static 11164 * @memberOf _ 11165 * @since 4.0.0 11166 * @category Lang 11167 * @param {*} value The value to recursively clone. 11168 * @param {Function} [customizer] The function to customize cloning. 11169 * @returns {*} Returns the deep cloned value. 11170 * @see _.cloneWith 11171 * @example 11172 * 11173 * function customizer(value) { 11174 * if (_.isElement(value)) { 11175 * return value.cloneNode(true); 11176 * } 11177 * } 11178 * 11179 * var el = _.cloneDeepWith(document.body, customizer); 11180 * 11181 * console.log(el === document.body); 11182 * // => false 11183 * console.log(el.nodeName); 11184 * // => 'BODY' 11185 * console.log(el.childNodes.length); 11186 * // => 20 11187 */ 11188 function cloneDeepWith(value, customizer) { 11189 customizer = typeof customizer == 'function' ? customizer : undefined; 11190 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 11191 } 11192 11193 /** 11194 * Checks if `object` conforms to `source` by invoking the predicate 11195 * properties of `source` with the corresponding property values of `object`. 11196 * 11197 * **Note:** This method is equivalent to `_.conforms` when `source` is 11198 * partially applied. 11199 * 11200 * @static 11201 * @memberOf _ 11202 * @since 4.14.0 11203 * @category Lang 11204 * @param {Object} object The object to inspect. 11205 * @param {Object} source The object of property predicates to conform to. 11206 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 11207 * @example 11208 * 11209 * var object = { 'a': 1, 'b': 2 }; 11210 * 11211 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 11212 * // => true 11213 * 11214 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 11215 * // => false 11216 */ 11217 function conformsTo(object, source) { 11218 return source == null || baseConformsTo(object, source, keys(source)); 11219 } 11220 11221 /** 11222 * Performs a 11223 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 11224 * comparison between two values to determine if they are equivalent. 11225 * 11226 * @static 11227 * @memberOf _ 11228 * @since 4.0.0 11229 * @category Lang 11230 * @param {*} value The value to compare. 11231 * @param {*} other The other value to compare. 11232 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 11233 * @example 11234 * 11235 * var object = { 'a': 1 }; 11236 * var other = { 'a': 1 }; 11237 * 11238 * _.eq(object, object); 11239 * // => true 11240 * 11241 * _.eq(object, other); 11242 * // => false 11243 * 11244 * _.eq('a', 'a'); 11245 * // => true 11246 * 11247 * _.eq('a', Object('a')); 11248 * // => false 11249 * 11250 * _.eq(NaN, NaN); 11251 * // => true 11252 */ 11253 function eq(value, other) { 11254 return value === other || (value !== value && other !== other); 11255 } 11256 11257 /** 11258 * Checks if `value` is greater than `other`. 11259 * 11260 * @static 11261 * @memberOf _ 11262 * @since 3.9.0 11263 * @category Lang 11264 * @param {*} value The value to compare. 11265 * @param {*} other The other value to compare. 11266 * @returns {boolean} Returns `true` if `value` is greater than `other`, 11267 * else `false`. 11268 * @see _.lt 11269 * @example 11270 * 11271 * _.gt(3, 1); 11272 * // => true 11273 * 11274 * _.gt(3, 3); 11275 * // => false 11276 * 11277 * _.gt(1, 3); 11278 * // => false 11279 */ 11280 var gt = createRelationalOperation(baseGt); 11281 11282 /** 11283 * Checks if `value` is greater than or equal to `other`. 11284 * 11285 * @static 11286 * @memberOf _ 11287 * @since 3.9.0 11288 * @category Lang 11289 * @param {*} value The value to compare. 11290 * @param {*} other The other value to compare. 11291 * @returns {boolean} Returns `true` if `value` is greater than or equal to 11292 * `other`, else `false`. 11293 * @see _.lte 11294 * @example 11295 * 11296 * _.gte(3, 1); 11297 * // => true 11298 * 11299 * _.gte(3, 3); 11300 * // => true 11301 * 11302 * _.gte(1, 3); 11303 * // => false 11304 */ 11305 var gte = createRelationalOperation(function(value, other) { 11306 return value >= other; 11307 }); 11308 11309 /** 11310 * Checks if `value` is likely an `arguments` object. 11311 * 11312 * @static 11313 * @memberOf _ 11314 * @since 0.1.0 11315 * @category Lang 11316 * @param {*} value The value to check. 11317 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 11318 * else `false`. 11319 * @example 11320 * 11321 * _.isArguments(function() { return arguments; }()); 11322 * // => true 11323 * 11324 * _.isArguments([1, 2, 3]); 11325 * // => false 11326 */ 11327 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 11328 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 11329 !propertyIsEnumerable.call(value, 'callee'); 11330 }; 11331 11332 /** 11333 * Checks if `value` is classified as an `Array` object. 11334 * 11335 * @static 11336 * @memberOf _ 11337 * @since 0.1.0 11338 * @category Lang 11339 * @param {*} value The value to check. 11340 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 11341 * @example 11342 * 11343 * _.isArray([1, 2, 3]); 11344 * // => true 11345 * 11346 * _.isArray(document.body.children); 11347 * // => false 11348 * 11349 * _.isArray('abc'); 11350 * // => false 11351 * 11352 * _.isArray(_.noop); 11353 * // => false 11354 */ 11355 var isArray = Array.isArray; 11356 11357 /** 11358 * Checks if `value` is classified as an `ArrayBuffer` object. 11359 * 11360 * @static 11361 * @memberOf _ 11362 * @since 4.3.0 11363 * @category Lang 11364 * @param {*} value The value to check. 11365 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 11366 * @example 11367 * 11368 * _.isArrayBuffer(new ArrayBuffer(2)); 11369 * // => true 11370 * 11371 * _.isArrayBuffer(new Array(2)); 11372 * // => false 11373 */ 11374 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 11375 11376 /** 11377 * Checks if `value` is array-like. A value is considered array-like if it's 11378 * not a function and has a `value.length` that's an integer greater than or 11379 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 11380 * 11381 * @static 11382 * @memberOf _ 11383 * @since 4.0.0 11384 * @category Lang 11385 * @param {*} value The value to check. 11386 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 11387 * @example 11388 * 11389 * _.isArrayLike([1, 2, 3]); 11390 * // => true 11391 * 11392 * _.isArrayLike(document.body.children); 11393 * // => true 11394 * 11395 * _.isArrayLike('abc'); 11396 * // => true 11397 * 11398 * _.isArrayLike(_.noop); 11399 * // => false 11400 */ 11401 function isArrayLike(value) { 11402 return value != null && isLength(value.length) && !isFunction(value); 11403 } 11404 11405 /** 11406 * This method is like `_.isArrayLike` except that it also checks if `value` 11407 * is an object. 11408 * 11409 * @static 11410 * @memberOf _ 11411 * @since 4.0.0 11412 * @category Lang 11413 * @param {*} value The value to check. 11414 * @returns {boolean} Returns `true` if `value` is an array-like object, 11415 * else `false`. 11416 * @example 11417 * 11418 * _.isArrayLikeObject([1, 2, 3]); 11419 * // => true 11420 * 11421 * _.isArrayLikeObject(document.body.children); 11422 * // => true 11423 * 11424 * _.isArrayLikeObject('abc'); 11425 * // => false 11426 * 11427 * _.isArrayLikeObject(_.noop); 11428 * // => false 11429 */ 11430 function isArrayLikeObject(value) { 11431 return isObjectLike(value) && isArrayLike(value); 11432 } 11433 11434 /** 11435 * Checks if `value` is classified as a boolean primitive or object. 11436 * 11437 * @static 11438 * @memberOf _ 11439 * @since 0.1.0 11440 * @category Lang 11441 * @param {*} value The value to check. 11442 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 11443 * @example 11444 * 11445 * _.isBoolean(false); 11446 * // => true 11447 * 11448 * _.isBoolean(null); 11449 * // => false 11450 */ 11451 function isBoolean(value) { 11452 return value === true || value === false || 11453 (isObjectLike(value) && baseGetTag(value) == boolTag); 11454 } 11455 11456 /** 11457 * Checks if `value` is a buffer. 11458 * 11459 * @static 11460 * @memberOf _ 11461 * @since 4.3.0 11462 * @category Lang 11463 * @param {*} value The value to check. 11464 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 11465 * @example 11466 * 11467 * _.isBuffer(new Buffer(2)); 11468 * // => true 11469 * 11470 * _.isBuffer(new Uint8Array(2)); 11471 * // => false 11472 */ 11473 var isBuffer = nativeIsBuffer || stubFalse; 11474 11475 /** 11476 * Checks if `value` is classified as a `Date` object. 11477 * 11478 * @static 11479 * @memberOf _ 11480 * @since 0.1.0 11481 * @category Lang 11482 * @param {*} value The value to check. 11483 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 11484 * @example 11485 * 11486 * _.isDate(new Date); 11487 * // => true 11488 * 11489 * _.isDate('Mon April 23 2012'); 11490 * // => false 11491 */ 11492 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 11493 11494 /** 11495 * Checks if `value` is likely a DOM element. 11496 * 11497 * @static 11498 * @memberOf _ 11499 * @since 0.1.0 11500 * @category Lang 11501 * @param {*} value The value to check. 11502 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 11503 * @example 11504 * 11505 * _.isElement(document.body); 11506 * // => true 11507 * 11508 * _.isElement('<body>'); 11509 * // => false 11510 */ 11511 function isElement(value) { 11512 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 11513 } 11514 11515 /** 11516 * Checks if `value` is an empty object, collection, map, or set. 11517 * 11518 * Objects are considered empty if they have no own enumerable string keyed 11519 * properties. 11520 * 11521 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 11522 * jQuery-like collections are considered empty if they have a `length` of `0`. 11523 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 11524 * 11525 * @static 11526 * @memberOf _ 11527 * @since 0.1.0 11528 * @category Lang 11529 * @param {*} value The value to check. 11530 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 11531 * @example 11532 * 11533 * _.isEmpty(null); 11534 * // => true 11535 * 11536 * _.isEmpty(true); 11537 * // => true 11538 * 11539 * _.isEmpty(1); 11540 * // => true 11541 * 11542 * _.isEmpty([1, 2, 3]); 11543 * // => false 11544 * 11545 * _.isEmpty({ 'a': 1 }); 11546 * // => false 11547 */ 11548 function isEmpty(value) { 11549 if (value == null) { 11550 return true; 11551 } 11552 if (isArrayLike(value) && 11553 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 11554 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 11555 return !value.length; 11556 } 11557 var tag = getTag(value); 11558 if (tag == mapTag || tag == setTag) { 11559 return !value.size; 11560 } 11561 if (isPrototype(value)) { 11562 return !baseKeys(value).length; 11563 } 11564 for (var key in value) { 11565 if (hasOwnProperty.call(value, key)) { 11566 return false; 11567 } 11568 } 11569 return true; 11570 } 11571 11572 /** 11573 * Performs a deep comparison between two values to determine if they are 11574 * equivalent. 11575 * 11576 * **Note:** This method supports comparing arrays, array buffers, booleans, 11577 * date objects, error objects, maps, numbers, `Object` objects, regexes, 11578 * sets, strings, symbols, and typed arrays. `Object` objects are compared 11579 * by their own, not inherited, enumerable properties. Functions and DOM 11580 * nodes are compared by strict equality, i.e. `===`. 11581 * 11582 * @static 11583 * @memberOf _ 11584 * @since 0.1.0 11585 * @category Lang 11586 * @param {*} value The value to compare. 11587 * @param {*} other The other value to compare. 11588 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 11589 * @example 11590 * 11591 * var object = { 'a': 1 }; 11592 * var other = { 'a': 1 }; 11593 * 11594 * _.isEqual(object, other); 11595 * // => true 11596 * 11597 * object === other; 11598 * // => false 11599 */ 11600 function isEqual(value, other) { 11601 return baseIsEqual(value, other); 11602 } 11603 11604 /** 11605 * This method is like `_.isEqual` except that it accepts `customizer` which 11606 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 11607 * are handled by the method instead. The `customizer` is invoked with up to 11608 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 11609 * 11610 * @static 11611 * @memberOf _ 11612 * @since 4.0.0 11613 * @category Lang 11614 * @param {*} value The value to compare. 11615 * @param {*} other The other value to compare. 11616 * @param {Function} [customizer] The function to customize comparisons. 11617 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 11618 * @example 11619 * 11620 * function isGreeting(value) { 11621 * return /^h(?:i|ello)$/.test(value); 11622 * } 11623 * 11624 * function customizer(objValue, othValue) { 11625 * if (isGreeting(objValue) && isGreeting(othValue)) { 11626 * return true; 11627 * } 11628 * } 11629 * 11630 * var array = ['hello', 'goodbye']; 11631 * var other = ['hi', 'goodbye']; 11632 * 11633 * _.isEqualWith(array, other, customizer); 11634 * // => true 11635 */ 11636 function isEqualWith(value, other, customizer) { 11637 customizer = typeof customizer == 'function' ? customizer : undefined; 11638 var result = customizer ? customizer(value, other) : undefined; 11639 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 11640 } 11641 11642 /** 11643 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 11644 * `SyntaxError`, `TypeError`, or `URIError` object. 11645 * 11646 * @static 11647 * @memberOf _ 11648 * @since 3.0.0 11649 * @category Lang 11650 * @param {*} value The value to check. 11651 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 11652 * @example 11653 * 11654 * _.isError(new Error); 11655 * // => true 11656 * 11657 * _.isError(Error); 11658 * // => false 11659 */ 11660 function isError(value) { 11661 if (!isObjectLike(value)) { 11662 return false;
vendor: 6,607 bytes, lines 11663-11900
11663 } 11664 var tag = baseGetTag(value); 11665 return tag == errorTag || tag == domExcTag || 11666 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 11667 } 11668 11669 /** 11670 * Checks if `value` is a finite primitive number. 11671 * 11672 * **Note:** This method is based on 11673 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 11674 * 11675 * @static 11676 * @memberOf _ 11677 * @since 0.1.0 11678 * @category Lang 11679 * @param {*} value The value to check. 11680 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 11681 * @example 11682 * 11683 * _.isFinite(3); 11684 * // => true 11685 * 11686 * _.isFinite(Number.MIN_VALUE); 11687 * // => true 11688 * 11689 * _.isFinite(Infinity); 11690 * // => false 11691 * 11692 * _.isFinite('3'); 11693 * // => false 11694 */ 11695 function isFinite(value) { 11696 return typeof value == 'number' && nativeIsFinite(value); 11697 } 11698 11699 /** 11700 * Checks if `value` is classified as a `Function` object. 11701 * 11702 * @static 11703 * @memberOf _ 11704 * @since 0.1.0 11705 * @category Lang 11706 * @param {*} value The value to check. 11707 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 11708 * @example 11709 * 11710 * _.isFunction(_); 11711 * // => true 11712 * 11713 * _.isFunction(/abc/); 11714 * // => false 11715 */ 11716 function isFunction(value) { 11717 if (!isObject(value)) { 11718 return false; 11719 } 11720 // The use of `Object#toString` avoids issues with the `typeof` operator 11721 // in Safari 9 which returns 'object' for typed arrays and other constructors. 11722 var tag = baseGetTag(value); 11723 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 11724 } 11725 11726 /** 11727 * Checks if `value` is an integer. 11728 * 11729 * **Note:** This method is based on 11730 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 11731 * 11732 * @static 11733 * @memberOf _ 11734 * @since 4.0.0 11735 * @category Lang 11736 * @param {*} value The value to check. 11737 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 11738 * @example 11739 * 11740 * _.isInteger(3); 11741 * // => true 11742 * 11743 * _.isInteger(Number.MIN_VALUE); 11744 * // => false 11745 * 11746 * _.isInteger(Infinity); 11747 * // => false 11748 * 11749 * _.isInteger('3'); 11750 * // => false 11751 */ 11752 function isInteger(value) { 11753 return typeof value == 'number' && value == toInteger(value); 11754 } 11755 11756 /** 11757 * Checks if `value` is a valid array-like length. 11758 * 11759 * **Note:** This method is loosely based on 11760 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 11761 * 11762 * @static 11763 * @memberOf _ 11764 * @since 4.0.0 11765 * @category Lang 11766 * @param {*} value The value to check. 11767 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 11768 * @example 11769 * 11770 * _.isLength(3); 11771 * // => true 11772 * 11773 * _.isLength(Number.MIN_VALUE); 11774 * // => false 11775 * 11776 * _.isLength(Infinity); 11777 * // => false 11778 * 11779 * _.isLength('3'); 11780 * // => false 11781 */ 11782 function isLength(value) { 11783 return typeof value == 'number' && 11784 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 11785 } 11786 11787 /** 11788 * Checks if `value` is the 11789 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 11790 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 11791 * 11792 * @static 11793 * @memberOf _ 11794 * @since 0.1.0 11795 * @category Lang 11796 * @param {*} value The value to check. 11797 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 11798 * @example 11799 * 11800 * _.isObject({}); 11801 * // => true 11802 * 11803 * _.isObject([1, 2, 3]); 11804 * // => true 11805 * 11806 * _.isObject(_.noop); 11807 * // => true 11808 * 11809 * _.isObject(null); 11810 * // => false 11811 */ 11812 function isObject(value) { 11813 var type = typeof value; 11814 return value != null && (type == 'object' || type == 'function'); 11815 } 11816 11817 /** 11818 * Checks if `value` is object-like. A value is object-like if it's not `null` 11819 * and has a `typeof` result of "object". 11820 * 11821 * @static 11822 * @memberOf _ 11823 * @since 4.0.0 11824 * @category Lang 11825 * @param {*} value The value to check. 11826 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 11827 * @example 11828 * 11829 * _.isObjectLike({}); 11830 * // => true 11831 * 11832 * _.isObjectLike([1, 2, 3]); 11833 * // => true 11834 * 11835 * _.isObjectLike(_.noop); 11836 * // => false 11837 * 11838 * _.isObjectLike(null); 11839 * // => false 11840 */ 11841 function isObjectLike(value) { 11842 return value != null && typeof value == 'object'; 11843 } 11844 11845 /** 11846 * Checks if `value` is classified as a `Map` object. 11847 * 11848 * @static 11849 * @memberOf _ 11850 * @since 4.3.0 11851 * @category Lang 11852 * @param {*} value The value to check. 11853 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 11854 * @example 11855 * 11856 * _.isMap(new Map); 11857 * // => true 11858 * 11859 * _.isMap(new WeakMap); 11860 * // => false 11861 */ 11862 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 11863 11864 /** 11865 * Performs a partial deep comparison between `object` and `source` to 11866 * determine if `object` contains equivalent property values. 11867 * 11868 * **Note:** This method is equivalent to `_.matches` when `source` is 11869 * partially applied. 11870 * 11871 * Partial comparisons will match empty array and empty object `source` 11872 * values against any array or object value, respectively. See `_.isEqual` 11873 * for a list of supported value comparisons. 11874 * 11875 * @static 11876 * @memberOf _ 11877 * @since 3.0.0 11878 * @category Lang 11879 * @param {Object} object The object to inspect. 11880 * @param {Object} source The object of property values to match. 11881 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 11882 * @example 11883 * 11884 * var object = { 'a': 1, 'b': 2 }; 11885 * 11886 * _.isMatch(object, { 'b': 2 }); 11887 * // => true 11888 * 11889 * _.isMatch(object, { 'b': 1 }); 11890 * // => false 11891 */ 11892 function isMatch(object, source) { 11893 return object === source || baseIsMatch(object, source, getMatchData(source)); 11894 } 11895 11896 /** 11897 * This method is like `_.isMatch` except that it accepts `customizer` which 11898 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 11899 * are handled by the method instead. The `customizer` is invoked with five 11900 * arguments: (objValue, srcValue, index|key, object, source).
vendor: 12,241 bytes, lines 11901-12366
11901 * 11902 * @static 11903 * @memberOf _ 11904 * @since 4.0.0 11905 * @category Lang 11906 * @param {Object} object The object to inspect. 11907 * @param {Object} source The object of property values to match. 11908 * @param {Function} [customizer] The function to customize comparisons. 11909 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 11910 * @example 11911 * 11912 * function isGreeting(value) { 11913 * return /^h(?:i|ello)$/.test(value); 11914 * } 11915 * 11916 * function customizer(objValue, srcValue) { 11917 * if (isGreeting(objValue) && isGreeting(srcValue)) { 11918 * return true; 11919 * } 11920 * } 11921 * 11922 * var object = { 'greeting': 'hello' }; 11923 * var source = { 'greeting': 'hi' }; 11924 * 11925 * _.isMatchWith(object, source, customizer); 11926 * // => true 11927 */ 11928 function isMatchWith(object, source, customizer) { 11929 customizer = typeof customizer == 'function' ? customizer : undefined; 11930 return baseIsMatch(object, source, getMatchData(source), customizer); 11931 } 11932 11933 /** 11934 * Checks if `value` is `NaN`. 11935 * 11936 * **Note:** This method is based on 11937 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 11938 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 11939 * `undefined` and other non-number values. 11940 * 11941 * @static 11942 * @memberOf _ 11943 * @since 0.1.0 11944 * @category Lang 11945 * @param {*} value The value to check. 11946 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 11947 * @example 11948 * 11949 * _.isNaN(NaN); 11950 * // => true 11951 * 11952 * _.isNaN(new Number(NaN)); 11953 * // => true 11954 * 11955 * isNaN(undefined); 11956 * // => true 11957 * 11958 * _.isNaN(undefined); 11959 * // => false 11960 */ 11961 function isNaN(value) { 11962 // An `NaN` primitive is the only value that is not equal to itself. 11963 // Perform the `toStringTag` check first to avoid errors with some 11964 // ActiveX objects in IE. 11965 return isNumber(value) && value != +value; 11966 } 11967 11968 /** 11969 * Checks if `value` is a pristine native function. 11970 * 11971 * **Note:** This method can't reliably detect native functions in the presence 11972 * of the core-js package because core-js circumvents this kind of detection. 11973 * Despite multiple requests, the core-js maintainer has made it clear: any 11974 * attempt to fix the detection will be obstructed. As a result, we're left 11975 * with little choice but to throw an error. Unfortunately, this also affects 11976 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 11977 * which rely on core-js. 11978 * 11979 * @static 11980 * @memberOf _ 11981 * @since 3.0.0 11982 * @category Lang 11983 * @param {*} value The value to check. 11984 * @returns {boolean} Returns `true` if `value` is a native function, 11985 * else `false`. 11986 * @example 11987 * 11988 * _.isNative(Array.prototype.push); 11989 * // => true 11990 * 11991 * _.isNative(_); 11992 * // => false 11993 */ 11994 function isNative(value) { 11995 if (isMaskable(value)) { 11996 throw new Error(CORE_ERROR_TEXT); 11997 } 11998 return baseIsNative(value); 11999 } 12000 12001 /** 12002 * Checks if `value` is `null`. 12003 * 12004 * @static 12005 * @memberOf _ 12006 * @since 0.1.0 12007 * @category Lang 12008 * @param {*} value The value to check. 12009 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 12010 * @example 12011 * 12012 * _.isNull(null); 12013 * // => true 12014 * 12015 * _.isNull(void 0); 12016 * // => false 12017 */ 12018 function isNull(value) { 12019 return value === null; 12020 } 12021 12022 /** 12023 * Checks if `value` is `null` or `undefined`. 12024 * 12025 * @static 12026 * @memberOf _ 12027 * @since 4.0.0 12028 * @category Lang 12029 * @param {*} value The value to check. 12030 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 12031 * @example 12032 * 12033 * _.isNil(null); 12034 * // => true 12035 * 12036 * _.isNil(void 0); 12037 * // => true 12038 * 12039 * _.isNil(NaN); 12040 * // => false 12041 */ 12042 function isNil(value) { 12043 return value == null; 12044 } 12045 12046 /** 12047 * Checks if `value` is classified as a `Number` primitive or object. 12048 * 12049 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 12050 * classified as numbers, use the `_.isFinite` method. 12051 * 12052 * @static 12053 * @memberOf _ 12054 * @since 0.1.0 12055 * @category Lang 12056 * @param {*} value The value to check. 12057 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 12058 * @example 12059 * 12060 * _.isNumber(3); 12061 * // => true 12062 * 12063 * _.isNumber(Number.MIN_VALUE); 12064 * // => true 12065 * 12066 * _.isNumber(Infinity); 12067 * // => true 12068 * 12069 * _.isNumber('3'); 12070 * // => false 12071 */ 12072 function isNumber(value) { 12073 return typeof value == 'number' || 12074 (isObjectLike(value) && baseGetTag(value) == numberTag); 12075 } 12076 12077 /** 12078 * Checks if `value` is a plain object, that is, an object created by the 12079 * `Object` constructor or one with a `[[Prototype]]` of `null`. 12080 * 12081 * @static 12082 * @memberOf _ 12083 * @since 0.8.0 12084 * @category Lang 12085 * @param {*} value The value to check. 12086 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 12087 * @example 12088 * 12089 * function Foo() { 12090 * this.a = 1; 12091 * } 12092 * 12093 * _.isPlainObject(new Foo); 12094 * // => false 12095 * 12096 * _.isPlainObject([1, 2, 3]); 12097 * // => false 12098 * 12099 * _.isPlainObject({ 'x': 0, 'y': 0 }); 12100 * // => true 12101 * 12102 * _.isPlainObject(Object.create(null)); 12103 * // => true 12104 */ 12105 function isPlainObject(value) { 12106 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 12107 return false; 12108 } 12109 var proto = getPrototype(value); 12110 if (proto === null) { 12111 return true; 12112 } 12113 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 12114 return typeof Ctor == 'function' && Ctor instanceof Ctor && 12115 funcToString.call(Ctor) == objectCtorString; 12116 } 12117 12118 /** 12119 * Checks if `value` is classified as a `RegExp` object. 12120 * 12121 * @static 12122 * @memberOf _ 12123 * @since 0.1.0 12124 * @category Lang 12125 * @param {*} value The value to check. 12126 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 12127 * @example 12128 * 12129 * _.isRegExp(/abc/); 12130 * // => true 12131 * 12132 * _.isRegExp('/abc/'); 12133 * // => false 12134 */ 12135 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 12136 12137 /** 12138 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 12139 * double precision number which isn't the result of a rounded unsafe integer. 12140 * 12141 * **Note:** This method is based on 12142 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 12143 * 12144 * @static 12145 * @memberOf _ 12146 * @since 4.0.0 12147 * @category Lang 12148 * @param {*} value The value to check. 12149 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 12150 * @example 12151 * 12152 * _.isSafeInteger(3); 12153 * // => true 12154 * 12155 * _.isSafeInteger(Number.MIN_VALUE); 12156 * // => false 12157 * 12158 * _.isSafeInteger(Infinity); 12159 * // => false 12160 * 12161 * _.isSafeInteger('3'); 12162 * // => false 12163 */ 12164 function isSafeInteger(value) { 12165 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 12166 } 12167 12168 /** 12169 * Checks if `value` is classified as a `Set` object. 12170 * 12171 * @static 12172 * @memberOf _ 12173 * @since 4.3.0 12174 * @category Lang 12175 * @param {*} value The value to check. 12176 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 12177 * @example 12178 * 12179 * _.isSet(new Set); 12180 * // => true 12181 * 12182 * _.isSet(new WeakSet); 12183 * // => false 12184 */ 12185 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 12186 12187 /** 12188 * Checks if `value` is classified as a `String` primitive or object. 12189 * 12190 * @static 12191 * @since 0.1.0 12192 * @memberOf _ 12193 * @category Lang 12194 * @param {*} value The value to check. 12195 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 12196 * @example 12197 * 12198 * _.isString('abc'); 12199 * // => true 12200 * 12201 * _.isString(1); 12202 * // => false 12203 */ 12204 function isString(value) { 12205 return typeof value == 'string' || 12206 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 12207 } 12208 12209 /** 12210 * Checks if `value` is classified as a `Symbol` primitive or object. 12211 * 12212 * @static 12213 * @memberOf _ 12214 * @since 4.0.0 12215 * @category Lang 12216 * @param {*} value The value to check. 12217 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 12218 * @example 12219 * 12220 * _.isSymbol(Symbol.iterator); 12221 * // => true 12222 * 12223 * _.isSymbol('abc'); 12224 * // => false 12225 */ 12226 function isSymbol(value) { 12227 return typeof value == 'symbol' || 12228 (isObjectLike(value) && baseGetTag(value) == symbolTag); 12229 } 12230 12231 /** 12232 * Checks if `value` is classified as a typed array. 12233 * 12234 * @static 12235 * @memberOf _ 12236 * @since 3.0.0 12237 * @category Lang 12238 * @param {*} value The value to check. 12239 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 12240 * @example 12241 * 12242 * _.isTypedArray(new Uint8Array); 12243 * // => true 12244 * 12245 * _.isTypedArray([]); 12246 * // => false 12247 */ 12248 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 12249 12250 /** 12251 * Checks if `value` is `undefined`. 12252 * 12253 * @static 12254 * @since 0.1.0 12255 * @memberOf _ 12256 * @category Lang 12257 * @param {*} value The value to check. 12258 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 12259 * @example 12260 * 12261 * _.isUndefined(void 0); 12262 * // => true 12263 * 12264 * _.isUndefined(null); 12265 * // => false 12266 */ 12267 function isUndefined(value) { 12268 return value === undefined; 12269 } 12270 12271 /** 12272 * Checks if `value` is classified as a `WeakMap` object. 12273 * 12274 * @static 12275 * @memberOf _ 12276 * @since 4.3.0 12277 * @category Lang 12278 * @param {*} value The value to check. 12279 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 12280 * @example 12281 * 12282 * _.isWeakMap(new WeakMap); 12283 * // => true 12284 * 12285 * _.isWeakMap(new Map); 12286 * // => false 12287 */ 12288 function isWeakMap(value) { 12289 return isObjectLike(value) && getTag(value) == weakMapTag; 12290 } 12291 12292 /** 12293 * Checks if `value` is classified as a `WeakSet` object. 12294 * 12295 * @static 12296 * @memberOf _ 12297 * @since 4.3.0 12298 * @category Lang 12299 * @param {*} value The value to check. 12300 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 12301 * @example 12302 * 12303 * _.isWeakSet(new WeakSet); 12304 * // => true 12305 * 12306 * _.isWeakSet(new Set); 12307 * // => false 12308 */ 12309 function isWeakSet(value) { 12310 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 12311 } 12312 12313 /** 12314 * Checks if `value` is less than `other`. 12315 * 12316 * @static 12317 * @memberOf _ 12318 * @since 3.9.0 12319 * @category Lang 12320 * @param {*} value The value to compare. 12321 * @param {*} other The other value to compare. 12322 * @returns {boolean} Returns `true` if `value` is less than `other`, 12323 * else `false`. 12324 * @see _.gt 12325 * @example 12326 * 12327 * _.lt(1, 3); 12328 * // => true 12329 * 12330 * _.lt(3, 3); 12331 * // => false 12332 * 12333 * _.lt(3, 1); 12334 * // => false 12335 */ 12336 var lt = createRelationalOperation(baseLt); 12337 12338 /** 12339 * Checks if `value` is less than or equal to `other`. 12340 * 12341 * @static 12342 * @memberOf _ 12343 * @since 3.9.0 12344 * @category Lang 12345 * @param {*} value The value to compare. 12346 * @param {*} other The other value to compare. 12347 * @returns {boolean} Returns `true` if `value` is less than or equal to 12348 * `other`, else `false`. 12349 * @see _.gte 12350 * @example 12351 * 12352 * _.lte(1, 3); 12353 * // => true 12354 * 12355 * _.lte(3, 3); 12356 * // => true 12357 * 12358 * _.lte(3, 1); 12359 * // => false 12360 */ 12361 var lte = createRelationalOperation(function(value, other) { 12362 return value <= other; 12363 }); 12364 12365 /** 12366 * Converts `value` to an array.
vendor: 11,756 bytes, lines 12367-12796
12367 * 12368 * @static 12369 * @since 0.1.0 12370 * @memberOf _ 12371 * @category Lang 12372 * @param {*} value The value to convert. 12373 * @returns {Array} Returns the converted array. 12374 * @example 12375 * 12376 * _.toArray({ 'a': 1, 'b': 2 }); 12377 * // => [1, 2] 12378 * 12379 * _.toArray('abc'); 12380 * // => ['a', 'b', 'c'] 12381 * 12382 * _.toArray(1); 12383 * // => [] 12384 * 12385 * _.toArray(null); 12386 * // => [] 12387 */ 12388 function toArray(value) { 12389 if (!value) { 12390 return []; 12391 } 12392 if (isArrayLike(value)) { 12393 return isString(value) ? stringToArray(value) : copyArray(value); 12394 } 12395 if (symIterator && value[symIterator]) { 12396 return iteratorToArray(value[symIterator]()); 12397 } 12398 var tag = getTag(value), 12399 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 12400 12401 return func(value); 12402 } 12403 12404 /** 12405 * Converts `value` to a finite number. 12406 * 12407 * @static 12408 * @memberOf _ 12409 * @since 4.12.0 12410 * @category Lang 12411 * @param {*} value The value to convert. 12412 * @returns {number} Returns the converted number. 12413 * @example 12414 * 12415 * _.toFinite(3.2); 12416 * // => 3.2 12417 * 12418 * _.toFinite(Number.MIN_VALUE); 12419 * // => 5e-324 12420 * 12421 * _.toFinite(Infinity); 12422 * // => 1.7976931348623157e+308 12423 * 12424 * _.toFinite('3.2'); 12425 * // => 3.2 12426 */ 12427 function toFinite(value) { 12428 if (!value) { 12429 return value === 0 ? value : 0; 12430 } 12431 value = toNumber(value); 12432 if (value === INFINITY || value === -INFINITY) { 12433 var sign = (value < 0 ? -1 : 1); 12434 return sign * MAX_INTEGER; 12435 } 12436 return value === value ? value : 0; 12437 } 12438 12439 /** 12440 * Converts `value` to an integer. 12441 * 12442 * **Note:** This method is loosely based on 12443 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 12444 * 12445 * @static 12446 * @memberOf _ 12447 * @since 4.0.0 12448 * @category Lang 12449 * @param {*} value The value to convert. 12450 * @returns {number} Returns the converted integer. 12451 * @example 12452 * 12453 * _.toInteger(3.2); 12454 * // => 3 12455 * 12456 * _.toInteger(Number.MIN_VALUE); 12457 * // => 0 12458 * 12459 * _.toInteger(Infinity); 12460 * // => 1.7976931348623157e+308 12461 * 12462 * _.toInteger('3.2'); 12463 * // => 3 12464 */ 12465 function toInteger(value) { 12466 var result = toFinite(value), 12467 remainder = result % 1; 12468 12469 return result === result ? (remainder ? result - remainder : result) : 0; 12470 } 12471 12472 /** 12473 * Converts `value` to an integer suitable for use as the length of an 12474 * array-like object. 12475 * 12476 * **Note:** This method is based on 12477 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 12478 * 12479 * @static 12480 * @memberOf _ 12481 * @since 4.0.0 12482 * @category Lang 12483 * @param {*} value The value to convert. 12484 * @returns {number} Returns the converted integer. 12485 * @example 12486 * 12487 * _.toLength(3.2); 12488 * // => 3 12489 * 12490 * _.toLength(Number.MIN_VALUE); 12491 * // => 0 12492 * 12493 * _.toLength(Infinity); 12494 * // => 4294967295 12495 * 12496 * _.toLength('3.2'); 12497 * // => 3 12498 */ 12499 function toLength(value) { 12500 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 12501 } 12502 12503 /** 12504 * Converts `value` to a number. 12505 * 12506 * @static 12507 * @memberOf _ 12508 * @since 4.0.0 12509 * @category Lang 12510 * @param {*} value The value to process. 12511 * @returns {number} Returns the number. 12512 * @example 12513 * 12514 * _.toNumber(3.2); 12515 * // => 3.2 12516 * 12517 * _.toNumber(Number.MIN_VALUE); 12518 * // => 5e-324 12519 * 12520 * _.toNumber(Infinity); 12521 * // => Infinity 12522 * 12523 * _.toNumber('3.2'); 12524 * // => 3.2 12525 */ 12526 function toNumber(value) { 12527 if (typeof value == 'number') { 12528 return value; 12529 } 12530 if (isSymbol(value)) { 12531 return NAN; 12532 } 12533 if (isObject(value)) { 12534 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 12535 value = isObject(other) ? (other + '') : other; 12536 } 12537 if (typeof value != 'string') { 12538 return value === 0 ? value : +value; 12539 } 12540 value = baseTrim(value); 12541 var isBinary = reIsBinary.test(value); 12542 return (isBinary || reIsOctal.test(value)) 12543 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 12544 : (reIsBadHex.test(value) ? NAN : +value); 12545 } 12546 12547 /** 12548 * Converts `value` to a plain object flattening inherited enumerable string 12549 * keyed properties of `value` to own properties of the plain object. 12550 * 12551 * @static 12552 * @memberOf _ 12553 * @since 3.0.0 12554 * @category Lang 12555 * @param {*} value The value to convert. 12556 * @returns {Object} Returns the converted plain object. 12557 * @example 12558 * 12559 * function Foo() { 12560 * this.b = 2; 12561 * } 12562 * 12563 * Foo.prototype.c = 3; 12564 * 12565 * _.assign({ 'a': 1 }, new Foo); 12566 * // => { 'a': 1, 'b': 2 } 12567 * 12568 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 12569 * // => { 'a': 1, 'b': 2, 'c': 3 } 12570 */ 12571 function toPlainObject(value) { 12572 return copyObject(value, keysIn(value)); 12573 } 12574 12575 /** 12576 * Converts `value` to a safe integer. A safe integer can be compared and 12577 * represented correctly. 12578 * 12579 * @static 12580 * @memberOf _ 12581 * @since 4.0.0 12582 * @category Lang 12583 * @param {*} value The value to convert. 12584 * @returns {number} Returns the converted integer. 12585 * @example 12586 * 12587 * _.toSafeInteger(3.2); 12588 * // => 3 12589 * 12590 * _.toSafeInteger(Number.MIN_VALUE); 12591 * // => 0 12592 * 12593 * _.toSafeInteger(Infinity); 12594 * // => 9007199254740991 12595 * 12596 * _.toSafeInteger('3.2'); 12597 * // => 3 12598 */ 12599 function toSafeInteger(value) { 12600 return value 12601 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 12602 : (value === 0 ? value : 0); 12603 } 12604 12605 /** 12606 * Converts `value` to a string. An empty string is returned for `null` 12607 * and `undefined` values. The sign of `-0` is preserved. 12608 * 12609 * @static 12610 * @memberOf _ 12611 * @since 4.0.0 12612 * @category Lang 12613 * @param {*} value The value to convert. 12614 * @returns {string} Returns the converted string. 12615 * @example 12616 * 12617 * _.toString(null); 12618 * // => '' 12619 * 12620 * _.toString(-0); 12621 * // => '-0' 12622 * 12623 * _.toString([1, 2, 3]); 12624 * // => '1,2,3' 12625 */ 12626 function toString(value) { 12627 return value == null ? '' : baseToString(value); 12628 } 12629 12630 /*------------------------------------------------------------------------*/ 12631 12632 /** 12633 * Assigns own enumerable string keyed properties of source objects to the 12634 * destination object. Source objects are applied from left to right. 12635 * Subsequent sources overwrite property assignments of previous sources. 12636 * 12637 * **Note:** This method mutates `object` and is loosely based on 12638 * [`Object.assign`](https://mdn.io/Object/assign). 12639 * 12640 * @static 12641 * @memberOf _ 12642 * @since 0.10.0 12643 * @category Object 12644 * @param {Object} object The destination object. 12645 * @param {...Object} [sources] The source objects. 12646 * @returns {Object} Returns `object`. 12647 * @see _.assignIn 12648 * @example 12649 * 12650 * function Foo() { 12651 * this.a = 1; 12652 * } 12653 * 12654 * function Bar() { 12655 * this.c = 3; 12656 * } 12657 * 12658 * Foo.prototype.b = 2; 12659 * Bar.prototype.d = 4; 12660 * 12661 * _.assign({ 'a': 0 }, new Foo, new Bar); 12662 * // => { 'a': 1, 'c': 3 } 12663 */ 12664 var assign = createAssigner(function(object, source) { 12665 if (isPrototype(source) || isArrayLike(source)) { 12666 copyObject(source, keys(source), object); 12667 return; 12668 } 12669 for (var key in source) { 12670 if (hasOwnProperty.call(source, key)) { 12671 assignValue(object, key, source[key]); 12672 } 12673 } 12674 }); 12675 12676 /** 12677 * This method is like `_.assign` except that it iterates over own and 12678 * inherited source properties. 12679 * 12680 * **Note:** This method mutates `object`. 12681 * 12682 * @static 12683 * @memberOf _ 12684 * @since 4.0.0 12685 * @alias extend 12686 * @category Object 12687 * @param {Object} object The destination object. 12688 * @param {...Object} [sources] The source objects. 12689 * @returns {Object} Returns `object`. 12690 * @see _.assign 12691 * @example 12692 * 12693 * function Foo() { 12694 * this.a = 1; 12695 * } 12696 * 12697 * function Bar() { 12698 * this.c = 3; 12699 * } 12700 * 12701 * Foo.prototype.b = 2; 12702 * Bar.prototype.d = 4; 12703 * 12704 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 12705 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 12706 */ 12707 var assignIn = createAssigner(function(object, source) { 12708 copyObject(source, keysIn(source), object); 12709 }); 12710 12711 /** 12712 * This method is like `_.assignIn` except that it accepts `customizer` 12713 * which is invoked to produce the assigned values. If `customizer` returns 12714 * `undefined`, assignment is handled by the method instead. The `customizer` 12715 * is invoked with five arguments: (objValue, srcValue, key, object, source). 12716 * 12717 * **Note:** This method mutates `object`. 12718 * 12719 * @static 12720 * @memberOf _ 12721 * @since 4.0.0 12722 * @alias extendWith 12723 * @category Object 12724 * @param {Object} object The destination object. 12725 * @param {...Object} sources The source objects. 12726 * @param {Function} [customizer] The function to customize assigned values. 12727 * @returns {Object} Returns `object`. 12728 * @see _.assignWith 12729 * @example 12730 * 12731 * function customizer(objValue, srcValue) { 12732 * return _.isUndefined(objValue) ? srcValue : objValue; 12733 * } 12734 * 12735 * var defaults = _.partialRight(_.assignInWith, customizer); 12736 * 12737 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 12738 * // => { 'a': 1, 'b': 2 } 12739 */ 12740 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 12741 copyObject(source, keysIn(source), object, customizer); 12742 }); 12743 12744 /** 12745 * This method is like `_.assign` except that it accepts `customizer` 12746 * which is invoked to produce the assigned values. If `customizer` returns 12747 * `undefined`, assignment is handled by the method instead. The `customizer` 12748 * is invoked with five arguments: (objValue, srcValue, key, object, source). 12749 * 12750 * **Note:** This method mutates `object`. 12751 * 12752 * @static 12753 * @memberOf _ 12754 * @since 4.0.0 12755 * @category Object 12756 * @param {Object} object The destination object. 12757 * @param {...Object} sources The source objects. 12758 * @param {Function} [customizer] The function to customize assigned values. 12759 * @returns {Object} Returns `object`. 12760 * @see _.assignInWith 12761 * @example 12762 * 12763 * function customizer(objValue, srcValue) { 12764 * return _.isUndefined(objValue) ? srcValue : objValue; 12765 * } 12766 * 12767 * var defaults = _.partialRight(_.assignWith, customizer); 12768 * 12769 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 12770 * // => { 'a': 1, 'b': 2 } 12771 */ 12772 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 12773 copyObject(source, keys(source), object, customizer); 12774 }); 12775 12776 /** 12777 * Creates an array of values corresponding to `paths` of `object`. 12778 * 12779 * @static 12780 * @memberOf _ 12781 * @since 1.0.0 12782 * @category Object 12783 * @param {Object} object The object to iterate over. 12784 * @param {...(string|string[])} [paths] The property paths to pick. 12785 * @returns {Array} Returns the picked values. 12786 * @example 12787 * 12788 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 12789 * 12790 * _.at(object, ['a[0].b.c', 'a[1]']); 12791 * // => [3, 4] 12792 */ 12793 var at = flatRest(baseAt); 12794 12795 /** 12796 * Creates an object that inherits from the `prototype` object. If a
vendor: 13,619 bytes, lines 12797-13261
12797 * `properties` object is given, its own enumerable string keyed properties 12798 * are assigned to the created object. 12799 * 12800 * @static 12801 * @memberOf _ 12802 * @since 2.3.0 12803 * @category Object 12804 * @param {Object} prototype The object to inherit from. 12805 * @param {Object} [properties] The properties to assign to the object. 12806 * @returns {Object} Returns the new object. 12807 * @example 12808 * 12809 * function Shape() { 12810 * this.x = 0; 12811 * this.y = 0; 12812 * } 12813 * 12814 * function Circle() { 12815 * Shape.call(this); 12816 * } 12817 * 12818 * Circle.prototype = _.create(Shape.prototype, { 12819 * 'constructor': Circle 12820 * }); 12821 * 12822 * var circle = new Circle; 12823 * circle instanceof Circle; 12824 * // => true 12825 * 12826 * circle instanceof Shape; 12827 * // => true 12828 */ 12829 function create(prototype, properties) { 12830 var result = baseCreate(prototype); 12831 return properties == null ? result : baseAssign(result, properties); 12832 } 12833 12834 /** 12835 * Assigns own and inherited enumerable string keyed properties of source 12836 * objects to the destination object for all destination properties that 12837 * resolve to `undefined`. Source objects are applied from left to right. 12838 * Once a property is set, additional values of the same property are ignored. 12839 * 12840 * **Note:** This method mutates `object`. 12841 * 12842 * @static 12843 * @since 0.1.0 12844 * @memberOf _ 12845 * @category Object 12846 * @param {Object} object The destination object. 12847 * @param {...Object} [sources] The source objects. 12848 * @returns {Object} Returns `object`. 12849 * @see _.defaultsDeep 12850 * @example 12851 * 12852 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 12853 * // => { 'a': 1, 'b': 2 } 12854 */ 12855 var defaults = baseRest(function(object, sources) { 12856 object = Object(object); 12857 12858 var index = -1; 12859 var length = sources.length; 12860 var guard = length > 2 ? sources[2] : undefined; 12861 12862 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 12863 length = 1; 12864 } 12865 12866 while (++index < length) { 12867 var source = sources[index]; 12868 var props = keysIn(source); 12869 var propsIndex = -1; 12870 var propsLength = props.length; 12871 12872 while (++propsIndex < propsLength) { 12873 var key = props[propsIndex]; 12874 var value = object[key]; 12875 12876 if (value === undefined || 12877 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 12878 object[key] = source[key]; 12879 } 12880 } 12881 } 12882 12883 return object; 12884 }); 12885 12886 /** 12887 * This method is like `_.defaults` except that it recursively assigns 12888 * default properties. 12889 * 12890 * **Note:** This method mutates `object`. 12891 * 12892 * @static 12893 * @memberOf _ 12894 * @since 3.10.0 12895 * @category Object 12896 * @param {Object} object The destination object. 12897 * @param {...Object} [sources] The source objects. 12898 * @returns {Object} Returns `object`. 12899 * @see _.defaults 12900 * @example 12901 * 12902 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 12903 * // => { 'a': { 'b': 2, 'c': 3 } } 12904 */ 12905 var defaultsDeep = baseRest(function(args) { 12906 args.push(undefined, customDefaultsMerge); 12907 return apply(mergeWith, undefined, args); 12908 }); 12909 12910 /** 12911 * This method is like `_.find` except that it returns the key of the first 12912 * element `predicate` returns truthy for instead of the element itself. 12913 * 12914 * @static 12915 * @memberOf _ 12916 * @since 1.1.0 12917 * @category Object 12918 * @param {Object} object The object to inspect. 12919 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12920 * @returns {string|undefined} Returns the key of the matched element, 12921 * else `undefined`. 12922 * @example 12923 * 12924 * var users = { 12925 * 'barney': { 'age': 36, 'active': true }, 12926 * 'fred': { 'age': 40, 'active': false }, 12927 * 'pebbles': { 'age': 1, 'active': true } 12928 * }; 12929 * 12930 * _.findKey(users, function(o) { return o.age < 40; }); 12931 * // => 'barney' (iteration order is not guaranteed) 12932 * 12933 * // The `_.matches` iteratee shorthand. 12934 * _.findKey(users, { 'age': 1, 'active': true }); 12935 * // => 'pebbles' 12936 * 12937 * // The `_.matchesProperty` iteratee shorthand. 12938 * _.findKey(users, ['active', false]); 12939 * // => 'fred' 12940 * 12941 * // The `_.property` iteratee shorthand. 12942 * _.findKey(users, 'active'); 12943 * // => 'barney' 12944 */ 12945 function findKey(object, predicate) { 12946 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 12947 } 12948 12949 /** 12950 * This method is like `_.findKey` except that it iterates over elements of 12951 * a collection in the opposite order. 12952 * 12953 * @static 12954 * @memberOf _ 12955 * @since 2.0.0 12956 * @category Object 12957 * @param {Object} object The object to inspect. 12958 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12959 * @returns {string|undefined} Returns the key of the matched element, 12960 * else `undefined`. 12961 * @example 12962 * 12963 * var users = { 12964 * 'barney': { 'age': 36, 'active': true }, 12965 * 'fred': { 'age': 40, 'active': false }, 12966 * 'pebbles': { 'age': 1, 'active': true } 12967 * }; 12968 * 12969 * _.findLastKey(users, function(o) { return o.age < 40; }); 12970 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 12971 * 12972 * // The `_.matches` iteratee shorthand. 12973 * _.findLastKey(users, { 'age': 36, 'active': true }); 12974 * // => 'barney' 12975 * 12976 * // The `_.matchesProperty` iteratee shorthand. 12977 * _.findLastKey(users, ['active', false]); 12978 * // => 'fred' 12979 * 12980 * // The `_.property` iteratee shorthand. 12981 * _.findLastKey(users, 'active'); 12982 * // => 'pebbles' 12983 */ 12984 function findLastKey(object, predicate) { 12985 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 12986 } 12987 12988 /** 12989 * Iterates over own and inherited enumerable string keyed properties of an 12990 * object and invokes `iteratee` for each property. The iteratee is invoked 12991 * with three arguments: (value, key, object). Iteratee functions may exit 12992 * iteration early by explicitly returning `false`. 12993 * 12994 * @static 12995 * @memberOf _ 12996 * @since 0.3.0 12997 * @category Object 12998 * @param {Object} object The object to iterate over. 12999 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13000 * @returns {Object} Returns `object`. 13001 * @see _.forInRight 13002 * @example 13003 * 13004 * function Foo() { 13005 * this.a = 1; 13006 * this.b = 2; 13007 * } 13008 * 13009 * Foo.prototype.c = 3; 13010 * 13011 * _.forIn(new Foo, function(value, key) { 13012 * console.log(key); 13013 * }); 13014 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 13015 */ 13016 function forIn(object, iteratee) { 13017 return object == null 13018 ? object 13019 : baseFor(object, getIteratee(iteratee, 3), keysIn); 13020 } 13021 13022 /** 13023 * This method is like `_.forIn` except that it iterates over properties of 13024 * `object` in the opposite order. 13025 * 13026 * @static 13027 * @memberOf _ 13028 * @since 2.0.0 13029 * @category Object 13030 * @param {Object} object The object to iterate over. 13031 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13032 * @returns {Object} Returns `object`. 13033 * @see _.forIn 13034 * @example 13035 * 13036 * function Foo() { 13037 * this.a = 1; 13038 * this.b = 2; 13039 * } 13040 * 13041 * Foo.prototype.c = 3; 13042 * 13043 * _.forInRight(new Foo, function(value, key) { 13044 * console.log(key); 13045 * }); 13046 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 13047 */ 13048 function forInRight(object, iteratee) { 13049 return object == null 13050 ? object 13051 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 13052 } 13053 13054 /** 13055 * Iterates over own enumerable string keyed properties of an object and 13056 * invokes `iteratee` for each property. The iteratee is invoked with three 13057 * arguments: (value, key, object). Iteratee functions may exit iteration 13058 * early by explicitly returning `false`. 13059 * 13060 * @static 13061 * @memberOf _ 13062 * @since 0.3.0 13063 * @category Object 13064 * @param {Object} object The object to iterate over. 13065 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13066 * @returns {Object} Returns `object`. 13067 * @see _.forOwnRight 13068 * @example 13069 * 13070 * function Foo() { 13071 * this.a = 1; 13072 * this.b = 2; 13073 * } 13074 * 13075 * Foo.prototype.c = 3; 13076 * 13077 * _.forOwn(new Foo, function(value, key) { 13078 * console.log(key); 13079 * }); 13080 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 13081 */ 13082 function forOwn(object, iteratee) { 13083 return object && baseForOwn(object, getIteratee(iteratee, 3)); 13084 } 13085 13086 /** 13087 * This method is like `_.forOwn` except that it iterates over properties of 13088 * `object` in the opposite order. 13089 * 13090 * @static 13091 * @memberOf _ 13092 * @since 2.0.0 13093 * @category Object 13094 * @param {Object} object The object to iterate over. 13095 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13096 * @returns {Object} Returns `object`. 13097 * @see _.forOwn 13098 * @example 13099 * 13100 * function Foo() { 13101 * this.a = 1; 13102 * this.b = 2; 13103 * } 13104 * 13105 * Foo.prototype.c = 3; 13106 * 13107 * _.forOwnRight(new Foo, function(value, key) { 13108 * console.log(key); 13109 * }); 13110 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 13111 */ 13112 function forOwnRight(object, iteratee) { 13113 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 13114 } 13115 13116 /** 13117 * Creates an array of function property names from own enumerable properties 13118 * of `object`. 13119 * 13120 * @static 13121 * @since 0.1.0 13122 * @memberOf _ 13123 * @category Object 13124 * @param {Object} object The object to inspect. 13125 * @returns {Array} Returns the function names. 13126 * @see _.functionsIn 13127 * @example 13128 * 13129 * function Foo() { 13130 * this.a = _.constant('a'); 13131 * this.b = _.constant('b'); 13132 * } 13133 * 13134 * Foo.prototype.c = _.constant('c'); 13135 * 13136 * _.functions(new Foo); 13137 * // => ['a', 'b'] 13138 */ 13139 function functions(object) { 13140 return object == null ? [] : baseFunctions(object, keys(object)); 13141 } 13142 13143 /** 13144 * Creates an array of function property names from own and inherited 13145 * enumerable properties of `object`. 13146 * 13147 * @static 13148 * @memberOf _ 13149 * @since 4.0.0 13150 * @category Object 13151 * @param {Object} object The object to inspect. 13152 * @returns {Array} Returns the function names. 13153 * @see _.functions 13154 * @example 13155 * 13156 * function Foo() { 13157 * this.a = _.constant('a'); 13158 * this.b = _.constant('b'); 13159 * } 13160 * 13161 * Foo.prototype.c = _.constant('c'); 13162 * 13163 * _.functionsIn(new Foo); 13164 * // => ['a', 'b', 'c'] 13165 */ 13166 function functionsIn(object) { 13167 return object == null ? [] : baseFunctions(object, keysIn(object)); 13168 } 13169 13170 /** 13171 * Gets the value at `path` of `object`. If the resolved value is 13172 * `undefined`, the `defaultValue` is returned in its place. 13173 * 13174 * @static 13175 * @memberOf _ 13176 * @since 3.7.0 13177 * @category Object 13178 * @param {Object} object The object to query. 13179 * @param {Array|string} path The path of the property to get. 13180 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 13181 * @returns {*} Returns the resolved value. 13182 * @example 13183 * 13184 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 13185 * 13186 * _.get(object, 'a[0].b.c'); 13187 * // => 3 13188 * 13189 * _.get(object, ['a', '0', 'b', 'c']); 13190 * // => 3 13191 * 13192 * _.get(object, 'a.b.c', 'default'); 13193 * // => 'default' 13194 */ 13195 function get(object, path, defaultValue) { 13196 var result = object == null ? undefined : baseGet(object, path); 13197 return result === undefined ? defaultValue : result; 13198 } 13199 13200 /** 13201 * Checks if `path` is a direct property of `object`. 13202 * 13203 * @static 13204 * @since 0.1.0 13205 * @memberOf _ 13206 * @category Object 13207 * @param {Object} object The object to query. 13208 * @param {Array|string} path The path to check. 13209 * @returns {boolean} Returns `true` if `path` exists, else `false`. 13210 * @example 13211 * 13212 * var object = { 'a': { 'b': 2 } }; 13213 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 13214 * 13215 * _.has(object, 'a'); 13216 * // => true 13217 * 13218 * _.has(object, 'a.b'); 13219 * // => true 13220 * 13221 * _.has(object, ['a', 'b']); 13222 * // => true 13223 * 13224 * _.has(other, 'a'); 13225 * // => false 13226 */ 13227 function has(object, path) { 13228 return object != null && hasPath(object, path, baseHas); 13229 } 13230 13231 /** 13232 * Checks if `path` is a direct or inherited property of `object`. 13233 * 13234 * @static 13235 * @memberOf _ 13236 * @since 4.0.0 13237 * @category Object 13238 * @param {Object} object The object to query. 13239 * @param {Array|string} path The path to check. 13240 * @returns {boolean} Returns `true` if `path` exists, else `false`. 13241 * @example 13242 * 13243 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 13244 * 13245 * _.hasIn(object, 'a'); 13246 * // => true 13247 * 13248 * _.hasIn(object, 'a.b'); 13249 * // => true 13250 * 13251 * _.hasIn(object, ['a', 'b']); 13252 * // => true 13253 * 13254 * _.hasIn(object, 'b'); 13255 * // => false 13256 */ 13257 function hasIn(object, path) { 13258 return object != null && hasPath(object, path, baseHasIn); 13259 } 13260 13261 /**
vendor: 1,026 bytes, lines 13262-13291
13262 * Creates an object composed of the inverted keys and values of `object`. 13263 * If `object` contains duplicate values, subsequent values overwrite 13264 * property assignments of previous values. 13265 * 13266 * @static 13267 * @memberOf _ 13268 * @since 0.7.0 13269 * @category Object 13270 * @param {Object} object The object to invert. 13271 * @returns {Object} Returns the new inverted object. 13272 * @example 13273 * 13274 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 13275 * 13276 * _.invert(object); 13277 * // => { '1': 'c', '2': 'b' } 13278 */ 13279 var invert = createInverter(function(result, value, key) { 13280 if (value != null && 13281 typeof value.toString != 'function') { 13282 value = nativeObjectToString.call(value); 13283 } 13284 13285 result[value] = key; 13286 }, constant(identity)); 13287 13288 /** 13289 * This method is like `_.invert` except that the inverted object is generated 13290 * from the results of running each element of `object` thru `iteratee`. The 13291 * corresponding inverted value of each inverted key
vendor: 10,822 bytes, lines 13291-13632
13291is an array of keys 13292 * responsible for generating the inverted value. The iteratee is invoked 13293 * with one argument: (value). 13294 * 13295 * @static 13296 * @memberOf _ 13297 * @since 4.1.0 13298 * @category Object 13299 * @param {Object} object The object to invert. 13300 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13301 * @returns {Object} Returns the new inverted object. 13302 * @example 13303 * 13304 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 13305 * 13306 * _.invertBy(object); 13307 * // => { '1': ['a', 'c'], '2': ['b'] } 13308 * 13309 * _.invertBy(object, function(value) { 13310 * return 'group' + value; 13311 * }); 13312 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 13313 */ 13314 var invertBy = createInverter(function(result, value, key) { 13315 if (value != null && 13316 typeof value.toString != 'function') { 13317 value = nativeObjectToString.call(value); 13318 } 13319 13320 if (hasOwnProperty.call(result, value)) { 13321 result[value].push(key); 13322 } else { 13323 result[value] = [key]; 13324 } 13325 }, getIteratee); 13326 13327 /** 13328 * Invokes the method at `path` of `object`. 13329 * 13330 * @static 13331 * @memberOf _ 13332 * @since 4.0.0 13333 * @category Object 13334 * @param {Object} object The object to query. 13335 * @param {Array|string} path The path of the method to invoke. 13336 * @param {...*} [args] The arguments to invoke the method with. 13337 * @returns {*} Returns the result of the invoked method. 13338 * @example 13339 * 13340 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 13341 * 13342 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 13343 * // => [2, 3] 13344 */ 13345 var invoke = baseRest(baseInvoke); 13346 13347 /** 13348 * Creates an array of the own enumerable property names of `object`. 13349 * 13350 * **Note:** Non-object values are coerced to objects. See the 13351 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 13352 * for more details. 13353 * 13354 * @static 13355 * @since 0.1.0 13356 * @memberOf _ 13357 * @category Object 13358 * @param {Object} object The object to query. 13359 * @returns {Array} Returns the array of property names. 13360 * @example 13361 * 13362 * function Foo() { 13363 * this.a = 1; 13364 * this.b = 2; 13365 * } 13366 * 13367 * Foo.prototype.c = 3; 13368 * 13369 * _.keys(new Foo); 13370 * // => ['a', 'b'] (iteration order is not guaranteed) 13371 * 13372 * _.keys('hi'); 13373 * // => ['0', '1'] 13374 */ 13375 function keys(object) { 13376 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 13377 } 13378 13379 /** 13380 * Creates an array of the own and inherited enumerable property names of `object`. 13381 * 13382 * **Note:** Non-object values are coerced to objects. 13383 * 13384 * @static 13385 * @memberOf _ 13386 * @since 3.0.0 13387 * @category Object 13388 * @param {Object} object The object to query. 13389 * @returns {Array} Returns the array of property names. 13390 * @example 13391 * 13392 * function Foo() { 13393 * this.a = 1; 13394 * this.b = 2; 13395 * } 13396 * 13397 * Foo.prototype.c = 3; 13398 * 13399 * _.keysIn(new Foo); 13400 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 13401 */ 13402 function keysIn(object) { 13403 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 13404 } 13405 13406 /** 13407 * The opposite of `_.mapValues`; this method creates an object with the 13408 * same values as `object` and keys generated by running each own enumerable 13409 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 13410 * with three arguments: (value, key, object). 13411 * 13412 * @static 13413 * @memberOf _ 13414 * @since 3.8.0 13415 * @category Object 13416 * @param {Object} object The object to iterate over. 13417 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13418 * @returns {Object} Returns the new mapped object. 13419 * @see _.mapValues 13420 * @example 13421 * 13422 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 13423 * return key + value; 13424 * }); 13425 * // => { 'a1': 1, 'b2': 2 } 13426 */ 13427 function mapKeys(object, iteratee) { 13428 var result = {}; 13429 iteratee = getIteratee(iteratee, 3); 13430 13431 baseForOwn(object, function(value, key, object) { 13432 baseAssignValue(result, iteratee(value, key, object), value); 13433 }); 13434 return result; 13435 } 13436 13437 /** 13438 * Creates an object with the same keys as `object` and values generated 13439 * by running each own enumerable string keyed property of `object` thru 13440 * `iteratee`. The iteratee is invoked with three arguments: 13441 * (value, key, object). 13442 * 13443 * @static 13444 * @memberOf _ 13445 * @since 2.4.0 13446 * @category Object 13447 * @param {Object} object The object to iterate over. 13448 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13449 * @returns {Object} Returns the new mapped object. 13450 * @see _.mapKeys 13451 * @example 13452 * 13453 * var users = { 13454 * 'fred': { 'user': 'fred', 'age': 40 }, 13455 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 13456 * }; 13457 * 13458 * _.mapValues(users, function(o) { return o.age; }); 13459 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 13460 * 13461 * // The `_.property` iteratee shorthand. 13462 * _.mapValues(users, 'age'); 13463 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 13464 */ 13465 function mapValues(object, iteratee) { 13466 var result = {}; 13467 iteratee = getIteratee(iteratee, 3); 13468 13469 baseForOwn(object, function(value, key, object) { 13470 baseAssignValue(result, key, iteratee(value, key, object)); 13471 }); 13472 return result; 13473 } 13474 13475 /** 13476 * This method is like `_.assign` except that it recursively merges own and 13477 * inherited enumerable string keyed properties of source objects into the 13478 * destination object. Source properties that resolve to `undefined` are 13479 * skipped if a destination value exists. Array and plain object properties 13480 * are merged recursively. Other objects and value types are overridden by 13481 * assignment. Source objects are applied from left to right. Subsequent 13482 * sources overwrite property assignments of previous sources. 13483 * 13484 * **Note:** This method mutates `object`. 13485 * 13486 * @static 13487 * @memberOf _ 13488 * @since 0.5.0 13489 * @category Object 13490 * @param {Object} object The destination object. 13491 * @param {...Object} [sources] The source objects. 13492 * @returns {Object} Returns `object`. 13493 * @example 13494 * 13495 * var object = { 13496 * 'a': [{ 'b': 2 }, { 'd': 4 }] 13497 * }; 13498 * 13499 * var other = { 13500 * 'a': [{ 'c': 3 }, { 'e': 5 }] 13501 * }; 13502 * 13503 * _.merge(object, other); 13504 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 13505 */ 13506 var merge = createAssigner(function(object, source, srcIndex) { 13507 baseMerge(object, source, srcIndex); 13508 }); 13509 13510 /** 13511 * This method is like `_.merge` except that it accepts `customizer` which 13512 * is invoked to produce the merged values of the destination and source 13513 * properties. If `customizer` returns `undefined`, merging is handled by the 13514 * method instead. The `customizer` is invoked with six arguments: 13515 * (objValue, srcValue, key, object, source, stack). 13516 * 13517 * **Note:** This method mutates `object`. 13518 * 13519 * @static 13520 * @memberOf _ 13521 * @since 4.0.0 13522 * @category Object 13523 * @param {Object} object The destination object. 13524 * @param {...Object} sources The source objects. 13525 * @param {Function} customizer The function to customize assigned values. 13526 * @returns {Object} Returns `object`. 13527 * @example 13528 * 13529 * function customizer(objValue, srcValue) { 13530 * if (_.isArray(objValue)) { 13531 * return objValue.concat(srcValue); 13532 * } 13533 * } 13534 * 13535 * var object = { 'a': [1], 'b': [2] }; 13536 * var other = { 'a': [3], 'b': [4] }; 13537 * 13538 * _.mergeWith(object, other, customizer); 13539 * // => { 'a': [1, 3], 'b': [2, 4] } 13540 */ 13541 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 13542 baseMerge(object, source, srcIndex, customizer); 13543 }); 13544 13545 /** 13546 * The opposite of `_.pick`; this method creates an object composed of the 13547 * own and inherited enumerable property paths of `object` that are not omitted. 13548 * 13549 * **Note:** This method is considerably slower than `_.pick`. 13550 * 13551 * @static 13552 * @since 0.1.0 13553 * @memberOf _ 13554 * @category Object 13555 * @param {Object} object The source object. 13556 * @param {...(string|string[])} [paths] The property paths to omit. 13557 * @returns {Object} Returns the new object. 13558 * @example 13559 * 13560 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13561 * 13562 * _.omit(object, ['a', 'c']); 13563 * // => { 'b': '2' } 13564 */ 13565 var omit = flatRest(function(object, paths) { 13566 var result = {}; 13567 if (object == null) { 13568 return result; 13569 } 13570 var isDeep = false; 13571 paths = arrayMap(paths, function(path) { 13572 path = castPath(path, object); 13573 isDeep || (isDeep = path.length > 1); 13574 return path; 13575 }); 13576 copyObject(object, getAllKeysIn(object), result); 13577 if (isDeep) { 13578 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 13579 } 13580 var length = paths.length; 13581 while (length--) { 13582 baseUnset(result, paths[length]); 13583 } 13584 return result; 13585 }); 13586 13587 /** 13588 * The opposite of `_.pickBy`; this method creates an object composed of 13589 * the own and inherited enumerable string keyed properties of `object` that 13590 * `predicate` doesn't return truthy for. The predicate is invoked with two 13591 * arguments: (value, key). 13592 * 13593 * @static 13594 * @memberOf _ 13595 * @since 4.0.0 13596 * @category Object 13597 * @param {Object} object The source object. 13598 * @param {Function} [predicate=_.identity] The function invoked per property. 13599 * @returns {Object} Returns the new object. 13600 * @example 13601 * 13602 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13603 * 13604 * _.omitBy(object, _.isNumber); 13605 * // => { 'b': '2' } 13606 */ 13607 function omitBy(object, predicate) { 13608 return pickBy(object, negate(getIteratee(predicate))); 13609 } 13610 13611 /** 13612 * Creates an object composed of the picked `object` properties. 13613 * 13614 * @static 13615 * @since 0.1.0 13616 * @memberOf _ 13617 * @category Object 13618 * @param {Object} object The source object. 13619 * @param {...(string|string[])} [paths] The property paths to pick. 13620 * @returns {Object} Returns the new object. 13621 * @example 13622 * 13623 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13624 * 13625 * _.pick(object, ['a', 'c']); 13626 * // => { 'a': 1, 'c': 3 } 13627 */ 13628 var pick = flatRest(function(object, paths) { 13629 return object == null ? {} : basePick(object, paths); 13630 }); 13631 13632 /**
vendor: 11,160 bytes, lines 13633-13971
13633 * Creates an object composed of the `object` properties `predicate` returns 13634 * truthy for. The predicate is invoked with two arguments: (value, key). 13635 * 13636 * @static 13637 * @memberOf _ 13638 * @since 4.0.0 13639 * @category Object 13640 * @param {Object} object The source object. 13641 * @param {Function} [predicate=_.identity] The function invoked per property. 13642 * @returns {Object} Returns the new object. 13643 * @example 13644 * 13645 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13646 * 13647 * _.pickBy(object, _.isNumber); 13648 * // => { 'a': 1, 'c': 3 } 13649 */ 13650 function pickBy(object, predicate) { 13651 if (object == null) { 13652 return {}; 13653 } 13654 var props = arrayMap(getAllKeysIn(object), function(prop) { 13655 return [prop]; 13656 }); 13657 predicate = getIteratee(predicate); 13658 return basePickBy(object, props, function(value, path) { 13659 return predicate(value, path[0]); 13660 }); 13661 } 13662 13663 /** 13664 * This method is like `_.get` except that if the resolved value is a 13665 * function it's invoked with the `this` binding of its parent object and 13666 * its result is returned. 13667 * 13668 * @static 13669 * @since 0.1.0 13670 * @memberOf _ 13671 * @category Object 13672 * @param {Object} object The object to query. 13673 * @param {Array|string} path The path of the property to resolve. 13674 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 13675 * @returns {*} Returns the resolved value. 13676 * @example 13677 * 13678 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 13679 * 13680 * _.result(object, 'a[0].b.c1'); 13681 * // => 3 13682 * 13683 * _.result(object, 'a[0].b.c2'); 13684 * // => 4 13685 * 13686 * _.result(object, 'a[0].b.c3', 'default'); 13687 * // => 'default' 13688 * 13689 * _.result(object, 'a[0].b.c3', _.constant('default')); 13690 * // => 'default' 13691 */ 13692 function result(object, path, defaultValue) { 13693 path = castPath(path, object); 13694 13695 var index = -1, 13696 length = path.length; 13697 13698 // Ensure the loop is entered when path is empty. 13699 if (!length) { 13700 length = 1; 13701 object = undefined; 13702 } 13703 while (++index < length) { 13704 var value = object == null ? undefined : object[toKey(path[index])]; 13705 if (value === undefined) { 13706 index = length; 13707 value = defaultValue; 13708 } 13709 object = isFunction(value) ? value.call(object) : value; 13710 } 13711 return object; 13712 } 13713 13714 /** 13715 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 13716 * it's created. Arrays are created for missing index properties while objects 13717 * are created for all other missing properties. Use `_.setWith` to customize 13718 * `path` creation. 13719 * 13720 * **Note:** This method mutates `object`. 13721 * 13722 * @static 13723 * @memberOf _ 13724 * @since 3.7.0 13725 * @category Object 13726 * @param {Object} object The object to modify. 13727 * @param {Array|string} path The path of the property to set. 13728 * @param {*} value The value to set. 13729 * @returns {Object} Returns `object`. 13730 * @example 13731 * 13732 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 13733 * 13734 * _.set(object, 'a[0].b.c', 4); 13735 * console.log(object.a[0].b.c); 13736 * // => 4 13737 * 13738 * _.set(object, ['x', '0', 'y', 'z'], 5); 13739 * console.log(object.x[0].y.z); 13740 * // => 5 13741 */ 13742 function set(object, path, value) { 13743 return object == null ? object : baseSet(object, path, value); 13744 } 13745 13746 /** 13747 * This method is like `_.set` except that it accepts `customizer` which is 13748 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 13749 * path creation is handled by the method instead. The `customizer` is invoked 13750 * with three arguments: (nsValue, key, nsObject). 13751 * 13752 * **Note:** This method mutates `object`. 13753 * 13754 * @static 13755 * @memberOf _ 13756 * @since 4.0.0 13757 * @category Object 13758 * @param {Object} object The object to modify. 13759 * @param {Array|string} path The path of the property to set. 13760 * @param {*} value The value to set. 13761 * @param {Function} [customizer] The function to customize assigned values. 13762 * @returns {Object} Returns `object`. 13763 * @example 13764 * 13765 * var object = {}; 13766 * 13767 * _.setWith(object, '[0][1]', 'a', Object); 13768 * // => { '0': { '1': 'a' } } 13769 */ 13770 function setWith(object, path, value, customizer) { 13771 customizer = typeof customizer == 'function' ? customizer : undefined; 13772 return object == null ? object : baseSet(object, path, value, customizer); 13773 } 13774 13775 /** 13776 * Creates an array of own enumerable string keyed-value pairs for `object` 13777 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 13778 * entries are returned. 13779 * 13780 * @static 13781 * @memberOf _ 13782 * @since 4.0.0 13783 * @alias entries 13784 * @category Object 13785 * @param {Object} object The object to query. 13786 * @returns {Array} Returns the key-value pairs. 13787 * @example 13788 * 13789 * function Foo() { 13790 * this.a = 1; 13791 * this.b = 2; 13792 * } 13793 * 13794 * Foo.prototype.c = 3; 13795 * 13796 * _.toPairs(new Foo); 13797 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 13798 */ 13799 var toPairs = createToPairs(keys); 13800 13801 /** 13802 * Creates an array of own and inherited enumerable string keyed-value pairs 13803 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 13804 * or set, its entries are returned. 13805 * 13806 * @static 13807 * @memberOf _ 13808 * @since 4.0.0 13809 * @alias entriesIn 13810 * @category Object 13811 * @param {Object} object The object to query. 13812 * @returns {Array} Returns the key-value pairs. 13813 * @example 13814 * 13815 * function Foo() { 13816 * this.a = 1; 13817 * this.b = 2; 13818 * } 13819 * 13820 * Foo.prototype.c = 3; 13821 * 13822 * _.toPairsIn(new Foo); 13823 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 13824 */ 13825 var toPairsIn = createToPairs(keysIn); 13826 13827 /** 13828 * An alternative to `_.reduce`; this method transforms `object` to a new 13829 * `accumulator` object which is the result of running each of its own 13830 * enumerable string keyed properties thru `iteratee`, with each invocation 13831 * potentially mutating the `accumulator` object. If `accumulator` is not 13832 * provided, a new object with the same `[[Prototype]]` will be used. The 13833 * iteratee is invoked with four arguments: (accumulator, value, key, object). 13834 * Iteratee functions may exit iteration early by explicitly returning `false`. 13835 * 13836 * @static 13837 * @memberOf _ 13838 * @since 1.3.0 13839 * @category Object 13840 * @param {Object} object The object to iterate over. 13841 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13842 * @param {*} [accumulator] The custom accumulator value. 13843 * @returns {*} Returns the accumulated value. 13844 * @example 13845 * 13846 * _.transform([2, 3, 4], function(result, n) { 13847 * result.push(n *= n); 13848 * return n % 2 == 0; 13849 * }, []); 13850 * // => [4, 9] 13851 * 13852 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 13853 * (result[value] || (result[value] = [])).push(key); 13854 * }, {}); 13855 * // => { '1': ['a', 'c'], '2': ['b'] } 13856 */ 13857 function transform(object, iteratee, accumulator) { 13858 var isArr = isArray(object), 13859 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 13860 13861 iteratee = getIteratee(iteratee, 4); 13862 if (accumulator == null) { 13863 var Ctor = object && object.constructor; 13864 if (isArrLike) { 13865 accumulator = isArr ? new Ctor : []; 13866 } 13867 else if (isObject(object)) { 13868 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 13869 } 13870 else { 13871 accumulator = {}; 13872 } 13873 } 13874 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 13875 return iteratee(accumulator, value, index, object); 13876 }); 13877 return accumulator; 13878 } 13879 13880 /** 13881 * Removes the property at `path` of `object`. 13882 * 13883 * **Note:** This method mutates `object`. 13884 * 13885 * @static 13886 * @memberOf _ 13887 * @since 4.0.0 13888 * @category Object 13889 * @param {Object} object The object to modify. 13890 * @param {Array|string} path The path of the property to unset. 13891 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 13892 * @example 13893 * 13894 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 13895 * _.unset(object, 'a[0].b.c'); 13896 * // => true 13897 * 13898 * console.log(object); 13899 * // => { 'a': [{ 'b': {} }] }; 13900 * 13901 * _.unset(object, ['a', '0', 'b', 'c']); 13902 * // => true 13903 * 13904 * console.log(object); 13905 * // => { 'a': [{ 'b': {} }] }; 13906 */ 13907 function unset(object, path) { 13908 return object == null ? true : baseUnset(object, path); 13909 } 13910 13911 /** 13912 * This method is like `_.set` except that accepts `updater` to produce the 13913 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 13914 * is invoked with one argument: (value). 13915 * 13916 * **Note:** This method mutates `object`. 13917 * 13918 * @static 13919 * @memberOf _ 13920 * @since 4.6.0 13921 * @category Object 13922 * @param {Object} object The object to modify. 13923 * @param {Array|string} path The path of the property to set. 13924 * @param {Function} updater The function to produce the updated value. 13925 * @returns {Object} Returns `object`. 13926 * @example 13927 * 13928 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 13929 * 13930 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 13931 * console.log(object.a[0].b.c); 13932 * // => 9 13933 * 13934 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 13935 * console.log(object.x[0].y.z); 13936 * // => 0 13937 */ 13938 function update(object, path, updater) { 13939 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 13940 } 13941 13942 /** 13943 * This method is like `_.update` except that it accepts `customizer` which is 13944 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 13945 * path creation is handled by the method instead. The `customizer` is invoked 13946 * with three arguments: (nsValue, key, nsObject). 13947 * 13948 * **Note:** This method mutates `object`. 13949 * 13950 * @static 13951 * @memberOf _ 13952 * @since 4.6.0 13953 * @category Object 13954 * @param {Object} object The object to modify. 13955 * @param {Array|string} path The path of the property to set. 13956 * @param {Function} updater The function to produce the updated value. 13957 * @param {Function} [customizer] The function to customize assigned values. 13958 * @returns {Object} Returns `object`. 13959 * @example 13960 * 13961 * var object = {}; 13962 * 13963 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 13964 * // => { '0': { '1': 'a' } } 13965 */ 13966 function updateWith(object, path, updater, customizer) { 13967 customizer = typeof customizer == 'function' ? customizer : undefined; 13968 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 13969 } 13970 13971 /**
vendor: 1,263 bytes, lines 13972-14021
13972 * Creates an array of the own enumerable string keyed property values of `object`. 13973 * 13974 * **Note:** Non-object values are coerced to objects. 13975 * 13976 * @static 13977 * @since 0.1.0 13978 * @memberOf _ 13979 * @category Object 13980 * @param {Object} object The object to query. 13981 * @returns {Array} Returns the array of property values. 13982 * @example 13983 * 13984 * function Foo() { 13985 * this.a = 1; 13986 * this.b = 2; 13987 * } 13988 * 13989 * Foo.prototype.c = 3; 13990 * 13991 * _.values(new Foo); 13992 * // => [1, 2] (iteration order is not guaranteed) 13993 * 13994 * _.values('hi'); 13995 * // => ['h', 'i'] 13996 */ 13997 function values(object) { 13998 return object == null ? [] : baseValues(object, keys(object)); 13999 } 14000 14001 /** 14002 * Creates an array of the own and inherited enumerable string keyed property 14003 * values of `object`. 14004 * 14005 * **Note:** Non-object values are coerced to objects. 14006 * 14007 * @static 14008 * @memberOf _ 14009 * @since 3.0.0 14010 * @category Object 14011 * @param {Object} object The object to query. 14012 * @returns {Array} Returns the array of property values. 14013 * @example 14014 * 14015 * function Foo() { 14016 * this.a = 1; 14017 * this.b = 2; 14018 * } 14019 * 14020 * Foo.prototype.c = 3; 14021 *
vendor: 9,679 bytes, lines 14022-14342
14022 * _.valuesIn(new Foo); 14023 * // => [1, 2, 3] (iteration order is not guaranteed) 14024 */ 14025 function valuesIn(object) { 14026 return object == null ? [] : baseValues(object, keysIn(object)); 14027 } 14028 14029 /*------------------------------------------------------------------------*/ 14030 14031 /** 14032 * Clamps `number` within the inclusive `lower` and `upper` bounds. 14033 * 14034 * @static 14035 * @memberOf _ 14036 * @since 4.0.0 14037 * @category Number 14038 * @param {number} number The number to clamp. 14039 * @param {number} [lower] The lower bound. 14040 * @param {number} upper The upper bound. 14041 * @returns {number} Returns the clamped number. 14042 * @example 14043 * 14044 * _.clamp(-10, -5, 5); 14045 * // => -5 14046 * 14047 * _.clamp(10, -5, 5); 14048 * // => 5 14049 */ 14050 function clamp(number, lower, upper) { 14051 if (upper === undefined) { 14052 upper = lower; 14053 lower = undefined; 14054 } 14055 if (upper !== undefined) { 14056 upper = toNumber(upper); 14057 upper = upper === upper ? upper : 0; 14058 } 14059 if (lower !== undefined) { 14060 lower = toNumber(lower); 14061 lower = lower === lower ? lower : 0; 14062 } 14063 return baseClamp(toNumber(number), lower, upper); 14064 } 14065 14066 /** 14067 * Checks if `n` is between `start` and up to, but not including, `end`. If 14068 * `end` is not specified, it's set to `start` with `start` then set to `0`. 14069 * If `start` is greater than `end` the params are swapped to support 14070 * negative ranges. 14071 * 14072 * @static 14073 * @memberOf _ 14074 * @since 3.3.0 14075 * @category Number 14076 * @param {number} number The number to check. 14077 * @param {number} [start=0] The start of the range. 14078 * @param {number} end The end of the range. 14079 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 14080 * @see _.range, _.rangeRight 14081 * @example 14082 * 14083 * _.inRange(3, 2, 4); 14084 * // => true 14085 * 14086 * _.inRange(4, 8); 14087 * // => true 14088 * 14089 * _.inRange(4, 2); 14090 * // => false 14091 * 14092 * _.inRange(2, 2); 14093 * // => false 14094 * 14095 * _.inRange(1.2, 2); 14096 * // => true 14097 * 14098 * _.inRange(5.2, 4); 14099 * // => false 14100 * 14101 * _.inRange(-3, -2, -6); 14102 * // => true 14103 */ 14104 function inRange(number, start, end) { 14105 start = toFinite(start); 14106 if (end === undefined) { 14107 end = start; 14108 start = 0; 14109 } else { 14110 end = toFinite(end); 14111 } 14112 number = toNumber(number); 14113 return baseInRange(number, start, end); 14114 } 14115 14116 /** 14117 * Produces a random number between the inclusive `lower` and `upper` bounds. 14118 * If only one argument is provided a number between `0` and the given number 14119 * is returned. If `floating` is `true`, or either `lower` or `upper` are 14120 * floats, a floating-point number is returned instead of an integer. 14121 * 14122 * **Note:** JavaScript follows the IEEE-754 standard for resolving 14123 * floating-point values which can produce unexpected results. 14124 * 14125 * @static 14126 * @memberOf _ 14127 * @since 0.7.0 14128 * @category Number 14129 * @param {number} [lower=0] The lower bound. 14130 * @param {number} [upper=1] The upper bound. 14131 * @param {boolean} [floating] Specify returning a floating-point number. 14132 * @returns {number} Returns the random number. 14133 * @example 14134 * 14135 * _.random(0, 5); 14136 * // => an integer between 0 and 5 14137 * 14138 * _.random(5); 14139 * // => also an integer between 0 and 5 14140 * 14141 * _.random(5, true); 14142 * // => a floating-point number between 0 and 5 14143 * 14144 * _.random(1.2, 5.2); 14145 * // => a floating-point number between 1.2 and 5.2 14146 */ 14147 function random(lower, upper, floating) { 14148 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 14149 upper = floating = undefined; 14150 } 14151 if (floating === undefined) { 14152 if (typeof upper == 'boolean') { 14153 floating = upper; 14154 upper = undefined; 14155 } 14156 else if (typeof lower == 'boolean') { 14157 floating = lower; 14158 lower = undefined; 14159 } 14160 } 14161 if (lower === undefined && upper === undefined) { 14162 lower = 0; 14163 upper = 1; 14164 } 14165 else { 14166 lower = toFinite(lower); 14167 if (upper === undefined) { 14168 upper = lower; 14169 lower = 0; 14170 } else { 14171 upper = toFinite(upper); 14172 } 14173 } 14174 if (lower > upper) { 14175 var temp = lower; 14176 lower = upper; 14177 upper = temp; 14178 } 14179 if (floating || lower % 1 || upper % 1) { 14180 var rand = nativeRandom(); 14181 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 14182 } 14183 return baseRandom(lower, upper); 14184 } 14185 14186 /*------------------------------------------------------------------------*/ 14187 14188 /** 14189 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 14190 * 14191 * @static 14192 * @memberOf _ 14193 * @since 3.0.0 14194 * @category String 14195 * @param {string} [string=''] The string to convert. 14196 * @returns {string} Returns the camel cased string. 14197 * @example 14198 * 14199 * _.camelCase('Foo Bar'); 14200 * // => 'fooBar' 14201 * 14202 * _.camelCase('--foo-bar--'); 14203 * // => 'fooBar' 14204 * 14205 * _.camelCase('__FOO_BAR__'); 14206 * // => 'fooBar' 14207 */ 14208 var camelCase = createCompounder(function(result, word, index) { 14209 word = word.toLowerCase(); 14210 return result + (index ? capitalize(word) : word); 14211 }); 14212 14213 /** 14214 * Converts the first character of `string` to upper case and the remaining 14215 * to lower case. 14216 * 14217 * @static 14218 * @memberOf _ 14219 * @since 3.0.0 14220 * @category String 14221 * @param {string} [string=''] The string to capitalize. 14222 * @returns {string} Returns the capitalized string. 14223 * @example 14224 * 14225 * _.capitalize('FRED'); 14226 * // => 'Fred' 14227 */ 14228 function capitalize(string) { 14229 return upperFirst(toString(string).toLowerCase()); 14230 } 14231 14232 /** 14233 * Deburrs `string` by converting 14234 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 14235 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 14236 * letters to basic Latin letters and removing 14237 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 14238 * 14239 * @static 14240 * @memberOf _ 14241 * @since 3.0.0 14242 * @category String 14243 * @param {string} [string=''] The string to deburr. 14244 * @returns {string} Returns the deburred string. 14245 * @example 14246 * 14247 * _.deburr('déjàvu'); 14248 * // => 'deja vu' 14249 */ 14250 function deburr(string) { 14251 string = toString(string); 14252 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 14253 } 14254 14255 /** 14256 * Checks if `string` ends with the given target string. 14257 * 14258 * @static 14259 * @memberOf _ 14260 * @since 3.0.0 14261 * @category String 14262 * @param {string} [string=''] The string to inspect. 14263 * @param {string} [target] The string to search for. 14264 * @param {number} [position=string.length] The position to search up to. 14265 * @returns {boolean} Returns `true` if `string` ends with `target`, 14266 * else `false`. 14267 * @example 14268 * 14269 * _.endsWith('abc', 'c'); 14270 * // => true 14271 * 14272 * _.endsWith('abc', 'b'); 14273 * // => false 14274 * 14275 * _.endsWith('abc', 'b', 2); 14276 * // => true 14277 */ 14278 function endsWith(string, target, position) { 14279 string = toString(string); 14280 target = baseToString(target); 14281 14282 var length = string.length; 14283 position = position === undefined 14284 ? length 14285 : baseClamp(toInteger(position), 0, length); 14286 14287 var end = position; 14288 position -= target.length; 14289 return position >= 0 && string.slice(position, end) == target; 14290 } 14291 14292 /** 14293 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 14294 * corresponding HTML entities. 14295 * 14296 * **Note:** No other characters are escaped. To escape additional 14297 * characters use a third-party library like [_he_](https://mths.be/he). 14298 * 14299 * Though the ">" character is escaped for symmetry, characters like 14300 * ">" and "/" don't need escaping in HTML and have no special meaning 14301 * unless they're part of a tag or unquoted attribute value. See 14302 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 14303 * (under "semi-related fun fact") for more details. 14304 * 14305 * When working with HTML you should always 14306 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 14307 * XSS vectors. 14308 * 14309 * @static 14310 * @since 0.1.0 14311 * @memberOf _ 14312 * @category String 14313 * @param {string} [string=''] The string to escape. 14314 * @returns {string} Returns the escaped string. 14315 * @example 14316 * 14317 * _.escape('fred, barney, & pebbles'); 14318 * // => 'fred, barney, & pebbles' 14319 */ 14320 function escape(string) { 14321 string = toString(string); 14322 return (string && reHasUnescapedHtml.test(string)) 14323 ? string.replace(reUnescapedHtml, escapeHtmlChar) 14324 : string; 14325 } 14326 14327 /** 14328 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 14329 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 14330 * 14331 * @static 14332 * @memberOf _ 14333 * @since 3.0.0 14334 * @category String 14335 * @param {string} [string=''] The string to escape. 14336 * @returns {string} Returns the escaped string. 14337 * @example 14338 * 14339 * _.escapeRegExp('[lodash](https://lodash.com/)'); 14340 * // => '\[lodash\]\(https://lodash\.com/\)' 14341 */ 14342 function escapeRegExp(string) {
vendor: 4,658 bytes, lines 14343-14512
14343 string = toString(string); 14344 return (string && reHasRegExpChar.test(string)) 14345 ? string.replace(reRegExpChar, '\\$&') 14346 : string; 14347 } 14348 14349 /** 14350 * Converts `string` to 14351 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 14352 * 14353 * @static 14354 * @memberOf _ 14355 * @since 3.0.0 14356 * @category String 14357 * @param {string} [string=''] The string to convert. 14358 * @returns {string} Returns the kebab cased string. 14359 * @example 14360 * 14361 * _.kebabCase('Foo Bar'); 14362 * // => 'foo-bar' 14363 * 14364 * _.kebabCase('fooBar'); 14365 * // => 'foo-bar' 14366 * 14367 * _.kebabCase('__FOO_BAR__'); 14368 * // => 'foo-bar' 14369 */ 14370 var kebabCase = createCompounder(function(result, word, index) { 14371 return result + (index ? '-' : '') + word.toLowerCase(); 14372 }); 14373 14374 /** 14375 * Converts `string`, as space separated words, to lower case. 14376 * 14377 * @static 14378 * @memberOf _ 14379 * @since 4.0.0 14380 * @category String 14381 * @param {string} [string=''] The string to convert. 14382 * @returns {string} Returns the lower cased string. 14383 * @example 14384 * 14385 * _.lowerCase('--Foo-Bar--'); 14386 * // => 'foo bar' 14387 * 14388 * _.lowerCase('fooBar'); 14389 * // => 'foo bar' 14390 * 14391 * _.lowerCase('__FOO_BAR__'); 14392 * // => 'foo bar' 14393 */ 14394 var lowerCase = createCompounder(function(result, word, index) { 14395 return result + (index ? ' ' : '') + word.toLowerCase(); 14396 }); 14397 14398 /** 14399 * Converts the first character of `string` to lower case. 14400 * 14401 * @static 14402 * @memberOf _ 14403 * @since 4.0.0 14404 * @category String 14405 * @param {string} [string=''] The string to convert. 14406 * @returns {string} Returns the converted string. 14407 * @example 14408 * 14409 * _.lowerFirst('Fred'); 14410 * // => 'fred' 14411 * 14412 * _.lowerFirst('FRED'); 14413 * // => 'fRED' 14414 */ 14415 var lowerFirst = createCaseFirst('toLowerCase'); 14416 14417 /** 14418 * Pads `string` on the left and right sides if it's shorter than `length`. 14419 * Padding characters are truncated if they can't be evenly divided by `length`. 14420 * 14421 * @static 14422 * @memberOf _ 14423 * @since 3.0.0 14424 * @category String 14425 * @param {string} [string=''] The string to pad. 14426 * @param {number} [length=0] The padding length. 14427 * @param {string} [chars=' '] The string used as padding. 14428 * @returns {string} Returns the padded string. 14429 * @example 14430 * 14431 * _.pad('abc', 8); 14432 * // => ' abc ' 14433 * 14434 * _.pad('abc', 8, '_-'); 14435 * // => '_-abc_-_' 14436 * 14437 * _.pad('abc', 3); 14438 * // => 'abc' 14439 */ 14440 function pad(string, length, chars) { 14441 string = toString(string); 14442 length = toInteger(length); 14443 14444 var strLength = length ? stringSize(string) : 0; 14445 if (!length || strLength >= length) { 14446 return string; 14447 } 14448 var mid = (length - strLength) / 2; 14449 return ( 14450 createPadding(nativeFloor(mid), chars) + 14451 string + 14452 createPadding(nativeCeil(mid), chars) 14453 ); 14454 } 14455 14456 /** 14457 * Pads `string` on the right side if it's shorter than `length`. Padding 14458 * characters are truncated if they exceed `length`. 14459 * 14460 * @static 14461 * @memberOf _ 14462 * @since 4.0.0 14463 * @category String 14464 * @param {string} [string=''] The string to pad. 14465 * @param {number} [length=0] The padding length. 14466 * @param {string} [chars=' '] The string used as padding. 14467 * @returns {string} Returns the padded string. 14468 * @example 14469 * 14470 * _.padEnd('abc', 6); 14471 * // => 'abc ' 14472 * 14473 * _.padEnd('abc', 6, '_-'); 14474 * // => 'abc_-_' 14475 * 14476 * _.padEnd('abc', 3); 14477 * // => 'abc' 14478 */ 14479 function padEnd(string, length, chars) { 14480 string = toString(string); 14481 length = toInteger(length); 14482 14483 var strLength = length ? stringSize(string) : 0; 14484 return (length && strLength < length) 14485 ? (string + createPadding(length - strLength, chars)) 14486 : string; 14487 } 14488 14489 /** 14490 * Pads `string` on the left side if it's shorter than `length`. Padding 14491 * characters are truncated if they exceed `length`. 14492 * 14493 * @static 14494 * @memberOf _ 14495 * @since 4.0.0 14496 * @category String 14497 * @param {string} [string=''] The string to pad. 14498 * @param {number} [length=0] The padding length. 14499 * @param {string} [chars=' '] The string used as padding. 14500 * @returns {string} Returns the padded string. 14501 * @example 14502 * 14503 * _.padStart('abc', 6); 14504 * // => ' abc' 14505 * 14506 * _.padStart('abc', 6, '_-'); 14507 * // => '_-_abc' 14508 * 14509 * _.padStart('abc', 3); 14510 * // => 'abc' 14511 */ 14512 function padStart(string, length, chars) {
vendor: 29,827 bytes, lines 14513-15410
14513 string = toString(string); 14514 length = toInteger(length); 14515 14516 var strLength = length ? stringSize(string) : 0; 14517 return (length && strLength < length) 14518 ? (createPadding(length - strLength, chars) + string) 14519 : string; 14520 } 14521 14522 /** 14523 * Converts `string` to an integer of the specified radix. If `radix` is 14524 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 14525 * hexadecimal, in which case a `radix` of `16` is used. 14526 * 14527 * **Note:** This method aligns with the 14528 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 14529 * 14530 * @static 14531 * @memberOf _ 14532 * @since 1.1.0 14533 * @category String 14534 * @param {string} string The string to convert. 14535 * @param {number} [radix=10] The radix to interpret `value` by. 14536 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14537 * @returns {number} Returns the converted integer. 14538 * @example 14539 * 14540 * _.parseInt('08'); 14541 * // => 8 14542 * 14543 * _.map(['6', '08', '10'], _.parseInt); 14544 * // => [6, 8, 10] 14545 */ 14546 function parseInt(string, radix, guard) { 14547 if (guard || radix == null) { 14548 radix = 0; 14549 } else if (radix) { 14550 radix = +radix; 14551 } 14552 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 14553 } 14554 14555 /** 14556 * Repeats the given string `n` times. 14557 * 14558 * @static 14559 * @memberOf _ 14560 * @since 3.0.0 14561 * @category String 14562 * @param {string} [string=''] The string to repeat. 14563 * @param {number} [n=1] The number of times to repeat the string. 14564 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14565 * @returns {string} Returns the repeated string. 14566 * @example 14567 * 14568 * _.repeat('*', 3); 14569 * // => '***' 14570 * 14571 * _.repeat('abc', 2); 14572 * // => 'abcabc' 14573 * 14574 * _.repeat('abc', 0); 14575 * // => '' 14576 */ 14577 function repeat(string, n, guard) { 14578 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 14579 n = 1; 14580 } else { 14581 n = toInteger(n); 14582 } 14583 return baseRepeat(toString(string), n); 14584 } 14585 14586 /** 14587 * Replaces matches for `pattern` in `string` with `replacement`. 14588 * 14589 * **Note:** This method is based on 14590 * [`String#replace`](https://mdn.io/String/replace). 14591 * 14592 * @static 14593 * @memberOf _ 14594 * @since 4.0.0 14595 * @category String 14596 * @param {string} [string=''] The string to modify. 14597 * @param {RegExp|string} pattern The pattern to replace. 14598 * @param {Function|string} replacement The match replacement. 14599 * @returns {string} Returns the modified string. 14600 * @example 14601 * 14602 * _.replace('Hi Fred', 'Fred', 'Barney'); 14603 * // => 'Hi Barney' 14604 */ 14605 function replace() { 14606 var args = arguments, 14607 string = toString(args[0]); 14608 14609 return args.length < 3 ? string : string.replace(args[1], args[2]); 14610 } 14611 14612 /** 14613 * Converts `string` to 14614 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 14615 * 14616 * @static 14617 * @memberOf _ 14618 * @since 3.0.0 14619 * @category String 14620 * @param {string} [string=''] The string to convert. 14621 * @returns {string} Returns the snake cased string. 14622 * @example 14623 * 14624 * _.snakeCase('Foo Bar'); 14625 * // => 'foo_bar' 14626 * 14627 * _.snakeCase('fooBar'); 14628 * // => 'foo_bar' 14629 * 14630 * _.snakeCase('--FOO-BAR--'); 14631 * // => 'foo_bar' 14632 */ 14633 var snakeCase = createCompounder(function(result, word, index) { 14634 return result + (index ? '_' : '') + word.toLowerCase(); 14635 }); 14636 14637 /** 14638 * Splits `string` by `separator`. 14639 * 14640 * **Note:** This method is based on 14641 * [`String#split`](https://mdn.io/String/split). 14642 * 14643 * @static 14644 * @memberOf _ 14645 * @since 4.0.0 14646 * @category String 14647 * @param {string} [string=''] The string to split. 14648 * @param {RegExp|string} separator The separator pattern to split by. 14649 * @param {number} [limit] The length to truncate results to. 14650 * @returns {Array} Returns the string segments. 14651 * @example 14652 * 14653 * _.split('a-b-c', '-', 2); 14654 * // => ['a', 'b'] 14655 */ 14656 function split(string, separator, limit) { 14657 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 14658 separator = limit = undefined; 14659 } 14660 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 14661 if (!limit) { 14662 return []; 14663 } 14664 string = toString(string); 14665 if (string && ( 14666 typeof separator == 'string' || 14667 (separator != null && !isRegExp(separator)) 14668 )) { 14669 separator = baseToString(separator); 14670 if (!separator && hasUnicode(string)) { 14671 return castSlice(stringToArray(string), 0, limit); 14672 } 14673 } 14674 return string.split(separator, limit); 14675 } 14676 14677 /** 14678 * Converts `string` to 14679 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 14680 * 14681 * @static 14682 * @memberOf _ 14683 * @since 3.1.0 14684 * @category String 14685 * @param {string} [string=''] The string to convert. 14686 * @returns {string} Returns the start cased string. 14687 * @example 14688 * 14689 * _.startCase('--foo-bar--'); 14690 * // => 'Foo Bar' 14691 * 14692 * _.startCase('fooBar'); 14693 * // => 'Foo Bar' 14694 * 14695 * _.startCase('__FOO_BAR__'); 14696 * // => 'FOO BAR' 14697 */ 14698 var startCase = createCompounder(function(result, word, index) { 14699 return result + (index ? ' ' : '') + upperFirst(word); 14700 }); 14701 14702 /** 14703 * Checks if `string` starts with the given target string. 14704 * 14705 * @static 14706 * @memberOf _ 14707 * @since 3.0.0 14708 * @category String 14709 * @param {string} [string=''] The string to inspect. 14710 * @param {string} [target] The string to search for. 14711 * @param {number} [position=0] The position to search from. 14712 * @returns {boolean} Returns `true` if `string` starts with `target`, 14713 * else `false`. 14714 * @example 14715 * 14716 * _.startsWith('abc', 'a'); 14717 * // => true 14718 * 14719 * _.startsWith('abc', 'b'); 14720 * // => false 14721 * 14722 * _.startsWith('abc', 'b', 1); 14723 * // => true 14724 */ 14725 function startsWith(string, target, position) { 14726 string = toString(string); 14727 position = position == null 14728 ? 0 14729 : baseClamp(toInteger(position), 0, string.length); 14730 14731 target = baseToString(target); 14732 return string.slice(position, position + target.length) == target; 14733 } 14734 14735 /** 14736 * Creates a compiled template function that can interpolate data properties 14737 * in "interpolate" delimiters, HTML-escape interpolated data properties in 14738 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 14739 * properties may be accessed as free variables in the template. If a setting 14740 * object is given, it takes precedence over `_.templateSettings` values. 14741 * 14742 * **Note:** In the development build `_.template` utilizes 14743 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 14744 * for easier debugging. 14745 * 14746 * For more information on precompiling templates see 14747 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 14748 * 14749 * For more information on Chrome extension sandboxes see 14750 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 14751 * 14752 * @static 14753 * @since 0.1.0 14754 * @memberOf _ 14755 * @category String 14756 * @param {string} [string=''] The template string. 14757 * @param {Object} [options={}] The options object. 14758 * @param {RegExp} [options.escape=_.templateSettings.escape] 14759 * The HTML "escape" delimiter. 14760 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 14761 * The "evaluate" delimiter. 14762 * @param {Object} [options.imports=_.templateSettings.imports] 14763 * An object to import into the template as free variables. 14764 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 14765 * The "interpolate" delimiter. 14766 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 14767 * The sourceURL of the compiled template. 14768 * @param {string} [options.variable='obj'] 14769 * The data object variable name. 14770 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14771 * @returns {Function} Returns the compiled template function. 14772 * @example 14773 * 14774 * // Use the "interpolate" delimiter to create a compiled template. 14775 * var compiled = _.template('hello <%= user %>!'); 14776 * compiled({ 'user': 'fred' }); 14777 * // => 'hello fred!' 14778 * 14779 * // Use the HTML "escape" delimiter to escape data property values. 14780 * var compiled = _.template('<b><%- value %></b>'); 14781 * compiled({ 'value': '<script>' }); 14782 * // => '<b><script></b>' 14783 * 14784 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 14785 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 14786 * compiled({ 'users': ['fred', 'barney'] }); 14787 * // => '<li>fred</li><li>barney</li>' 14788 * 14789 * // Use the internal `print` function in "evaluate" delimiters. 14790 * var compiled = _.template('<% print("hello " + user); %>!'); 14791 * compiled({ 'user': 'barney' }); 14792 * // => 'hello barney!' 14793 * 14794 * // Use the ES template literal delimiter as an "interpolate" delimiter. 14795 * // Disable support by replacing the "interpolate" delimiter. 14796 * var compiled = _.template('hello ${ user }!'); 14797 * compiled({ 'user': 'pebbles' }); 14798 * // => 'hello pebbles!' 14799 * 14800 * // Use backslashes to treat delimiters as plain text. 14801 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 14802 * compiled({ 'value': 'ignored' }); 14803 * // => '<%- value %>' 14804 * 14805 * // Use the `imports` option to import `jQuery` as `jq`. 14806 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 14807 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 14808 * compiled({ 'users': ['fred', 'barney'] }); 14809 * // => '<li>fred</li><li>barney</li>' 14810 * 14811 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 14812 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 14813 * compiled(data); 14814 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 14815 * 14816 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 14817 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 14818 * compiled.source; 14819 * // => function(data) { 14820 * // var __t, __p = ''; 14821 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 14822 * // return __p; 14823 * // } 14824 * 14825 * // Use custom template delimiters. 14826 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 14827 * var compiled = _.template('hello {{ user }}!'); 14828 * compiled({ 'user': 'mustache' }); 14829 * // => 'hello mustache!' 14830 * 14831 * // Use the `source` property to inline compiled templates for meaningful 14832 * // line numbers in error messages and stack traces. 14833 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 14834 * var JST = {\ 14835 * "main": ' + _.template(mainText).source + '\ 14836 * };\ 14837 * '); 14838 */ 14839 function template(string, options, guard) { 14840 // Based on John Resig's `tmpl` implementation 14841 // (http://ejohn.org/blog/javascript-micro-templating/) 14842 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 14843 var settings = lodash.templateSettings; 14844 14845 if (guard && isIterateeCall(string, options, guard)) { 14846 options = undefined; 14847 } 14848 string = toString(string); 14849 options = assignInWith({}, options, settings, customDefaultsAssignIn); 14850 14851 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 14852 importsKeys = keys(imports), 14853 importsValues = baseValues(imports, importsKeys); 14854 14855 var isEscaping, 14856 isEvaluating, 14857 index = 0, 14858 interpolate = options.interpolate || reNoMatch, 14859 source = "__p += '"; 14860 14861 // Compile the regexp to match each delimiter. 14862 var reDelimiters = RegExp( 14863 (options.escape || reNoMatch).source + '|' + 14864 interpolate.source + '|' + 14865 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 14866 (options.evaluate || reNoMatch).source + '|$' 14867 , 'g'); 14868 14869 // Use a sourceURL for easier debugging. 14870 // The sourceURL gets injected into the source that's eval-ed, so be careful 14871 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 14872 // and escape the comment, thus injecting code that gets evaled. 14873 var sourceURL = '//# sourceURL=' + 14874 (hasOwnProperty.call(options, 'sourceURL') 14875 ? (options.sourceURL + '').replace(/\s/g, ' ') 14876 : ('lodash.templateSources[' + (++templateCounter) + ']') 14877 ) + '\n'; 14878 14879 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 14880 interpolateValue || (interpolateValue = esTemplateValue); 14881 14882 // Escape characters that can't be included in string literals. 14883 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 14884 14885 // Replace delimiters with snippets. 14886 if (escapeValue) { 14887 isEscaping = true; 14888 source += "' +\n__e(" + escapeValue + ") +\n'"; 14889 } 14890 if (evaluateValue) { 14891 isEvaluating = true; 14892 source += "';\n" + evaluateValue + ";\n__p += '"; 14893 } 14894 if (interpolateValue) { 14895 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 14896 } 14897 index = offset + match.length; 14898 14899 // The JS engine embedded in Adobe products needs `match` returned in 14900 // order to produce the correct `offset` value. 14901 return match; 14902 }); 14903 14904 source += "';\n"; 14905 14906 // If `variable` is not specified wrap a with-statement around the generated 14907 // code to add the data object to the top of the scope chain. 14908 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 14909 if (!variable) { 14910 source = 'with (obj) {\n' + source + '\n}\n'; 14911 } 14912 // Throw an error if a forbidden character was found in `variable`, to prevent 14913 // potential command injection attacks. 14914 else if (reForbiddenIdentifierChars.test(variable)) { 14915 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); 14916 } 14917 14918 // Cleanup code by stripping empty strings. 14919 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 14920 .replace(reEmptyStringMiddle, '$1') 14921 .replace(reEmptyStringTrailing, '$1;'); 14922 14923 // Frame code as the function body. 14924 source = 'function(' + (variable || 'obj') + ') {\n' + 14925 (variable 14926 ? '' 14927 : 'obj || (obj = {});\n' 14928 ) + 14929 "var __t, __p = ''" + 14930 (isEscaping 14931 ? ', __e = _.escape' 14932 : '' 14933 ) + 14934 (isEvaluating 14935 ? ', __j = Array.prototype.join;\n' + 14936 "function print() { __p += __j.call(arguments, '') }\n" 14937 : ';\n' 14938 ) + 14939 source + 14940 'return __p\n}'; 14941 14942 var result = attempt(function() { 14943 return Function(importsKeys, sourceURL + 'return ' + source) 14944 .apply(undefined, importsValues); 14945 }); 14946 14947 // Provide the compiled function's source by its `toString` method or 14948 // the `source` property as a convenience for inlining compiled templates. 14949 result.source = source; 14950 if (isError(result)) { 14951 throw result; 14952 } 14953 return result; 14954 } 14955 14956 /** 14957 * Converts `string`, as a whole, to lower case just like 14958 * [String#toLowerCase](https://mdn.io/toLowerCase). 14959 * 14960 * @static 14961 * @memberOf _ 14962 * @since 4.0.0 14963 * @category String 14964 * @param {string} [string=''] The string to convert. 14965 * @returns {string} Returns the lower cased string. 14966 * @example 14967 * 14968 * _.toLower('--Foo-Bar--'); 14969 * // => '--foo-bar--' 14970 * 14971 * _.toLower('fooBar'); 14972 * // => 'foobar' 14973 * 14974 * _.toLower('__FOO_BAR__'); 14975 * // => '__foo_bar__' 14976 */ 14977 function toLower(value) { 14978 return toString(value).toLowerCase(); 14979 } 14980 14981 /** 14982 * Converts `string`, as a whole, to upper case just like 14983 * [String#toUpperCase](https://mdn.io/toUpperCase). 14984 * 14985 * @static 14986 * @memberOf _ 14987 * @since 4.0.0 14988 * @category String 14989 * @param {string} [string=''] The string to convert. 14990 * @returns {string} Returns the upper cased string. 14991 * @example 14992 * 14993 * _.toUpper('--foo-bar--'); 14994 * // => '--FOO-BAR--' 14995 * 14996 * _.toUpper('fooBar'); 14997 * // => 'FOOBAR' 14998 * 14999 * _.toUpper('__foo_bar__'); 15000 * // => '__FOO_BAR__' 15001 */ 15002 function toUpper(value) { 15003 return toString(value).toUpperCase(); 15004 } 15005 15006 /** 15007 * Removes leading and trailing whitespace or specified characters from `string`. 15008 * 15009 * @static 15010 * @memberOf _ 15011 * @since 3.0.0 15012 * @category String 15013 * @param {string} [string=''] The string to trim. 15014 * @param {string} [chars=whitespace] The characters to trim. 15015 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15016 * @returns {string} Returns the trimmed string. 15017 * @example 15018 * 15019 * _.trim(' abc '); 15020 * // => 'abc' 15021 * 15022 * _.trim('-_-abc-_-', '_-'); 15023 * // => 'abc' 15024 * 15025 * _.map([' foo ', ' bar '], _.trim); 15026 * // => ['foo', 'bar'] 15027 */ 15028 function trim(string, chars, guard) { 15029 string = toString(string); 15030 if (string && (guard || chars === undefined)) { 15031 return baseTrim(string); 15032 } 15033 if (!string || !(chars = baseToString(chars))) { 15034 return string; 15035 } 15036 var strSymbols = stringToArray(string), 15037 chrSymbols = stringToArray(chars), 15038 start = charsStartIndex(strSymbols, chrSymbols), 15039 end = charsEndIndex(strSymbols, chrSymbols) + 1; 15040 15041 return castSlice(strSymbols, start, end).join(''); 15042 } 15043 15044 /** 15045 * Removes trailing whitespace or specified characters from `string`. 15046 * 15047 * @static 15048 * @memberOf _ 15049 * @since 4.0.0 15050 * @category String 15051 * @param {string} [string=''] The string to trim. 15052 * @param {string} [chars=whitespace] The characters to trim. 15053 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15054 * @returns {string} Returns the trimmed string. 15055 * @example 15056 * 15057 * _.trimEnd(' abc '); 15058 * // => ' abc' 15059 * 15060 * _.trimEnd('-_-abc-_-', '_-'); 15061 * // => '-_-abc' 15062 */ 15063 function trimEnd(string, chars, guard) { 15064 string = toString(string); 15065 if (string && (guard || chars === undefined)) { 15066 return string.slice(0, trimmedEndIndex(string) + 1); 15067 } 15068 if (!string || !(chars = baseToString(chars))) { 15069 return string; 15070 } 15071 var strSymbols = stringToArray(string), 15072 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 15073 15074 return castSlice(strSymbols, 0, end).join(''); 15075 } 15076 15077 /** 15078 * Removes leading whitespace or specified characters from `string`. 15079 * 15080 * @static 15081 * @memberOf _ 15082 * @since 4.0.0 15083 * @category String 15084 * @param {string} [string=''] The string to trim. 15085 * @param {string} [chars=whitespace] The characters to trim. 15086 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15087 * @returns {string} Returns the trimmed string. 15088 * @example 15089 * 15090 * _.trimStart(' abc '); 15091 * // => 'abc ' 15092 * 15093 * _.trimStart('-_-abc-_-', '_-'); 15094 * // => 'abc-_-' 15095 */ 15096 function trimStart(string, chars, guard) { 15097 string = toString(string); 15098 if (string && (guard || chars === undefined)) { 15099 return string.replace(reTrimStart, ''); 15100 } 15101 if (!string || !(chars = baseToString(chars))) { 15102 return string; 15103 } 15104 var strSymbols = stringToArray(string), 15105 start = charsStartIndex(strSymbols, stringToArray(chars)); 15106 15107 return castSlice(strSymbols, start).join(''); 15108 } 15109 15110 /** 15111 * Truncates `string` if it's longer than the given maximum string length. 15112 * The last characters of the truncated string are replaced with the omission 15113 * string which defaults to "...". 15114 * 15115 * @static 15116 * @memberOf _ 15117 * @since 4.0.0 15118 * @category String 15119 * @param {string} [string=''] The string to truncate. 15120 * @param {Object} [options={}] The options object. 15121 * @param {number} [options.length=30] The maximum string length. 15122 * @param {string} [options.omission='...'] The string to indicate text is omitted. 15123 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 15124 * @returns {string} Returns the truncated string. 15125 * @example 15126 * 15127 * _.truncate('hi-diddly-ho there, neighborino'); 15128 * // => 'hi-diddly-ho there, neighbo...' 15129 * 15130 * _.truncate('hi-diddly-ho there, neighborino', { 15131 * 'length': 24, 15132 * 'separator': ' ' 15133 * }); 15134 * // => 'hi-diddly-ho there,...' 15135 * 15136 * _.truncate('hi-diddly-ho there, neighborino', { 15137 * 'length': 24, 15138 * 'separator': /,? +/ 15139 * }); 15140 * // => 'hi-diddly-ho there...' 15141 * 15142 * _.truncate('hi-diddly-ho there, neighborino', { 15143 * 'omission': ' [...]' 15144 * }); 15145 * // => 'hi-diddly-ho there, neig [...]' 15146 */ 15147 function truncate(string, options) { 15148 var length = DEFAULT_TRUNC_LENGTH, 15149 omission = DEFAULT_TRUNC_OMISSION; 15150 15151 if (isObject(options)) { 15152 var separator = 'separator' in options ? options.separator : separator; 15153 length = 'length' in options ? toInteger(options.length) : length; 15154 omission = 'omission' in options ? baseToString(options.omission) : omission; 15155 } 15156 string = toString(string); 15157 15158 var strLength = string.length; 15159 if (hasUnicode(string)) { 15160 var strSymbols = stringToArray(string); 15161 strLength = strSymbols.length; 15162 } 15163 if (length >= strLength) { 15164 return string; 15165 } 15166 var end = length - stringSize(omission); 15167 if (end < 1) { 15168 return omission; 15169 } 15170 var result = strSymbols 15171 ? castSlice(strSymbols, 0, end).join('') 15172 : string.slice(0, end); 15173 15174 if (separator === undefined) { 15175 return result + omission; 15176 } 15177 if (strSymbols) { 15178 end += (result.length - end); 15179 } 15180 if (isRegExp(separator)) { 15181 if (string.slice(end).search(separator)) { 15182 var match, 15183 substring = result; 15184 15185 if (!separator.global) { 15186 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 15187 } 15188 separator.lastIndex = 0; 15189 while ((match = separator.exec(substring))) { 15190 var newEnd = match.index; 15191 } 15192 result = result.slice(0, newEnd === undefined ? end : newEnd); 15193 } 15194 } else if (string.indexOf(baseToString(separator), end) != end) { 15195 var index = result.lastIndexOf(separator); 15196 if (index > -1) { 15197 result = result.slice(0, index); 15198 } 15199 } 15200 return result + omission; 15201 } 15202 15203 /** 15204 * The inverse of `_.escape`; this method converts the HTML entities 15205 * `&`, `<`, `>`, `"`, and `'` in `string` to 15206 * their corresponding characters. 15207 * 15208 * **Note:** No other HTML entities are unescaped. To unescape additional 15209 * HTML entities use a third-party library like [_he_](https://mths.be/he). 15210 * 15211 * @static 15212 * @memberOf _ 15213 * @since 0.6.0 15214 * @category String 15215 * @param {string} [string=''] The string to unescape. 15216 * @returns {string} Returns the unescaped string. 15217 * @example 15218 * 15219 * _.unescape('fred, barney, & pebbles'); 15220 * // => 'fred, barney, & pebbles' 15221 */ 15222 function unescape(string) { 15223 string = toString(string); 15224 return (string && reHasEscapedHtml.test(string)) 15225 ? string.replace(reEscapedHtml, unescapeHtmlChar) 15226 : string; 15227 } 15228 15229 /** 15230 * Converts `string`, as space separated words, to upper case. 15231 * 15232 * @static 15233 * @memberOf _ 15234 * @since 4.0.0 15235 * @category String 15236 * @param {string} [string=''] The string to convert. 15237 * @returns {string} Returns the upper cased string. 15238 * @example 15239 * 15240 * _.upperCase('--foo-bar'); 15241 * // => 'FOO BAR' 15242 * 15243 * _.upperCase('fooBar'); 15244 * // => 'FOO BAR' 15245 * 15246 * _.upperCase('__foo_bar__'); 15247 * // => 'FOO BAR' 15248 */ 15249 var upperCase = createCompounder(function(result, word, index) { 15250 return result + (index ? ' ' : '') + word.toUpperCase(); 15251 }); 15252 15253 /** 15254 * Converts the first character of `string` to upper case. 15255 * 15256 * @static 15257 * @memberOf _ 15258 * @since 4.0.0 15259 * @category String 15260 * @param {string} [string=''] The string to convert. 15261 * @returns {string} Returns the converted string. 15262 * @example 15263 * 15264 * _.upperFirst('fred'); 15265 * // => 'Fred' 15266 * 15267 * _.upperFirst('FRED'); 15268 * // => 'FRED' 15269 */ 15270 var upperFirst = createCaseFirst('toUpperCase'); 15271 15272 /** 15273 * Splits `string` into an array of its words. 15274 * 15275 * @static 15276 * @memberOf _ 15277 * @since 3.0.0 15278 * @category String 15279 * @param {string} [string=''] The string to inspect. 15280 * @param {RegExp|string} [pattern] The pattern to match words. 15281 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15282 * @returns {Array} Returns the words of `string`. 15283 * @example 15284 * 15285 * _.words('fred, barney, & pebbles'); 15286 * // => ['fred', 'barney', 'pebbles'] 15287 * 15288 * _.words('fred, barney, & pebbles', /[^, ]+/g); 15289 * // => ['fred', 'barney', '&', 'pebbles'] 15290 */ 15291 function words(string, pattern, guard) { 15292 string = toString(string); 15293 pattern = guard ? undefined : pattern; 15294 15295 if (pattern === undefined) { 15296 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 15297 } 15298 return string.match(pattern) || []; 15299 } 15300 15301 /*------------------------------------------------------------------------*/ 15302 15303 /** 15304 * Attempts to invoke `func`, returning either the result or the caught error 15305 * object. Any additional arguments are provided to `func` when it's invoked. 15306 * 15307 * @static 15308 * @memberOf _ 15309 * @since 3.0.0 15310 * @category Util 15311 * @param {Function} func The function to attempt. 15312 * @param {...*} [args] The arguments to invoke `func` with. 15313 * @returns {*} Returns the `func` result or error object. 15314 * @example 15315 * 15316 * // Avoid throwing errors for invalid selectors. 15317 * var elements = _.attempt(function(selector) { 15318 * return document.querySelectorAll(selector); 15319 * }, '>_>'); 15320 * 15321 * if (_.isError(elements)) { 15322 * elements = []; 15323 * } 15324 */ 15325 var attempt = baseRest(function(func, args) { 15326 try { 15327 return apply(func, undefined, args); 15328 } catch (e) { 15329 return isError(e) ? e : new Error(e); 15330 } 15331 }); 15332 15333 /** 15334 * Binds methods of an object to the object itself, overwriting the existing 15335 * method. 15336 * 15337 * **Note:** This method doesn't set the "length" property of bound functions. 15338 * 15339 * @static 15340 * @since 0.1.0 15341 * @memberOf _ 15342 * @category Util 15343 * @param {Object} object The object to bind and assign the bound methods to. 15344 * @param {...(string|string[])} methodNames The object method names to bind. 15345 * @returns {Object} Returns `object`. 15346 * @example 15347 * 15348 * var view = { 15349 * 'label': 'docs', 15350 * 'click': function() { 15351 * console.log('clicked ' + this.label); 15352 * } 15353 * }; 15354 * 15355 * _.bindAll(view, ['click']); 15356 * jQuery(element).on('click', view.click); 15357 * // => Logs 'clicked docs' when clicked. 15358 */ 15359 var bindAll = flatRest(function(object, methodNames) { 15360 arrayEach(methodNames, function(key) { 15361 key = toKey(key); 15362 baseAssignValue(object, key, bind(object[key], object)); 15363 }); 15364 return object; 15365 }); 15366 15367 /** 15368 * Creates a function that iterates over `pairs` and invokes the corresponding 15369 * function of the first predicate to return truthy. The predicate-function 15370 * pairs are invoked with the `this` binding and arguments of the created 15371 * function. 15372 * 15373 * @static 15374 * @memberOf _ 15375 * @since 4.0.0 15376 * @category Util 15377 * @param {Array} pairs The predicate-function pairs. 15378 * @returns {Function} Returns the new composite function. 15379 * @example 15380 * 15381 * var func = _.cond([ 15382 * [_.matches({ 'a': 1 }), _.constant('matches A')], 15383 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 15384 * [_.stubTrue, _.constant('no match')] 15385 * ]); 15386 * 15387 * func({ 'a': 1, 'b': 2 }); 15388 * // => 'matches A' 15389 * 15390 * func({ 'a': 0, 'b': 1 }); 15391 * // => 'matches B' 15392 * 15393 * func({ 'a': '1', 'b': '2' }); 15394 * // => 'no match' 15395 */ 15396 function cond(pairs) { 15397 var length = pairs == null ? 0 : pairs.length, 15398 toIteratee = getIteratee(); 15399 15400 pairs = !length ? [] : arrayMap(pairs, function(pair) { 15401 if (typeof pair[1] != 'function') { 15402 throw new TypeError(FUNC_ERROR_TEXT); 15403 } 15404 return [toIteratee(pair[0]), pair[1]]; 15405 }); 15406 15407 return baseRest(function(args) { 15408 var index = -1; 15409 while (++index < length) { 15410 var pair = pairs[index];
vendor: 10,296 bytes, lines 15411-15743
15411 if (apply(pair[0], this, args)) { 15412 return apply(pair[1], this, args); 15413 } 15414 } 15415 }); 15416 } 15417 15418 /** 15419 * Creates a function that invokes the predicate properties of `source` with 15420 * the corresponding property values of a given object, returning `true` if 15421 * all predicates return truthy, else `false`. 15422 * 15423 * **Note:** The created function is equivalent to `_.conformsTo` with 15424 * `source` partially applied. 15425 * 15426 * @static 15427 * @memberOf _ 15428 * @since 4.0.0 15429 * @category Util 15430 * @param {Object} source The object of property predicates to conform to. 15431 * @returns {Function} Returns the new spec function. 15432 * @example 15433 * 15434 * var objects = [ 15435 * { 'a': 2, 'b': 1 }, 15436 * { 'a': 1, 'b': 2 } 15437 * ]; 15438 * 15439 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 15440 * // => [{ 'a': 1, 'b': 2 }] 15441 */ 15442 function conforms(source) { 15443 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 15444 } 15445 15446 /** 15447 * Creates a function that returns `value`. 15448 * 15449 * @static 15450 * @memberOf _ 15451 * @since 2.4.0 15452 * @category Util 15453 * @param {*} value The value to return from the new function. 15454 * @returns {Function} Returns the new constant function. 15455 * @example 15456 * 15457 * var objects = _.times(2, _.constant({ 'a': 1 })); 15458 * 15459 * console.log(objects); 15460 * // => [{ 'a': 1 }, { 'a': 1 }] 15461 * 15462 * console.log(objects[0] === objects[1]); 15463 * // => true 15464 */ 15465 function constant(value) { 15466 return function() { 15467 return value; 15468 }; 15469 } 15470 15471 /** 15472 * Checks `value` to determine whether a default value should be returned in 15473 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 15474 * or `undefined`. 15475 * 15476 * @static 15477 * @memberOf _ 15478 * @since 4.14.0 15479 * @category Util 15480 * @param {*} value The value to check. 15481 * @param {*} defaultValue The default value. 15482 * @returns {*} Returns the resolved value. 15483 * @example 15484 * 15485 * _.defaultTo(1, 10); 15486 * // => 1 15487 * 15488 * _.defaultTo(undefined, 10); 15489 * // => 10 15490 */ 15491 function defaultTo(value, defaultValue) { 15492 return (value == null || value !== value) ? defaultValue : value; 15493 } 15494 15495 /** 15496 * Creates a function that returns the result of invoking the given functions 15497 * with the `this` binding of the created function, where each successive 15498 * invocation is supplied the return value of the previous. 15499 * 15500 * @static 15501 * @memberOf _ 15502 * @since 3.0.0 15503 * @category Util 15504 * @param {...(Function|Function[])} [funcs] The functions to invoke. 15505 * @returns {Function} Returns the new composite function. 15506 * @see _.flowRight 15507 * @example 15508 * 15509 * function square(n) { 15510 * return n * n; 15511 * } 15512 * 15513 * var addSquare = _.flow([_.add, square]); 15514 * addSquare(1, 2); 15515 * // => 9 15516 */ 15517 var flow = createFlow(); 15518 15519 /** 15520 * This method is like `_.flow` except that it creates a function that 15521 * invokes the given functions from right to left. 15522 * 15523 * @static 15524 * @since 3.0.0 15525 * @memberOf _ 15526 * @category Util 15527 * @param {...(Function|Function[])} [funcs] The functions to invoke. 15528 * @returns {Function} Returns the new composite function. 15529 * @see _.flow 15530 * @example 15531 * 15532 * function square(n) { 15533 * return n * n; 15534 * } 15535 * 15536 * var addSquare = _.flowRight([square, _.add]); 15537 * addSquare(1, 2); 15538 * // => 9 15539 */ 15540 var flowRight = createFlow(true); 15541 15542 /** 15543 * This method returns the first argument it receives. 15544 * 15545 * @static 15546 * @since 0.1.0 15547 * @memberOf _ 15548 * @category Util 15549 * @param {*} value Any value. 15550 * @returns {*} Returns `value`. 15551 * @example 15552 * 15553 * var object = { 'a': 1 }; 15554 * 15555 * console.log(_.identity(object) === object); 15556 * // => true 15557 */ 15558 function identity(value) { 15559 return value; 15560 } 15561 15562 /** 15563 * Creates a function that invokes `func` with the arguments of the created 15564 * function. If `func` is a property name, the created function returns the 15565 * property value for a given element. If `func` is an array or object, the 15566 * created function returns `true` for elements that contain the equivalent 15567 * source properties, otherwise it returns `false`. 15568 * 15569 * @static 15570 * @since 4.0.0 15571 * @memberOf _ 15572 * @category Util 15573 * @param {*} [func=_.identity] The value to convert to a callback. 15574 * @returns {Function} Returns the callback. 15575 * @example 15576 * 15577 * var users = [ 15578 * { 'user': 'barney', 'age': 36, 'active': true }, 15579 * { 'user': 'fred', 'age': 40, 'active': false } 15580 * ]; 15581 * 15582 * // The `_.matches` iteratee shorthand. 15583 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 15584 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 15585 * 15586 * // The `_.matchesProperty` iteratee shorthand. 15587 * _.filter(users, _.iteratee(['user', 'fred'])); 15588 * // => [{ 'user': 'fred', 'age': 40 }] 15589 * 15590 * // The `_.property` iteratee shorthand. 15591 * _.map(users, _.iteratee('user')); 15592 * // => ['barney', 'fred'] 15593 * 15594 * // Create custom iteratee shorthands. 15595 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 15596 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 15597 * return func.test(string); 15598 * }; 15599 * }); 15600 * 15601 * _.filter(['abc', 'def'], /ef/); 15602 * // => ['def'] 15603 */ 15604 function iteratee(func) { 15605 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 15606 } 15607 15608 /** 15609 * Creates a function that performs a partial deep comparison between a given 15610 * object and `source`, returning `true` if the given object has equivalent 15611 * property values, else `false`. 15612 * 15613 * **Note:** The created function is equivalent to `_.isMatch` with `source` 15614 * partially applied. 15615 * 15616 * Partial comparisons will match empty array and empty object `source` 15617 * values against any array or object value, respectively. See `_.isEqual` 15618 * for a list of supported value comparisons. 15619 * 15620 * **Note:** Multiple values can be checked by combining several matchers 15621 * using `_.overSome` 15622 * 15623 * @static 15624 * @memberOf _ 15625 * @since 3.0.0 15626 * @category Util 15627 * @param {Object} source The object of property values to match. 15628 * @returns {Function} Returns the new spec function. 15629 * @example 15630 * 15631 * var objects = [ 15632 * { 'a': 1, 'b': 2, 'c': 3 }, 15633 * { 'a': 4, 'b': 5, 'c': 6 } 15634 * ]; 15635 * 15636 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 15637 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 15638 * 15639 * // Checking for several possible values 15640 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 15641 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 15642 */ 15643 function matches(source) { 15644 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 15645 } 15646 15647 /** 15648 * Creates a function that performs a partial deep comparison between the 15649 * value at `path` of a given object to `srcValue`, returning `true` if the 15650 * object value is equivalent, else `false`. 15651 * 15652 * **Note:** Partial comparisons will match empty array and empty object 15653 * `srcValue` values against any array or object value, respectively. See 15654 * `_.isEqual` for a list of supported value comparisons. 15655 * 15656 * **Note:** Multiple values can be checked by combining several matchers 15657 * using `_.overSome` 15658 * 15659 * @static 15660 * @memberOf _ 15661 * @since 3.2.0 15662 * @category Util 15663 * @param {Array|string} path The path of the property to get. 15664 * @param {*} srcValue The value to match. 15665 * @returns {Function} Returns the new spec function. 15666 * @example 15667 * 15668 * var objects = [ 15669 * { 'a': 1, 'b': 2, 'c': 3 }, 15670 * { 'a': 4, 'b': 5, 'c': 6 } 15671 * ]; 15672 * 15673 * _.find(objects, _.matchesProperty('a', 4)); 15674 * // => { 'a': 4, 'b': 5, 'c': 6 } 15675 * 15676 * // Checking for several possible values 15677 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 15678 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 15679 */ 15680 function matchesProperty(path, srcValue) { 15681 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 15682 } 15683 15684 /** 15685 * Creates a function that invokes the method at `path` of a given object. 15686 * Any additional arguments are provided to the invoked method. 15687 * 15688 * @static 15689 * @memberOf _ 15690 * @since 3.7.0 15691 * @category Util 15692 * @param {Array|string} path The path of the method to invoke. 15693 * @param {...*} [args] The arguments to invoke the method with. 15694 * @returns {Function} Returns the new invoker function. 15695 * @example 15696 * 15697 * var objects = [ 15698 * { 'a': { 'b': _.constant(2) } }, 15699 * { 'a': { 'b': _.constant(1) } } 15700 * ]; 15701 * 15702 * _.map(objects, _.method('a.b')); 15703 * // => [2, 1] 15704 * 15705 * _.map(objects, _.method(['a', 'b'])); 15706 * // => [2, 1] 15707 */ 15708 var method = baseRest(function(path, args) { 15709 return function(object) { 15710 return baseInvoke(object, path, args); 15711 }; 15712 }); 15713 15714 /** 15715 * The opposite of `_.method`; this method creates a function that invokes 15716 * the method at a given path of `object`. Any additional arguments are 15717 * provided to the invoked method. 15718 * 15719 * @static 15720 * @memberOf _ 15721 * @since 3.7.0 15722 * @category Util 15723 * @param {Object} object The object to query. 15724 * @param {...*} [args] The arguments to invoke the method with. 15725 * @returns {Function} Returns the new invoker function. 15726 * @example 15727 * 15728 * var array = _.times(3, _.constant), 15729 * object = { 'a': array, 'b': array, 'c': array }; 15730 * 15731 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 15732 * // => [2, 0] 15733 * 15734 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 15735 * // => [2, 0] 15736 */ 15737 var methodOf = baseRest(function(object, args) { 15738 return function(path) { 15739 return baseInvoke(object, path, args); 15740 }; 15741 }); 15742 15743 /**
vendor: 10,734 bytes, lines 15744-16131
15744 * Adds all own enumerable string keyed function properties of a source 15745 * object to the destination object. If `object` is a function, then methods 15746 * are added to its prototype as well. 15747 * 15748 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 15749 * avoid conflicts caused by modifying the original. 15750 * 15751 * @static 15752 * @since 0.1.0 15753 * @memberOf _ 15754 * @category Util 15755 * @param {Function|Object} [object=lodash] The destination object. 15756 * @param {Object} source The object of functions to add. 15757 * @param {Object} [options={}] The options object. 15758 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 15759 * @returns {Function|Object} Returns `object`. 15760 * @example 15761 * 15762 * function vowels(string) { 15763 * return _.filter(string, function(v) { 15764 * return /[aeiou]/i.test(v); 15765 * }); 15766 * } 15767 * 15768 * _.mixin({ 'vowels': vowels }); 15769 * _.vowels('fred'); 15770 * // => ['e'] 15771 * 15772 * _('fred').vowels().value(); 15773 * // => ['e'] 15774 * 15775 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 15776 * _('fred').vowels(); 15777 * // => ['e'] 15778 */ 15779 function mixin(object, source, options) { 15780 var props = keys(source), 15781 methodNames = baseFunctions(source, props); 15782 15783 if (options == null && 15784 !(isObject(source) && (methodNames.length || !props.length))) { 15785 options = source; 15786 source = object; 15787 object = this; 15788 methodNames = baseFunctions(source, keys(source)); 15789 } 15790 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 15791 isFunc = isFunction(object); 15792 15793 arrayEach(methodNames, function(methodName) { 15794 var func = source[methodName]; 15795 object[methodName] = func; 15796 if (isFunc) { 15797 object.prototype[methodName] = function() { 15798 var chainAll = this.__chain__; 15799 if (chain || chainAll) { 15800 var result = object(this.__wrapped__), 15801 actions = result.__actions__ = copyArray(this.__actions__); 15802 15803 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 15804 result.__chain__ = chainAll; 15805 return result; 15806 } 15807 return func.apply(object, arrayPush([this.value()], arguments)); 15808 }; 15809 } 15810 }); 15811 15812 return object; 15813 } 15814 15815 /** 15816 * Reverts the `_` variable to its previous value and returns a reference to 15817 * the `lodash` function. 15818 * 15819 * @static 15820 * @since 0.1.0 15821 * @memberOf _ 15822 * @category Util 15823 * @returns {Function} Returns the `lodash` function. 15824 * @example 15825 * 15826 * var lodash = _.noConflict(); 15827 */ 15828 function noConflict() { 15829 if (root._ === this) { 15830 root._ = oldDash; 15831 } 15832 return this; 15833 } 15834 15835 /** 15836 * This method returns `undefined`. 15837 * 15838 * @static 15839 * @memberOf _ 15840 * @since 2.3.0 15841 * @category Util 15842 * @example 15843 * 15844 * _.times(2, _.noop); 15845 * // => [undefined, undefined] 15846 */ 15847 function noop() { 15848 // No operation performed. 15849 } 15850 15851 /** 15852 * Creates a function that gets the argument at index `n`. If `n` is negative, 15853 * the nth argument from the end is returned. 15854 * 15855 * @static 15856 * @memberOf _ 15857 * @since 4.0.0 15858 * @category Util 15859 * @param {number} [n=0] The index of the argument to return. 15860 * @returns {Function} Returns the new pass-thru function. 15861 * @example 15862 * 15863 * var func = _.nthArg(1); 15864 * func('a', 'b', 'c', 'd'); 15865 * // => 'b' 15866 * 15867 * var func = _.nthArg(-2); 15868 * func('a', 'b', 'c', 'd'); 15869 * // => 'c' 15870 */ 15871 function nthArg(n) { 15872 n = toInteger(n); 15873 return baseRest(function(args) { 15874 return baseNth(args, n); 15875 }); 15876 } 15877 15878 /** 15879 * Creates a function that invokes `iteratees` with the arguments it receives 15880 * and returns their results. 15881 * 15882 * @static 15883 * @memberOf _ 15884 * @since 4.0.0 15885 * @category Util 15886 * @param {...(Function|Function[])} [iteratees=[_.identity]] 15887 * The iteratees to invoke. 15888 * @returns {Function} Returns the new function. 15889 * @example 15890 * 15891 * var func = _.over([Math.max, Math.min]); 15892 * 15893 * func(1, 2, 3, 4); 15894 * // => [4, 1] 15895 */ 15896 var over = createOver(arrayMap); 15897 15898 /** 15899 * Creates a function that checks if **all** of the `predicates` return 15900 * truthy when invoked with the arguments it receives. 15901 * 15902 * Following shorthands are possible for providing predicates. 15903 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 15904 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 15905 * 15906 * @static 15907 * @memberOf _ 15908 * @since 4.0.0 15909 * @category Util 15910 * @param {...(Function|Function[])} [predicates=[_.identity]] 15911 * The predicates to check. 15912 * @returns {Function} Returns the new function. 15913 * @example 15914 * 15915 * var func = _.overEvery([Boolean, isFinite]); 15916 * 15917 * func('1'); 15918 * // => true 15919 * 15920 * func(null); 15921 * // => false 15922 * 15923 * func(NaN); 15924 * // => false 15925 */ 15926 var overEvery = createOver(arrayEvery); 15927 15928 /** 15929 * Creates a function that checks if **any** of the `predicates` return 15930 * truthy when invoked with the arguments it receives. 15931 * 15932 * Following shorthands are possible for providing predicates. 15933 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 15934 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 15935 * 15936 * @static 15937 * @memberOf _ 15938 * @since 4.0.0 15939 * @category Util 15940 * @param {...(Function|Function[])} [predicates=[_.identity]] 15941 * The predicates to check. 15942 * @returns {Function} Returns the new function. 15943 * @example 15944 * 15945 * var func = _.overSome([Boolean, isFinite]); 15946 * 15947 * func('1'); 15948 * // => true 15949 * 15950 * func(null); 15951 * // => true 15952 * 15953 * func(NaN); 15954 * // => false 15955 * 15956 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 15957 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 15958 */ 15959 var overSome = createOver(arraySome); 15960 15961 /** 15962 * Creates a function that returns the value at `path` of a given object. 15963 * 15964 * @static 15965 * @memberOf _ 15966 * @since 2.4.0 15967 * @category Util 15968 * @param {Array|string} path The path of the property to get. 15969 * @returns {Function} Returns the new accessor function. 15970 * @example 15971 * 15972 * var objects = [ 15973 * { 'a': { 'b': 2 } }, 15974 * { 'a': { 'b': 1 } } 15975 * ]; 15976 * 15977 * _.map(objects, _.property('a.b')); 15978 * // => [2, 1] 15979 * 15980 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 15981 * // => [1, 2] 15982 */ 15983 function property(path) { 15984 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 15985 } 15986 15987 /** 15988 * The opposite of `_.property`; this method creates a function that returns 15989 * the value at a given path of `object`. 15990 * 15991 * @static 15992 * @memberOf _ 15993 * @since 3.0.0 15994 * @category Util 15995 * @param {Object} object The object to query. 15996 * @returns {Function} Returns the new accessor function. 15997 * @example 15998 * 15999 * var array = [0, 1, 2], 16000 * object = { 'a': array, 'b': array, 'c': array }; 16001 * 16002 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 16003 * // => [2, 0] 16004 * 16005 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 16006 * // => [2, 0] 16007 */ 16008 function propertyOf(object) { 16009 return function(path) { 16010 return object == null ? undefined : baseGet(object, path); 16011 }; 16012 } 16013 16014 /** 16015 * Creates an array of numbers (positive and/or negative) progressing from 16016 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 16017 * `start` is specified without an `end` or `step`. If `end` is not specified, 16018 * it's set to `start` with `start` then set to `0`. 16019 * 16020 * **Note:** JavaScript follows the IEEE-754 standard for resolving 16021 * floating-point values which can produce unexpected results. 16022 * 16023 * @static 16024 * @since 0.1.0 16025 * @memberOf _ 16026 * @category Util 16027 * @param {number} [start=0] The start of the range. 16028 * @param {number} end The end of the range. 16029 * @param {number} [step=1] The value to increment or decrement by. 16030 * @returns {Array} Returns the range of numbers. 16031 * @see _.inRange, _.rangeRight 16032 * @example 16033 * 16034 * _.range(4); 16035 * // => [0, 1, 2, 3] 16036 * 16037 * _.range(-4); 16038 * // => [0, -1, -2, -3] 16039 * 16040 * _.range(1, 5); 16041 * // => [1, 2, 3, 4] 16042 * 16043 * _.range(0, 20, 5); 16044 * // => [0, 5, 10, 15] 16045 * 16046 * _.range(0, -4, -1); 16047 * // => [0, -1, -2, -3] 16048 * 16049 * _.range(1, 4, 0); 16050 * // => [1, 1, 1] 16051 * 16052 * _.range(0); 16053 * // => [] 16054 */ 16055 var range = createRange(); 16056 16057 /** 16058 * This method is like `_.range` except that it populates values in 16059 * descending order. 16060 * 16061 * @static 16062 * @memberOf _ 16063 * @since 4.0.0 16064 * @category Util 16065 * @param {number} [start=0] The start of the range. 16066 * @param {number} end The end of the range. 16067 * @param {number} [step=1] The value to increment or decrement by. 16068 * @returns {Array} Returns the range of numbers. 16069 * @see _.inRange, _.range 16070 * @example 16071 * 16072 * _.rangeRight(4); 16073 * // => [3, 2, 1, 0] 16074 * 16075 * _.rangeRight(-4); 16076 * // => [-3, -2, -1, 0] 16077 * 16078 * _.rangeRight(1, 5); 16079 * // => [4, 3, 2, 1] 16080 * 16081 * _.rangeRight(0, 20, 5); 16082 * // => [15, 10, 5, 0] 16083 * 16084 * _.rangeRight(0, -4, -1); 16085 * // => [-3, -2, -1, 0] 16086 * 16087 * _.rangeRight(1, 4, 0); 16088 * // => [1, 1, 1] 16089 * 16090 * _.rangeRight(0); 16091 * // => [] 16092 */ 16093 var rangeRight = createRange(true); 16094 16095 /** 16096 * This method returns a new empty array. 16097 * 16098 * @static 16099 * @memberOf _ 16100 * @since 4.13.0 16101 * @category Util 16102 * @returns {Array} Returns the new empty array. 16103 * @example 16104 * 16105 * var arrays = _.times(2, _.stubArray); 16106 * 16107 * console.log(arrays); 16108 * // => [[], []] 16109 * 16110 * console.log(arrays[0] === arrays[1]); 16111 * // => false 16112 */ 16113 function stubArray() { 16114 return []; 16115 } 16116 16117 /** 16118 * This method returns `false`. 16119 * 16120 * @static 16121 * @memberOf _ 16122 * @since 4.13.0 16123 * @category Util 16124 * @returns {boolean} Returns `false`. 16125 * @example 16126 * 16127 * _.times(2, _.stubFalse); 16128 * // => [false, false] 16129 */ 16130 function stubFalse() { 16131 return false;
vendor: 1,044 bytes, lines 16132-16185
16132 } 16133 16134 /** 16135 * This method returns a new empty object. 16136 * 16137 * @static 16138 * @memberOf _ 16139 * @since 4.13.0 16140 * @category Util 16141 * @returns {Object} Returns the new empty object. 16142 * @example 16143 * 16144 * var objects = _.times(2, _.stubObject); 16145 * 16146 * console.log(objects); 16147 * // => [{}, {}] 16148 * 16149 * console.log(objects[0] === objects[1]); 16150 * // => false 16151 */ 16152 function stubObject() { 16153 return {}; 16154 } 16155 16156 /** 16157 * This method returns an empty string. 16158 * 16159 * @static 16160 * @memberOf _ 16161 * @since 4.13.0 16162 * @category Util 16163 * @returns {string} Returns the empty string. 16164 * @example 16165 * 16166 * _.times(2, _.stubString); 16167 * // => ['', ''] 16168 */ 16169 function stubString() { 16170 return ''; 16171 } 16172 16173 /** 16174 * This method returns `true`. 16175 * 16176 * @static 16177 * @memberOf _ 16178 * @since 4.13.0 16179 * @category Util 16180 * @returns {boolean} Returns `true`. 16181 * @example 16182 * 16183 * _.times(2, _.stubTrue); 16184 * // => [true, true] 16185 */
vendor: 9,081 bytes, lines 16186-16529
16186 function stubTrue() { 16187 return true; 16188 } 16189 16190 /** 16191 * Invokes the iteratee `n` times, returning an array of the results of 16192 * each invocation. The iteratee is invoked with one argument; (index). 16193 * 16194 * @static 16195 * @since 0.1.0 16196 * @memberOf _ 16197 * @category Util 16198 * @param {number} n The number of times to invoke `iteratee`. 16199 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 16200 * @returns {Array} Returns the array of results. 16201 * @example 16202 * 16203 * _.times(3, String); 16204 * // => ['0', '1', '2'] 16205 * 16206 * _.times(4, _.constant(0)); 16207 * // => [0, 0, 0, 0] 16208 */ 16209 function times(n, iteratee) { 16210 n = toInteger(n); 16211 if (n < 1 || n > MAX_SAFE_INTEGER) { 16212 return []; 16213 } 16214 var index = MAX_ARRAY_LENGTH, 16215 length = nativeMin(n, MAX_ARRAY_LENGTH); 16216 16217 iteratee = getIteratee(iteratee); 16218 n -= MAX_ARRAY_LENGTH; 16219 16220 var result = baseTimes(length, iteratee); 16221 while (++index < n) { 16222 iteratee(index); 16223 } 16224 return result; 16225 } 16226 16227 /** 16228 * Converts `value` to a property path array. 16229 * 16230 * @static 16231 * @memberOf _ 16232 * @since 4.0.0 16233 * @category Util 16234 * @param {*} value The value to convert. 16235 * @returns {Array} Returns the new property path array. 16236 * @example 16237 * 16238 * _.toPath('a.b.c'); 16239 * // => ['a', 'b', 'c'] 16240 * 16241 * _.toPath('a[0].b.c'); 16242 * // => ['a', '0', 'b', 'c'] 16243 */ 16244 function toPath(value) { 16245 if (isArray(value)) { 16246 return arrayMap(value, toKey); 16247 } 16248 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 16249 } 16250 16251 /** 16252 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 16253 * 16254 * @static 16255 * @since 0.1.0 16256 * @memberOf _ 16257 * @category Util 16258 * @param {string} [prefix=''] The value to prefix the ID with. 16259 * @returns {string} Returns the unique ID. 16260 * @example 16261 * 16262 * _.uniqueId('contact_'); 16263 * // => 'contact_104' 16264 * 16265 * _.uniqueId(); 16266 * // => '105' 16267 */ 16268 function uniqueId(prefix) { 16269 var id = ++idCounter; 16270 return toString(prefix) + id; 16271 } 16272 16273 /*------------------------------------------------------------------------*/ 16274 16275 /** 16276 * Adds two numbers. 16277 * 16278 * @static 16279 * @memberOf _ 16280 * @since 3.4.0 16281 * @category Math 16282 * @param {number} augend The first number in an addition. 16283 * @param {number} addend The second number in an addition. 16284 * @returns {number} Returns the total. 16285 * @example 16286 * 16287 * _.add(6, 4); 16288 * // => 10 16289 */ 16290 var add = createMathOperation(function(augend, addend) { 16291 return augend + addend; 16292 }, 0); 16293 16294 /** 16295 * Computes `number` rounded up to `precision`. 16296 * 16297 * @static 16298 * @memberOf _ 16299 * @since 3.10.0 16300 * @category Math 16301 * @param {number} number The number to round up. 16302 * @param {number} [precision=0] The precision to round up to. 16303 * @returns {number} Returns the rounded up number. 16304 * @example 16305 * 16306 * _.ceil(4.006); 16307 * // => 5 16308 * 16309 * _.ceil(6.004, 2); 16310 * // => 6.01 16311 * 16312 * _.ceil(6040, -2); 16313 * // => 6100 16314 */ 16315 var ceil = createRound('ceil'); 16316 16317 /** 16318 * Divide two numbers. 16319 * 16320 * @static 16321 * @memberOf _ 16322 * @since 4.7.0 16323 * @category Math 16324 * @param {number} dividend The first number in a division. 16325 * @param {number} divisor The second number in a division. 16326 * @returns {number} Returns the quotient. 16327 * @example 16328 * 16329 * _.divide(6, 4); 16330 * // => 1.5 16331 */ 16332 var divide = createMathOperation(function(dividend, divisor) { 16333 return dividend / divisor; 16334 }, 1); 16335 16336 /** 16337 * Computes `number` rounded down to `precision`. 16338 * 16339 * @static 16340 * @memberOf _ 16341 * @since 3.10.0 16342 * @category Math 16343 * @param {number} number The number to round down. 16344 * @param {number} [precision=0] The precision to round down to. 16345 * @returns {number} Returns the rounded down number. 16346 * @example 16347 * 16348 * _.floor(4.006); 16349 * // => 4 16350 * 16351 * _.floor(0.046, 2); 16352 * // => 0.04 16353 * 16354 * _.floor(4060, -2); 16355 * // => 4000 16356 */ 16357 var floor = createRound('floor'); 16358 16359 /** 16360 * Computes the maximum value of `array`. If `array` is empty or falsey, 16361 * `undefined` is returned. 16362 * 16363 * @static 16364 * @since 0.1.0 16365 * @memberOf _ 16366 * @category Math 16367 * @param {Array} array The array to iterate over. 16368 * @returns {*} Returns the maximum value. 16369 * @example 16370 * 16371 * _.max([4, 2, 8, 6]); 16372 * // => 8 16373 * 16374 * _.max([]); 16375 * // => undefined 16376 */ 16377 function max(array) { 16378 return (array && array.length) 16379 ? baseExtremum(array, identity, baseGt) 16380 : undefined; 16381 } 16382 16383 /** 16384 * This method is like `_.max` except that it accepts `iteratee` which is 16385 * invoked for each element in `array` to generate the criterion by which 16386 * the value is ranked. The iteratee is invoked with one argument: (value). 16387 * 16388 * @static 16389 * @memberOf _ 16390 * @since 4.0.0 16391 * @category Math 16392 * @param {Array} array The array to iterate over. 16393 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16394 * @returns {*} Returns the maximum value. 16395 * @example 16396 * 16397 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 16398 * 16399 * _.maxBy(objects, function(o) { return o.n; }); 16400 * // => { 'n': 2 } 16401 * 16402 * // The `_.property` iteratee shorthand. 16403 * _.maxBy(objects, 'n'); 16404 * // => { 'n': 2 } 16405 */ 16406 function maxBy(array, iteratee) { 16407 return (array && array.length) 16408 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 16409 : undefined; 16410 } 16411 16412 /** 16413 * Computes the mean of the values in `array`. 16414 * 16415 * @static 16416 * @memberOf _ 16417 * @since 4.0.0 16418 * @category Math 16419 * @param {Array} array The array to iterate over. 16420 * @returns {number} Returns the mean. 16421 * @example 16422 * 16423 * _.mean([4, 2, 8, 6]); 16424 * // => 5 16425 */ 16426 function mean(array) { 16427 return baseMean(array, identity); 16428 } 16429 16430 /** 16431 * This method is like `_.mean` except that it accepts `iteratee` which is 16432 * invoked for each element in `array` to generate the value to be averaged. 16433 * The iteratee is invoked with one argument: (value). 16434 * 16435 * @static 16436 * @memberOf _ 16437 * @since 4.7.0 16438 * @category Math 16439 * @param {Array} array The array to iterate over. 16440 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16441 * @returns {number} Returns the mean. 16442 * @example 16443 * 16444 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 16445 * 16446 * _.meanBy(objects, function(o) { return o.n; }); 16447 * // => 5 16448 * 16449 * // The `_.property` iteratee shorthand. 16450 * _.meanBy(objects, 'n'); 16451 * // => 5 16452 */ 16453 function meanBy(array, iteratee) { 16454 return baseMean(array, getIteratee(iteratee, 2)); 16455 } 16456 16457 /** 16458 * Computes the minimum value of `array`. If `array` is empty or falsey, 16459 * `undefined` is returned. 16460 * 16461 * @static 16462 * @since 0.1.0 16463 * @memberOf _ 16464 * @category Math 16465 * @param {Array} array The array to iterate over. 16466 * @returns {*} Returns the minimum value. 16467 * @example 16468 * 16469 * _.min([4, 2, 8, 6]); 16470 * // => 2 16471 * 16472 * _.min([]); 16473 * // => undefined 16474 */ 16475 function min(array) { 16476 return (array && array.length) 16477 ? baseExtremum(array, identity, baseLt) 16478 : undefined; 16479 } 16480 16481 /** 16482 * This method is like `_.min` except that it accepts `iteratee` which is 16483 * invoked for each element in `array` to generate the criterion by which 16484 * the value is ranked. The iteratee is invoked with one argument: (value). 16485 * 16486 * @static 16487 * @memberOf _ 16488 * @since 4.0.0 16489 * @category Math 16490 * @param {Array} array The array to iterate over. 16491 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16492 * @returns {*} Returns the minimum value. 16493 * @example 16494 * 16495 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 16496 * 16497 * _.minBy(objects, function(o) { return o.n; }); 16498 * // => { 'n': 1 } 16499 * 16500 * // The `_.property` iteratee shorthand. 16501 * _.minBy(objects, 'n'); 16502 * // => { 'n': 1 } 16503 */ 16504 function minBy(array, iteratee) { 16505 return (array && array.length) 16506 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 16507 : undefined; 16508 } 16509 16510 /** 16511 * Multiply two numbers. 16512 * 16513 * @static 16514 * @memberOf _ 16515 * @since 4.7.0 16516 * @category Math 16517 * @param {number} multiplier The first number in a multiplication. 16518 * @param {number} multiplicand The second number in a multiplication. 16519 * @returns {number} Returns the product. 16520 * @example 16521 * 16522 * _.multiply(6, 4); 16523 * // => 24 16524 */ 16525 var multiply = createMathOperation(function(multiplier, multiplicand) { 16526 return multiplier * multiplicand; 16527 }, 1); 16528 16529 /**
vendor: 13,137 bytes, lines 16530-16968
16530 * Computes `number` rounded to `precision`. 16531 * 16532 * @static 16533 * @memberOf _ 16534 * @since 3.10.0 16535 * @category Math 16536 * @param {number} number The number to round. 16537 * @param {number} [precision=0] The precision to round to. 16538 * @returns {number} Returns the rounded number. 16539 * @example 16540 * 16541 * _.round(4.006); 16542 * // => 4 16543 * 16544 * _.round(4.006, 2); 16545 * // => 4.01 16546 * 16547 * _.round(4060, -2); 16548 * // => 4100 16549 */ 16550 var round = createRound('round'); 16551 16552 /** 16553 * Subtract two numbers. 16554 * 16555 * @static 16556 * @memberOf _ 16557 * @since 4.0.0 16558 * @category Math 16559 * @param {number} minuend The first number in a subtraction. 16560 * @param {number} subtrahend The second number in a subtraction. 16561 * @returns {number} Returns the difference. 16562 * @example 16563 * 16564 * _.subtract(6, 4); 16565 * // => 2 16566 */ 16567 var subtract = createMathOperation(function(minuend, subtrahend) { 16568 return minuend - subtrahend; 16569 }, 0); 16570 16571 /** 16572 * Computes the sum of the values in `array`. 16573 * 16574 * @static 16575 * @memberOf _ 16576 * @since 3.4.0 16577 * @category Math 16578 * @param {Array} array The array to iterate over. 16579 * @returns {number} Returns the sum. 16580 * @example 16581 * 16582 * _.sum([4, 2, 8, 6]); 16583 * // => 20 16584 */ 16585 function sum(array) { 16586 return (array && array.length) 16587 ? baseSum(array, identity) 16588 : 0; 16589 } 16590 16591 /** 16592 * This method is like `_.sum` except that it accepts `iteratee` which is 16593 * invoked for each element in `array` to generate the value to be summed. 16594 * The iteratee is invoked with one argument: (value). 16595 * 16596 * @static 16597 * @memberOf _ 16598 * @since 4.0.0 16599 * @category Math 16600 * @param {Array} array The array to iterate over. 16601 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16602 * @returns {number} Returns the sum. 16603 * @example 16604 * 16605 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 16606 * 16607 * _.sumBy(objects, function(o) { return o.n; }); 16608 * // => 20 16609 * 16610 * // The `_.property` iteratee shorthand. 16611 * _.sumBy(objects, 'n'); 16612 * // => 20 16613 */ 16614 function sumBy(array, iteratee) { 16615 return (array && array.length) 16616 ? baseSum(array, getIteratee(iteratee, 2)) 16617 : 0; 16618 } 16619 16620 /*------------------------------------------------------------------------*/ 16621 16622 // Add methods that return wrapped values in chain sequences. 16623 lodash.after = after; 16624 lodash.ary = ary; 16625 lodash.assign = assign; 16626 lodash.assignIn = assignIn; 16627 lodash.assignInWith = assignInWith; 16628 lodash.assignWith = assignWith; 16629 lodash.at = at; 16630 lodash.before = before; 16631 lodash.bind = bind; 16632 lodash.bindAll = bindAll; 16633 lodash.bindKey = bindKey; 16634 lodash.castArray = castArray; 16635 lodash.chain = chain; 16636 lodash.chunk = chunk; 16637 lodash.compact = compact; 16638 lodash.concat = concat; 16639 lodash.cond = cond; 16640 lodash.conforms = conforms; 16641 lodash.constant = constant; 16642 lodash.countBy = countBy; 16643 lodash.create = create; 16644 lodash.curry = curry; 16645 lodash.curryRight = curryRight; 16646 lodash.debounce = debounce; 16647 lodash.defaults = defaults; 16648 lodash.defaultsDeep = defaultsDeep; 16649 lodash.defer = defer; 16650 lodash.delay = delay; 16651 lodash.difference = difference; 16652 lodash.differenceBy = differenceBy; 16653 lodash.differenceWith = differenceWith; 16654 lodash.drop = drop; 16655 lodash.dropRight = dropRight; 16656 lodash.dropRightWhile = dropRightWhile; 16657 lodash.dropWhile = dropWhile; 16658 lodash.fill = fill; 16659 lodash.filter = filter; 16660 lodash.flatMap = flatMap; 16661 lodash.flatMapDeep = flatMapDeep; 16662 lodash.flatMapDepth = flatMapDepth; 16663 lodash.flatten = flatten; 16664 lodash.flattenDeep = flattenDeep; 16665 lodash.flattenDepth = flattenDepth; 16666 lodash.flip = flip; 16667 lodash.flow = flow; 16668 lodash.flowRight = flowRight; 16669 lodash.fromPairs = fromPairs; 16670 lodash.functions = functions; 16671 lodash.functionsIn = functionsIn; 16672 lodash.groupBy = groupBy; 16673 lodash.initial = initial; 16674 lodash.intersection = intersection; 16675 lodash.intersectionBy = intersectionBy; 16676 lodash.intersectionWith = intersectionWith; 16677 lodash.invert = invert; 16678 lodash.invertBy = invertBy; 16679 lodash.invokeMap = invokeMap; 16680 lodash.iteratee = iteratee; 16681 lodash.keyBy = keyBy; 16682 lodash.keys = keys; 16683 lodash.keysIn = keysIn; 16684 lodash.map = map; 16685 lodash.mapKeys = mapKeys; 16686 lodash.mapValues = mapValues; 16687 lodash.matches = matches; 16688 lodash.matchesProperty = matchesProperty; 16689 lodash.memoize = memoize; 16690 lodash.merge = merge; 16691 lodash.mergeWith = mergeWith; 16692 lodash.method = method; 16693 lodash.methodOf = methodOf; 16694 lodash.mixin = mixin; 16695 lodash.negate = negate; 16696 lodash.nthArg = nthArg; 16697 lodash.omit = omit; 16698 lodash.omitBy = omitBy; 16699 lodash.once = once; 16700 lodash.orderBy = orderBy; 16701 lodash.over = over; 16702 lodash.overArgs = overArgs; 16703 lodash.overEvery = overEvery; 16704 lodash.overSome = overSome; 16705 lodash.partial = partial; 16706 lodash.partialRight = partialRight; 16707 lodash.partition = partition; 16708 lodash.pick = pick; 16709 lodash.pickBy = pickBy; 16710 lodash.property = property; 16711 lodash.propertyOf = propertyOf; 16712 lodash.pull = pull; 16713 lodash.pullAll = pullAll; 16714 lodash.pullAllBy = pullAllBy; 16715 lodash.pullAllWith = pullAllWith; 16716 lodash.pullAt = pullAt; 16717 lodash.range = range; 16718 lodash.rangeRight = rangeRight; 16719 lodash.rearg = rearg; 16720 lodash.reject = reject; 16721 lodash.remove = remove; 16722 lodash.rest = rest; 16723 lodash.reverse = reverse; 16724 lodash.sampleSize = sampleSize; 16725 lodash.set = set; 16726 lodash.setWith = setWith; 16727 lodash.shuffle = shuffle; 16728 lodash.slice = slice; 16729 lodash.sortBy = sortBy; 16730 lodash.sortedUniq = sortedUniq; 16731 lodash.sortedUniqBy = sortedUniqBy; 16732 lodash.split = split; 16733 lodash.spread = spread; 16734 lodash.tail = tail; 16735 lodash.take = take; 16736 lodash.takeRight = takeRight; 16737 lodash.takeRightWhile = takeRightWhile; 16738 lodash.takeWhile = takeWhile; 16739 lodash.tap = tap; 16740 lodash.throttle = throttle; 16741 lodash.thru = thru; 16742 lodash.toArray = toArray; 16743 lodash.toPairs = toPairs; 16744 lodash.toPairsIn = toPairsIn; 16745 lodash.toPath = toPath; 16746 lodash.toPlainObject = toPlainObject; 16747 lodash.transform = transform; 16748 lodash.unary = unary; 16749 lodash.union = union; 16750 lodash.unionBy = unionBy; 16751 lodash.unionWith = unionWith; 16752 lodash.uniq = uniq; 16753 lodash.uniqBy = uniqBy; 16754 lodash.uniqWith = uniqWith; 16755 lodash.unset = unset; 16756 lodash.unzip = unzip; 16757 lodash.unzipWith = unzipWith; 16758 lodash.update = update; 16759 lodash.updateWith = updateWith; 16760 lodash.values = values; 16761 lodash.valuesIn = valuesIn; 16762 lodash.without = without; 16763 lodash.words = words; 16764 lodash.wrap = wrap; 16765 lodash.xor = xor; 16766 lodash.xorBy = xorBy; 16767 lodash.xorWith = xorWith; 16768 lodash.zip = zip; 16769 lodash.zipObject = zipObject; 16770 lodash.zipObjectDeep = zipObjectDeep; 16771 lodash.zipWith = zipWith; 16772 16773 // Add aliases. 16774 lodash.entries = toPairs; 16775 lodash.entriesIn = toPairsIn; 16776 lodash.extend = assignIn; 16777 lodash.extendWith = assignInWith; 16778 16779 // Add methods to `lodash.prototype`. 16780 mixin(lodash, lodash); 16781 16782 /*------------------------------------------------------------------------*/ 16783 16784 // Add methods that return unwrapped values in chain sequences. 16785 lodash.add = add; 16786 lodash.attempt = attempt; 16787 lodash.camelCase = camelCase; 16788 lodash.capitalize = capitalize; 16789 lodash.ceil = ceil; 16790 lodash.clamp = clamp; 16791 lodash.clone = clone; 16792 lodash.cloneDeep = cloneDeep; 16793 lodash.cloneDeepWith = cloneDeepWith; 16794 lodash.cloneWith = cloneWith; 16795 lodash.conformsTo = conformsTo; 16796 lodash.deburr = deburr; 16797 lodash.defaultTo = defaultTo; 16798 lodash.divide = divide; 16799 lodash.endsWith = endsWith; 16800 lodash.eq = eq; 16801 lodash.escape = escape; 16802 lodash.escapeRegExp = escapeRegExp; 16803 lodash.every = every; 16804 lodash.find = find; 16805 lodash.findIndex = findIndex; 16806 lodash.findKey = findKey; 16807 lodash.findLast = findLast; 16808 lodash.findLastIndex = findLastIndex; 16809 lodash.findLastKey = findLastKey; 16810 lodash.floor = floor; 16811 lodash.forEach = forEach; 16812 lodash.forEachRight = forEachRight; 16813 lodash.forIn = forIn; 16814 lodash.forInRight = forInRight; 16815 lodash.forOwn = forOwn; 16816 lodash.forOwnRight = forOwnRight; 16817 lodash.get = get; 16818 lodash.gt = gt; 16819 lodash.gte = gte; 16820 lodash.has = has; 16821 lodash.hasIn = hasIn; 16822 lodash.head = head; 16823 lodash.identity = identity; 16824 lodash.includes = includes; 16825 lodash.indexOf = indexOf; 16826 lodash.inRange = inRange; 16827 lodash.invoke = invoke; 16828 lodash.isArguments = isArguments; 16829 lodash.isArray = isArray; 16830 lodash.isArrayBuffer = isArrayBuffer; 16831 lodash.isArrayLike = isArrayLike; 16832 lodash.isArrayLikeObject = isArrayLikeObject; 16833 lodash.isBoolean = isBoolean; 16834 lodash.isBuffer = isBuffer; 16835 lodash.isDate = isDate; 16836 lodash.isElement = isElement; 16837 lodash.isEmpty = isEmpty; 16838 lodash.isEqual = isEqual; 16839 lodash.isEqualWith = isEqualWith; 16840 lodash.isError = isError; 16841 lodash.isFinite = isFinite; 16842 lodash.isFunction = isFunction; 16843 lodash.isInteger = isInteger; 16844 lodash.isLength = isLength; 16845 lodash.isMap = isMap; 16846 lodash.isMatch = isMatch; 16847 lodash.isMatchWith = isMatchWith; 16848 lodash.isNaN = isNaN; 16849 lodash.isNative = isNative; 16850 lodash.isNil = isNil; 16851 lodash.isNull = isNull; 16852 lodash.isNumber = isNumber; 16853 lodash.isObject = isObject; 16854 lodash.isObjectLike = isObjectLike; 16855 lodash.isPlainObject = isPlainObject; 16856 lodash.isRegExp = isRegExp; 16857 lodash.isSafeInteger = isSafeInteger; 16858 lodash.isSet = isSet; 16859 lodash.isString = isString; 16860 lodash.isSymbol = isSymbol; 16861 lodash.isTypedArray = isTypedArray; 16862 lodash.isUndefined = isUndefined; 16863 lodash.isWeakMap = isWeakMap; 16864 lodash.isWeakSet = isWeakSet; 16865 lodash.join = join; 16866 lodash.kebabCase = kebabCase; 16867 lodash.last = last; 16868 lodash.lastIndexOf = lastIndexOf; 16869 lodash.lowerCase = lowerCase; 16870 lodash.lowerFirst = lowerFirst; 16871 lodash.lt = lt; 16872 lodash.lte = lte; 16873 lodash.max = max; 16874 lodash.maxBy = maxBy; 16875 lodash.mean = mean; 16876 lodash.meanBy = meanBy; 16877 lodash.min = min; 16878 lodash.minBy = minBy; 16879 lodash.stubArray = stubArray; 16880 lodash.stubFalse = stubFalse; 16881 lodash.stubObject = stubObject; 16882 lodash.stubString = stubString; 16883 lodash.stubTrue = stubTrue; 16884 lodash.multiply = multiply; 16885 lodash.nth = nth; 16886 lodash.noConflict = noConflict; 16887 lodash.noop = noop; 16888 lodash.now = now; 16889 lodash.pad = pad; 16890 lodash.padEnd = padEnd; 16891 lodash.padStart = padStart; 16892 lodash.parseInt = parseInt; 16893 lodash.random = random; 16894 lodash.reduce = reduce; 16895 lodash.reduceRight = reduceRight; 16896 lodash.repeat = repeat; 16897 lodash.replace = replace; 16898 lodash.result = result; 16899 lodash.round = round; 16900 lodash.runInContext = runInContext; 16901 lodash.sample = sample; 16902 lodash.size = size; 16903 lodash.snakeCase = snakeCase; 16904 lodash.some = some; 16905 lodash.sortedIndex = sortedIndex; 16906 lodash.sortedIndexBy = sortedIndexBy; 16907 lodash.sortedIndexOf = sortedIndexOf; 16908 lodash.sortedLastIndex = sortedLastIndex; 16909 lodash.sortedLastIndexBy = sortedLastIndexBy; 16910 lodash.sortedLastIndexOf = sortedLastIndexOf; 16911 lodash.startCase = startCase; 16912 lodash.startsWith = startsWith; 16913 lodash.subtract = subtract; 16914 lodash.sum = sum; 16915 lodash.sumBy = sumBy; 16916 lodash.template = template; 16917 lodash.times = times; 16918 lodash.toFinite = toFinite; 16919 lodash.toInteger = toInteger; 16920 lodash.toLength = toLength; 16921 lodash.toLower = toLower; 16922 lodash.toNumber = toNumber; 16923 lodash.toSafeInteger = toSafeInteger; 16924 lodash.toString = toString; 16925 lodash.toUpper = toUpper; 16926 lodash.trim = trim; 16927 lodash.trimEnd = trimEnd; 16928 lodash.trimStart = trimStart; 16929 lodash.truncate = truncate; 16930 lodash.unescape = unescape; 16931 lodash.uniqueId = uniqueId; 16932 lodash.upperCase = upperCase; 16933 lodash.upperFirst = upperFirst; 16934 16935 // Add aliases. 16936 lodash.each = forEach; 16937 lodash.eachRight = forEachRight; 16938 lodash.first = head; 16939 16940 mixin(lodash, (function() { 16941 var source = {}; 16942 baseForOwn(lodash, function(func, methodName) { 16943 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 16944 source[methodName] = func; 16945 } 16946 }); 16947 return source; 16948 }()), { 'chain': false }); 16949 16950 /*------------------------------------------------------------------------*/ 16951 16952 /** 16953 * The semantic version number. 16954 * 16955 * @static 16956 * @memberOf _ 16957 * @type {string} 16958 */ 16959 lodash.VERSION = VERSION; 16960 16961 // Assign default placeholders. 16962 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 16963 lodash[methodName].placeholder = lodash; 16964 }); 16965 16966 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 16967 arrayEach(['drop', 'take'], function(methodName, index) { 16968 LazyWrapper.prototype[methodName] = function(n) {
vendor: 7,433 bytes, lines 16969-17186
16969 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 16970 16971 var result = (this.__filtered__ && !index) 16972 ? new LazyWrapper(this) 16973 : this.clone(); 16974 16975 if (result.__filtered__) { 16976 result.__takeCount__ = nativeMin(n, result.__takeCount__); 16977 } else { 16978 result.__views__.push({ 16979 'size': nativeMin(n, MAX_ARRAY_LENGTH), 16980 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 16981 }); 16982 } 16983 return result; 16984 }; 16985 16986 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 16987 return this.reverse()[methodName](n).reverse(); 16988 }; 16989 }); 16990 16991 // Add `LazyWrapper` methods that accept an `iteratee` value. 16992 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 16993 var type = index + 1, 16994 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 16995 16996 LazyWrapper.prototype[methodName] = function(iteratee) { 16997 var result = this.clone(); 16998 result.__iteratees__.push({ 16999 'iteratee': getIteratee(iteratee, 3), 17000 'type': type 17001 }); 17002 result.__filtered__ = result.__filtered__ || isFilter; 17003 return result; 17004 }; 17005 }); 17006 17007 // Add `LazyWrapper` methods for `_.head` and `_.last`. 17008 arrayEach(['head', 'last'], function(methodName, index) { 17009 var takeName = 'take' + (index ? 'Right' : ''); 17010 17011 LazyWrapper.prototype[methodName] = function() { 17012 return this[takeName](1).value()[0]; 17013 }; 17014 }); 17015 17016 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 17017 arrayEach(['initial', 'tail'], function(methodName, index) { 17018 var dropName = 'drop' + (index ? '' : 'Right'); 17019 17020 LazyWrapper.prototype[methodName] = function() { 17021 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 17022 }; 17023 }); 17024 17025 LazyWrapper.prototype.compact = function() { 17026 return this.filter(identity); 17027 }; 17028 17029 LazyWrapper.prototype.find = function(predicate) { 17030 return this.filter(predicate).head(); 17031 }; 17032 17033 LazyWrapper.prototype.findLast = function(predicate) { 17034 return this.reverse().find(predicate); 17035 }; 17036 17037 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 17038 if (typeof path == 'function') { 17039 return new LazyWrapper(this); 17040 } 17041 return this.map(function(value) { 17042 return baseInvoke(value, path, args); 17043 }); 17044 }); 17045 17046 LazyWrapper.prototype.reject = function(predicate) { 17047 return this.filter(negate(getIteratee(predicate))); 17048 }; 17049 17050 LazyWrapper.prototype.slice = function(start, end) { 17051 start = toInteger(start); 17052 17053 var result = this; 17054 if (result.__filtered__ && (start > 0 || end < 0)) { 17055 return new LazyWrapper(result); 17056 } 17057 if (start < 0) { 17058 result = result.takeRight(-start); 17059 } else if (start) { 17060 result = result.drop(start); 17061 } 17062 if (end !== undefined) { 17063 end = toInteger(end); 17064 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 17065 } 17066 return result; 17067 }; 17068 17069 LazyWrapper.prototype.takeRightWhile = function(predicate) { 17070 return this.reverse().takeWhile(predicate).reverse(); 17071 }; 17072 17073 LazyWrapper.prototype.toArray = function() { 17074 return this.take(MAX_ARRAY_LENGTH); 17075 }; 17076 17077 // Add `LazyWrapper` methods to `lodash.prototype`. 17078 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 17079 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 17080 isTaker = /^(?:head|last)$/.test(methodName), 17081 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 17082 retUnwrapped = isTaker || /^find/.test(methodName); 17083 17084 if (!lodashFunc) { 17085 return; 17086 } 17087 lodash.prototype[methodName] = function() { 17088 var value = this.__wrapped__, 17089 args = isTaker ? [1] : arguments, 17090 isLazy = value instanceof LazyWrapper, 17091 iteratee = args[0], 17092 useLazy = isLazy || isArray(value); 17093 17094 var interceptor = function(value) { 17095 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 17096 return (isTaker && chainAll) ? result[0] : result; 17097 }; 17098 17099 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 17100 // Avoid lazy use if the iteratee has a "length" value other than `1`. 17101 isLazy = useLazy = false; 17102 } 17103 var chainAll = this.__chain__, 17104 isHybrid = !!this.__actions__.length, 17105 isUnwrapped = retUnwrapped && !chainAll, 17106 onlyLazy = isLazy && !isHybrid; 17107 17108 if (!retUnwrapped && useLazy) { 17109 value = onlyLazy ? value : new LazyWrapper(this); 17110 var result = func.apply(value, args); 17111 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 17112 return new LodashWrapper(result, chainAll); 17113 } 17114 if (isUnwrapped && onlyLazy) { 17115 return func.apply(this, args); 17116 } 17117 result = this.thru(interceptor); 17118 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 17119 }; 17120 }); 17121 17122 // Add `Array` methods to `lodash.prototype`. 17123 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 17124 var func = arrayProto[methodName], 17125 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 17126 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 17127 17128 lodash.prototype[methodName] = function() { 17129 var args = arguments; 17130 if (retUnwrapped && !this.__chain__) { 17131 var value = this.value(); 17132 return func.apply(isArray(value) ? value : [], args); 17133 } 17134 return this[chainName](function(value) { 17135 return func.apply(isArray(value) ? value : [], args); 17136 }); 17137 }; 17138 }); 17139 17140 // Map minified method names to their real names. 17141 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 17142 var lodashFunc = lodash[methodName]; 17143 if (lodashFunc) { 17144 var key = lodashFunc.name + ''; 17145 if (!hasOwnProperty.call(realNames, key)) { 17146 realNames[key] = []; 17147 } 17148 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 17149 } 17150 }); 17151 17152 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 17153 'name': 'wrapper', 17154 'func': undefined 17155 }]; 17156 17157 // Add methods to `LazyWrapper`. 17158 LazyWrapper.prototype.clone = lazyClone; 17159 LazyWrapper.prototype.reverse = lazyReverse; 17160 LazyWrapper.prototype.value = lazyValue; 17161 17162 // Add chain sequence methods to the `lodash` wrapper. 17163 lodash.prototype.at = wrapperAt; 17164 lodash.prototype.chain = wrapperChain; 17165 lodash.prototype.commit = wrapperCommit; 17166 lodash.prototype.next = wrapperNext; 17167 lodash.prototype.plant = wrapperPlant; 17168 lodash.prototype.reverse = wrapperReverse; 17169 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 17170 17171 // Add lazy aliases. 17172 lodash.prototype.first = lodash.prototype.head; 17173 17174 if (symIterator) { 17175 lodash.prototype[symIterator] = wrapperToIterator; 17176 } 17177 return lodash; 17178 }); 17179 17180 /*--------------------------------------------------------------------------*/ 17181 17182 // Export lodash. 17183 var _ = runInContext(); 17184 17185 // Some AMD build optimizers, like r.js, check for condition patterns like: 17186 if (
17186false && typeof define == 'function' && typeof define.amd == 'object' && define.amd) { 17187 // Expose Lodash on the global object to prevent errors when Lodash is 17188 // loaded by a script tag in the presence of an AMD loader. 17189 // See http://requirejs.org/docs/errors.html#mismatch for more details. 17190 // Use `_.noConflict` to remove Lodash from the global object. 17191 root._ = _; 17192 17193 // Define as an anonymous module so, through path mapping, it can be 17194 // referenced as the "underscore" module. 17195 define(function() { 17196 return _; 17197 }); 17198 } 17199 // Check for `exports` after `define` in case a build optimizer adds it. 17200 else if (freeModule) { 17201 // Export for Node.js. 17202 (freeModule.exports = _)._ = _; 17203 // Export for CommonJS support. 17204 freeExports._ = _; 17205 } 17206 else { 17207 // Export to the global object. 17208 root._ = _; 17209 } 17210}.call(this));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.